From fcec785f001521c7f0ea41833575da55aa1ff121 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Mon, 26 Sep 2022 13:34:07 +0200 Subject: [PATCH] Mourblade : add initiative --- modules/mournblade-actor.js | 31 ++++---- modules/mournblade-combat.js | 7 +- modules/mournblade-utility.js | 2 +- system.json | 101 +++++++++++---------------- templates/item-competence-sheet.html | 2 +- 5 files changed, 66 insertions(+), 77 deletions(-) diff --git a/modules/mournblade-actor.js b/modules/mournblade-actor.js index d558046..bbab915 100644 --- a/modules/mournblade-actor.js +++ b/modules/mournblade-actor.js @@ -188,11 +188,11 @@ export class MournbladeActor extends Actor { if (this.type == 'personnage') { 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 }) + this.update({ 'system.sante.base': newSante }) } 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 }) + this.update({ 'system.ame.fullmax': newAme }) } } @@ -218,7 +218,7 @@ export class MournbladeActor extends Actor { async equipItem(itemId) { let item = this.items.find(item => item.id == itemId); if (item && item.system.data) { - let update = { _id: item.id, "data.equipped": !item.system.equipped }; + let update = { _id: item.id, "system.equipped": !item.system.equipped }; await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity } } @@ -233,7 +233,7 @@ export class MournbladeActor extends Actor { } else { value = String(value) } - let update = { _id: item.id, [`data.${itemField}`]: value }; + let update = { _id: item.id, [`system.${itemField}`]: value }; this.updateEmbeddedDocuments("Item", [update]) } } @@ -247,7 +247,7 @@ export class MournbladeActor extends Actor { changeBonneAventure(value) { let newBA = this.system.bonneaventure.actuelle newBA += value - this.update({ 'data.bonneaventure.actuelle': newBA }) + this.update({ 'system.bonneaventure.actuelle': newBA }) } /* -------------------------------------------- */ @@ -259,7 +259,7 @@ export class MournbladeActor extends Actor { changeEclat(value) { let newE = this.system.eclat.value newE += value - this.update({ 'data.eclat.value': newE }) + this.update({ 'system.eclat.value': newE }) } /* -------------------------------------------- */ @@ -274,7 +274,7 @@ export class MournbladeActor extends Actor { } else { ame.currentmax -= value } - this.update( {'data.ame': ame}) + this.update( {'system.ame': ame}) } /* -------------------------------------------- */ @@ -302,7 +302,7 @@ export class MournbladeActor extends Actor { async equipGear(equipmentId) { let item = this.items.find(item => item.id == equipmentId); if (item && item.system.data) { - let update = { _id: item.id, "data.equipped": !item.system.equipped }; + let update = { _id: item.id, "system.equipped": !item.system.equipped }; await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity } } @@ -319,7 +319,7 @@ export class MournbladeActor extends Actor { async addSubActor(subActorId) { let subActors = duplicate(this.system.subactors); subActors.push(subActorId); - await this.update({ 'data.subactors': subActors }); + await this.update({ 'system.subactors': subActors }); } /* -------------------------------------------- */ async delSubActor(subActorId) { @@ -329,7 +329,7 @@ export class MournbladeActor extends Actor { newArray.push(id); } } - await this.update({ 'data.subactors': newArray }); + await this.update({ 'system.subactors': newArray }); } /* -------------------------------------------- */ @@ -337,7 +337,7 @@ export class MournbladeActor extends Actor { let objetQ = this.items.get(objetId) if (objetQ) { let newQ = objetQ.system.quantity + incDec; - const updated = await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'data.quantity': newQ }]); // pdates one EmbeddedEntity + const updated = await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'system.quantity': newQ }]); // pdates one EmbeddedEntity } } @@ -351,7 +351,12 @@ export class MournbladeActor extends Actor { 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 }]) + await this.updateEmbeddedDocuments('Item', [{ _id: compId, 'system.predilections': pred }]) + } + + /* -------------------------------------------- */ + getInitiativeScore( ) { + return Number(this.system.attributs.adr.value) + Number(this.system.combat.initbonus) } /* -------------------------------------------- */ @@ -403,7 +408,7 @@ export class MournbladeActor extends Actor { async rollRune(runeId) { let rollData = this.getCommonRollData("cla", undefined, "Savoir : Runes") rollData.rune = duplicate(this.items.get(runeId) || {}) - rollData.difficulte = rollData.rune?.data?.seuil || 0 + rollData.difficulte = rollData.rune?.system?.seuil || 0 rollData.runemode = "prononcer" rollData.runeame = 1 console.log("runeData", rollData) diff --git a/modules/mournblade-combat.js b/modules/mournblade-combat.js index 14e21a8..2c4eff6 100644 --- a/modules/mournblade-combat.js +++ b/modules/mournblade-combat.js @@ -9,8 +9,11 @@ export class MournbladeCombat extends Combat { for (let cId = 0; cId < ids.length; cId++) { const c = this.combatants.get(ids[cId]); let id = c._id || c.id; - let initBonus = c.actor ? c.actor.getInitiativeScore( this.id, id ) : -1; - await this.updateEmbeddedDocuments("Combatant", [ { _id: id, initiative: initBonus } ]); + let initBonus = c.actor ? c.actor.getInitiativeScore() : 0 + let roll = new Roll("1d10 + "+initBonus).roll({ async: false}) + await MournbladeUtility.showDiceSoNice(roll, game.settings.get("core", "rollMode")) + console.log("Init bonus", initBonus, roll.total) + await this.updateEmbeddedDocuments("Combatant", [ { _id: id, initiative: roll.total } ]); } return this; diff --git a/modules/mournblade-utility.js b/modules/mournblade-utility.js index eb733f3..7b4771b 100644 --- a/modules/mournblade-utility.js +++ b/modules/mournblade-utility.js @@ -327,7 +327,7 @@ export class MournbladeUtility { } let myRoll = new Roll(rollData.diceFormula).roll({ async: false }) - await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode")); + await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode")) rollData.roll = myRoll console.log(">>>> ", myRoll) diff --git a/system.json b/system.json index b7d08f2..d5afb4d 100644 --- a/system.json +++ b/system.json @@ -1,10 +1,11 @@ { "id": "fvtt-mournblade", "description": "Mournblade RPG for FoundryVTT", - "version": "10.0.1", + "version": "10.0.2", "authors": [ { - "name": "Uberwald/LeRatierBretonnien" + "name": "Uberwald/LeRatierBretonnien", + "flags": {} } ], "esmodules": [ @@ -12,136 +13,117 @@ ], "gridDistance": 5, "gridUnits": "m", - "languages": [ - ], - "library": false, "license": "LICENSE.txt", "manifest": "https://www.uberwald.me/gitea/public/fvtt-mournblade/raw/branch/v10/system.json", - "download": "https://www.uberwald.me/gitea/public/fvtt-mournblade/archive/fvtt-mournblade-10.0.1.zip", - "manifestPlusVersion": "1.0.0", - "media": [], + "download": "https://www.uberwald.me/gitea/public/fvtt-mournblade/archive/fvtt-mournblade-10.0.2.zip", "packs": [ { "type": "Item", "label": "Compétences", "name": "skills", - "path": "./packs/skills.db", + "path": "packs/skills.db", "system": "fvtt-mournblade", - "tags": [ - "skill", - "competence" - ] + "private": false, + "flags": {} }, { "type": "Item", "label": "Armes", "name": "armes", - "path": "./packs/armes.db", + "path": "packs/armes.db", "system": "fvtt-mournblade", - "tags": [ - "arme" - ] + "private": false, + "flags": {} }, { "type": "Item", "label": "Protections", "name": "protection", - "path": "./packs/protection.db", + "path": "packs/protection.db", "system": "fvtt-mournblade", - "tags": [ - "armor", - "shield" - ] + "private": false, + "flags": {} }, { "type": "Item", "label": "Equipement", "name": "equipement", - "path": "./packs/equipement.db", + "path": "packs/equipement.db", "system": "fvtt-mournblade", - "tags": [ - "equipement" - ] + "private": false, + "flags": {} }, { "label": "Dons", "type": "Item", "name": "dons", - "path": "./packs/dons.db", + "path": "packs/dons.db", "system": "fvtt-mournblade", - "tags": [ - "don" - ] + "private": false, + "flags": {} }, { "type": "Item", "label": "Origines", "name": "origines", - "path": "./packs/origines.db", + "path": "packs/origines.db", "system": "fvtt-mournblade", - "tags": [ - "originess" - ] + "private": false, + "flags": {} }, { "type": "Item", "label": "Héritages", "name": "heritages", - "path": "./packs/heritages.db", + "path": "packs/heritages.db", "system": "fvtt-mournblade", - "tags": [ - "héritage" - ] + "private": false, + "flags": {} }, { "type": "Item", "label": "Métiers", "name": "metiers", - "path": "./packs/metiers.db", + "path": "packs/metiers.db", "system": "fvtt-mournblade", - "tags": [ - "metier" - ] + "private": false, + "flags": {} }, { "type": "Item", "label": "Tendances", "name": "tendances", - "path": "./packs/tendances.db", + "path": "packs/tendances.db", "system": "fvtt-mournblade", - "tags": [ - "tendance" - ] + "private": false, + "flags": {} }, { "type": "Item", "label": "Traits chaotiques", "name": "traits-chaotiques", - "path": "./packs/traits-chaotiques.db", + "path": "packs/traits-chaotiques.db", "system": "fvtt-mournblade", - "tags": [ - "traits chaotiques" - ] + "private": false, + "flags": {} }, { "type": "Item", "label": "Runes", "name": "runes", - "path": "./packs/runes.db", + "path": "packs/runes.db", "system": "fvtt-mournblade", - "tags": [ - "runes" - ] + "private": false, + "flags": {} }, { "type": "RollTable", "label": "Tables", "name": "tables", - "path": "./packs/tables.db", + "path": "packs/tables.db", "system": "fvtt-mournblade", - "tags": [ - "tables" - ] + "private": false, + "flags": {} } ], "primaryTokenAttribute": "secondary.health", @@ -150,13 +132,12 @@ "styles": [ "styles/simple.css" ], - "templateVersion": 18, "title": "Mournblade", "url": "https://www.uberwald.me/gitea/public/fvtt-mournblade", "background": "systems/fvtt-mournblade/assets/ui/fond_mournblade.webp", "compatibility": { "minimum": "10", - "verified": "10.285", + "verified": "10.286", "maximum": "10" } } \ No newline at end of file diff --git a/templates/item-competence-sheet.html b/templates/item-competence-sheet.html index d30b87a..db92264 100644 --- a/templates/item-competence-sheet.html +++ b/templates/item-competence-sheet.html @@ -64,7 +64,7 @@
  • - +
  • {{/each}}