fix: XP compétences négatives (base de catégorie)
Le champ base (INTEGER, min 0) rejetait les bases négatives (-4/-6/-8/-11) : toute compétence voyait sa base forcée à 0, d'où un total d'XP compétences fortement négatif (ex. -5790 sur un personnage neuf). - competence.mjs : base en INTEGER_SIGNED - item-competence.js : _preCreate affecte la base de la catégorie - migrations.js : migration 14.0.3 corrige les compétences existantes - compendiums repackés (bases de catégorie présentes dans les packs)
This commit is contained in:
@@ -55,6 +55,13 @@ export class RdDItemCompetence extends RdDItem {
|
||||
return this.system.niveau == this.system.base && this.system.xp == 0
|
||||
}
|
||||
|
||||
async _preCreate(data, options, user) {
|
||||
await super._preCreate(data, options, user)
|
||||
if (this.system.categorie && !Number(data.system?.base)) {
|
||||
this.updateSource({ 'system.base': RdDItemCompetence.getNiveauBase(this.system.categorie, this.type) })
|
||||
}
|
||||
}
|
||||
|
||||
getBaseInit() {
|
||||
const carac = this.getInitCarac()
|
||||
if (carac == undefined) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import { Grammar } from "./grammar.js";
|
||||
import { Monnaie } from "./item-monnaie.js";
|
||||
import { ITEM_TYPES, ACTOR_TYPES } from "./constants.js";
|
||||
import { RdDItem } from "./item.js";
|
||||
import { RdDItemCompetence } from "./item-competence.js";
|
||||
import { RdDTimestamp } from "./time/rdd-timestamp.js";
|
||||
import { RdDRaretes } from "./item/raretes.js";
|
||||
import { VOIES_DRACONIC } from "./item-sort.js";
|
||||
@@ -720,6 +721,20 @@ class _13_0_23_OmbreCategorieFalse extends Migration {
|
||||
}
|
||||
}
|
||||
|
||||
class _14_0_3_MigrationCompetenceBase extends Migration {
|
||||
get code() { return "competence-base-categorie" }
|
||||
get version() { return "14.0.3" }
|
||||
|
||||
async migrate() {
|
||||
await this.applyItemsUpdates(items => items
|
||||
.filter(it => it.type == ITEM_TYPES.competence
|
||||
&& it.system.categorie
|
||||
&& Number(it.system.base) == 0)
|
||||
.map(it => ({ _id: it.id, 'system.base': RdDItemCompetence.getNiveauBase(it.system.categorie, it.type) }))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export class Migrations {
|
||||
static getMigrations() {
|
||||
return [
|
||||
@@ -748,6 +763,7 @@ export class Migrations {
|
||||
new _13_0_21_AjoutAppreciation(),
|
||||
new _13_0_22_PoidsDesMonnaies(),
|
||||
new _13_0_23_OmbreCategorieFalse(),
|
||||
new _14_0_3_MigrationCompetenceBase(),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ export default class RdDModelCompetence extends foundry.abstract.TypeDataModel {
|
||||
{
|
||||
niveau: new fields.NumberField({ label: "Niveau", initial: 0, ...INTEGER_SIGNED, min: -11 }),
|
||||
default_diffLibre: new fields.NumberField({ label: "Difficulté libre par défaut", initial: 0, ...INTEGER_SIGNED, min: -10, max: 0 }),
|
||||
base: new fields.NumberField({ label: "Base", initial: 0, ...INTEGER }),
|
||||
base: new fields.NumberField({ label: "Base", initial: 0, ...INTEGER_SIGNED }),
|
||||
categorie: new fields.StringField({ label: "Catégorie", initial: "", ...STRING }),
|
||||
xp: new fields.NumberField({ label: "XP", initial: 0, ...INTEGER }),
|
||||
defaut_carac: new fields.StringField({ label: "Caractéristique par défaut", initial: "", ...STRING }),
|
||||
|
||||
Reference in New Issue
Block a user