2023-05-28 21:59:11 +02:00
|
|
|
|
|
|
|
export const XP_TOPIC = {
|
|
|
|
XP: { code: 'xp', label: 'xp' },
|
|
|
|
XPSORT: { code: 'xpsort', label: 'xp sort' },
|
|
|
|
NIVEAU: { code: 'niveau', label: 'Niveau' },
|
|
|
|
XPCARAC: { code: 'xpcarac', label: 'xp carac' },
|
|
|
|
CARAC: { code: 'carac', label: 'Carac' },
|
|
|
|
STRESS: { code: 'stress', label: 'Stress' },
|
|
|
|
TRANSFORM: { code: 'xps', label: 'Transformé' },
|
|
|
|
}
|
|
|
|
|
|
|
|
export class ExperienceLog {
|
|
|
|
|
|
|
|
static async add(actor, topic, from, to, raison, manuel = false) {
|
2024-03-09 23:12:13 +01:00
|
|
|
if (!actor.isPersonnageJoueur()) {
|
2023-05-28 21:59:11 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
if (from == to) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
const newXpLog = {
|
|
|
|
mode: topic?.code ?? topic,
|
|
|
|
raison: (manuel ? '(manuel) ' : '') + raison,
|
|
|
|
from: from,
|
|
|
|
to: to,
|
|
|
|
valeur: to - from,
|
|
|
|
daterdd: game.system.rdd.calendrier.dateCourante(),
|
|
|
|
datereel: game.system.rdd.calendrier.dateReel().replace('T', ' ')
|
|
|
|
};
|
|
|
|
console.log('ExperienceLog.add', newXpLog)
|
|
|
|
const newExperienceLog = (actor.system.experiencelog ?? []).concat([newXpLog]);
|
|
|
|
await actor.update({ [`system.experiencelog`]: newExperienceLog });
|
|
|
|
}
|
|
|
|
|
|
|
|
static labelTopic(topic) {
|
|
|
|
const xpt = Object.values(XP_TOPIC).find(it => it.code == topic);
|
|
|
|
return xpt?.label ?? xpt?.code ?? topic;
|
|
|
|
}
|
|
|
|
}
|