Appréciation des services

This commit is contained in:
2025-12-08 20:10:56 +01:00
parent f0736015a7
commit dd7a3700dc
4 changed files with 21 additions and 12 deletions
+5 -1
View File
@@ -11,6 +11,7 @@ import { RdDUtility } from "../rdd-utility.js";
import { SystemCompendiums } from "../settings/system-compendiums.js"; import { SystemCompendiums } from "../settings/system-compendiums.js";
import { RdDItem } from "../item.js"; import { RdDItem } from "../item.js";
import { StatusEffects, STATUSES } from "../settings/status-effects.js"; import { StatusEffects, STATUSES } from "../settings/status-effects.js";
import { Apprecier } from "../moral/apprecier.mjs";
export class RdDBaseActor extends Actor { export class RdDBaseActor extends Actor {
@@ -517,10 +518,13 @@ export class RdDBaseActor extends Actor {
async acheter(item, quantite, cout, achat) { async acheter(item, quantite, cout, achat) {
await this.depenserSols(cout) await this.depenserSols(cout)
const createdItemId = await this.creerQuantiteItem(item, quantite) const createdItemId = await this.creerQuantiteItem(item, quantite)
if (achat.choix.consommer && item.type == 'nourritureboisson' && createdItemId != undefined) { if (item.type == ITEM_TYPES.nourritureboisson && achat.choix.consommer && createdItemId != undefined) {
achat.choix.doses = achat.choix.nombreLots; achat.choix.doses = achat.choix.nombreLots;
await this.consommerNourritureboisson(createdItemId, achat.choix, achat.vente.actingUserId); await this.consommerNourritureboisson(createdItemId, achat.choix, achat.vente.actingUserId);
} }
if (item.type == ITEM_TYPES.service) {
new Apprecier(this, item.system.appreciation, item.system.qualite).apprecier()
}
} }
verifierFortune(cout) { verifierFortune(cout) {
+11 -5
View File
@@ -1,5 +1,6 @@
import { ITEM_TYPES } from "../constants.js" import { ITEM_TYPES } from "../constants.js"
import { SANS_COMPETENCE } from "../item/base-items.js" import { SANS_COMPETENCE } from "../item/base-items.js"
import { Misc } from "../misc.js"
import { CARACS } from "../rdd-carac.js" import { CARACS } from "../rdd-carac.js"
import { RdDUtility } from "../rdd-utility.js" import { RdDUtility } from "../rdd-utility.js"
import { DIFF } from "../roll/roll-constants.mjs" import { DIFF } from "../roll/roll-constants.mjs"
@@ -100,16 +101,16 @@ export class Apprecier {
this.raisons = [] this.raisons = []
} }
apprecier(rollCallbacks = []) { apprecier(callbacks = []) {
if (this.qualite <= 0) { if (this.qualite <= 0) {
this.raisons.push(`la qualité ${this.qualite} est négative.`) this.raisons.push(`la qualité ${this.qualite} est négative.`)
} }
if (this.qualite <= this.actor.getMoralTotal()) { if (this.qualite <= this.actor.getMoralTotal()) {
this.raisons.push(`la qualité de ${this.qualite} est inférieure au moral de ${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 const competence = this.getCompetenceAppreciation()
if (this.appreciation.compMinimum && this.qualite <= competence.system.niveau && competence.system.niveau > 0) { 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 ${this.appreciation.competence}`) this.raisons.push(`la qualité ${this.qualite} est insuffisante pour le niveau ${competence.system.niveau} en ${competence.name}`)
} }
const bonmoment = this.appreciation.bonmoment const bonmoment = this.appreciation.bonmoment
if (!["", undefined].includes(bonmoment) && this.actor.system.compteurs.bonmoments.includes(bonmoment)) { if (!["", undefined].includes(bonmoment) && this.actor.system.compteurs.bonmoments.includes(bonmoment)) {
@@ -117,13 +118,17 @@ export class Apprecier {
} }
if (this.appreciation.carac != "") { if (this.appreciation.carac != "") {
this.rollAppreciation(rollCallbacks) this.rollAppreciation(callbacks)
} }
else { else {
this.rollMoral() this.rollMoral()
} }
} }
getCompetenceAppreciation() {
return [SANS_COMPETENCE.name, ""].includes(this.appreciation.competence) ? SANS_COMPETENCE : this.actor.getCompetence(this.appreciation.competence)
}
rollAppreciation(rollCallbacks = []) { rollAppreciation(rollCallbacks = []) {
const competence = (this.appreciation.jetComp && this.appreciation.competence) ? this.appreciation.competence : "" const competence = (this.appreciation.jetComp && this.appreciation.competence) ? this.appreciation.competence : ""
const rollData = { const rollData = {
@@ -161,6 +166,7 @@ export class Apprecier {
async rollMoral(moral = undefined) { async rollMoral(moral = undefined) {
if (this.raisons.length > 0) { if (this.raisons.length > 0) {
ui.notifications.info('Pas de jet de moral:' + Misc.concat(this.raisons.map(r => `<br> - ${r}`)))
return return
} }
+1 -2
View File
@@ -821,8 +821,7 @@
"reposalchimique": false "reposalchimique": false
}, },
"service": { "service": {
"templates": ["description", "inventaire", "appreciable"], "templates": ["description", "inventaire", "appreciable"]
"moral": false
}, },
"musique": { "musique": {
"templates": ["description", "appreciable"], "templates": ["description", "appreciable"],
+4 -4
View File
@@ -3,17 +3,17 @@
<section class="sheet-body"> <section class="sheet-body">
<div class="form-group"> <div class="form-group">
<span for="system.moral">Jet de moral en situation heureuse</span> <label for="system.qualite">Qualité</label>
<input {{@root.disabled}} class="attribute-value" type="checkbox" name="system.moral" {{#if system.moral}}checked{{/if}}/> <input class="attribute-value number-x3" type="number" name="system.qualite" value="{{system.qualite}}" data-dtype="Number"
{{#unless (isFieldInventaireModifiable type 'qualite')}}disabled{{/unless}}/>
</div> </div>
{{>"systems/foundryvtt-reve-de-dragon/templates/item/partial-appreciable.hbs"}}
<div class="form-group item-cout"> <div class="form-group item-cout">
<label for="system.cout">Prix (sols)</label> <label for="system.cout">Prix (sols)</label>
<input class="input-prix attribute-value number-x3" type="number" name="system.cout" value="{{numberFormat system.cout decimals=2 sign=false}}" data-dtype="Number" <input class="input-prix attribute-value number-x3" type="number" name="system.cout" value="{{numberFormat system.cout decimals=2 sign=false}}" data-dtype="Number"
{{#unless (isFieldInventaireModifiable type 'cout')}}disabled{{/unless}}/> {{#unless (isFieldInventaireModifiable type 'cout')}}disabled{{/unless}}/>
</div> </div>
{{>"systems/foundryvtt-reve-de-dragon/templates/item/partial-appreciable.hbs"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/item/partial-description.hbs"}} {{>"systems/foundryvtt-reve-de-dragon/templates/item/partial-description.hbs"}}
</section> </section>
</form> </form>