Skip to content

Commit

Permalink
character creation fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
moo-man committed Jul 5, 2024
1 parent c5b3c27 commit 11b21c6
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 16 deletions.
10 changes: 5 additions & 5 deletions scripts/apps/character-creation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}

Expand All @@ -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)

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion scripts/model/actor/components/combat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion scripts/model/actor/components/standard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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") || {});
}
}
17 changes: 16 additions & 1 deletion scripts/model/item/archetype.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"}),
Expand All @@ -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;
}
}
4 changes: 2 additions & 2 deletions scripts/model/item/components/damage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
10 changes: 4 additions & 6 deletions scripts/model/item/weapon.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
}
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 11b21c6

Please sign in to comment.