First iteration over items

This commit is contained in:
2025-11-06 23:30:37 +01:00
parent 6b883f8126
commit 4a9f026a2a
109 changed files with 1535 additions and 715 deletions
+39 -8
View File
@@ -25,6 +25,9 @@ Hooks.once("init", function () {
globalThis.prismRPG = game.system
game.system.CONST = SYSTEM
// Expose system configuration to CONFIG
CONFIG.PRISMRPG = SYSTEM
// Expose the system API
game.system.api = {
applications,
@@ -44,14 +47,16 @@ Hooks.once("init", function () {
CONFIG.Item.documentClass = documents.PrismRPGItem
CONFIG.Item.dataModels = {
skill: models.PrismRPGSkill,
gift: models.PrismRPGGift,
"racial-ability": models.PrismRPGRacialAbility,
weapon: models.PrismRPGWeapon,
armor: models.PrismRPGArmor,
shield: models.PrismRPGShield,
spell: models.PrismRPGSpell,
vulnerability: models.PrismRPGVulnerability,
// Vulnerability: models.PrismRPGVulnerability, // Disabled - Legacy from Lethal Fantasy
equipment: models.PrismRPGEquipment,
miracle: models.PrismRPGMiracle
// Miracle: models.PrismRPGMiracle // Disabled - Legacy from Lethal Fantasy, PRISM uses Divine class features instead
race: models.PrismRPGRace,
class: models.PrismRPGClass,
}
// Register sheet application classes
@@ -61,14 +66,16 @@ Hooks.once("init", function () {
foundry.documents.collections.Items.unregisterSheet("core", foundry.appv1.sheets.ActorSheet)
foundry.documents.collections.Items.registerSheet("prismRPG", applications.PrismRPGSkillSheet, { types: ["skill"], makeDefault: true })
foundry.documents.collections.Items.registerSheet("prismRPG", applications.PrismRPGGiftSheet, { types: ["gift"], makeDefault: true })
foundry.documents.collections.Items.registerSheet("prismRPG", applications.PrismRPGVulnerabilitySheet, { types: ["vulnerability"], makeDefault: true })
foundry.documents.collections.Items.registerSheet("prismRPG", applications.PrismRPGRacialAbilitySheet, { types: ["racial-ability"], makeDefault: true })
// Foundry.documents.collections.Items.registerSheet("prismRPG", applications.PrismRPGVulnerabilitySheet, { types: ["vulnerability"], makeDefault: true }) // Disabled - Legacy from Lethal Fantasy
foundry.documents.collections.Items.registerSheet("prismRPG", applications.PrismRPGWeaponSheet, { types: ["weapon"], makeDefault: true })
foundry.documents.collections.Items.registerSheet("prismRPG", applications.PrismRPGSpellSheet, { types: ["spell"], makeDefault: true })
foundry.documents.collections.Items.registerSheet("prismRPG", applications.PrismRPGArmorSheet, { types: ["armor"], makeDefault: true })
foundry.documents.collections.Items.registerSheet("prismRPG", applications.PrismRPGShieldSheet, { types: ["shield"], makeDefault: true })
foundry.documents.collections.Items.registerSheet("prismRPG", applications.PrismRPGEquipmentSheet, { types: ["equipment"], makeDefault: true })
foundry.documents.collections.Items.registerSheet("prismRPG", applications.PrismRPGMiracleSheet, { types: ["miracle"], makeDefault: true })
foundry.documents.collections.Items.registerSheet("prismRPG", applications.PrismRPGRaceSheet, { types: ["race"], makeDefault: true })
foundry.documents.collections.Items.registerSheet("prismRPG", applications.PrismRPGClassSheet, { types: ["class"], makeDefault: true })
// Foundry.documents.collections.Items.registerSheet("prismRPG", applications.PrismRPGMiracleSheet, { types: ["miracle"], makeDefault: true }) // Disabled - Legacy from Lethal Fantasy
// Other Document Configuration
CONFIG.ChatMessage.documentClass = documents.PrismRPGChatMessage
@@ -95,18 +102,42 @@ Hooks.once("init", function () {
})
/**
* Perform one-time configuration of system configuration objects.f
* Perform one-time pre-localization of system configuration objects.
*/
function preLocalizeConfig() {
const localizeConfigObject = (obj, keys) => {
for (let o of Object.values(obj)) {
for (let k of keys) {
o[k] = game.i18n.localize(o[k])
if (typeof o[k] === "string") {
o[k] = game.i18n.localize(o[k])
}
}
}
}
// Pre-localize choice objects that are displayed in forms
const choicesToLocalize = [
"CORE_SKILLS_CHOICES",
"SPELL_COLORS_CHOICES",
"SHIELD_TYPE_CHOICES",
"WEAPON_TYPE_CHOICES",
"WEAPON_GROUP_CHOICES"
]
for (const choice of choicesToLocalize) {
if (CONFIG.PRISMRPG[choice]) {
for (const [key, label] of Object.entries(CONFIG.PRISMRPG[choice])) {
CONFIG.PRISMRPG[choice][key] = game.i18n.localize(label)
}
}
}
}
Hooks.once("i18nInit", function () {
console.info("PRISM RPG | Localizing configuration")
preLocalizeConfig()
})
Hooks.once("ready", function () {
console.info("PRISM RPG | Ready")