Revision armes/boucliers

This commit is contained in:
2022-10-01 08:47:01 +02:00
parent da6d6584c4
commit 983bc6a2ed
15 changed files with 281 additions and 156 deletions

View File

@@ -71,6 +71,19 @@ export class MournbladeActor extends Actor {
}
return arme
}
/* -------------------------------------------- */
prepareBouclier(bouclier) {
bouclier = duplicate(bouclier)
let combat = this.getCombatValues()
bouclier.system.competence = duplicate(this.items.find(item => item.type == "competence" && item.name.toLowerCase() == "mêlée"))
bouclier.system.attrKey = "pui"
bouclier.system.totalDegats = bouclier.system.degats + "+" + combat.bonusDegatsTotal
bouclier.system.totalOffensif = this.system.attributs.pui.value + bouclier.system.competence.system.niveau
bouclier.system.isdefense = true
bouclier.system.bonusmaniementoff = 0
bouclier.system.totalDefensif = combat.defenseTotal + bouclier.system.competence.system.niveau + bouclier.system.bonusdefense
return bouclier
}
/* -------------------------------------------- */
getWeapons() {
@@ -79,6 +92,9 @@ export class MournbladeActor extends Actor {
if (arme.type == "arme") {
armes.push(this.prepareArme(arme))
}
if (arme.type == "bouclier") {
armes.push(this.prepareBouclier(arme))
}
}
return armes
}
@@ -179,6 +195,7 @@ export class MournbladeActor extends Actor {
}
return combat
}
/* -------------------------------------------- */
prepareBaseData() {
}
@@ -222,9 +239,9 @@ 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, "system.equipped": !item.system.equipped };
let item = this.items.find(item => item.id == itemId)
if (item && item.system) {
let update = { _id: item.id, "system.equipped": !item.system.equipped }
await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity
}
}
@@ -364,6 +381,25 @@ export class MournbladeActor extends Actor {
getInitiativeScore( ) {
return Number(this.system.attributs.adr.value) + Number(this.system.combat.initbonus)
}
/* -------------------------------------------- */
getBestDefenseValue() {
let defenseList = this.items.filter(item => (item.type =="arme" || item.type == "bouclier") && item.system.equipped)
let maxDef = 0
let bestArme
for(let arme of defenseList) {
if (arme.type == "arme" && arme.system.isdefense) {
arme = this.prepareArme(arme)
}
if (arme.type == "bouclier" ) {
arme = this.prepareBouclier(arme)
}
if ( arme.system.totalDefensif > maxDef) {
maxDef = arme.system.totalDefensif
bestArme = duplicate(arme)
}
}
return bestArme
}
/* -------------------------------------------- */
getCommonRollData(attrKey = undefined, compId = undefined, compName = undefined) {
@@ -430,7 +466,12 @@ export class MournbladeActor extends Actor {
/* -------------------------------------------- */
async rollArmeOffensif(armeId) {
let arme = this.items.get(armeId)
arme = this.prepareArme(arme)
if (arme.type == "arme") {
arme = this.prepareArme(arme)
}
if (arme.type == "bouclier") {
arme = this.prepareBouclier(arme)
}
let rollData = this.getCommonRollData(arme.system.attrKey, arme.system.competence._id)
rollData.arme = arme
console.log("ARME!", rollData)
@@ -441,7 +482,12 @@ export class MournbladeActor extends Actor {
/* -------------------------------------------- */
async rollArmeDegats(armeId) {
let arme = this.items.get(armeId)
arme = this.prepareArme(arme)
if (arme.type == "arme") {
arme = this.prepareArme(arme)
}
if (arme.type == "bouclier") {
arme = this.prepareBouclier(arme)
}
let roll = new Roll(arme.system.totalDegats).roll({ async: false })
await MournbladeUtility.showDiceSoNice(roll, game.settings.get("core", "rollMode"));
let rollData = {