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 { RdDUtility } from "./rdd-utility.js";
|
||||||
import { RdDEncaisser } from "./rdd-roll-encaisser.js";
|
import { RdDEncaisser } from "./rdd-roll-encaisser.js";
|
||||||
|
import { HtmlUtility } from "./html-utility.js";
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
export class RdDActorSheet extends ActorSheet {
|
export class RdDActorSheet extends ActorSheet {
|
||||||
@ -90,7 +91,6 @@ export class RdDActorSheet extends ActorSheet {
|
|||||||
this.armesList = duplicate(data.data.combat);
|
this.armesList = duplicate(data.data.combat);
|
||||||
|
|
||||||
data.data.carac.taille.isTaille = true; // To avoid button link;
|
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.compteurs.chance.isChance = true;
|
||||||
data.data.blessures.resume = this.actor.computeResumeBlessure(data.data.blessures);
|
data.data.blessures.resume = this.actor.computeResumeBlessure(data.data.blessures);
|
||||||
|
|
||||||
@ -190,11 +190,7 @@ export class RdDActorSheet extends ActorSheet {
|
|||||||
activateListeners(html) {
|
activateListeners(html) {
|
||||||
super.activateListeners(html);
|
super.activateListeners(html);
|
||||||
|
|
||||||
if (game.user.isGM) {
|
HtmlUtility._showControlWhen(".gm-only", game.user.isGM);
|
||||||
$(".gm-only").show();
|
|
||||||
} else {
|
|
||||||
$(".gm-only").hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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;
|
||||||
@ -258,6 +254,10 @@ export class RdDActorSheet extends ActorSheet {
|
|||||||
this.actor.rollCarac( caracName.toLowerCase() );
|
this.actor.rollCarac( caracName.toLowerCase() );
|
||||||
});
|
});
|
||||||
|
|
||||||
|
html.find('#chance-actuel').click((event) => {
|
||||||
|
this.actor.rollCarac( 'chance-actuel' );
|
||||||
|
});
|
||||||
|
|
||||||
// Roll Skill
|
// Roll Skill
|
||||||
html.find('.competence-label a').click((event) => {
|
html.find('.competence-label a').click((event) => {
|
||||||
let compName = event.currentTarget.text;
|
let compName = event.currentTarget.text;
|
||||||
|
182
module/actor.js
182
module/actor.js
@ -270,7 +270,7 @@ export class RdDActor extends Actor {
|
|||||||
this.computeRecul( rollData, encaisser );
|
this.computeRecul( rollData, encaisser );
|
||||||
} else { // This is the attack roll!
|
} else { // This is the attack roll!
|
||||||
if (rolled.isSuccess) {
|
if (rolled.isSuccess) {
|
||||||
let target = this.getTarget();
|
let target = this._getTarget();
|
||||||
if (await this.targetEntiteNonAccordee(target, 'avant-defense')) {
|
if (await this.targetEntiteNonAccordee(target, 'avant-defense')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1273,91 +1273,104 @@ export class RdDActor extends Actor {
|
|||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async rollCarac( caracName )
|
async rollCarac( caracName )
|
||||||
{
|
{
|
||||||
let carac;
|
let carac = this.getCaracByName(caracName);
|
||||||
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 rollData = {
|
let rollData = {
|
||||||
selectedCarac: carac,
|
selectedCarac: carac,
|
||||||
ajustementsConditions: CONFIG.RDD.ajustementsConditions,
|
ajustementsConditions: CONFIG.RDD.ajustementsConditions,
|
||||||
difficultesLibres: CONFIG.RDD.difficultesLibres,
|
difficultesLibres: CONFIG.RDD.difficultesLibres,
|
||||||
etat: this.data.data.compteurs.etat.value,
|
etat: this.data.data.compteurs.etat.value,
|
||||||
finalLevel: 0,
|
finalLevel: 0,
|
||||||
diffConditions: 0,
|
diffConditions: 0,
|
||||||
diffLibre: 0,
|
diffLibre: 0,
|
||||||
malusArmureValue: (this.data.data.attributs) ? this.data.data.attributs.malusarmure.value : 0,
|
malusArmureValue: (this.data.data.attributs) ? this.data.data.attributs.malusarmure.value : 0,
|
||||||
surencMalusFlag: (this.data.data.compteurs.surenc.value < 0),
|
surencMalusFlag: (this.data.data.compteurs.surenc.value < 0),
|
||||||
surencMalusValue: this.data.data.compteurs.surenc.value,
|
surencMalusValue: this.data.data.compteurs.surenc.value,
|
||||||
surencMalusApply: false,
|
surencMalusApply: false,
|
||||||
isNatation: false,
|
isNatation: false,
|
||||||
useEncForNatation: false
|
useEncForNatation: false
|
||||||
}
|
|
||||||
console.log(caracName, rollData);
|
|
||||||
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html', rollData);
|
|
||||||
new RdDRollDialog("carac", html, rollData, this ).render(true);
|
|
||||||
}
|
}
|
||||||
|
console.log(caracName, rollData);
|
||||||
/* -------------------------------------------- */
|
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html', rollData);
|
||||||
getSortList() {
|
new RdDRollDialog("carac", html, rollData, this ).render(true);
|
||||||
return this.data.items.filter(item => item.type == "sort");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
getDraconicList() {
|
|
||||||
return this.data.items.filter(item => item.data.categorie == 'draconic')
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
async displayTMR(mode="normal")
|
|
||||||
{
|
|
||||||
let isRapide= mode == "rapide"
|
|
||||||
if (mode != "visu")
|
|
||||||
{
|
|
||||||
let minReveValue = (isRapide) ? 3 : 2;
|
|
||||||
if (this.getReveActuel() < minReveValue ) {
|
|
||||||
ChatMessage.create( {
|
|
||||||
content: "Vous n'avez plus assez de Points de Reve pour monter dans les Terres Médianes",
|
|
||||||
whisper: ChatMessage.getWhisperRecipients(game.user.name) } );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Notification au MJ
|
|
||||||
ChatMessage.create( { content: game.user.name + " est monté dans les TMR en mode : " + mode, whisper: ChatMessage.getWhisperRecipients("GM") } );
|
|
||||||
|
|
||||||
let data = {
|
getCaracByName(caracName) {
|
||||||
fatigue: {
|
switch (caracName)
|
||||||
malus: RdDUtility.calculMalusFatigue(this.data.data.sante.fatigue.value, this.data.data.sante.endurance.max),
|
|
||||||
html: "<table class='table-fatigue'>" + RdDUtility.makeHTMLfatigueMatrix( this.data.data.sante.fatigue.value, this.data.data.sante.endurance.max ).html() + "</table>"
|
|
||||||
},
|
|
||||||
draconic: this.getDraconicList(),
|
|
||||||
sort: this.getSortList(),
|
|
||||||
caracReve: this.data.data.carac.reve.value,
|
|
||||||
pointsReve: this.getReveActuel(),
|
|
||||||
isRapide: isRapide
|
|
||||||
}
|
|
||||||
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-tmr.html', data );
|
|
||||||
this.currentTMR = new RdDTMRDialog(html, this, data, mode);
|
|
||||||
this.currentTMR.render(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
rollArme( armeName, competenceName=undefined )
|
|
||||||
{
|
{
|
||||||
let armeItem = this.data.items.find(item=>item.type==="arme" && (item.name === armeName));
|
case 'reveActuel':
|
||||||
if (armeItem ) {
|
return {
|
||||||
if ( competenceName == undefined) competenceName = armeItem.data.competence;
|
label: 'Rêve Actuel',
|
||||||
this.rollCompetence( competenceName, armeItem );
|
value: this.getReveActuel(),
|
||||||
} else {
|
type: "number",
|
||||||
this.rollCompetence( armeName ); //Bypass mode!
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
getDraconicList() {
|
||||||
|
return this.data.items.filter(item => item.data.categorie == 'draconic')
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
async displayTMR(mode="normal")
|
||||||
|
{
|
||||||
|
let isRapide= mode == "rapide"
|
||||||
|
if (mode != "visu")
|
||||||
|
{
|
||||||
|
let minReveValue = (isRapide) ? 3 : 2;
|
||||||
|
if (this.getReveActuel() < minReveValue ) {
|
||||||
|
ChatMessage.create( {
|
||||||
|
content: "Vous n'avez plus assez de Points de Reve pour monter dans les Terres Médianes",
|
||||||
|
whisper: ChatMessage.getWhisperRecipients(game.user.name) } );
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Notification au MJ
|
||||||
|
ChatMessage.create( { content: game.user.name + " est monté dans les TMR en mode : " + mode, whisper: ChatMessage.getWhisperRecipients("GM") } );
|
||||||
|
|
||||||
|
let data = {
|
||||||
|
fatigue: {
|
||||||
|
malus: RdDUtility.calculMalusFatigue(this.data.data.sante.fatigue.value, this.data.data.sante.endurance.max),
|
||||||
|
html: "<table class='table-fatigue'>" + RdDUtility.makeHTMLfatigueMatrix( this.data.data.sante.fatigue.value, this.data.data.sante.endurance.max ).html() + "</table>"
|
||||||
|
},
|
||||||
|
draconic: this.getDraconicList(),
|
||||||
|
sort: this.getSortList(),
|
||||||
|
caracReve: this.data.data.carac.reve.value,
|
||||||
|
pointsReve: this.getReveActuel(),
|
||||||
|
isRapide: isRapide
|
||||||
|
}
|
||||||
|
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-tmr.html', data );
|
||||||
|
this.currentTMR = new RdDTMRDialog(html, this, data, mode);
|
||||||
|
this.currentTMR.render(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
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;
|
||||||
|
this.rollCompetence( competenceName, armeItem );
|
||||||
|
} else {
|
||||||
|
this.rollCompetence( armeName ); //Bypass mode!
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async rollCompetence( name, armeItem=undefined, attackerRoll=undefined, attacker = undefined) {
|
async rollCompetence( name, armeItem=undefined, attackerRoll=undefined, attacker = undefined) {
|
||||||
let competence = RdDUtility.findCompetence( this.data.items, name);
|
let competence = RdDUtility.findCompetence( this.data.items, name);
|
||||||
@ -1415,7 +1428,7 @@ export class RdDActor extends Actor {
|
|||||||
|
|
||||||
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-competence.html', rollData);
|
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-competence.html', rollData);
|
||||||
if (rollData.arme) {
|
if (rollData.arme) {
|
||||||
if (await this.targetEntiteNonAccordee(this.getTarget(), 'avant-attaque')) {
|
if (await this.targetEntiteNonAccordee(this._getTarget(), 'avant-attaque')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
new RdDRollDialog("arme", html, rollData, this, attacker).render(true);
|
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) {
|
if (game.user.targets && game.user.targets.size == 1) {
|
||||||
for (let target of game.user.targets) {
|
for (let target of game.user.targets) {
|
||||||
return target;
|
return target;
|
||||||
@ -1435,8 +1447,7 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async equiperObjet( itemID )
|
async equiperObjet( itemID ) {
|
||||||
{
|
|
||||||
let item = this.getOwnedItem(itemID);
|
let item = this.getOwnedItem(itemID);
|
||||||
if ( item && item.data.data ) {
|
if ( item && item.data.data ) {
|
||||||
let update = {_id: item._id, "data.equipe": !item.data.data.equipe };
|
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 ) {
|
async encaisserDommages( attackerRoll, attacker = undefined ) {
|
||||||
|
|
||||||
|
|
||||||
if (attacker && !await attacker.accorder(this, 'avant-encaissement')) {
|
if (attacker && !await attacker.accorder(this, 'avant-encaissement')) {
|
||||||
return;
|
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 { RdDItemSort } from "./item-sort.js";
|
||||||
import { Misc } from "./misc.js";
|
import { Misc } from "./misc.js";
|
||||||
import { RdDResolutionTable } from "./rdd-resolution-table.js";
|
import { RdDResolutionTable } from "./rdd-resolution-table.js";
|
||||||
@ -72,25 +73,12 @@ export class RdDRollDialog extends Dialog {
|
|||||||
rollData.finalLevel = rollLevel;
|
rollData.finalLevel = rollLevel;
|
||||||
rollData.caracValue = caracValue
|
rollData.caracValue = caracValue
|
||||||
|
|
||||||
if (RdDRollDialog._isEtatGeneralApplicable(rollData)) {
|
HtmlUtility._showControlWhen(".etat-general", !RdDRollDialog._isIgnoreEtatGeneral(rollData));
|
||||||
$(".etat-general").show();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$(".etat-general").hide();
|
|
||||||
}
|
|
||||||
// Sort management
|
// Sort management
|
||||||
if ( rollData.selectedSort ) {
|
if ( rollData.selectedSort ) {
|
||||||
//console.log("Toggle show/hide", rollData.selectedSort);
|
//console.log("Toggle show/hide", rollData.selectedSort);
|
||||||
if (RdDItemSort.isDifficulteVariable(rollData.selectedSort)) {
|
HtmlUtility._showControlWhen("#div-sort-difficulte",RdDItemSort.isDifficulteVariable(rollData.selectedSort));
|
||||||
$("#div-sort-difficulte").show();
|
HtmlUtility._showControlWhen("#div-sort-ptreve", RdDItemSort.isCoutVariable(rollData.selectedSort));
|
||||||
} else {
|
|
||||||
$("#div-sort-difficulte").hide();
|
|
||||||
}
|
|
||||||
if (RdDItemSort.isCoutVariable(rollData.selectedSort)) {
|
|
||||||
$("#div-sort-ptreve").show();
|
|
||||||
} else {
|
|
||||||
$("#div-sort-ptreve").hide();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mise à jour valeurs
|
// Mise à jour valeurs
|
||||||
@ -173,16 +161,13 @@ export class RdDRollDialog extends Dialog {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static _isEtatGeneralApplicable(rollData) {
|
static _isIgnoreEtatGeneral(rollData) {
|
||||||
if (rollData.selectedCarac.label == 'Chance') return false;
|
return rollData.selectedCarac.ignoreEtatGeneral;
|
||||||
if (rollData.selectedCarac.label == 'Rêve Actuel') return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static _computeFinalLevel(rollData) {
|
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);
|
const diffConditions = Misc.toInt(rollData.diffConditions);
|
||||||
let malusEnc = (rollData.surencMalusApply ) ? rollData.surencMalusValue : 0;
|
let malusEnc = (rollData.surencMalusApply ) ? rollData.surencMalusValue : 0;
|
||||||
let diffLibre = Misc.toInt(rollData.diffLibre);
|
let diffLibre = Misc.toInt(rollData.diffLibre);
|
||||||
|
@ -131,7 +131,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<ul class="carac-list alterne-list">
|
<ul class="carac-list alterne-list">
|
||||||
<li class="competence flexrow list-item">
|
<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"/>
|
<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>
|
<a class="item-control stress-test" id="chance-appel">Utiliser</a>
|
||||||
</li>
|
</li>
|
||||||
|
Loading…
Reference in New Issue
Block a user