forked from public/foundryvtt-reve-de-dragon
Séparation des tir/mêlée/lancer
Migration automatique des objets du monde et de ses acteurs Migration des objets des compendiums
This commit is contained in:
@ -127,6 +127,59 @@ class _10_0_33_MigrationNomsDraconic extends Migration {
|
||||
}
|
||||
}
|
||||
|
||||
class _10_2_5_ArmesTirLancer extends Migration {
|
||||
constructor() {
|
||||
super();
|
||||
this.dagues = { "system.competence": 'Dague', "system.lancer": 'Dague de jet', "system.portee_courte": 3, "system.portee_moyenne": 8, "system.portee_extreme": 15 }
|
||||
this.javelot = { "system.competence": 'Lance', "system.lancer": 'Javelot', "system.portee_courte": 6, "system.portee_moyenne": 12, "system.portee_extreme": 20 }
|
||||
this.fouet = { "system.competence": '', "system.lancer": 'Fouet', "system.portee_courte": 2, "system.portee_moyenne": 2, "system.portee_extreme": 3, "system.penetration": -1 }
|
||||
this.arc = { "system.competence": '', "system.tir": 'Arc' }
|
||||
this.arbalete = { "system.competence": '', "system.tir": 'Arbalète' }
|
||||
this.fronde = { "system.competence": '', "system.tir": 'Fronde' }
|
||||
|
||||
this.mappings = {
|
||||
'dague': { filter: it => true, updates: this.dagues },
|
||||
'dague de jet': { filter: it => true, updates: this.dagues },
|
||||
'javelot': { filter: it => true, updates: this.javelot },
|
||||
'lance': { filter: it => it.name == 'Javeline', updates: this.javelot },
|
||||
'fouet': { filter: it => true, updates: this.fouet },
|
||||
'arc': { filter: it => true, updates: this.arc },
|
||||
'arbalete': { filter: it => true, updates: this.arbalete },
|
||||
'fronde': { filter: it => true, updates: this.fronde },
|
||||
}
|
||||
}
|
||||
|
||||
get code() { return "separation-competences-tir-lancer"; }
|
||||
get version() { return "10.2.5"; }
|
||||
|
||||
migrateArmeTirLancer(it) {
|
||||
let updates = mergeObject({ _id: it.id }, this.getMapping(it).updates);
|
||||
console.log(it.name, updates);
|
||||
return updates;
|
||||
}
|
||||
|
||||
async migrate() {
|
||||
await this.applyItemsUpdates(items => items
|
||||
.filter(it => "arme" == it.type)
|
||||
.filter(it => this.isTirLancer(it))
|
||||
.filter(it => this.getMapping(it).filter(it))
|
||||
.map(it => this.migrateArmeTirLancer(it)));
|
||||
}
|
||||
|
||||
|
||||
isTirLancer(it) {
|
||||
return Object.keys(this.mappings).includes(this.getCompKey(it));
|
||||
}
|
||||
|
||||
getMapping(it) {
|
||||
return this.mappings[this.getCompKey(it)];
|
||||
}
|
||||
|
||||
getCompKey(it) {
|
||||
return Grammar.toLowerCaseNoAccent(it.system.competence);
|
||||
}
|
||||
}
|
||||
|
||||
export class Migrations {
|
||||
static getMigrations() {
|
||||
return [
|
||||
@ -134,6 +187,7 @@ export class Migrations {
|
||||
new _10_0_17_MigrationCompetenceCreature(),
|
||||
new _10_0_21_VehiculeStructureResistanceMax(),
|
||||
new _10_0_33_MigrationNomsDraconic(),
|
||||
new _10_2_5_ArmesTirLancer(),
|
||||
];
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user