Merge branch 'chance' into 'dev_1.1'
Appel à la chance See merge request LeRatierBretonnien/foundryvtt-reve-de-dragon!57
This commit is contained in:
commit
63fee16096
@ -42,9 +42,8 @@ export class RdDActorCreatureSheet extends ActorSheet {
|
|||||||
data.data.caracSum = sum;
|
data.data.caracSum = sum;
|
||||||
|
|
||||||
data.data.carac.taille.isTaille = true; // To avoid button link;
|
data.data.carac.taille.isTaille = true; // To avoid button link;
|
||||||
data.data.nbLegeres = this.actor.countBlessures(data.data.blessures.legeres.liste );
|
data.data.blessures.resume = this.actor.computeResumeBlessure(data.data.blessures);
|
||||||
data.data.nbGraves = this.actor.countBlessures(data.data.blessures.graves.liste );
|
|
||||||
data.data.nbCritiques = this.actor.countBlessures(data.data.blessures.critiques.liste );
|
|
||||||
data.data.isGM = game.user.isGM;
|
data.data.isGM = game.user.isGM;
|
||||||
|
|
||||||
data.data.competencecreature = data.itemsByType["competencecreature"];
|
data.data.competencecreature = data.itemsByType["competencecreature"];
|
||||||
|
@ -41,9 +41,9 @@ export class RdDActorHumanoideSheet extends ActorSheet {
|
|||||||
data.data.caracSum = sum;
|
data.data.caracSum = sum;
|
||||||
|
|
||||||
data.data.carac.taille.isTaille = true; // To avoid button link;
|
data.data.carac.taille.isTaille = true; // To avoid button link;
|
||||||
data.data.nbLegeres = this.actor.countBlessures(data.data.blessures.legeres.liste );
|
data.data.carac.chance.isChance = true; // Ajouter chance actuelle et utiliser;
|
||||||
data.data.nbGraves = this.actor.countBlessures(data.data.blessures.graves.liste );
|
data.data.blessures.resume = this.actor.computeResumeBlessure(data.data.blessures);
|
||||||
data.data.nbCritiques = this.actor.countBlessures(data.data.blessures.critiques.liste );
|
|
||||||
data.data.competencecreature = data.itemsByType["competencecreature"];
|
data.data.competencecreature = data.itemsByType["competencecreature"];
|
||||||
data.data.isGM = game.user.isGM;
|
data.data.isGM = game.user.isGM;
|
||||||
|
|
||||||
|
@ -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,9 +91,8 @@ 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.nbLegeres = this.actor.countBlessures(data.data.blessures.legeres.liste );
|
data.data.compteurs.chance.isChance = true;
|
||||||
data.data.nbGraves = this.actor.countBlessures(data.data.blessures.graves.liste );
|
data.data.blessures.resume = this.actor.computeResumeBlessure(data.data.blessures);
|
||||||
data.data.nbCritiques = this.actor.countBlessures(data.data.blessures.critiques.liste );
|
|
||||||
|
|
||||||
// Mise à jour de l'encombrement total
|
// Mise à jour de l'encombrement total
|
||||||
this.actor.computeEncombrementTotalEtMalusArmure();
|
this.actor.computeEncombrementTotalEtMalusArmure();
|
||||||
@ -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,14 @@ 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' );
|
||||||
|
});
|
||||||
|
|
||||||
|
html.find('#chance-appel').click((event) => {
|
||||||
|
this.actor.appelChance();
|
||||||
|
});
|
||||||
|
|
||||||
// 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;
|
||||||
|
124
module/actor.js
124
module/actor.js
@ -6,6 +6,7 @@
|
|||||||
import { RdDUtility } from "./rdd-utility.js";
|
import { RdDUtility } from "./rdd-utility.js";
|
||||||
import { TMRUtility } from "./tmr-utility.js";
|
import { TMRUtility } from "./tmr-utility.js";
|
||||||
import { RdDRollDialog } from "./rdd-roll-dialog.js";
|
import { RdDRollDialog } from "./rdd-roll-dialog.js";
|
||||||
|
import { RdDRoll } from "./rdd-roll.js";
|
||||||
import { RdDTMRDialog } from "./rdd-tmr-dialog.js";
|
import { RdDTMRDialog } from "./rdd-tmr-dialog.js";
|
||||||
import { Misc } from "./misc.js";
|
import { Misc } from "./misc.js";
|
||||||
|
|
||||||
@ -107,6 +108,10 @@ export class RdDActor extends Actor {
|
|||||||
return this.data.data.reve.reve.value;
|
return this.data.data.reve.reve.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getChanceActuel() {
|
||||||
|
return this.data.data.compteurs.chance.value;
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
getBestDraconic() {
|
getBestDraconic() {
|
||||||
const list = this.getDraconicList().sort((a, b) => b.data.niveau - a.data.niveau);
|
const list = this.getDraconicList().sort((a, b) => b.data.niveau - a.data.niveau);
|
||||||
@ -270,7 +275,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;
|
||||||
}
|
}
|
||||||
@ -862,6 +867,33 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
computeResumeBlessure(blessures = this.data.data.blessures) {
|
||||||
|
let nbLegeres = this.countBlessures(blessures.legeres.liste );
|
||||||
|
let nbGraves = this.countBlessures(blessures.graves.liste );
|
||||||
|
let nbCritiques = this.countBlessures(blessures.critiques.liste );
|
||||||
|
|
||||||
|
let resume = "Blessures:";
|
||||||
|
if (nbCritiques > 0 || nbGraves > 0 || nbLegeres > 0) {
|
||||||
|
if (nbLegeres > 0) {
|
||||||
|
resume += " " + nbLegeres + " légères";
|
||||||
|
}
|
||||||
|
if (nbGraves > 0) {
|
||||||
|
if (nbLegeres > 0)
|
||||||
|
resume += ",";
|
||||||
|
resume += " " + nbGraves + " graves";
|
||||||
|
}
|
||||||
|
if (nbCritiques > 0) {
|
||||||
|
if (nbGraves > 0 || nbLegeres > 0)
|
||||||
|
resume += ",";
|
||||||
|
resume += " une CRITIQUE !";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
resume += " aucune";
|
||||||
|
}
|
||||||
|
return resume;
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
computeEtatGeneral( )
|
computeEtatGeneral( )
|
||||||
{
|
{
|
||||||
@ -1246,15 +1278,7 @@ 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,
|
||||||
@ -1275,6 +1299,74 @@ export class RdDActor extends Actor {
|
|||||||
new RdDRollDialog("carac", html, rollData, this ).render(true);
|
new RdDRollDialog("carac", html, rollData, this ).render(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async appelChance( )
|
||||||
|
{
|
||||||
|
let rollData = {
|
||||||
|
selectedCarac: this.getCaracByName('chance-actuelle'),
|
||||||
|
diffConditions: this.ajustementAstrologique()
|
||||||
|
}
|
||||||
|
|
||||||
|
const dialog = await RdDRoll.create(
|
||||||
|
'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html',
|
||||||
|
this,
|
||||||
|
rollData,
|
||||||
|
{
|
||||||
|
name: 'appelChance',
|
||||||
|
label: 'Appel à la chance',
|
||||||
|
callbacks: [
|
||||||
|
{ action: rollData => this._appelChanceResultat(rollData) }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
);
|
||||||
|
dialog.render(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
_appelChanceResultat(rollData) {
|
||||||
|
const message = {
|
||||||
|
user: game.user._id,
|
||||||
|
alias: this.name,
|
||||||
|
content: this.name + " fait appel à la chance" + RdDResolutionTable.explain(rollData.rolled)
|
||||||
|
};
|
||||||
|
if (rollData.rolled.isSuccess) {
|
||||||
|
message.content += "<br>Dépense d'un point de chance, l'action peut être retentée"
|
||||||
|
this.chanceActuelleIncDec(-1)
|
||||||
|
}
|
||||||
|
ChatMessage.create(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
async chanceActuelleIncDec(value) {
|
||||||
|
let chance = duplicate(this.data.data.compteurs.chance);
|
||||||
|
chance.value = Math.max(chance.value + value, 0);
|
||||||
|
await this.update( {"data.compteurs.chance": chance } );
|
||||||
|
}
|
||||||
|
|
||||||
|
ajustementAstrologique() {
|
||||||
|
//TODO: selon heure et heure de naissance...
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
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() {
|
getSortList() {
|
||||||
return this.data.items.filter(item => item.type == "sort");
|
return this.data.items.filter(item => item.type == "sort");
|
||||||
@ -1320,8 +1412,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));
|
let armeItem = this.data.items.find(item=>item.type==="arme" && (item.name === armeName));
|
||||||
if (armeItem ) {
|
if (armeItem ) {
|
||||||
if ( competenceName == undefined) competenceName = armeItem.data.competence;
|
if ( competenceName == undefined) competenceName = armeItem.data.competence;
|
||||||
@ -1388,7 +1479,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);
|
||||||
@ -1397,8 +1488,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;
|
||||||
@ -1408,8 +1498,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 };
|
||||||
@ -1449,7 +1538,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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -80,22 +80,26 @@ export class RdDResolutionTable {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static explain(rolled) {
|
static explain(rolled) {
|
||||||
let message = "<br>Jet : <strong>" + rolled.roll + "</strong> sur " + rolled.score + "%";
|
let message = "<br>Jet : <strong>" + rolled.roll + "</strong> sur " + rolled.score + "% ";
|
||||||
if (rolled.caracValue != null && rolled.finalLevel!= null) {
|
if (rolled.caracValue != null && rolled.finalLevel!= null) {
|
||||||
message += " (" + rolled.caracValue + " à " + Misc.toSignedString(rolled.finalLevel) + ")";
|
message += "(" + rolled.caracValue + " à " + Misc.toSignedString(rolled.finalLevel) + ") ";
|
||||||
}
|
}
|
||||||
|
message += rolled.quality
|
||||||
return message;
|
return message;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static updateChancesWithBonus( chances, bonus ) {
|
static updateChancesWithBonus( chances, bonus ) {
|
||||||
|
if (bonus) {
|
||||||
let newScore = Number(chances.score) + Number(bonus);
|
let newScore = Number(chances.score) + Number(bonus);
|
||||||
chances.score = newScore;
|
mergeObject(chances, this._computeCell(null, newScore), {overwrite: true});
|
||||||
chances.sign = this._reussiteSignificative(newScore);
|
}
|
||||||
chances.part = this._reussitePart(newScore);
|
}
|
||||||
chances.epart = this._echecParticulier(newScore);
|
|
||||||
chances.etotal = this._echecTotal(newScore);
|
static async rollData(rollData ) {
|
||||||
|
rollData.rolled = await this.roll(rollData.caracValue, rollData.finalLevel, rollData.bonus);
|
||||||
|
return rollData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
@ -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,19 +73,12 @@ export class RdDRollDialog extends Dialog {
|
|||||||
rollData.finalLevel = rollLevel;
|
rollData.finalLevel = rollLevel;
|
||||||
rollData.caracValue = caracValue
|
rollData.caracValue = caracValue
|
||||||
|
|
||||||
|
HtmlUtility._showControlWhen(".etat-general", !RdDRollDialog._isIgnoreEtatGeneral(rollData));
|
||||||
// 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
|
||||||
@ -167,9 +161,13 @@ export class RdDRollDialog extends Dialog {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static _isIgnoreEtatGeneral(rollData) {
|
||||||
|
return rollData.selectedCarac.ignoreEtatGeneral;
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static _computeFinalLevel(rollData) {
|
static _computeFinalLevel(rollData) {
|
||||||
const etat = Misc.toInt(rollData.etat);
|
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);
|
||||||
|
230
module/rdd-roll.js
Normal file
230
module/rdd-roll.js
Normal file
@ -0,0 +1,230 @@
|
|||||||
|
import { HtmlUtility } from "./html-utility.js";
|
||||||
|
import { RdDItemSort } from "./item-sort.js";
|
||||||
|
import { Misc } from "./misc.js";
|
||||||
|
import { RdDResolutionTable } from "./rdd-resolution-table.js";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extend the base Dialog entity to select roll parameters
|
||||||
|
* @extends {Dialog}
|
||||||
|
*/
|
||||||
|
|
||||||
|
export class RdDRoll extends Dialog {
|
||||||
|
|
||||||
|
static async create(htmlTemplate, actor, rollData, ...actions) {
|
||||||
|
RdDRoll._ensureCorrectActions(actions);
|
||||||
|
|
||||||
|
RdDRoll._setDefaultOptions(actor, rollData);
|
||||||
|
|
||||||
|
const html = await renderTemplate(htmlTemplate, rollData);
|
||||||
|
|
||||||
|
return new RdDRoll(actor, rollData, html, {
|
||||||
|
classes: ["rdddialog"],
|
||||||
|
width: 600, height: 500, 'z-index': 99999
|
||||||
|
}, actions);
|
||||||
|
}
|
||||||
|
|
||||||
|
static _setDefaultOptions(actor, rollData) {
|
||||||
|
|
||||||
|
mergeObject(rollData,
|
||||||
|
{
|
||||||
|
ajustementsConditions: CONFIG.RDD.ajustementsConditions,
|
||||||
|
difficultesLibres: CONFIG.RDD.difficultesLibres,
|
||||||
|
etat: actor.data.data.compteurs.etat.value,
|
||||||
|
finalLevel: 0,
|
||||||
|
diffConditions: 0,
|
||||||
|
diffLibre: 0,
|
||||||
|
malusArmureValue: 0,
|
||||||
|
surencMalusFlag: actor.data.data.attributs ? actor.data.data.attributs.malusarmure.value : 0,
|
||||||
|
surencMalusValue: actor.data.data.compteurs.surenc.value,
|
||||||
|
surencMalusApply: false,
|
||||||
|
isNatation: false,
|
||||||
|
useEncForNatation: false
|
||||||
|
},
|
||||||
|
{ overwrite: false });
|
||||||
|
}
|
||||||
|
|
||||||
|
static _ensureCorrectActions(actions) {
|
||||||
|
if (actions.length==0) {
|
||||||
|
throw 'No action defined';
|
||||||
|
}
|
||||||
|
actions.forEach(action => {
|
||||||
|
if (action.callbacks == undefined) {
|
||||||
|
action.callbacks = [{action: r => console.log(action.name, r)}];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(actor, rollData, html, options, actions) {
|
||||||
|
let conf = {
|
||||||
|
title: actions[0].label,
|
||||||
|
content: html,
|
||||||
|
buttons: {},
|
||||||
|
default: actions[0].name
|
||||||
|
};
|
||||||
|
for (let action of actions) {
|
||||||
|
conf.buttons[action.name] = { label: action.label, callback: html => this.onAction(action, html) };
|
||||||
|
}
|
||||||
|
|
||||||
|
super(conf, options);
|
||||||
|
|
||||||
|
this.actor = actor;
|
||||||
|
this.rollData = rollData;
|
||||||
|
}
|
||||||
|
|
||||||
|
async onAction(action, html) {
|
||||||
|
await RdDResolutionTable.rollData(this.rollData);
|
||||||
|
if (action.callbacks)
|
||||||
|
for (let callback of action.callbacks) {
|
||||||
|
if (callback.condition == undefined || callback.condition(this.rollData.rolled)) {
|
||||||
|
callback.action(this.rollData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
activateListeners(html) {
|
||||||
|
super.activateListeners(html);
|
||||||
|
|
||||||
|
this.bringToTop();
|
||||||
|
|
||||||
|
var rollData = this.rollData;
|
||||||
|
|
||||||
|
function updateRollResult(rollData) {
|
||||||
|
let caracValue = parseInt(rollData.selectedCarac.value)
|
||||||
|
let rollLevel = RdDRoll._computeFinalLevel(rollData);
|
||||||
|
|
||||||
|
rollData.finalLevel = rollLevel;
|
||||||
|
rollData.caracValue = caracValue
|
||||||
|
|
||||||
|
HtmlUtility._showControlWhen(".etat-general", !RdDRoll._isIgnoreEtatGeneral(rollData));
|
||||||
|
|
||||||
|
// Sort management
|
||||||
|
if (rollData.selectedSort) {
|
||||||
|
//console.log("Toggle show/hide", rollData.selectedSort);
|
||||||
|
HtmlUtility._showControlWhen("#div-sort-difficulte", RdDItemSort.isDifficulteVariable(rollData.selectedSort))
|
||||||
|
HtmlUtility._showControlWhen("#div-sort-ptreve", RdDItemSort.isCoutVariable(rollData.selectedSort))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mise à jour valeurs
|
||||||
|
$("#roll-param").text(rollData.selectedCarac.value + " / " + Misc.toSignedString(rollData.finalLevel));
|
||||||
|
$("#compdialogTitle").text(RdDRoll._getTitle(rollData));
|
||||||
|
$(".table-resolution").remove();
|
||||||
|
$("#resolutionTable").append(RdDResolutionTable.buildHTMLTableExtract(caracValue, rollLevel));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup everything onload
|
||||||
|
$(function () {
|
||||||
|
// Update html, according to data
|
||||||
|
if (rollData.competence) {
|
||||||
|
// Set the default carac from the competence item
|
||||||
|
rollData.selectedCarac = rollData.carac[rollData.competence.data.defaut_carac];
|
||||||
|
$("#carac").val(rollData.competence.data.defaut_carac);
|
||||||
|
}
|
||||||
|
RdDItemSort.setCoutReveReel(rollData.selectedSort);
|
||||||
|
$("#diffLibre").val(Misc.toInt(rollData.diffLibre));
|
||||||
|
$("#diffConditions").val(Misc.toInt(rollData.diffConditions));
|
||||||
|
updateRollResult(rollData);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Update !
|
||||||
|
html.find('#diffLibre').change((event) => {
|
||||||
|
rollData.diffLibre = Misc.toInt(event.currentTarget.value); // Update the selected bonus/malus
|
||||||
|
//console.log("RdDRollSelectDialog","BM CLICKED !!!", rollData);
|
||||||
|
updateRollResult(rollData);
|
||||||
|
});
|
||||||
|
html.find('#diffConditions').change((event) => {
|
||||||
|
rollData.diffConditions = Misc.toInt(event.currentTarget.value); // Update the selected bonus/malus
|
||||||
|
//console.log("RdDRollSelectDialog","BM CLICKED !!!", rollData);
|
||||||
|
updateRollResult(rollData);
|
||||||
|
});
|
||||||
|
html.find('#carac').change((event) => {
|
||||||
|
let caracKey = event.currentTarget.value;
|
||||||
|
this.rollData.selectedCarac = rollData.carac[caracKey]; // Update the selectedCarac
|
||||||
|
//console.log("RdDRollSelectDialog","CARAC CLICKED !!!", rollData);
|
||||||
|
updateRollResult(rollData);
|
||||||
|
});
|
||||||
|
html.find('#draconic').change((event) => {
|
||||||
|
let draconicKey = Misc.toInt(event.currentTarget.value);
|
||||||
|
this.rollData.selectedDraconic = rollData.draconicList[draconicKey]; // Update the selectedCarac
|
||||||
|
//console.log("RdDRollSelectDialog","CARAC CLICKED !!!", rollData);
|
||||||
|
updateRollResult(rollData);
|
||||||
|
});
|
||||||
|
html.find('#sort').change((event) => {
|
||||||
|
let sortKey = Misc.toInt(event.currentTarget.value);
|
||||||
|
this.rollData.selectedSort = rollData.sortList[sortKey]; // Update the selectedCarac
|
||||||
|
RdDItemSort.setCoutReveReel(rollData.selectedSort);
|
||||||
|
//console.log("RdDRollSelectDialog - Sort selection", rollData.selectedSort);
|
||||||
|
updateRollResult(rollData);
|
||||||
|
});
|
||||||
|
html.find('#ptreve-variable').change((event) => {
|
||||||
|
let ptreve = Misc.toInt(event.currentTarget.value);
|
||||||
|
this.rollData.selectedSort.data.ptreve_reel = ptreve;
|
||||||
|
console.log("RdDRollSelectDialog - Cout reve", ptreve);
|
||||||
|
updateRollResult(rollData);
|
||||||
|
});
|
||||||
|
html.find('#ptreve-variable').change((event) => {
|
||||||
|
let ptreve = Misc.toInt(event.currentTarget.value);
|
||||||
|
this.rollData.selectedSort.data.ptreve_reel = ptreve; // Update the selectedCarac
|
||||||
|
console.log("RdDRollSelectDialog - Cout reve", ptreve);
|
||||||
|
updateRollResult(rollData);
|
||||||
|
});
|
||||||
|
html.find('#coupsNonMortels').change((event) => {
|
||||||
|
this.rollData.mortalite = event.currentTarget.checked ? "non-mortel" : "non-mortel";
|
||||||
|
});
|
||||||
|
html.find('#surencMalusApply').change((event) => {
|
||||||
|
this.rollData.surencMalusApply = event.currentTarget.checked;
|
||||||
|
updateRollResult(rollData);
|
||||||
|
});
|
||||||
|
html.find('#useEncForNatation').change((event) => {
|
||||||
|
this.rollData.useEncForNatation = event.currentTarget.checked;
|
||||||
|
updateRollResult(rollData);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static _isIgnoreEtatGeneral(rollData) {
|
||||||
|
return rollData.selectedCarac.ignoreEtatGeneral;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
static _computeFinalLevel(rollData) {
|
||||||
|
const etat = RdDRoll._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);
|
||||||
|
let malusEncNatation = (rollData.useEncForNatation) ? -rollData.encValueForNatation : 0;
|
||||||
|
|
||||||
|
// Gestion malus armure
|
||||||
|
let malusArmureValue = 0;
|
||||||
|
if (rollData.malusArmureValue != 0 && (rollData.selectedCarac.label == "Agilité" || rollData.selectedCarac.label == "Dérobée")) {
|
||||||
|
$("#addon-message").text("Malus armure appliqué : " + rollData.malusArmureValue);
|
||||||
|
malusArmureValue = rollData.malusArmureValue;
|
||||||
|
} else {
|
||||||
|
$("#addon-message").text("");
|
||||||
|
}
|
||||||
|
|
||||||
|
let diffCompetence = 0;
|
||||||
|
if (rollData.competence) {
|
||||||
|
diffCompetence = Misc.toInt(rollData.competence.data.niveau);
|
||||||
|
}
|
||||||
|
else if (rollData.draconicList) {
|
||||||
|
diffCompetence = Misc.toInt(rollData.selectedDraconic.data.niveau);
|
||||||
|
diffLibre = RdDItemSort.getDifficulte(rollData.selectedSort, diffLibre);
|
||||||
|
}
|
||||||
|
|
||||||
|
return etat + diffCompetence + diffLibre + diffConditions + malusEnc + malusEncNatation + malusArmureValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
static _getTitle(rollData) {
|
||||||
|
if (rollData.competence) {
|
||||||
|
// If a weapon is there, add it in the title
|
||||||
|
let armeTitle = (rollData.arme) ? " (" + rollData.arme.name + ") " : "";
|
||||||
|
let niveau = Misc.toSignedString(rollData.competence.data.niveau);
|
||||||
|
return rollData.selectedCarac.label + "/" + rollData.competence.name + armeTitle + " " + niveau
|
||||||
|
}
|
||||||
|
if (rollData.draconicList) {
|
||||||
|
return rollData.selectedDraconic.name + " - " + rollData.selectedSort.name;
|
||||||
|
}
|
||||||
|
return rollData.selectedCarac.label;
|
||||||
|
}
|
||||||
|
}
|
@ -2,7 +2,7 @@
|
|||||||
"name": "foundryvtt-reve-de-dragon",
|
"name": "foundryvtt-reve-de-dragon",
|
||||||
"title": "Rêve de Dragon",
|
"title": "Rêve de Dragon",
|
||||||
"description": "Rêve de Dragon RPG for FoundryVTT",
|
"description": "Rêve de Dragon RPG for FoundryVTT",
|
||||||
"version": "1.1.0",
|
"version": "1.1.1",
|
||||||
"minimumCoreVersion": "0.7.5",
|
"minimumCoreVersion": "0.7.5",
|
||||||
"compatibleCoreVersion": "0.7.7",
|
"compatibleCoreVersion": "0.7.7",
|
||||||
"templateVersion": 56,
|
"templateVersion": 56,
|
||||||
|
@ -7,9 +7,7 @@
|
|||||||
<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 class="flexrow">
|
<div class="flexrow">
|
||||||
<div class="flexrow">
|
<div class="flexrow">
|
||||||
<div class="flex-group-center">Blessures légères : {{data.nbLegeres}}</div>
|
<span>{{data.blessures.resume}}</span>
|
||||||
<div class="flex-group-center">Blessures graves : {{data.nbGraves}}</div>
|
|
||||||
<div class="flex-group-center">Blessure critique : {{data.nbCritiques}}</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -7,9 +7,7 @@
|
|||||||
<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 class="flexrow">
|
<div class="flexrow">
|
||||||
<div class="flexrow">
|
<div class="flexrow">
|
||||||
<div class="flex-group-center">Blessures légères : {{data.nbLegeres}}</div>
|
<span>{{data.blessures.resume}}</span>
|
||||||
<div class="flex-group-center">Blessures graves : {{data.nbGraves}}</div>
|
|
||||||
<div class="flex-group-center">Blessure critique : {{data.nbCritiques}}</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -70,22 +70,11 @@
|
|||||||
<span class="tooltip">Malus de fatigue : {{data.fatigue.malus}}
|
<span class="tooltip">Malus de fatigue : {{data.fatigue.malus}}
|
||||||
<span class="tooltiptext">{{{data.fatigue.html}}}</span>
|
<span class="tooltiptext">{{{data.fatigue.html}}}</span>
|
||||||
</span>
|
</span>
|
||||||
<span>
|
<span>{{data.blessures.resume}}</span>
|
||||||
{{#if data.nbLegeres}}
|
<span>{{data.compteurs.etat.label}}: {{data.compteurs.etat.value}}</span>
|
||||||
Blessures: {{data.nbLegeres}} légères
|
</div>
|
||||||
{{#if data.nbGraves}}, {{data.nbGraves}} graves{{/if}}
|
<div class="flexrow">
|
||||||
{{#if data.nbCritiques}}, une CRITIQUE !{{/if}}
|
<span>{{data.compteurs.surenc.label}}: {{data.compteurs.surenc.value}}</span>
|
||||||
{{else}}
|
|
||||||
{{#if data.nbGraves}}
|
|
||||||
Blessures:{{data.nbGraves}} graves
|
|
||||||
{{#if data.nbCritiques}}et une CRITIQUE !{{data.nbCritiques}}{{/if}}
|
|
||||||
{{else}}
|
|
||||||
{{#if data.nbCritiques}}une CRITIQUE !{{data.nbCritiques}}
|
|
||||||
{{else}}Aucune blessure
|
|
||||||
{{/if}}
|
|
||||||
{{/if}}
|
|
||||||
{{/if}}
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -135,16 +124,33 @@
|
|||||||
<div class="flex-group-left flexcol" >
|
<div class="flex-group-left flexcol" >
|
||||||
<ul class="carac-list">
|
<ul class="carac-list">
|
||||||
{{#each data.attributs as |attr key|}}
|
{{#each data.attributs as |attr key|}}
|
||||||
<li class="competence flexrow" data-attribute="{{key}}">
|
<li class="competence flexrow list-item" data-attribute="{{key}}">
|
||||||
<span class="competence-label flexrow" name="data.attributs.{{key}}.label">{{attr.label}} : {{attr.value}}</span>
|
<span class="competence-label flexrow" name="data.attributs.{{key}}.label">{{attr.label}} : {{attr.value}}</span>
|
||||||
</li>
|
</li>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
{{#each data.sante as |point key|}}
|
</ul>
|
||||||
<li class="competence flexrow" data-attribute="{{key}}">
|
<ul class="carac-list alterne-list">
|
||||||
<span class="competence-label flexrow" name="data.attributs.{{key}}.label">{{point.label}} : {{point.value}} / {{point.max}}</span>
|
<li class="competence flexrow list-item">
|
||||||
|
<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>
|
</li>
|
||||||
|
{{#each data.compteurs as |compteur key|}}
|
||||||
|
{{#if compteur.isChance}}
|
||||||
|
{{else if compteur.isInput}}
|
||||||
|
<li class="competence flexrow list-item">
|
||||||
|
<span class="generic-label">{{compteur.label}}</span>
|
||||||
|
<input class="compteur-edit" id="{{key}}-edit" type="text" name="{{key}}" value="{{compteur.value}}" data-dtype="number"/>
|
||||||
|
{{#if compteur.isStress}}
|
||||||
|
<a class="item-control stress-test" id="stress-test" title="Transformer">Transformer</a>
|
||||||
|
{{else}}
|
||||||
|
<label></label>
|
||||||
|
{{/if}}
|
||||||
|
</li>
|
||||||
|
{{/if}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</ul>
|
</ul>
|
||||||
|
<ul class="carac-list"></ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -336,26 +342,6 @@
|
|||||||
|
|
||||||
{{!-- Compteurs/Blessures Tab --}}
|
{{!-- Compteurs/Blessures Tab --}}
|
||||||
<div class="tab blessurescompteurs" data-group="primary" data-tab="blessurescompteurs">
|
<div class="tab blessurescompteurs" data-group="primary" data-tab="blessurescompteurs">
|
||||||
<div class="flex-group-left">
|
|
||||||
<ul class="item-list flexrow">
|
|
||||||
{{#each data.compteurs as |compteur key|}}
|
|
||||||
<li class="item list-item">
|
|
||||||
<span class="competence-label">{{compteur.label}}</span>
|
|
||||||
{{#if compteur.isInput}}
|
|
||||||
<input class="stress-value stress-style compteur-edit" id="{{key}}-edit" type="text" name="{{key}}" value="{{compteur.value}}" data-dtype="number"/>
|
|
||||||
{{#if compteur.isStress}}
|
|
||||||
<a class="item-control stress-test" id="stress-test" title="Faire un jet de Stress">Faire un jet de Stress</a>
|
|
||||||
{{else}}
|
|
||||||
<label></label>
|
|
||||||
{{/if}}
|
|
||||||
<label></label>
|
|
||||||
{{else}}
|
|
||||||
<span class="competence-label">{{compteur.value}}</span>
|
|
||||||
{{/if}}
|
|
||||||
</li>
|
|
||||||
{{/each}}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
{{!-- Liste de blessures --}}
|
{{!-- Liste de blessures --}}
|
||||||
<div class="flex-group-left flexcol competence-column">
|
<div class="flex-group-left flexcol competence-column">
|
||||||
<h3 class="blessures-title">Blessures Légeres :</h3>
|
<h3 class="blessures-title">Blessures Légeres :</h3>
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
{{/if}}
|
{{/if}}
|
||||||
{{>"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-natation.html"}}
|
||||||
<div class="form-group">
|
<div class="form-group etat-general">
|
||||||
<label for="categorie">Etat général</label><label>{{numberFormat etat decimals=0 sign=true}}</label>
|
<label for="categorie">Etat général</label><label>{{numberFormat etat decimals=0 sign=true}}</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
{{>"systems/foundryvtt-reve-de-dragon/templates/dialog-roll-surenc.html"}}
|
{{>"systems/foundryvtt-reve-de-dragon/templates/dialog-roll-surenc.html"}}
|
||||||
<div class="form-group">
|
<div class="form-group etat-general">
|
||||||
<label for="categorie">Etat général</label><label>{{numberFormat etat decimals=0 sign=true}}</label>
|
<label for="categorie">Etat général</label><label>{{numberFormat etat decimals=0 sign=true}}</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
@ -59,7 +59,7 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group etat-general">
|
||||||
<label for="categorie">Etat général</label><label>{{numberFormat etat decimals=0 sign=true}}</label>
|
<label for="categorie">Etat général</label><label>{{numberFormat etat decimals=0 sign=true}}</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
Loading…
Reference in New Issue
Block a user