Auto formatting

This commit is contained in:
Vincent Vandemeulebrouck 2021-01-09 19:33:19 +01:00
parent c9cc1de16e
commit e7b9070cf1
6 changed files with 740 additions and 762 deletions

File diff suppressed because it is too large Load Diff

View File

@ -152,7 +152,7 @@ export class RdDCombat {
() => this.defenseChanceuse(attackerRoll), () => this.defenseChanceuse(attackerRoll),
() => this.afficherOptionsDefense(attackerRoll, { defenseChance: true })); () => this.afficherOptionsDefense(attackerRoll, { defenseChance: true }));
case '#appel-destinee-attaque': return this.attacker.appelDestinee( case '#appel-destinee-attaque': return this.attacker.appelDestinee(
() => this.attaqueSignificative(attackerRoll), () => this.attaqueSignificative(attackerRoll),
() => { }); () => { });
case '#appel-destinee-defense': return this.defender.appelDestinee( case '#appel-destinee-defense': return this.defender.appelDestinee(
() => this.defenseDestinee(attackerRoll), () => this.defenseDestinee(attackerRoll),
@ -228,7 +228,7 @@ export class RdDCombat {
/* -------------------------------------------- */ /* -------------------------------------------- */
removeChatMessageActionsPasseArme(passeArme) { removeChatMessageActionsPasseArme(passeArme) {
if (game.settings.get("foundryvtt-reve-de-dragon", "supprimer-dialogues-combat-chat")){ if (game.settings.get("foundryvtt-reve-de-dragon", "supprimer-dialogues-combat-chat")) {
ChatUtility.removeMyChatMessageContaining(`<div data-passearme="${passeArme}">`); ChatUtility.removeMyChatMessageContaining(`<div data-passearme="${passeArme}">`);
} }
} }
@ -301,7 +301,7 @@ export class RdDCombat {
competence: competence, competence: competence,
surprise: this.attacker.getSurprise(), surprise: this.attacker.getSurprise(),
surpriseDefenseur: this.defender.getSurprise(), surpriseDefenseur: this.defender.getSurprise(),
essais: { } essais: {}
}; };
if (this.attacker.isCreature()) { if (this.attacker.isCreature()) {
@ -364,7 +364,7 @@ export class RdDCombat {
console.log("RdDCombat._sendMessageDefense", attackerRoll, essais, " / ", this.attacker, this.target, this.attackerId, attackerRoll.competence.data.categorie); console.log("RdDCombat._sendMessageDefense", attackerRoll, essais, " / ", this.attacker, this.target, this.attackerId, attackerRoll.competence.data.categorie);
this.removeChatMessageActionsPasseArme(attackerRoll.passeArme); this.removeChatMessageActionsPasseArme(attackerRoll.passeArme);
mergeObject(attackerRoll.essais, essais, {overwrite: true}); mergeObject(attackerRoll.essais, essais, { overwrite: true });
const paramDemandeDefense = { const paramDemandeDefense = {
passeArme: attackerRoll.passeArme, passeArme: attackerRoll.passeArme,
essais: attackerRoll.essais, essais: attackerRoll.essais,
@ -494,18 +494,18 @@ export class RdDCombat {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
_getDiviseurSignificative(rollData) { _getDiviseurSignificative(defenderRoll) {
let facteurSign = (this.defender.isDemiSurprise() || rollData.needParadeSignificative) ? 2 : 1; let facteurSign = (this.defender.isDemiSurprise() || defenderRoll.needParadeSignificative) ? 2 : 1;
if (RdDBonus.isDefenseAttaqueFinesse(rollData)) { if (RdDBonus.isDefenseAttaqueFinesse(defenderRoll)) {
facteurSign *= 2; facteurSign *= 2;
} }
return facteurSign; return facteurSign;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
_onParadeParticuliere(rollData) { _onParadeParticuliere(defenderRoll) {
console.log("RdDCombat._onParadeParticuliere >>>", rollData); console.log("RdDCombat._onParadeParticuliere >>>", defenderRoll);
if (!rollData.attackerRoll.isPart) { if (!defenderRoll.attackerRoll.isPart) {
// TODO: attaquant doit jouer résistance et peut être désarmé p132 // TODO: attaquant doit jouer résistance et peut être désarmé p132
ChatUtility.chatWithRollMode({ ChatUtility.chatWithRollMode({
content: `(à gérer) L'attaquant doit jouer résistance et peut être désarmé (p132)` content: `(à gérer) L'attaquant doit jouer résistance et peut être désarmé (p132)`
@ -514,25 +514,25 @@ export class RdDCombat {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async _onParadeNormale(rollData) { async _onParadeNormale(defenderRoll) {
console.log("RdDCombat._onParadeNormale >>>", rollData); console.log("RdDCombat._onParadeNormale >>>", defenderRoll);
this._consumeDefense(rollData.passeArme); this._consumeDefense(defenderRoll.passeArme);
await this.computeRecul(rollData); await this.computeRecul(defenderRoll);
await this.computeDeteriorationArme(rollData); await this.computeDeteriorationArme(defenderRoll);
await RdDResolutionTable.displayRollData(rollData, this.defender, 'chat-resultat-parade.html'); await RdDResolutionTable.displayRollData(defenderRoll, this.defender, 'chat-resultat-parade.html');
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async _onParadeEchec(rollData) { async _onParadeEchec(defenderRoll) {
console.log("RdDCombat._onParadeEchec >>>", rollData); console.log("RdDCombat._onParadeEchec >>>", defenderRoll);
await RdDResolutionTable.displayRollData(rollData, this.defender, 'chat-resultat-parade.html'); await RdDResolutionTable.displayRollData(defenderRoll, this.defender, 'chat-resultat-parade.html');
this.removeChatMessageActionsPasseArme(rollData.passeArme); this.removeChatMessageActionsPasseArme(defenderRoll.passeArme);
this._sendMessageDefense(rollData.attackerRoll, { defense: true }); this._sendMessageDefense(defenderRoll.attackerRoll, { defense: true });
this._storeDefense(rollData); this._storeDefense(defenderRoll);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -656,11 +656,11 @@ export class RdDCombat {
} }
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async computeRecul(rollData) { // Calcul du recul (p. 132) async computeRecul(defenderRoll) { // Calcul du recul (p. 132)
const attaque = rollData.attackerRoll; const attackerRoll = defenderRoll.attackerRoll;
if (this._isAttaqueCauseRecul(attaque)) { if (this._isAttaqueCauseRecul(attackerRoll)) {
let impactRecul = this._computeImpactRecul(attaque); let impactRecul = this._computeImpactRecul(attackerRoll);
const agilite = this.defender.isEntiteCauchemar() const agilite = this.defender.isEntiteCauchemar()
? this.defender.data.data.carac.reve.value ? this.defender.data.data.carac.reve.value
: this.defender.data.data.carac.agilite.value; : this.defender.data.data.carac.agilite.value;
@ -668,13 +668,13 @@ export class RdDCombat {
let rollRecul = await RdDResolutionTable.rollData({ caracValue: 10, finalLevel: impactRecul, showDice: false }); let rollRecul = await RdDResolutionTable.rollData({ caracValue: 10, finalLevel: impactRecul, showDice: false });
if (rollRecul.isSuccess) { if (rollRecul.isSuccess) {
rollData.show.recul = 'encaisse'; defenderRoll.show.recul = 'encaisse';
} else if (rollRecul.isETotal) { } else if (rollRecul.isETotal) {
rollData.show.recul = 'chute'; defenderRoll.show.recul = 'chute';
} }
else { else {
let chute = await RdDResolutionTable.rollData({ caracValue: agilite, finalLevel: impactRecul, showDice: false }); let chute = await RdDResolutionTable.rollData({ caracValue: agilite, finalLevel: impactRecul, showDice: false });
rollData.show.recul = (chute.isSuccess) defenderRoll.show.recul = (chute.isSuccess)
? 'recul' ? 'recul'
: 'chute'; : 'chute';
} }
@ -701,7 +701,13 @@ export class RdDCombat {
console.log("RdDCombat.encaisser >>>", attackerRoll, defenderTokenId); console.log("RdDCombat.encaisser >>>", attackerRoll, defenderTokenId);
let defenderRoll = this._consumeDefense(attackerRoll.passeArme); let defenderRoll = this._consumeDefense(attackerRoll.passeArme);
if (defenderRoll && RdDCombat.isEchecTotal(defenderRoll)) { if (!defenderRoll) {
defenderRoll = {
attackerRoll: attackerRoll,
show: {}
};
}
else if (RdDCombat.isEchecTotal(defenderRoll)) {
// TODO: echec total!!! // TODO: echec total!!!
this._onEchecTotal(defenderRoll); this._onEchecTotal(defenderRoll);
} }

View File

@ -69,7 +69,7 @@ export class RdDCommands {
return; return;
} }
const term = path[0]; const term = path[0];
fullPath = fullPath+term+' ' fullPath = fullPath + term + ' '
if (path.length == 1) { if (path.length == 1) {
command.descr = `<strong>${fullPath}</strong>: ${command.descr}`; command.descr = `<strong>${fullPath}</strong>: ${command.descr}`;
targetTable[term] = command; targetTable[term] = command;

View File

@ -15,7 +15,7 @@ export class RdDDice {
if (game.modules.get("dice-so-nice") && game.modules.get("dice-so-nice").active) { if (game.modules.get("dice-so-nice") && game.modules.get("dice-so-nice").active) {
let whisper = null; let whisper = null;
let blind = false; let blind = false;
rollMode = rollMode || game.settings.get("core", "rollMode"); rollMode = rollMode ?? game.settings.get("core", "rollMode");
switch (rollMode) { switch (rollMode) {
case "blindroll": //GM only case "blindroll": //GM only
blind = true; blind = true;

View File

@ -139,7 +139,7 @@ export class RdDResolutionTable {
} }
} }
static forceSignificative(chances) { static forceSignificative(chances) {
chances.roll = Math.floor(chances.score /2); chances.roll = Math.floor(chances.score / 2);
mergeObject(chances, reussites.find(x => x.code == 'sign'), { overwrite: true }); mergeObject(chances, reussites.find(x => x.code == 'sign'), { overwrite: true });
} }

View File

@ -260,14 +260,14 @@ export class RdDUtility {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static async processItemDropEvent( actorSheet, event) { static async processItemDropEvent(actorSheet, event) {
let dragData = JSON.parse(event.dataTransfer.getData("text/plain")); let dragData = JSON.parse(event.dataTransfer.getData("text/plain"));
console.log(dragData, actorSheet.actor._id); console.log(dragData, actorSheet.actor._id);
let dropID = $(event.target).parents(".item").attr("data-item-id"); // Only relevant if container drop let dropID = $(event.target).parents(".item").attr("data-item-id"); // Only relevant if container drop
let objetId = dragData.id || dragData.data._id; let objetId = dragData.id || dragData.data._id;
if ( dropID ) { // Dropped over an item !!! if ( dropID ) { // Dropped over an item !!!
if ( actorSheet.objetVersConteneur[objetId] != dropID && objetId != dropID) { if (actorSheet.objetVersConteneur[objetId] != dropID && objetId != dropID) {
if ( actorSheet.actor.validateConteneur(objetId, dropID) && actorSheet.actor.testConteneurCapacite(objetId, dropID) ) { if (actorSheet.actor.validateConteneur(objetId, dropID) && actorSheet.actor.testConteneurCapacite(objetId, dropID)) {
await actorSheet.actor.enleverDeConteneur(objetId, actorSheet.objetVersConteneur[objetId]); await actorSheet.actor.enleverDeConteneur(objetId, actorSheet.objetVersConteneur[objetId]);
await actorSheet.actor.ajouterAConteneur(objetId, dropID); await actorSheet.actor.ajouterAConteneur(objetId, dropID);
} }
@ -281,9 +281,9 @@ export class RdDUtility {
actorSheet.actor.computeEncombrementTotalEtMalusArmure(); actorSheet.actor.computeEncombrementTotalEtMalusArmure();
return true; return true;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static buildArbreDeConteneur( actorSheet, data ) { static buildArbreDeConteneur(actorSheet, data) {
actorSheet.objetVersConteneur = {}; // Table de hash locale pour recupération rapide du conteneur parent (si existant) actorSheet.objetVersConteneur = {}; // Table de hash locale pour recupération rapide du conteneur parent (si existant)
// Attribution des objets aux conteneurs // Attribution des objets aux conteneurs
for (let conteneur of data.data.conteneurs) { for (let conteneur of data.data.conteneurs) {
@ -551,10 +551,10 @@ export class RdDUtility {
/* -------------------------------------------- */ /* -------------------------------------------- */
static _evaluatePerte(formula, over20) { static _evaluatePerte(formula, over20) {
console.log("_evaluatePerte", formula, over20) console.log("_evaluatePerte", formula, over20);
let perte = new Roll(formula, { over20: over20 }) let perte = new Roll(formula, { over20: over20 });
perte.evaluate() perte.evaluate();
return perte.total return perte.total;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */