fix: race field type — string default in template, remove Array.isArray guards

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-04 22:46:20 +01:00
co-authored by Claude Sonnet 4.6
parent 25250dc98a
commit 61b18ca3fc
2 changed files with 4 additions and 7 deletions
+1 -1
View File
@@ -16,7 +16,7 @@
"ladAccount": false, "ladAccount": false,
"showingOff": 0 "showingOff": 0
}, },
"race": [], "race": "",
"training": [], "training": [],
"archetype": "", "archetype": "",
"attributes": { "attributes": {
+3 -6
View File
@@ -419,8 +419,7 @@ class ZeroEngineActorSheet extends foundry.appv1.sheets.ActorSheet {
context.drugAlerts = this._buildDrugAlerts(this.actor); context.drugAlerts = this._buildDrugAlerts(this.actor);
// EBB user detection — Ebon and Brain Waster are ebb users // EBB user detection — Ebon and Brain Waster are ebb users
const raceRaw = this.actor.system.race; const race = String(this.actor.system.race || "").toLowerCase();
const race = String(Array.isArray(raceRaw) ? (raceRaw[0] || "") : (raceRaw || "")).toLowerCase();
// Flat string versions for dropdown selected-state matching in templates // Flat string versions for dropdown selected-state matching in templates
context.raceStr = race; context.raceStr = race;
const trainingRaw = this.actor.system.training; const trainingRaw = this.actor.system.training;
@@ -7128,8 +7127,7 @@ const SLA_RACIAL_ABILITY_DATA = {
async function _ensureRacialAbilities(actor) { async function _ensureRacialAbilities(actor) {
if (!actor || actor.type !== "character") return; if (!actor || actor.type !== "character") return;
const raceRaw = actor.system?.race; const race = String(actor.system?.race || "")
const race = String(Array.isArray(raceRaw) ? (raceRaw[0] || "") : (raceRaw || ""))
.toLowerCase() .toLowerCase()
.replace(/[\s-]/g, "") .replace(/[\s-]/g, "")
.replace("313-s", "") .replace("313-s", "")
@@ -7189,8 +7187,7 @@ Hooks.once("ready", function() {
let count = 0; let count = 0;
for (const actor of game.actors ?? []) { for (const actor of game.actors ?? []) {
if (actor.type !== "character") continue; if (actor.type !== "character") continue;
const raceRaw = actor.system?.race; const race = String(actor.system?.race || "").toLowerCase();
const race = String(Array.isArray(raceRaw) ? (raceRaw[0] || "") : (raceRaw || "")).toLowerCase();
if (!race || race === "undefined") continue; if (!race || race === "undefined") continue;
const before = actor.items.filter(i => i.system?.category === "racial").length; const before = actor.items.filter(i => i.system?.category === "racial").length;
await _ensureRacialAbilities(actor); await _ensureRacialAbilities(actor);