Prepare for v10
This commit is contained in:
parent
87998801e3
commit
f64928858c
@ -48,21 +48,22 @@ export class RdDActorSheet extends ActorSheet {
|
||||
name: objectData.name,
|
||||
editable: this.isEditable,
|
||||
cssClass: this.isEditable ? "editable" : "locked",
|
||||
data: foundry.utils.deepClone(Misc.templateData(this.object)),
|
||||
data: foundry.utils.deepClone(this.object.system),
|
||||
effects: this.object.effects.map(e => foundry.utils.deepClone(e.data)),
|
||||
limited: this.object.limited,
|
||||
options: this.options,
|
||||
owner: this.document.isOwner,
|
||||
itemsByType: Misc.classify(this.object.items.map(i => foundry.utils.deepClone(i.data))),
|
||||
};
|
||||
console.log("ACTOR DATA:", formData)
|
||||
|
||||
RdDUtility.filterItemsPerTypeForSheet(formData);
|
||||
RdDUtility.filterItemsPerTypeForSheet(formData)
|
||||
|
||||
formData.options.isGM = game.user.isGM;
|
||||
|
||||
if (formData.type == 'creature') return formData; // Shortcut
|
||||
|
||||
formData.competenceByCategory = Misc.classify(formData.competences, it => it.data.categorie);
|
||||
formData.competenceByCategory = Misc.classify(formData.competences, it => it.system.categorie)
|
||||
|
||||
formData.calc = {
|
||||
comptageArchetype: RdDItemCompetence.computeResumeArchetype(formData.competences),
|
||||
@ -93,8 +94,8 @@ export class RdDActorSheet extends ActorSheet {
|
||||
formData.combat = duplicate(formData.armes ?? []);
|
||||
RdDItemArme.computeNiveauArmes(formData.combat, formData.competences);
|
||||
RdDItemArme.ajoutCorpsACorps(formData.combat, formData.competences, formData.data.carac);
|
||||
formData.esquives = this.actor.getCompetences("Esquive").map(i => foundry.utils.deepClone(i.data));
|
||||
formData.combat = RdDCombatManager.finalizeArmeList(formData.combat, formData.competences, formData.data.carac);
|
||||
formData.esquives = this.actor.getCompetences("Esquive").map(i => foundry.utils.deepClone(i.system))
|
||||
formData.combat = RdDCombatManager.finalizeArmeList(formData.combat, formData.competences, formData.data.carac)
|
||||
|
||||
this.armesList = formData.combat;
|
||||
|
||||
@ -118,7 +119,7 @@ export class RdDActorSheet extends ActorSheet {
|
||||
montures: this.actor.listeMontures(),
|
||||
suivants: this.actor.listeSuivants()
|
||||
}
|
||||
if (this.actor.getBestDraconic().data.niveau > -11 && !this.actor.isHautRevant()) {
|
||||
if (this.actor.getBestDraconic().system.niveau > -11 && !this.actor.isHautRevant()) {
|
||||
ui.notifications.error(`${this.actor.name} a des compétences draconiques, mais pas le don de Haut-Rêve!
|
||||
<br>Ajoutez-lui la tête "Don de Haut-Rêve" pour lui permettre d'utiliser ses compétences et d'accéder aux terres médianes du rêve`);
|
||||
}
|
||||
|
375
module/actor.js
375
module/actor.js
File diff suppressed because it is too large
Load Diff
@ -146,7 +146,7 @@ export class RdDItemCompetence extends Item {
|
||||
return competenceTroncs.map(
|
||||
list => list.map(name => RdDItemCompetence.findCompetence(competences, name))
|
||||
// calcul du coût xp jusqu'au niveau 0 maximum
|
||||
.map(it => RdDItemCompetence.computeDeltaXP(it?.data.base ?? -11, Math.min(it?.data.niveau ?? -11, 0)))
|
||||
.map(it => RdDItemCompetence.computeDeltaXP(it?.system.base ?? -11, Math.min(it?.system.niveau ?? -11, 0)))
|
||||
.sort(Misc.ascending())
|
||||
.splice(0, list.length - 1) // prendre toutes les valeurs sauf l'une des plus élevées
|
||||
.reduce(Misc.sum(), 0)
|
||||
|
@ -101,16 +101,16 @@ export class RdDItem extends Item {
|
||||
}
|
||||
|
||||
getEncTotal() {
|
||||
const itemData = Misc.data(this);
|
||||
return Number(itemData.data.encombrement ?? 0) * Number(itemData.data.quantite ?? 1);
|
||||
const itemData = this.system
|
||||
return Number(itemData.encombrement ?? 0) * Number(itemData.quantite ?? 1);
|
||||
}
|
||||
getEnc() {
|
||||
const itemData = Misc.data(this);
|
||||
const itemData = this.system
|
||||
switch (itemData.type) {
|
||||
case 'herbe':
|
||||
return encBrin;
|
||||
}
|
||||
return itemData.data.encombrement ?? 0;
|
||||
return itemData.encombrement ?? 0
|
||||
}
|
||||
|
||||
prepareDerivedData() {
|
||||
@ -138,7 +138,7 @@ export class RdDItem extends Item {
|
||||
}
|
||||
|
||||
_calculsEquipement() {
|
||||
const tplData = Misc.templateData(this);
|
||||
const tplData = this.system
|
||||
const quantite = this.isConteneur() ? 1 : (tplData.quantite ?? 0);
|
||||
const enc = this.getEnc();
|
||||
if (enc != undefined) {
|
||||
@ -150,15 +150,15 @@ export class RdDItem extends Item {
|
||||
}
|
||||
|
||||
getActionPrincipale(options = { warnIfNot: true }) {
|
||||
const itemData = Misc.data(this);
|
||||
if (!this.isConteneur() && (itemData.data.quantite ?? 0) <= 0) {
|
||||
const itemData = this.system
|
||||
if (!this.isConteneur() && (itemData.quantite ?? 0) <= 0) {
|
||||
if (options.warnIfNot) {
|
||||
ui.notifications.warn(`Vous n'avez plus de ${itemData.name}.`);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
switch (itemData.type) {
|
||||
case 'nourritureboisson': return itemData.data.boisson ? 'Boire' : 'Manger';
|
||||
case 'nourritureboisson': return itemData.boisson ? 'Boire' : 'Manger';
|
||||
case 'potion': return 'Boire';
|
||||
case 'livre': return 'Lire';
|
||||
case 'conteneur': return 'Ouvrir';
|
||||
@ -177,8 +177,8 @@ export class RdDItem extends Item {
|
||||
}
|
||||
|
||||
async quantiteIncDec(nombre, options = { diminuerQuantite: true, supprimerSiZero: false }) {
|
||||
const itemData = Misc.data(this);
|
||||
const quantite = Number(itemData.data.quantite ?? -1);
|
||||
const itemData = this.system
|
||||
const quantite = Number(itemData.quantite ?? -1);
|
||||
if (quantite >= 0) {
|
||||
const reste = Math.max(quantite + Number(nombre), 0);
|
||||
|
||||
@ -201,8 +201,8 @@ export class RdDItem extends Item {
|
||||
/* -------------------------------------------- */
|
||||
// détermine si deux équipements sont similaires: de même type, et avec les même champs hormis la quantité
|
||||
isEquipementSimilaire(other) {
|
||||
const itemData = Misc.data(this);
|
||||
const otherData = Misc.data(other);
|
||||
const itemData = this.system
|
||||
const otherData = other.data
|
||||
const tplData = Misc.templateData(this);
|
||||
const otherTplData = Misc.templateData(other);
|
||||
if (!this.isEquipement()) return false;
|
||||
|
@ -108,13 +108,14 @@ export class Misc {
|
||||
|
||||
static data(it) {
|
||||
if (it instanceof Actor || it instanceof Item || it instanceof Combatant) {
|
||||
return it.data;
|
||||
return it.system
|
||||
}
|
||||
return it;
|
||||
return it
|
||||
}
|
||||
|
||||
static templateData(it) {
|
||||
return Misc.data(it)?.data ?? {}
|
||||
return it.system ?? {}
|
||||
//return Misc.data(it)?.system ?? {}
|
||||
}
|
||||
|
||||
static getEntityTypeLabel(entity) {
|
||||
|
@ -155,12 +155,13 @@ export class RdDCombatManager extends Combat {
|
||||
// Gestion des armes 1/2 mains
|
||||
let armesEquipe = [];
|
||||
for (const arme of armes) {
|
||||
let armeData = duplicate(Misc.data(arme));
|
||||
let armeData = duplicate(arme)
|
||||
if (armeData.data.equipe) {
|
||||
let compData = competences.map(c => Misc.data(c)).find(c => c.name == armeData.data.competence);
|
||||
|
||||
armesEquipe.push(armeData);
|
||||
armesEquipe.push(armeData)
|
||||
armeData.data.dommagesReels = Number(armeData.data.dommages);
|
||||
console.log("ARME", armeData, compData)
|
||||
armeData.data.niveau = compData.data.niveau;
|
||||
armeData.data.initiative = RdDCombatManager.calculInitiative(compData.data.niveau, carac[compData.data.defaut_carac].value);
|
||||
// Dupliquer les armes pouvant être à 1 main et 2 mains en patchant la compétence
|
||||
|
@ -225,6 +225,7 @@ function registerUsageCount( registerKey ) {
|
||||
name: "Unique world key",
|
||||
scope: "world",
|
||||
config: false,
|
||||
value: "EMPTY",
|
||||
type: String
|
||||
});
|
||||
|
||||
@ -268,7 +269,7 @@ Hooks.once("ready", async function () {
|
||||
}
|
||||
if (Misc.isUniqueConnectedGM()) {
|
||||
messageDeBienvenue();
|
||||
registerUsageCount( SYSTEM_RDD );
|
||||
registerUsageCount( SYSTEM_RDD )
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -38,19 +38,18 @@ export class RdDRoll extends Dialog {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static _setDefaultOptions(actor, rollData) {
|
||||
const actorData = Misc.data(actor);
|
||||
let defaultRollData = {
|
||||
alias: actor.name,
|
||||
ajustementsConditions: CONFIG.RDD.ajustementsConditions,
|
||||
difficultesLibres: CONFIG.RDD.difficultesLibres,
|
||||
etat: actor.getEtatGeneral(),
|
||||
moral: actor.getMoralTotal(), /* La valeur du moral pour les jets de volonté */
|
||||
carac: actorData.data.carac,
|
||||
carac: actor.system.carac,
|
||||
finalLevel: 0,
|
||||
diffConditions: 0,
|
||||
diffLibre: rollData.competence?.data.default_diffLibre ?? 0,
|
||||
malusArmureValue: actor.getMalusArmure(),
|
||||
surencMalusFlag: actor.isPersonnage() ? (actorData.data.compteurs.surenc.value < 0) : false,
|
||||
surencMalusFlag: actor.isPersonnage() ? (actor.system.compteurs.surenc.value < 0) : false,
|
||||
surencMalusValue: actor.computeMalusSurEncombrement(),
|
||||
useMalusSurenc: false,
|
||||
useMoral: false, /* Est-ce que le joueur demande d'utiliser le moral ? Utile si le joueur change plusieurs fois de carac associée. */
|
||||
|
@ -29,9 +29,9 @@
|
||||
"url": "https://gitlab.com/LeRatierBretonnien/foundryvtt-reve-de-dragon/",
|
||||
"license": "LICENSE.txt",
|
||||
"flags": {},
|
||||
"version": "1.5.68",
|
||||
"minimumCoreVersion": "0.8.0",
|
||||
"compatibleCoreVersion": "9",
|
||||
"version": "10.0.0",
|
||||
"minimumCoreVersion": "10",
|
||||
"compatibleCoreVersion": "10",
|
||||
"scripts": [],
|
||||
"esmodules": [
|
||||
"module/rdd-main.js"
|
||||
|
Loading…
Reference in New Issue
Block a user