Nouveau roll-dialog: mode attaque / defense
This commit is contained in:
@@ -15,6 +15,10 @@ import { RdDItemArme } from "./item/arme.js";
|
||||
import { RdDItemCompetence } from "./item-competence.js";
|
||||
import { RdDItemCompetenceCreature } from "./item-competencecreature.js";
|
||||
import { RdDInitiative } from "./initiative.mjs";
|
||||
import RollDialog from "./roll/roll-dialog.mjs";
|
||||
import { PART_DEFENSE } from "./roll/roll-part-defense.mjs";
|
||||
import { PART_ATTAQUE } from "./roll/roll-part-attaque.mjs";
|
||||
import { RollDialogAdapter } from "./roll/roll-dialog-adapter.mjs";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
const premierRoundInit = [
|
||||
@@ -398,6 +402,7 @@ export class RdDCombat {
|
||||
/* -------------------------------------------- */
|
||||
static registerChatCallbacks(html) {
|
||||
for (let button of [
|
||||
'.defense-button',
|
||||
'.parer-button',
|
||||
'.esquiver-button',
|
||||
'.particuliere-attaque',
|
||||
@@ -466,6 +471,8 @@ export class RdDCombat {
|
||||
|
||||
switch (button) {
|
||||
case '.particuliere-attaque': return await this.choixParticuliere(attackerRoll, event.currentTarget.attributes['data-mode'].value);
|
||||
case '.defense-button': return this.defenseV2(attackerRoll);
|
||||
|
||||
case '.parer-button': return this.parade(attackerRoll, armeParadeId);
|
||||
case '.esquiver-button': return this.esquive(attackerRoll, compId, competence);
|
||||
case '.encaisser-button': return this.encaisser(attackerRoll, defenderRoll);
|
||||
@@ -713,9 +720,6 @@ export class RdDCombat {
|
||||
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)
|
||||
}
|
||||
@@ -857,7 +861,7 @@ export class RdDCombat {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_filterArmesParade(defender, competence, armeAttaque) {
|
||||
let defenses = defender.items.filter(it => RdDItemArme.isParade(it))
|
||||
let defenses = defender.items.filter(it => it.isParade())
|
||||
defenses = foundry.utils.duplicate(defenses)
|
||||
defenses.forEach(armeDefense => {
|
||||
// Ajout du # d'utilisation ce round
|
||||
@@ -946,6 +950,41 @@ export class RdDCombat {
|
||||
dialog.render(true);
|
||||
}
|
||||
|
||||
async defenseV2(attackerRoll) {
|
||||
|
||||
// this._prepareParade(attackerRoll, arme, competence);
|
||||
const rollData =
|
||||
{
|
||||
ids: {
|
||||
actorId: this.defender.id,
|
||||
actorTokenId: this.defenderTokenId,
|
||||
opponentTokenId: this.attackerTokenId,
|
||||
opponentId: this.attackerId,
|
||||
},
|
||||
mode: {
|
||||
allowed: ['defense'],
|
||||
current: 'defense'
|
||||
},
|
||||
attaque: RollDialogAdapter.mapActionAttaque(attackerRoll),
|
||||
passeArme: attackerRoll.passeArme,
|
||||
}
|
||||
|
||||
await RollDialog.create(rollData, {
|
||||
onRoll: (dialog) => {
|
||||
this._onCloseRollDialog(),
|
||||
dialog.close()
|
||||
},
|
||||
customChatMessage: true,
|
||||
callbacks: [async (actor, rd) => {
|
||||
this.removeChatMessageActionsPasseArme(rd.passeArme)
|
||||
// defense: esquive / arme de parade / competence de défense
|
||||
await rd.active.actor.incDecItemUse(rd.current[PART_DEFENSE].defense?.id, !RdDCombat.isParticuliere(rd))
|
||||
await this._onDefenseV2(rd)
|
||||
}]
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_prepareParade(attackerRoll, armeParade, competenceParade) {
|
||||
let defenderRoll = {
|
||||
@@ -971,7 +1010,6 @@ export class RdDCombat {
|
||||
return defenderRoll;
|
||||
}
|
||||
|
||||
|
||||
async _onParade(defenderRoll) {
|
||||
if (RdDCombat.isReussite(defenderRoll)) {
|
||||
await this._onParadeNormale(defenderRoll)
|
||||
@@ -982,6 +1020,16 @@ export class RdDCombat {
|
||||
}
|
||||
await this._onParadeEchec(defenderRoll)
|
||||
}
|
||||
async _onDefenseV2(defenderRoll) {
|
||||
if (RdDCombat.isReussite(defenderRoll)) {
|
||||
await this._onParadeNormale(defenderRoll)
|
||||
if (RdDCombat.isParticuliere(defenderRoll)) {
|
||||
await this._onParadeParticuliere(defenderRoll)
|
||||
}
|
||||
return
|
||||
}
|
||||
await this._onParadeEchec(defenderRoll)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async _onParadeParticuliere(defenderRoll) {
|
||||
@@ -1255,4 +1303,8 @@ export class RdDCombat {
|
||||
alias: alias
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function newFunction(attackerRoll) {
|
||||
return attackerRoll.diffLibre;
|
||||
}
|
||||
|
Reference in New Issue
Block a user