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);
rencontreData.rolled = presentCite
rencontreData.rolled = rencontreData.presentCite
? this._rollPresentCite(rencontreData)
: await RdDResolutionTable.roll(rencontreData.reve, RollDataAjustements.sum(rencontreData.ajustements));
@ -419,19 +419,23 @@ export class RdDTMRDialog extends Dialog {
}
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 = {
actor: this.actor,
alias: this.actor.name,
reveDepart: this.actor.getReveActuel(),
competence: this.actor.getBestDraconic(),
rencontre: rencontre,
tmr: tmr
rencontre: this.currentRencontre,
tmr: tmr,
presentCite: presentCite
};
await TMRRencontres.evaluerForceRencontre(rencontre);
await EffetsDraconiques.presentCites.ouvrirLePresent(this.actor, presentCite);
this.removeToken(tmr, presentCite);
await this._tentativeMaitrise(rencontreData, presentCite);
await this._tentativeMaitrise(rencontreData);
this.maximize();
postRencontre();
}
@ -554,7 +558,7 @@ export class RdDTMRDialog extends Dialog {
await this._conquerir(tmr, {
difficulte: -9,
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(),
canClose: false
});
@ -572,7 +576,7 @@ export class RdDTMRDialog extends Dialog {
await this._conquerir(tmr, {
difficulte: -7,
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 => { },
canClose: false
});

View File

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

View File

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