Gestion assistée pour les actions
This commit is contained in:
@@ -77,6 +77,31 @@ export class TeDeumActor extends Actor {
|
||||
return 0
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getMeilleureCompetenceMainGauche(comp) {
|
||||
let compScore = this.getCompetenceScore(comp.name)
|
||||
let mainGaucheScore = this.getCompetenceScore("main gauche")
|
||||
if (mainGaucheScore < compScore) {
|
||||
ui.notifications.info(`${actor.name} : Utilisation de la compétence Main Gauche au lieu de ${comp.name}`)
|
||||
let mainGaucheComp = this.itms.find(item => item.type == "competence" && item.name.toLowerCase() == "main gauche")
|
||||
if (!mainGaucheComp) {
|
||||
// Create a fake competence object
|
||||
mainGaucheComp = foundry.utils.duplicate(comp)
|
||||
mainGaucheComp.name = "Main Gauche"
|
||||
mainGaucheComp.system.isBase = false
|
||||
mainGaucheComp.system.score = 0
|
||||
mainGaucheComp.system.caracteristique = "adresse"
|
||||
mainGaucheComp.system.description = "Compétence Main Gauche (automatique)"
|
||||
mainGaucheComp.system.isMainGauche = true
|
||||
return mainGaucheComp
|
||||
} else {
|
||||
return mainGaucheComp
|
||||
}
|
||||
} else {
|
||||
return comp
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_onUpdate(changed, options, userId) {
|
||||
let updates = []
|
||||
@@ -116,12 +141,6 @@ export class TeDeumActor extends Actor {
|
||||
updates.push({ _id: initiative.id, "system.score": Number(newScore) })
|
||||
}
|
||||
|
||||
let actionsTour = this.items.find(item => item.type == "competence" && item.name.toLowerCase() == "actions/tour")
|
||||
newScore = this.getCommonBaseValue(this.system.caracteristiques.adresse.value)
|
||||
if (actionsTour && actionsTour?.system.score != newScore) {
|
||||
updates.push({ _id: actionsTour.id, "system.score": Number(newScore) })
|
||||
}
|
||||
|
||||
let effort = this.items.find(item => item.type == "competence" && item.name.toLowerCase() == "effort")
|
||||
newScore = this.getCommonBaseValue(this.system.caracteristiques.puissance.value)
|
||||
if (effort && effort?.system.score != newScore) {
|
||||
@@ -151,7 +170,7 @@ export class TeDeumActor extends Actor {
|
||||
getCommonBaseValue(value) {
|
||||
return game.system.tedeum.config.COMMON_VALUE[value]?.value || 0
|
||||
}
|
||||
getInitiative() {
|
||||
getInitiativeValue() {
|
||||
return game.system.tedeum.config.COMMON_VALUE[this.system.caracteristiques.adresse.value]?.value || 0
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
@@ -616,21 +635,16 @@ export class TeDeumActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getInitiativeScore() {
|
||||
let initiative = this.items.find(it => it.type == "competence" && it.name.toLowerCase() == "initiative")
|
||||
initiative = foundry.utils.duplicate(initiative)
|
||||
let initiative = this.getInitiativeValue()
|
||||
// Vérifie les armes avec bonus d'initiative
|
||||
let armes = this.getArmes()
|
||||
for (let arme of armes) {
|
||||
if (arme.system.equipe && arme.system.bonusInitiative != 0) {
|
||||
ui.notifications.info("L'arme " + arme.name + " vous confère un bonus d'initiative de " + arme.system.bonusInitiative)
|
||||
initiative.system.score += 1
|
||||
if (arme.system.equipe && Number(arme.system.initiativeBonus) && Number(arme.system.initiativeBonus) != 0) {
|
||||
ui.notifications.info("L'arme " + arme.name + " vous confère un bonus d'initiative de " + arme.system.initiativeBonus)
|
||||
initiative += arme.system.initiativeBonus
|
||||
}
|
||||
}
|
||||
if (initiative) {
|
||||
return initiative.system.score
|
||||
}
|
||||
ui.notifications.warn("Impossible de trouver la compétence Initiative pour l'acteur " + this.name)
|
||||
return -1;
|
||||
return initiative
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
Reference in New Issue
Block a user