diff --git a/modules/mournblade-actor-sheet.js b/modules/mournblade-actor-sheet.js index e12d1a4..a2f1e32 100644 --- a/modules/mournblade-actor-sheet.js +++ b/modules/mournblade-actor-sheet.js @@ -25,9 +25,8 @@ export class MournbladeActorSheet extends ActorSheet { /* -------------------------------------------- */ async getData() { - const objectData = MournbladeUtility.data(this.object); - - let actorData = duplicate(MournbladeUtility.templateData(this.object)) + const objectData = duplicate(this.object) + let actorData = objectData let formData = { title: this.title, @@ -37,7 +36,7 @@ export class MournbladeActorSheet extends ActorSheet { name: objectData.name, editable: this.isEditable, cssClass: this.isEditable ? "editable" : "locked", - data: actorData, + data: actorData.system, effects: this.object.effects.map(e => foundry.utils.deepClone(e.data)), limited: this.object.limited, skills: this.actor.getSkills(), diff --git a/modules/mournblade-actor.js b/modules/mournblade-actor.js index 2f709fb..d558046 100644 --- a/modules/mournblade-actor.js +++ b/modules/mournblade-actor.js @@ -51,22 +51,22 @@ export class MournbladeActor extends Actor { prepareArme(arme) { arme = duplicate(arme) let combat = this.getCombatValues() - if (arme.data.typearme == "contact" || arme.data.typearme == "contactjet") { - arme.data.competence = duplicate(this.data.items.find(item => item.type == "competence" && item.name.toLowerCase() == "mêlée")) - arme.data.attrKey = "pui" - arme.data.totalDegats = arme.data.degats + "+" + combat.bonusDegatsTotal - arme.data.totalOffensif = this.data.data.attributs.pui.value + arme.data.competence.data.niveau + arme.data.bonusmaniementoff - if (arme.data.isdefense) { - arme.data.totalDefensif = combat.defenseTotal + arme.data.competence.data.niveau + arme.data.bonusmaniementdef + if (arme.system.typearme == "contact" || arme.system.typearme == "contactjet") { + arme.system.competence = duplicate(this.items.find(item => item.type == "competence" && item.name.toLowerCase() == "mêlée")) + arme.system.attrKey = "pui" + arme.system.totalDegats = arme.system.degats + "+" + combat.bonusDegatsTotal + arme.system.totalOffensif = this.system.attributs.pui.value + arme.system.competence.system.niveau + arme.system.bonusmaniementoff + if (arme.system.isdefense) { + arme.system.totalDefensif = combat.defenseTotal + arme.system.competence.system.niveau + arme.system.bonusmaniementdef } } - if (arme.data.typearme == "jet" || arme.data.typearme == "tir") { - arme.data.competence = duplicate(this.data.items.find(item => item.type == "competence" && item.name.toLowerCase() == "armes à distance")) - arme.data.attrKey = "adr" - arme.data.totalOffensif = this.data.data.attributs.adr.value + arme.data.competence.data.niveau + arme.data.bonusmaniementoff - arme.data.totalDegats = arme.data.degats - if (arme.data.isdefense) { - arme.data.totalDefensif = combat.defenseTotal + arme.data.competence.data.niveau + arme.data.bonusmaniementdef + if (arme.system.typearme == "jet" || arme.system.typearme == "tir") { + arme.system.competence = duplicate(this.items.find(item => item.type == "competence" && item.name.toLowerCase() == "armes à distance")) + arme.system.attrKey = "adr" + arme.system.totalOffensif = this.system.attributs.adr.value + arme.system.competence.system.niveau + arme.system.bonusmaniementoff + arme.system.totalDegats = arme.system.degats + if (arme.system.isdefense) { + arme.system.totalDefensif = combat.defenseTotal + arme.system.competence.system.niveau + arme.system.bonusmaniementdef } } return arme @@ -75,7 +75,7 @@ export class MournbladeActor extends Actor { /* -------------------------------------------- */ getWeapons() { let armes = [] - for (let arme of this.data.items) { + for (let arme of this.items) { if (arme.type == "arme") { armes.push(this.prepareArme(arme)) } @@ -85,49 +85,49 @@ export class MournbladeActor extends Actor { /* -------------------------------------------- */ getDons() { - return this.data.items.filter(item => item.type == "don") + return this.items.filter(item => item.type == "don") } /* -------------------------------------------- */ getTendances() { - return this.data.items.filter(item => item.type == "tendance") + return this.items.filter(item => item.type == "tendance") } getRunes() { - return this.data.items.filter(item => item.type == "rune") + return this.items.filter(item => item.type == "rune") } /* -------------------------------------------- */ getEquipments() { - return this.data.items.filter(item => item.type == "equipement") + return this.items.filter(item => item.type == "equipement") } /* -------------------------------------------- */ getArmors() { - return this.data.items.filter(item => item.type == "protection") + return this.items.filter(item => item.type == "protection") } getOrigine() { - return this.data.items.find(item => item.type == "origine") + return this.items.find(item => item.type == "origine") } getMetier() { - return this.data.items.find(item => item.type == "metier") + return this.items.find(item => item.type == "metier") } getHeritage() { - return this.data.items.find(item => item.type == "heritage") + return this.items.find(item => item.type == "heritage") } /* -------------------------------------------- */ getSkills() { let comp = [] - for (let item of this.data.items) { + for (let item of this.items) { item = duplicate(item) if (item.type == "competence") { - item.data.attribut1total = item.data.niveau + (this.data.data.attributs[item.data.attribut1]?.value || 0) - item.data.attribut2total = item.data.niveau + (this.data.data.attributs[item.data.attribut2]?.value || 0) - item.data.attribut3total = item.data.niveau + (this.data.data.attributs[item.data.attribut3]?.value || 0) - if (item.data.niveau == 0) { - item.data.attribut1total -= 3 - item.data.attribut2total -= 3 - item.data.attribut3total -= 3 + item.system.attribut1total = item.system.niveau + (this.system.attributs[item.system.attribut1]?.value || 0) + item.system.attribut2total = item.system.niveau + (this.system.attributs[item.system.attribut2]?.value || 0) + item.system.attribut3total = item.system.niveau + (this.system.attributs[item.system.attribut3]?.value || 0) + if (item.system.niveau == 0) { + item.system.attribut1total -= 3 + item.system.attribut2total -= 3 + item.system.attribut3total -= 3 } - item.data.attribut1label = this.data.data.attributs[item.data.attribut1]?.label || "" - item.data.attribut2label = this.data.data.attributs[item.data.attribut2]?.label || "" - item.data.attribut3label = this.data.data.attributs[item.data.attribut3]?.label || "" + item.system.attribut1label = this.system.attributs[item.system.attribut1]?.label || "" + item.system.attribut2label = this.system.attributs[item.system.attribut2]?.label || "" + item.system.attribut3label = this.system.attributs[item.system.attribut3]?.label || "" comp.push(item) } } @@ -146,30 +146,30 @@ export class MournbladeActor extends Actor { /* -------------------------------------------- */ getAlignement() { - return (this.data.data.balance.loi > this.data.data.balance.chaos) ? "loyal" : "chaotique" + return (this.system.balance.loi > this.system.balance.chaos) ? "loyal" : "chaotique" } /* -------------------------------------------- */ getDefenseBase() { - return this.data.data.attributs.tre.value + 5 + return this.system.attributs.tre.value + 5 } /* -------------------------------------------- */ getVitesseBase() { - return 5 + __vitesseBonus[this.data.data.attributs.adr.value] + return 5 + __vitesseBonus[this.system.attributs.adr.value] } /* -------------------------------------------- */ getCombatValues() { let combat = { - initBase: this.data.data.attributs.adr.value, - initTotal: this.data.data.attributs.adr.value + this.data.data.combat.initbonus, + initBase: this.system.attributs.adr.value, + initTotal: this.system.attributs.adr.value + this.system.combat.initbonus, bonusDegats: this.getBonusDegats(), - bonusDegatsTotal: this.getBonusDegats() + this.data.data.combat.bonusdegats, + bonusDegatsTotal: this.getBonusDegats() + this.system.combat.bonusdegats, vitesseBase: this.getVitesseBase(), - vitesseTotal: this.getVitesseBase() + this.data.data.combat.vitessebonus, + vitesseTotal: this.getVitesseBase() + this.system.combat.vitessebonus, defenseBase: this.getDefenseBase(), - defenseTotal: this.getDefenseBase() + this.data.data.combat.defensebonus + defenseTotal: this.getDefenseBase() + this.system.combat.defensebonus } return combat } @@ -186,12 +186,12 @@ export class MournbladeActor extends Actor { prepareDerivedData() { if (this.type == 'personnage') { - let newSante = this.data.data.sante.bonus + (this.data.data.attributs.pui.value + this.data.data.attributs.tre.value) * 2 + 5 - if (this.data.data.sante.base != newSante) { + let newSante = this.system.sante.bonus + (this.system.attributs.pui.value + this.system.attributs.tre.value) * 2 + 5 + if (this.system.sante.base != newSante) { this.update({ 'data.sante.base': newSante }) } - let newAme = (this.data.data.attributs.cla.value + this.data.data.attributs.tre.value) * this.data.data.biodata.amemultiplier + 5 - if (this.data.data.ame.fullmax != newAme) { + let newAme = (this.system.attributs.cla.value + this.system.attributs.tre.value) * this.system.biodata.amemultiplier + 5 + if (this.system.ame.fullmax != newAme) { this.update({ 'data.ame.fullmax': newAme }) } } @@ -207,7 +207,7 @@ export class MournbladeActor extends Actor { /* -------------------------------------------- */ getItemById(id) { - let item = this.data.items.find(item => item.id == id); + let item = this.items.find(item => item.id == id); if (item) { item = duplicate(item) } @@ -216,16 +216,16 @@ export class MournbladeActor extends Actor { /* -------------------------------------------- */ async equipItem(itemId) { - let item = this.data.items.find(item => item.id == itemId); - if (item && item.data.data) { - let update = { _id: item.id, "data.equipped": !item.data.data.equipped }; + let item = this.items.find(item => item.id == itemId); + if (item && item.system.data) { + let update = { _id: item.id, "data.equipped": !item.system.equipped }; await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity } } /* -------------------------------------------- */ editItemField(itemId, itemType, itemField, dataType, value) { - let item = this.data.items.find(item => item.id == itemId) + let item = this.items.find(item => item.id == itemId) if (item) { console.log("Item ", item, itemField, dataType, value) if (dataType.toLowerCase() == "number") { @@ -240,35 +240,35 @@ export class MournbladeActor extends Actor { /* -------------------------------------------- */ getBonneAventure() { - return this.data.data.bonneaventure.actuelle + return this.system.bonneaventure.actuelle } /* -------------------------------------------- */ changeBonneAventure(value) { - let newBA = this.data.data.bonneaventure.actuelle + let newBA = this.system.bonneaventure.actuelle newBA += value this.update({ 'data.bonneaventure.actuelle': newBA }) } /* -------------------------------------------- */ getEclat() { - return this.data.data.eclat.value + return this.system.eclat.value } /* -------------------------------------------- */ changeEclat(value) { - let newE = this.data.data.eclat.value + let newE = this.system.eclat.value newE += value this.update({ 'data.eclat.value': newE }) } /* -------------------------------------------- */ canEclatDoubleD20() { - return (this.getAlignement() == "loyal" && this.data.data.eclat.value > 0) + return (this.getAlignement() == "loyal" && this.system.eclat.value > 0) } /* -------------------------------------------- */ subPointsAme(runeMode, value) { - let ame = duplicate(this.data.data.ame) + let ame = duplicate(this.system.ame) if(runeMode == "prononcer") { ame.value -= value } else { @@ -290,19 +290,19 @@ export class MournbladeActor extends Actor { /* -------------------------------------------- */ getAttribute(attrKey) { - return this.data.data.attributes[attrKey] + return this.system.attributes[attrKey] } /* -------------------------------------------- */ getBonusDegats() { - return __degatsBonus[this.data.data.attributs.pui.value] + return __degatsBonus[this.system.attributs.pui.value] } /* -------------------------------------------- */ async equipGear(equipmentId) { - let item = this.data.items.find(item => item.id == equipmentId); - if (item && item.data.data) { - let update = { _id: item.id, "data.equipped": !item.data.data.equipped }; + let item = this.items.find(item => item.id == equipmentId); + if (item && item.system.data) { + let update = { _id: item.id, "data.equipped": !item.system.equipped }; await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity } } @@ -310,21 +310,21 @@ export class MournbladeActor extends Actor { /* -------------------------------------------- */ getSubActors() { let subActors = []; - for (let id of this.data.data.subactors) { + for (let id of this.system.subactors) { subActors.push(duplicate(game.actors.get(id))); } return subActors; } /* -------------------------------------------- */ async addSubActor(subActorId) { - let subActors = duplicate(this.data.data.subactors); + let subActors = duplicate(this.system.subactors); subActors.push(subActorId); await this.update({ 'data.subactors': subActors }); } /* -------------------------------------------- */ async delSubActor(subActorId) { let newArray = []; - for (let id of this.data.data.subactors) { + for (let id of this.system.subactors) { if (id != subActorId) { newArray.push(id); } @@ -334,22 +334,22 @@ export class MournbladeActor extends Actor { /* -------------------------------------------- */ async incDecQuantity(objetId, incDec = 0) { - let objetQ = this.data.items.get(objetId) + let objetQ = this.items.get(objetId) if (objetQ) { - let newQ = objetQ.data.data.quantity + incDec; + let newQ = objetQ.system.quantity + incDec; const updated = await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'data.quantity': newQ }]); // pdates one EmbeddedEntity } } /* -------------------------------------------- */ getCompetence(compId) { - return this.data.items.get(compId) + return this.items.get(compId) } /* -------------------------------------------- */ async setPredilectionUsed(compId, predIdx) { - let comp = this.data.items.get(compId) - let pred = duplicate(comp.data.data.predilections) + let comp = this.items.get(compId) + let pred = duplicate(comp.system.predilections) pred[predIdx].used = true await this.updateEmbeddedDocuments('Item', [{ _id: compId, 'data.predilections': pred }]) } @@ -368,16 +368,16 @@ export class MournbladeActor extends Actor { if (attrKey) { rollData.attrKey = attrKey if (attrKey != "tochoose") { - rollData.actionImg = "systems/fvtt-mournblade/assets/icons/" + this.data.data.attributs[attrKey].labelnorm + ".webp" - rollData.attr = duplicate(this.data.data.attributs[attrKey]) + rollData.actionImg = "systems/fvtt-mournblade/assets/icons/" + this.system.attributs[attrKey].labelnorm + ".webp" + rollData.attr = duplicate(this.system.attributs[attrKey]) } } if (compId) { - rollData.competence = duplicate(this.data.items.get(compId) || {}) + rollData.competence = duplicate(this.items.get(compId) || {}) rollData.actionImg = rollData.competence?.img } if (compName) { - rollData.competence = duplicate(this.data.items.find( item => item.name.toLowerCase() == compName.toLowerCase()) || {}) + rollData.competence = duplicate(this.items.find( item => item.name.toLowerCase() == compName.toLowerCase()) || {}) rollData.actionImg = rollData.competence?.img } return rollData @@ -402,7 +402,7 @@ export class MournbladeActor extends Actor { /* -------------------------------------------- */ async rollRune(runeId) { let rollData = this.getCommonRollData("cla", undefined, "Savoir : Runes") - rollData.rune = duplicate(this.data.items.get(runeId) || {}) + rollData.rune = duplicate(this.items.get(runeId) || {}) rollData.difficulte = rollData.rune?.data?.seuil || 0 rollData.runemode = "prononcer" rollData.runeame = 1 @@ -413,9 +413,9 @@ export class MournbladeActor extends Actor { /* -------------------------------------------- */ async rollArmeOffensif(armeId) { - let arme = this.data.items.get(armeId) + let arme = this.items.get(armeId) arme = this.prepareArme(arme) - let rollData = this.getCommonRollData(arme.data.attrKey, arme.data.competence._id) + let rollData = this.getCommonRollData(arme.system.attrKey, arme.system.competence._id) rollData.arme = arme console.log("ARME!", rollData) let rollDialog = await MournbladeRollDialog.create(this, rollData) @@ -424,9 +424,9 @@ export class MournbladeActor extends Actor { /* -------------------------------------------- */ async rollArmeDegats(armeId) { - let arme = this.data.items.get(armeId) + let arme = this.items.get(armeId) arme = this.prepareArme(arme) - let roll = new Roll(arme.data.totalDegats).roll({ async: false }) + let roll = new Roll(arme.system.totalDegats).roll({ async: false }) await MournbladeUtility.showDiceSoNice(roll, game.settings.get("core", "rollMode")); let rollData = { arme: arme, diff --git a/modules/mournblade-item-sheet.js b/modules/mournblade-item-sheet.js index 0f0466d..1f8bad8 100644 --- a/modules/mournblade-item-sheet.js +++ b/modules/mournblade-item-sheet.js @@ -48,9 +48,8 @@ export class MournbladeItemSheet extends ItemSheet { /* -------------------------------------------- */ async getData() { - const objectData = MournbladeUtility.data(this.object); - - let itemData = foundry.utils.deepClone(MournbladeUtility.templateData(this.object)); + const objectData = duplicate(this.object) + let itemData = objectData let formData = { title: this.title, id: this.id, @@ -60,7 +59,7 @@ export class MournbladeItemSheet extends ItemSheet { editable: this.isEditable, cssClass: this.isEditable ? "editable" : "locked", attributs: MournbladeUtility.getAttributs(), - data: itemData, + data: itemData.system, limited: this.object.limited, options: this.options, owner: this.document.isOwner, @@ -68,7 +67,7 @@ export class MournbladeItemSheet extends ItemSheet { isGM: game.user.isGM } - this.options.editable = !(this.object.data.origin == "embeddedItem"); + //this.options.editable = !(this.object.origin == "embeddedItem"); console.log("ITEM DATA", formData, this); return formData; } @@ -130,26 +129,26 @@ export class MournbladeItemSheet extends ItemSheet { html.find('.edit-prediction').change(ev => { const li = $(ev.currentTarget).parents(".prediction-item") let index = li.data("prediction-index") - let pred = duplicate(this.object.data.data.predilections) + let pred = duplicate(this.object.system.predilections) pred[index].name = ev.currentTarget.value this.object.update( { 'data.predilections': pred }) }) html.find('.delete-prediction').click(ev => { const li = $(ev.currentTarget).parents(".prediction-item") let index = li.data("prediction-index") - let pred = duplicate(this.object.data.data.predilections) + let pred = duplicate(this.object.system.predilections) pred.splice(index,1) this.object.update( { 'data.predilections': pred }) }) html.find('.use-prediction').change(ev => { const li = $(ev.currentTarget).parents(".prediction-item") let index = li.data("prediction-index") - let pred = duplicate(this.object.data.data.predilections) + let pred = duplicate(this.object.system.predilections) pred[index].used = ev.currentTarget.checked this.object.update( { 'data.predilections': pred }) }) html.find('#add-predilection').click(ev => { - let pred = duplicate(this.object.data.data.predilections) + let pred = duplicate(this.object.system.predilections) pred.push( { name: "Nouvelle prédilection", used: false }) this.object.update( { 'data.predilections': pred }) }) diff --git a/modules/mournblade-utility.js b/modules/mournblade-utility.js index f70fe44..eb733f3 100644 --- a/modules/mournblade-utility.js +++ b/modules/mournblade-utility.js @@ -155,19 +155,6 @@ export class MournbladeUtility { return undefined; } - /* -------------------------------------------- */ - static templateData(it) { - return MournbladeUtility.data(it)?.data ?? {} - } - - /* -------------------------------------------- */ - static data(it) { - if (it instanceof Actor || it instanceof Item || it instanceof Combatant) { - return it.data; - } - return it; - } - /* -------------------------------------------- */ static createDirectOptionList(min, max) { let options = {}; @@ -309,8 +296,8 @@ export class MournbladeUtility { rollData.attrKey = "adr" } if ( !rollData.attr) { - rollData.actionImg = "systems/fvtt-mournblade/assets/icons/" + actor.data.data.attributs[rollData.attrKey].labelnorm + ".webp" - rollData.attr = duplicate(actor.data.data.attributs[rollData.attrKey]) + rollData.actionImg = "systems/fvtt-mournblade/assets/icons/" + actor.system.attributs[rollData.attrKey].labelnorm + ".webp" + rollData.attr = duplicate(actor.system.attributs[rollData.attrKey]) } rollData.diceFormula = rollData.mainDice @@ -321,15 +308,15 @@ export class MournbladeUtility { } } if (rollData.competence) { - rollData.predilections = duplicate( rollData.competence.data.predilections.filter( pred => !pred.used) || [] ) - let compmod = (rollData.competence.data.niveau == 0) ? -3 : 0 - rollData.diceFormula += `+${rollData.attr.value}+${rollData.competence.data.niveau}+${rollData.modificateur}+${compmod}` + rollData.predilections = duplicate( rollData.competence.system.predilections.filter( pred => !pred.used) || [] ) + let compmod = (rollData.competence.system.niveau == 0) ? -3 : 0 + rollData.diceFormula += `+${rollData.attr.value}+${rollData.competence.system.niveau}+${rollData.modificateur}+${compmod}` } else { rollData.diceFormula += `+${rollData.attr.value}*2+${rollData.modificateur}` } if (rollData.arme) { - rollData.diceFormula += `+${rollData.arme.data.bonusmaniementoff}` + rollData.diceFormula += `+${rollData.arme.system.bonusmaniementoff}` } if(rollData.rune) { diff --git a/styles/simple.css b/styles/simple.css index bb686f8..3d4d286 100644 --- a/styles/simple.css +++ b/styles/simple.css @@ -8,7 +8,7 @@ :root { /* =================== 1. ACTOR SHEET FONT STYLES =========== */ --window-header-font-family: Charlemagne; - --window-header-title-font-size: 1.3rem; + --window-header-title-font-size: 1.1rem; --window-header-title-font-weight: normal; --window-header-title-color: #f5f5f5; @@ -44,15 +44,16 @@ /*@import url("https://fonts.googleapis.com/css2?family=Martel:wght@400;800&family=Roboto:wght@300;400;500&display=swap");*/ /* Global styles & Font */ .window-app { + font-family: Charlemagne; text-align: justify; - font-size: 16px; + font-size: 12px; letter-spacing: 1px; } /* Fonts */ .sheet header.sheet-header h1 input, .window-app .window-header, #actors .directory-list, #navigation #scene-list .scene.nav-item { font-family: "Charlemagne"; - font-size: 1.0rem; + font-size: 0.8rem; } /* For title, sidebar character and scene */ .sheet nav.sheet-tabs { font-family: "Charlemagne"; diff --git a/system.json b/system.json index 8f46203..9d379ee 100644 --- a/system.json +++ b/system.json @@ -13,11 +13,6 @@ "gridDistance": 5, "gridUnits": "m", "languages": [ - { - "lang": "en", - "name": "English", - "path": "lang/en.json" - } ], "library": false, "license": "LICENSE.txt", @@ -70,6 +65,7 @@ }, { "label": "Dons", + "type": "Item", "name": "dons", "path": "./packs/dons.db", "system": "fvtt-mournblade", diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 2d73626..fc9acfb 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -12,14 +12,14 @@