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) {
|
async sortMisEnReserve(rollData, sort) {
|
||||||
let reserve = duplicate(this.data.data.reve.reserve);
|
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 });
|
await this.update({ "data.reve.reserve": reserve });
|
||||||
this.currentTMR.updateSortReserve();
|
this.currentTMR.updateSortReserve();
|
||||||
}
|
}
|
||||||
@ -1319,7 +1319,7 @@ export class RdDActor extends Actor {
|
|||||||
selectedCarac: this.data.data.carac.reve,
|
selectedCarac: this.data.data.carac.reve,
|
||||||
draconicList: this.getDraconicList(),
|
draconicList: this.getDraconicList(),
|
||||||
sortList: sortList,
|
sortList: sortList,
|
||||||
selectedDraconic: this.getBestDraconic(),
|
competence: this.getBestDraconic(),
|
||||||
selectedSort: sortList[0],
|
selectedSort: sortList[0],
|
||||||
coord: coord,
|
coord: coord,
|
||||||
coordLabel: TMRUtility.getTMRDescription( coord).label,
|
coordLabel: TMRUtility.getTMRDescription( coord).label,
|
||||||
@ -1447,82 +1447,67 @@ export class RdDActor extends Actor {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async _rollUnSortResult(rollData, isSortReserve = false) {
|
async _rollUnSortResult(rollData, isSortReserve = false) {
|
||||||
rollData.isSortReserve = isSortReserve;
|
|
||||||
let rolled = rollData.rolled;
|
let rolled = rollData.rolled;
|
||||||
let sort = rollData.selectedSort;
|
let selectedSort = rollData.selectedSort;
|
||||||
let closeTMR = !rollData.isSortReserve;
|
let closeTMR = !isSortReserve;
|
||||||
if (sort.data.isrituel && isSortReserve) {
|
if (selectedSort.data.isrituel && isSortReserve) {
|
||||||
ui.notifications.error("Impossible de mettre le rituel '" + sort.name + "' en réserve");
|
ui.notifications.error("Impossible de mettre le rituel '" + selectedSort.name + "' en réserve");
|
||||||
this.currentTMR.close(); // Close TMR !
|
this.currentTMR.close(); // Close TMR !
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let explications = rollData.isSortReserve
|
rollData.isSortReserve = isSortReserve;
|
||||||
? ("<br>Mise en réserve du sort en " + rollData.coordLabel + "(" + rollData.coord + ")<strong>")
|
rollData.show = {}
|
||||||
: "<br>Lancement du sort <strong>";
|
rollData.depenseReve = Number(selectedSort.data.ptreve_reel);
|
||||||
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 + ")";
|
|
||||||
|
|
||||||
let depenseReve = Number(sort.data.ptreve_reel);
|
|
||||||
let myReve = duplicate(this.data.data.reve.reve);
|
let myReve = duplicate(this.data.data.reve.reve);
|
||||||
if (rolled.isSuccess) { // Réussite du sort !
|
if (rolled.isSuccess) { // Réussite du sort !
|
||||||
//sort.ptreve_reel = coutReve;
|
|
||||||
if (rolled.isPart) {
|
if (rolled.isPart) {
|
||||||
depenseReve = Math.max(Math.floor(depenseReve / 2), 1);
|
rollData.depenseReve = Math.max(Math.floor(rollData.depenseReve / 2), 1);
|
||||||
}
|
}
|
||||||
if (rollData.isSortReserve) {
|
if (rollData.isSortReserve) {
|
||||||
depenseReve++;
|
rollData.depenseReve++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (myReve.value > depenseReve) {
|
if (myReve.value > rollData.depenseReve) {
|
||||||
explications += "<br>Réussite du sort: " + depenseReve + " points de Rêve sont dépensés (Bonus de case en " + rollData.coord + ": +" + rolled.bonus + "%)";
|
|
||||||
|
|
||||||
// Incrémenter/gére le bonus de case
|
// Incrémenter/gére le bonus de case
|
||||||
RdDItemSort.incrementBonusCase(this, sort, rollData.coord);
|
RdDItemSort.incrementBonusCase(this, selectedSort, rollData.coord);
|
||||||
|
|
||||||
if (rollData.isSortReserve) {
|
if (rollData.isSortReserve) {
|
||||||
await this.sortMisEnReserve(rollData, sort);
|
await this.sortMisEnReserve(rollData, selectedSort);
|
||||||
closeTMR = false;
|
closeTMR = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Todo 0 pts de reve !!!!
|
rollData.depenseReve = 0;
|
||||||
depenseReve = 0;
|
rollData.show.reveInsuffisant = true;
|
||||||
explications += "<br>Pas assez de rêve";
|
mergeObject(rollData.rolled, RdDResolutionTable.getResultat("echec"), {overwrite:true});
|
||||||
mergeObject(rollData, RdDResolutionTable.getResultat("echec"));
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (rolled.isETotal) { // Echec total !
|
if (rolled.isETotal) { // Echec total !
|
||||||
depenseReve = Math.min(myReve.value, Math.floor(depenseReve * 1.5));
|
rollData.depenseReve = Math.min(myReve.value, Math.floor(rollData.depenseReve * 1.5))
|
||||||
explications += "<br><strong>Echec TOTAL</strong> du sort : " + depenseReve + " Points de Rêve";
|
|
||||||
// TODO: mise en réserve d'un échec total...
|
// TODO: mise en réserve d'un échec total...
|
||||||
} else {
|
} else {
|
||||||
depenseReve = 0
|
rollData.depenseReve = 0
|
||||||
explications += "<br>Echec du sort !";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
myReve.value = Math.max(myReve.value - depenseReve, 0);
|
myReve.value = Math.max(myReve.value - rollData.depenseReve, 0);
|
||||||
await this.update({ "data.reve.reve": myReve });
|
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) {
|
if (closeTMR) {
|
||||||
this.currentTMR.close(); // Close TMR !
|
this.currentTMR.close(); // Close TMR !
|
||||||
} else {
|
} else {
|
||||||
this.currentTMR.maximize(); // Re-display TMR
|
this.currentTMR.maximize(); // Re-display TMR
|
||||||
}
|
}
|
||||||
// Final chat message
|
// Final chat message
|
||||||
let chatOptions = {
|
let chatOptions = { content: await RdDResolutionTable.explainRollDataV2(rollData, 'chat-resultat-sort.html') }
|
||||||
content: "<strong>Test : " + rollData.selectedCarac.label + " / " + rollData.selectedDraconic.name + " / " + rollData.selectedSort.name + "</strong>"
|
|
||||||
+ RdDResolutionTable.explainRollData(rollData)
|
|
||||||
+ explications
|
|
||||||
}
|
|
||||||
|
|
||||||
ChatUtility.chatWithRollMode(chatOptions, this.name)
|
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) {
|
static getResultat(code) {
|
||||||
let resultat = reussites.filter(r => code == r.code);
|
let resultat = reussites.find(r => code == r.code);
|
||||||
if (resultat == undefined) {
|
if (resultat == undefined) {
|
||||||
resultat = reussites.find(r => r.code == "error");
|
resultat = reussites.find(r => r.code == "error");
|
||||||
}
|
}
|
||||||
@ -117,6 +117,9 @@ export class RdDResolutionTable {
|
|||||||
if (RdDResolutionTable.isAjustementAstrologique(rollData)) {
|
if (RdDResolutionTable.isAjustementAstrologique(rollData)) {
|
||||||
list.push({ label: 'astrologique', value: rollData.ajustementAstrologique||0 });
|
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;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ export class RdDRoll extends Dialog {
|
|||||||
});
|
});
|
||||||
html.find('#draconic').change((event) => {
|
html.find('#draconic').change((event) => {
|
||||||
let draconicKey = Misc.toInt(event.currentTarget.value);
|
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);
|
//console.log("RdDRollSelectDialog","CARAC CLICKED !!!", rollData);
|
||||||
updateRollResult(rollData);
|
updateRollResult(rollData);
|
||||||
});
|
});
|
||||||
@ -245,7 +245,7 @@ export class RdDRoll extends Dialog {
|
|||||||
return Misc.toInt(rollData.competence.data.niveau);
|
return Misc.toInt(rollData.competence.data.niveau);
|
||||||
}
|
}
|
||||||
if (rollData.draconicList) {
|
if (rollData.draconicList) {
|
||||||
return Misc.toInt(rollData.selectedDraconic.data.niveau);
|
return Misc.toInt(rollData.competence.data.niveau);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -278,7 +278,7 @@ export class RdDRoll extends Dialog {
|
|||||||
return rollData.selectedCarac.label + "/" + rollData.competence.name + armeTitle + " " + niveau
|
return rollData.selectedCarac.label + "/" + rollData.competence.name + armeTitle + " " + niveau
|
||||||
}
|
}
|
||||||
if (rollData.draconicList) {
|
if (rollData.draconicList) {
|
||||||
return rollData.selectedDraconic.name + " - " + rollData.selectedSort.name;
|
return rollData.competence.name + " - " + rollData.selectedSort.name;
|
||||||
}
|
}
|
||||||
return rollData.selectedCarac.label;
|
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