Gestion reserve
This commit is contained in:
parent
dc57b46db5
commit
c1a6ee1e92
@ -86,6 +86,22 @@ export class RdDActor extends Actor {
|
|||||||
return draconic;
|
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 ) {
|
async performRoll( rollData ) {
|
||||||
|
|
||||||
@ -197,9 +213,10 @@ export class RdDActor extends Actor {
|
|||||||
// Sort management
|
// Sort management
|
||||||
let lvl = ""
|
let lvl = ""
|
||||||
if ( rollData.selectedSort) { // Lancement de sort !
|
if ( rollData.selectedSort) { // Lancement de sort !
|
||||||
specialStr = "<br>Lancement du sort <strong>" + rollData.selectedSort.name + "</strong> : " + rollData.selectedSort.data.draconic + "/" + rollData.selectedSort.data.difficulte +
|
let draconic = rollData.selectedSort.data.draconic;
|
||||||
"/" + rollData.selectedSort.data.caseTMR + "/" + rollData.selectedSort.data.ptreve;
|
specialStr = "<br>Lancement du sort <strong>" + rollData.selectedSort.name + "</strong> : " + draconic.charAt(0).toUpperCase() + draconic.slice(1) + "/" + rollData.selectedSort.data.difficulte +
|
||||||
specialStr += "<br>Depuis la case " + rollData.coord + "(" + TMRUtility.getTMRDescription(rollData.coord).label + ")";
|
"/" + rollData.selectedSort.data.caseTMR + "/R" + rollData.selectedSort.data.ptreve;
|
||||||
|
specialStr += "<br>Depuis la case " + rollData.coord + " (" + TMRUtility.getTMRDescription(rollData.coord).label + ")";
|
||||||
lvl = rollData.selectedDraconic.name +"/"+ rollData.selectedSort.name;
|
lvl = rollData.selectedDraconic.name +"/"+ rollData.selectedSort.name;
|
||||||
let costReve = rollData.selectedSort.data.ptreve;
|
let costReve = rollData.selectedSort.data.ptreve;
|
||||||
let myReve = duplicate(this.data.data.reve.reve);
|
let myReve = duplicate(this.data.data.reve.reve);
|
||||||
@ -210,8 +227,14 @@ export class RdDActor extends Actor {
|
|||||||
if (myReve.value < 0) myReve.value = 0;
|
if (myReve.value < 0) myReve.value = 0;
|
||||||
await this.update( {"data.reve.reve": myReve } );
|
await this.update( {"data.reve.reve": myReve } );
|
||||||
specialStr += "<br>Réussite du sort pour " + costReve + " Points de Rêve";
|
specialStr += "<br>Réussite du sort pour " + costReve + " Points de Rêve";
|
||||||
if ( !rollData.isSortReserve)
|
if ( !rollData.isSortReserve) {
|
||||||
this.currentTMR.close(); // Close TMR !
|
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 {
|
} else {
|
||||||
if ( rollData.pointsDeTache == -4) { // Echec total !
|
if ( rollData.pointsDeTache == -4) { // Echec total !
|
||||||
costReve *= 2;
|
costReve *= 2;
|
||||||
|
@ -40,9 +40,10 @@ export class RdDTMRDialog extends Dialog {
|
|||||||
this.actor = actor;
|
this.actor = actor;
|
||||||
this.nbFatigue = 1; // 1 premier point de fatigue du à la montée
|
this.nbFatigue = 1; // 1 premier point de fatigue du à la montée
|
||||||
this.rencontresExistantes = duplicate(this.actor.data.data.reve.rencontre.list);
|
this.rencontresExistantes = duplicate(this.actor.data.data.reve.rencontre.list);
|
||||||
|
this.sortReserves = duplicate(this.actor.data.data.reve.reserve.list);
|
||||||
|
|
||||||
//console.log(this.rencontresExistantes);
|
//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
|
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() {
|
displayPreviousRencontres() {
|
||||||
for (let rencontre of this.rencontresExistantes) {
|
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.rencontresExistantes = duplicate(this.actor.data.data.reve.rencontre.list);
|
||||||
this.displayPreviousRencontres();
|
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() {
|
async derober() {
|
||||||
@ -105,10 +133,9 @@ export class RdDTMRDialog extends Dialog {
|
|||||||
let level = draconic.data.niveau - this.currentRencontre.force;
|
let level = draconic.data.niveau - this.currentRencontre.force;
|
||||||
console.log("Maitriser", carac, 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 scoreDef = CONFIG.RDD.resolutionTable[carac][level+10];
|
||||||
let myroll = new Roll("d100");
|
let result = new Roll("d100").roll().total;
|
||||||
myroll.roll();
|
if ( result > scoreDef.score ) {
|
||||||
if ( myroll.total > scoreDef.score ) {
|
TMRUtility.processRencontreEchec( this.actor, this.currentRencontre);
|
||||||
TMRUtility.processRencontreEchec( this.actor, this.rencontre);
|
|
||||||
ChatMessage.create( { title: "TMR", content: "Vous avez <strong>échoué</strong> à votre maîtrise d'un " . this.currentRencontre.name + " de force " +
|
ChatMessage.create( { title: "TMR", content: "Vous avez <strong>échoué</strong> à votre maîtrise d'un " . this.currentRencontre.name + " de force " +
|
||||||
this.currentRencontre.force +
|
this.currentRencontre.force +
|
||||||
"<br>Vous quittez brutalement les Terres Médianes !",
|
"<br>Vous quittez brutalement les Terres Médianes !",
|
||||||
@ -260,6 +287,19 @@ export class RdDTMRDialog extends Dialog {
|
|||||||
myself.circle.y = myy;
|
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) {
|
async getCursorPosition(event) {
|
||||||
let origEvent = event.data.originalEvent;
|
let origEvent = event.data.originalEvent;
|
||||||
@ -294,8 +334,8 @@ export class RdDTMRDialog extends Dialog {
|
|||||||
myself.nbFatigue += 1;
|
myself.nbFatigue += 1;
|
||||||
myself.updateValuesDisplay();
|
myself.updateValuesDisplay();
|
||||||
myself.manageRencontre(coordTMR, cellDescr);
|
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.pixiApp.stage.addChild(this.circle);
|
||||||
|
|
||||||
this.displayPreviousRencontres();
|
this.displayPreviousRencontres();
|
||||||
|
this.displaySortReserve();
|
||||||
} );
|
} );
|
||||||
|
|
||||||
await this.actor.updatePointsDeReve( (this.tmrdata.isRapide) ? -2 : -1); // 1 point defatigue
|
await this.actor.updatePointsDeReve( (this.tmrdata.isRapide) ? -2 : -1); // 1 point defatigue
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"name": "foundryvtt-reve-de-dragon",
|
"name": "foundryvtt-reve-de-dragon",
|
||||||
"title": "Rêve de Dragon",
|
"title": "Rêve de Dragon",
|
||||||
"description": "L'implémentation de Rêve de Dragon pour FoundryVTT",
|
"description": "L'implémentation de Rêve de Dragon pour FoundryVTT",
|
||||||
"version": "0.8.0",
|
"version": "0.8.1",
|
||||||
"minimumCoreVersion": "0.6.0",
|
"minimumCoreVersion": "0.6.0",
|
||||||
"compatibleCoreVersion": "0.6.2",
|
"compatibleCoreVersion": "0.6.2",
|
||||||
"templateVersion": 20,
|
"templateVersion": 20,
|
||||||
|
Loading…
Reference in New Issue
Block a user