diff --git a/module/actor.js b/module/actor.js
index 19c79bbb..1e65bb8b 100644
--- a/module/actor.js
+++ b/module/actor.js
@@ -86,6 +86,22 @@ export class RdDActor extends Actor {
return draconic;
}
+ /* -------------------------------------------- */
+ async deleteSortReserve(coordTMR) {
+ 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 )
+ newTable.push(reserve.list[i]);
+ }
+ if ( newTable.length != len ) {
+ reserve.list = newTable;
+ await this.update( {"data.reve.reserve": reserve } );
+ }
+ }
+
/* -------------------------------------------- */
async performRoll( rollData ) {
@@ -197,9 +213,10 @@ export class RdDActor extends Actor {
// Sort management
let lvl = ""
if ( rollData.selectedSort) { // Lancement de sort !
- specialStr = "
Lancement du sort " + rollData.selectedSort.name + " : " + rollData.selectedSort.data.draconic + "/" + rollData.selectedSort.data.difficulte +
- "/" + rollData.selectedSort.data.caseTMR + "/" + rollData.selectedSort.data.ptreve;
- specialStr += "
Depuis la case " + rollData.coord + "(" + TMRUtility.getTMRDescription(rollData.coord).label + ")";
+ let draconic = rollData.selectedSort.data.draconic;
+ specialStr = "
Lancement du sort " + rollData.selectedSort.name + " : " + draconic.charAt(0).toUpperCase() + draconic.slice(1) + "/" + rollData.selectedSort.data.difficulte +
+ "/" + rollData.selectedSort.data.caseTMR + "/R" + rollData.selectedSort.data.ptreve;
+ specialStr += "
Depuis la case " + rollData.coord + " (" + TMRUtility.getTMRDescription(rollData.coord).label + ")";
lvl = rollData.selectedDraconic.name +"/"+ rollData.selectedSort.name;
let costReve = rollData.selectedSort.data.ptreve;
let myReve = duplicate(this.data.data.reve.reve);
@@ -210,8 +227,14 @@ export class RdDActor extends Actor {
if (myReve.value < 0) myReve.value = 0;
await this.update( {"data.reve.reve": myReve } );
specialStr += "
Réussite du sort pour " + costReve + " Points de Rêve";
- if ( !rollData.isSortReserve)
+ if ( !rollData.isSortReserve) {
this.currentTMR.close(); // Close TMR !
+ } else { // Mise en réserve
+ let reserve = duplicate(this.data.data.reve.reserve);
+ reserve.list.push( { coord: rollData.coord, sort: duplicate(rollData.selectedSort), draconic: duplicate(rollData.selectedDraconic) });
+ await this.update( {"data.reve.reserve": reserve} );
+ this.currentTMR.updateSortReserve();
+ }
} else {
if ( rollData.pointsDeTache == -4) { // Echec total !
costReve *= 2;
diff --git a/module/rdd-tmr-dialog.js b/module/rdd-tmr-dialog.js
index 0c6195cd..ed9abf7d 100644
--- a/module/rdd-tmr-dialog.js
+++ b/module/rdd-tmr-dialog.js
@@ -40,9 +40,10 @@ export class RdDTMRDialog extends Dialog {
this.actor = actor;
this.nbFatigue = 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);
+
//console.log(this.rencontresExistantes);
- this.pixiApp = new PIXI.Application( {width: 720, height: 860 } );
-
+ this.pixiApp = new PIXI.Application( {width: 720, height: 860 } );
}
/* -------------------------------------------- */
@@ -50,6 +51,24 @@ export class RdDTMRDialog extends Dialog {
this.actor.santeIncDec("fatigue", this.nbFatigue).then( super.close() ); // moving 1 cell costs 1 fatigue
}
+ /* -------------------------------------------- */
+ displaySortReserve() {
+ console.log(this.sortReserves);
+ for (let sortReserve of this.sortReserves) {
+ sortReserve.circle = new PIXI.Graphics();
+ sortReserve.circle.beginFill(0x767610, 0.6);
+ sortReserve.circle.drawCircle(0, 0, 6);
+ sortReserve.circle.endFill();
+ let coordXY = TMRUtility.convertToCellCoord( sortReserve.coord );
+ let basey = (coordXY.x % 2 == 0) ? this.col1_y : this.col2_y;
+ let myx = 28+(coordXY.x * this.cellw);
+ let myy = basey+28+(coordXY.y * this.cellh);
+ sortReserve.circle.x = myx - (this.cellw/2)+16;
+ sortReserve.circle.y = myy - (this.cellh/2)+16;
+ this.pixiApp.stage.addChild(sortReserve.circle);
+ }
+ }
+
/* -------------------------------------------- */
displayPreviousRencontres() {
for (let rencontre of this.rencontresExistantes) {
@@ -75,6 +94,15 @@ export class RdDTMRDialog extends Dialog {
this.rencontresExistantes = duplicate(this.actor.data.data.reve.rencontre.list);
this.displayPreviousRencontres();
}
+
+ /* -------------------------------------------- */
+ updateSortReserve() {
+ for (let sortReserve of this.sortReserves) { //cleanup pixi icons
+ this.pixiApp.stage.removeChild( sortReserve.circle );
+ }
+ this.sortReserves = duplicate(this.actor.data.data.reve.reserve.list); // Then do it again!
+ this.displaySortReserve();
+ }
/* -------------------------------------------- */
async derober() {
@@ -105,10 +133,9 @@ export class RdDTMRDialog extends Dialog {
let level = draconic.data.niveau - this.currentRencontre.force;
console.log("Maitriser", carac, draconic.data.niveau, this.currentRencontre.force);
let scoreDef = CONFIG.RDD.resolutionTable[carac][level+10];
- let myroll = new Roll("d100");
- myroll.roll();
- if ( myroll.total > scoreDef.score ) {
- TMRUtility.processRencontreEchec( this.actor, this.rencontre);
+ let result = new Roll("d100").roll().total;
+ if ( result > scoreDef.score ) {
+ TMRUtility.processRencontreEchec( this.actor, this.currentRencontre);
ChatMessage.create( { title: "TMR", content: "Vous avez échoué à votre maîtrise d'un " . this.currentRencontre.name + " de force " +
this.currentRencontre.force +
"
Vous quittez brutalement les Terres Médianes !",
@@ -260,6 +287,19 @@ export class RdDTMRDialog extends Dialog {
myself.circle.y = myy;
}
+ /* -------------------------------------------- */
+ async declencheSortEnReserve( coordTMR )
+ {
+ for (let sortReserve of this.sortReserves ) {
+ if ( sortReserve.coord == coordTMR) {
+ await this.actor.deleteSortReserve(coordTMR);
+ this.updateSortReserve();
+ ChatMessage.create( { title: "Sort en réserve", content: "Vous avez déclenché le sort en réserve " + sortReserve.sort.name, user: game.user._id } );
+ this.close();
+ }
+ }
+ }
+
/* -------------------------------------------- */
async getCursorPosition(event) {
let origEvent = event.data.originalEvent;
@@ -294,8 +334,8 @@ export class RdDTMRDialog extends Dialog {
myself.nbFatigue += 1;
myself.updateValuesDisplay();
myself.manageRencontre(coordTMR, cellDescr);
- myself.manageCaseHumide( cellDescr );
-
+ myself.manageCaseHumide( cellDescr );
+ await myself.declencheSortEnReserve( coordTMR );
}
}
@@ -340,6 +380,7 @@ export class RdDTMRDialog extends Dialog {
this.pixiApp.stage.addChild(this.circle);
this.displayPreviousRencontres();
+ this.displaySortReserve();
} );
await this.actor.updatePointsDeReve( (this.tmrdata.isRapide) ? -2 : -1); // 1 point defatigue
diff --git a/system.json b/system.json
index 301beb31..df66156c 100644
--- a/system.json
+++ b/system.json
@@ -2,7 +2,7 @@
"name": "foundryvtt-reve-de-dragon",
"title": "Rêve de Dragon",
"description": "L'implémentation de Rêve de Dragon pour FoundryVTT",
- "version": "0.8.0",
+ "version": "0.8.1",
"minimumCoreVersion": "0.6.0",
"compatibleCoreVersion": "0.6.2",
"templateVersion": 20,