Appréciation des services
This commit is contained in:
@@ -11,6 +11,7 @@ import { RdDUtility } from "../rdd-utility.js";
|
||||
import { SystemCompendiums } from "../settings/system-compendiums.js";
|
||||
import { RdDItem } from "../item.js";
|
||||
import { StatusEffects, STATUSES } from "../settings/status-effects.js";
|
||||
import { Apprecier } from "../moral/apprecier.mjs";
|
||||
|
||||
export class RdDBaseActor extends Actor {
|
||||
|
||||
@@ -517,10 +518,13 @@ export class RdDBaseActor extends Actor {
|
||||
async acheter(item, quantite, cout, achat) {
|
||||
await this.depenserSols(cout)
|
||||
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;
|
||||
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) {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -821,8 +821,7 @@
|
||||
"reposalchimique": false
|
||||
},
|
||||
"service": {
|
||||
"templates": ["description", "inventaire", "appreciable"],
|
||||
"moral": false
|
||||
"templates": ["description", "inventaire", "appreciable"]
|
||||
},
|
||||
"musique": {
|
||||
"templates": ["description", "appreciable"],
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
|
||||
<section class="sheet-body">
|
||||
<div class="form-group">
|
||||
<span for="system.moral">Jet de moral en situation heureuse</span>
|
||||
<input {{@root.disabled}} class="attribute-value" type="checkbox" name="system.moral" {{#if system.moral}}checked{{/if}}/>
|
||||
<label for="system.qualite">Qualité</label>
|
||||
<input class="attribute-value number-x3" type="number" name="system.qualite" value="{{system.qualite}}" data-dtype="Number"
|
||||
{{#unless (isFieldInventaireModifiable type 'qualite')}}disabled{{/unless}}/>
|
||||
</div>
|
||||
|
||||
{{>"systems/foundryvtt-reve-de-dragon/templates/item/partial-appreciable.hbs"}}
|
||||
<div class="form-group item-cout">
|
||||
<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"
|
||||
{{#unless (isFieldInventaireModifiable type 'cout')}}disabled{{/unless}}/>
|
||||
</div>
|
||||
|
||||
{{>"systems/foundryvtt-reve-de-dragon/templates/item/partial-appreciable.hbs"}}
|
||||
{{>"systems/foundryvtt-reve-de-dragon/templates/item/partial-description.hbs"}}
|
||||
</section>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user