From 11b21c6e25699bdfd49a0edaf0b8d3e709420479 Mon Sep 17 00:00:00 2001 From: Russell Date: Thu, 4 Jul 2024 21:57:53 -0500 Subject: [PATCH] character creation fixes --- scripts/apps/character-creation.js | 10 +++++----- scripts/model/actor/components/combat.js | 2 +- scripts/model/actor/components/standard.js | 2 +- scripts/model/item/archetype.js | 17 ++++++++++++++++- scripts/model/item/components/damage.js | 4 ++-- scripts/model/item/weapon.js | 10 ++++------ 6 files changed, 29 insertions(+), 16 deletions(-) diff --git a/scripts/apps/character-creation.js b/scripts/apps/character-creation.js index f1160a9..044dd1d 100644 --- a/scripts/apps/character-creation.js +++ b/scripts/apps/character-creation.js @@ -31,7 +31,7 @@ export default class CharacterCreation extends FormApplication { async initializeCharacter() { - this.character = await Actor.create({type: "agent", name : this.object.actor.name, system : game.system.model.Actor.agent}, {temporary : true}) // Temporary actor + this.character = await Actor.create({type: "agent", name : this.object.actor.name, system: foundry.utils.deepClone(game.release.generation == 12 ? game.system.template.Actor.agent : game.system.model.Actor.agent)}, {temporary : true}) // Temporary actor // Can't just merge object because actor attributes/skills are an object, archetype and species have just numbers for (let attribute in this.character.attributes) @@ -130,7 +130,7 @@ export default class CharacterCreation extends FormApplication { } } - html += groupToHTML(ArchetypeGroups.groupIndexToObjects(this.archetype.groups, this.archetype), html) + html += groupToHTML(ArchetypeGroups.groupIndexToObjects(this.archetype.system.groups, this.archetype), html) return html; } @@ -143,7 +143,7 @@ export default class CharacterCreation extends FormApplication { async chooseWargear(filter, id) { let element = this.element.find(`.generic[data-id=${filter.groupId}]`)[0] - let group = ArchetypeGroups.search(filter.groupId, this.archetype.groups) + let group = ArchetypeGroups.search(filter.groupId, this.archetype.system.groups) let wargearObject = this.archetype.wargear[group.index] let item = await game.wng.utility.findItem(id) @@ -256,7 +256,7 @@ export default class CharacterCreation extends FormApplication { this.element.find(".wargear-item.generic").each((i, e) => { if (!this.isDisabled(e)) { let id = e.dataset.id - let group = ArchetypeGroups.search(id, this.archetype.groups) + let group = ArchetypeGroups.search(id, this.archetype.system.groups) let wargear = this.archetype.wargear[group.index] if (wargear.filters.length) unresolvedGenerics = true; @@ -371,7 +371,7 @@ export default class CharacterCreation extends FormApplication { html.find(".wargear-item").click(async ev => { let id = ev.currentTarget.dataset.id - let group = ArchetypeGroups.search(id, this.archetype.groups) + let group = ArchetypeGroups.search(id, this.archetype.system.groups) let wargear = this.archetype.wargear[group.index] if (wargear.type == "generic" && wargear.filters.length) diff --git a/scripts/model/actor/components/combat.js b/scripts/model/actor/components/combat.js index 9c07ecf..39fdca7 100644 --- a/scripts/model/actor/components/combat.js +++ b/scripts/model/actor/components/combat.js @@ -48,7 +48,7 @@ export class CombatModel extends foundry.abstract.DataModel { let actor = this.parent.parent; let attributes = actor.system.attributes; let skills = actor.system.skills; - let autoCalc = actor.getFlag("wrath-and-glory", "autoCalc"); + let autoCalc = actor.getFlag("wrath-and-glory", "autoCalc") || {}; this.computeArmour(actor.itemTypes.armour, attributes); diff --git a/scripts/model/actor/components/standard.js b/scripts/model/actor/components/standard.js index ef8fa98..4a83e92 100644 --- a/scripts/model/actor/components/standard.js +++ b/scripts/model/actor/components/standard.js @@ -47,6 +47,6 @@ export class StandardWNGActorModel extends BaseActorModel { computeDerived() { this.attributes.compute(); this.skills.compute(this.attributes); - this.combat.compute(this.attributes, this.parent.getFlag("wrath-and-glory", "autoCalc")); + this.combat.compute(this.attributes, this.parent.getFlag("wrath-and-glory", "autoCalc") || {}); } } diff --git a/scripts/model/item/archetype.js b/scripts/model/item/archetype.js index 839f8ff..ee1569d 100644 --- a/scripts/model/item/archetype.js +++ b/scripts/model/item/archetype.js @@ -20,7 +20,7 @@ export class ArchetypeModel extends BaseItemModel schema.attributes = Attributes(); schema.skills = Skills(); schema.ability = new fields.EmbeddedDataField(DeferredDocumentReferenceModel) - schema.wargear = new fields.ArrayField(new fields.EmbeddedDataField(DeferredDocumentReferenceModel)) + schema.wargear = new fields.ArrayField(new fields.EmbeddedDataField(ArchetypeWargearModel)) schema.groups = new fields.SchemaField({ type : new fields.StringField({initial : "and"}), groupId : new fields.StringField({initial : "root"}), @@ -33,5 +33,20 @@ export class ArchetypeModel extends BaseItemModel }) return schema; } +} + +class ArchetypeWargearModel extends DeferredDocumentReferenceModel +{ + static defineSchema() + { + let schema = super.defineSchema(); + schema.type = new fields.StringField(); + schema.filters = new fields.ArrayField(new fields.SchemaField({ + test : new fields.StringField(), + property : new fields.StringField(), + value : new fields.StringField(), + })) + return schema; + } } \ No newline at end of file diff --git a/scripts/model/item/components/damage.js b/scripts/model/item/components/damage.js index 0c217ae..e3a8057 100644 --- a/scripts/model/item/components/damage.js +++ b/scripts/model/item/components/damage.js @@ -35,8 +35,8 @@ export class DamageModel extends foundry.abstract.DataModel get formatted() { let damage = Number(this._dataWithRank("damage")); - if (this.isMelee && this.isOwned) - damage += this.actor.attributes.strength.total + if (this.parent.isMelee && this.parent.parent.isOwned) + damage += this.parent.parent.actor?.attributes.strength.total || 0 return damage } get ED() { diff --git a/scripts/model/item/weapon.js b/scripts/model/item/weapon.js index 79af1cb..ff29799 100644 --- a/scripts/model/item/weapon.js +++ b/scripts/model/item/weapon.js @@ -51,10 +51,10 @@ export class WeaponModel extends EquippedItemModel get Range() { if (this.isRanged) { - if (this.category == "launcher" || this.category == "grenade-missile") + if (this.category == "grenade-missile") { - if (this.actor) - return this.range.thrown * this.actor.attributes.strength.total + if (this.parent.actor) + return this.range.thrown * this.parent.actor.attributes.strength.total else return `S x ${this.range.thrown}` } @@ -98,9 +98,7 @@ export class WeaponModel extends EquippedItemModel computeOwned() { if (this.isRanged && this.category == "launcher" && this.Ammo) { - this.system = this.Ammo.system.damage - this.system.ap = this.Ammo.system.damage.ap - this.system.ed = this.Ammo.system.damage.ed + this.damage = this.Ammo.system.damage } if (this.isRanged && this.Ammo) { this.applyAmmo()