Passage au gestionaire de combat
This commit is contained in:
parent
537cc005ad
commit
b6d3359625
121
module/actor.js
121
module/actor.js
@ -1,11 +1,5 @@
|
|||||||
/**
|
|
||||||
* Extend the base Actor entity by defining a custom roll data structure which is ideal for the Simple system.
|
|
||||||
* @extends {Actor}
|
|
||||||
*/
|
|
||||||
|
|
||||||
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 { RdDRollDialogEthylisme } from "./rdd-roll-ethylisme.js";
|
import { RdDRollDialogEthylisme } from "./rdd-roll-ethylisme.js";
|
||||||
import { RdDRoll } from "./rdd-roll.js";
|
import { RdDRoll } from "./rdd-roll.js";
|
||||||
import { RdDTMRDialog } from "./rdd-tmr-dialog.js";
|
import { RdDTMRDialog } from "./rdd-tmr-dialog.js";
|
||||||
@ -20,6 +14,10 @@ import { Grammar } from "./grammar.js";
|
|||||||
import { RdDItemArme } from "./item-arme.js";
|
import { RdDItemArme } from "./item-arme.js";
|
||||||
import { RdDCombat } from "./rdd-combat.js";
|
import { RdDCombat } from "./rdd-combat.js";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extend the base Actor entity by defining a custom roll data structure which is ideal for the Simple system.
|
||||||
|
* @extends {Actor}
|
||||||
|
*/
|
||||||
export class RdDActor extends Actor {
|
export class RdDActor extends Actor {
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -110,6 +108,7 @@ export class RdDActor extends Actor {
|
|||||||
isCreature() {
|
isCreature() {
|
||||||
return this.data.type == 'creature' || this.data.type == 'entite';
|
return this.data.type == 'creature' || this.data.type == 'entite';
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
getReveActuel() {
|
getReveActuel() {
|
||||||
return this.data.data.reve.reve.value;
|
return this.data.data.reve.reve.value;
|
||||||
@ -128,9 +127,17 @@ export class RdDActor extends Actor {
|
|||||||
getBonusDegat() {
|
getBonusDegat() {
|
||||||
return Misc.toInt(this.data.data.attributs.plusdom.value);
|
return Misc.toInt(this.data.data.attributs.plusdom.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
getProtectionNaturelle() {
|
getProtectionNaturelle() {
|
||||||
return Misc.toInt(this.data.data.attributs.protection.value);
|
return Misc.toInt(this.data.data.attributs.protection.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
getCompetenceList() {
|
||||||
|
return this.data.items.filter( (item) => item.type == 'competence');
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
getCompetence(compName) {
|
getCompetence(compName) {
|
||||||
return RdDUtility.findCompetence(this.data.items, compName);
|
return RdDUtility.findCompetence(this.data.items, compName);
|
||||||
@ -145,6 +152,7 @@ export class RdDActor extends Actor {
|
|||||||
return duplicate(list[0]);
|
return duplicate(list[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async deleteSortReserve(coordTMR) {
|
async deleteSortReserve(coordTMR) {
|
||||||
let reserve = duplicate(this.data.data.reve.reserve);
|
let reserve = duplicate(this.data.data.reve.reserve);
|
||||||
@ -1426,11 +1434,6 @@ export class RdDActor extends Actor {
|
|||||||
ChatUtility.chatWithRollMode(chatOptions, this.name)
|
ChatUtility.chatWithRollMode(chatOptions, this.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
getCompetenceList() {
|
|
||||||
return this.data.items.filter( (item) => item.type == 'competence');
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async rollCarac( caracName ) {
|
async rollCarac( caracName ) {
|
||||||
let rollData = {
|
let rollData = {
|
||||||
@ -1775,7 +1778,8 @@ export class RdDActor extends Actor {
|
|||||||
async rollCompetenceCreature( compName ) {
|
async rollCompetenceCreature( compName ) {
|
||||||
let competence = this.getCompetence(compName);
|
let competence = this.getCompetence(compName);
|
||||||
if ( competence.type == 'competencecreature' && competence.data.iscombat ) {
|
if ( competence.type == 'competencecreature' && competence.data.iscombat ) {
|
||||||
this.rollCompetenceCombat(competence, armeItem);
|
let competence = this.getCompetence(compName);
|
||||||
|
RdDCombat.createUsingTarget(this).attaque(competence, armeItem);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.rollCompetence(name);
|
this.rollCompetence(name);
|
||||||
@ -1790,84 +1794,12 @@ export class RdDActor extends Actor {
|
|||||||
let competence = this.getCompetence(compName == undefined? armeName : compName);
|
let competence = this.getCompetence(compName == undefined? armeName : compName);
|
||||||
|
|
||||||
if (armeItem || armeName || (competence.type == 'competencecreature' && competence.data.iscombat)) {
|
if (armeItem || armeName || (competence.type == 'competencecreature' && competence.data.iscombat)) {
|
||||||
this.rollCompetenceCombat( compName, armeItem );
|
RdDCombat.createUsingTarget(this).attaque(competence, armeItem);
|
||||||
} else {
|
} else {
|
||||||
this.rollCompetence( competence.name );
|
this.rollCompetence( competence.name );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
async rollCompetenceCombat( compName, armeItem=undefined, attackerRoll=undefined, attacker = undefined) {
|
|
||||||
let competence = this.getCompetence(compName);
|
|
||||||
|
|
||||||
if (RdDCombat.isActive()) {
|
|
||||||
const assaut = RdDCombat.createUsingTarget(this);
|
|
||||||
assaut.attaque(competence, armeItem);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( competence.type == 'competencecreature' && competence.data.iscombat ) {
|
|
||||||
armeItem = { name: compName, data: { dommages: competence.data.dommages, dommagesReels: competence.data.dommages} };
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log("rollCompetenceCombat !!!", competence, armeItem, attackerRoll);
|
|
||||||
// Common rollData values
|
|
||||||
let rollData = {
|
|
||||||
ajustementsConditions: CONFIG.RDD.ajustementsConditions,
|
|
||||||
difficultesLibres: CONFIG.RDD.difficultesLibres,
|
|
||||||
etat: this.data.data.compteurs.etat.value,
|
|
||||||
diffConditions: 0,
|
|
||||||
forceValue : attackerRoll ? this.getForceValue() : 0, // Utilisé pour le jet de recul
|
|
||||||
diffLibre: (attackerRoll) ? attackerRoll.diffLibre : 0,
|
|
||||||
attackerRoll: attackerRoll,
|
|
||||||
editLibre: true,
|
|
||||||
editConditions: true,
|
|
||||||
finalLevel: 0,
|
|
||||||
coupsNonMortels: false,
|
|
||||||
malusArmureValue: 0,
|
|
||||||
surencMalusFlag: false,
|
|
||||||
surencMalusValue: 0,
|
|
||||||
surencMalusApply: false,
|
|
||||||
isNatation: false,
|
|
||||||
useEncForNatation: false,
|
|
||||||
encValueForNatation: 0
|
|
||||||
}
|
|
||||||
if ( this.type == 'personnage ') {
|
|
||||||
rollData.malusArmureValue = (this.data.data.attributs && this.data.data.attributs.malusarmure) ? this.data.data.attributs.malusarmure.value : 0,
|
|
||||||
rollData.surencMalusFlag = (this.data.data.compteurs.surenc.value < 0);
|
|
||||||
rollData.surencMalusValue = this.data.data.compteurs.surenc.value;
|
|
||||||
rollData.surencMalusApply = false;
|
|
||||||
rollData.isNatation = compName.toLowerCase().includes("natation");
|
|
||||||
rollData.useEncForNatation = false;
|
|
||||||
rollData.encValueForNatation = (this.encombrementTotal) ? Math.round(this.encombrementTotal) : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( competence.type == 'competencecreature') { // Specific case for Creatures
|
|
||||||
competence.data.defaut_carac = "carac_creature"; // Fake default competence
|
|
||||||
competence.data.categorie = "creature"; // Fake default competence
|
|
||||||
rollData.competence = competence;
|
|
||||||
rollData.arme = armeItem;
|
|
||||||
rollData.carac = { carac_creature: { label: compName, value: competence.data.carac_value } };
|
|
||||||
} else { // Usual competence
|
|
||||||
rollData.competence = competence;
|
|
||||||
if (armeItem) {
|
|
||||||
armeItem = RdDItemArme.armeUneOuDeuxMains(armeItem, compName.toLowerCase().includes("1 main"));
|
|
||||||
}
|
|
||||||
rollData.arme = armeItem;
|
|
||||||
rollData.carac = this.data.data.carac;
|
|
||||||
}
|
|
||||||
|
|
||||||
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')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
new RdDRollDialog("arme", html, rollData, this, attacker).render(true);
|
|
||||||
} else {
|
|
||||||
new RdDRollDialog("competence", html, rollData, this, attacker).render(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_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) {
|
||||||
@ -1965,29 +1897,10 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
parerAttaque( attackerRoll, armeId, attacker = undefined )
|
|
||||||
{
|
|
||||||
let armeItem = this.getOwnedItem(armeId); // Item.data.data !
|
|
||||||
console.log("Going to PARY !!!!!!!!!", armeItem, attackerRoll.diffLibre);
|
|
||||||
if (armeItem.type == 'competencecreature') {
|
|
||||||
this.rollCompetenceCombat( armeItem.name, armeItem.data, attackerRoll, attacker);
|
|
||||||
} else {
|
|
||||||
this.rollCompetenceCombat( armeItem.data.data.competence, armeItem.data, attackerRoll, attacker);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
esquiverAttaque( attackerRoll, attacker = undefined )
|
|
||||||
{
|
|
||||||
this.rollCompetenceCombat( "esquive", undefined, attackerRoll, attacker );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
/** @override */
|
/** @override */
|
||||||
getRollData() {
|
getRollData() {
|
||||||
const data = super.getRollData();
|
const data = super.getRollData();
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import { RdDUtility } from "./rdd-utility.js";
|
|||||||
export class RdDCombat {
|
export class RdDCombat {
|
||||||
|
|
||||||
static isActive() {
|
static isActive() {
|
||||||
return game.settings.get("foundryvtt-reve-de-dragon", "moteur-combat") == 'experimental';
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -70,9 +70,6 @@ export class RdDCombat {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async onEvent(button, event) {
|
async onEvent(button, event) {
|
||||||
if (!RdDCombat.isActive()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let rollData = game.system.rdd.rollDataHandler[this.attackerId];
|
let rollData = game.system.rdd.rollDataHandler[this.attackerId];
|
||||||
if (!rollData) {
|
if (!rollData) {
|
||||||
ui.notifications.warn("Action automatisée impossible, le jet de l'attaquant a été perdu (suite à un raffraichissement?)")
|
ui.notifications.warn("Action automatisée impossible, le jet de l'attaquant a été perdu (suite à un raffraichissement?)")
|
||||||
|
@ -145,19 +145,6 @@ Hooks.once("init", async function() {
|
|||||||
type: Object
|
type: Object
|
||||||
});
|
});
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
game.settings.register("foundryvtt-reve-de-dragon", "moteur-combat", {
|
|
||||||
name: "Utiliser le moteur de combat",
|
|
||||||
scope: "world",
|
|
||||||
config: true,
|
|
||||||
type: String,
|
|
||||||
choices: { // If choices are defined, the resulting setting will be a select menu
|
|
||||||
"standard": "Standard",
|
|
||||||
"experimental": "Expérimental"
|
|
||||||
},
|
|
||||||
default: "experimental"
|
|
||||||
});
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
game.settings.register("foundryvtt-reve-de-dragon", "dice-so-nice", {
|
game.settings.register("foundryvtt-reve-de-dragon", "dice-so-nice", {
|
||||||
name: "Montrer les dés pour toutes les jets",
|
name: "Montrer les dés pour toutes les jets",
|
||||||
|
@ -1,215 +0,0 @@
|
|||||||
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 by defining a custom window to perform roll.
|
|
||||||
* @extends {Dialog}
|
|
||||||
*/
|
|
||||||
export class RdDRollDialog extends Dialog {
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
constructor(mode, html, rollData, actor, attacker = undefined) {
|
|
||||||
|
|
||||||
let myButtons
|
|
||||||
if (mode == "sort") {
|
|
||||||
myButtons = {
|
|
||||||
rollButton: { label: "Lancer le sort", callback: html => this.performRollSort(html, false) },
|
|
||||||
reserveButton: { label: "Mettre en reserve", callback: html => this.performRollSort(html, true) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
myButtons = {
|
|
||||||
rollButton: { label: "Lancer", callback: html => this.actor.performRoll(this.rollData) }
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Common conf
|
|
||||||
let dialogConf = { content: html, title: "Test", buttons: myButtons, default: "rollButton" }
|
|
||||||
let dialogOptions = { classes: ["rdddialog"], width: 600, height: 460, 'z-index': 99999 }
|
|
||||||
|
|
||||||
// Select proper roll dialog template and stuff
|
|
||||||
if (mode == "competence") {
|
|
||||||
dialogConf.title = "Test de compétence"
|
|
||||||
dialogOptions.height = 430
|
|
||||||
ui.notifications.warn("RdDRollDialog - Plus utilisé pour les compétences")
|
|
||||||
|
|
||||||
} else if (mode == "arme") {
|
|
||||||
dialogConf.title = "Test de combat/arme"
|
|
||||||
dialogOptions.height = 460
|
|
||||||
} else if (mode == "carac") {
|
|
||||||
ui.notifications.warn("RdDRollDialog - Plus utilisé pour les caractéristiques")
|
|
||||||
dialogConf.title = "Test de caractéristique"
|
|
||||||
dialogOptions.height = 420
|
|
||||||
} else if (mode == "sort") {
|
|
||||||
ui.notifications.warn("RdDRollDialog - Plus utilisé pour les sorts")
|
|
||||||
dialogConf.title = "Lancer un sort"
|
|
||||||
dialogOptions.height = 460
|
|
||||||
}
|
|
||||||
super(dialogConf, dialogOptions)
|
|
||||||
|
|
||||||
this.mode = mode;
|
|
||||||
this.rollData = rollData;
|
|
||||||
this.actor = actor;
|
|
||||||
if (attacker)
|
|
||||||
this.attacker = attacker;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
performRollSort(html, isSortReserve = false) {
|
|
||||||
this.rollData.isSortReserve = isSortReserve;
|
|
||||||
this.actor.performRoll(this.rollData, this.attacker);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
activateListeners(html) {
|
|
||||||
super.activateListeners(html);
|
|
||||||
|
|
||||||
this.bringToTop(); // Ensure top level
|
|
||||||
// Get the rollData stuff
|
|
||||||
var rollData = this.rollData;
|
|
||||||
|
|
||||||
function updateRollResult(rollData) {
|
|
||||||
let caracValue = parseInt(rollData.selectedCarac.value)
|
|
||||||
let rollLevel = RdDRollDialog._computeFinalLevel(rollData);
|
|
||||||
|
|
||||||
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);
|
|
||||||
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(RdDRollDialog._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
|
|
||||||
//console.log("RdDDialogRoll", rollData.competence.data.defaut_carac, rollData.carac);
|
|
||||||
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("RdDRollDialog","BM CLICKED !!!", rollData);
|
|
||||||
updateRollResult(rollData);
|
|
||||||
});
|
|
||||||
html.find('#diffConditions').change((event) => {
|
|
||||||
rollData.diffConditions = Misc.toInt(event.currentTarget.value); // Update the selected bonus/malus
|
|
||||||
//console.log("RdDRollDialog","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("RdDRollDialog","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("RdDRollDialog","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("RdDRollDialog - 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("RdDRollDialog - 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("RdDRollDialog - Cout reve", ptreve);
|
|
||||||
updateRollResult(rollData);
|
|
||||||
});
|
|
||||||
html.find('#coupsNonMortels').change((event) => {
|
|
||||||
this.rollData.mortalite = event.currentTarget.checked ? "non-mortel" : "mortel";
|
|
||||||
});
|
|
||||||
html.find('#isCharge').change((event) => {
|
|
||||||
this.rollData.isCharge = event.currentTarget.checked;
|
|
||||||
});
|
|
||||||
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 = 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);
|
|
||||||
let malusEncNatation = (rollData.useEncForNatation) ? -rollData.encValueForNatation : 0;
|
|
||||||
let chargeBonus = (rollData.isCharge) ? 4 : 0; // gestion de la charge en mélée
|
|
||||||
|
|
||||||
// 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 + chargeBonus;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -858,56 +858,6 @@ export class RdDUtility {
|
|||||||
{
|
{
|
||||||
RdDCombat.registerChatCallbacks(html);
|
RdDCombat.registerChatCallbacks(html);
|
||||||
|
|
||||||
html.on("click", '#encaisser-button', event => {
|
|
||||||
event.preventDefault();
|
|
||||||
if (RdDCombat.isActive()) return;
|
|
||||||
let attackerId = event.currentTarget.attributes['data-attackerId'].value;
|
|
||||||
let defenderTokenId = event.currentTarget.attributes['data-defenderTokenId'].value;
|
|
||||||
if ( game.user.isGM ) { // Current user is the GM -> direct access
|
|
||||||
let rollData = game.system.rdd.rollDataHandler[attackerId];
|
|
||||||
rollData.attackerId = attackerId;
|
|
||||||
rollData.defenderTokenId = defenderTokenId;
|
|
||||||
let defenderToken = canvas.tokens.get( defenderTokenId );
|
|
||||||
defenderToken.actor.encaisserDommages( rollData, game.actors.get(attackerId));
|
|
||||||
} else { // Emit message for GM
|
|
||||||
game.socket.emit("system.foundryvtt-reve-de-dragon", {
|
|
||||||
msg: "msg_encaisser",
|
|
||||||
data: { attackerId: attackerId, defenderTokenId: defenderTokenId }
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
html.on("click", '#parer-button', event => {
|
|
||||||
event.preventDefault();
|
|
||||||
if (RdDCombat.isActive()) return;
|
|
||||||
let attackerId = event.currentTarget.attributes['data-attackerId'].value;
|
|
||||||
let defenderToken = canvas.tokens.get(event.currentTarget.attributes['data-defenderTokenId'].value );
|
|
||||||
let armeId = event.currentTarget.attributes['data-armeid'].value;
|
|
||||||
let rollData = game.system.rdd.rollDataHandler[attackerId];
|
|
||||||
defenderToken.actor.parerAttaque( rollData, armeId, game.actors.get(attackerId));
|
|
||||||
});
|
|
||||||
|
|
||||||
html.on("click", '#esquiver-button', event => {
|
|
||||||
event.preventDefault();
|
|
||||||
if (RdDCombat.isActive()) return;
|
|
||||||
let attackerId = event.currentTarget.attributes['data-attackerId'].value;
|
|
||||||
let defenderToken = canvas.tokens.get(event.currentTarget.attributes['data-defenderTokenId'].value );
|
|
||||||
let rollData = game.system.rdd.rollDataHandler[attackerId];
|
|
||||||
//console.log("Esquive !", rollData, defenderActor);
|
|
||||||
defenderToken.actor.esquiverAttaque( rollData, game.actors.get(attackerId));
|
|
||||||
});
|
|
||||||
|
|
||||||
html.on("click", '#particuliere-attaque', event => {
|
|
||||||
event.preventDefault();
|
|
||||||
if (RdDCombat.isActive()) return;
|
|
||||||
let attackerId = event.currentTarget.attributes['data-attackerId'].value;
|
|
||||||
let attackerActor = game.actors.get(event.currentTarget.attributes['data-attackerId'].value );
|
|
||||||
let rollData = game.system.rdd.rollDataHandler[attackerId];
|
|
||||||
rollData.particuliereAttaque = event.currentTarget.attributes['data-mode'].value;
|
|
||||||
//console.log("Particulère !", rollData);
|
|
||||||
attackerActor.continueRoll( rollData );
|
|
||||||
});
|
|
||||||
|
|
||||||
html.on("click", '.tmr-passeur-coord a', event => {
|
html.on("click", '.tmr-passeur-coord a', event => {
|
||||||
let coord = event.currentTarget.attributes['data-tmr-coord'].value;
|
let coord = event.currentTarget.attributes['data-tmr-coord'].value;
|
||||||
let actorId = event.currentTarget.attributes['data-actor-id'].value;
|
let actorId = event.currentTarget.attributes['data-actor-id'].value;
|
||||||
|
Loading…
Reference in New Issue
Block a user