From 9458d59dcc07a415f82e840b6070f60b9c1bf614 Mon Sep 17 00:00:00 2001 From: Oliver Grack Date: Tue, 20 Feb 2024 02:12:40 +0100 Subject: [PATCH] charm splits fixed --- src/app/run/[id]/_run_splits.tsx | 15 +++++--- src/app/run/[id]/_viewOptionsStore.tsx | 7 ++-- src/lib/viz/charms.ts | 3 +- src/lib/viz/player-data/enemies.ts | 4 ++- .../viz/recording-files/recording-splits.ts | 36 ++++++------------- 5 files changed, 28 insertions(+), 37 deletions(-) diff --git a/src/app/run/[id]/_run_splits.tsx b/src/app/run/[id]/_run_splits.tsx index 0012e755..b3f28c8f 100644 --- a/src/app/run/[id]/_run_splits.tsx +++ b/src/app/run/[id]/_run_splits.tsx @@ -2,11 +2,10 @@ import { Checkbox } from '@/components/ui/checkbox'; import { Table, TableBody, TableCell, TableRow } from '@/components/ui/table'; import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'; import { cn } from '@/lib/utils'; -import Image from 'next/image'; import { forwardRef, memo, useCallback, useEffect, useId, useMemo, useRef, type ReactNode } from 'react'; import { assertNever } from '~/lib/utils/utils'; import { - RecordingSplitGroups, + recordingSplitGroups, type RecordingSplit, type RecordingSplitGroup, } from '~/lib/viz/recording-files/recording-splits'; @@ -28,7 +27,15 @@ const RunSplitRow = memo( ) { let icon: ReactNode | undefined = undefined; if (split.imageUrl) { - icon = ; + // icon = ; + icon = ( +
+ ); } function handleClick() { @@ -124,7 +131,7 @@ export function RunSplits({ useViewOptionsStore }: Props) { <>
- {RecordingSplitGroups.map((group) => { + {recordingSplitGroups.map((group) => { const checked = visibleSplitGroups.includes(group.name); return (
diff --git a/src/app/run/[id]/_viewOptionsStore.tsx b/src/app/run/[id]/_viewOptionsStore.tsx index 44de272b..899350b6 100644 --- a/src/app/run/[id]/_viewOptionsStore.tsx +++ b/src/app/run/[id]/_viewOptionsStore.tsx @@ -3,10 +3,7 @@ import { create } from 'zustand'; import { combine } from 'zustand/middleware'; import { playerDataFields } from '~/lib/viz/player-data/player-data'; import { type CombinedRecording } from '~/lib/viz/recording-files/recording'; -import { - RecordingSplitGroup, - RecordingSplitGroups as recordingSplitGroups, -} from '~/lib/viz/recording-files/recording-splits'; +import { RecordingSplitGroup, recordingSplitGroups } from '~/lib/viz/recording-files/recording-splits'; import { type AggregatedRunData, type AggregationVariable } from '~/lib/viz/recording-files/run-aggregation-store'; export type RoomVisibility = 'all' | 'visited' | 'visited-animated'; @@ -42,7 +39,7 @@ function createViewOptionsStore() { extraChartsFollowAnimation: true, mainCardTab: 'overview' as MainCardTab, - visibleSplitGroups: recordingSplitGroups.map((it) => it.name), + visibleSplitGroups: recordingSplitGroups.filter((it) => it.defaultShown).map((it) => it.name), }, (set, get) => { function handleAnyAnimationVisiblityChanged() { diff --git a/src/lib/viz/charms.ts b/src/lib/viz/charms.ts index 93c08bf7..ca80f9a0 100644 --- a/src/lib/viz/charms.ts +++ b/src/lib/viz/charms.ts @@ -29,7 +29,8 @@ type GetCharmId = T extends `gotCharm_${infer N}` ? N : never; type CharmPlayerDataId = GetCharmId; function defaultHasCharm(charmId: CharmPlayerDataId): (frameEndEvent: FrameEndEvent) => boolean { - return (frameEndEvent) => frameEndEvent[`gotCharm_${charmId}`] === true; + const key = `gotCharm_${charmId}` as const; + return (frameEndEvent) => !!frameEndEvent[key]; } function defaultSpriteName(charmId: CharmPlayerDataId): string { diff --git a/src/lib/viz/player-data/enemies.ts b/src/lib/viz/player-data/enemies.ts index d5efafdd..ce5f0419 100644 --- a/src/lib/viz/player-data/enemies.ts +++ b/src/lib/viz/player-data/enemies.ts @@ -17,7 +17,7 @@ export const playerDataNameToDefeatedName: Record< lurien: { dreamer: 'Lurien', achievementSprite: 'Achievement_icon__0000_watcher' }, hegemol: { dreamer: 'Herrah', achievementSprite: 'Achievement_icon__0002_beast' }, monomon: { dreamer: 'Monomon', achievementSprite: 'Achievement_icon__0001_teacher' }, - zote: { enemy: 'Zote' }, + zote: undefined, // covered below { enemy: 'Zote' }, falseKnight: undefined, falseKnightDream: undefined, mawlek: undefined, @@ -85,6 +85,8 @@ const isBossOverrides: Partial> = { Worm: false, // Goam BigCentipede: false, // Garpede AbyssTendril: false, // Void Tendrils + LazyFlyer: false, // Aluba + BindingSeal: false, }; export function isEnemyBoss(enemy: EnemyInfo): boolean { diff --git a/src/lib/viz/recording-files/recording-splits.ts b/src/lib/viz/recording-files/recording-splits.ts index 91fe2a5f..1d775d81 100644 --- a/src/lib/viz/recording-files/recording-splits.ts +++ b/src/lib/viz/recording-files/recording-splits.ts @@ -1,34 +1,35 @@ import { assertNever } from '~/lib/utils/utils'; -import { charms, virtualCharms } from '../charms'; +import { virtualCharms } from '../charms'; import { enemiesJournalLang } from '../generated/lang-enemies-journal.generated'; import { enemies, isEnemyBoss, playerDataNameToDefeatedName, type EnemyInfo } from '../player-data/enemies'; import { - getCharmIdFromGotCharmField, getEnemyNameFromDefeatedField, getEnemyNameFromKilledField, isPlayerDataDefeatedField, - isPlayerDataGotCharmField, isPlayerDataKilledField, playerDataFields, } from '../player-data/player-data'; import { type CombinedRecording } from './recording'; -export const RecordingSplitGroups = [ +export const recordingSplitGroups = [ { name: 'boss', displayName: 'Bosses', + defaultShown: true, }, { name: 'dreamer', displayName: 'Dreamers', + defaultShown: true, }, { name: 'charmCollection', displayName: 'Charm pick ups', + defaultShown: false, }, ] as const; -export type RecordingSplitGroup = (typeof RecordingSplitGroups)[number]['name']; +export type RecordingSplitGroup = (typeof recordingSplitGroups)[number]['name']; export interface RecordingSplit { msIntoGame: number; @@ -131,37 +132,20 @@ export function createRecordingSplits(recording: CombinedRecording): RecordingSp } }); } - } else if (isPlayerDataGotCharmField(field)) { - const charmId = getCharmIdFromGotCharmField(field); - const charm = charms.byId[charmId]; - const charmName = charm?.name ?? `Charm ${charmId}`; - - recording.allPlayerDataEventsOfField(field).forEach((event) => { - if (event.value && !event.previousPlayerDataEventOfField?.value) { - splits.push({ - msIntoGame: event.msIntoGame, - title: `Got ${charmName}`, - tooltip: `Got ${charmName}`, - imageUrl: charm ? `/ingame-sprites/charms/${charm.spriteName}.png` : undefined, - group: 'charmCollection', - debugInfo: undefined, - }); - } - }); } } - for (const frameEndEvent of recording.frameEndEvents) { - for (const virtualCharm of virtualCharms) { + for (const virtualCharm of virtualCharms) { + for (const frameEndEvent of recording.frameEndEvents) { if ( virtualCharm.hasCharm(frameEndEvent) && - (!frameEndEvent.previousFrameEndEvent || virtualCharm.hasCharm(frameEndEvent.previousFrameEndEvent)) + (!frameEndEvent.previousFrameEndEvent || !virtualCharm.hasCharm(frameEndEvent.previousFrameEndEvent)) ) { splits.push({ msIntoGame: frameEndEvent.msIntoGame, title: `${virtualCharm.name}`, tooltip: `Got ${virtualCharm.name}`, - imageUrl: '/charms/' + virtualCharm.spriteName, + imageUrl: `/ingame-sprites/charms/${virtualCharm.spriteName}.png`, group: 'charmCollection', debugInfo: undefined, });