Chance actuelle
+ amélioration show/hide: dispo pour toute application (Dialog, Sheet)
This commit is contained in:
parent
c5c6d6208d
commit
29eb489b27
@ -5,6 +5,7 @@
|
||||
|
||||
import { RdDUtility } from "./rdd-utility.js";
|
||||
import { RdDEncaisser } from "./rdd-roll-encaisser.js";
|
||||
import { HtmlUtility } from "./html-utility.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
export class RdDActorSheet extends ActorSheet {
|
||||
@ -90,7 +91,6 @@ export class RdDActorSheet extends ActorSheet {
|
||||
this.armesList = duplicate(data.data.combat);
|
||||
|
||||
data.data.carac.taille.isTaille = true; // To avoid button link;
|
||||
data.data.carac.chance.isChance = true; // Ajouter chance actuelle et utiliser;
|
||||
data.data.compteurs.chance.isChance = true;
|
||||
data.data.blessures.resume = this.actor.computeResumeBlessure(data.data.blessures);
|
||||
|
||||
@ -190,11 +190,7 @@ export class RdDActorSheet extends ActorSheet {
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
|
||||
if (game.user.isGM) {
|
||||
$(".gm-only").show();
|
||||
} else {
|
||||
$(".gm-only").hide();
|
||||
}
|
||||
HtmlUtility._showControlWhen(".gm-only", game.user.isGM);
|
||||
|
||||
// Everything below here is only needed if the sheet is editable
|
||||
if (!this.options.editable) return;
|
||||
@ -258,6 +254,10 @@ export class RdDActorSheet extends ActorSheet {
|
||||
this.actor.rollCarac( caracName.toLowerCase() );
|
||||
});
|
||||
|
||||
html.find('#chance-actuel').click((event) => {
|
||||
this.actor.rollCarac( 'chance-actuel' );
|
||||
});
|
||||
|
||||
// Roll Skill
|
||||
html.find('.competence-label a').click((event) => {
|
||||
let compName = event.currentTarget.text;
|
||||
|
@ -270,7 +270,7 @@ export class RdDActor extends Actor {
|
||||
this.computeRecul( rollData, encaisser );
|
||||
} else { // This is the attack roll!
|
||||
if (rolled.isSuccess) {
|
||||
let target = this.getTarget();
|
||||
let target = this._getTarget();
|
||||
if (await this.targetEntiteNonAccordee(target, 'avant-defense')) {
|
||||
return;
|
||||
}
|
||||
@ -1273,15 +1273,7 @@ export class RdDActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
async rollCarac( caracName )
|
||||
{
|
||||
let carac;
|
||||
if ( caracName == "reveActuel") { // Fake carac for Reve Actuel
|
||||
carac = {type: "number",
|
||||
value: this.getReveActuel(),
|
||||
label: "Rêve Actuel"
|
||||
}
|
||||
} else {
|
||||
carac = this.data.data.carac[caracName];// Per default
|
||||
}
|
||||
let carac = this.getCaracByName(caracName);
|
||||
let rollData = {
|
||||
selectedCarac: carac,
|
||||
ajustementsConditions: CONFIG.RDD.ajustementsConditions,
|
||||
@ -1302,6 +1294,28 @@ export class RdDActor extends Actor {
|
||||
new RdDRollDialog("carac", html, rollData, this ).render(true);
|
||||
}
|
||||
|
||||
getCaracByName(caracName) {
|
||||
switch (caracName)
|
||||
{
|
||||
case 'reveActuel':
|
||||
return {
|
||||
label: 'Rêve Actuel',
|
||||
value: this.getReveActuel(),
|
||||
type: "number",
|
||||
ignoreEtatGeneral: true
|
||||
};
|
||||
case 'chance-actuelle':
|
||||
return {
|
||||
type: "number",
|
||||
value: this.getChanceActuel(),
|
||||
label: 'Chance actuelle',
|
||||
ignoreEtatGeneral: true
|
||||
};
|
||||
default:
|
||||
return this.data.data.carac[caracName]; // Per default
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getSortList() {
|
||||
return this.data.items.filter(item => item.type == "sort");
|
||||
@ -1347,8 +1361,7 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
rollArme( armeName, competenceName=undefined )
|
||||
{
|
||||
rollArme( armeName, competenceName=undefined ) {
|
||||
let armeItem = this.data.items.find(item=>item.type==="arme" && (item.name === armeName));
|
||||
if (armeItem ) {
|
||||
if ( competenceName == undefined) competenceName = armeItem.data.competence;
|
||||
@ -1415,7 +1428,7 @@ export class RdDActor extends Actor {
|
||||
|
||||
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-competence.html', rollData);
|
||||
if (rollData.arme) {
|
||||
if (await this.targetEntiteNonAccordee(this.getTarget(), 'avant-attaque')) {
|
||||
if (await this.targetEntiteNonAccordee(this._getTarget(), 'avant-attaque')) {
|
||||
return;
|
||||
}
|
||||
new RdDRollDialog("arme", html, rollData, this, attacker).render(true);
|
||||
@ -1424,8 +1437,7 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getTarget() {
|
||||
_getTarget() {
|
||||
if (game.user.targets && game.user.targets.size == 1) {
|
||||
for (let target of game.user.targets) {
|
||||
return target;
|
||||
@ -1435,8 +1447,7 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async equiperObjet( itemID )
|
||||
{
|
||||
async equiperObjet( itemID ) {
|
||||
let item = this.getOwnedItem(itemID);
|
||||
if ( item && item.data.data ) {
|
||||
let update = {_id: item._id, "data.equipe": !item.data.data.equipe };
|
||||
@ -1476,7 +1487,6 @@ export class RdDActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
async encaisserDommages( attackerRoll, attacker = undefined ) {
|
||||
|
||||
|
||||
if (attacker && !await attacker.accorder(this, 'avant-encaissement')) {
|
||||
return;
|
||||
}
|
||||
|
10
module/html-utility.js
Normal file
10
module/html-utility.js
Normal file
@ -0,0 +1,10 @@
|
||||
export class HtmlUtility{
|
||||
static _showControlWhen(control, condition) {
|
||||
if (condition) {
|
||||
$(control).show();
|
||||
}
|
||||
else {
|
||||
$(control).hide();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
import { HtmlUtility } from "./html-utility.js";
|
||||
import { RdDItemSort } from "./item-sort.js";
|
||||
import { Misc } from "./misc.js";
|
||||
import { RdDResolutionTable } from "./rdd-resolution-table.js";
|
||||
@ -72,25 +73,12 @@ export class RdDRollDialog extends Dialog {
|
||||
rollData.finalLevel = rollLevel;
|
||||
rollData.caracValue = caracValue
|
||||
|
||||
if (RdDRollDialog._isEtatGeneralApplicable(rollData)) {
|
||||
$(".etat-general").show();
|
||||
}
|
||||
else {
|
||||
$(".etat-general").hide();
|
||||
}
|
||||
HtmlUtility._showControlWhen(".etat-general", !RdDRollDialog._isIgnoreEtatGeneral(rollData));
|
||||
// Sort management
|
||||
if ( rollData.selectedSort ) {
|
||||
//console.log("Toggle show/hide", rollData.selectedSort);
|
||||
if (RdDItemSort.isDifficulteVariable(rollData.selectedSort)) {
|
||||
$("#div-sort-difficulte").show();
|
||||
} else {
|
||||
$("#div-sort-difficulte").hide();
|
||||
}
|
||||
if (RdDItemSort.isCoutVariable(rollData.selectedSort)) {
|
||||
$("#div-sort-ptreve").show();
|
||||
} else {
|
||||
$("#div-sort-ptreve").hide();
|
||||
}
|
||||
HtmlUtility._showControlWhen("#div-sort-difficulte",RdDItemSort.isDifficulteVariable(rollData.selectedSort));
|
||||
HtmlUtility._showControlWhen("#div-sort-ptreve", RdDItemSort.isCoutVariable(rollData.selectedSort));
|
||||
}
|
||||
|
||||
// Mise à jour valeurs
|
||||
@ -173,16 +161,13 @@ export class RdDRollDialog extends Dialog {
|
||||
});
|
||||
}
|
||||
|
||||
static _isEtatGeneralApplicable(rollData) {
|
||||
if (rollData.selectedCarac.label == 'Chance') return false;
|
||||
if (rollData.selectedCarac.label == 'Rêve Actuel') return false;
|
||||
|
||||
return true;
|
||||
static _isIgnoreEtatGeneral(rollData) {
|
||||
return rollData.selectedCarac.ignoreEtatGeneral;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static _computeFinalLevel(rollData) {
|
||||
const etat = RdDRollDialog._isEtatGeneralApplicable(rollData) ? Misc.toInt(rollData.etat) : 0;
|
||||
const etat = RdDRollDialog._isIgnoreEtatGeneral(rollData) ? 0 : Misc.toInt(rollData.etat);
|
||||
const diffConditions = Misc.toInt(rollData.diffConditions);
|
||||
let malusEnc = (rollData.surencMalusApply ) ? rollData.surencMalusValue : 0;
|
||||
let diffLibre = Misc.toInt(rollData.diffLibre);
|
||||
|
@ -131,7 +131,7 @@
|
||||
</ul>
|
||||
<ul class="carac-list alterne-list">
|
||||
<li class="competence flexrow list-item">
|
||||
<span class="generic-label" id="chance-actuel"><a>Chance actuelle</a></span>
|
||||
<span class="generic-label" id="chance-actuelle"><a>Chance actuelle</a></span>
|
||||
<input class="compteur-edit" id="chance-edit" type="text" name="chance" value="{{data.compteurs.chance.value}}" data-dtype="number"/>
|
||||
<a class="item-control stress-test" id="chance-appel">Utiliser</a>
|
||||
</li>
|
||||
|
Loading…
Reference in New Issue
Block a user