Release Healer Man 0.1.4

This commit is contained in:
phenom
2026-08-18 12:06:04 -04:00
parent 5bb170039a
commit f4c9cf356c
63 changed files with 2694 additions and 81 deletions
+45 -5
View File
@@ -12,6 +12,11 @@ import {
import { normalizeInventory, type InventoryItem } from "../game/lootTypes";
import { normalizeEquipment, type EquipmentAssignments } from "../game/equipment";
import type { GameplaySettings } from "../game/combatStore";
import {
DEFAULT_COMBAT_PRESENTATION_SETTINGS,
normalizeCombatPresentationSettings,
type CombatPresentationSettings,
} from "../game/combatPresentation";
import {
createEmptyManastormProgress,
normalizeManastormProgress,
@@ -46,9 +51,10 @@ interface LocalAccount {
}
interface ProfileDatabase {
version: 2;
version: 3;
accounts: LocalAccount[];
rosters: Record<string, CharacterProfile[]>;
presentationSettingsByOwner: Record<string, CombatPresentationSettings>;
}
export interface AccountResult {
@@ -87,7 +93,7 @@ function browserSessionStorage(): StorageLike | null {
}
function emptyDatabase(): ProfileDatabase {
return { version: 2, accounts: [], rosters: {} };
return { version: 3, accounts: [], rosters: {}, presentationSettingsByOwner: {} };
}
function isCharacterProfile(value: unknown): value is CharacterProfile {
@@ -178,8 +184,9 @@ function readDatabase(storage: StorageLike | null = browserLocalStorage()): Prof
version?: number;
accounts?: unknown;
rosters?: unknown;
presentationSettingsByOwner?: unknown;
}) | null;
if (!parsed || (parsed.version !== 1 && parsed.version !== 2) || !Array.isArray(parsed.accounts) || !parsed.rosters || typeof parsed.rosters !== "object") {
if (!parsed || ![1, 2, 3].includes(parsed.version ?? 0) || !Array.isArray(parsed.accounts) || !parsed.rosters || typeof parsed.rosters !== "object") {
return emptyDatabase();
}
const accounts = parsed.accounts.filter((account): account is LocalAccount => Boolean(
@@ -197,8 +204,19 @@ function readDatabase(storage: StorageLike | null = browserLocalStorage()): Prof
? roster.filter(isCharacterProfile).map(normalizeCharacterProfile).slice(0, MAX_CHARACTERS)
: [],
]));
const database: ProfileDatabase = { version: 2, accounts, rosters };
if (parsed.version === 1) writeDatabase(database, storage);
const rawPresentationSettings = parsed.presentationSettingsByOwner
&& typeof parsed.presentationSettingsByOwner === "object"
&& !Array.isArray(parsed.presentationSettingsByOwner)
? parsed.presentationSettingsByOwner as Record<string, unknown>
: {};
const presentationSettingsByOwner = Object.fromEntries(
Object.entries(rawPresentationSettings).map(([ownerId, settings]) => [
ownerId,
normalizeCombatPresentationSettings(settings),
]),
);
const database: ProfileDatabase = { version: 3, accounts, rosters, presentationSettingsByOwner };
if (parsed.version !== 3) writeDatabase(database, storage);
return database;
} catch {
return emptyDatabase();
@@ -626,6 +644,28 @@ export function updateCharacterSettings(
return updated;
}
export function loadCombatPresentationSettings(
ownerId: string,
storage: StorageLike | null = browserLocalStorage(),
): CombatPresentationSettings {
if (!storage) return DEFAULT_COMBAT_PRESENTATION_SETTINGS;
return readDatabase(storage).presentationSettingsByOwner[ownerId]
?? DEFAULT_COMBAT_PRESENTATION_SETTINGS;
}
export function updateCombatPresentationSettings(
ownerId: string,
settings: CombatPresentationSettings,
storage: StorageLike | null = browserLocalStorage(),
): CombatPresentationSettings {
const normalized = normalizeCombatPresentationSettings(settings);
if (!storage) return normalized;
const database = readDatabase(storage);
database.presentationSettingsByOwner[ownerId] = normalized;
writeDatabase(database, storage);
return normalized;
}
export function updateCharacterManastormProgress(
ownerId: string,
characterId: string,