Gestion des désir lancinant/idée fixe

Ajout d'un flag pour les identifier.
This commit is contained in:
Vincent Vandemeulebrouck
2022-11-26 16:23:53 +01:00
parent 31eabbce23
commit 029bece877
9 changed files with 131 additions and 84 deletions

View File

@ -2993,7 +2993,7 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */
checkDesirLancinant() {
let queue = this.filterItems(it => it.type == 'queue' || it.type == 'ombre')
.filter(it => Grammar.toLowerCaseNoAccent(it.name).includes('desir lancinant'));
.filter(it => it.system.categorie == 'lancinant');
return (queue.length > 0);
}

View File

@ -179,6 +179,37 @@ class _10_2_5_ArmesTirLancer extends Migration {
return Grammar.toLowerCaseNoAccent(it.system.competence);
}
}
class _10_2_10_DesirLancinant_IdeeFixe extends Migration {
get code() { return "desir-lancinat-idee-fixe"; }
get version() { return "10.2.10"; }
migrateQueue(it) {
let categorie = undefined
let name = it.name
if (Grammar.toLowerCaseNoAccent(name).includes('desir')) {
categorie = 'lancinant';
name = it.name.replace('Désir lancinant : ', '');
}
if (Grammar.toLowerCaseNoAccent(name).includes('idee fixe')) {
categorie = 'ideefixe';
name = it.name.replace('Idée fixe : ', '')
}
return { _id: it.id, name: name,
'system.ideefixe': undefined,
'system.lancinant': undefined,
'system.categorie': categorie
}
}
async migrate() {
await this.applyItemsUpdates(items => items
.filter(it => ['queue', 'ombre'].includes(it.type))
.map(it => this.migrateQueue(it))
//.filter(it => it.system.categorie )
);
}
}
export class Migrations {
static getMigrations() {
@ -188,6 +219,7 @@ export class Migrations {
new _10_0_21_VehiculeStructureResistanceMax(),
new _10_0_33_MigrationNomsDraconic(),
new _10_2_5_ArmesTirLancer(),
new _10_2_10_DesirLancinant_IdeeFixe(),
];
}

View File

@ -56,12 +56,12 @@ export class RdDRollTables {
static async getDesirLancinant(toChat = false) {
return await RdDRollTables.listOrRoll('queues-de-dragon', 'Item', 'queue', toChat, it => it.system.frequence,
it => Grammar.toLowerCaseNoAccent(it.name).includes('desir lancinant') /* it.system.lancinant */);
it => it.system.categorie == 'lancinant' );
}
static async getIdeeFixe(toChat = false) {
return await RdDRollTables.listOrRoll('queues-de-dragon', 'Item', 'queue', toChat, it => it.system.frequence,
it => Grammar.toLowerCaseNoAccent(it.name).includes('idee fixe') /* it.system.ideefixe */);
it => it.system.categorie == 'ideefixe' );
}
/* -------------------------------------------- */

View File

@ -209,6 +209,7 @@ export class RdDUtility {
'systems/foundryvtt-reve-de-dragon/templates/enum-initpremierround.html',
'systems/foundryvtt-reve-de-dragon/templates/enum-niveau-ethylisme.html',
'systems/foundryvtt-reve-de-dragon/templates/enum-rarete.html',
'systems/foundryvtt-reve-de-dragon/templates/enum-categorie-queue.html',
'systems/foundryvtt-reve-de-dragon/templates/enum-draconic.html',
'systems/foundryvtt-reve-de-dragon/templates/enum-tmr-type.html',
'systems/foundryvtt-reve-de-dragon/templates/enum-tmr-effet.html',