2023-11-04 17:48:50 +01:00
|
|
|
import { ENTITE_INCARNE } from "../constants.js";
|
2023-11-12 15:00:48 +01:00
|
|
|
import { TYPES } from "../item.js";
|
2023-11-04 17:48:50 +01:00
|
|
|
import { STATUSES } from "../settings/status-effects.js";
|
|
|
|
import { RdDBaseActorSang } from "./base-actor-sang.js";
|
|
|
|
|
|
|
|
export class RdDCreature extends RdDBaseActorSang {
|
|
|
|
|
|
|
|
static get defaultIcon() {
|
|
|
|
return "systems/foundryvtt-reve-de-dragon/icons/creatures/bramart.svg";
|
|
|
|
}
|
|
|
|
|
|
|
|
isCreature() { return true }
|
|
|
|
|
|
|
|
canReceive(item) {
|
|
|
|
return item.type == TYPES.competencecreature || item.isInventaire();
|
|
|
|
}
|
|
|
|
|
|
|
|
async remiseANeuf() {
|
|
|
|
await this.removeEffects(e => true);
|
|
|
|
await this.supprimerBlessures(it => true);
|
2023-11-21 16:03:26 +01:00
|
|
|
await this.update({
|
2023-11-04 17:48:50 +01:00
|
|
|
'system.sante.endurance.value': this.system.sante.endurance.max,
|
|
|
|
'system.sante.vie.value': this.system.sante.vie.max,
|
|
|
|
'system.sante.fatigue.value': 0
|
2023-11-21 16:03:26 +01:00
|
|
|
});
|
2023-11-04 17:48:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
async finDeRoundBlessures() {
|
|
|
|
const nbGraves = this.filterItems(it => it.isGrave(), 'blessure').length;
|
|
|
|
if (nbGraves > 0) {
|
|
|
|
// Gestion blessure graves : -1 pt endurance par blessure grave
|
|
|
|
await this.santeIncDec("endurance", -nbGraves);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-08 23:50:16 +01:00
|
|
|
isEffectAllowed(effectId) {
|
|
|
|
return [STATUSES.StatusComma].includes(effectId);
|
2023-11-04 17:48:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
isEntiteAccordee(attacker) {
|
|
|
|
if (this.isEntite([ENTITE_INCARNE])) {
|
|
|
|
let resonnance = this.system.sante.resonnance
|
|
|
|
return (resonnance.actors.find(it => it == attacker.id))
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
async setEntiteReveAccordee(attacker) {
|
|
|
|
if (this.isEntite([ENTITE_INCARNE])) {
|
2024-05-02 14:08:02 +02:00
|
|
|
let resonnance = foundry.utils.duplicate(this.system.sante.resonnance);
|
2023-11-04 17:48:50 +01:00
|
|
|
if (resonnance.actors.find(it => it == attacker.id)) {
|
|
|
|
// déjà accordé
|
|
|
|
return;
|
|
|
|
}
|
2023-11-21 16:03:26 +01:00
|
|
|
await this.update({ "system.sante.resonnance": [...resonnance, attacker.id] });
|
2023-11-04 17:48:50 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
super.setEntiteReveAccordee(attacker)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|