Fréquences par milieu pour l'environnement

Les herbes et les ingrédients peuvent être cherchées/tirées
This commit is contained in:
Vincent Vandemeulebrouck
2022-11-28 11:31:19 +01:00
parent b7a8b0c08d
commit b7a0e5d034
23 changed files with 702 additions and 158 deletions

View File

@ -1,6 +1,6 @@
import { LOG_HEAD, SYSTEM_RDD } from "./constants.js";
import { Environnement } from "./environnement.js";
import { Grammar } from "./grammar.js";
import { Misc } from "./misc.js";
class Migration {
get code() { return "sample"; }
@ -179,6 +179,7 @@ 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"; }
@ -240,6 +241,24 @@ class _10_3_0_Inventaire extends Migration {
}
}
class _10_3_0_FrequenceEnvironnement extends Migration {
get code() { return "migration-frequence-resources"; }
get version() { return "10.3.0"; }
async migrate() {
await this.applyItemsUpdates(items => items.filter(it => ['herbe', 'ingredient'].includes(it.type))
.map(it => this._updatesFrequences(it)));
}
_updatesFrequences(it) {
return {
_id: it.id,
'system.rarete': undefined,
'system.environnement': [{ milieu: it.system.milieu, rarete: it.system.rarete, frequence: Environnement.getFrequenceRarete(it.system.rarete, 'frequence') }]
}
}
}
export class Migrations {
static getMigrations() {
return [
@ -249,7 +268,8 @@ export class Migrations {
new _10_0_33_MigrationNomsDraconic(),
new _10_2_5_ArmesTirLancer(),
new _10_2_10_DesirLancinant_IdeeFixe(),
new _10_3_0_Inventaire()
new _10_3_0_Inventaire(),
new _10_3_0_FrequenceEnvironnement()
];
}
@ -264,11 +284,9 @@ export class Migrations {
}
migrate() {
const currentVersion = game.settings.get(
SYSTEM_RDD,
"systemMigrationVersion"
);
if (isNewerVersion(game.system.version, currentVersion)) {
const currentVersion = game.settings.get(SYSTEM_RDD,"systemMigrationVersion");
//if (isNewerVersion(game.system.version, currentVersion)) {
if (true) { /* comment previous and uncomment here to test before upgrade */
const migrations = Migrations.getMigrations().filter(m => isNewerVersion(m.version, currentVersion));
if (migrations.length > 0) {
migrations.sort((a, b) =>