Mourblade : add initiative

This commit is contained in:
sladecraven 2022-09-26 13:34:07 +02:00
parent 734945d68e
commit fcec785f00
5 changed files with 66 additions and 77 deletions

View File

@ -188,11 +188,11 @@ export class MournbladeActor extends Actor {
if (this.type == 'personnage') { if (this.type == 'personnage') {
let newSante = this.system.sante.bonus + (this.system.attributs.pui.value + this.system.attributs.tre.value) * 2 + 5 let newSante = this.system.sante.bonus + (this.system.attributs.pui.value + this.system.attributs.tre.value) * 2 + 5
if (this.system.sante.base != newSante) { 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 let newAme = (this.system.attributs.cla.value + this.system.attributs.tre.value) * this.system.biodata.amemultiplier + 5
if (this.system.ame.fullmax != newAme) { 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) { async equipItem(itemId) {
let item = this.items.find(item => item.id == itemId); let item = this.items.find(item => item.id == itemId);
if (item && item.system.data) { 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 await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity
} }
} }
@ -233,7 +233,7 @@ export class MournbladeActor extends Actor {
} else { } else {
value = String(value) value = String(value)
} }
let update = { _id: item.id, [`data.${itemField}`]: value }; let update = { _id: item.id, [`system.${itemField}`]: value };
this.updateEmbeddedDocuments("Item", [update]) this.updateEmbeddedDocuments("Item", [update])
} }
} }
@ -247,7 +247,7 @@ export class MournbladeActor extends Actor {
changeBonneAventure(value) { changeBonneAventure(value) {
let newBA = this.system.bonneaventure.actuelle let newBA = this.system.bonneaventure.actuelle
newBA += value 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) { changeEclat(value) {
let newE = this.system.eclat.value let newE = this.system.eclat.value
newE += 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 { } else {
ame.currentmax -= value 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) { async equipGear(equipmentId) {
let item = this.items.find(item => item.id == equipmentId); let item = this.items.find(item => item.id == equipmentId);
if (item && item.system.data) { 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 await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity
} }
} }
@ -319,7 +319,7 @@ export class MournbladeActor extends Actor {
async addSubActor(subActorId) { async addSubActor(subActorId) {
let subActors = duplicate(this.system.subactors); let subActors = duplicate(this.system.subactors);
subActors.push(subActorId); subActors.push(subActorId);
await this.update({ 'data.subactors': subActors }); await this.update({ 'system.subactors': subActors });
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async delSubActor(subActorId) { async delSubActor(subActorId) {
@ -329,7 +329,7 @@ export class MournbladeActor extends Actor {
newArray.push(id); 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) let objetQ = this.items.get(objetId)
if (objetQ) { if (objetQ) {
let newQ = objetQ.system.quantity + incDec; 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 comp = this.items.get(compId)
let pred = duplicate(comp.system.predilections) let pred = duplicate(comp.system.predilections)
pred[predIdx].used = true 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) { async rollRune(runeId) {
let rollData = this.getCommonRollData("cla", undefined, "Savoir : Runes") let rollData = this.getCommonRollData("cla", undefined, "Savoir : Runes")
rollData.rune = duplicate(this.items.get(runeId) || {}) 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.runemode = "prononcer"
rollData.runeame = 1 rollData.runeame = 1
console.log("runeData", rollData) console.log("runeData", rollData)

View File

@ -9,8 +9,11 @@ export class MournbladeCombat extends Combat {
for (let cId = 0; cId < ids.length; cId++) { for (let cId = 0; cId < ids.length; cId++) {
const c = this.combatants.get(ids[cId]); const c = this.combatants.get(ids[cId]);
let id = c._id || c.id; let id = c._id || c.id;
let initBonus = c.actor ? c.actor.getInitiativeScore( this.id, id ) : -1; let initBonus = c.actor ? c.actor.getInitiativeScore() : 0
await this.updateEmbeddedDocuments("Combatant", [ { _id: id, initiative: initBonus } ]); 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; return this;

View File

@ -327,7 +327,7 @@ export class MournbladeUtility {
} }
let myRoll = new Roll(rollData.diceFormula).roll({ async: false }) 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 rollData.roll = myRoll
console.log(">>>> ", myRoll) console.log(">>>> ", myRoll)

View File

@ -1,10 +1,11 @@
{ {
"id": "fvtt-mournblade", "id": "fvtt-mournblade",
"description": "Mournblade RPG for FoundryVTT", "description": "Mournblade RPG for FoundryVTT",
"version": "10.0.1", "version": "10.0.2",
"authors": [ "authors": [
{ {
"name": "Uberwald/LeRatierBretonnien" "name": "Uberwald/LeRatierBretonnien",
"flags": {}
} }
], ],
"esmodules": [ "esmodules": [
@ -12,136 +13,117 @@
], ],
"gridDistance": 5, "gridDistance": 5,
"gridUnits": "m", "gridUnits": "m",
"languages": [
],
"library": false,
"license": "LICENSE.txt", "license": "LICENSE.txt",
"manifest": "https://www.uberwald.me/gitea/public/fvtt-mournblade/raw/branch/v10/system.json", "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", "download": "https://www.uberwald.me/gitea/public/fvtt-mournblade/archive/fvtt-mournblade-10.0.2.zip",
"manifestPlusVersion": "1.0.0",
"media": [],
"packs": [ "packs": [
{ {
"type": "Item", "type": "Item",
"label": "Compétences", "label": "Compétences",
"name": "skills", "name": "skills",
"path": "./packs/skills.db", "path": "packs/skills.db",
"system": "fvtt-mournblade", "system": "fvtt-mournblade",
"tags": [ "private": false,
"skill", "flags": {}
"competence"
]
}, },
{ {
"type": "Item", "type": "Item",
"label": "Armes", "label": "Armes",
"name": "armes", "name": "armes",
"path": "./packs/armes.db", "path": "packs/armes.db",
"system": "fvtt-mournblade", "system": "fvtt-mournblade",
"tags": [ "private": false,
"arme" "flags": {}
]
}, },
{ {
"type": "Item", "type": "Item",
"label": "Protections", "label": "Protections",
"name": "protection", "name": "protection",
"path": "./packs/protection.db", "path": "packs/protection.db",
"system": "fvtt-mournblade", "system": "fvtt-mournblade",
"tags": [ "private": false,
"armor", "flags": {}
"shield"
]
}, },
{ {
"type": "Item", "type": "Item",
"label": "Equipement", "label": "Equipement",
"name": "equipement", "name": "equipement",
"path": "./packs/equipement.db", "path": "packs/equipement.db",
"system": "fvtt-mournblade", "system": "fvtt-mournblade",
"tags": [ "private": false,
"equipement" "flags": {}
]
}, },
{ {
"label": "Dons", "label": "Dons",
"type": "Item", "type": "Item",
"name": "dons", "name": "dons",
"path": "./packs/dons.db", "path": "packs/dons.db",
"system": "fvtt-mournblade", "system": "fvtt-mournblade",
"tags": [ "private": false,
"don" "flags": {}
]
}, },
{ {
"type": "Item", "type": "Item",
"label": "Origines", "label": "Origines",
"name": "origines", "name": "origines",
"path": "./packs/origines.db", "path": "packs/origines.db",
"system": "fvtt-mournblade", "system": "fvtt-mournblade",
"tags": [ "private": false,
"originess" "flags": {}
]
}, },
{ {
"type": "Item", "type": "Item",
"label": "Héritages", "label": "Héritages",
"name": "heritages", "name": "heritages",
"path": "./packs/heritages.db", "path": "packs/heritages.db",
"system": "fvtt-mournblade", "system": "fvtt-mournblade",
"tags": [ "private": false,
"héritage" "flags": {}
]
}, },
{ {
"type": "Item", "type": "Item",
"label": "Métiers", "label": "Métiers",
"name": "metiers", "name": "metiers",
"path": "./packs/metiers.db", "path": "packs/metiers.db",
"system": "fvtt-mournblade", "system": "fvtt-mournblade",
"tags": [ "private": false,
"metier" "flags": {}
]
}, },
{ {
"type": "Item", "type": "Item",
"label": "Tendances", "label": "Tendances",
"name": "tendances", "name": "tendances",
"path": "./packs/tendances.db", "path": "packs/tendances.db",
"system": "fvtt-mournblade", "system": "fvtt-mournblade",
"tags": [ "private": false,
"tendance" "flags": {}
]
}, },
{ {
"type": "Item", "type": "Item",
"label": "Traits chaotiques", "label": "Traits chaotiques",
"name": "traits-chaotiques", "name": "traits-chaotiques",
"path": "./packs/traits-chaotiques.db", "path": "packs/traits-chaotiques.db",
"system": "fvtt-mournblade", "system": "fvtt-mournblade",
"tags": [ "private": false,
"traits chaotiques" "flags": {}
]
}, },
{ {
"type": "Item", "type": "Item",
"label": "Runes", "label": "Runes",
"name": "runes", "name": "runes",
"path": "./packs/runes.db", "path": "packs/runes.db",
"system": "fvtt-mournblade", "system": "fvtt-mournblade",
"tags": [ "private": false,
"runes" "flags": {}
]
}, },
{ {
"type": "RollTable", "type": "RollTable",
"label": "Tables", "label": "Tables",
"name": "tables", "name": "tables",
"path": "./packs/tables.db", "path": "packs/tables.db",
"system": "fvtt-mournblade", "system": "fvtt-mournblade",
"tags": [ "private": false,
"tables" "flags": {}
]
} }
], ],
"primaryTokenAttribute": "secondary.health", "primaryTokenAttribute": "secondary.health",
@ -150,13 +132,12 @@
"styles": [ "styles": [
"styles/simple.css" "styles/simple.css"
], ],
"templateVersion": 18,
"title": "Mournblade", "title": "Mournblade",
"url": "https://www.uberwald.me/gitea/public/fvtt-mournblade", "url": "https://www.uberwald.me/gitea/public/fvtt-mournblade",
"background": "systems/fvtt-mournblade/assets/ui/fond_mournblade.webp", "background": "systems/fvtt-mournblade/assets/ui/fond_mournblade.webp",
"compatibility": { "compatibility": {
"minimum": "10", "minimum": "10",
"verified": "10.285", "verified": "10.286",
"maximum": "10" "maximum": "10"
} }
} }

View File

@ -64,7 +64,7 @@
<li class="prediction-item item flexrow" data-prediction-index="{{key}}"> <li class="prediction-item item flexrow" data-prediction-index="{{key}}">
<input type="text" class="padd-right color-class-common edit-prediction" <input type="text" class="padd-right color-class-common edit-prediction"
name="system.predilections[{{key}}]" value="{{predilection.name}}" data-dtype="String" /> name="system.predilections[{{key}}]" value="{{predilection.name}}" data-dtype="String" />
<input class="use-prediction" type="checkbox" name="predilection.used" value="{{predilection.used}}" {{checked predilection.used}} /> <label class="generic-label">Utilisée ? <input class="use-prediction" type="checkbox" name="predilection.used" value="{{predilection.used}}" {{checked predilection.used}} /></label>
<a class="item-control delete-prediction" title="Supprimer une predilection"><i class="fas fa-trash"></i></a> <a class="item-control delete-prediction" title="Supprimer une predilection"><i class="fas fa-trash"></i></a>
</li> </li>
{{/each}} {{/each}}