Merge branch 'fix-esquive' into 'dev_1.1'
Fix esquive See merge request LeRatierBretonnien/foundryvtt-reve-de-dragon!86
This commit is contained in:
commit
6b0ace3619
@ -296,7 +296,7 @@ export class RdDCombat {
|
||||
message += "<br><a class='chat-card-button' id='parer-button' data-attackerId='" + this.attackerId + "' data-defenderTokenId='" + this.defenderTokenId + "'>Parer à mains nues</a>";
|
||||
}
|
||||
// esquive
|
||||
if (rollData.competence.data.categorie == 'melee' || rollData.competence.data.categorie == "lancer" || rollData.competence.data.categorie == 'competencecreature') {
|
||||
if (rollData.competence.data.categorie != 'tir') {
|
||||
message += "<br><a class='chat-card-button' id='esquiver-button' data-attackerId='" + this.attackerId + "' data-defenderTokenId='" + this.defenderTokenId + "'>Esquiver</a>";
|
||||
}
|
||||
}
|
||||
|
125
module/rdd-roll-resolution.js
Normal file
125
module/rdd-roll-resolution.js
Normal file
@ -0,0 +1,125 @@
|
||||
import { ChatUtility } from "./chat-utility.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 RdDRollResolution extends Dialog {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async open() {
|
||||
let rollData = RdDRollResolution._prepareDefaultOptions();
|
||||
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-resolution.html', rollData);
|
||||
const dialog = new RdDRollResolution(rollData, html);
|
||||
dialog.render(true);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static _prepareDefaultOptions() {
|
||||
let rollData = {
|
||||
ajustementsConditions: CONFIG.RDD.ajustementsConditions,
|
||||
difficultesLibres: CONFIG.RDD.difficultesLibres,
|
||||
etat: 0,
|
||||
moral: 0,
|
||||
carac: {},
|
||||
finalLevel: 0,
|
||||
diffConditions: 0,
|
||||
diffLibre: 0
|
||||
}
|
||||
for (let i = 1; i < 21; i++) {
|
||||
rollData.carac[i] = { type: "number", value: i, label: i }
|
||||
}
|
||||
rollData.selectedCarac = rollData.carac[10];
|
||||
return rollData;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
constructor(rollData, html) {
|
||||
|
||||
let conf = {
|
||||
title: 'Lancer les dés',
|
||||
content: html,
|
||||
buttons: {
|
||||
'lancer': { label: 'Lancer les dés', callback: html => this.onAction(html) }
|
||||
}
|
||||
};
|
||||
super(conf, { classes: ["rdddialog"], width: 800, height: 800, 'z-index': 99999 });
|
||||
|
||||
this.rollData = rollData;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async onAction(html) {
|
||||
await RdDResolutionTable.rollData(this.rollData);
|
||||
console.log("RdDRollResolution -=>", this.rollData, this.rollData.rolled);
|
||||
const message = {
|
||||
content: "Table de résolution: " + RdDResolutionTable.explainRollData(this.rollData)
|
||||
};
|
||||
ChatUtility.chatWithRollMode(message, game.user.name)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
|
||||
this.bringToTop();
|
||||
|
||||
var rollData = this.rollData;
|
||||
var dialog = this;
|
||||
|
||||
function updateRollResult(rollData) {
|
||||
rollData.caracValue = parseInt(rollData.selectedCarac.value)
|
||||
rollData.finalLevel = dialog._computeFinalLevel(rollData);
|
||||
|
||||
// Mise à jour valeurs
|
||||
$("#carac").val(rollData.caracValue);
|
||||
$("#roll-param").text(rollData.selectedCarac.value + " / " + Misc.toSignedString(rollData.finalLevel));
|
||||
$(".table-resolution").remove();
|
||||
$("#resolutionTable").append(RdDResolutionTable.buildHTMLTable(rollData.caracValue, rollData.finalLevel, 1, 20, -10, 10));
|
||||
$(".span-valeur").remove();
|
||||
$("#resolutionValeurs").append(RdDResolutionTable.buildHTMLResults(rollData.caracValue, rollData.finalLevel));
|
||||
}
|
||||
|
||||
// Setup everything onload
|
||||
$(function () {
|
||||
$("#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);
|
||||
updateRollResult(rollData);
|
||||
});
|
||||
html.find('#diffConditions').change((event) => {
|
||||
rollData.diffConditions = Misc.toInt(event.currentTarget.value);
|
||||
updateRollResult(rollData);
|
||||
});
|
||||
html.find('#carac').change((event) => {
|
||||
let caracKey = event.currentTarget.value;
|
||||
this.rollData.selectedCarac = rollData.carac[caracKey];
|
||||
updateRollResult(rollData);
|
||||
});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_computeFinalLevel(rollData) {
|
||||
const diffConditions = Misc.toInt(rollData.diffConditions);
|
||||
const diffLibre = this._computeDiffLibre(rollData);
|
||||
|
||||
return diffLibre + diffConditions;
|
||||
}
|
||||
|
||||
_computeDiffLibre(rollData) {
|
||||
return Misc.toInt(rollData.diffLibre);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_getTitle(rollData) {
|
||||
return 'Table de résolution';
|
||||
}
|
||||
}
|
@ -17,9 +17,9 @@ export class RdDTokenHud {
|
||||
if (!token.inCombat) return;
|
||||
if (!combatant) return;
|
||||
|
||||
const hudData = { combatant: combatant, armes: RdDTokenHud.buildListeActionsCombat(combatant) };
|
||||
let armesList = RdDTokenHud.buildListeActionsCombat(combatant) ;
|
||||
const hudData = { combatant: combatant, armes: armesList };
|
||||
|
||||
let armesList = RdDUtility.buildArmeList(combatant);
|
||||
// initiative
|
||||
await RdDTokenHud._configureSubMenu(html.find('.control-icon.combat'), 'systems/foundryvtt-reve-de-dragon/templates/hud-actor-init.html', hudData,
|
||||
(event) => {
|
||||
@ -54,6 +54,7 @@ export class RdDTokenHud {
|
||||
const imgHud = hud.find('img.rdd-hud-togglebutton');
|
||||
const list = hud.find('div.rdd-hud-list');
|
||||
|
||||
hud.toggleClass('active');
|
||||
HtmlUtility._showControlWhen(list, hud.hasClass('active'));
|
||||
|
||||
imgHud.click(event => {
|
||||
|
@ -5,6 +5,7 @@ import { RdDRollTables } from "./rdd-rolltables.js";
|
||||
import { ChatUtility } from "./chat-utility.js";
|
||||
import { RdDItemCompetence } from "./item-competence.js";
|
||||
import { RdDCombat } from "./rdd-combat.js";
|
||||
import { RdDRollResolution } from "./rdd-roll-resolution.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
const level_category = {
|
||||
@ -91,7 +92,8 @@ const fatigueMarche = { "aise": { "4":1, "6":2, "8":3, "10":4, "12":6 },
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/* Static tables for commands /table */
|
||||
const table2func = { "queues": {descr: "queues : Tire une queue de Dragon", func: RdDRollTables.getQueue},
|
||||
const table2func = { "rdd": { descr: "rdd: Ouvre la table de résolution", func: RdDRollResolution.open },
|
||||
"queues": { descr: "queues: Tire une queue de Dragon", func: RdDRollTables.getQueue},
|
||||
"ombre": { descr: "ombre: Tire une Ombre de Dragon", func: RdDRollTables.getOmbre },
|
||||
"tetehr": { descr: "tetehr: Tire une Tête de Dragon pour Hauts Revants", fund: RdDRollTables.getTeteHR},
|
||||
"tete" : { descr: "tete: Tire une Tête de Dragon", func: RdDRollTables.getTete},
|
||||
@ -173,6 +175,7 @@ export class RdDUtility {
|
||||
'systems/foundryvtt-reve-de-dragon/templates/sort-tmr.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/niveau-ethylisme.html',
|
||||
// Dialogs
|
||||
'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-resolution.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/dialog-competence.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-sort.html',
|
||||
|
@ -679,7 +679,7 @@ ul, li {
|
||||
flex-direction: column;
|
||||
position: absolute;
|
||||
top: 2.75rem;
|
||||
right: -6rem;
|
||||
left: 4rem;
|
||||
}
|
||||
.control-icon.tokenhudicon {
|
||||
width: fit-content;
|
||||
|
36
templates/dialog-roll-resolution.html
Normal file
36
templates/dialog-roll-resolution.html
Normal file
@ -0,0 +1,36 @@
|
||||
<form class="resolution-roll-dialog">
|
||||
<div class="form-group">
|
||||
<label for="categorie">Caractéristique </label>
|
||||
<select name="carac" id="carac" data-dtype="String">
|
||||
{{#select carac}}
|
||||
{{#each carac as |caracitem key|}}
|
||||
<option value={{key}}>{{caracitem.label}}</option>
|
||||
{{/each}}
|
||||
{{/select}}
|
||||
</select>
|
||||
<label></label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="categorie">Difficulté libre</label>
|
||||
<select name="diffLibre" id="diffLibre" data-dtype="number">
|
||||
{{#select diffLibre}}
|
||||
{{#each difficultesLibres as |key|}}
|
||||
<option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option>
|
||||
{{/each}}
|
||||
{{/select}}
|
||||
</select>
|
||||
<label for="categorie"> Conditions</label>
|
||||
<select name="diffConditions" id="diffConditions" data-dtype="number">
|
||||
{{#select diffConditions}}
|
||||
{{#each ajustementsConditions as |key|}}
|
||||
<option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option>
|
||||
{{/each}}
|
||||
{{/select}}
|
||||
</select>
|
||||
</div>
|
||||
<div id="resolutionTable">
|
||||
</div>
|
||||
<div id="resolutionValeurs">
|
||||
</div>
|
||||
|
||||
</form>
|
Loading…
Reference in New Issue
Block a user