Appliquer encTotal à l'acrobatie #75
This commit is contained in:
parent
8091b5a2e1
commit
fe4fd0ce93
@ -113,7 +113,7 @@ export class RdDActorSheet extends ActorSheet {
|
|||||||
this.actor.computeEncombrementTotalEtMalusArmure();
|
this.actor.computeEncombrementTotalEtMalusArmure();
|
||||||
// Common data
|
// Common data
|
||||||
data.data.competenceByCategory = data.competenceByCategory;
|
data.data.competenceByCategory = data.competenceByCategory;
|
||||||
data.data.encombrementTotal = this.actor.encombrementTotal;
|
data.data.encTotal = this.actor.encTotal;
|
||||||
data.data.isGM = game.user.isGM;
|
data.data.isGM = game.user.isGM;
|
||||||
data.ajustementsConditions = CONFIG.RDD.ajustementsConditions;
|
data.ajustementsConditions = CONFIG.RDD.ajustementsConditions;
|
||||||
data.difficultesLibres = CONFIG.RDD.difficultesLibres;
|
data.difficultesLibres = CONFIG.RDD.difficultesLibres;
|
||||||
|
@ -77,7 +77,7 @@ export class RdDActor extends Actor {
|
|||||||
const actorData = this.data;
|
const actorData = this.data;
|
||||||
|
|
||||||
// Dynamic computing fields
|
// Dynamic computing fields
|
||||||
this.encombrementTotal = 0;
|
this.encTotal = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// Auto-resize token
|
// Auto-resize token
|
||||||
@ -158,7 +158,9 @@ export class RdDActor extends Actor {
|
|||||||
return duplicate(list[0]);
|
return duplicate(list[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getEncombrementTotal() {
|
||||||
|
return this.encTotal ? Math.floor(this.encTotal) : 0
|
||||||
|
}
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async deleteSortReserve(coordTMR) {
|
async deleteSortReserve(coordTMR) {
|
||||||
let reserve = duplicate(this.data.data.reve.reserve);
|
let reserve = duplicate(this.data.data.reve.reserve);
|
||||||
@ -618,7 +620,7 @@ export class RdDActor extends Actor {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
detectSurEncombrement( ) {
|
detectSurEncombrement( ) {
|
||||||
let diffEnc = Number(this.encombrementTotal) - Number(this.data.data.attributs.encombrement.value);
|
let diffEnc = Number(this.encTotal) - Number(this.data.data.attributs.encombrement.value);
|
||||||
if ( diffEnc > 0 ) { // Sur-encombrement
|
if ( diffEnc > 0 ) { // Sur-encombrement
|
||||||
let malus = Math.round( diffEnc);
|
let malus = Math.round( diffEnc);
|
||||||
malus = (malus == 0) ? 1 : malus; // Always 1 at least
|
malus = (malus == 0) ? 1 : malus; // Always 1 at least
|
||||||
@ -630,7 +632,7 @@ export class RdDActor extends Actor {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async computeEncombrementTotalEtMalusArmure( ) {
|
async computeEncombrementTotalEtMalusArmure( ) {
|
||||||
let totalEnc = 0;
|
let encTotal = 0;
|
||||||
let malusArmureData = duplicate(this.data.data.attributs.malusarmure);
|
let malusArmureData = duplicate(this.data.data.attributs.malusarmure);
|
||||||
let newMalusArmure = 0;
|
let newMalusArmure = 0;
|
||||||
for (const item of this.data.items) {
|
for (const item of this.data.items) {
|
||||||
@ -643,13 +645,13 @@ export class RdDActor extends Actor {
|
|||||||
if (!item.data.quantite) item.data.quantite = 1; // Auto-fix
|
if (!item.data.quantite) item.data.quantite = 1; // Auto-fix
|
||||||
item.data.encTotal = Number(item.data.encombrement) * Number(item.data.quantite);
|
item.data.encTotal = Number(item.data.encombrement) * Number(item.data.quantite);
|
||||||
//console.log("Enc:", item.name, item.data.encombrement, item.data.quantite, item.data.encTotal);
|
//console.log("Enc:", item.name, item.data.encombrement, item.data.quantite, item.data.encTotal);
|
||||||
totalEnc += item.data.encTotal;
|
encTotal += item.data.encTotal;
|
||||||
} else {
|
} else {
|
||||||
item.data.encTotal = 0; // Force default enc
|
item.data.encTotal = 0; // Force default enc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Mise à jour valeur totale et états
|
// Mise à jour valeur totale et états
|
||||||
this.encombrementTotal = totalEnc;
|
this.encTotal = encTotal;
|
||||||
this.detectSurEncombrement();
|
this.detectSurEncombrement();
|
||||||
// Mise à jour éventuelle du malus armure
|
// Mise à jour éventuelle du malus armure
|
||||||
if (newMalusArmure != malusArmureData.value) {
|
if (newMalusArmure != malusArmureData.value) {
|
||||||
|
@ -5,7 +5,10 @@ export class RdDItemCompetence extends Item {
|
|||||||
return name.toLowerCase().match(/(epée|épée|hache|fleau|fléau|masse|lance|hast|dague|bouclier)/);
|
return name.toLowerCase().match(/(epée|épée|hache|fleau|fléau|masse|lance|hast|dague|bouclier)/);
|
||||||
}
|
}
|
||||||
static isArmeUneMain(competence) {
|
static isArmeUneMain(competence) {
|
||||||
return competence.name.toLowerCase().includes("1 main");
|
return competence && competence.name.toLowerCase().includes("1 main");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static isMalusEncombrementTotal(competence) {
|
||||||
|
return competence && competence.name.toLowerCase().match(/(natation|acrobatie)/);
|
||||||
|
}
|
||||||
}
|
}
|
@ -252,7 +252,7 @@ Hooks.once("ready", function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Integration du TokenHUD
|
// Integration du TokenHUD
|
||||||
Hooks.on('renderTokenHUD', (app, html, data) => { RdDTokenHud.addTokenHudExtensions(app, html, data) });
|
Hooks.on('renderTokenHUD', (app, html, data) => { RdDTokenHud.addTokenHudExtensions(app, html, data._id) });
|
||||||
});
|
});
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { HtmlUtility } from "./html-utility.js";
|
import { HtmlUtility } from "./html-utility.js";
|
||||||
|
import { RdDItemCompetence } from "./item-competence.js";
|
||||||
import { RdDItemSort } from "./item-sort.js";
|
import { RdDItemSort } from "./item-sort.js";
|
||||||
import { Misc } from "./misc.js";
|
import { Misc } from "./misc.js";
|
||||||
import { RdDBonus } from "./rdd-bonus.js";
|
import { RdDBonus } from "./rdd-bonus.js";
|
||||||
@ -45,9 +46,9 @@ export class RdDRoll extends Dialog {
|
|||||||
surencMalusFlag: actor.isPersonnage() ? (actor.data.data.compteurs.surenc.value < 0) : false,
|
surencMalusFlag: actor.isPersonnage() ? (actor.data.data.compteurs.surenc.value < 0) : false,
|
||||||
surencMalusValue: actor.isPersonnage() ? actor.data.data.compteurs.surenc.value : 0,
|
surencMalusValue: actor.isPersonnage() ? actor.data.data.compteurs.surenc.value : 0,
|
||||||
surencMalusApply: false,
|
surencMalusApply: false,
|
||||||
isNatation: rollData.competence ? rollData.competence.name.toLowerCase().includes("natation") : false,
|
isMalusEncombrementTotal: RdDItemCompetence.isMalusEncombrementTotal(rollData.competence),
|
||||||
useEncForNatation: false,
|
useMalusEncTotal: false,
|
||||||
encValueForNatation: actor.encombrementTotal ? Math.floor(actor.encombrementTotal) : 0,
|
encTotal: actor.getEncombrementTotal(),
|
||||||
ajustementAstrologique: actor.ajustementAstrologique()
|
ajustementAstrologique: actor.ajustementAstrologique()
|
||||||
}
|
}
|
||||||
mergeObject(rollData, defaultRollData, { overwrite: false });
|
mergeObject(rollData, defaultRollData, { overwrite: false });
|
||||||
@ -210,8 +211,8 @@ export class RdDRoll extends Dialog {
|
|||||||
this.rollData.surencMalusApply = event.currentTarget.checked;
|
this.rollData.surencMalusApply = event.currentTarget.checked;
|
||||||
updateRollResult(rollData);
|
updateRollResult(rollData);
|
||||||
});
|
});
|
||||||
html.find('#useEncForNatation').change((event) => {
|
html.find('#useMalusEncTotal').change((event) => {
|
||||||
this.rollData.useEncForNatation = event.currentTarget.checked;
|
this.rollData.useMalusEncTotal = event.currentTarget.checked;
|
||||||
updateRollResult(rollData);
|
updateRollResult(rollData);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -226,7 +227,7 @@ export class RdDRoll extends Dialog {
|
|||||||
const diffConditions = Misc.toInt(rollData.diffConditions);
|
const diffConditions = Misc.toInt(rollData.diffConditions);
|
||||||
const malusEnc = (rollData.surencMalusApply) ? rollData.surencMalusValue : 0;
|
const malusEnc = (rollData.surencMalusApply) ? rollData.surencMalusValue : 0;
|
||||||
const bonusTactique = RdDBonus.bonusAttaque(rollData.tactique);
|
const bonusTactique = RdDBonus.bonusAttaque(rollData.tactique);
|
||||||
const malusEncNatation = (rollData.useEncForNatation) ? -rollData.encValueForNatation : 0;
|
const malusEncTotal = (rollData.useMalusEncTotal) ? -rollData.encTotal : 0;
|
||||||
const ajustementChance = rollData.selectedCarac.label.toLowerCase().includes('chance') ? rollData.ajustementAstrologique : 0;
|
const ajustementChance = rollData.selectedCarac.label.toLowerCase().includes('chance') ? rollData.ajustementAstrologique : 0;
|
||||||
// Gestion malus armure
|
// Gestion malus armure
|
||||||
const malusArmureValue = this._computeMalusArmure(rollData);
|
const malusArmureValue = this._computeMalusArmure(rollData);
|
||||||
@ -235,7 +236,7 @@ export class RdDRoll extends Dialog {
|
|||||||
const diffCompetence = this._computeDiffCompetence(rollData);
|
const diffCompetence = this._computeDiffCompetence(rollData);
|
||||||
const diffMoral = rollData.selectedCarac == this.actor.data.data.carac.volonte ? rollData.moral : 0;
|
const diffMoral = rollData.selectedCarac == this.actor.data.data.carac.volonte ? rollData.moral : 0;
|
||||||
|
|
||||||
return etat + diffCompetence + diffLibre + diffMoral + diffConditions + malusEnc + malusEncNatation + malusArmureValue + ajustementChance + bonusTactique;
|
return etat + diffCompetence + diffLibre + diffMoral + diffConditions + malusEnc + malusEncTotal + malusArmureValue + ajustementChance + bonusTactique;
|
||||||
}
|
}
|
||||||
|
|
||||||
_computeDiffCompetence(rollData) {
|
_computeDiffCompetence(rollData) {
|
||||||
|
@ -7,8 +7,8 @@ export class RdDTokenHud {
|
|||||||
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static async addTokenHudExtensions(app, html, data) {
|
static async addTokenHudExtensions(app, html, tokenId) {
|
||||||
let token = canvas.tokens.get(data._id);
|
let token = canvas.tokens.get(tokenId);
|
||||||
let actor = token.actor;
|
let actor = token.actor;
|
||||||
let combatant = game.combat.data.combatants.find(c => c.tokenId == token.data._id);
|
let combatant = game.combat.data.combatants.find(c => c.tokenId == token.data._id);
|
||||||
|
|
||||||
@ -17,10 +17,10 @@ export class RdDTokenHud {
|
|||||||
if (!token.inCombat) return;
|
if (!token.inCombat) return;
|
||||||
if (!combatant) return;
|
if (!combatant) return;
|
||||||
|
|
||||||
const dataUp = { combatant: combatant, armes: RdDTokenHud.buildListeActionsCombat(combatant) };
|
const hudData = { combatant: combatant, armes: RdDTokenHud.buildListeActionsCombat(combatant) };
|
||||||
|
|
||||||
// initiative
|
// initiative
|
||||||
await RdDTokenHud._configureSubMenu(html.find('.control-icon.combat'), 'systems/foundryvtt-reve-de-dragon/templates/hud-actor-init.html', dataUp,
|
await RdDTokenHud._configureSubMenu(html.find('.control-icon.combat'), 'systems/foundryvtt-reve-de-dragon/templates/hud-actor-init.html', hudData,
|
||||||
(event) => {
|
(event) => {
|
||||||
let armeIndex = event.currentTarget.attributes['data-arme-id'].value;
|
let armeIndex = event.currentTarget.attributes['data-arme-id'].value;
|
||||||
let combatantId = event.currentTarget.attributes['data-combatant-id'].value;
|
let combatantId = event.currentTarget.attributes['data-combatant-id'].value;
|
||||||
@ -29,7 +29,7 @@ export class RdDTokenHud {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// combat
|
// combat
|
||||||
await RdDTokenHud._configureSubMenu(html.find('.control-icon.target'), 'systems/foundryvtt-reve-de-dragon/templates/hud-actor-attaque.html', dataUp,
|
await RdDTokenHud._configureSubMenu(html.find('.control-icon.target'), 'systems/foundryvtt-reve-de-dragon/templates/hud-actor-attaque.html', hudData,
|
||||||
(event) => {
|
(event) => {
|
||||||
let armeIndex = event.currentTarget.attributes['data-arme-id'].value;
|
let armeIndex = event.currentTarget.attributes['data-arme-id'].value;
|
||||||
let arme = armesList[armeIndex];
|
let arme = armesList[armeIndex];
|
||||||
@ -46,8 +46,8 @@ export class RdDTokenHud {
|
|||||||
return armesList;
|
return armesList;
|
||||||
}
|
}
|
||||||
|
|
||||||
static async _configureSubMenu(insertionPoint, template, data, onMenuItem) {
|
static async _configureSubMenu(insertionPoint, template, hudData, onMenuItem) {
|
||||||
const hud = $(await renderTemplate(template, data));
|
const hud = $(await renderTemplate(template, hudData));
|
||||||
const imgHud = hud.find('img.rdd-hud-togglebutton');
|
const imgHud = hud.find('img.rdd-hud-togglebutton');
|
||||||
const list = hud.find('div.rdd-hud-list');
|
const list = hud.find('div.rdd-hud-list');
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ export class RdDUtility {
|
|||||||
'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-encaisser.html',
|
'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-encaisser.html',
|
||||||
'systems/foundryvtt-reve-de-dragon/templates/dialog-tmr.html',
|
'systems/foundryvtt-reve-de-dragon/templates/dialog-tmr.html',
|
||||||
'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-surenc.html',
|
'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-surenc.html',
|
||||||
'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-natation.html',
|
'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-enctotal.html',
|
||||||
'systems/foundryvtt-reve-de-dragon/templates/dialog-astrologie-joueur.html',
|
'systems/foundryvtt-reve-de-dragon/templates/dialog-astrologie-joueur.html',
|
||||||
// Calendrier
|
// Calendrier
|
||||||
'systems/foundryvtt-reve-de-dragon/templates/calendar-template.html',
|
'systems/foundryvtt-reve-de-dragon/templates/calendar-template.html',
|
||||||
|
@ -176,7 +176,7 @@
|
|||||||
|
|
||||||
{{!-- Equipment Tab --}}
|
{{!-- Equipment Tab --}}
|
||||||
<div class="tab items" data-group="primary" data-tab="items">
|
<div class="tab items" data-group="primary" data-tab="items">
|
||||||
<span cass=item-name>Encombrement total/max : {{numberFormat data.encombrementTotal decimals=1}} / {{data.attributs.encombrement.value}}</span>
|
<span cass=item-name>Encombrement total/max : {{numberFormat data.encTotal decimals=1}} / {{data.attributs.encombrement.value}}</span>
|
||||||
<hr>
|
<hr>
|
||||||
<span cass=item-name>Porté sur soi</span>
|
<span cass=item-name>Porté sur soi</span>
|
||||||
<ol class="item-list alterne-list">
|
<ol class="item-list alterne-list">
|
||||||
|
@ -176,7 +176,7 @@
|
|||||||
|
|
||||||
{{!-- Equipment Tab --}}
|
{{!-- Equipment Tab --}}
|
||||||
<div class="tab items" data-group="primary" data-tab="items">
|
<div class="tab items" data-group="primary" data-tab="items">
|
||||||
<span cass=item-name>Encombrement total/max : {{numberFormat data.encombrementTotal decimals=1}} / {{data.attributs.encombrement.value}}</span>
|
<span cass=item-name>Encombrement total/max : {{numberFormat data.encTotal decimals=1}} / {{data.attributs.encombrement.value}}</span>
|
||||||
<ol class="item-list alterne-list">
|
<ol class="item-list alterne-list">
|
||||||
<li class="competence-header flexrow">
|
<li class="competence-header flexrow">
|
||||||
<span class="competence-title competence-label">Nom</span>
|
<span class="competence-title competence-label">Nom</span>
|
||||||
|
@ -597,7 +597,7 @@
|
|||||||
|
|
||||||
{{!-- Equipment Tab --}}
|
{{!-- Equipment Tab --}}
|
||||||
<div class="tab items" data-group="primary" data-tab="items">
|
<div class="tab items" data-group="primary" data-tab="items">
|
||||||
<span class="item-name">Encombrement total/max : {{numberFormat data.encombrementTotal decimals=1}} / {{data.attributs.encombrement.value}} <b>{{data.surEncombrementMessage}}</b></span> -
|
<span class="item-name">Encombrement total/max : {{numberFormat data.encTotal decimals=1}} / {{data.attributs.encombrement.value}} <b>{{data.surEncombrementMessage}}</b></span> -
|
||||||
<span class="item-name"><a id="creer-un-objet">Créer un objet</a></span>
|
<span class="item-name"><a id="creer-un-objet">Créer un objet</a></span>
|
||||||
<ul class="item-list alterne-list">
|
<ul class="item-list alterne-list">
|
||||||
<li class="competence-header flexrow">
|
<li class="competence-header flexrow">
|
||||||
|
@ -65,7 +65,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{>"systems/foundryvtt-reve-de-dragon/templates/dialog-roll-surenc.html"}}
|
{{>"systems/foundryvtt-reve-de-dragon/templates/dialog-roll-surenc.html"}}
|
||||||
{{>"systems/foundryvtt-reve-de-dragon/templates/dialog-roll-natation.html"}}
|
{{>"systems/foundryvtt-reve-de-dragon/templates/dialog-roll-enctotal.html"}}
|
||||||
<div id="resolutionTable">
|
<div id="resolutionTable">
|
||||||
</div>
|
</div>
|
||||||
<div id="resolutionValeurs">
|
<div id="resolutionValeurs">
|
||||||
|
6
templates/dialog-roll-enctotal.html
Normal file
6
templates/dialog-roll-enctotal.html
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{{#if isMalusEncombrementTotal}}
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="xp">Appliquer l'encombrement total comme malus (-{{encTotal}} ) ? </label>
|
||||||
|
<input class="attribute-value" type="checkbox" id="useMalusEncTotal" name="useMalusEncTotal" {{#if useMalusEncTotal}}checked{{/if}}/>
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
@ -1,6 +0,0 @@
|
|||||||
{{#if isNatation}}
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="xp">Appliquer l'encombrement comme malus à la Natation (-{{encValueForNatation}} ) ? </label>
|
|
||||||
<input class="attribute-value" type="checkbox" id="useEncForNatation" name="useEncForNatation" {{#if useEncForNatation}}checked{{/if}}/>
|
|
||||||
</div>
|
|
||||||
{{/if}}
|
|
Loading…
Reference in New Issue
Block a user