Amélioration export voies draconiques

This commit is contained in:
Vincent Vandemeulebrouck 2024-09-26 00:55:08 +02:00
parent a65326d658
commit 2aa8fcb980
4 changed files with 38 additions and 15 deletions

View File

@ -1602,7 +1602,7 @@ export class RdDActor extends RdDBaseActorSang {
computeDraconicAndSortIndex(sortList) {
let draconicList = this.getDraconicList();
for (let sort of sortList) {
let draconicsSort = this.getDraconicsSort(draconicList, sort).map(it => it.name);
let draconicsSort = RdDItemSort.getDraconicsSort(draconicList, sort).map(it => it.name);
for (let index = 0; index < draconicList.length && sort.system.listIndex == undefined; index++) {
if (draconicsSort.includes(draconicList[index].name)) {
sort.system.listIndex = index;
@ -1612,19 +1612,6 @@ export class RdDActor extends RdDBaseActorSang {
return draconicList;
}
/* -------------------------------------------- */
getDraconicsSort(draconicList, sort) {
//console.log(draconicList, bestDraconic, draconic, voie);
switch (Grammar.toLowerCaseNoAccent(sort.name)) {
case "lecture d'aura":
case "detection d'aura":
return draconicList;
case "annulation de magie":
return draconicList.filter(it => !RdDItemCompetence.isThanatos(it));
}
return [RdDItemCompetence.getVoieDraconic(draconicList, sort.system.draconic)];
}
/* -------------------------------------------- */
async rollUnSort(coord) {
RdDEmpoignade.checkEmpoignadeEnCours(this)

View File

@ -115,6 +115,7 @@ export class Mapping {
static prepareArmes(actor) {
return actor.items.filter(it => it.type == ITEM_TYPES.arme)
.map(arme => {
// TODO: gestion armes 1 ou 2 mains
const compToUse = RdDItemArme.getCompetenceArme(arme, 'competence');
const comp = actor.getCompetence(compToUse);
const bonusDom = Mapping.calculBonusDom(comp, actor)
@ -183,7 +184,7 @@ export class Mapping {
static prepareSorts(actor) {
return actor.itemTypes[ITEM_TYPES.sort].map(it => {
return {
voie: it.system.voie,
voie: RdDItemSort.getCodeDraconic(it),
description: Mapping.descriptionSort(it),
bonus: Mapping.bonusCase(it)
}

View File

@ -1,10 +1,43 @@
import { Grammar } from "./grammar.js";
import { RdDItemCompetence } from "./item-competence.js";
import { ITEM_TYPES } from "./item.js";
import { Misc } from "./misc.js";
import { TMRUtility } from "./tmr-utility.js";
const VOIES_DRACONIC = [
{ code: 'O', label: "Voie d'Oniros", short: 'Oniros'},
{ code: 'H', label: "Voie d'Hypnos" , short:'Hypnos' },
{ code: 'N', label: "Voie de Narcos", short: 'Narcos' },
{ code: 'T', label: "Voie de Thanatos", short:'Thanatos' },
{ code: 'O/H/N/T', label: "Oniros/Hypnos/Narcos/Thanatos", short:'Oniros/Hypnos/Narcos/Thanatos' },
{ code: 'O/H/N', label: "Oniros/Hypnos/Narcos" }
]
/* -------------------------------------------- */
export class RdDItemSort extends Item {
static getDraconicsSort(draconicList, sort) {
switch (Grammar.toLowerCaseNoAccent(sort.name)) {
case "lecture d'aura":
case "detection d'aura":
return draconicList;
case "annulation de magie":
return draconicList.filter(it => !RdDItemCompetence.isThanatos(it));
}
return [RdDItemCompetence.getVoieDraconic(draconicList, sort.system.draconic)];
}
static getCodeDraconic(sort) {
switch (Grammar.toLowerCaseNoAccent(sort.name)) {
case "lecture d'aura":
case "detection d'aura":
return 'O/H/N/T'
case "annulation de magie":
return 'O/H/N'
}
const voie = VOIES_DRACONIC.find(it => it.label.includes(sort.system.draconic))
return voie?.code ?? sort.system.draconic
}
/* -------------------------------------------- */
static isDifficulteVariable(sort) {
return sort && (sort.system.difficulte.toLowerCase() == "variable");

View File

@ -3,3 +3,5 @@
<option value="{{competence.name}}">{{competence.name}}</option>
{{/if}}
{{/each}}
<option value="O/H/N/T">Oniros/Hypnos/Narcos/Thanatos</option>
<option value="O/H/N">Oniros/Hypnos/Narcos</option>