mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-18 16:09:03 +01:00
Added use of ItemLinkFields
This commit is contained in:
parent
8cdad5172e
commit
569e567dfd
18 changed files with 232 additions and 288 deletions
|
|
@ -340,10 +340,7 @@ export default class DhCharacterCreation extends HandlebarsApplicationMixin(Appl
|
|||
})
|
||||
};
|
||||
context.traits.nrTotal = Object.keys(context.traits.values).length;
|
||||
context.traits.nrSelected = Object.values(context.traits.values).reduce(
|
||||
(acc, trait) => acc + (trait.value !== null ? 1 : 0),
|
||||
0
|
||||
);
|
||||
context.traits.nrSelected = this.getNrSelectedTrait();
|
||||
|
||||
context.experience = {
|
||||
values: this.setup.experiences,
|
||||
|
|
@ -397,6 +394,10 @@ export default class DhCharacterCreation extends HandlebarsApplicationMixin(Appl
|
|||
choiceA: { suggestions: suggestions.inventory.choiceA, compendium: 'consumables' },
|
||||
choiceB: { suggestions: suggestions.inventory.choiceB, compendium: 'general-items' }
|
||||
};
|
||||
context.noInventoryChoices =
|
||||
suggestions.inventory.take.length === 0 &&
|
||||
suggestions.inventory.choiceA?.length === 0 &&
|
||||
suggestions.inventory.choiceB?.length === 0;
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
@ -427,7 +428,7 @@ export default class DhCharacterCreation extends HandlebarsApplicationMixin(Appl
|
|||
case 5:
|
||||
return Object.values(this.setup.experiences).every(x => x.name) ? 6 : 5;
|
||||
case 4:
|
||||
return Object.values(this.setup.traits).every(x => x.value !== null) ? 5 : 4;
|
||||
return this.getNrSelectedTrait() === 6 ? 5 : 4;
|
||||
case 3:
|
||||
return this.setup.class.uuid && this.setup.subclass.uuid ? 4 : 3;
|
||||
case 2:
|
||||
|
|
@ -437,6 +438,18 @@ export default class DhCharacterCreation extends HandlebarsApplicationMixin(Appl
|
|||
}
|
||||
}
|
||||
|
||||
getNrSelectedTrait() {
|
||||
const traitCompareArray = [
|
||||
...game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew).traitArray
|
||||
];
|
||||
return Object.values(this.setup.traits).reduce((acc, x) => {
|
||||
const index = traitCompareArray.indexOf(x.value);
|
||||
traitCompareArray.splice(index, 1);
|
||||
acc += index !== -1;
|
||||
return acc;
|
||||
}, 0);
|
||||
}
|
||||
|
||||
async getEquipmentSuggestions(choiceA, choiceB) {
|
||||
if (!this.setup.class.uuid) return { inventory: { take: [] } };
|
||||
|
||||
|
|
@ -448,10 +461,15 @@ export default class DhCharacterCreation extends HandlebarsApplicationMixin(Appl
|
|||
? { ...characterGuide.suggestedSecondaryWeapon, uuid: characterGuide.suggestedSecondaryWeapon.uuid }
|
||||
: null,
|
||||
inventory: {
|
||||
take: inventory.take ?? [],
|
||||
take: inventory.take?.filter(x => x) ?? [],
|
||||
choiceA:
|
||||
inventory.choiceA?.map(x => ({ ...x, uuid: x.uuid, selected: x.uuid === choiceA?.uuid })) ?? [],
|
||||
choiceB: inventory.choiceB?.map(x => ({ ...x, uuid: x.uuid, selected: x.uuid === choiceB?.uuid })) ?? []
|
||||
inventory.choiceA
|
||||
?.filter(x => x)
|
||||
.map(x => ({ ...x, uuid: x.uuid, selected: x.uuid === choiceA?.uuid })) ?? [],
|
||||
choiceB:
|
||||
inventory.choiceB
|
||||
?.filter(x => x)
|
||||
.map(x => ({ ...x, uuid: x.uuid, selected: x.uuid === choiceB?.uuid })) ?? []
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -525,7 +543,10 @@ export default class DhCharacterCreation extends HandlebarsApplicationMixin(Appl
|
|||
name: this.setup.ancestryName ?? this.setup.primaryAncestry.name,
|
||||
system: {
|
||||
...this.setup.primaryAncestry.system,
|
||||
features: [primaryAncestryFeature.uuid, secondaryAncestryFeature.uuid]
|
||||
features: [
|
||||
{ type: 'primary', item: primaryAncestryFeature.uuid },
|
||||
{ type: 'secondary', item: secondaryAncestryFeature.uuid }
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -554,7 +575,10 @@ export default class DhCharacterCreation extends HandlebarsApplicationMixin(Appl
|
|||
await this.character.createEmbeddedDocuments('Item', [this.equipment.inventory.choiceA]);
|
||||
if (this.equipment.inventory.choiceB.uuid)
|
||||
await this.character.createEmbeddedDocuments('Item', [this.equipment.inventory.choiceB]);
|
||||
await this.character.createEmbeddedDocuments('Item', this.setup.class.system.inventory.take);
|
||||
await this.character.createEmbeddedDocuments(
|
||||
'Item',
|
||||
this.setup.class.system.inventory.take.filter(x => x)
|
||||
);
|
||||
|
||||
await this.character.update({
|
||||
system: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue