Gestion des signes draconiques #455

Closed
vincent.vandeme wants to merge 233 commits from v1.4-signes-draconiques into master
7 changed files with 47 additions and 3 deletions
Showing only changes of commit 33ed7bfe2c - Show all commits

View File

@ -1210,6 +1210,17 @@ export class RdDActor extends Actor {
return queue; return queue;
} }
/* -------------------------------------------- */
async cacheTMR( ) {
await this.update({ 'data.reve.tmrpos.cache': true });
}
async montreTMR( ) {
await this.update({ 'data.reve.tmrpos.cache': false });
}
async isTMRCache( ) {
return this.data.data.reve.tmrpos.cache;
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async reinsertionAleatoire(raison) { async reinsertionAleatoire(raison) {
ChatMessage.create({ ChatMessage.create({
@ -1219,9 +1230,11 @@ export class RdDActor extends Actor {
const innaccessible = this.buildTMRInnaccessible(); const innaccessible = this.buildTMRInnaccessible();
let tmr = TMRUtility.getTMRAleatoire(tmr => !innaccessible.includes(tmr.coord)); let tmr = TMRUtility.getTMRAleatoire(tmr => !innaccessible.includes(tmr.coord));
this.updateCoordTMR(tmr.coord); this.updateCoordTMR(tmr.coord);
this.cacheTMR();
return tmr; return tmr;
} }
/* -------------------------------------------- */
buildTMRInnaccessible() { buildTMRInnaccessible() {
const tmrInnaccessibles = this.filterItemsData(it => Draconique.isCaseTMR(it) && const tmrInnaccessibles = this.filterItemsData(it => Draconique.isCaseTMR(it) &&
EffetsDraconiques.isInnaccessible(it)); EffetsDraconiques.isInnaccessible(it));

View File

@ -3,12 +3,13 @@
* Extend the base Dialog entity by defining a custom window to perform roll. * Extend the base Dialog entity by defining a custom window to perform roll.
* @extends {Dialog} * @extends {Dialog}
*/ */
export class RdDAstrologieEditeur extends Dialog { export class RdDAstrologieEditeur extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
constructor(html, calendrier, calendrierData) { constructor(html, calendrier, calendrierData) {
let myButtons = { let myButtons = {
resetButton: { label: "Re-tirer les nombres astraux", callback: html => this.resetNombreAstraux() },
saveButton: { label: "Fermer", callback: html => this.fillData() } saveButton: { label: "Fermer", callback: html => this.fillData() }
}; };
@ -21,7 +22,15 @@ export class RdDAstrologieEditeur extends Dialog {
this.updateData( calendrierData ); this.updateData( calendrierData );
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
resetNombreAstraux() {
game.system.rdd.calendrier.resetNombreAstral();
game.system.rdd.calendrier.rebuildListeNombreAstral();
game.system.rdd.calendrier.showAstrologieEditor();
}
/* -------------------------------------------- */
fillData( ) { fillData( ) {
} }

View File

@ -136,6 +136,12 @@ export class RdDCalendrier extends Application {
return this.getNombreAstral(indexDate); return this.getNombreAstral(indexDate);
} }
/* -------------------------------------------- */
resetNombreAstral( ) {
this.listeNombreAstral = [];
game.settings.set("foundryvtt-reve-de-dragon", "liste-nombre-astral", this.listeNombreAstral);
}
/* -------------------------------------------- */ /* -------------------------------------------- */
getNombreAstral(indexDate) { getNombreAstral(indexDate) {
const liste = this.listeNombreAstral ?? this._loadListNombreAstral(); const liste = this.listeNombreAstral ?? this._loadListNombreAstral();

View File

@ -44,6 +44,10 @@ export class RdDTMRDialog extends Dialog {
} }
super(dialogConf, dialogOptions); super(dialogConf, dialogOptions);
if ( actor.isTMRCache() ) {
console.log("TMR cachées !!!!!!");
}
this.tmrdata = duplicate(tmrData); this.tmrdata = duplicate(tmrData);
this.actor = actor; this.actor = actor;
this.actor.tmrApp = this; // reference this app in the actor structure this.actor.tmrApp = this; // reference this app in the actor structure
@ -669,6 +673,7 @@ export class RdDTMRDialog extends Dialog {
dialog.render(true); dialog.render(true);
} }
/* -------------------------------------------- */
async validerVisite(tmr) { async validerVisite(tmr) {
await EffetsDraconiques.pelerinage.onVisiteSupprimer(this.actor, tmr, (casetmr) => this.removeToken(tmr, casetmr)); await EffetsDraconiques.pelerinage.onVisiteSupprimer(this.actor, tmr, (casetmr) => this.removeToken(tmr, casetmr));
await EffetsDraconiques.urgenceDraconique.onVisiteSupprimer(this.actor, tmr, (casetmr) => this.removeToken(tmr, casetmr)); await EffetsDraconiques.urgenceDraconique.onVisiteSupprimer(this.actor, tmr, (casetmr) => this.removeToken(tmr, casetmr));
@ -783,6 +788,7 @@ export class RdDTMRDialog extends Dialog {
await tmrObject._onClickTMRPos(eventPos); // Vérifier l'état des compteurs reve/fatigue/vie await tmrObject._onClickTMRPos(eventPos); // Vérifier l'état des compteurs reve/fatigue/vie
} }
/* -------------------------------------------- */
async _onClickTMRPos(eventPos) { async _onClickTMRPos(eventPos) {
let currentPos = TMRUtility.convertToCellPos(Misc.data(this.actor).data.reve.tmrpos.coord); let currentPos = TMRUtility.convertToCellPos(Misc.data(this.actor).data.reve.tmrpos.coord);
@ -862,6 +868,8 @@ export class RdDTMRDialog extends Dialog {
} }
} }
/* -------------------------------------------- */
async postRencontre(tmr) { async postRencontre(tmr) {
if (!(this.viewOnly || this.currentRencontre)) { if (!(this.viewOnly || this.currentRencontre)) {
await this.manageCaseHumide(tmr); await this.manageCaseHumide(tmr);

View File

@ -445,6 +445,7 @@ export class TMRRencontres {
} }
} }
/* -------------------------------------------- */
static async postEchecPasseurFou(tmrDialog, tmrData) { static async postEchecPasseurFou(tmrDialog, tmrData) {
if (tmrData.sortReserve) { if (tmrData.sortReserve) {
await tmrDialog.processSortReserve(tmrData.sortReserve); await tmrDialog.processSortReserve(tmrData.sortReserve);
@ -468,6 +469,7 @@ export class TMRRencontres {
await data.actor.santeIncDec("vie", -1); // Et -1 PV await data.actor.santeIncDec("vie", -1); // Et -1 PV
} }
/* -------------------------------------------- */
static async _toubillonner(tmrDialog, actor, cases) { static async _toubillonner(tmrDialog, actor, cases) {
let coord = Misc.templateData(actor).reve.tmrpos.coord; let coord = Misc.templateData(actor).reve.tmrpos.coord;
for (let i = 0; i < cases; i++) { for (let i = 0; i < cases; i++) {
@ -476,6 +478,7 @@ export class TMRRencontres {
await tmrDialog.forceDemiRevePosition(coord) await tmrDialog.forceDemiRevePosition(coord)
} }
/* -------------------------------------------- */
static async onPostSuccessReveDeDragon(tmrDialog, tmrData) { static async onPostSuccessReveDeDragon(tmrDialog, tmrData) {
if (tmrData.rolled.isPart) { if (tmrData.rolled.isPart) {
await tmrData.actor.appliquerExperience(tmrData.rolled, 'reve', tmrData.competence); await tmrData.actor.appliquerExperience(tmrData.rolled, 'reve', tmrData.competence);
@ -483,6 +486,7 @@ export class TMRRencontres {
await tmrData.actor.resultCombatReveDeDragon(tmrData); await tmrData.actor.resultCombatReveDeDragon(tmrData);
} }
/* -------------------------------------------- */
static async onPostEchecReveDeDragon(tmrDialog, tmrData) { static async onPostEchecReveDeDragon(tmrDialog, tmrData) {
await tmrData.actor.resultCombatReveDeDragon(tmrData); await tmrData.actor.resultCombatReveDeDragon(tmrData);
tmrDialog.close(); tmrDialog.close();

View File

@ -378,6 +378,7 @@ export class TMRUtility {
return Misc.rollOneOf(tmrRandomMovePatten); return Misc.rollOneOf(tmrRandomMovePatten);
} }
/* -------------------------------------------- */
static deplaceTMRAleatoire(actor, coord) { static deplaceTMRAleatoire(actor, coord) {
return TMRUtility.deplaceTMRSelonPattern(actor, coord, TMRUtility.getDirectionPattern(), 1); return TMRUtility.deplaceTMRSelonPattern(actor, coord, TMRUtility.getDirectionPattern(), 1);
} }
@ -465,12 +466,14 @@ export class TMRUtility {
return caseList; return caseList;
} }
/* -------------------------------------------- */
static distanceTMR(coord1, coord2) { static distanceTMR(coord1, coord2) {
let pos1 = this.convertToCellPos(coord1); let pos1 = this.convertToCellPos(coord1);
let pos2 = this.convertToCellPos(coord2); let pos2 = this.convertToCellPos(coord2);
return this.distancePosTMR(pos1, pos2); return this.distancePosTMR(pos1, pos2);
} }
/* -------------------------------------------- */
static distancePosTMR(pos1, pos2) { static distancePosTMR(pos1, pos2) {
const dx = pos2.x - pos1.x; const dx = pos2.x - pos1.x;
const dy = pos2.y - pos1.y; const dy = pos2.y - pos1.y;

View File

@ -452,7 +452,8 @@
}, },
"tmrpos": { "tmrpos": {
"coord": "A1", "coord": "A1",
"label": "Position TMR" "label": "Position TMR",
"cache": false
}, },
"reserve": { "reserve": {
"list": [] "list": []