forked from public/foundryvtt-reve-de-dragon
Message pour maîtrise Fleuve de l'Oubli
This commit is contained in:
@ -4,12 +4,14 @@
|
||||
*/
|
||||
import { RollDataAjustements } from "./rolldata-ajustements.js";
|
||||
import { RdDUtility } from "./rdd-utility.js";
|
||||
import { TMRUtility } from "./tmr-utility.js";
|
||||
import { poesieCaseHumide, TMRUtility } from "./tmr-utility.js";
|
||||
import { tmrConstants } from "./tmr-utility.js";
|
||||
import { RdDResolutionTable } from "./rdd-resolution-table.js";
|
||||
import { RdDTMRRencontreDialog } from "./rdd-tmr-rencontre-dialog.js";
|
||||
import { TMRRencontres } from "./tmr-rencontres.js";
|
||||
import { ChatUtility } from "./chat-utility.js";
|
||||
import { RdDRoll } from "./rdd-roll.js";
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
export class RdDTMRDialog extends Dialog {
|
||||
@ -70,16 +72,16 @@ export class RdDTMRDialog extends Dialog {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
displaySpecificCase() {
|
||||
for (let caseTMR of this.casesSpeciales) {
|
||||
console.log("SPEC CASE ", caseTMR);
|
||||
if (caseTMR.data.specific == 'trounoir') {
|
||||
this._trackToken(this._tokenTrouNoir(caseTMR.data.coord));
|
||||
} else if (caseTMR.data.specific == 'attache') {
|
||||
this._trackToken(this._tokenTerreAttache(caseTMR.data.coord));
|
||||
} else if (caseTMR.data.specific == 'debordement') {
|
||||
this._trackToken(this._tokenDebordement(caseTMR.data.coord));
|
||||
} else if (caseTMR.data.specific == 'maitrisee') {
|
||||
this._trackToken(this._tokenMaitrisee(caseTMR.data.coord));
|
||||
for (let caseSpeciale of this.casesSpeciales) {
|
||||
console.log("SPEC CASE ", caseSpeciale);
|
||||
if (caseSpeciale.data.specific == 'trounoir') {
|
||||
this._trackToken(this._tokenTrouNoir(caseSpeciale.data.coord));
|
||||
} else if (caseSpeciale.data.specific == 'attache') {
|
||||
this._trackToken(this._tokenTerreAttache(caseSpeciale.data.coord));
|
||||
} else if (caseSpeciale.data.specific == 'debordement') {
|
||||
this._trackToken(this._tokenDebordement(caseSpeciale.data.coord));
|
||||
} else if (caseSpeciale.data.specific == 'maitrisee') {
|
||||
this._trackToken(this._tokenMaitrisee(caseSpeciale.data.coord));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -208,6 +210,7 @@ export class RdDTMRDialog extends Dialog {
|
||||
competence: this.actor.getBestDraconic(),
|
||||
rencontre: this.currentRencontre,
|
||||
nbRounds: 1,
|
||||
canClose: false,
|
||||
tmr: TMRUtility.getTMR(this.actor.data.data.reve.tmrpos.coord)
|
||||
}
|
||||
|
||||
@ -299,19 +302,25 @@ export class RdDTMRDialog extends Dialog {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async _jetDeRencontre(tmr) {
|
||||
if (TMRUtility.isForceRencontre()) {
|
||||
return await TMRUtility.rencontreTMRRoll(tmr.coord, tmr);
|
||||
}
|
||||
let rencontre = this.rencontresExistantes.find(prev => prev.coord == tmr.coord);
|
||||
if (rencontre) {
|
||||
return rencontre;
|
||||
}
|
||||
let myRoll = new Roll("1d7").evaluate();
|
||||
if (myRoll.total == 7) {
|
||||
let isMauvaise = this.actor.isRencontreSpeciale();
|
||||
return await TMRUtility.rencontreTMRRoll(tmr.coord, tmr, isMauvaise);
|
||||
let myRoll = new Roll("1d7").evaluate().total;
|
||||
if (TMRUtility.isForceRencontre() || myRoll== 7) {
|
||||
return await this.rencontreTMRRoll(tmr, this.actor.isRencontreSpeciale());
|
||||
}
|
||||
this._tellToUser(myRoll.total + ": Pas de rencontre en " + tmr.label + " (" + tmr.coord + ")");
|
||||
this._tellToUser(myRoll + ": Pas de rencontre en " + tmr.label + " (" + tmr.coord + ")");
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rencontreTMRRoll(tmr, isMauvaise = false) {
|
||||
let rencontre = TMRUtility.utiliseForceRencontre() ??
|
||||
isMauvaise ? await TMRRencontres.getMauvaiseRencontre()
|
||||
: await TMRRencontres.getRencontreAleatoire(tmr.type);
|
||||
rencontre.coord = tmr.coord;
|
||||
return rencontre;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -352,79 +361,27 @@ export class RdDTMRDialog extends Dialog {
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
isCaseMaitrisee(coordTMR) {
|
||||
return this.casesSpeciales.find(it => it.data.coord = coordTMR && it.data.specific == 'maitrisee');
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
manageCaseHumideResult() {
|
||||
if (this.toclose)
|
||||
this.close();
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async manageCaseHumide(tmr) {
|
||||
if (this.viewOnly || this.currentRencontre) {
|
||||
return;
|
||||
}
|
||||
if (this.isCaseHumide(tmr)) {
|
||||
// TODO: permettre de choisir la voie de draconic?
|
||||
let draconic = this.actor.getBestDraconic();
|
||||
let rollData = {
|
||||
actor: this.actor,
|
||||
competence: duplicate(this.actor.getBestDraconic()),
|
||||
tmr: tmr,
|
||||
canClose: false,
|
||||
diffLibre: -7,
|
||||
forceCarac: { "reveactuel": { label: "Rêve Actuel", value: this.actor.getReveActuel() } }
|
||||
}
|
||||
rollData.competence.data.defaut_carac = "reveactuel";
|
||||
|
||||
let carac = this.actor.getReveActuel();
|
||||
const etatGeneral = this.actor.getEtatGeneral();
|
||||
let difficulte = draconic.data.niveau - 7;
|
||||
let rolled = await RdDResolutionTable.roll(carac, difficulte);
|
||||
|
||||
// Gestion du souffle Double Résistance du Fleuve
|
||||
if (this.actor.isDoubleResistanceFleuve()) {
|
||||
let rolled2 = await RdDResolutionTable.roll(carac, difficulte);
|
||||
if (rolled2.isEchec)
|
||||
rolled = rolled;
|
||||
}
|
||||
console.log("manageCaseHumide >>", rolled);
|
||||
|
||||
let explication = "";
|
||||
let msg2MJ = "";
|
||||
this.toclose = rolled.isEchec;
|
||||
if (rolled.isEchec) {
|
||||
explication += "Vous êtes entré sur une case humide, et vous avez <strong>raté</strong> votre maîtrise ! Vous <strong>quittez les Terres Médianes</strong> !"
|
||||
msg2MJ += game.user.name + " est rentré sur une case humides : Echec !";
|
||||
}
|
||||
else {
|
||||
explication += "Vous êtes entré sur une case humide, et vous avez <strong>réussi</strong> votre maîtrise !"
|
||||
msg2MJ += game.user.name + " est rentré sur une case humides : Réussite !";
|
||||
}
|
||||
explication += "<br><strong>Test : Rêve actuel / " + draconic.name + " / " + tmr.type + "</strong>"
|
||||
+ RdDResolutionTable.explain(rolled);
|
||||
|
||||
if (rolled.isETotal) {
|
||||
let souffle = await this.actor.ajouterSouffle({ chat: false });
|
||||
explication += "<br>Vous avez fait un Echec Total. Vous subissez un Souffle de Dragon : " + souffle.name;
|
||||
msg2MJ += "<br>Et a reçu un Souffle de Dragon : " + souffle.name;
|
||||
}
|
||||
if (rolled.isPart) {
|
||||
explication += "<br>Vous avez fait une Réussite Particulière";
|
||||
this.actor._appliquerAjoutExperience({ rolled: rolled, selectedCarac: { label: 'reve' }, competence: draconic.name })
|
||||
msg2MJ += "<br>Et a fait une réussite particulière";
|
||||
}
|
||||
|
||||
// Notification au MJ
|
||||
ChatMessage.create({ content: msg2MJ, whisper: ChatMessage.getWhisperRecipients("GM") });
|
||||
// Et au joueur (ca pourrait être un message de tchat d'ailleurs)
|
||||
let humideDiag = new Dialog({
|
||||
title: "Case humide",
|
||||
content: explication,
|
||||
buttons: {
|
||||
choice: { icon: '<i class="fas fa-check"></i>', label: "Fermer", callback: () => this.manageCaseHumideResult() }
|
||||
}
|
||||
}
|
||||
);
|
||||
humideDiag.render(true);
|
||||
await this._rollMaitriseCaseHumide(rollData);
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
isCaseHumide(tmr) {
|
||||
if (this.isCaseMaitrisee(tmr.coord)) {
|
||||
ChatMessage.create({
|
||||
@ -439,6 +396,60 @@ export class RdDTMRDialog extends Dialog {
|
||||
return tmr.type == "lac" || tmr.type == "fleuve" || tmr.type == "marais";
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
isCaseMaitrisee(coordTMR) {
|
||||
return this.casesSpeciales.find(it => it.data.coord = coordTMR && it.data.specific == 'maitrisee');
|
||||
}
|
||||
|
||||
async _rollMaitriseCaseHumide(rollData) {
|
||||
this.minimize(); // Hide
|
||||
const dialog = await RdDRoll.create(this.actor, rollData,
|
||||
{
|
||||
html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-tmr-humide.html',
|
||||
options:{ height: 350 },
|
||||
close: html => { this.maximize(); } // Re-display TMR
|
||||
},
|
||||
{
|
||||
name: 'maitrise',
|
||||
label: 'Maîtriser le fleuve',
|
||||
callbacks: [
|
||||
this.actor.createCallbackExperience(),
|
||||
{ action: r => this._maitriseCaseHumide(r) }
|
||||
]
|
||||
}
|
||||
);
|
||||
dialog.render(true);
|
||||
}
|
||||
|
||||
async _maitriseCaseHumide(rollData) {
|
||||
if (rollData.rolled.isETotal) {
|
||||
rollData.souffle = await this.actor.ajouterSouffle({ chat: false });
|
||||
}
|
||||
this.toclose = rollData.rolled.isEchec;
|
||||
if (rollData.rolled.isSuccess) {
|
||||
if (!rollData.previous && this.actor.isDoubleResistanceFleuve()) {
|
||||
ChatMessage.create({
|
||||
content: `Double résistance du fleuve: `,
|
||||
whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name)
|
||||
});
|
||||
rollData.previous = [rollData.rolled];
|
||||
await this._rollMaitriseCaseHumide(rollData);
|
||||
return;
|
||||
}
|
||||
}
|
||||
rollData.poesie = poesieCaseHumide[new Roll("1d" + poesieCaseHumide.length).evaluate().total - 1];
|
||||
const whisperTo = ChatUtility.getWhisperRecipientsAndGMs(game.user.name);
|
||||
const content = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-fleuve-tmr.html`, rollData);
|
||||
ChatMessage.create({
|
||||
whisper: whisperTo,
|
||||
content: content
|
||||
});
|
||||
if (rollData.rolled.isEchec) {
|
||||
this.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
isReserveExtensible(coordTMR) {
|
||||
for (let caseTMR of this.casesSpeciales) {
|
||||
@ -625,7 +636,7 @@ export class RdDTMRDialog extends Dialog {
|
||||
if (deplacementType == 'normal') { // Pas de rencontres après un saut de type passeur/changeur/...
|
||||
await this.manageRencontre(tmr, () => this.postRencontre(tmr));
|
||||
}
|
||||
else{
|
||||
else {
|
||||
await this.postRencontre(tmr);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user