reroll OK
This commit is contained in:
@@ -91,17 +91,16 @@ export class VermineActorSheet extends ActorSheet {
|
||||
}
|
||||
|
||||
//click on wound radio
|
||||
html.find('[type="radio"][data-wound]').click(ev => {
|
||||
this._onWoundClick(ev)
|
||||
html.find('.hexa [type="radio"]').click(ev => {
|
||||
this._onClickRadioHexa(ev)
|
||||
})
|
||||
|
||||
}
|
||||
_onWoundClick(ev) {
|
||||
_onClickRadioHexa(ev) {
|
||||
if (!ev.currentTarget.checked) { return }
|
||||
let woundType = ev.currentTarget.dataset.wound;
|
||||
let targetProp = "system." + woundType + ".value";
|
||||
let prop = ev.currentTarget.name;
|
||||
let update = {};
|
||||
update[targetProp] = ev.currentTarget.value - 1
|
||||
update[prop] = ev.currentTarget.value - 1
|
||||
|
||||
this.actor.update(update)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { onManageActiveEffect, prepareActiveEffectCategories } from "../system/effects.mjs";
|
||||
import { VermineActorSheet } from "./actor-sheet.mjs";
|
||||
import { getRollBox } from "../system/dialogs.mjs";
|
||||
import { RollDialog } from "../system/dialogs.mjs";
|
||||
import { TotemPicker } from "../system/applications.mjs";
|
||||
|
||||
/**
|
||||
@@ -103,16 +103,35 @@ export class VermineCharacterSheet extends VermineActorSheet {
|
||||
// Choose Totem
|
||||
html.find('.chooseTotem').click(this._onTotemButton.bind(this));
|
||||
html.find('.ability .rollable').click(this._onRoll.bind(this));
|
||||
html.find('[data-totem-name]').click(this._onClickTotemDice.bind(this))
|
||||
|
||||
}
|
||||
|
||||
async _onClickTotemDice(ev) {
|
||||
let el = ev.currentTarget;
|
||||
let totem = el.dataset.totemName;
|
||||
let value = parseInt(el.dataset.totemValue);
|
||||
|
||||
let oldValue = this.actor.system.adaptation.totems[totem].value;
|
||||
if (value === oldValue) { value-- };
|
||||
let updates = {};
|
||||
updates[`system.adaptation.totems.${totem}.value`] = value;
|
||||
let totems = this.actor.system.adaptation.totems;
|
||||
let sumTotems = Object.keys(totems).reduce(function (previous, key) {
|
||||
return previous + totems[key].value;
|
||||
}, 0);
|
||||
if (sumTotems >5) {
|
||||
ui.notifications.warn('vous ne pouvez pas avoir plus de 5 dés totems')
|
||||
}
|
||||
console.log(sumTotems, updates)
|
||||
await this.actor.update(updates);
|
||||
}
|
||||
/**
|
||||
* Handle clickable rolls.
|
||||
* @param {Event} event The originating click event
|
||||
* @private
|
||||
*/
|
||||
_onRoll(event) {
|
||||
async _onRoll(event) {
|
||||
event.preventDefault();
|
||||
const element = event.currentTarget;
|
||||
const dataset = element.dataset;
|
||||
@@ -129,26 +148,17 @@ export class VermineCharacterSheet extends VermineActorSheet {
|
||||
// Handle rolls that supply the formula directly.
|
||||
if (dataset.label) {
|
||||
dataset.rollType = dataset.type;
|
||||
/*const label = game.i18n.localize(dataset.label) ? `[ability] ${game.i18n.localize(dataset.label)}` : '';
|
||||
console.log($(element).attr('for'));
|
||||
const NoD = this.actor.system.skills[$(element).attr('for').split('.')[2]]?.value || 0
|
||||
return game.vermine2047.VermineRoll.roll(this.actor.id, label, NoD, 0, {});*/
|
||||
|
||||
let data = {
|
||||
actorId: this.actor.id,
|
||||
abilities: this.actor.system.abilities,
|
||||
skills: this.actor.system.skills,
|
||||
rollType: dataset.rollType,
|
||||
labelKey: dataset.label,
|
||||
abilityScore: 0,
|
||||
skillScore: 0,
|
||||
|
||||
label: game.i18n.localize(dataset.label)
|
||||
};
|
||||
if (dataset.type == 'ability') {
|
||||
data.abilityScore = this.actor.system.abilities[dataset.label].value;
|
||||
} else if (dataset.type == 'skill') {
|
||||
data.skillScore = this.actor.system.skills[dataset.label].value;
|
||||
}
|
||||
getRollBox(data);
|
||||
|
||||
let dial = await RollDialog.create(data);
|
||||
dial.render(true)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user