foundryvtt-reve-de-dragon/module/actor/base-actor-sang-sheet.js

47 lines
2.2 KiB
JavaScript
Raw Normal View History

import { ChatUtility } from "../chat-utility.js";
import { RdDItemBlessure } from "../item/blessure.js";
import { RdDBaseActorReveSheet } from "./base-actor-reve-sheet.js";
/* -------------------------------------------- */
/**
* Extend the basic ActorSheet with some very simple modifications
* @extends {ActorSheet}
*/
export class RdDBaseActorSangSheet extends RdDBaseActorReveSheet {
/* -------------------------------------------- */
/** @override */
activateListeners(html) {
super.activateListeners(html);
// Everything below here is only needed if the sheet is editable
if (!this.options.editable) return;
this.html.find('.creer-blessure-legere').click(async event => RdDItemBlessure.createBlessure(this.actor, 2));
this.html.find('.creer-blessure-grave').click(async event => RdDItemBlessure.createBlessure(this.actor, 4));
this.html.find('.creer-blessure-critique').click(async event => RdDItemBlessure.createBlessure(this.actor, 6));
this.html.find('.subir-blessure-contusion').click(async event => RdDItemBlessure.applyFullBlessure(this.actor, 0));
this.html.find('.subir-blessure-legere').click(async event => RdDItemBlessure.applyFullBlessure(this.actor, 2));
this.html.find('.subir-blessure-grave').click(async event => RdDItemBlessure.applyFullBlessure(this.actor, 4));
this.html.find('.subir-blessure-critique').click(async event => RdDItemBlessure.applyFullBlessure(this.actor, 6));
this.html.find('.jet-vie').click(async event => this.actor.jetDeVie())
this.html.find('.jet-endurance').click(async event => await this.jetEndurance())
this.html.find('.vie-plus').click(async event => this.actor.santeIncDec("vie", 1))
this.html.find('.vie-moins').click(async event => this.actor.santeIncDec("vie", -1))
}
async jetEndurance() {
const endurance = this.actor.getEnduranceActuelle()
const result = await this.actor.jetEndurance(endurance);
ChatMessage.create({
content: `Jet d'Endurance : ${result.jetEndurance} / ${endurance}
<br>${this.actor.name} a ${result.sonne ? 'échoué' : 'réussi'} son Jet d'Endurance ${result.sonne ? 'et devient Sonné' : ''}`,
whisper: ChatUtility.getOwners(this.actor)
})
}
}