mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
Feature/666 experience hope cost (#728)
* h * Character & Companion Experience Hope Cost
This commit is contained in:
parent
f9cb0954f9
commit
45b3569cba
7 changed files with 61 additions and 13 deletions
|
|
@ -47,6 +47,7 @@ export default class CostField extends fields.ArrayField {
|
|||
static hasCost(costs) {
|
||||
const realCosts = CostField.getRealCosts.call(this, costs),
|
||||
hasFearCost = realCosts.findIndex(c => c.key === 'fear');
|
||||
|
||||
if (hasFearCost > -1) {
|
||||
const fearCost = realCosts.splice(hasFearCost, 1)[0];
|
||||
if (
|
||||
|
|
@ -70,7 +71,8 @@ export default class CostField extends fields.ArrayField {
|
|||
}
|
||||
|
||||
static getResources(costs) {
|
||||
const actorResources = this.actor.system.resources;
|
||||
const actorResources = foundry.utils.deepClone(this.actor.system.resources);
|
||||
if(this.actor.system.partner) actorResources.hope = foundry.utils.deepClone(this.actor.system.partner.system.resources.hope);
|
||||
const itemResources = {};
|
||||
for (let itemResource of costs) {
|
||||
if (itemResource.keyIsID) {
|
||||
|
|
@ -89,7 +91,13 @@ export default class CostField extends fields.ArrayField {
|
|||
|
||||
static getRealCosts(costs) {
|
||||
const realCosts = costs?.length ? costs.filter(c => c.enabled) : [];
|
||||
return realCosts;
|
||||
let mergedCosts = [];
|
||||
realCosts.forEach(c => {
|
||||
const getCost = Object.values(mergedCosts).find(gc => gc.key === c.key);
|
||||
if(getCost) getCost.total += c.total;
|
||||
else mergedCosts.push(c);
|
||||
});
|
||||
return mergedCosts;
|
||||
}
|
||||
|
||||
static formatMax(max) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue