Merge remote-tracking branch 'origin/master' into 008-chatRollInterface
This commit is contained in:
commit
c89278992f
43 changed files with 1137 additions and 640 deletions
|
@ -4,6 +4,8 @@ export interface DS4ActorDataType {
|
|||
combatValues: DS4ActorDataCombatValues;
|
||||
baseInfo: DS4ActorDataBaseInfo;
|
||||
progression: DS4ActorDataProgression;
|
||||
language: DS4ActorDataLanguage;
|
||||
profile: DS4ActorDataProfile;
|
||||
}
|
||||
|
||||
interface DS4ActorDataAttributes {
|
||||
|
@ -23,8 +25,9 @@ interface UsableResource<T> {
|
|||
used: T;
|
||||
}
|
||||
|
||||
interface CurrentData<T> extends ModifiableData<T> {
|
||||
current: T;
|
||||
interface ResourceData<T> extends ModifiableData<T> {
|
||||
value: T;
|
||||
max?: T;
|
||||
}
|
||||
|
||||
// Blueprint in case we need more detailed differentiation
|
||||
|
@ -40,7 +43,7 @@ interface DS4ActorDataTraits {
|
|||
}
|
||||
|
||||
interface DS4ActorDataCombatValues {
|
||||
hitPoints: CurrentData<number>;
|
||||
hitPoints: ResourceData<number>;
|
||||
defense: ModifiableData<number>;
|
||||
initiative: ModifiableData<number>;
|
||||
movement: ModifiableData<number>;
|
||||
|
@ -55,6 +58,7 @@ interface DS4ActorDataBaseInfo {
|
|||
class: string;
|
||||
heroClass: string;
|
||||
racialAbilities: string;
|
||||
culture: string;
|
||||
}
|
||||
|
||||
interface DS4ActorDataProgression {
|
||||
|
@ -63,3 +67,20 @@ interface DS4ActorDataProgression {
|
|||
talentPoints: UsableResource<number>;
|
||||
progressPoints: UsableResource<number>;
|
||||
}
|
||||
|
||||
interface DS4ActorDataLanguage {
|
||||
languages: string;
|
||||
alphabets: string;
|
||||
}
|
||||
|
||||
interface DS4ActorDataProfile {
|
||||
gender: string;
|
||||
birthday: string;
|
||||
birthplace: string;
|
||||
age: number;
|
||||
height: number;
|
||||
hairColor: string;
|
||||
weight: number;
|
||||
eyeColor: string;
|
||||
specialCharacteristics: string;
|
||||
}
|
||||
|
|
|
@ -18,5 +18,7 @@ export class DS4Actor extends Actor<DS4ActorDataType, DS4ItemDataType, DS4Item>
|
|||
Object.values(combatValues).forEach(
|
||||
(combatValue: ModifiableData<number>) => (combatValue.total = combatValue.base + combatValue.mod),
|
||||
);
|
||||
|
||||
combatValues.hitPoints.max = combatValues.hitPoints.total;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,8 @@ export const DS4 = {
|
|||
shield: "DS4.ItemTypeShield",
|
||||
trinket: "DS4.ItemTypeTrinket",
|
||||
equipment: "DS4.ItemTypeEquipment",
|
||||
talent: "DS4.ItemTypeTalent",
|
||||
racialAbility: "DS4.ItemTypeRacialAbility",
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -135,10 +137,11 @@ export const DS4 = {
|
|||
class: "DS4.BaseInfoClass",
|
||||
heroClass: "DS4.BaseInfoHeroClass",
|
||||
racialAbilities: "DS4.BaseInfoRacialAbilities",
|
||||
culture: "DS4.BaseInfoCulture",
|
||||
},
|
||||
|
||||
/**
|
||||
* Definme the progression info of a character
|
||||
* Define the progression info of a character
|
||||
*/
|
||||
progression: {
|
||||
level: "DS4.ProgressionLevel",
|
||||
|
@ -146,4 +149,42 @@ export const DS4 = {
|
|||
talentPoints: "DS4.ProgressionTalentPoints",
|
||||
progressPoints: "DS4.ProgressionProgressPoints",
|
||||
},
|
||||
|
||||
/**
|
||||
* Define the language info of a character
|
||||
*/
|
||||
language: {
|
||||
languages: "DS4.LanguageLanguages",
|
||||
alphabets: "DS4.LanguageAlphabets",
|
||||
},
|
||||
|
||||
/**
|
||||
* Define the profile info of a character
|
||||
*/
|
||||
profile: {
|
||||
gender: "DS4.ProfileGender",
|
||||
birthday: "DS4.ProfileBirthday",
|
||||
birthplace: "DS4.ProfileBirthplace",
|
||||
age: "DS4.ProfileAge",
|
||||
height: "DS4.ProfileHeight",
|
||||
hairColor: "DS4.ProfilHairColor",
|
||||
weight: "DS4.ProfileWeight",
|
||||
eyeColor: "DS4.ProfileEyeColor",
|
||||
specialCharacteristics: "DS4.ProfileSpecialCharacteristics",
|
||||
},
|
||||
|
||||
/**
|
||||
* Define the profile info types for hanndlebars of a character
|
||||
*/
|
||||
profileDTypes: {
|
||||
gender: "String",
|
||||
birthday: "String",
|
||||
birthplace: "String",
|
||||
age: "Number",
|
||||
height: "Number",
|
||||
hairColor: "String",
|
||||
weight: "Number",
|
||||
eyeColor: "String",
|
||||
specialCharacteristics: "String",
|
||||
},
|
||||
};
|
||||
|
|
|
@ -46,8 +46,13 @@ async function registerHandlebarsPartials() {
|
|||
"systems/ds4/templates/item/partials/effects.hbs",
|
||||
"systems/ds4/templates/item/partials/body.hbs",
|
||||
"systems/ds4/templates/actor/partials/items-overview.hbs",
|
||||
"systems/ds4/templates/actor/partials/talents-overview.hbs",
|
||||
"systems/ds4/templates/actor/partials/overview-add-button.hbs",
|
||||
"systems/ds4/templates/actor/partials/overview-control-buttons.hbs",
|
||||
"systems/ds4/templates/actor/partials/attributes-traits.hbs",
|
||||
"systems/ds4/templates/actor/partials/combat-values.hbs",
|
||||
"systems/ds4/templates/actor/partials/profile.hbs",
|
||||
"systems/ds4/templates/actor/partials/character-progression.hbs",
|
||||
];
|
||||
return loadTemplates(templatePaths);
|
||||
}
|
||||
|
@ -75,6 +80,8 @@ Hooks.once("setup", function () {
|
|||
"combatValues",
|
||||
"baseInfo",
|
||||
"progression",
|
||||
"language",
|
||||
"profile",
|
||||
];
|
||||
|
||||
// Exclude some from sorting where the default order matters
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
// TODO: Actually add a type for data
|
||||
export type DS4ItemDataType = DS4Weapon | DS4Armor | DS4Shield | DS4Trinket | DS4Equipment;
|
||||
import { ModifiableData } from "../actor/actor-data";
|
||||
|
||||
export type DS4ItemDataType =
|
||||
| DS4Weapon
|
||||
| DS4Armor
|
||||
| DS4Shield
|
||||
| DS4Trinket
|
||||
| DS4Equipment
|
||||
| DS4Talent
|
||||
| DS4RacialAbility;
|
||||
|
||||
// types
|
||||
|
||||
|
@ -14,9 +22,18 @@ interface DS4Armor extends DS4ItemBase, DS4ItemPhysical, DS4ItemEquipable, DS4It
|
|||
armorType: "body" | "helmet" | "vambrace" | "greaves" | "vambraceGreaves";
|
||||
}
|
||||
|
||||
export interface DS4Talent extends DS4ItemBase {
|
||||
rank: DS4TalentRank;
|
||||
}
|
||||
|
||||
interface DS4TalentRank extends ModifiableData<number> {
|
||||
max: number;
|
||||
}
|
||||
|
||||
interface DS4Shield extends DS4ItemBase, DS4ItemPhysical, DS4ItemEquipable, DS4ItemProtective {}
|
||||
interface DS4Trinket extends DS4ItemBase, DS4ItemPhysical, DS4ItemEquipable {}
|
||||
interface DS4Equipment extends DS4ItemBase, DS4ItemPhysical {}
|
||||
type DS4RacialAbility = DS4ItemBase;
|
||||
|
||||
// templates
|
||||
|
||||
|
@ -30,6 +47,10 @@ interface DS4ItemPhysical {
|
|||
storageLocation: string;
|
||||
}
|
||||
|
||||
export function isDS4ItemDataTypePhysical(input: DS4ItemDataType): boolean {
|
||||
return "quantity" in input && "price" in input && "availability" in input && "storageLocation" in input;
|
||||
}
|
||||
|
||||
interface DS4ItemEquipable {
|
||||
equipped: boolean;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { DS4Item } from "./item";
|
||||
import { DS4ItemDataType } from "./item-data";
|
||||
import { DS4ItemDataType, isDS4ItemDataTypePhysical } from "./item-data";
|
||||
|
||||
/**
|
||||
* Extend the basic ItemSheet with some very simple modifications
|
||||
|
@ -26,7 +26,13 @@ export class DS4ItemSheet extends ItemSheet<DS4ItemDataType, DS4Item> {
|
|||
|
||||
/** @override */
|
||||
getData(): ItemSheetData<DS4ItemDataType, DS4Item> {
|
||||
const data = { ...super.getData(), config: CONFIG.DS4, isOwned: this.item.isOwned, actor: this.item.actor };
|
||||
const data = {
|
||||
...super.getData(),
|
||||
config: CONFIG.DS4,
|
||||
isOwned: this.item.isOwned,
|
||||
actor: this.item.actor,
|
||||
isPhysical: isDS4ItemDataTypePhysical(this.item.data.data),
|
||||
};
|
||||
console.log(data);
|
||||
return data;
|
||||
}
|
||||
|
@ -54,29 +60,38 @@ export class DS4ItemSheet extends ItemSheet<DS4ItemDataType, DS4Item> {
|
|||
|
||||
if (!this.options.editable) return;
|
||||
|
||||
html.find(".effect-create").on("click", this._onEffectCreate.bind(this));
|
||||
|
||||
html.find(".effect-edit").on("click", (ev) => {
|
||||
const li = $(ev.currentTarget).parents(".effect");
|
||||
console.log(li.data("effectId"));
|
||||
const effect = this.item.effects.get(li.data("effectId"));
|
||||
effect.sheet.render(true);
|
||||
});
|
||||
|
||||
html.find(".effect-delete").on("click", async (ev) => {
|
||||
const li = $(ev.currentTarget).parents(".effect");
|
||||
await this.item.deleteEmbeddedEntity("ActiveEffect", li.data("effectId"));
|
||||
});
|
||||
html.find(".effect-control").on("click", this._onManageActiveEffect.bind(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle creating a new ActiveEffect for the item using initial data defined in the HTML dataset
|
||||
* Handle management of ActiveEffects.
|
||||
* @param {Event} event The originating click event
|
||||
* @private
|
||||
*/
|
||||
private async _onEffectCreate(event: JQuery.ClickEvent): Promise<unknown> {
|
||||
private async _onManageActiveEffect(event: JQuery.ClickEvent): Promise<unknown> {
|
||||
event.preventDefault();
|
||||
|
||||
if (this.item.isOwned) {
|
||||
return ui.notifications.warn(game.i18n.localize("DS4.WarningManageActiveEffectOnOwnedItem"));
|
||||
}
|
||||
const a = event.currentTarget;
|
||||
const li = $(a).parents(".effect");
|
||||
|
||||
switch (a.dataset["action"]) {
|
||||
case "create":
|
||||
return this._createActiveEffect();
|
||||
case "edit":
|
||||
const effect = this.item.effects.get(li.data("effectId"));
|
||||
return effect.sheet.render(true);
|
||||
case "delete": {
|
||||
return this.item.deleteEmbeddedEntity("ActiveEffect", li.data("effectId"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new ActiveEffect for the item using default data.
|
||||
*/
|
||||
private async _createActiveEffect(): Promise<unknown> {
|
||||
const label = `New Effect`;
|
||||
|
||||
const createData = {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { DS4Actor } from "../actor/actor";
|
||||
import { DS4ActorDataType } from "../actor/actor-data";
|
||||
import { DS4ItemDataType } from "./item-data";
|
||||
import { DS4ItemDataType, DS4Talent } from "./item-data";
|
||||
|
||||
/**
|
||||
* Extend the basic Item with some very simple modifications.
|
||||
|
@ -12,10 +12,18 @@ export class DS4Item extends Item<DS4ItemDataType, DS4ActorDataType, DS4Actor> {
|
|||
*/
|
||||
prepareData(): void {
|
||||
super.prepareData();
|
||||
this.prepareDerivedData();
|
||||
|
||||
// Get the Item's data
|
||||
// const itemData = this.data;
|
||||
// const actorData = this.actor ? this.actor.data : {};
|
||||
// const data = itemData.data;
|
||||
}
|
||||
|
||||
prepareDerivedData(): void {
|
||||
if (this.type === "talent") {
|
||||
const data = this.data.data as DS4Talent;
|
||||
data.rank.total = data.rank.base + data.rank.mod;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue