Gestion des présents des cités

* fix present des cités passeur/messager
* suppression des tokens de conquête
This commit is contained in:
Vincent Vandemeulebrouck 2021-02-12 13:05:09 +01:00
parent 99ed077da8
commit d700fc7b6c
3 changed files with 20 additions and 14 deletions

View File

@ -321,7 +321,7 @@ export class RdDTMRDialog extends Dialog {
RollDataAjustements.calcul(rencontreData, this.actor); RollDataAjustements.calcul(rencontreData, this.actor);
rencontreData.rolled = presentCite rencontreData.rolled = rencontreData.presentCite
? this._rollPresentCite(rencontreData) ? this._rollPresentCite(rencontreData)
: await RdDResolutionTable.roll(rencontreData.reve, RollDataAjustements.sum(rencontreData.ajustements)); : await RdDResolutionTable.roll(rencontreData.reve, RollDataAjustements.sum(rencontreData.ajustements));
@ -419,19 +419,23 @@ export class RdDTMRDialog extends Dialog {
} }
async _utiliserPresentCite(presentCite, typeRencontre, tmr, postRencontre) { async _utiliserPresentCite(presentCite, typeRencontre, tmr, postRencontre) {
const rencontre = TMRRencontres.getRencontre(typeRencontre); this.currentRencontre = TMRRencontres.getRencontre(typeRencontre);
await TMRRencontres.evaluerForceRencontre(this.currentRencontre);
await EffetsDraconiques.presentCites.ouvrirLePresent(this.actor, presentCite);
this.removeToken(tmr, presentCite);
// simuler une rencontre
let rencontreData = { let rencontreData = {
actor: this.actor, actor: this.actor,
alias: this.actor.name, alias: this.actor.name,
reveDepart: this.actor.getReveActuel(), reveDepart: this.actor.getReveActuel(),
competence: this.actor.getBestDraconic(), competence: this.actor.getBestDraconic(),
rencontre: rencontre, rencontre: this.currentRencontre,
tmr: tmr tmr: tmr,
presentCite: presentCite
}; };
await TMRRencontres.evaluerForceRencontre(rencontre); await this._tentativeMaitrise(rencontreData);
await EffetsDraconiques.presentCites.ouvrirLePresent(this.actor, presentCite);
this.removeToken(tmr, presentCite);
await this._tentativeMaitrise(rencontreData, presentCite);
this.maximize(); this.maximize();
postRencontre(); postRencontre();
} }
@ -554,7 +558,7 @@ export class RdDTMRDialog extends Dialog {
await this._conquerir(tmr, { await this._conquerir(tmr, {
difficulte: -9, difficulte: -9,
action: 'Conquérir la cité', action: 'Conquérir la cité',
onConqueteReussie: r => EffetsDraconiques.fermetureCites.onConquete(r.actor, tmr.coord), onConqueteReussie: r => EffetsDraconiques.fermetureCites.onConquete(r.actor, tmr, (casetmr) => this.removeToken(tmr, casetmr)),
onConqueteEchec: r => this.close(), onConqueteEchec: r => this.close(),
canClose: false canClose: false
}); });
@ -572,7 +576,7 @@ export class RdDTMRDialog extends Dialog {
await this._conquerir(tmr, { await this._conquerir(tmr, {
difficulte: -7, difficulte: -7,
action: 'Conquérir', action: 'Conquérir',
onConqueteReussie: r => EffetsDraconiques.conquete.onConquete(r.actor, tmr.coord, (casetmr) => this.removeToken(tmr, casetmr)), onConqueteReussie: r => EffetsDraconiques.conquete.onConquete(r.actor, tmr, (casetmr) => this.removeToken(tmr, casetmr)),
onConqueteEchec: r => { }, onConqueteEchec: r => { },
canClose: false canClose: false
}); });

View File

@ -31,11 +31,12 @@ export class Conquete extends Draconique {
await this.createCaseTmr(actor, 'Conquête: ' + conquete.label, conquete, queue._id); await this.createCaseTmr(actor, 'Conquête: ' + conquete.label, conquete, queue._id);
} }
async onConquete(actor, coord) { async onConquete(actor, tmr, onRemoveToken) {
let existants = actor.data.items.filter(it => this.isCase(it, coord)); let existants = actor.data.items.filter(it => this.isCase(it, tmr.coord));
for (let casetmr of existants) { for (let casetmr of existants) {
await actor.deleteOwnedItem(casetmr._id); await actor.deleteOwnedItem(casetmr._id);
await actor.deleteOwnedItem(casetmr.data.sourceid); await actor.deleteOwnedItem(casetmr.data.sourceid);
onRemoveToken(tmr, casetmr);
} }
} }
} }

View File

@ -31,9 +31,10 @@ export class FermetureCites extends Draconique {
} }
} }
async onConquete(actor, coord) { async onConquete(actor, tmr, onRemoveToken) {
const citeFermee = actor.data.items.find(it => this.isCase(it, coord)); const citeFermee = actor.data.items.find(it => this.isCase(it, tmr.coord));
await actor.deleteOwnedItem(citeFermee._id); await actor.deleteOwnedItem(citeFermee._id);
onRemoveToken(tmr, citeFermee);
} }
} }