Mourblade : add initiative
This commit is contained in:
@@ -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)
|
||||
|
@@ -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;
|
||||
|
@@ -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)
|
||||
|
||||
|
Reference in New Issue
Block a user