#27 Gestion des rencontres
This commit is contained in:
parent
7925e54b25
commit
ad64bc4021
@ -38,17 +38,19 @@ export class RdDTMRDialog extends Dialog {
|
||||
|
||||
this.tmrdata = duplicate(tmrData);
|
||||
this.actor = actor;
|
||||
this.actor.tmrApp = this; // reference this app in the actor structure
|
||||
this.viewOnly = viewOnly
|
||||
this.nbFatigue = this.viewOnly ? 0 : 1; // 1 premier point de fatigue du à la montée
|
||||
this.rencontresExistantes = duplicate(this.actor.data.data.reve.rencontre.list);
|
||||
this.sortReserves = duplicate(this.actor.data.data.reve.reserve.list);
|
||||
this.allTokens = []
|
||||
this.allTokens = [];
|
||||
this.pixiApp = new PIXI.Application({ width: 720, height: 860 });
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
close() {
|
||||
this.actor.santeIncDec("fatigue", this.nbFatigue).then(super.close()); // moving 1 cell costs 1 fatigue
|
||||
this.actor.tmrApp = undefined; // Cleanup reference
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -114,12 +116,12 @@ export class RdDTMRDialog extends Dialog {
|
||||
+ RdDResolutionTable.explain(rolled);
|
||||
|
||||
if (rolled.isEchec) {
|
||||
message += TMRUtility.processRencontreEchec(this.actor, this.currentRencontre, rolled);
|
||||
message += await TMRUtility.processRencontreEchec(this.actor, this.currentRencontre, rolled);
|
||||
this._tellToUser("Vous avez <strong>échoué</strong> à maîtriser un " + this.currentRencontre.name + " de force " + this.currentRencontre.force
|
||||
+ "<br>Vous quittez brutalement les Terres Médianes !" + message);
|
||||
this.close();
|
||||
} else {
|
||||
message += TMRUtility.processRencontreReussite(this.actor, this.currentRencontre, rolled);
|
||||
message += await TMRUtility.processRencontreReussite(this.actor, this.currentRencontre, rolled);
|
||||
this._tellToUser("Vous avez <strong>réussi</strong> à maîtriser un " + this.currentRencontre.name + " de force " + this.currentRencontre.force + message);
|
||||
}
|
||||
console.log("-> matriser", this.currentRencontre);
|
||||
@ -140,9 +142,9 @@ export class RdDTMRDialog extends Dialog {
|
||||
let rencontre = this.rencontresExistantes.find(prev => prev.coord == coordTMR);
|
||||
if (rencontre == undefined) {
|
||||
let deRencontre = new Roll("d7").roll();
|
||||
//if (deRencontre.total == 7) {
|
||||
if (deRencontre.total == 7) {
|
||||
rencontre = await TMRUtility.rencontreTMRRoll(coordTMR, cellDescr);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
if (rencontre) { // Manages it
|
||||
@ -178,7 +180,7 @@ export class RdDTMRDialog extends Dialog {
|
||||
|
||||
let tmrpos = document.getElementById("tmr-pos");
|
||||
let tmr = TMRUtility.getTMRDescription(this.actor.data.data.reve.tmrpos.coord);
|
||||
console.log("updateValuesDisplay", this.actor.data.data.reve.tmrpos, tmr);
|
||||
//console.log("updateValuesDisplay", this.actor.data.data.reve.tmrpos, tmr);
|
||||
tmrpos.innerHTML = this.actor.data.data.reve.tmrpos.coord + " (" + tmr.label + ")";
|
||||
|
||||
let etat = document.getElementById("etatgeneral-value");
|
||||
@ -300,6 +302,12 @@ export class RdDTMRDialog extends Dialog {
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async forceDemiRevePosition( coordTMR ) {
|
||||
await actor.updateCoordTMR(coordTMR);
|
||||
this._updateDemiReve(this);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
@ -368,6 +376,7 @@ export class RdDTMRDialog extends Dialog {
|
||||
return { cellx, celly };
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static _horsDePortee(pos, cellx, celly) {
|
||||
return Math.abs(cellx - pos.x) > 1
|
||||
|| Math.abs(celly - pos.y) > 1
|
||||
@ -375,6 +384,7 @@ export class RdDTMRDialog extends Dialog {
|
||||
|| (celly == 0 && celly < pos.y && cellx != pos.x && pos.x % 2 == 1);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_tokenRencontre(rencontre) {
|
||||
let sprite = new PIXI.Graphics();
|
||||
sprite.beginFill(0x767610, 0.6);
|
||||
@ -387,6 +397,7 @@ export class RdDTMRDialog extends Dialog {
|
||||
return { sprite: sprite, rencontre: rencontre, coordTMR: () => rencontre.coord };
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_tokenSortEnReserve(sort) {
|
||||
let sprite = new PIXI.Graphics();
|
||||
sprite.beginFill(0x101010, 0.8);
|
||||
@ -399,6 +410,7 @@ export class RdDTMRDialog extends Dialog {
|
||||
return { sprite: sprite, sort: sort, coordTMR: () => sort.coord }
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_tokenDemiReve() {
|
||||
let texture = PIXI.utils.TextureCache['demi-reve'];
|
||||
let sprite = new PIXI.Sprite(texture);
|
||||
@ -416,10 +428,12 @@ export class RdDTMRDialog extends Dialog {
|
||||
this.pixiApp.stage.addChild(this.demiReve.sprite);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_updateDemiReve(myself) {
|
||||
myself._setTokenPosition(myself.demiReve);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_setTokenPosition(token) {
|
||||
let coordXY = TMRUtility.convertToCellCoord(token.coordTMR());
|
||||
let decallagePairImpair = (coordXY.x % 2 == 0) ? tmrConstants.col1_y : tmrConstants.col2_y;
|
||||
@ -429,6 +443,7 @@ export class RdDTMRDialog extends Dialog {
|
||||
token.sprite.y = tmrConstants.gridy + (coordXY.y * tmrConstants.cellh) + dy + decallagePairImpair;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_removeTokens(filter) {
|
||||
const tokensToRemove = this.allTokens.filter(filter);
|
||||
for (let token of tokensToRemove) {
|
||||
@ -436,6 +451,7 @@ export class RdDTMRDialog extends Dialog {
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_trackToken(token) {
|
||||
this.allTokens.push(token)
|
||||
this._setTokenPosition(token);
|
||||
|
@ -583,10 +583,11 @@ export class RdDUtility {
|
||||
});
|
||||
|
||||
html.on("click", '.tmr-passeur-coord a', event => {
|
||||
let coord = event.currentTarget.attributes['data-tmr-coord'].value;
|
||||
let actor = game.actors.get( game.user.character.id );
|
||||
actor.updateCoordTMR(coord);
|
||||
});
|
||||
let coord = event.currentTarget.attributes['data-tmr-coord'].value;
|
||||
let actorId = event.currentTarget.attributes['data-actor-id'].value;
|
||||
let actor = game.actors.get( actorId );
|
||||
actor.tmrApp.forceDemiRevePosition(coord);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
@ -268,11 +268,11 @@ export class TMRUtility {
|
||||
/* -------------------------------------------- */
|
||||
static async rencontreTMRRoll( coordTMR, cellDescr )
|
||||
{
|
||||
//let rencontre = this.rencontreTMRTypeCase(cellDescr.type);
|
||||
let rencontre = rencontresTable[4];
|
||||
let rencontre = this.rencontreTMRTypeCase(cellDescr.type);
|
||||
//let rencontre = rencontresTable[4];
|
||||
if (rencontre){
|
||||
rencontre = duplicate(rencontre);
|
||||
rencontre.force = 1;//this.evaluerForceRencontre(rencontre);
|
||||
rencontre.force = this.evaluerForceRencontre(rencontre);
|
||||
rencontre.coord = coordTMR;
|
||||
}
|
||||
return rencontre;
|
||||
@ -378,7 +378,7 @@ export class TMRUtility {
|
||||
let locList = this.getLocationTypeList( actor.data.data.reve.tmrpos.coord );
|
||||
for ( let coord of locList) {
|
||||
let caseTMR = TMRMapping[coord];
|
||||
msg += "<li class='tmr-passeur-coord' data-tmr-coord='"+coord+"'><a>"+coord+" - " +caseTMR.label+"</a></li>";
|
||||
msg += "<li class='tmr-passeur-coord'><a data-actor-id='"+actor.data._id+"' data-tmr-coord='"+coord+"'>"+coord+" - " +caseTMR.label+"</a></li>";
|
||||
}
|
||||
|
||||
} else if (rencontre.name == "Briseur de Rêve") {
|
||||
|
Loading…
Reference in New Issue
Block a user