forked from phenom/healer-man
Update Healer Man server
This commit is contained in:
1 parent
4fb7a0b9c8
commit
4c768fbec6
24 files changed
+654
-22
No files matched your search
@@ -129,6 +129,7 @@ function normalizeCharacterProfile(value: CharacterProfile): CharacterProfile {
|
||||
actionBindings?: unknown;
|
||||
experience?: unknown;
|
||||
talentRanks?: unknown;
|
||||
glyphIds?: unknown;
|
||||
level?: unknown;
|
||||
inventory?: unknown;
|
||||
equipment?: unknown;
|
||||
@@ -150,6 +151,11 @@ function normalizeCharacterProfile(value: CharacterProfile): CharacterProfile {
|
||||
.filter(([, rank]) => typeof rank === "number" && Number.isFinite(rank) && rank > 0)
|
||||
.map(([id, rank]) => [id, Math.floor(rank as number)]))
|
||||
: {};
|
||||
const glyphIds = Array.isArray(legacy.glyphIds)
|
||||
? [...new Set(legacy.glyphIds.filter((glyphId): glyphId is string => (
|
||||
typeof glyphId === "string" && glyphId.trim().length > 0
|
||||
)))]
|
||||
: [];
|
||||
const actionBindings = legacy.actionBindings && typeof legacy.actionBindings === "object" && !Array.isArray(legacy.actionBindings)
|
||||
? Object.fromEntries(Object.entries(legacy.actionBindings as Record<string, unknown>)
|
||||
.filter(([, abilityId]) => abilityId === null || typeof abilityId === "string")
|
||||
@@ -188,6 +194,7 @@ function normalizeCharacterProfile(value: CharacterProfile): CharacterProfile {
|
||||
level,
|
||||
experience,
|
||||
talentRanks,
|
||||
glyphIds,
|
||||
actionBindings,
|
||||
categoryId,
|
||||
specializationId,
|
||||
@@ -513,7 +520,7 @@ export function replaceCharactersForOwner(
|
||||
}
|
||||
|
||||
export function createCharacter(
|
||||
profile: Omit<CharacterProfile, "id" | "createdAt" | "lastPlayedAt" | "level" | "experience" | "talentRanks" | "actionBindings" | "inventory" | "equipment" | "manastormProgress" | "location" | "specializationId"> & {
|
||||
profile: Omit<CharacterProfile, "id" | "createdAt" | "lastPlayedAt" | "level" | "experience" | "talentRanks" | "glyphIds" | "actionBindings" | "inventory" | "equipment" | "manastormProgress" | "location" | "specializationId"> & {
|
||||
specializationId?: string | null;
|
||||
},
|
||||
storage: StorageLike | null = browserLocalStorage(),
|
||||
@@ -532,6 +539,7 @@ export function createCharacter(
|
||||
level: 1,
|
||||
experience: 0,
|
||||
talentRanks: {},
|
||||
glyphIds: [],
|
||||
actionBindings: {},
|
||||
inventory: [],
|
||||
equipment: {},
|
||||
@@ -565,7 +573,7 @@ export function touchCharacter(
|
||||
export function updateCharacterProgression(
|
||||
ownerId: string,
|
||||
characterId: string,
|
||||
progression: Pick<CharacterProfile, "level" | "experience" | "talentRanks">,
|
||||
progression: Pick<CharacterProfile, "level" | "experience" | "talentRanks"> & Partial<Pick<CharacterProfile, "glyphIds">>,
|
||||
storage: StorageLike | null = browserLocalStorage(),
|
||||
): CharacterProfile | null {
|
||||
if (!storage) return null;
|
||||
@@ -578,6 +586,9 @@ export function updateCharacterProgression(
|
||||
level: progression.level,
|
||||
experience: progression.experience,
|
||||
talentRanks: { ...progression.talentRanks },
|
||||
glyphIds: progression.glyphIds === undefined
|
||||
? [...(character.glyphIds ?? [])]
|
||||
: [...progression.glyphIds],
|
||||
});
|
||||
return updated;
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user