From afd8c2ac80953a2c4cfe82820e63a2d96c512435 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Thu, 11 Sep 2025 14:47:50 +0200 Subject: [PATCH] Migration niveau oeuvres MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Passage du niveau à une valeur numérique --- changelog.md | 1 + module/migrations.js | 24 ++++++++++++++++++++---- template.json | 8 ++++---- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/changelog.md b/changelog.md index c38958ef..f560cb5a 100644 --- a/changelog.md +++ b/changelog.md @@ -6,6 +6,7 @@ - en cas d'appel au moral lorsqu'une double significative est requise, le moral est perdu si la réussite est insuffisante +- transformation du niveau des musiques/danses/chants/recettes de cuisine en valeur numérique ## 13.0.6 - Le bandage d'Illysis diff --git a/module/migrations.js b/module/migrations.js index 153c96df..208b667a 100644 --- a/module/migrations.js +++ b/module/migrations.js @@ -632,7 +632,7 @@ class _12_0_38_TachesEcriture extends Migration { async migrate() { await this.applyItemsUpdates(items => items - .filter(it => [ITEM_TYPES.tache, ITEM_TYPES.livre, ITEM_TYPES.oeuvre, ITEM_TYPES.meditation].includes(it.type) ) + .filter(it => [ITEM_TYPES.tache, ITEM_TYPES.livre, ITEM_TYPES.oeuvre, ITEM_TYPES.meditation].includes(it.type)) .filter(it => Grammar.equalsInsensitive(it.system.competence, 'ecriture')) .map(it => { return { _id: it.id, 'system.competence': 'Écriture' } }) ) @@ -640,11 +640,26 @@ class _12_0_38_TachesEcriture extends Migration { } class _13_0_4_FixReveActuel extends Migration { - get code() { return "fix-revvve-actuel" } + get code() { return "fix-reve-actuel" } get version() { return "13.0.4" } async migrate() { - game.actors.forEach(it => it.update({'system.carac.-=reve-actuel': null})) + game.actors.forEach(it => it.update({ 'system.carac.-=reve-actuel': null })) + } +} + +class _13_0_7_FixNiveauOeuvres extends Migration { + get code() { return "fix-niveau-oeuvres" } + get version() { return "13.0.7" } + + async migrate() { + await this.applyItemsUpdates(items => items + .filter(it => [ITEM_TYPES.musique, ITEM_TYPES.chant, ITEM_TYPES.danse, ITEM_TYPES.recettecuisine].includes(it.type)) + .map(it => { + const niveau = isNaN(it.system.niveau) ? 0 : parseInt(it.system.niveau) + return { _id: it.id, 'system.niveau': niveau } + }) + ) } } @@ -671,7 +686,8 @@ export class Migrations { new _12_0_32_MigrationRaces(), new _12_0_37_MigrationAlchimieEtat(), new _12_0_38_TachesEcriture(), - new _13_0_4_FixReveActuel() + new _13_0_4_FixReveActuel(), + new _13_0_7_FixNiveauOeuvres(), ]; } diff --git a/template.json b/template.json index ac3f4c68..23c6e3ec 100644 --- a/template.json +++ b/template.json @@ -811,7 +811,7 @@ }, "musique": { "templates": ["description"], - "niveau": "", + "niveau": 0, "reference": "" }, "danse": { @@ -819,12 +819,12 @@ "type": "", "agilite": false, "apparence": false, - "niveau": "", + "niveau": 0, "reference": "" }, "chant": { "templates": ["description"], - "niveau": "", + "niveau": 0, "reference": "" }, "jeu": { @@ -836,7 +836,7 @@ }, "recettecuisine": { "templates": ["description"], - "niveau": "", + "niveau": 0, "ingredients": "", "duree": "", "sust": 0,