mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-04-24 08:23:38 +02:00
Merged with feature/custom-resources
This commit is contained in:
commit
5e6b0f9a75
10 changed files with 28 additions and 31 deletions
|
|
@ -1003,10 +1003,10 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const element of html.querySelectorAll('.resource-value'))
|
for (const element of html.querySelectorAll('.resource-value'))
|
||||||
element.addEventListener('click', this.updateResource.bind(this));
|
element.addEventListener('click', this.onUpdateResource.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateResource(event) {
|
async onUpdateResource(event) {
|
||||||
const target = event.target.closest('.resource-value');
|
const target = event.target.closest('.resource-value');
|
||||||
const { resource, value: textValue } = target.dataset;
|
const { resource, value: textValue } = target.dataset;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,18 +57,6 @@ export const abilities = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getScrollingTextResources = actorType => ({
|
|
||||||
armor: {
|
|
||||||
label: 'DAGGERHEART.GENERAL.armor',
|
|
||||||
reverse: true
|
|
||||||
},
|
|
||||||
...(actorType === 'character'
|
|
||||||
? allCharacterResources()
|
|
||||||
: actorType === 'adversary'
|
|
||||||
? allAdversaryResources
|
|
||||||
: allCompanionResources)
|
|
||||||
});
|
|
||||||
|
|
||||||
export const featureProperties = {
|
export const featureProperties = {
|
||||||
agility: {
|
agility: {
|
||||||
name: 'DAGGERHEART.CONFIG.Traits.agility.name',
|
name: 'DAGGERHEART.CONFIG.Traits.agility.name',
|
||||||
|
|
|
||||||
|
|
@ -187,6 +187,7 @@ export default class DhpAdversary extends DhCreature {
|
||||||
}
|
}
|
||||||
|
|
||||||
prepareDerivedData() {
|
prepareDerivedData() {
|
||||||
|
super.prepareDerivedData();
|
||||||
this.attack.roll.isStandardAttack = true;
|
this.attack.roll.isStandardAttack = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -213,7 +213,7 @@ export default class BaseDataActor extends foundry.abstract.TypeDataModel {
|
||||||
const textData = Object.keys(changes.system.resources).reduce((acc, key) => {
|
const textData = Object.keys(changes.system.resources).reduce((acc, key) => {
|
||||||
const resource = changes.system.resources[key];
|
const resource = changes.system.resources[key];
|
||||||
if (resource.value !== undefined && resource.value !== this.resources[key].value) {
|
if (resource.value !== undefined && resource.value !== this.resources[key].value) {
|
||||||
acc.push(getScrollTextData(this.resources, resource, key, this.parent.type));
|
acc.push(getScrollTextData(this.parent, resource, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
return acc;
|
return acc;
|
||||||
|
|
|
||||||
|
|
@ -658,6 +658,7 @@ export default class DhCharacter extends DhCreature {
|
||||||
}
|
}
|
||||||
|
|
||||||
prepareDerivedData() {
|
prepareDerivedData() {
|
||||||
|
super.prepareDerivedData();
|
||||||
let baseHope = this.resources.hope.value;
|
let baseHope = this.resources.hope.value;
|
||||||
if (this.companion) {
|
if (this.companion) {
|
||||||
for (let levelKey in this.companion.system.levelData.levelups) {
|
for (let levelKey in this.companion.system.levelData.levelups) {
|
||||||
|
|
@ -677,6 +678,7 @@ export default class DhCharacter extends DhCreature {
|
||||||
this.attack.roll.trait = this.rules.attack.roll.trait ?? this.attack.roll.trait;
|
this.attack.roll.trait = this.rules.attack.roll.trait ?? this.attack.roll.trait;
|
||||||
|
|
||||||
this.resources.armor = {
|
this.resources.armor = {
|
||||||
|
label: 'DAGGERHEART.GENERAL.armor',
|
||||||
value: this.armor?.system?.marks?.value ?? 0,
|
value: this.armor?.system?.marks?.value ?? 0,
|
||||||
max: this.armorScore,
|
max: this.armorScore,
|
||||||
isReversed: true
|
isReversed: true
|
||||||
|
|
|
||||||
|
|
@ -157,6 +157,7 @@ export default class DhCompanion extends DhCreature {
|
||||||
}
|
}
|
||||||
|
|
||||||
prepareDerivedData() {
|
prepareDerivedData() {
|
||||||
|
super.prepareDerivedData();
|
||||||
/* Partner Related Setup */
|
/* Partner Related Setup */
|
||||||
if (this.partner) {
|
if (this.partner) {
|
||||||
this.levelData.level.changed = this.partner.system.levelData.level.current;
|
this.levelData.level.changed = this.partner.system.levelData.level.current;
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@ export default class DhCreature extends BaseDataActor {
|
||||||
resource.max,
|
resource.max,
|
||||||
resource.initial,
|
resource.initial,
|
||||||
resource.label,
|
resource.label,
|
||||||
resource.reverse,
|
|
||||||
resource.maxLabel
|
resource.maxLabel
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -57,6 +56,17 @@ export default class DhCreature extends BaseDataActor {
|
||||||
return !vulnerableAppliedByOther;
|
return !vulnerableAppliedByOther;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prepareDerivedData() {
|
||||||
|
super.prepareDerivedData();
|
||||||
|
const resources = CONFIG.DH.RESOURCE[`all${this.parent.type.capitalize()}Resources`]();
|
||||||
|
if (resources) {
|
||||||
|
for (const [key, value] of Object.entries(this.resources)) {
|
||||||
|
value.label = resources[key]?.label;
|
||||||
|
value.isReversed = resources[key]?.reverse;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async _preUpdate(changes, options, userId) {
|
async _preUpdate(changes, options, userId) {
|
||||||
const allowed = await super._preUpdate(changes, options, userId);
|
const allowed = await super._preUpdate(changes, options, userId);
|
||||||
if (allowed === false) return;
|
if (allowed === false) return;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ const attributeField = label =>
|
||||||
tierMarked: new fields.BooleanField({ initial: false })
|
tierMarked: new fields.BooleanField({ initial: false })
|
||||||
});
|
});
|
||||||
|
|
||||||
const resourceField = (max = 0, initial = 0, label, reverse = false, maxLabel) =>
|
const resourceField = (max = 0, initial = 0, label, maxLabel) =>
|
||||||
new fields.SchemaField(
|
new fields.SchemaField(
|
||||||
{
|
{
|
||||||
value: new fields.NumberField({ initial: initial, min: 0, integer: true, label }),
|
value: new fields.NumberField({ initial: initial, min: 0, integer: true, label }),
|
||||||
|
|
@ -16,8 +16,7 @@ const resourceField = (max = 0, initial = 0, label, reverse = false, maxLabel) =
|
||||||
label:
|
label:
|
||||||
maxLabel ??
|
maxLabel ??
|
||||||
game.i18n.format('DAGGERHEART.GENERAL.maxWithThing', { thing: game.i18n.localize(label) })
|
game.i18n.format('DAGGERHEART.GENERAL.maxWithThing', { thing: game.i18n.localize(label) })
|
||||||
}),
|
})
|
||||||
isReversed: new fields.BooleanField({ initial: reverse })
|
|
||||||
},
|
},
|
||||||
{ label }
|
{ label }
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -224,12 +224,7 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
|
||||||
const armorChanged =
|
const armorChanged =
|
||||||
changed.system?.marks?.value !== undefined && changed.system.marks.value !== this.marks.value;
|
changed.system?.marks?.value !== undefined && changed.system.marks.value !== this.marks.value;
|
||||||
if (armorChanged && autoSettings.resourceScrollTexts && this.parent.parent?.type === 'character') {
|
if (armorChanged && autoSettings.resourceScrollTexts && this.parent.parent?.type === 'character') {
|
||||||
const armorData = getScrollTextData(
|
const armorData = getScrollTextData(this.parent.parent, changed.system.marks, 'armor');
|
||||||
this.parent.parent.system.resources,
|
|
||||||
changed.system.marks,
|
|
||||||
'armor',
|
|
||||||
this.parent.parent.type
|
|
||||||
);
|
|
||||||
options.scrollingTextData = [armorData];
|
options.scrollingTextData = [armorData];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -378,17 +378,18 @@ export const arraysEqual = (a, b) =>
|
||||||
|
|
||||||
export const setsEqual = (a, b) => a.size === b.size && [...a].every(value => b.has(value));
|
export const setsEqual = (a, b) => a.size === b.size && [...a].every(value => b.has(value));
|
||||||
|
|
||||||
export function getScrollTextData(resources, resource, key, actorType) {
|
export function getScrollTextData(actor, resource, key) {
|
||||||
const { reverse, label } = CONFIG.DH.ACTOR.getScrollingTextResources(actorType)[key];
|
|
||||||
const { BOTTOM, TOP } = CONST.TEXT_ANCHOR_POINTS;
|
const { BOTTOM, TOP } = CONST.TEXT_ANCHOR_POINTS;
|
||||||
|
|
||||||
|
const resources = actor.system.resources;
|
||||||
const increased = resources[key].value < resource.value;
|
const increased = resources[key].value < resource.value;
|
||||||
const value = -1 * (resources[key].value - resource.value);
|
const value = -1 * (resources[key].value - resource.value);
|
||||||
|
const { label, isReversed } = resources[key];
|
||||||
|
|
||||||
const text = `${game.i18n.localize(label)} ${value.signedString()}`;
|
const text = `${game.i18n.localize(label)} ${value.signedString()}`;
|
||||||
|
const stroke = increased ? (isReversed ? 0xffffff : 0x000000) : isReversed ? 0x000000 : 0xffffff;
|
||||||
const stroke = increased ? (reverse ? 0xffffff : 0x000000) : reverse ? 0x000000 : 0xffffff;
|
const fill = increased ? (isReversed ? 0x0032b1 : 0xffe760) : isReversed ? 0xffe760 : 0x0032b1;
|
||||||
const fill = increased ? (reverse ? 0x0032b1 : 0xffe760) : reverse ? 0xffe760 : 0x0032b1;
|
const direction = increased ? (isReversed ? BOTTOM : TOP) : isReversed ? TOP : BOTTOM;
|
||||||
const direction = increased ? (reverse ? BOTTOM : TOP) : reverse ? TOP : BOTTOM;
|
|
||||||
|
|
||||||
return { text, stroke, fill, direction };
|
return { text, stroke, fill, direction };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue