Corrections automatisations combat
Visiblement des changements sur les callbacks n'avaient pas été finalisés
This commit is contained in:
parent
5f3c678195
commit
df76c4bd78
@ -2643,12 +2643,13 @@ export class RdDActor extends RdDBaseActorSang {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async incDecItemUse(itemId, inc = 1) {
|
async incDecItemUse(itemId, shouldIncrease = true) {
|
||||||
const currentItemUse = this.getFlag(SYSTEM_RDD, 'itemUse');
|
if (shouldIncrease) {
|
||||||
let itemUse = currentItemUse ? foundry.utils.duplicate(currentItemUse) : {};
|
const currentItemUse = this.getFlag(SYSTEM_RDD, 'itemUse');
|
||||||
itemUse[itemId] = (itemUse[itemId] ?? 0) + inc;
|
let itemUse = currentItemUse ? foundry.utils.duplicate(currentItemUse) : {};
|
||||||
await this.setFlag(SYSTEM_RDD, 'itemUse', itemUse);
|
itemUse[itemId] = (itemUse[itemId] ?? 0) + 1;
|
||||||
console.log("ITEM USE INC", inc, itemUse);
|
await this.setFlag(SYSTEM_RDD, 'itemUse', itemUse);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
@ -277,14 +277,9 @@ export class RdDBaseActorReve extends RdDBaseActor {
|
|||||||
return dialog
|
return dialog
|
||||||
}
|
}
|
||||||
|
|
||||||
createEmptyCallback() {
|
createCallbackExperience() { return { action: r => { } } }
|
||||||
return {
|
createCallbackAppelAuMoral() { return { action: r => { } } }
|
||||||
condition: r => false,
|
|
||||||
action: r => { }
|
|
||||||
};
|
|
||||||
}
|
|
||||||
createCallbackExperience() { return this.createEmptyCallback(); }
|
|
||||||
createCallbackAppelAuMoral() { return this.createEmptyCallback(); }
|
|
||||||
async _onCloseRollDialog(html) { }
|
async _onCloseRollDialog(html) { }
|
||||||
|
|
||||||
async rollCaracCompetence(caracName, compName, diff, options = { title: "" }) {
|
async rollCaracCompetence(caracName, compName, diff, options = { title: "" }) {
|
||||||
|
@ -747,7 +747,7 @@ export class RdDBaseActor extends Actor {
|
|||||||
async jetDeMoral() { this.actionImpossible("jet de moral") }
|
async jetDeMoral() { this.actionImpossible("jet de moral") }
|
||||||
|
|
||||||
async resetItemUse() { }
|
async resetItemUse() { }
|
||||||
async incDecItemUse(itemId, inc = 1) { }
|
async incDecItemUse(itemId, shouldIncrease = true) { }
|
||||||
getItemUse(itemId) { return 0; }
|
getItemUse(itemId) { return 0; }
|
||||||
|
|
||||||
async finDeRound(options = { terminer: false }) { }
|
async finDeRound(options = { terminer: false }) { }
|
||||||
|
@ -743,23 +743,13 @@ export class RdDCombat {
|
|||||||
this.attacker.createCallbackExperience(),
|
this.attacker.createCallbackExperience(),
|
||||||
this.attacker.createCallbackAppelAuMoral(),
|
this.attacker.createCallbackAppelAuMoral(),
|
||||||
{ action: r => this.removeChatMessageActionsPasseArme(r.passeArme) },
|
{ action: r => this.removeChatMessageActionsPasseArme(r.passeArme) },
|
||||||
{ action: r => this._increaseItemUse(r, arme) },
|
{ action: async r => await this.attacker.incDecItemUse(arme._id, arme && !RdDCombat.isParticuliere(r)) },
|
||||||
{ action: r => this._onAttaqueNormale(r) },
|
{ action: r => this._onAttaque(r) },
|
||||||
{ action: r => this._onAttaqueParticuliere(r) },
|
|
||||||
{ action: r => this._onAttaqueEchec(r) },
|
|
||||||
{ action: r => this._onAttaqueEchecTotal(r) },
|
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
dialog.render(true);
|
dialog.render(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
_increaseItemUse(rollData, arme) {
|
|
||||||
if (!arme || RdDCombat.isParticuliere(rollData)) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.attacker.incDecItemUse(arme._id)
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
_prepareAttaque(competence, arme) {
|
_prepareAttaque(competence, arme) {
|
||||||
let rollData = {
|
let rollData = {
|
||||||
@ -790,11 +780,23 @@ export class RdDCombat {
|
|||||||
return rollData;
|
return rollData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async _onAttaque(attackerRoll) {
|
||||||
|
if (RdDCombat.isParticuliere(attackerRoll)) {
|
||||||
|
return await this._onAttaqueParticuliere(attackerRoll)
|
||||||
|
}
|
||||||
|
if (RdDCombat.isReussite(attackerRoll)) {
|
||||||
|
return await this._onAttaqueNormale(attackerRoll)
|
||||||
|
}
|
||||||
|
// if (RdDCombat.isParticuliere(attackerRoll) && attackerRoll.particuliere == undefined) {
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
if (RdDCombat.isEchecTotal(attackerRoll)) {
|
||||||
|
return await this._onAttaqueEchecTotal(attackerRoll)
|
||||||
|
}
|
||||||
|
return await this._onAttaqueEchec(attackerRoll)
|
||||||
|
}
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async _onAttaqueParticuliere(rollData) {
|
async _onAttaqueParticuliere(rollData) {
|
||||||
if (!RdDCombat.isParticuliere(rollData)) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const isMeleeDiffNegative = (rollData.competence.type == 'competencecreature' || rollData.selectedCarac.label == "Mêlée") && rollData.diffLibre < 0;
|
const isMeleeDiffNegative = (rollData.competence.type == 'competencecreature' || rollData.selectedCarac.label == "Mêlée") && rollData.diffLibre < 0;
|
||||||
// force toujours, sauf empoignade
|
// force toujours, sauf empoignade
|
||||||
// finesse seulement en mélée, pour l'empoignade, ou si la difficulté libre est de -1 minimum
|
// finesse seulement en mélée, pour l'empoignade, ou si la difficulté libre est de -1 minimum
|
||||||
@ -832,12 +834,6 @@ export class RdDCombat {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async _onAttaqueNormale(attackerRoll) {
|
async _onAttaqueNormale(attackerRoll) {
|
||||||
if (!RdDCombat.isReussite(attackerRoll)) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (RdDCombat.isParticuliere(attackerRoll) && attackerRoll.particuliere == undefined) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
console.log("RdDCombat.onAttaqueNormale >>>", attackerRoll);
|
console.log("RdDCombat.onAttaqueNormale >>>", attackerRoll);
|
||||||
|
|
||||||
attackerRoll.dmg = RdDBonus.dmg(attackerRoll, this.attacker, this.defender.isEntite());
|
attackerRoll.dmg = RdDBonus.dmg(attackerRoll, this.attacker, this.defender.isEntite());
|
||||||
@ -954,9 +950,6 @@ export class RdDCombat {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async _onAttaqueEchecTotal(attackerRoll) {
|
async _onAttaqueEchecTotal(attackerRoll) {
|
||||||
if (!RdDCombat.isEchecTotal(attackerRoll)) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const choixEchecTotal = await ChatMessage.create({
|
const choixEchecTotal = await ChatMessage.create({
|
||||||
whisper: ChatUtility.getOwners(this.attacker),
|
whisper: ChatUtility.getOwners(this.attacker),
|
||||||
content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-demande-attaque-etotal.hbs', {
|
content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-demande-attaque-etotal.hbs', {
|
||||||
@ -983,22 +976,16 @@ export class RdDCombat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async _onAttaqueEchec(rollData) {
|
async _onAttaqueEchec(attackerRoll) {
|
||||||
if (!RdDCombat.isEchec(rollData)) {
|
console.log("RdDCombat.onAttaqueEchec >>>", attackerRoll);
|
||||||
return
|
await RdDRollResult.displayRollData(attackerRoll, this.attacker, 'chat-resultat-attaque.hbs');
|
||||||
}
|
|
||||||
console.log("RdDCombat.onAttaqueEchec >>>", rollData);
|
|
||||||
await RdDRollResult.displayRollData(rollData, this.attacker, 'chat-resultat-attaque.hbs');
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async choixParticuliere(rollData, choix) {
|
async choixParticuliere(rollData, choix) {
|
||||||
console.log("RdDCombat.choixParticuliere >>>", rollData, choix);
|
console.log("RdDCombat.choixParticuliere >>>", rollData, choix);
|
||||||
|
|
||||||
if (choix != "rapidite") {
|
await this.attacker.incDecItemUse(rollData.arme.id, choix != "rapidite")
|
||||||
this.attacker.incDecItemUse(rollData.arme.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.removeChatMessageActionsPasseArme(rollData.passeArme);
|
this.removeChatMessageActionsPasseArme(rollData.passeArme);
|
||||||
rollData.particuliere = choix;
|
rollData.particuliere = choix;
|
||||||
@ -1026,10 +1013,8 @@ export class RdDCombat {
|
|||||||
this.defender.createCallbackExperience(),
|
this.defender.createCallbackExperience(),
|
||||||
this.defender.createCallbackAppelAuMoral(),
|
this.defender.createCallbackAppelAuMoral(),
|
||||||
{ action: r => this.removeChatMessageActionsPasseArme(r.passeArme) },
|
{ action: r => this.removeChatMessageActionsPasseArme(r.passeArme) },
|
||||||
{ condition: r => !RdDCombat.isParticuliere(r), action: r => this.defender.incDecItemUse(armeParadeId) },
|
{ action: async r => await this.defender.incDecItemUse(armeParadeId, !RdDCombat.isParticuliere(r)) },
|
||||||
{ condition: RdDCombat.isReussite, action: r => this._onParadeNormale(r) },
|
{ action: r => this._onParade(r) },
|
||||||
{ condition: RdDCombat.isParticuliere, action: r => this._onParadeParticuliere(r) },
|
|
||||||
{ condition: RdDCombat.isEchec, action: r => this._onParadeEchec(r) },
|
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
dialog.render(true);
|
dialog.render(true);
|
||||||
@ -1060,8 +1045,19 @@ export class RdDCombat {
|
|||||||
return defenderRoll;
|
return defenderRoll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async _onParade(defenderRoll) {
|
||||||
|
if (RdDCombat.isParticuliere(defenderRoll)) {
|
||||||
|
return await this._onParadeParticuliere(defenderRoll)
|
||||||
|
}
|
||||||
|
if (RdDCombat.isReussite(defenderRoll)) {
|
||||||
|
return await this._onParadeNormale(defenderRoll)
|
||||||
|
}
|
||||||
|
await this._onParadeEchec(defenderRoll)
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
_onParadeParticuliere(defenderRoll) {
|
async _onParadeParticuliere(defenderRoll) {
|
||||||
console.log("RdDCombat._onParadeParticuliere >>>", defenderRoll);
|
console.log("RdDCombat._onParadeParticuliere >>>", defenderRoll);
|
||||||
if (!defenderRoll.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
|
||||||
@ -1070,7 +1066,6 @@ export class RdDCombat {
|
|||||||
this.defender)
|
this.defender)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async _onParadeNormale(defenderRoll) {
|
async _onParadeNormale(defenderRoll) {
|
||||||
console.log("RdDCombat._onParadeNormale >>>", defenderRoll);
|
console.log("RdDCombat._onParadeNormale >>>", defenderRoll);
|
||||||
@ -1109,11 +1104,9 @@ export class RdDCombat {
|
|||||||
callbacks: [
|
callbacks: [
|
||||||
this.defender.createCallbackExperience(),
|
this.defender.createCallbackExperience(),
|
||||||
this.defender.createCallbackAppelAuMoral(),
|
this.defender.createCallbackAppelAuMoral(),
|
||||||
{ condition: r => !RdDCombat.isParticuliere(r), action: r => this.defender.incDecItemUse(esquive._id) },
|
{ action: async r => await this.defender.incDecItemUse(esquive._id, !RdDCombat.isParticuliere(r)) },
|
||||||
{ action: r => this.removeChatMessageActionsPasseArme(r.passeArme) },
|
{ action: r => this.removeChatMessageActionsPasseArme(r.passeArme) },
|
||||||
{ condition: RdDCombat.isReussite, action: r => this._onEsquiveNormale(r) },
|
{ action: r => this._onEsquive(r) },
|
||||||
{ condition: RdDCombat.isParticuliere, action: r => this._onEsquiveParticuliere(r) },
|
|
||||||
{ condition: RdDCombat.isEchec, action: r => this._onEsquiveEchec(r) },
|
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
dialog.render(true);
|
dialog.render(true);
|
||||||
@ -1141,9 +1134,18 @@ export class RdDCombat {
|
|||||||
return rollData;
|
return rollData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async _onEsquive(defenderRoll) {
|
||||||
|
if (RdDCombat.isParticuliere(defenderRoll)) {
|
||||||
|
return await this._onEsquiveParticuliere(defenderRoll)
|
||||||
|
}
|
||||||
|
if (RdDCombat.isReussite(defenderRoll)) {
|
||||||
|
return await this._onEsquiveNormale(defenderRoll)
|
||||||
|
}
|
||||||
|
return await this._onEsquiveEchec(defenderRoll)
|
||||||
|
}
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
_onEsquiveParticuliere(rollData) {
|
async _onEsquiveParticuliere(defenderRoll) {
|
||||||
console.log("RdDCombat._onEsquiveParticuliere >>>", rollData);
|
console.log("RdDCombat._onEsquiveParticuliere >>>", defenderRoll);
|
||||||
ChatUtility.createChatWithRollMode(
|
ChatUtility.createChatWithRollMode(
|
||||||
{ content: "<strong>Vous pouvez esquiver une deuxième fois!</strong>" },
|
{ content: "<strong>Vous pouvez esquiver une deuxième fois!</strong>" },
|
||||||
this.defender);
|
this.defender);
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { ChatUtility } from "./chat-utility.js";
|
|
||||||
import { Misc } from "./misc.js";
|
import { Misc } from "./misc.js";
|
||||||
import { RdDDice } from "./rdd-dice.js";
|
import { RdDDice } from "./rdd-dice.js";
|
||||||
import { ReglesOptionnelles } from "./settings/regles-optionnelles.js";
|
import { ReglesOptionnelles } from "./settings/regles-optionnelles.js";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user