Appréciation des services
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { ITEM_TYPES } from "../constants.js"
|
||||
import { SANS_COMPETENCE } from "../item/base-items.js"
|
||||
import { Misc } from "../misc.js"
|
||||
import { CARACS } from "../rdd-carac.js"
|
||||
import { RdDUtility } from "../rdd-utility.js"
|
||||
import { DIFF } from "../roll/roll-constants.mjs"
|
||||
@@ -100,16 +101,16 @@ export class Apprecier {
|
||||
this.raisons = []
|
||||
}
|
||||
|
||||
apprecier(rollCallbacks = []) {
|
||||
apprecier(callbacks = []) {
|
||||
if (this.qualite <= 0) {
|
||||
this.raisons.push(`la qualité ${this.qualite} est négative.`)
|
||||
}
|
||||
if (this.qualite <= this.actor.getMoralTotal()) {
|
||||
this.raisons.push(`la qualité de ${this.qualite} est inférieure au moral de ${this.actor.getMoralTotal()}.`)
|
||||
}
|
||||
const competence = this.actor.getCompetence(this.appreciation.competence) ?? SANS_COMPETENCE
|
||||
if (this.appreciation.compMinimum && this.qualite <= competence.system.niveau && competence.system.niveau > 0) {
|
||||
this.raisons.push(`la qualité ${this.qualite} est insuffisante pour le niveau ${competence.system.niveau} en ${this.appreciation.competence}`)
|
||||
const competence = this.getCompetenceAppreciation()
|
||||
if (this.appreciation.compMinimum && this.qualite <= competence.system.niveau && competence.system.niveau > 0 && competence.id) {
|
||||
this.raisons.push(`la qualité ${this.qualite} est insuffisante pour le niveau ${competence.system.niveau} en ${competence.name}`)
|
||||
}
|
||||
const bonmoment = this.appreciation.bonmoment
|
||||
if (!["", undefined].includes(bonmoment) && this.actor.system.compteurs.bonmoments.includes(bonmoment)) {
|
||||
@@ -117,13 +118,17 @@ export class Apprecier {
|
||||
}
|
||||
|
||||
if (this.appreciation.carac != "") {
|
||||
this.rollAppreciation(rollCallbacks)
|
||||
this.rollAppreciation(callbacks)
|
||||
}
|
||||
else {
|
||||
this.rollMoral()
|
||||
}
|
||||
}
|
||||
|
||||
getCompetenceAppreciation() {
|
||||
return [SANS_COMPETENCE.name, ""].includes(this.appreciation.competence) ? SANS_COMPETENCE : this.actor.getCompetence(this.appreciation.competence)
|
||||
}
|
||||
|
||||
rollAppreciation(rollCallbacks = []) {
|
||||
const competence = (this.appreciation.jetComp && this.appreciation.competence) ? this.appreciation.competence : ""
|
||||
const rollData = {
|
||||
@@ -161,6 +166,7 @@ export class Apprecier {
|
||||
|
||||
async rollMoral(moral = undefined) {
|
||||
if (this.raisons.length > 0) {
|
||||
ui.notifications.info('Pas de jet de moral:' + Misc.concat(this.raisons.map(r => `<br> - ${r}`)))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user