#90 : Gestion des tetes reserve extensible et reserve en securite

This commit is contained in:
sladecraven 2020-12-30 19:18:07 +01:00
parent 4bd23b3a59
commit 557bb3a7d7
5 changed files with 118 additions and 33 deletions

View File

@ -370,12 +370,18 @@ export class RdDActorSheet extends ActorSheet {
const item = this.actor.getOwnedItem(myID);
item.sheet.render(true);
});
// Display info about queue
// Info sort
html.find('.sort-label a').click((event) => {
let myID = event.currentTarget.attributes['data-id'].value;
const item = this.actor.getOwnedItem(myID);
item.sheet.render(true);
});
// Info sort
html.find('.case-label a').click((event) => {
let myID = event.currentTarget.attributes['data-id'].value;
const item = this.actor.getOwnedItem(myID);
item.sheet.render(true);
});
// Display info about queue
html.find('.conteneur-name a').click((event) => {

View File

@ -162,13 +162,13 @@ export class RdDActor extends Actor {
return this.encTotal ? Math.floor(this.encTotal) : 0
}
/* -------------------------------------------- */
async deleteSortReserve(coordTMR) {
async deleteSortReserve(sortReserve) {
let reserve = duplicate(this.data.data.reve.reserve);
let len = reserve.list.length;
let i = 0;
let newTable = [];
for( i=0; i < len; i++) {
if (reserve.list[i].coord != coordTMR )
if (reserve.list[i].coord != sortReserve.coord && reserve.list[i].sort.name != sortReserve.sort.name )
newTable.push(reserve.list[i]);
}
if ( newTable.length != len ) {
@ -1351,6 +1351,12 @@ export class RdDActor extends Actor {
return 1;
}
/* -------------------------------------------- */
isReserveEnSecurite() {
let reserveSecurite = this.data.items.find( item => item.type == 'tete' && item.name.toLowerCase().includes( ' en sécurité' ) );
return reserveSecurite;
}
/* -------------------------------------------- */
isDoubleResistanceFleuve( ) {
let resistFleuve = this.data.items.find( item => item.type == 'souffle' && item.name.toLowerCase().includes( 'résistance du fleuve' ) );

View File

@ -76,6 +76,8 @@ export class RdDTMRDialog extends Dialog {
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 ));
}
}
}
@ -418,6 +420,14 @@ export class RdDTMRDialog extends Dialog {
humideDiag.render(true);
}
}
/* -------------------------------------------- */
isReserveExtensible( coordTMR) {
for( let caseTMR of this.casesSpeciales) {
if (caseTMR.data.specific == 'reserve_extensible' && caseTMR.data.coord == coordTMR )
return true;
}
return false;
}
/* -------------------------------------------- */
async declencheSortEnReserve(coordTMR) {
@ -425,9 +435,39 @@ export class RdDTMRDialog extends Dialog {
return;
}
let sortReserve = TMRUtility.getSortReserve( this.sortReserves, coordTMR );
if (sortReserve != undefined) {
await this.actor.deleteSortReserve(sortReserve.coord);
let sortReserveList = TMRUtility.getSortReserveList( this.sortReserves, coordTMR );
if (sortReserveList.length > 0 ) {
if ( this.actor.isReserveEnSecurite() || this.isReserveExtensible(coordTMR) ) {
let msg = "Vous êtes sur une case avec un Sort en Réserve. Grâce à votre Tête <strong>Reserve en Sécurité</strong> ou <strong>Réserve Exensible</strong>, vous pouvez contrôler le déclenchement. Cliquez si vous souhaitez le déclencher : <ul>";
for (let sortReserve of sortReserveList) {
msg += "<li><a class='chat-card-button' id='sort-reserve' data-actor-id='"+this.actor._id+"' data-tmr-coord='"+coordTMR+"' data-sort-id='"+sortReserve.sort._id+"'>"+sortReserve.sort.name+"</a></li>";
}
msg += "</ol>";
ChatMessage.create( {
content: msg,
whisper: ChatMessage.getWhisperRecipients(game.user.name) } );
} else {
await this.processSortReserve( sortReserveList[0] );
}
}
}
/* -------------------------------------------- */
lancerSortEnReserve( coordTMR, sortId ) {
let sortReserveList = TMRUtility.getSortReserveList( this.sortReserves, coordTMR );
let sortReserve = sortReserveList.find( sortReserve => sortReserve.sort._id == sortId);
//console.log("SORT RESA", sortReserveList, coordTMR, sortId, sortReserve);
if ( sortReserve) {
this.processSortReserve( sortReserve );
} else {
ChatMessage.create( {
content: "Une erreur est survenue : impossible de récupérer le sort en réserve demandé.",
whisper: ChatMessage.getWhisperRecipients(game.user.name) } );
}
}
/* -------------------------------------------- */
async processSortReserve( sortReserve ) {
await this.actor.deleteSortReserve(sortReserve);
this.updateSortReserve();
console.log("declencheSortEnReserve", sortReserve)
const declenchementSort = "Vous avez déclenché le sort <strong>" + sortReserve.sort.name
@ -436,7 +476,6 @@ export class RdDTMRDialog extends Dialog {
this._tellToGM(declenchementSort);
this.close();
}
}
/* -------------------------------------------- */
nettoyerRencontre( ) {
@ -463,6 +502,16 @@ export class RdDTMRDialog extends Dialog {
return deplacementType;
}
/* -------------------------------------------- */
isTerreAttache( coordTMR ) {
for( let caseTMR of this.casesSpeciales) {
if (caseTMR.data.specific == 'attache' && caseTMR.data.coord == coordTMR) { // Match !
return true;
}
}
return false;
}
/* -------------------------------------------- */
async deplacerDemiReve(event) {
if (this.viewOnly) {
@ -482,7 +531,7 @@ export class RdDTMRDialog extends Dialog {
// Validation de la case de destination (gestion du cas des rencontres qui peuvent téléporter)
let deplacementType = 'erreur';
if ( myself.rencontreState == 'aucune') { // Pas de recontre en post-processing, donc deplacement normal
if ( !RdDTMRDialog._horsDePortee(currentPos, cellx, celly) ) {
if ( !RdDTMRDialog._horsDePortee(currentPos, cellx, celly) || myself.isTerreAttache(coordTMR) ) {
deplacementType = 'normal';
}
} else {
@ -494,6 +543,8 @@ export class RdDTMRDialog extends Dialog {
myself.nettoyerRencontre();
let cellDescr = TMRUtility.getTMRDescription(coordTMR);
await myself.manageCaseSpeciale(cellDescr, coordTMR); // Gestion cases spéciales type Trou noir, etc
console.log("deplacerDemiReve: TMR column is", coordTMR, cellx, celly, cellDescr, this);
let tmrPos = duplicate(myself.actor.data.data.reve.tmrpos);
@ -503,10 +554,10 @@ export class RdDTMRDialog extends Dialog {
myself.nbFatigue += 1;
myself.updateValuesDisplay();
if ( deplacementType == 'normal') { // Pas de rencontres après un saut de type passeur/changeur/...
await myself.manageRencontre(coordTMR, cellDescr);
}
await myself.manageCaseSpeciale(cellDescr, coordTMR);
await myself.manageCaseHumide(cellDescr);
await myself.declencheSortEnReserve(coordTMR);
await myself.actor.checkSoufflePeage(cellDescr);
@ -646,6 +697,19 @@ export class RdDTMRDialog extends Dialog {
return { sprite: sprite, coordTMR: () => coord }
}
/* -------------------------------------------- */
_tokenTerreAttache(coord) {
let sprite = new PIXI.Graphics();
sprite.beginFill(0x10F010, 0.8);
sprite.drawCircle(0, 0, 6);
sprite.endFill();
sprite.decallage = {
x: 16 - (tmrConstants.cellw / 2),
y: 16 - (tmrConstants.cellh / 2)
}
return { sprite: sprite, coordTMR: () => coord }
}
/* -------------------------------------------- */
_tokenSortEnReserve(sort) {
let sprite = new PIXI.Graphics();

View File

@ -865,12 +865,21 @@ export class RdDUtility {
{
RdDCombat.registerChatCallbacks(html);
// Gestion spécifique message passeurs
html.on("click", '.tmr-passeur-coord a', event => {
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);
});
// Gestio spécifique des sorts en réserve multiples (ie têtes)
html.on("click", '#sort-reserve', event => {
let coord = event.currentTarget.attributes['data-tmr-coord'].value;
let sortId = event.currentTarget.attributes['data-sort-id'].value;
let actorId = event.currentTarget.attributes['data-actor-id'].value;
let actor = game.actors.get( actorId );
actor.tmrApp.lancerSortEnReserve(coord, sortId);
});
}
/* -------------------------------------------- */

View File

@ -253,7 +253,7 @@ const rencontresTable = [
]
/* -------------------------------------------- */
const caseSpecificModes = [ "attache", "trounoir", "humide", "reserve_securite", "reserve_extensible", "maitrisee", "debordement" ];
const caseSpecificModes = [ "attache", "trounoir", "humide", "reserve_extensible", "maitrisee", "debordement" ];
/* -------------------------------------------- */
const tmrMovePattern =
@ -589,18 +589,18 @@ export class TMRUtility {
}
/* -------------------------------------------- */
static getSortReserve( reserveList, coordTMR ) {
static getSortReserveList( reserveList, coordTMR ) {
// TODO : Gérer les têtes spéciales réserve!
let sortReserve
let sortReserveList
let tmrDescr = this.getTMRDescription(coordTMR);
//console.log("Sort réserve : ", tmrDescr);
if ( tmrDescr.type == 'fleuve') { // Gestion de la reserve en Fleuve
sortReserve = reserveList.find(it => TMRUtility.getTMRDescription(it.coord).type == 'fleuve' );
sortReserveList = reserveList.filter(it => TMRUtility.getTMRDescription(it.coord).type == 'fleuve' );
} else { // Reserve sur un case "normale"
sortReserve = reserveList.find(it => it.coord == coordTMR);
sortReserveList = reserveList.filter(it => it.coord == coordTMR);
}
//console.log("Sort réserve : ", tmrDescr, sortReserve, reserveList);
return sortReserve;
return sortReserveList;
}
/* -------------------------------------------- */