Fix apv2, WIP

This commit is contained in:
2026-06-06 10:21:24 +02:00
parent 6cec1da910
commit 9b77a0c552
130 changed files with 12850 additions and 2830 deletions
+7
View File
@@ -0,0 +1,7 @@
/**
* Module de ré-export des classes de documents
* Compatible avec Foundry V2
*/
export { default as VermineActor } from "./actor.mjs";
export { default as VermineItem } from "./item.mjs";
+1 -38
View File
@@ -3,44 +3,7 @@
* Extend the base Actor document by defining a custom roll data structure which is ideal for the Simple system.
* @extends {Actor}
*/
export class VermineActor extends Actor {
/** @override */
prepareBaseData() {
// Data modifications in this step occur before processing embedded
// documents or derived data.
// Initialize wound data to prevent undefined errors with active effects
if (!this.system.minorWound) this.system.minorWound = { value: 0, min: 0, max: 5, threshold: 1 };
if (!this.system.majorWound) this.system.majorWound = { value: 0, min: 0, max: 4, threshold: 4 };
if (!this.system.deadlyWound) this.system.deadlyWound = { value: 0, min: 0, max: 2, threshold: 8 };
// Initialize combatStatus to prevent errors
if (!this.system.combatStatus) {
this.system.combatStatus = { difficulty: "9", label: "Passif" };
}
if (this.type == 'character') {
}
}
/** @override */
prepareEmbeddedDocuments() {
// Check if effects are already being applied in this preparation cycle
// In Foundry V11+, the parent prepareEmbeddedDocuments() calls applyActiveEffects()
// If this is called multiple times in the same cycle, we get the "phase already completed" error
const phase = this.effects?.applicationPhase;
// If we're already in the middle of applying effects (initial or final phase),
// don't call super as it would try to apply effects again
if (phase === "initial" || phase === "final") {
return;
}
// If effects haven't been applied yet, proceed normally
super.prepareEmbeddedDocuments();
}
export default class VermineActor extends Actor {
/**
* @override
+6 -13
View File
@@ -2,7 +2,7 @@
* Extend the basic Item with some very simple modifications.
* @extends {Item}
*/
export class VermineItem extends Item {
export default class VermineItem extends Item {
/**
* Augment the basic Item data model with additional dynamic data.
*/
@@ -15,8 +15,7 @@ export class VermineItem extends Item {
const actorType = (this.actor !== null) ? this.actor.type : 'character';
const itemType = this.type;
// Vérifie si une méthode spécifique au type existe// preparedData specifique au type
// Vérifie si une méthode spécifique au type existe
if (typeof this[`prepare${itemType.charAt(0).toUpperCase() + itemType.slice(1)}Data`] === 'function') {
this[`prepare${itemType.charAt(0).toUpperCase() + itemType.slice(1)}Data`]();
}
@@ -26,15 +25,14 @@ export class VermineItem extends Item {
this.damagedLabel = this.system.damages.state[parseInt(this.system.damages?.value) - 1];
switch (this.damagedLabel) {
case "endommagé":
this.damagedIcon = '<i class="fas fa-exclamation-circle" style:"color="yellow"></i>';
this.damagedIcon = '<i class="fas fa-exclamation-circle" style="color=yellow"></i>';
break;
case "défectueux":
this.damagedIcon = '<i class="fas fa-exclamation-triangle" style:"color="orange"></i>';
this.damagedIcon = '<i class="fas fa-exclamation-triangle" style="color=orange"></i>';
break;
case "hors d'usage":
this.damagedIcon = '<i class="fas fa-star-exclamation" style:"color="red"></i>';
this.damagedIcon = '<i class="fas fa-star-exclamation" style="color=red"></i>';
break;
}
}
}
@@ -44,11 +42,9 @@ export class VermineItem extends Item {
const actorType = (this.actor !== null) ? this.actor.type : 'character';
if (this.system.type == "") {
// console.log('je suis une capacité, avec pour sous-type', this.system.type, actorType);
this.system.type = actorType;
}
if (this.system.totem == "" && this.actor !== null && this.actor.system.identity.totem != "") {
// console.log('je suis une capacité, avec pour sous-type', this.system.type, actorType);
this.system.totem = this.actor.system.identity.totem;
}
}
@@ -79,16 +75,13 @@ export class VermineItem extends Item {
const rollMode = game.settings.get('core', 'rollMode');
const label = `[${item.type}] ${item.name}`;
// If there's no roll data, send a chat message.
let mess = {
speaker: speaker,
rollMode: rollMode,
flavor: label,
};
mess.content = await renderTemplate(`systems/vermine2047/templates/item/chatCards/${this.type}.hbs`, { item: this, message: mess }) ?? null;
mess.content = await foundry.applications.handlebars.renderTemplate(`systems/vermine2047/templates/item/chatCards/${this.type}.hbs`, { item: this, message: mess }) ?? null;
ChatMessage.create(mess)
}
}