#63 Jet d'éthylisme

This commit is contained in:
sladecraven 2020-12-06 20:13:43 +01:00
commit bf317e54d7
15 changed files with 498 additions and 184 deletions

View File

@ -42,9 +42,8 @@ export class RdDActorCreatureSheet extends ActorSheet {
data.data.caracSum = sum;
data.data.carac.taille.isTaille = true; // To avoid button link;
data.data.nbLegeres = this.actor.countBlessures(data.data.blessures.legeres.liste );
data.data.nbGraves = this.actor.countBlessures(data.data.blessures.graves.liste );
data.data.nbCritiques = this.actor.countBlessures(data.data.blessures.critiques.liste );
data.data.blessures.resume = this.actor.computeResumeBlessure(data.data.blessures);
data.data.isGM = game.user.isGM;
data.data.competencecreature = data.itemsByType["competencecreature"];

View File

@ -41,9 +41,9 @@ export class RdDActorHumanoideSheet extends ActorSheet {
data.data.caracSum = sum;
data.data.carac.taille.isTaille = true; // To avoid button link;
data.data.nbLegeres = this.actor.countBlessures(data.data.blessures.legeres.liste );
data.data.nbGraves = this.actor.countBlessures(data.data.blessures.graves.liste );
data.data.nbCritiques = this.actor.countBlessures(data.data.blessures.critiques.liste );
data.data.carac.chance.isChance = true; // Ajouter chance actuelle et utiliser;
data.data.blessures.resume = this.actor.computeResumeBlessure(data.data.blessures);
data.data.competencecreature = data.itemsByType["competencecreature"];
data.data.isGM = game.user.isGM;

View File

@ -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,9 +91,8 @@ export class RdDActorSheet extends ActorSheet {
this.armesList = duplicate(data.data.combat);
data.data.carac.taille.isTaille = true; // To avoid button link;
data.data.nbLegeres = this.actor.countBlessures(data.data.blessures.legeres.liste );
data.data.nbGraves = this.actor.countBlessures(data.data.blessures.graves.liste );
data.data.nbCritiques = this.actor.countBlessures(data.data.blessures.critiques.liste );
data.data.compteurs.chance.isChance = true;
data.data.blessures.resume = this.actor.computeResumeBlessure(data.data.blessures);
// Mise à jour de l'encombrement total
this.actor.computeEncombrementTotalEtMalusArmure();
@ -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,14 @@ export class RdDActorSheet extends ActorSheet {
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
html.find('.competence-label a').click((event) => {
let compName = event.currentTarget.text;

View File

@ -7,6 +7,7 @@ import { RdDUtility } from "./rdd-utility.js";
import { TMRUtility } from "./tmr-utility.js";
import { RdDRollDialog } from "./rdd-roll-dialog.js";
import { RdDRollDialogEthylisme } from "./rdd-roll-ethylisme.js";
import { RdDRoll } from "./rdd-roll.js";
import { RdDTMRDialog } from "./rdd-tmr-dialog.js";
import { Misc } from "./misc.js";
@ -108,6 +109,10 @@ export class RdDActor extends Actor {
return this.data.data.reve.reve.value;
}
getChanceActuel() {
return this.data.data.compteurs.chance.value;
}
/* -------------------------------------------- */
getBestDraconic() {
const list = this.getDraconicList().sort((a, b) => b.data.niveau - a.data.niveau);
@ -271,7 +276,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;
}
@ -863,6 +868,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( )
{
@ -978,7 +1010,7 @@ export class RdDActor extends Actor {
}
/* -------------------------------------------- */
async reveActuelIncDec( value ) {
async reveActuelIncDec( value ) {
let reve = duplicate(this.data.data.reve.reve);
reve.value = Math.max(reve.value + value, 0);
await this.update( {"data.reve.reve": reve } );
@ -1285,91 +1317,150 @@ 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,
difficultesLibres: CONFIG.RDD.difficultesLibres,
etat: this.data.data.compteurs.etat.value,
finalLevel: 0,
diffConditions: 0,
diffLibre: 0,
malusArmureValue: (this.data.data.attributs) ? this.data.data.attributs.malusarmure.value : 0,
surencMalusFlag: (this.data.data.compteurs.surenc.value < 0),
surencMalusValue: this.data.data.compteurs.surenc.value,
surencMalusApply: false,
isNatation: 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);
selectedCarac: carac,
ajustementsConditions: CONFIG.RDD.ajustementsConditions,
difficultesLibres: CONFIG.RDD.difficultesLibres,
etat: this.data.data.compteurs.etat.value,
finalLevel: 0,
diffConditions: 0,
diffLibre: 0,
malusArmureValue: (this.data.data.attributs) ? this.data.data.attributs.malusarmure.value : 0,
surencMalusFlag: (this.data.data.compteurs.surenc.value < 0),
surencMalusValue: this.data.data.compteurs.surenc.value,
surencMalusApply: false,
isNatation: false,
useEncForNatation: false
}
/* -------------------------------------------- */
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") } );
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);
}
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);
async appelChance( )
{
let rollData = {
selectedCarac: this.getCaracByName('chance-actuelle'),
diffConditions: this.ajustementAstrologique()
}
/* -------------------------------------------- */
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!
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() {
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) {
let competence = RdDUtility.findCompetence( this.data.items, name);
@ -1427,7 +1518,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);
@ -1436,8 +1527,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;
@ -1447,8 +1537,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 };
@ -1488,7 +1577,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
View File

@ -0,0 +1,10 @@
export class HtmlUtility{
static _showControlWhen(control, condition) {
if (condition) {
$(control).show();
}
else {
$(control).hide();
}
}
}

View File

@ -80,24 +80,28 @@ export class RdDResolutionTable {
/* -------------------------------------------- */
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) {
message += " (" + rolled.caracValue + " à " + Misc.toSignedString(rolled.finalLevel) + ")";
message += "(" + rolled.caracValue + " à " + Misc.toSignedString(rolled.finalLevel) + ") ";
}
message += rolled.quality
return message;
}
/* -------------------------------------------- */
static updateChancesWithBonus( chances, bonus ) {
let newScore = Number(chances.score) + Number(bonus);
chances.score = newScore;
chances.sign = this._reussiteSignificative(newScore);
chances.part = this._reussitePart(newScore);
chances.epart = this._echecParticulier(newScore);
chances.etotal = this._echecTotal(newScore);
if (bonus) {
let newScore = Number(chances.score) + Number(bonus);
mergeObject(chances, this._computeCell(null, newScore), {overwrite: true});
}
}
static async rollData(rollData ) {
rollData.rolled = await this.roll(rollData.caracValue, rollData.finalLevel, rollData.bonus);
return rollData;
}
/* -------------------------------------------- */
static async roll(caracValue, finalLevel, bonus = 0 ) {
let chances = this.computeChances(caracValue, finalLevel);

View File

@ -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";
@ -71,20 +72,13 @@ export class RdDRollDialog extends Dialog {
rollData.finalLevel = rollLevel;
rollData.caracValue = caracValue
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
@ -167,9 +161,13 @@ export class RdDRollDialog extends Dialog {
});
}
static _isIgnoreEtatGeneral(rollData) {
return rollData.selectedCarac.ignoreEtatGeneral;
}
/* -------------------------------------------- */
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);
let malusEnc = (rollData.surencMalusApply ) ? rollData.surencMalusValue : 0;
let diffLibre = Misc.toInt(rollData.diffLibre);

230
module/rdd-roll.js Normal file
View 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;
}
}

View File

@ -2,7 +2,7 @@
"name": "foundryvtt-reve-de-dragon",
"title": "Rêve de Dragon",
"description": "Rêve de Dragon RPG for FoundryVTT",
"version": "1.1.0",
"version": "1.1.1",
"minimumCoreVersion": "0.7.5",
"compatibleCoreVersion": "0.7.7",
"templateVersion": 58,

View File

@ -7,9 +7,7 @@
<h1 class="charname"><input name="name" type="text" value="{{actor.name}}" placeholder="Name" /></h1>
<div class="flexrow">
<div class="flexrow">
<div class="flex-group-center">Blessures légères : {{data.nbLegeres}}</div>
<div class="flex-group-center">Blessures graves : {{data.nbGraves}}</div>
<div class="flex-group-center">Blessure critique : {{data.nbCritiques}}</div>
<span>{{data.blessures.resume}}</span>
</div>
</div>
</div>

View File

@ -7,9 +7,7 @@
<h1 class="charname"><input name="name" type="text" value="{{actor.name}}" placeholder="Name" /></h1>
<div class="flexrow">
<div class="flexrow">
<div class="flex-group-center">Blessures légères : {{data.nbLegeres}}</div>
<div class="flex-group-center">Blessures graves : {{data.nbGraves}}</div>
<div class="flex-group-center">Blessure critique : {{data.nbCritiques}}</div>
<span>{{data.blessures.resume}}</span>
</div>
</div>
</div>

View File

@ -70,22 +70,11 @@
<span class="tooltip">Malus de fatigue : {{data.fatigue.malus}}
<span class="tooltiptext">{{{data.fatigue.html}}}</span>
</span>
<span>
{{#if data.nbLegeres}}
Blessures: {{data.nbLegeres}} légères
{{#if data.nbGraves}}, {{data.nbGraves}} graves{{/if}}
{{#if data.nbCritiques}}, une CRITIQUE !{{/if}}
{{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>
<span>{{data.blessures.resume}}</span>
<span>{{data.compteurs.etat.label}}: {{data.compteurs.etat.value}}</span>
</div>
<div class="flexrow">
<span>{{data.compteurs.surenc.label}}: {{data.compteurs.surenc.value}}</span>
</div>
</div>
</div>
@ -118,12 +107,12 @@
{{else}}
<span class="carac-label flexrow" name="data.carac.{{key}}.label"><a name={{key}}>{{carac.label}}</a></span>
{{/if}}
{{#if carac.derivee}}
<label class="competence-value flexrow">{{carac.value}}</label>
{{else}}
<input class="carac-value flexrow" type="text" name="data.carac.{{key}}.value" value="{{carac.value}}" data-dtype="{{carac.type}}" {{#unless @root.data.editCaracComp}}disabled{{/unless}} />
<input class="competence-xp flexrow" type="text" name="data.carac.{{key}}.xp" value="{{carac.xp}}" data-dtype="number" {{#unless @root.data.editCaracComp}}disabled{{/unless}} />
{{/if}}
{{#if carac.derivee}}
<label class="competence-value flexrow">{{carac.value}}</label>
{{else}}
<input class="carac-value flexrow" type="text" name="data.carac.{{key}}.value" value="{{carac.value}}" data-dtype="{{carac.type}}" {{#unless @root.data.editCaracComp}}disabled{{/unless}} />
<input class="competence-xp flexrow" type="text" name="data.carac.{{key}}.xp" value="{{carac.xp}}" data-dtype="number" {{#unless @root.data.editCaracComp}}disabled{{/unless}} />
{{/if}}
</li>
{{/each}}
<li class="competence flexrow">
@ -135,16 +124,37 @@
<div class="flex-group-left flexcol" >
<ul class="carac-list">
{{#each data.attributs as |attr key|}}
<li class="competence flexrow" data-attribute="{{key}}">
<span class="competence-label flexrow" name="data.attributs.{{key}}.label">{{attr.label}} : {{attr.value}}</span>
</li>
{{/each}}
{{#each data.sante as |point key|}}
<li class="competence flexrow" data-attribute="{{key}}">
<span class="competence-label flexrow" name="data.attributs.{{key}}.label">{{point.label}} : {{point.value}} / {{point.max}}</span>
</li>
<li class="competence flexrow list-item" data-attribute="{{key}}">
<span class="competence-label flexrow" name="data.attributs.{{key}}.label">{{attr.label}} : {{attr.value}}</span>
</li>
{{/each}}
</ul>
<ul class="carac-list alterne-list">
<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>
{{#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}}
{{#if eq compteur.label 'Ethylisme'}}
<a class="item-control ethylisme-test" id="ethylisme-test" title="Jet d'Ethylisme">Jet d'Ethylisme</a>
{{else}}
<label></label>
{{/if}}
{{/if}}
</li>
{{/if}}
{{/each}}
</ul>
<ul class="carac-list"></ul>
</div>
</div>
</div>
@ -336,31 +346,6 @@
{{!-- Compteurs/Blessures Tab --}}
<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}}
{{#if (eq compteur.label 'Ethylisme')}}
<a class="item-control ethylisme-test" id="ethylisme-test" title="Faire un jet d'Ethylisme">Faire un jet d'Ethylisme</a>
{{else}}
<label></label>
{{/if}}
<label></label>
{{/if}}
<label></label>
{{else}}
<span class="competence-label">{{compteur.value}}</span>
{{/if}}
</li>
{{/each}}
</ul>
</div>
{{!-- Liste de blessures --}}
<div class="flex-group-left flexcol competence-column">
<h3 class="blessures-title">Blessures Légeres :</h3>

View File

@ -45,7 +45,7 @@
{{/if}}
{{>"systems/foundryvtt-reve-de-dragon/templates/dialog-roll-surenc.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>
</div>
<div class="form-group">

View File

@ -19,7 +19,7 @@
</select>
</div>
{{>"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>
</div>
<div class="form-group">

View File

@ -59,7 +59,7 @@
</select>
</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>
</div>
<div class="form-group">