From 62aba86dfb6cfe3346f7cf1c8827ebfff22c3a7f Mon Sep 17 00:00:00 2001 From: Aliharu Date: Sun, 9 Jun 2024 09:31:25 -0600 Subject: [PATCH] Bug fixes --- module/actor/actor-sheet.js | 20 +++++++++------ module/apps/character-builder.js | 43 ++++++++++++++++++++++---------- module/apps/dice-roller.js | 4 +-- system.json | 4 +-- 4 files changed, 46 insertions(+), 25 deletions(-) diff --git a/module/actor/actor-sheet.js b/module/actor/actor-sheet.js index c1cfa211..68d43493 100644 --- a/module/actor/actor-sheet.js +++ b/module/actor/actor-sheet.js @@ -531,7 +531,7 @@ export class ExaltedThirdActorSheet extends ActorSheet { endings: 0, } // Iterate through items, allocating to containers - for (let i of actorData.items) { + for (let i of sheetData.items) { i.img = i.img || DEFAULT_TOKEN; if (i.type === 'item') { gear.push(i); @@ -580,13 +580,6 @@ export class ExaltedThirdActorSheet extends ActorSheet { else if (i.type === 'shape') { shapes.push(i); } - else if (i.type === 'spell') { - if (i.system.circle !== undefined) { - spells[i.system.circle].list.push(i); - spells[i.system.circle].visible = true; - spells[i.system.circle].collapse = this.actor.spells ? this.actor.spells[i.system.circle].collapse : true; - } - } else if (i.type === 'action') { actions.push(i); } @@ -594,6 +587,17 @@ export class ExaltedThirdActorSheet extends ActorSheet { activeItems.push(i); } } + let actorSpells = actorData.items.filter((item) => item.type === 'spell'); + actorSpells = actorSpells.sort(function (a, b) { + return a.name < b.name ? -1 : a.name > b.name ? 1 : 0; + }); + for (let i of actorSpells) { + if (i.system.circle !== undefined) { + spells[i.system.circle].list.push(i); + spells[i.system.circle].visible = true; + spells[i.system.circle].collapse = this.actor.spells ? this.actor.spells[i.system.circle].collapse : true; + } + } let actorCharms = actorData.items.filter((item) => item.type === 'charm'); actorCharms = actorCharms.sort(function (a, b) { diff --git a/module/apps/character-builder.js b/module/apps/character-builder.js index 3cd7c832..d0c4c37b 100644 --- a/module/apps/character-builder.js +++ b/module/apps/character-builder.js @@ -592,8 +592,22 @@ export default class CharacterBuilder extends FormApplication { html.find(".add-item").on("click", async (event) => { const type = event.currentTarget.dataset.type; + let listIndex = 0; + let indexAdd = "0"; + let indexType = type; + if(type === 'weapons') { + indexType = 'randomWeapons'; + } + for (const key of Object.keys(this.object.character[indexType])) { + if (key !== listIndex.toString()) { + break; + } + listIndex++; + } + indexAdd = listIndex.toString(); + if (type === 'specialties') { - this.object.character.specialties[Object.entries(this.object.character['specialties']).length] = { + this.object.character.specialties[indexAdd] = { name: 'Specialty', system: { ability: 'archery', @@ -601,7 +615,7 @@ export default class CharacterBuilder extends FormApplication { }; } else if (type === 'weapons') { - this.object.character.randomWeapons[Object.entries(this.object.character['randomWeapons']).length] = { + this.object.character.randomWeapons[indexAdd] = { type: "random", weaponType: "any", weight: "any", @@ -609,7 +623,7 @@ export default class CharacterBuilder extends FormApplication { }; } else if (type === 'intimacies') { - this.object.character[type][Object.entries(this.object.character[type]).length] = { + this.object.character[type][indexAdd] = { name: 'Name', system: { strength: 'minor', @@ -617,16 +631,8 @@ export default class CharacterBuilder extends FormApplication { } }; } - else if (type === 'merits') { - this.object.character[type][Object.entries(this.object.character[type]).length] = { - name: 'Name', - system: { - points: 0, - } - }; - } else { - this.object.character[type][Object.entries(this.object.character[type]).length] = { + this.object.character[type][indexAdd] = { name: 'Name', system: { points: 0, @@ -903,7 +909,18 @@ export default class CharacterBuilder extends FormApplication { } } else { - this.object.character[type][Object.entries(this.object.character[type]).length] = newItem; + if (newItem) { + let listIndex = 0; + let indexAdd = "0"; + for (const key of Object.keys(this.object.character[type])) { + if (key !== listIndex.toString()) { + break; + } + listIndex++; + } + indexAdd = listIndex.toString(); + this.object.character[type][indexAdd] = newItem; + } } this.onChange(ev); diff --git a/module/apps/dice-roller.js b/module/apps/dice-roller.js index 0d8335fd..f179378c 100644 --- a/module/apps/dice-roller.js +++ b/module/apps/dice-roller.js @@ -474,7 +474,7 @@ export class RollForm extends FormApplication { if (this.actor.merits.some(merit => Object.keys(merit.system.triggers.dicerollertriggers)?.length > 0)) { this.object.charmList['merits'] = { name: game.i18n.localize("Ex3.Merits"), - list: this.actor.merits.filter(merit => Object.keys(merit.system.triggers.dicerollertriggers)?.length > 0), + list: this.actor.items.filter(merit => merit.type === 'merit' && Object.keys(merit.system.triggers.dicerollertriggers)?.length > 0), visible: true, collapse: true, } @@ -482,7 +482,7 @@ export class RollForm extends FormApplication { if (this.actor.specialabilities.some(merit => Object.keys(merit.system.triggers.dicerollertriggers)?.length > 0)) { this.object.charmList['specialabilities'] = { name: game.i18n.localize("Ex3.SpecialAbilities"), - list: this.actor.specialabilities.filter(merit => Object.keys(merit.system.triggers.dicerollertriggers)?.length > 0), + list: this.actor.items.filter(merit => merit.type === 'specialability' && Object.keys(merit.system.triggers.dicerollertriggers)?.length > 0), visible: true, collapse: true, } diff --git a/system.json b/system.json index 34033e4f..20c48e0d 100644 --- a/system.json +++ b/system.json @@ -4,7 +4,7 @@ "description": "Unofficial Exalted third edition system module for FoundryVTT! Portions of the materials are the copyrights and trademarks of Paradox Interactive AB, and are used with permission. All rights reserved. For more information please visit worldofdarkness.com.", "url": "https://github.com/Aliharu/Foundry-Ex3", "license": "LICENSE.txt", - "version": "2.9.4", + "version": "2.9.5", "compatibility": { "minimum": "11", "verified": "12", @@ -49,7 +49,7 @@ ], "relationships": [], "manifest": "https://raw.githubusercontent.com/Aliharu/Foundry-Ex3/master/system.json", - "download": "https://github.com/Aliharu/Foundry-Ex3/releases/download/v2.9.4/release2.9.4.zip", + "download": "https://github.com/Aliharu/Foundry-Ex3/releases/download/v2.9.5/release2.9.5.zip", "bugs": "https://github.com/Aliharu/Foundry-Ex3/issues", "gridDistance": 5, "gridUnits": "ft",