Boutons encaisser/remise à neuf #69

Pour entités et créatures
This commit is contained in:
Vincent Vandemeulebrouck 2020-12-27 19:55:51 +01:00
parent 01b98f2f3b
commit ac8a1b509b
6 changed files with 74 additions and 28 deletions

View File

@ -4,6 +4,7 @@
* @extends {ActorSheet} * @extends {ActorSheet}
*/ */
import { HtmlUtility } from "./html-utility.js";
import { RdDUtility } from "./rdd-utility.js"; import { RdDUtility } from "./rdd-utility.js";
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -65,6 +66,8 @@ export class RdDActorCreatureSheet extends ActorSheet {
activateListeners(html) { activateListeners(html) {
super.activateListeners(html); super.activateListeners(html);
HtmlUtility._showControlWhen($(".gm-only"), game.user.isGM);
// Everything below here is only needed if the sheet is editable // Everything below here is only needed if the sheet is editable
if (!this.options.editable) return; if (!this.options.editable) return;
@ -147,6 +150,16 @@ export class RdDActorCreatureSheet extends ActorSheet {
this.actor.santeIncDec("endurance", -1); this.actor.santeIncDec("endurance", -1);
this.render(true); this.render(true);
}); });
html.find('#encaisser-direct').click(ev => {
this.actor.encaisser();
});
html.find('#remise-a-neuf').click(ev => {
if (game.user.isGM) {
this.actor.remiseANeuf();
}
});
} }

View File

@ -4,6 +4,7 @@
* @extends {ActorSheet} * @extends {ActorSheet}
*/ */
import { HtmlUtility } from "./html-utility.js";
import { RdDUtility } from "./rdd-utility.js"; import { RdDUtility } from "./rdd-utility.js";
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -55,6 +56,8 @@ export class RdDActorEntiteSheet extends ActorSheet {
activateListeners(html) { activateListeners(html) {
super.activateListeners(html); super.activateListeners(html);
HtmlUtility._showControlWhen($(".gm-only"), game.user.isGM);
// Everything below here is only needed if the sheet is editable // Everything below here is only needed if the sheet is editable
if (!this.options.editable) return; if (!this.options.editable) return;
@ -106,6 +109,17 @@ export class RdDActorEntiteSheet extends ActorSheet {
this.actor.santeIncDec("endurance", -1); this.actor.santeIncDec("endurance", -1);
this.render(true); this.render(true);
}); });
html.find('#encaisser-direct').click(ev => {
this.actor.encaisser();
});
html.find('#remise-a-neuf').click(ev => {
if (game.user.isGM) {
this.actor.remiseANeuf();
}
});
} }

View File

@ -4,7 +4,6 @@
*/ */
import { RdDUtility } from "./rdd-utility.js"; import { RdDUtility } from "./rdd-utility.js";
import { RdDEncaisser } from "./rdd-roll-encaisser.js";
import { HtmlUtility } from "./html-utility.js"; import { HtmlUtility } from "./html-utility.js";
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -132,13 +131,6 @@ export class RdDActorSheet extends ActorSheet {
return data; return data;
} }
/* -------------------------------------------- */
async displayDialogEncaisser( ) {
let data = { ajustementsEncaissement: RdDUtility.getAjustementsEncaissement() };
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-encaisser.html', data );
new RdDEncaisser(html, this.actor ).render(true);
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async _onDrop(event) { async _onDrop(event) {
await RdDUtility.processItemDropEvent(this, event); await RdDUtility.processItemDropEvent(this, event);
@ -253,7 +245,7 @@ export class RdDActorSheet extends ActorSheet {
}); });
html.find('#encaisser-direct').click(ev => { html.find('#encaisser-direct').click(ev => {
this.displayDialogEncaisser() this.actor.encaisser();
}); });
html.find('#remise-a-neuf').click(ev => { html.find('#remise-a-neuf').click(ev => {

View File

@ -11,7 +11,7 @@ import { RdDRollTables } from "./rdd-rolltables.js";
import { ChatUtility } from "./chat-utility.js"; import { ChatUtility } from "./chat-utility.js";
import { RdDItemSort } from "./item-sort.js"; import { RdDItemSort } from "./item-sort.js";
import { Grammar } from "./grammar.js"; import { Grammar } from "./grammar.js";
import { RdDItemArme } from "./item-arme.js"; import { RdDEncaisser } from "./rdd-roll-encaisser.js";
import { RdDCombat } from "./rdd-combat.js"; import { RdDCombat } from "./rdd-combat.js";
/** /**
@ -309,6 +309,7 @@ export class RdDActor extends Actor {
whisper: ChatUtility.getWhisperRecipientsAndGMs( this.name ), whisper: ChatUtility.getWhisperRecipientsAndGMs( this.name ),
content : "Remise à neuf de " + this.name content : "Remise à neuf de " + this.name
}; };
if (!this.isEntiteCauchemar()) {
if (this.data.data.blessures){ if (this.data.data.blessures){
const blessures = duplicate(this.data.data.blessures); const blessures = duplicate(this.data.data.blessures);
for (let listeBlessures of [blessures.legeres.liste, blessures.graves.liste, blessures.critiques.liste]) { for (let listeBlessures of [blessures.legeres.liste, blessures.graves.liste, blessures.critiques.liste]) {
@ -321,12 +322,15 @@ export class RdDActor extends Actor {
await this.update({ "data.compteurs.ethylisme.value": 0 }); await this.update({ "data.compteurs.ethylisme.value": 0 });
await this.update({ "data.compteurs.ethylisme.nb_doses": 0 }); await this.update({ "data.compteurs.ethylisme.nb_doses": 0 });
await this.santeIncDec("vie", this.data.data.sante.vie.max - this.data.data.sante.vie.value); await this.santeIncDec("vie", this.data.data.sante.vie.max - this.data.data.sante.vie.value);
}
await this.santeIncDec("endurance", this.data.data.sante.endurance.max - this.data.data.sante.endurance.value); await this.santeIncDec("endurance", this.data.data.sante.endurance.max - this.data.data.sante.endurance.value);
if (!this.isEntiteCauchemar()) {
if (this.data.data.sante.fatigue){ if (this.data.data.sante.fatigue){
let fatigue = duplicate(this.data.data.sante.fatigue) let fatigue = duplicate(this.data.data.sante.fatigue)
fatigue.value = 0; fatigue.value = 0;
await this.update( {"data.sante.fatigue": fatigue } ); await this.update( {"data.sante.fatigue": fatigue } );
} }
}
ChatMessage.create( message ); ChatMessage.create( message );
} }
@ -1749,6 +1753,13 @@ export class RdDActor extends Actor {
return protection; return protection;
} }
/* -------------------------------------------- */
async encaisser( ) {
let data = { ajustementsEncaissement: RdDUtility.getAjustementsEncaissement() };
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-encaisser.html', data );
new RdDEncaisser(html, this ).render(true);
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async encaisserDommages( attackerRoll, attacker = undefined ) { async encaisserDommages( attackerRoll, attacker = undefined ) {
if (attacker && !await attacker.accorder(this, 'avant-encaissement')) { if (attacker && !await attacker.accorder(this, 'avant-encaissement')) {

View File

@ -4,7 +4,15 @@
<header class="sheet-header"> <header class="sheet-header">
<img class="profile-img" src="{{actor.img}}" data-edit="img" title="{{actor.name}}" /> <img class="profile-img" src="{{actor.img}}" data-edit="img" title="{{actor.name}}" />
<div class="header-fields"> <div class="header-fields">
<div class="flexrow">
<h1 class="charname"><input name="name" type="text" value="{{actor.name}}" placeholder="Name" /></h1> <h1 class="charname"><input name="name" type="text" value="{{actor.name}}" placeholder="Name" /></h1>
</div>
<div class="flexrow flex-group-center flex-actions-bar">
<div>
<span id="encaisser-direct"><a title="Encaisser des dommages"><img class="button-img" src="icons/svg/bones.svg" alt="Encaisser des dommages"/></a></span>
<span id="remise-a-neuf" class="gm-only"><a title="Remise à neuf"><img class="button-img" src="icons/svg/regen.svg" alt="Remise à neuf"/></a></span>
</div>
</div>
<div class="flexrow"> <div class="flexrow">
<div class="flexrow"> <div class="flexrow">
<span>{{data.blessures.resume}}</span> <span>{{data.blessures.resume}}</span>

View File

@ -4,8 +4,16 @@
<header class="sheet-header"> <header class="sheet-header">
<img class="profile-img" src="{{actor.img}}" data-edit="img" title="{{actor.name}}" /> <img class="profile-img" src="{{actor.img}}" data-edit="img" title="{{actor.name}}" />
<div class="header-fields"> <div class="header-fields">
<div class="flexrow">
<h1 class="charname"><input name="name" type="text" value="{{actor.name}}" placeholder="Name" /></h1> <h1 class="charname"><input name="name" type="text" value="{{actor.name}}" placeholder="Name" /></h1>
</div> </div>
<div class="flexrow flex-group-center flex-actions-bar">
<div>
<span id="encaisser-direct"><a title="Encaisser des dommages"><img class="button-img" src="icons/svg/bones.svg" alt="Encaisser des dommages"/></a></span>
<span id="remise-a-neuf" class="gm-only"><a title="Remise à neuf"><img class="button-img" src="icons/svg/regen.svg" alt="Remise à neuf"/></a></span>
</div>
</div>
</div>
</header> </header>
{{!-- Sheet Tab Navigation --}} {{!-- Sheet Tab Navigation --}}