Simplifications en cherchant bug rêve actuel
Parfois, le rêve actuel est ajouté dans les caractéristiques des feuilles de personnage. Simplifications pour essayer d'isoler le souci.
This commit is contained in:
@@ -48,39 +48,26 @@ export class RdDBaseActorReve extends RdDBaseActor {
|
||||
}
|
||||
|
||||
getCarac() {
|
||||
return foundry.utils.mergeObject(this.system.carac,
|
||||
{
|
||||
'reve-actuel': this.getCaracReveActuel(),
|
||||
'chance-actuelle': this.getCaracChanceActuelle()
|
||||
},
|
||||
{ inplace: false })
|
||||
}
|
||||
|
||||
getCaracChanceActuelle() {
|
||||
return {
|
||||
label: 'Chance actuelle',
|
||||
value: this.getChanceActuel(),
|
||||
type: "number"
|
||||
};
|
||||
}
|
||||
|
||||
getCaracReveActuel() {
|
||||
return {
|
||||
label: 'Rêve actuel',
|
||||
value: this.getReveActuel(),
|
||||
type: "number"
|
||||
};
|
||||
const carac = super.getCarac()
|
||||
foundry.utils.mergeObject(carac, this.getCaracReveActuel())
|
||||
foundry.utils.mergeObject(carac, this.getCaracCompetenceCreature(), { overwrite: false })
|
||||
return carac
|
||||
}
|
||||
|
||||
getTaille() { return Misc.toInt(this.system.carac.taille?.value) }
|
||||
getConstitution() { return this.getReve() }
|
||||
getVie() { return this.getReve() }
|
||||
getCaracVie() { return { [CARACS.VIE]: { label: "Vie", value: this.getVieMax(), type: "number" } } }
|
||||
|
||||
getForce() { return this.getReve() }
|
||||
getAgilite() { return this.getForce() }
|
||||
getReve() { return Misc.toInt(this.system.carac.reve?.value) }
|
||||
getChance() { return this.getReve() }
|
||||
getChanceActuel() { return this.getChance() }
|
||||
getCaracChanceActuelle() { return { [CARACS.CHANCE_ACTUELLE]: { label: 'Chance actuelle', value: this.getChanceActuel(), type: "number" } } }
|
||||
|
||||
getReveActuel() { return this.getReve() }
|
||||
getChanceActuel() { return this.getChance() }
|
||||
getCaracReveActuel() { return { [CARACS.REVE_ACTUEL]: { label: "Rêve Actuel", value: this.getReveActuel(), type: "number" } } }
|
||||
|
||||
getEnduranceMax() { return Math.max(1, this.getTaille() + this.getConstitution()) }
|
||||
getEncombrementMax() { return (this.getForce() + this.getTaille()) / 2 }
|
||||
|
||||
@@ -23,10 +23,18 @@ export class RdDBaseActorSang extends RdDBaseActorReve {
|
||||
this.system.attributs.encombrement.value = this.getEncombrementMax()
|
||||
}
|
||||
|
||||
getCarac() {
|
||||
const carac = super.getCarac()
|
||||
foundry.utils.mergeObject(carac, this.getCaracChanceActuelle())
|
||||
foundry.utils.mergeObject(carac, this.getCaracVie())
|
||||
return carac
|
||||
}
|
||||
|
||||
getForce() { return Misc.toInt(this.system.carac.force?.value) }
|
||||
getConstitution() { return Misc.toInt(this.system.carac.constitution?.value) }
|
||||
getVolonte() { return Misc.toInt(this.system.carac.volonte?.value) }
|
||||
|
||||
getCaracVie() { return { [CARACS.VIE]: { label: "Vie", value: this.getVieMax(), type: "number" } } }
|
||||
getVieMax() { return Misc.toInt(this.system.sante.vie?.max) }
|
||||
getEnduranceMax() { return Math.max(1, this.getTaille() + this.getConstitution()) }
|
||||
getFatigueMax() { return this.getEnduranceMax() * 2 }
|
||||
|
||||
+24
-14
@@ -12,6 +12,7 @@ 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";
|
||||
import { CARACS } from "../rdd-carac.js";
|
||||
|
||||
export class RdDBaseActor extends Actor {
|
||||
|
||||
@@ -155,20 +156,21 @@ export class RdDBaseActor extends Actor {
|
||||
super(docData, context);
|
||||
}
|
||||
|
||||
getCarac() {
|
||||
return foundry.utils.duplicate(this.system.carac)
|
||||
}
|
||||
|
||||
findCaracByName(name) {
|
||||
name = Grammar.toLowerCaseNoAccent(name)
|
||||
switch (name) {
|
||||
case 'reve-actuel': case 'reve actuel':
|
||||
return this.system.carac.reve
|
||||
case 'chance-actuelle': case 'chance actuelle':
|
||||
return this.system.carac.chance
|
||||
case 'vie':
|
||||
return this.system.sante.vie
|
||||
case 'reve actuel':
|
||||
name = CARACS.REVE_ACTUEL
|
||||
break
|
||||
case 'chance actuelle':
|
||||
name = CARACS.CHANCE_ACTUELLE
|
||||
break
|
||||
}
|
||||
|
||||
const carac = {}
|
||||
foundry.utils.mergeObject(carac, this.system.carac, { overwrite: false })
|
||||
foundry.utils.mergeObject(carac, this.getCaracCompetenceCreature(), { overwrite: false })
|
||||
const carac = this.getCarac()
|
||||
return RdDBaseActor.$findCaracByName(carac, name);
|
||||
}
|
||||
|
||||
@@ -183,10 +185,18 @@ export class RdDBaseActor extends Actor {
|
||||
getCaracByName(name) {
|
||||
name = this.mapCarac(Grammar.toLowerCaseNoAccent(name)) ?? name
|
||||
switch (name) {
|
||||
case 'reve-actuel': case 'reve actuel':
|
||||
return this.getCaracReveActuel();
|
||||
case 'chance-actuelle': case 'chance-actuelle':
|
||||
return this.getCaracChanceActuelle();
|
||||
case 'reve actuel':
|
||||
name = CARACS.REVE_ACTUEL
|
||||
break
|
||||
case 'chanceactuelle':
|
||||
name = CARACS.CHANCE_ACTUELLE
|
||||
break
|
||||
}
|
||||
switch (name) {
|
||||
case CARACS.REVE_ACTUEL:
|
||||
return this.getCaracReveActuel()[CARACS.REVE_ACTUEL]
|
||||
case CARACS.CHANCE_ACTUELLE:
|
||||
return this.getCaracChanceActuelle()[CARACS.CHANCE_ACTUELLE]
|
||||
}
|
||||
return this.findCaracByName(name);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user