forked from public/foundryvtt-reve-de-dragon
Séparation de l'Actor Vehicule
This commit is contained in:
@ -67,12 +67,10 @@ export class RdDActor extends RdDBaseActor {
|
||||
// TODO: separate derived/base data preparation
|
||||
// TODO: split by actor class
|
||||
|
||||
// Make separate methods for each Actor type (character, npc, etc.) to keep
|
||||
// things organized.
|
||||
// Make separate methods for each Actor type (character, npc, etc.) to keep things organized.
|
||||
if (this.isPersonnage()) this._prepareCharacterData(this)
|
||||
if (this.isCreatureEntite()) this._prepareCreatureData(this)
|
||||
if (this.isVehicule()) this._prepareVehiculeData(this)
|
||||
this.computeEtatGeneral();
|
||||
this.recompute();
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -80,11 +78,6 @@ export class RdDActor extends RdDBaseActor {
|
||||
this.computeEncTotal();
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_prepareVehiculeData(actorData) {
|
||||
this.computeEncTotal();
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/**
|
||||
* Prepare Character type specific data
|
||||
@ -114,9 +107,6 @@ export class RdDActor extends RdDBaseActor {
|
||||
if (this.isEntite()) {
|
||||
return item.type == 'competencecreature';
|
||||
}
|
||||
if (this.isVehicule()) {
|
||||
return item.isInventaire();
|
||||
}
|
||||
if (this.isPersonnage()) {
|
||||
switch (item.type) {
|
||||
case 'competencecreature': case 'tarot': case 'service':
|
||||
@ -153,7 +143,6 @@ export class RdDActor extends RdDBaseActor {
|
||||
case 'creature':
|
||||
case 'entite':
|
||||
return Misc.toInt(this.system.carac.reve?.value)
|
||||
case 'vehicule':
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@ -709,11 +698,11 @@ export class RdDActor extends RdDBaseActor {
|
||||
jetsReve.push(-1);
|
||||
return 'eveil';
|
||||
}
|
||||
else {
|
||||
await this.reveActuelIncDec(reve);
|
||||
jetsReve.push(reve);
|
||||
else {
|
||||
await this.reveActuelIncDec(reve);
|
||||
jetsReve.push(reve);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 'dort';
|
||||
}
|
||||
|
||||
@ -1125,7 +1114,7 @@ export class RdDActor extends RdDBaseActor {
|
||||
/* -------------------------------------------- */
|
||||
computeMalusSurEncombrement() {
|
||||
switch (this.type) {
|
||||
case 'entite': case 'vehicule':
|
||||
case 'entite':
|
||||
return 0;
|
||||
}
|
||||
return Math.min(0, Math.floor(this.getEncombrementMax() - this.encTotal));
|
||||
@ -1138,8 +1127,6 @@ export class RdDActor extends RdDBaseActor {
|
||||
/* -------------------------------------------- */
|
||||
getEncombrementMax() {
|
||||
switch (this.type) {
|
||||
case 'vehicule':
|
||||
return this.system.capacite_encombrement;
|
||||
case 'entite':
|
||||
return 0;
|
||||
default:
|
||||
@ -1184,29 +1171,40 @@ export class RdDActor extends RdDBaseActor {
|
||||
return resume;
|
||||
}
|
||||
|
||||
recompute() {
|
||||
this.computeEtatGeneral();
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
computeEtatGeneral() {
|
||||
// Pas d'état général pour les entités forçage à 0
|
||||
if (this.type == 'vehicule') {
|
||||
return
|
||||
}
|
||||
recompute() {
|
||||
if (this.type == 'entite') {
|
||||
// Pas d'état général pour les entités forçage à 0
|
||||
this.system.compteurs.etat.value = 0;
|
||||
return
|
||||
}
|
||||
// Pour les autres
|
||||
let state = Math.min(this.system.sante.vie.value - this.system.sante.vie.max, 0);
|
||||
if (ReglesOptionnelles.isUsing("appliquer-fatigue") && this.system.sante.fatigue) {
|
||||
state += RdDUtility.currentFatigueMalus(this.system.sante.fatigue.value, this.system.sante.endurance.max);
|
||||
}
|
||||
// Ajout de l'éthylisme
|
||||
state += Math.min(0, (this.system.compteurs.ethylisme?.value ?? 0));
|
||||
this.system.compteurs.etat.value = this.$malusVie() + this.$malusFatigue() + this.$malusEthylisme();
|
||||
}
|
||||
|
||||
this.system.compteurs.etat.value = state;
|
||||
$malusVie() {
|
||||
return Math.min(this.system.sante.vie.value - this.system.sante.vie.max, 0);
|
||||
}
|
||||
|
||||
$malusEthylisme() {
|
||||
return Math.min(0, (this.system.compteurs.ethylisme?.value ?? 0));
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
$malusFatigue() {
|
||||
if (ReglesOptionnelles.isUsing("appliquer-fatigue") && this.system.sante.fatigue) {
|
||||
const max = Math.max(1, Math.min(this.system.sante.endurance.max, 60));
|
||||
|
||||
let fatigueTab = RdDUtility.getSegmentsFatigue(max);
|
||||
let reste = Math.min(max * 2, Math.max(0, this.system.sante.fatigue.value));
|
||||
for (let idx = 0; idx < fatigueTab.length; idx++) {
|
||||
reste -= fatigueTab[idx];
|
||||
if (reste <= 0) {
|
||||
return fatigueMalus[idx];
|
||||
}
|
||||
}
|
||||
return -7; // This is the max !
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -1579,17 +1577,6 @@ export class RdDActor extends RdDBaseActor {
|
||||
return result;
|
||||
}
|
||||
|
||||
async vehicleIncDec(name, inc) {
|
||||
if (!this.isVehicule() || !['resistance', 'structure'].includes(name)) {
|
||||
return
|
||||
}
|
||||
const value = this.system.etat[name].value;
|
||||
const max = this.system.etat[name].max;
|
||||
const newValue = value + inc;
|
||||
if (0 <= newValue && newValue <= max) {
|
||||
await this.update({ [`system.etat.${name}.value`]: newValue })
|
||||
}
|
||||
}
|
||||
|
||||
isDead() {
|
||||
return !this.isEntite() && this.system.sante.vie.value < -this.getSConst()
|
||||
@ -3772,7 +3759,7 @@ export class RdDActor extends RdDBaseActor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async setEffect(statusId, status) {
|
||||
if (this.isEntite() || this.isVehicule()) {
|
||||
if (this.isEntite()) {
|
||||
return;
|
||||
}
|
||||
console.log("setEffect", statusId, status)
|
||||
|
Reference in New Issue
Block a user