Corrections sur traits et fiches perso/creature
Release Creation / build (release) Successful in 8m45s
Release Creation / build (release) Successful in 8m45s
This commit is contained in:
@@ -26,3 +26,4 @@ export { default as MournbladeCYD2TraitEspeceSheet } from './mournblade-cyd2-tra
|
||||
export { default as MournbladeCYD2TraitDemoniaqueSheet } from './mournblade-cyd2-traitdemoniaque-sheet.mjs';
|
||||
export { default as MournbladeCYD2PouvoirElementaireSheet } from './mournblade-cyd2-pouvoirselementaire-sheet.mjs';
|
||||
export { default as MournbladeCYD2CapaciteAutomataSheet } from './mournblade-cyd2-capaciteautomata-sheet.mjs';
|
||||
export { default as MournbladeCYD2FaiblesseDemoniaqueSheet } from './mournblade-cyd2-faiblessedemoniaque-sheet.mjs';
|
||||
|
||||
@@ -143,6 +143,9 @@ export default class MournbladeCYD2ActorSheetV2 extends HandlebarsApplicationMix
|
||||
enrichedHabitat: await foundry.applications.ux.TextEditor.implementation.enrichHTML(
|
||||
actor.system.biodata?.habitat || "", { async: true }
|
||||
),
|
||||
enrichedGmnotes: await foundry.applications.ux.TextEditor.implementation.enrichHTML(
|
||||
actor.system.biodata?.gmnotes || "", { async: true }
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,10 @@ export default class MournbladeCYD2CreatureSheet extends MournbladeCYD2ActorShee
|
||||
context.talents = foundry.utils.duplicate(actor.getTalents?.() ?? []);
|
||||
context.traitsChaotiques = foundry.utils.duplicate(actor.getTraitsChaotiques?.() ?? []);
|
||||
context.traitsEspeces = foundry.utils.duplicate(actor.getTraitsEspeces?.() ?? []);
|
||||
context.traitsDemoniaques = foundry.utils.duplicate(actor.getItemsByType?.("traitdemoniaque") ?? []);
|
||||
context.faiblessesDemoniaques = foundry.utils.duplicate(actor.getFaiblessesDemoniaques?.() ?? []);
|
||||
context.pouvoirsElementaires = foundry.utils.duplicate(actor.getItemsByType?.("pouvoirselementaire") ?? []);
|
||||
context.capacitesAutomata = foundry.utils.duplicate(actor.getItemsByType?.("capaciteautomata") ?? []);
|
||||
context.protectionTotal = actor.getProtectionTotal?.() ?? 0;
|
||||
context.adversiteTotal = (actor.system.adversite?.bleue || 0) + (actor.system.adversite?.rouge || 0) + (actor.system.adversite?.noire || 0);
|
||||
|
||||
|
||||
@@ -24,6 +24,9 @@ export default class MournbladeCYD2DonSheet extends MournbladeCYD2ItemSheetV2 {
|
||||
const context = await super._prepareContext();
|
||||
context.owner = this.document.isOwner;
|
||||
context.editable = this.isEditable;
|
||||
context.enrichedSacrifice = await foundry.applications.ux.TextEditor.implementation.enrichHTML(
|
||||
this.document.system.sacrifice || "", { async: true }
|
||||
);
|
||||
return context;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import MournbladeCYD2ItemSheetV2 from "./base-item-sheet.mjs";
|
||||
|
||||
export default class MournbladeCYD2FaiblesseDemoniaqueSheet extends MournbladeCYD2ItemSheetV2 {
|
||||
|
||||
/** @override */
|
||||
static DEFAULT_OPTIONS = {
|
||||
...super.DEFAULT_OPTIONS,
|
||||
classes: [...super.DEFAULT_OPTIONS.classes, "faiblessedemoniaque"],
|
||||
window: {
|
||||
...super.DEFAULT_OPTIONS.window,
|
||||
title: "SHEETS.Item.faiblessedemoniaque",
|
||||
},
|
||||
};
|
||||
|
||||
/** @override */
|
||||
static PARTS = {
|
||||
main: {
|
||||
template: "systems/fvtt-mournblade-cyd-2-0/templates/item-faiblessedemoniaque-sheet.hbs",
|
||||
},
|
||||
};
|
||||
|
||||
/** @override */
|
||||
async _prepareContext() {
|
||||
const context = await super._prepareContext();
|
||||
return context;
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,10 @@ export default class MournbladeCYD2PersonnageSheet extends MournbladeCYD2ActorSh
|
||||
context.runes = foundry.utils.duplicate(actor.getRunes?.() ?? []);
|
||||
context.traitsChaotiques = foundry.utils.duplicate(actor.getTraitsChaotiques?.() ?? []);
|
||||
context.traitsEspeces = foundry.utils.duplicate(actor.getTraitsEspeces?.() ?? []);
|
||||
context.traitsDemoniaques = foundry.utils.duplicate(actor.getItemsByType?.("traitdemoniaque") ?? []);
|
||||
context.faiblessesDemoniaques = foundry.utils.duplicate(actor.getFaiblessesDemoniaques?.() ?? []);
|
||||
context.pouvoirsElementaires = foundry.utils.duplicate(actor.getItemsByType?.("pouvoirselementaire") ?? []);
|
||||
context.capacitesAutomata = foundry.utils.duplicate(actor.getItemsByType?.("capaciteautomata") ?? []);
|
||||
context.profil = actor.getProfil?.() ?? null;
|
||||
context.historiques = foundry.utils.duplicate(actor.getHistoriques?.() ?? []);
|
||||
context.combat = actor.getCombatValues?.() ?? {};
|
||||
@@ -58,27 +62,19 @@ export default class MournbladeCYD2PersonnageSheet extends MournbladeCYD2ActorSh
|
||||
context.richesse = actor.computeRichesse?.() ?? { po: 0, pa: 0, sc: 0, valueSC: 0 };
|
||||
context.valeurEquipement = actor.computeValeurEquipement?.() ?? { po: 0, pa: 0, sc: 0, valueSC: 0 };
|
||||
|
||||
// Prepare sorcellerie linked actors for display
|
||||
context.creaturesInvoqueesActors = await this._getLinkedActors(actor.system.sorcellerie.creaturesinvoquees);
|
||||
context.demonsLiesActors = await this._getLinkedActors(actor.system.sorcellerie.demonslies);
|
||||
context.enchantementsActors = await this._getLinkedActors(actor.system.sorcellerie.enchantements);
|
||||
|
||||
// Prepare enriched HTML for sorcellerie fields
|
||||
context.enrichedInvocationsEnCours = await foundry.applications.ux.TextEditor.implementation.enrichHTML(
|
||||
actor.system.sorcellerie?.invocationsencours || "", { async: true }
|
||||
);
|
||||
|
||||
// Linked creatures for invocation section
|
||||
context.creaturesInvoqueesActors = await this._getLinkedActors(actor.system.sorcellerie.creaturesinvoquees);
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get actor objects from UUID references
|
||||
* @param {string[]} uuids - Array of actor UUIDs
|
||||
* @returns {Promise<Actor[]>} Array of actor documents
|
||||
*/
|
||||
async _getLinkedActors(uuids) {
|
||||
if (!uuids || !Array.isArray(uuids) || uuids.length === 0) return [];
|
||||
|
||||
const actors = [];
|
||||
for (const uuid of uuids) {
|
||||
const actor = await fromUuid(uuid);
|
||||
@@ -89,98 +85,45 @@ export default class MournbladeCYD2PersonnageSheet extends MournbladeCYD2ActorSh
|
||||
return actors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle actor drop on the sheet
|
||||
* @override
|
||||
*/
|
||||
async _onDropActor(event, data) {
|
||||
if (!this.document.isOwner) return;
|
||||
|
||||
const droppedActor = await Actor.fromDropData(data);
|
||||
if (!droppedActor) return;
|
||||
|
||||
// Only allow dropping Creature type actors
|
||||
if (droppedActor.type !== 'creature') return;
|
||||
|
||||
// Determine which list to add to based on creature subtype
|
||||
let fieldPath = '';
|
||||
const subType = droppedActor.system.soustype || 'creature';
|
||||
|
||||
switch (subType) {
|
||||
case 'demon':
|
||||
fieldPath = 'system.sorcellerie.demonslies';
|
||||
break;
|
||||
case 'automata':
|
||||
fieldPath = 'system.sorcellerie.enchantements';
|
||||
break;
|
||||
case 'creature':
|
||||
default:
|
||||
fieldPath = 'system.sorcellerie.creaturesinvoquees';
|
||||
break;
|
||||
const uuids = this.document.system.sorcellerie.creaturesinvoquees || [];
|
||||
if (!uuids.includes(droppedActor.uuid)) {
|
||||
uuids.push(droppedActor.uuid);
|
||||
await this.document.update({ "system.sorcellerie.creaturesinvoquees": uuids });
|
||||
}
|
||||
|
||||
// Add the actor UUID to the appropriate array
|
||||
const currentValue = foundry.utils.getProperty(this.document.system, fieldPath) || [];
|
||||
|
||||
// Avoid duplicates
|
||||
if (!currentValue.includes(droppedActor.uuid)) {
|
||||
currentValue.push(droppedActor.uuid);
|
||||
await this.document.update({ [fieldPath]: currentValue });
|
||||
}
|
||||
|
||||
this.render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle removal of a linked actor from sorcellerie sections
|
||||
* @param {Event} event - The click event
|
||||
* @param {HTMLElement} target - The clicked element
|
||||
*/
|
||||
static async #onRemoveLinkedActor(event, target) {
|
||||
const li = target.closest(".item");
|
||||
if (!li) return;
|
||||
|
||||
const field = target.dataset.field;
|
||||
const uuid = target.dataset.uuid;
|
||||
|
||||
if (!field || !uuid) return;
|
||||
|
||||
const fieldPath = `system.sorcellerie.${field}`;
|
||||
const currentValue = foundry.utils.getProperty(this.document.system, fieldPath) || [];
|
||||
|
||||
// Remove the UUID from the array
|
||||
const newValue = currentValue.filter(u => u !== uuid);
|
||||
|
||||
await this.document.update({ [fieldPath]: newValue });
|
||||
if (!uuid) return;
|
||||
const currentValue = this.document.system.sorcellerie.creaturesinvoquees || [];
|
||||
await this.document.update({
|
||||
"system.sorcellerie.creaturesinvoquees": currentValue.filter(u => u !== uuid)
|
||||
});
|
||||
this.render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle click on linked actor name to open its sheet
|
||||
* @param {Event} event - The click event
|
||||
*/
|
||||
static async #onOpenLinkedActor(event) {
|
||||
const target = event.target.closest(".linked-actor-name");
|
||||
static async #onOpenInvocationActor(event) {
|
||||
const target = event.target.closest(".invocation-actor-link");
|
||||
if (!target) return;
|
||||
|
||||
const uuid = target.dataset.actorUuid;
|
||||
if (!uuid) return;
|
||||
|
||||
const actor = await fromUuid(uuid);
|
||||
if (actor) {
|
||||
actor.sheet.render(true);
|
||||
}
|
||||
if (actor) actor.sheet.render(true);
|
||||
}
|
||||
|
||||
/** @override */
|
||||
_onRender(context, options) {
|
||||
super._onRender(context, options);
|
||||
|
||||
// Add click handler for linked actor names
|
||||
this.element.querySelectorAll('.linked-actor-name').forEach(el => {
|
||||
this.element.querySelectorAll('.invocation-actor-link').forEach(el => {
|
||||
el.addEventListener('click', (event) => {
|
||||
event.preventDefault();
|
||||
this.constructor.#onOpenLinkedActor(event);
|
||||
this.constructor.#onOpenInvocationActor(event);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ export default class DonDataModel extends foundry.abstract.TypeDataModel {
|
||||
description: new fields.HTMLField({ initial: "" }),
|
||||
allegeance: new fields.StringField({ initial: "" }),
|
||||
prerequis: new fields.StringField({ initial: "" }),
|
||||
sacrifice: new fields.StringField({ initial: "" })
|
||||
sacrifice: new fields.HTMLField({ initial: "" })
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
export default class FaiblesseDemoniaqueDataModel extends foundry.abstract.TypeDataModel {
|
||||
static defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
return {
|
||||
description: new fields.HTMLField({ initial: "" }),
|
||||
bonusmalus: new fields.StringField({ initial: "" })
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ export { default as TraitEspeceDataModel } from './traitespece.mjs';
|
||||
export { default as TraitDemoniaqueDataModel } from './traitdemoniaque.mjs';
|
||||
export { default as PouvoirElementaireDataModel } from './pouvoirselementaire.mjs';
|
||||
export { default as CapaciteAutomataDataModel } from './capaciteautomata.mjs';
|
||||
export { default as FaiblesseDemoniaqueDataModel } from './faiblessedemoniaque.mjs';
|
||||
|
||||
// Modèles d'acteurs
|
||||
export { default as PersonnageDataModel } from './personnage.mjs';
|
||||
|
||||
@@ -157,6 +157,12 @@ export class MournbladeCYD2Actor extends Actor {
|
||||
getTraitsEspeces() {
|
||||
return this.getItemSorted(["traitespece"])
|
||||
}
|
||||
getItemsByType(type) {
|
||||
return this.getItemSorted([type])
|
||||
}
|
||||
getFaiblessesDemoniaques() {
|
||||
return this.getItemSorted(["faiblessedemoniaque"])
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getAspect() {
|
||||
|
||||
@@ -73,7 +73,8 @@ Hooks.once("init", async function () {
|
||||
traitespece: models.TraitEspeceDataModel,
|
||||
traitdemoniaque: models.TraitDemoniaqueDataModel,
|
||||
pouvoirselementaire: models.PouvoirElementaireDataModel,
|
||||
capaciteautomata: models.CapaciteAutomataDataModel
|
||||
capaciteautomata: models.CapaciteAutomataDataModel,
|
||||
faiblessedemoniaque: models.FaiblesseDemoniaqueDataModel
|
||||
}
|
||||
game.system.mournbladecyd2 = {
|
||||
MournbladeCYD2Utility,
|
||||
@@ -107,6 +108,7 @@ Hooks.once("init", async function () {
|
||||
foundry.documents.collections.Items.registerSheet("fvtt-mournblade-cyd-2-0", sheets.MournbladeCYD2TraitDemoniaqueSheet, { types: ["traitdemoniaque"], makeDefault: true });
|
||||
foundry.documents.collections.Items.registerSheet("fvtt-mournblade-cyd-2-0", sheets.MournbladeCYD2PouvoirElementaireSheet, { types: ["pouvoirselementaire"], makeDefault: true });
|
||||
foundry.documents.collections.Items.registerSheet("fvtt-mournblade-cyd-2-0", sheets.MournbladeCYD2CapaciteAutomataSheet, { types: ["capaciteautomata"], makeDefault: true });
|
||||
foundry.documents.collections.Items.registerSheet("fvtt-mournblade-cyd-2-0", sheets.MournbladeCYD2FaiblesseDemoniaqueSheet, { types: ["faiblessedemoniaque"], makeDefault: true });
|
||||
|
||||
MournbladeCYD2Utility.init()
|
||||
MournbladeCYD2Automation.init()
|
||||
|
||||
@@ -119,6 +119,7 @@ export class MournbladeCYD2Utility {
|
||||
traitdemoniaque: "Trait démoniaque",
|
||||
pouvoirselementaire: "Pouvoir élémentaire",
|
||||
capaciteautomata: "Capacité d'Automata",
|
||||
faiblessedemoniaque: "Faiblesse Démoniaque",
|
||||
runeeffect: "Effet de Rune"
|
||||
};
|
||||
return labels[type] || type;
|
||||
|
||||
Reference in New Issue
Block a user