Amélioration Tchat Sort #42
This commit is contained in:
parent
dbe37233d5
commit
1484e40cf9
@ -517,7 +517,7 @@ export class RdDActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
async sortMisEnReserve(rollData, sort) {
|
||||
let reserve = duplicate(this.data.data.reve.reserve);
|
||||
reserve.list.push({ coord: rollData.coord, sort: sort, draconic: duplicate(rollData.selectedDraconic) });
|
||||
reserve.list.push({ coord: rollData.coord, sort: sort, draconic: duplicate(rollData.competence) });
|
||||
await this.update({ "data.reve.reserve": reserve });
|
||||
this.currentTMR.updateSortReserve();
|
||||
}
|
||||
@ -1319,7 +1319,7 @@ export class RdDActor extends Actor {
|
||||
selectedCarac: this.data.data.carac.reve,
|
||||
draconicList: this.getDraconicList(),
|
||||
sortList: sortList,
|
||||
selectedDraconic: this.getBestDraconic(),
|
||||
competence: this.getBestDraconic(),
|
||||
selectedSort: sortList[0],
|
||||
coord: coord,
|
||||
coordLabel: TMRUtility.getTMRDescription( coord).label,
|
||||
@ -1447,82 +1447,67 @@ export class RdDActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async _rollUnSortResult(rollData, isSortReserve = false) {
|
||||
rollData.isSortReserve = isSortReserve;
|
||||
let rolled = rollData.rolled;
|
||||
let sort = rollData.selectedSort;
|
||||
let closeTMR = !rollData.isSortReserve;
|
||||
if (sort.data.isrituel && isSortReserve) {
|
||||
ui.notifications.error("Impossible de mettre le rituel '" + sort.name + "' en réserve");
|
||||
let selectedSort = rollData.selectedSort;
|
||||
let closeTMR = !isSortReserve;
|
||||
if (selectedSort.data.isrituel && isSortReserve) {
|
||||
ui.notifications.error("Impossible de mettre le rituel '" + selectedSort.name + "' en réserve");
|
||||
this.currentTMR.close(); // Close TMR !
|
||||
return;
|
||||
}
|
||||
|
||||
let explications = rollData.isSortReserve
|
||||
? ("<br>Mise en réserve du sort en " + rollData.coordLabel + "(" + rollData.coord + ")<strong>")
|
||||
: "<br>Lancement du sort <strong>";
|
||||
explications += sort.name + "</strong> : " + Misc.upperFirst(sort.data.draconic)
|
||||
+ " pour " + sort.data.ptreve_reel + " points de Rêve"
|
||||
+ "<br>Depuis la case " + rollData.coord + " (" + TMRUtility.getTMRDescription(rollData.coord).label + ")";
|
||||
rollData.isSortReserve = isSortReserve;
|
||||
rollData.show = {}
|
||||
rollData.depenseReve = Number(selectedSort.data.ptreve_reel);
|
||||
|
||||
let depenseReve = Number(sort.data.ptreve_reel);
|
||||
let myReve = duplicate(this.data.data.reve.reve);
|
||||
if (rolled.isSuccess) { // Réussite du sort !
|
||||
//sort.ptreve_reel = coutReve;
|
||||
if (rolled.isPart) {
|
||||
depenseReve = Math.max(Math.floor(depenseReve / 2), 1);
|
||||
rollData.depenseReve = Math.max(Math.floor(rollData.depenseReve / 2), 1);
|
||||
}
|
||||
if (rollData.isSortReserve) {
|
||||
depenseReve++;
|
||||
rollData.depenseReve++;
|
||||
}
|
||||
|
||||
if (myReve.value > depenseReve) {
|
||||
explications += "<br>Réussite du sort: " + depenseReve + " points de Rêve sont dépensés (Bonus de case en " + rollData.coord + ": +" + rolled.bonus + "%)";
|
||||
|
||||
if (myReve.value > rollData.depenseReve) {
|
||||
// Incrémenter/gére le bonus de case
|
||||
RdDItemSort.incrementBonusCase(this, sort, rollData.coord);
|
||||
RdDItemSort.incrementBonusCase(this, selectedSort, rollData.coord);
|
||||
|
||||
if (rollData.isSortReserve) {
|
||||
await this.sortMisEnReserve(rollData, sort);
|
||||
await this.sortMisEnReserve(rollData, selectedSort);
|
||||
closeTMR = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Todo 0 pts de reve !!!!
|
||||
depenseReve = 0;
|
||||
explications += "<br>Pas assez de rêve";
|
||||
mergeObject(rollData, RdDResolutionTable.getResultat("echec"));
|
||||
rollData.depenseReve = 0;
|
||||
rollData.show.reveInsuffisant = true;
|
||||
mergeObject(rollData.rolled, RdDResolutionTable.getResultat("echec"), {overwrite:true});
|
||||
}
|
||||
} else {
|
||||
if (rolled.isETotal) { // Echec total !
|
||||
depenseReve = Math.min(myReve.value, Math.floor(depenseReve * 1.5));
|
||||
explications += "<br><strong>Echec TOTAL</strong> du sort : " + depenseReve + " Points de Rêve";
|
||||
rollData.depenseReve = Math.min(myReve.value, Math.floor(rollData.depenseReve * 1.5))
|
||||
// TODO: mise en réserve d'un échec total...
|
||||
} else {
|
||||
depenseReve = 0
|
||||
explications += "<br>Echec du sort !";
|
||||
rollData.depenseReve = 0
|
||||
}
|
||||
}
|
||||
|
||||
myReve.value = Math.max(myReve.value - depenseReve, 0);
|
||||
myReve.value = Math.max(myReve.value - rollData.depenseReve, 0);
|
||||
await this.update({ "data.reve.reve": myReve });
|
||||
|
||||
if (myReve.value == 0) { // 0 points de reve
|
||||
ChatMessage.create({ content: this.name + " est réduit à 0 Points de Rêve, et tombe endormi !" });
|
||||
closeTMR = true;
|
||||
}
|
||||
if (closeTMR) {
|
||||
this.currentTMR.close(); // Close TMR !
|
||||
} else {
|
||||
this.currentTMR.maximize(); // Re-display TMR
|
||||
}
|
||||
// Final chat message
|
||||
let chatOptions = {
|
||||
content: "<strong>Test : " + rollData.selectedCarac.label + " / " + rollData.selectedDraconic.name + " / " + rollData.selectedSort.name + "</strong>"
|
||||
+ RdDResolutionTable.explainRollData(rollData)
|
||||
+ explications
|
||||
}
|
||||
|
||||
let chatOptions = { content: await RdDResolutionTable.explainRollDataV2(rollData, 'chat-resultat-sort.html') }
|
||||
ChatUtility.chatWithRollMode(chatOptions, this.name)
|
||||
|
||||
if (myReve.value == 0) { // 0 points de reve
|
||||
ChatMessage.create({ content: this.name + " est réduit à 0 Points de Rêve, et tombe endormi !" });
|
||||
closeTMR = true;
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
@ -70,7 +70,7 @@ export class RdDResolutionTable {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getResultat(code) {
|
||||
let resultat = reussites.filter(r => code == r.code);
|
||||
let resultat = reussites.find(r => code == r.code);
|
||||
if (resultat == undefined) {
|
||||
resultat = reussites.find(r => r.code == "error");
|
||||
}
|
||||
@ -117,6 +117,9 @@ export class RdDResolutionTable {
|
||||
if (RdDResolutionTable.isAjustementAstrologique(rollData)) {
|
||||
list.push({ label: 'astrologique', value: rollData.ajustementAstrologique||0 });
|
||||
}
|
||||
if (rollData.rolled.bonus && rollData.selectedSort) {
|
||||
list.push({ label: 'Bonus de case', value: rollData.rolled.bonus, unit: '%' });
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,7 @@ export class RdDRoll extends Dialog {
|
||||
});
|
||||
html.find('#draconic').change((event) => {
|
||||
let draconicKey = Misc.toInt(event.currentTarget.value);
|
||||
this.rollData.selectedDraconic = rollData.draconicList[draconicKey]; // Update the selectedCarac
|
||||
this.rollData.competence = rollData.draconicList[draconicKey]; // Update the selectedCarac
|
||||
//console.log("RdDRollSelectDialog","CARAC CLICKED !!!", rollData);
|
||||
updateRollResult(rollData);
|
||||
});
|
||||
@ -245,7 +245,7 @@ export class RdDRoll extends Dialog {
|
||||
return Misc.toInt(rollData.competence.data.niveau);
|
||||
}
|
||||
if (rollData.draconicList) {
|
||||
return Misc.toInt(rollData.selectedDraconic.data.niveau);
|
||||
return Misc.toInt(rollData.competence.data.niveau);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -278,7 +278,7 @@ export class RdDRoll extends Dialog {
|
||||
return rollData.selectedCarac.label + "/" + rollData.competence.name + armeTitle + " " + niveau
|
||||
}
|
||||
if (rollData.draconicList) {
|
||||
return rollData.selectedDraconic.name + " - " + rollData.selectedSort.name;
|
||||
return rollData.competence.name + " - " + rollData.selectedSort.name;
|
||||
}
|
||||
return rollData.selectedCarac.label;
|
||||
}
|
||||
|
40
templates/chat-resultat-sort.html
Normal file
40
templates/chat-resultat-sort.html
Normal file
@ -0,0 +1,40 @@
|
||||
<h4>
|
||||
{{#if isSortReserve}}Mise en réserve{{else}}Lancement{{/if}} du sort {{selectedSort.name}} r{{selectedSort.data.ptreve_reel}}
|
||||
<br>
|
||||
<span class="tooltip">
|
||||
{{competence.name}}: {{rolled.caracValue}} à {{numberFormat rolled.finalLevel decimals=0 sign=true}}
|
||||
<div class="tooltiptext tooltiptext-ajustements">
|
||||
<div>Ajustements</div>
|
||||
{{#each ajustements as |item key|}}
|
||||
<div class="{{#if item.strong}}strong-text{{/if}}" >{{item.label}}: {{numberFormat item.value decimals=0 sign=true}}{{#if item.unit}}{{item.unit}}{{/if}}</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
</span>
|
||||
{{#if rolled.needSignificative}}<label class="rdd-need-significative">(×½)</label>{{/if}} =
|
||||
{{rolled.score}}%
|
||||
</h4>
|
||||
<div>Pour {{selectedSort.data.ptreve_reel}} points de rêve en {{coordLabel}} ({{coord}})</div>
|
||||
<hr>
|
||||
<div>
|
||||
<span>{{rolled.roll}} :</span>
|
||||
<span class="rdd-roll-{{rolled.code}} strong-text">{{rolled.quality}}</span>
|
||||
{{#if show.reveInsuffisant}}<span>Pas assez de rêve!</span>{{/if}}
|
||||
<span>
|
||||
{{#if rolled.isETotal}}
|
||||
Echec TOTAL du sort!
|
||||
{{else if rolled.isEchec}}
|
||||
Echec du sort,
|
||||
{{else}}
|
||||
Réussite du sort,
|
||||
{{/if~}}
|
||||
</span>
|
||||
<span>
|
||||
{{#if (eq depenseReve 0)}}
|
||||
pas de dépense de rêve
|
||||
{{else if (eq depenseReve 1)}}
|
||||
1 point de rêve a été dépensé
|
||||
{{else}}
|
||||
{{depenseReve}} points de rêve ont été dépensés
|
||||
{{/if}}
|
||||
</span>
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user