From aee6b2feae4a1668d0a3c10ad493616dfb0a9179 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Wed, 21 Sep 2022 11:42:09 +0200 Subject: [PATCH] First v10 migration --- modules/yggdrasill-actor-sheet.js | 4 +- modules/yggdrasill-actor.js | 238 ++++++++++++------------- modules/yggdrasill-figurant-sheet.js | 4 +- modules/yggdrasill-item-sheet.js | 4 +- modules/yggdrasill-main.js | 3 +- modules/yggdrasill-roll-dialog.js | 8 +- modules/yggdrasill-utility.js | 27 +-- system.json | 10 +- templates/actor-sheet.html | 102 +++++------ templates/chat-generic-result.html | 12 +- templates/editor-notes-gm.html | 2 +- templates/figurant-sheet.html | 12 +- templates/hud-actor-attaque.html | 2 +- templates/item-armecc-sheet.html | 16 +- templates/item-armedist-sheet.html | 16 +- templates/item-armure-sheet.html | 12 +- templates/item-blessure-sheet.html | 2 +- templates/item-bouclier-sheet.html | 16 +- templates/item-competence-sheet.html | 12 +- templates/item-don-sheet.html | 2 +- templates/item-effetderune-sheet.html | 2 +- templates/item-effetmagique-sheet.html | 4 +- templates/item-equipement-sheet.html | 8 +- templates/item-faiblesse-sheet.html | 2 +- templates/item-maladie-sheet.html | 6 +- templates/item-monnaie-sheet.html | 6 +- templates/item-poison-sheet.html | 6 +- templates/item-prouesse-sheet.html | 12 +- templates/item-rune-sheet.html | 10 +- templates/item-sortgaldr-sheet.html | 6 +- templates/item-sortsejdr-sheet.html | 14 +- templates/roll-dialog-armecc.html | 2 +- templates/roll-dialog-armetir.html | 2 +- templates/roll-dialog-competence.html | 4 +- templates/roll-dialog-galdr.html | 4 +- templates/roll-dialog-rune.html | 4 +- templates/roll-dialog-sejdr.html | 6 +- 37 files changed, 295 insertions(+), 307 deletions(-) diff --git a/modules/yggdrasill-actor-sheet.js b/modules/yggdrasill-actor-sheet.js index 8c77380..166b7d8 100644 --- a/modules/yggdrasill-actor-sheet.js +++ b/modules/yggdrasill-actor-sheet.js @@ -24,7 +24,7 @@ export class YggdrasillActorSheet extends ActorSheet { /* -------------------------------------------- */ getData() { - const objectData = YggdrasillUtility.data(this.object); + const objectData = duplicate(this.object) let formData = { title: this.title, @@ -34,7 +34,7 @@ export class YggdrasillActorSheet extends ActorSheet { name: objectData.name, editable: this.isEditable, cssClass: this.isEditable ? "editable" : "locked", - data: foundry.utils.deepClone(YggdrasillUtility.templateData(this.object)), + data: foundry.utils.deepClone(objectData.system), effects: this.object.effects.map(e => foundry.utils.deepClone(e.data)), limited: this.object.limited, isEpuise: this.actor.isEpuise(), diff --git a/modules/yggdrasill-actor.js b/modules/yggdrasill-actor.js index c2ae4d4..5b18820 100644 --- a/modules/yggdrasill-actor.js +++ b/modules/yggdrasill-actor.js @@ -175,15 +175,15 @@ export class YggdrasillActor extends Actor { async prepareData() { if ( this.type == "personnage") { this.computeCaracSecondaire(); - if (this.data.data.furor.value == 0) + if (this.system.furor.value == 0) await this.setEpuise(); else await this.cleanEpuise(); - if ( this.data.data.caracsecondaire.pv.value < (this.data.data.caracsecondaire.pv.max/4) ) + if ( this.system.caracsecondaire.pv.value < (this.system.caracsecondaire.pv.max/4) ) await this.setMeurtri(); else await this.cleanMeurtri(); - if ( this.data.data.caracsecondaire.pv.value < (this.data.data.caracsecondaire.pv.max/2) ) + if ( this.system.caracsecondaire.pv.value < (this.system.caracsecondaire.pv.max/2) ) await this.setBlesse(); else await this.cleanBlesse(); @@ -196,21 +196,21 @@ export class YggdrasillActor extends Actor { if ( changed.data?.caracsecondaire?.pv?.value ) { if ( changed.data.caracsecondaire.pv.value < 0 ) changed.data.caracsecondaire.pv.value = 0; - if ( changed.data.caracsecondaire.pv.value > this.data.data.caracsecondaire.pv.max ) - changed.data.caracsecondaire.pv.value = this.data.data.caracsecondaire.pv.max; + if ( changed.data.caracsecondaire.pv.value > this.system.caracsecondaire.pv.max ) + changed.data.caracsecondaire.pv.value = this.system.caracsecondaire.pv.max; } if ( changed.data?.furor?.value ) { if ( changed.data.furor.value < 0 ) changed.data.furor.value = 0; - if ( changed.data.furor.value > this.data.data.furor.max ) - changed.data.furor.value = this.data.data.furor.max; + if ( changed.data.furor.value > this.system.furor.max ) + changed.data.furor.value = this.system.furor.max; } super._preUpdate(changed, options, user); } /* -------------------------------------------- */ getCompetences() { - let comp = this.data.items.filter( item => item.type == 'competence'); + let comp = this.items.filter( item => item.type == 'competence'); return comp; } /* -------------------------------------------- */ @@ -226,95 +226,95 @@ export class YggdrasillActor extends Actor { /* -------------------------------------------- */ getInitiativeScore() { if ( this.type == 'personnage') { - return this.data.data.caracsecondaire.reaction.max; + return this.system.caracsecondaire.reaction.max; } else { - return this.data.data.attributs.physique.values.defaut.value; + return this.system.attributs.physique.values.defaut.value; } } /* -------------------------------------------- */ getCompetencesGenerales() { - let comp = this.data.items.filter( item => item.type == 'competence' && item.data.data.categorie == 'generale'); + let comp = this.items.filter( item => item.type == 'competence' && item.system.categorie == 'generale'); return comp.sort( this.compareName ); } /* -------------------------------------------- */ getCompetencesMartiales() { - let comp = this.data.items.filter( item => item.type == 'competence' && item.data.data.categorie == 'martiale'); + let comp = this.items.filter( item => item.type == 'competence' && item.system.categorie == 'martiale'); return comp.sort( this.compareName ); } /* -------------------------------------------- */ getCompetencesMagiques() { - let comp = this.data.items.filter( item => item.type == 'competence' && item.data.data.categorie == 'magique'); + let comp = this.items.filter( item => item.type == 'competence' && item.system.categorie == 'magique'); return comp.sort( this.compareName ); } /* -------------------------------------------- */ getDons( ) { - let dons = this.data.items.filter( item => item.type == 'don'); + let dons = this.items.filter( item => item.type == 'don'); return dons.sort( this.compareName ); } /* -------------------------------------------- */ getEffetsMagiques( ) { - let effets = this.data.items.filter( item => item.type == 'effetmagique'); + let effets = this.items.filter( item => item.type == 'effetmagique'); return effets.sort( this.compareName ); } /* -------------------------------------------- */ getEffetsDeRunes( ) { - let effets = this.data.items.filter( item => item.type == 'effetderune'); + let effets = this.items.filter( item => item.type == 'effetderune'); return effets.sort( this.compareName ); } /* -------------------------------------------- */ getMonnaies( ) { - let monnaies = this.data.items.filter( item => item.type == 'monnaie'); + let monnaies = this.items.filter( item => item.type == 'monnaie'); return monnaies.sort( this.compareName ); } /* -------------------------------------------- */ getFaiblesses( ) { - let faib = this.data.items.filter( item => item.type == 'faiblesse'); + let faib = this.items.filter( item => item.type == 'faiblesse'); return faib.sort( this.compareName ); } /* -------------------------------------------- */ getBlessures( ) { - return this.data.items.filter( item => item.type == 'blessure'); + return this.items.filter( item => item.type == 'blessure'); } /* -------------------------------------------- */ getToutEquipements() { - return this.data.items.filter( item => item.type == 'equipement' || item.type == 'armure' || item.type == 'armecc' || item.type == 'armedist' || item.type == 'bouclier'); + return this.items.filter( item => item.type == 'equipement' || item.type == 'armure' || item.type == 'armecc' || item.type == 'armedist' || item.type == 'bouclier'); } /* -------------------------------------------- */ getArmes() { - return this.data.items.filter( item => (item.type == 'armecc' || item.type == 'armedist') && item.data.data.equipe ); + return this.items.filter( item => (item.type == 'armecc' || item.type == 'armedist') && item.system.equipe ); } /* -------------------------------------------- */ getArmures() { - return this.data.items.filter( item => item.type == 'armure' && item.data.data.equipe ); + return this.items.filter( item => item.type == 'armure' && item.system.equipe ); } getBoucliers() { - return this.data.items.filter( item => item.type == 'bouclier' && item.data.data.equipe ); + return this.items.filter( item => item.type == 'bouclier' && item.system.equipe ); } getProuessesMartiales() { - let prouesse = this.data.items.filter( item => item.type == 'prouesse' ); + let prouesse = this.items.filter( item => item.type == 'prouesse' ); return prouesse.sort( this.compareName ); } getSortsSejdr() { - let sort = this.data.items.filter( item => item.type == 'sortsejdr' ); + let sort = this.items.filter( item => item.type == 'sortsejdr' ); return sort.sort( this.compareName ); } getSortsGaldr() { - let sort = this.data.items.filter( item => item.type == 'sortgaldr' ); + let sort = this.items.filter( item => item.type == 'sortgaldr' ); return sort.sort( this.compareName ); } getRunes() { - let sort = this.data.items.filter( item => item.type == 'rune' ); + let sort = this.items.filter( item => item.type == 'rune' ); return sort.sort( this.compareName ); } /* -------------------------------------------- */ async setEpuise( ) { - if (!this.data.data.status.epuise) { - await this.update({ 'data.status.epuise': true}); - this.data.data.status.epuise = true; + if (!this.system.status.epuise) { + await this.update({ 'system.status.epuise': true}); + this.system.status.epuise = true; } /*let effect = this.getEffectByLabel('Epuisé'); if ( !effect ) { @@ -324,9 +324,9 @@ export class YggdrasillActor extends Actor { } /* -------------------------------------------- */ async cleanEpuise() { - if (this.data.data.status.epuise) { - await this.update({ 'data.status.epuise': false}); - this.data.data.status.epuise = false; + if (this.system.status.epuise) { + await this.update({ 'system.status.epuise': false}); + this.system.status.epuise = false; } /*let effect = this.getEffectByLabel('Epuisé'); if ( effect ) { @@ -335,7 +335,7 @@ export class YggdrasillActor extends Actor { } /* -------------------------------------------- */ async toggleEpuise( ) { - if ( this.data.data.status.epuise ) { + if ( this.system.status.epuise ) { await this.cleanEpuise(); } else { await this.setEpuise(); @@ -343,14 +343,14 @@ export class YggdrasillActor extends Actor { } /* -------------------------------------------- */ isEpuise() { - return this.data.data.status.epuise; + return this.system.status.epuise; } /* -------------------------------------------- */ async setBlesse( ) { - if (!this.data.data.status.blesse) { - await this.update({ 'data.status.blesse': true} ); - this.data.data.status.blesse = true; + if (!this.system.status.blesse) { + await this.update({ 'system.status.blesse': true} ); + this.system.status.blesse = true; } /*let effect = this.getEffectByLabel('Blessé'); if ( !effect ) { @@ -360,9 +360,9 @@ export class YggdrasillActor extends Actor { } /* -------------------------------------------- */ async cleanBlesse() { - if (this.data.data.status.blesse) { - await this.update({ 'data.status.blesse': false} ); - this.data.data.status.blesse = false; + if (this.system.status.blesse) { + await this.update({ 'system.status.blesse': false} ); + this.system.status.blesse = false; } /*let effect = this.getEffectByLabel('Blessé'); if ( effect ) { @@ -372,37 +372,37 @@ export class YggdrasillActor extends Actor { /* -------------------------------------------- */ isBlesse() { - return this.data.data.status.blesse; + return this.system.status.blesse; //return this.getEffectByLabel('Blessé'); } /* -------------------------------------------- */ async setMeurtri( ) { await this.setBlesse(); - if (!this.data.data.status.meurtri) { - await this.update({ 'data.status.meurtri': true}); - this.data.data.status.meurtri = true; + if (!this.system.status.meurtri) { + await this.update({ 'system.status.meurtri': true}); + this.system.status.meurtri = true; } } /* -------------------------------------------- */ async cleanMeurtri() { - if (this.data.data.status.meurtri) { - await this.update({ 'data.status.meurtri': false}); - this.data.data.status.meurtri = false; + if (this.system.status.meurtri) { + await this.update({ 'system.status.meurtri': false}); + this.system.status.meurtri = false; } } /* -------------------------------------------- */ isMeurtri() { - return this.data.data.status.meurtri; + return this.system.status.meurtri; } /* -------------------------------------------- */ async decrementFuror( nbFuror) { - await this.update( { 'data.furor.value': this.data.data.furor.value - nbFuror } ); + await this.update( { 'system.furor.value': this.system.furor.value - nbFuror } ); } /* -------------------------------------------- */ getCurrentFuror() { - return this.data.data.furor.value; + return this.system.furor.value; } /* -------------------------------------------- */ @@ -421,8 +421,8 @@ export class YggdrasillActor extends Actor { /* -------------------------------------------- */ getCarac( caracName ) { - for( let key in this.data.data.carac) { - let categ = this.data.data.carac[key]; + for( let key in this.system.carac) { + let categ = this.system.carac[key]; for( let carac in categ.carac) { if (carac.toLowerCase() == caracName.toLowerCase() ) { return deepClone(categ.carac[carac]); @@ -434,50 +434,50 @@ export class YggdrasillActor extends Actor { /* -------------------------------------------- */ computeCaracSecondaire( ) { if ( this.type == "personnage") { - let basecorps = this.data.data.carac.corps.carac; + let basecorps = this.system.carac.corps.carac; let sumcorps = basecorps.puissance.value + basecorps.agilite.value + basecorps.vigueur.value - let baseesprit = this.data.data.carac.esprit.carac; + let baseesprit = this.system.carac.esprit.carac; let sumesprit = baseesprit.intellect.value + baseesprit.perception.value + baseesprit.tenacite.value - let baseame = this.data.data.carac.ame.carac; + let baseame = this.system.carac.ame.carac; let sumame = baseame.charisme.value + baseame.communication.value + baseame.instinct.value let newPV = (sumcorps*3) + (sumesprit *2) + sumame; - if ( newPV != this.data.data.caracsecondaire.pv.max) { - this.data.data.caracsecondaire.pv.max = newPV; - this.update( { 'data.caracsecondaire.pv.max': newPV }); + if ( newPV != this.system.caracsecondaire.pv.max) { + this.system.caracsecondaire.pv.max = newPV; + this.update( { 'system.caracsecondaire.pv.max': newPV }); } - this.data.data.caracsecondaire.reaction.value = baseesprit.intellect.value + baseesprit.perception.value + baseame.instinct.value; - this.data.data.caracsecondaire.reaction.max = baseesprit.intellect.value + baseesprit.perception.value + baseame.instinct.value; + this.system.caracsecondaire.reaction.value = baseesprit.intellect.value + baseesprit.perception.value + baseame.instinct.value; + this.system.caracsecondaire.reaction.max = baseesprit.intellect.value + baseesprit.perception.value + baseame.instinct.value; - this.data.data.caracsecondaire.defensephy.value = basecorps.agilite.value + basecorps.vigueur.value + baseame.instinct.value; - this.data.data.caracsecondaire.defensephy.max = basecorps.agilite.value + basecorps.vigueur.value + baseame.instinct.value; + this.system.caracsecondaire.defensephy.value = basecorps.agilite.value + basecorps.vigueur.value + baseame.instinct.value; + this.system.caracsecondaire.defensephy.max = basecorps.agilite.value + basecorps.vigueur.value + baseame.instinct.value; - this.data.data.caracsecondaire.defensemen.value = baseesprit.tenacite.value + baseame.instinct.value + baseesprit.intellect.value; - this.data.data.caracsecondaire.defensemen.max = baseesprit.tenacite.value + baseame.instinct.value + baseesprit.intellect.value; + this.system.caracsecondaire.defensemen.value = baseesprit.tenacite.value + baseame.instinct.value + baseesprit.intellect.value; + this.system.caracsecondaire.defensemen.max = baseesprit.tenacite.value + baseame.instinct.value + baseesprit.intellect.value; - this.data.data.caracsecondaire.deplacement.value = basecorps.agilite.value + basecorps.vigueur.value; - this.data.data.caracsecondaire.deplacement.max = basecorps.agilite.value + basecorps.vigueur.value; + this.system.caracsecondaire.deplacement.value = basecorps.agilite.value + basecorps.vigueur.value; + this.system.caracsecondaire.deplacement.max = basecorps.agilite.value + basecorps.vigueur.value; - this.data.data.caracsecondaire.capaenc.value = (basecorps.puissance.value * 2) + basecorps.vigueur.value; - this.data.data.caracsecondaire.capaenc.max = (basecorps.puissance.value * 2) + basecorps.vigueur.value; + this.system.caracsecondaire.capaenc.value = (basecorps.puissance.value * 2) + basecorps.vigueur.value; + this.system.caracsecondaire.capaenc.max = (basecorps.puissance.value * 2) + basecorps.vigueur.value; } } /* -------------------------------------------- */ async equiperObject( equipementId ) { - let item = this.data.items.find( item => item.id == equipementId ); - if (item && item.data.data) { - let update = { _id: item.id, "data.equipe": !item.data.data.equipe }; + let item = this.items.find( item => item.id == equipementId ); + if (item && item.system) { + let update = { _id: item.id, "data.equipe": !item.system.equipe }; await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity } } /* -------------------------------------------- */ async updateCompetence( compId, niveau) { - let comp = this.data.items.find( item => item.type == 'competence' && item.id == compId); + let comp = this.items.find( item => item.type == 'competence' && item.id == compId); console.log("Comp updated!!!!", compId, niveau); if (comp) { - const update = { _id: comp.id, 'data.niveau': niveau }; + const update = { _id: comp.id, 'system.niveau': niveau }; await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity } else { ui.notifications.warn("Compétence inconnue", compId) @@ -491,9 +491,9 @@ export class YggdrasillActor extends Actor { /* -------------------------------------------- */ async rollAttribute( attrkey, subAttrKey = 'defaut') { - let attr = duplicate(this.data.data.attributs[attrkey]); + let attr = duplicate(this.system.attributs[attrkey]); console.log("ATTR : ", attr, attrkey, subAttrKey); - let subAttr = duplicate(this.data.data.attributs[attrkey].values[subAttrKey] ); + let subAttr = duplicate(this.system.attributs[attrkey].values[subAttrKey] ); if ( attr ) { subAttr.label = subAttr.label || ""; let title = `Attribut : ${attr.label} ${subAttr.label} : ${subAttr.value}`; @@ -503,11 +503,11 @@ export class YggdrasillActor extends Actor { actorImg: this.img, actorId: this.id, attr: attr, - valuePhysique: this.data.data.attributs["physique"].values["defaut"].value, + valuePhysique: this.system.attributs["physique"].values["defaut"].value, subAttr: subAttr, rollMode: game.settings.get("core", "rollMode"), title: title, - isBlesse: this.data.data.etat.etat == "blesse", + isBlesse: this.system.etat.etat == "blesse", optionsBonusMalus: YggdrasillUtility.buildListOptions(-15, +15), bonusMalus: 0, bonusdefense: 0, @@ -525,8 +525,8 @@ export class YggdrasillActor extends Actor { /* -------------------------------------------- */ async rollCarac( categName, caracName) { - let carac = duplicate(this.data.data.carac[categName].carac[caracName]); - console.log("CARAC : ", carac, this.data.data.carac); + let carac = duplicate(this.system.carac[categName].carac[caracName]); + console.log("CARAC : ", carac, this.system.carac); if ( carac) { let rollData = { mode: "carac", @@ -559,7 +559,7 @@ export class YggdrasillActor extends Actor { /* -------------------------------------------- */ async rollCompetence( competenceId ) { - let competence = this.data.items.find( item => item.type == 'competence' && item.id == competenceId); + let competence = this.items.find( item => item.type == 'competence' && item.id == competenceId); if ( competence) { let rollData = { mode: "competence", @@ -568,7 +568,7 @@ export class YggdrasillActor extends Actor { actorId: this.id, img: competence.img, rollMode: game.settings.get("core", "rollMode"), - title: `Compétence ${competence.name} : ${competence.data.data.niveau}`, + title: `Compétence ${competence.name} : ${competence.system.niveau}`, competence: duplicate(competence), isEpuise: this.isEpuise(), isBlesse: this.isBlesse(), @@ -593,18 +593,18 @@ export class YggdrasillActor extends Actor { let attackData = duplicate(attackMode[mode]); if ( attackData){ attackData.mode = mode; - attackData.carac = duplicate(this.data.data.carac[attackData.categName].carac[attackData.caracName]); + attackData.carac = duplicate(this.system.carac[attackData.categName].carac[attackData.caracName]); if ( attackData.malus != 0) { let malusTab = attackData.malus.split(';'); - attackData.malus = this.data.data.carac[attackData.categName].carac[malusTab[0]].value * Number(malusTab[1]) + attackData.malus = this.system.carac[attackData.categName].carac[malusTab[0]].value * Number(malusTab[1]) } if ( attackData.protection != 0) { let malusTab = attackData.protection.split(';'); - attackData.protection = this.data.data.carac[attackData.categName].carac[malusTab[0]].value * Number(malusTab[1]) + attackData.protection = this.system.carac[attackData.categName].carac[malusTab[0]].value * Number(malusTab[1]) } if ( attackData.bonusdegats != 0) { let malusTab = attackData.bonusdegats.split(';'); - attackData.bonusdegats = this.data.data.carac[attackData.categName].carac[malusTab[0]].value * Number(malusTab[1]) + attackData.bonusdegats = this.system.carac[attackData.categName].carac[malusTab[0]].value * Number(malusTab[1]) } } return attackData; @@ -615,18 +615,18 @@ export class YggdrasillActor extends Actor { let attackData = duplicate( tirMode[mode] ); if ( attackData){ attackData.mode = mode; - attackData.carac = duplicate(this.data.data.carac[attackData.categName].carac[attackData.caracName]); + attackData.carac = duplicate(this.system.carac[attackData.categName].carac[attackData.caracName]); if ( attackData.malus != 0) { let malusTab = attackData.malus.split(';'); - attackData.malus = this.data.data.carac[attackData.categName].carac[malusTab[0]].value * Number(malusTab[1]) + attackData.malus = this.system.carac[attackData.categName].carac[malusTab[0]].value * Number(malusTab[1]) } if ( attackData.protection != 0) { let malusTab = attackData.protection.split(';'); - attackData.protection = this.data.data.carac[attackData.categName].carac[malusTab[0]].value * Number(malusTab[1]) + attackData.protection = this.system.carac[attackData.categName].carac[malusTab[0]].value * Number(malusTab[1]) } if ( attackData.bonusdegats != 0) { let malusTab = attackData.bonusdegats.split(';'); - attackData.bonusdegats = this.data.data.carac[attackData.categName].carac[malusTab[0]].value * Number(malusTab[1]) + attackData.bonusdegats = this.system.carac[attackData.categName].carac[malusTab[0]].value * Number(malusTab[1]) } } return attackData; @@ -634,17 +634,17 @@ export class YggdrasillActor extends Actor { /* -------------------------------------------- */ async rollSort( sortId, magie) { - let sort = this.data.items.find( item => item.id == sortId); - let competence = this.data.items.find( item => item.type == 'competence' && item.name.toLowerCase().includes(magie)); + let sort = this.items.find( item => item.id == sortId); + let competence = this.items.find( item => item.type == 'competence' && item.name.toLowerCase().includes(magie)); console.log("SORT :", sortId, sort, competence ); let carac; if ( magie == "sejdr") { - carac = duplicate(this.data.data.carac.ame.carac.instinct); + carac = duplicate(this.system.carac.ame.carac.instinct); } else if ( magie == "rune") { - carac = duplicate(this.data.data.carac.ame.carac.communication); + carac = duplicate(this.system.carac.ame.carac.communication); } else { - carac = duplicate(this.data.data.carac.ame.carac.charisme); + carac = duplicate(this.system.carac.ame.carac.charisme); } if ( sort && competence) { @@ -659,8 +659,8 @@ export class YggdrasillActor extends Actor { rollMode: game.settings.get("core", "rollMode"), title: magie + " - " + sort.name, selectedCarac: carac, - agiliteCarac: duplicate(this.data.data.carac.corps.carac.agilite), - instinctCarac: duplicate(this.data.data.carac.ame.carac.instinct), + agiliteCarac: duplicate(this.system.carac.corps.carac.agilite), + instinctCarac: duplicate(this.system.carac.ame.carac.instinct), sort: duplicate(sort), competence: duplicate(competence), dureeGaldr: "1d5a", @@ -691,9 +691,9 @@ export class YggdrasillActor extends Actor { /* -------------------------------------------- */ async rollArme( armeId ) { - let arme = this.data.items.find( item => item.id == armeId); - let compName = armeCategorieToCompetence[arme.data.data.categorie]; - let competence = this.data.items.find( item => item.type == 'competence' && item.name == compName); + let arme = this.items.find( item => item.id == armeId); + let compName = armeCategorieToCompetence[arme.system.categorie]; + let competence = this.items.find( item => item.type == 'competence' && item.name == compName); console.log("ARME :", armeId, arme, competence ); if ( arme && competence) { @@ -714,7 +714,7 @@ export class YggdrasillActor extends Actor { img: competence.img, rollMode: game.settings.get("core", "rollMode"), title: "Attaque !", - selectedCarac: duplicate(this.data.data.carac.corps.carac.agilite), + selectedCarac: duplicate(this.system.carac.corps.carac.agilite), arme: duplicate(arme), competence: duplicate(competence), bonusdefense: 0, @@ -740,16 +740,16 @@ export class YggdrasillActor extends Actor { /* -------------------------------------------- */ getEncTotal( ) { let encTotal = 0; - for( let item of this.data.items) { + for( let item of this.items) { if (item.type == "equipement" || item.type == "armecc" || item.type == "armedist" || item.type == "armure" || item.type == "monnaie" || item.type == "bouclier") { - encTotal += (item.data.data.enc * item.data.data.quantite); + encTotal += (item.system.enc * item.system.quantite); } } - for( let item of this.data.items) { - if (item.type == "bouclier" && item.data.data.equipe) { - encTotal -= (item.data.data.enc * item.data.data.quantite); - encTotal += (item.data.data.enccomb * item.data.data.quantite); + for( let item of this.items) { + if (item.type == "bouclier" && item.system.equipe) { + encTotal -= (item.system.enc * item.system.quantite); + encTotal += (item.system.enccomb * item.system.quantite); } } return encTotal; @@ -758,9 +758,9 @@ export class YggdrasillActor extends Actor { /* -------------------------------------------- */ getProtectionTotal( ) { let protectionTotal = 0; - for( let item of this.data.items) { - if (item.type == "armure" && item.data.data.equipe) { - protectionTotal += Number(item.data.data.protection); + for( let item of this.items) { + if (item.type == "armure" && item.system.equipe) { + protectionTotal += Number(item.system.protection); } } return protectionTotal; @@ -768,9 +768,9 @@ export class YggdrasillActor extends Actor { /* -------------------------------------------- */ getDpBouclier( ) { let dpBouclier = 0; - for( let item of this.data.items) { - if (item.type == "bouclier" && item.data.data.equipe) { - dpBouclier += Number(item.data.data.defensebonus); + for( let item of this.items) { + if (item.type == "bouclier" && item.system.equipe) { + dpBouclier += Number(item.system.defensebonus); } } return dpBouclier; @@ -778,20 +778,20 @@ export class YggdrasillActor extends Actor { /* -------------------------------------------- */ async incrementeQuantite( objetId ) { - let objetQ = this.data.items.find( item => item.id == objetId ); + let objetQ = this.items.find( item => item.id == objetId ); if (objetQ) { - let newQ = objetQ.data.data.quantite + 1; - const updated = await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'data.quantite': newQ }]); // pdates one EmbeddedEntity + let newQ = objetQ.system.quantite + 1; + const updated = await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'system.quantite': newQ }]); // pdates one EmbeddedEntity } } /* -------------------------------------------- */ async decrementeQuantite( objetId ) { - let objetQ = this.data.items.find( item => item.id == objetId ); + let objetQ = this.items.find( item => item.id == objetId ); if (objetQ) { - let newQ = objetQ.data.data.quantite - 1; + let newQ = objetQ.system.quantite - 1; newQ = (newQ <= 0) ? 0 : newQ; - const updated = await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'data.quantite': newQ }]); // pdates one EmbeddedEntity + const updated = await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'system.quantite': newQ }]); // pdates one EmbeddedEntity } } diff --git a/modules/yggdrasill-figurant-sheet.js b/modules/yggdrasill-figurant-sheet.js index 64129c8..35092fc 100644 --- a/modules/yggdrasill-figurant-sheet.js +++ b/modules/yggdrasill-figurant-sheet.js @@ -24,7 +24,7 @@ export class YggdrasillFigurantSheet extends ActorSheet { /* -------------------------------------------- */ getData() { - const objectData = YggdrasillUtility.data(this.object); + const objectData = duplicate(this.object) let formData = { title: this.title, @@ -34,7 +34,7 @@ export class YggdrasillFigurantSheet extends ActorSheet { name: objectData.name, editable: this.isEditable, cssClass: this.isEditable ? "editable" : "locked", - data: foundry.utils.deepClone(YggdrasillUtility.templateData(this.object)), + data: foundry.utils.deepClone(this.object.system), limited: this.object.limited, equipements: this.actor.getToutEquipements(), effetsmagiques: this.actor.getEffetsMagiques(), diff --git a/modules/yggdrasill-item-sheet.js b/modules/yggdrasill-item-sheet.js index b4531b2..ec61d62 100644 --- a/modules/yggdrasill-item-sheet.js +++ b/modules/yggdrasill-item-sheet.js @@ -43,7 +43,7 @@ export class YggdrasillItemSheet extends ItemSheet { /* -------------------------------------------- */ async getData() { - const objectData = YggdrasillUtility.data(this.object); + const objectData = duplicate(this.object); let formData = { title: this.title, @@ -53,7 +53,7 @@ export class YggdrasillItemSheet extends ItemSheet { name: objectData.name, editable: this.isEditable, cssClass: this.isEditable ? "editable" : "locked", - data: foundry.utils.deepClone(YggdrasillUtility.templateData(this.object)), + data: foundry.utils.deepClone(this.object.system), optionsBase: YggdrasillUtility.createDirectOptionList(0, 20), optionsNiveaux4: YggdrasillUtility.buildListOptions(1, 5), limited: this.object.limited, diff --git a/modules/yggdrasill-main.js b/modules/yggdrasill-main.js index fdd2927..d2994ef 100644 --- a/modules/yggdrasill-main.js +++ b/modules/yggdrasill-main.js @@ -82,6 +82,7 @@ function registerUsageCount( registerKey ) { name: "Unique world key", scope: "world", config: false, + default: "", type: String }); @@ -90,7 +91,7 @@ function registerUsageCount( registerKey ) { worldKey = randomID(32) game.settings.set(registerKey, "world-key", worldKey ) } - let regURL = `https://www.uberwald.me/fvtt_appcount/count.php?name="${registerKey}"&worldKey="${worldKey}"&version="${game.release.generation}.${game.release.build}"&system="${game.system.id}"&systemversion="${game.system.data.version}"` + let regURL = `https://www.uberwald.me/fvtt_appcount/count.php?name="${registerKey}"&worldKey="${worldKey}"&version="${game.release.generation}.${game.release.build}"&system="${game.system.id}"&systemversion="${game.system.version}"` $.ajax(regURL) /* -------------------------------------------- */ } diff --git a/modules/yggdrasill-roll-dialog.js b/modules/yggdrasill-roll-dialog.js index 98e6ab6..657a0ec 100644 --- a/modules/yggdrasill-roll-dialog.js +++ b/modules/yggdrasill-roll-dialog.js @@ -73,12 +73,12 @@ export class YggdrasillRoll extends Dialog { updateGaldrSR( ) { let sdDuree = Number(dureeGaldrSD[this.rollData.dureeGaldr]); let sdVar = 0; - if ( this.rollData.sort.data.voie == "illusion") { + if ( this.rollData.sort.system.voie == "illusion") { sdVar = Number(zonesciblesGaldrSD[this.rollData.zoneGaldr]); } else { sdVar = Number(ciblesGaldrSD[this.rollData.nbCibles]); } - let SR = Number(this.rollData.sort.data.sd) + sdDuree + sdVar; + let SR = Number(this.rollData.sort.system.sd) + sdDuree + sdVar; $("#srTotal").text(SR); this.rollData.sr = SR; } @@ -113,10 +113,10 @@ export class YggdrasillRoll extends Dialog { this.rollData.echelleDuree = "Jours"; this.rollData.echelleDureeVie = "Années" } - let SR = this.rollData.puissanceRune + (Number(this.rollData.sort.data.niveau)*3) + support; + let SR = this.rollData.puissanceRune + (Number(this.rollData.sort.system.niveau)*3) + support; $("#srTotal").text(SR); $("#runeDuree").text( this.rollData.dureeRune + " " + this.rollData.echelleDuree); - $("#runeDureeVie").text( this.rollData.competence.data.niveau + " " + this.rollData.echelleDureeVie); + $("#runeDureeVie").text( this.rollData.competence.system.niveau + " " + this.rollData.echelleDureeVie); this.rollData.sr = SR; } diff --git a/modules/yggdrasill-utility.js b/modules/yggdrasill-utility.js index 1ba30b0..391a58b 100644 --- a/modules/yggdrasill-utility.js +++ b/modules/yggdrasill-utility.js @@ -20,19 +20,6 @@ export class YggdrasillUtility { return loadTemplates(templatePaths); } - /* -------------------------------------------- */ - static templateData(it) { - return YggdrasillUtility.data(it)?.data ?? {} - } - - /* -------------------------------------------- */ - static data(it) { - if (it instanceof Actor || it instanceof Item || it instanceof Combatant) { - return it.data; - } - return it; - } - /* -------------------------------------------- */ static createDirectSortedOptionList( min, max) { let options = []; @@ -205,7 +192,7 @@ export class YggdrasillUtility { // Select niveau de competence/arme/carac if ( rollData.mode != "carac" ) { - niveauCompetence = rollData.competence.data.niveau; + niveauCompetence = rollData.competence.system.niveau; } else { niveauCompetence = rollData.selectedCarac.value; } @@ -215,8 +202,8 @@ export class YggdrasillUtility { if ( rollData.attackDef) { rollData.finalBM -= rollData.attackDef.malus; } - if ( rollData.sort && rollData.sort.data.malus ) { - rollData.finalBM += rollData.sort.data.malus; + if ( rollData.sort && rollData.sort.system.malus ) { + rollData.finalBM += rollData.sort.system.malus; } // Gestion cas blessé (malus de -3) if ( rollData.isBlesse) { // Cas blesse : malus de -3 @@ -276,8 +263,8 @@ export class YggdrasillUtility { // Dégats if ( isSuccess && (rollData.mode == "armecc" || rollData.mode == "armedist") ) { - rollData.degatsExplain = `Marge(${marge}) + Degats Arme(${rollData.arme.data.degat}) + Bonus Attaque(${rollData.attackDef.bonusdegats})`; - rollData.degats = marge + rollData.arme.data.degat + rollData.attackDef.bonusdegats; + rollData.degatsExplain = `Marge(${marge}) + Degats Arme(${rollData.arme.system.degat}) + Bonus Attaque(${rollData.attackDef.bonusdegats})`; + rollData.degats = marge + rollData.arme.system.degat + rollData.attackDef.bonusdegats; } // Stockage resultats @@ -292,7 +279,7 @@ export class YggdrasillUtility { let galdrRoll = new Roll( rollData.dureeGaldr.substring(0, rollData.dureeGaldr.length - 1) ).roll( { async: false} ); await this.showDiceSoNice(galdrRoll, game.settings.get("core", "rollMode") ); rollData.dureeGaldrText = galdrRoll.total + " " + dureeGaldrText[rollData.dureeGaldr]; - if ( rollData.sort.data.voie == "illusion") { + if ( rollData.sort.system.voie == "illusion") { let volume = rollData.zoneGaldr.substring(3, rollData.zoneGaldr.length); rollData.zoneGaldrText = rollData.instinctCarac.value + " x " + volume; } else { @@ -310,7 +297,7 @@ export class YggdrasillUtility { /* -------------------------------------------- */ static getUsers(filter) { - return game.users.filter(filter).map(user => user.data._id); + return game.users.filter(filter).map(user => user.system._id); } /* -------------------------------------------- */ static getWhisperRecipients(rollMode, name) { diff --git a/system.json b/system.json index c422450..93c32ff 100644 --- a/system.json +++ b/system.json @@ -1,14 +1,14 @@ { "title": "Yggdrasill", "description": "Système non-officiel Yggdrasill (7ième Cercle) pour FoundryVTT", - "version": "1.2.3", + "version": "10.0.0", "esmodules": [ "modules/yggdrasill-main.js" ], "styles": [ "styles/simple.css" ], - "background": "images/ui/yggdrasill_map.webp", + "background": "systems/fvtt-yggdrasill/images/ui/yggdrasill_map.webp", "packs": [ { "label": "Compétences Générales", @@ -196,7 +196,7 @@ "socket": true, "url": "https://www.uberwald.me/gitea/public/fvtt-yggdrasill/", "manifest": "https://www.uberwald.me/gitea/public/fvtt-yggdrasill/raw/main/system.json", - "download": "https://www.uberwald.me/gitea/public/fvtt-yggdrasill/archive/fvtt-yggdrasill-1.2.3.zip", + "download": "https://www.uberwald.me/gitea/public/fvtt-yggdrasill/archive/fvtt-yggdrasill-10.0.0.zip", "license": "LICENSE.txt", "id": "fvtt-yggdrasill", "authors": [ @@ -220,7 +220,7 @@ ] }, "compatibility": { - "minimum": "9", - "verified": "9" + "minimum": "10", + "verified": "10.286" } } \ No newline at end of file diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 8ec4ffc..5da57e5 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -43,7 +43,7 @@
  • {{mycarac.label}} - {{selectOptions @root.optionsCarac selected=mycarac.value localize=false}}
  • @@ -56,10 +56,10 @@

    Furor