Files
vermine2047/module/documents/actor.mjs
T
uberwald 90de66d668
Release Creation / build (release) Failing after 1m28s
fix: Dice So Nice import v14 compat, override Foundry text colors for readability
- hooks.mjs: replace static dice-so-nice import with dynamic import
  using game.modules.get('dice-so-nice').id (path removed in v14)
- hooks.mjs: fix permission condition (|| -> &&), jQuery -> vanilla JS
- less/base.less: override --color-text-* and --button-text-color
  for both .themed.theme-dark (AppV2) and body.theme-dark (legacy apps)
- target #settings-config buttons + labels + hints for dark grays
2026-07-12 22:05:45 +02:00

113 lines
3.0 KiB
JavaScript

/**
* Extend the base Actor document by defining a custom roll data structure which is ideal for the Simple system.
* @extends {Actor}
*/
export default class VermineActor extends Actor {
/**
* @override
* Augment the basic actor data with additional dynamic data. Typically,
* you'll want to handle most of your calculated/derived data in this step.
* Data calculated in this step should generally not exist in template.json
* (such as ability modifiers rather than ability scores) and should be
* available both inside and outside of character sheets (such as if an actor
* is queried and has a roll executed directly from it).
*/
prepareDerivedData() {
super.prepareDerivedData();
const actorData = this;
const systemData = actorData.system;
const flags = actorData.flags.vermine2047 || {};
// Make separate methods for each Actor type (character, npc, etc.) to keep
// things organized.
switch (this.type) {
case "character":
this._prepareCharacterData(actorData);
break;
case "npc":
this._prepareNpcData(actorData);
break;
case "group":
this._prepareGroupData(actorData);
break;
case "creature":
this._prepareCreatureData(actorData);
break;
}
}
/**
* Prepare Character type specific data
*/
_prepareCharacterData(actorData) {
// Character derived data is computed by VermineCharacterData.prepareDerivedData()
}
/**
* Prepare NPC type specific data.
*/
_prepareNpcData(actorData) {
// NPC derived data is computed by VermineNpcData.prepareDerivedData()
}
/**
* Prepare Group type specific data.
*/
_prepareGroupData(actorData) {
// Group derived data is computed by VermineGroupData.prepareDerivedData()
}
/**
* Prepare Creature type specific data.
*/
_prepareCreatureData(actorData) {
// Creature derived data is computed by VermineCreatureData.prepareDerivedData()
}
/**
* Override getRollData() that's supplied to rolls.
*/
getRollData() {
const data = super.getRollData();
// Prepare character roll data.
this._getCharacterRollData(data);
this._getNpcRollData(data);
return data;
}
/**
* Prepare character roll data.
*/
_getCharacterRollData(data) {
if (this.type !== 'character') return;
// Copy the ability scores to the top level, so that rolls can use
// formulas like `@str.mod + 4`.
if (data.abilities) {
for (let [k, v] of Object.entries(data.abilities)) {
data[k] = foundry.utils.deepClone(v);
}
}
// Add level for easier access, or fall back to 0.
if (data.attributes.level) {
data.lvl = data.attributes.level.value ?? 0;
}
}
/**
* Prepare NPC roll data.
*/
_getNpcRollData(data) {
if (this.type !== 'npc') return;
// Process additional NPC data here.
}
// Character derived-data methods removed — handled by VermineCharacterData.prepareDerivedData()
}