Ameliorations lancer de sort

This commit is contained in:
sladecraven 2021-02-02 07:56:45 +01:00
parent be796a7169
commit d24b9c07fa
4 changed files with 56 additions and 7 deletions

View File

@ -275,7 +275,7 @@ export class RdDActor extends Actor {
getBestDraconic() { getBestDraconic() {
const list = this.getDraconicList().sort((a, b) => b.data.niveau - a.data.niveau); const list = this.getDraconicList().sort((a, b) => b.data.niveau - a.data.niveau);
if (list.length == 0) { if (list.length == 0) {
return { name: "none", niveau: -11 }; return { name: "none", data: { niveau: -11 } };
} }
return duplicate(list[0]); return duplicate(list[0]);
} }
@ -926,7 +926,7 @@ export class RdDActor extends Actor {
if (item.data.quantite == undefined) item.data.quantite = 1; // Auto-fix if (item.data.quantite == undefined) item.data.quantite = 1; // Auto-fix
if (item.data.cout < 0) item.data.cout = 0; // Auto-fix if (item.data.cout < 0) item.data.cout = 0; // Auto-fix
prixTotalEquipement += Number(item.data.cout) * Number(item.data.quantite); prixTotalEquipement += Number(item.data.cout) * Number(item.data.quantite);
console.log("cout équipement : ", item.name, item.data.cout, item.data.quantite, prixTotalEquipement); //console.log("cout équipement : ", item.name, item.data.cout, item.data.quantite, prixTotalEquipement);
} }
} }
// Mise à jour valeur totale de l'équipement // Mise à jour valeur totale de l'équipement
@ -1627,6 +1627,46 @@ export class RdDActor extends Actor {
} }
} }
/* -------------------------------------------- */
filterSortList(sortList, coord) {
let tmr = TMRUtility.getTMRDescription( coord);
let letfilteredList = []
for ( let sort of sortList) {
if (sort.data.caseTMR.toLowerCase().includes('variable') ) {
letfilteredList.push( sort);
} else if (sort.data.caseTMRspeciale.toLowerCase().includes('variable') ) {
letfilteredList.push( sort);
} else if (sort.data.caseTMR.toLowerCase() == tmr.type ) {
letfilteredList.push( sort);
} else if ( sort.data.caseTMR.toLowerCase().includes('spéciale') && sort.data.caseTMRspeciale.toLowerCase().includes( coord.toLowerCase() ) ) {
letfilteredList.push( sort);
}
}
return letfilteredList;
}
/* -------------------------------------------- */
filterDraconicList(sortList ) {
let draconicDone = {};
let newDraconicList = [];
let draconicList = this.getDraconicList();
let bestDraconic = this.getBestDraconic();
for ( let sort of sortList) {
let voie = sort.data.draconic.toLowerCase();
let competenceVoie = draconicList.find(item => item.data.categorie == 'draconic' && item.name.toLowerCase().includes( voie ) );
if ( sort.name.toLowerCase().includes('aura') ) {
competenceVoie = bestDraconic;
}
if (!draconicDone[competenceVoie.name]) {
newDraconicList.push( competenceVoie );
draconicDone[competenceVoie.name] = newDraconicList.length-1; // Patch local pour relier facilement voie/compétence
}
sort.data.listIndex = draconicDone[competenceVoie.name] || 0;
}
return newDraconicList;
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async rollUnSort(coord) { async rollUnSort(coord) {
let sortList = duplicate(this.getSortList()); // Duplication car les pts de reve sont modifiés dans le sort let sortList = duplicate(this.getSortList()); // Duplication car les pts de reve sont modifiés dans le sort
@ -1634,11 +1674,17 @@ export class RdDActor extends Actor {
ui.notifications.info("Aucun sort disponible!"); ui.notifications.info("Aucun sort disponible!");
return; return;
} }
sortList = this.filterSortList(sortList, coord);
if (!sortList || sortList.length == 0) {
ui.notifications.info("Aucun sort disponible pour cette case !");
return;
}
if (this.currentTMR) this.currentTMR.minimize(); // Hide if (this.currentTMR) this.currentTMR.minimize(); // Hide
let draconicList = this.filterDraconicList(sortList);
let rollData = { let rollData = {
selectedCarac: this.data.data.carac.reve, selectedCarac: this.data.data.carac.reve,
draconicList: this.getDraconicList(), draconicList: draconicList,
sortList: sortList, sortList: sortList,
competence: this.getBestDraconic(), competence: this.getBestDraconic(),
selectedSort: sortList[0], selectedSort: sortList[0],

View File

@ -120,6 +120,9 @@ export class RdDRoll extends Dialog {
rollData.selectedCarac = rollData.carac[rollData.competence.data.defaut_carac]; rollData.selectedCarac = rollData.carac[rollData.competence.data.defaut_carac];
$("#carac").val(rollData.competence.data.defaut_carac); $("#carac").val(rollData.competence.data.defaut_carac);
} }
if (rollData.selectedSort) {
$("#draconic").val( rollData.selectedSort.data.listIndex ); // Uniquement a la selection du sort, pour permettre de changer
}
RdDItemSort.setCoutReveReel(rollData.selectedSort); RdDItemSort.setCoutReveReel(rollData.selectedSort);
$("#diffLibre").val(Misc.toInt(rollData.diffLibre)); $("#diffLibre").val(Misc.toInt(rollData.diffLibre));
$("#diffConditions").val(Misc.toInt(rollData.diffConditions)); $("#diffConditions").val(Misc.toInt(rollData.diffConditions));
@ -153,6 +156,7 @@ export class RdDRoll extends Dialog {
this.rollData.selectedSort = this.rollData.sortList[sortKey]; // Update the selectedCarac this.rollData.selectedSort = this.rollData.sortList[sortKey]; // Update the selectedCarac
this.rollData.bonus = RdDItemSort.getCaseBonus(this.rollData.selectedSort, this.rollData.coord); this.rollData.bonus = RdDItemSort.getCaseBonus(this.rollData.selectedSort, this.rollData.coord);
RdDItemSort.setCoutReveReel(this.rollData.selectedSort); RdDItemSort.setCoutReveReel(this.rollData.selectedSort);
$("#draconic").val( this.rollData.selectedSort.data.listIndex ); // Uniquement a la selection du sort, pour permettre de changer
this.updateRollResult(); this.updateRollResult();
}); });
html.find('#ptreve-variable').change((event) => { html.find('#ptreve-variable').change((event) => {

View File

@ -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": "Rêve de Dragon RPG for FoundryVTT", "description": "Rêve de Dragon RPG for FoundryVTT",
"version": "1.3.7", "version": "1.3.8",
"manifestPlusVersion": "1.0.0", "manifestPlusVersion": "1.0.0",
"minimumCoreVersion": "0.7.5", "minimumCoreVersion": "0.7.5",
"compatibleCoreVersion": "0.7.9", "compatibleCoreVersion": "0.7.9",

View File

@ -13,7 +13,7 @@
{{/each}} {{/each}}
{{/select}} {{/select}}
</select> </select>
<label for="categorie">conditions</label> <label for="categorie"> &nbsp;Conditions</label>
<select name="diffConditions" id="diffConditions" data-dtype="number"> <select name="diffConditions" id="diffConditions" data-dtype="number">
{{#select diffConditions}} {{#select diffConditions}}
{{#each ajustementsConditions as |key|}} {{#each ajustementsConditions as |key|}}
@ -28,8 +28,7 @@
<select name="sort" id="sort" data-dtype="String"> <select name="sort" id="sort" data-dtype="String">
{{#select sort}} {{#select sort}}
{{#each sortList as |sort key|}} {{#each sortList as |sort key|}}
<option value={{key}}>{{this.name}} - {{#if this.data.caseTMRspeciale}} {{this.data.caseTMRspeciale}} {{else}}{{this.data.caseTMR}}{{/if}} / R{{this.data.difficulte}} r {{sort.data.ptreve}}</option> <option value={{key}}>{{this.name}} - {{#if this.data.caseTMRspeciale}} {{this.data.caseTMRspeciale}} {{else}}{{this.data.caseTMR}}{{/if}} / R{{this.data.difficulte}} r {{sort.data.ptreve}} ({{sort.data.draconic}})</option>
{{/each}} {{/each}}
{{/select}} {{/select}}
</select> </select>