From 5c01e545adada946a26176c5903dd45805153cb3 Mon Sep 17 00:00:00 2001 From: Chris Vickery Date: Tue, 13 Feb 2024 23:04:36 -0800 Subject: [PATCH] boss hints --- src/game/locations/index.tsx | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/game/locations/index.tsx b/src/game/locations/index.tsx index 31e008d..0822bf5 100644 --- a/src/game/locations/index.tsx +++ b/src/game/locations/index.tsx @@ -19,7 +19,9 @@ import { distance2d } from "src/helpers"; import { useMoveLocationMutation, MoveDirection, + useMonstersQuery, useTeleportMutation, + MonsterInstance, } from "src/generated/graphql"; import { Map } from "./map"; @@ -29,6 +31,15 @@ import { Camp } from "./camp"; import { SettlementManager } from "./settlement"; import { MapModal } from "./map-modal"; +const specialMonsterHints: { [x in string]: string } = { + "random-aberration-unholy-paladin": "The darkness here isn't natural", + "random-aberration-thornbrute": "The overgrowth here is hostile deadly", + "domari-aberration-1": "The ash in the air is so thick you can barely breath", + "random-aberration-moving-mountain": "The ground itself threatens you", +}; + +type PartialMonsterInstance = Pick; + export function Locations(): JSX.Element | null { const hero = useHero(); const [showSettlementManager, setIsShowingSettlement] = @@ -39,6 +50,13 @@ export function Locations(): JSX.Element | null { const [moveMutation, { loading }] = useMoveLocationMutation(); const [teleportMutation, { loading: teleportLoading }] = useTeleportMutation(); + const { data: monsters, refetch: refetchMonsters } = useMonstersQuery(); + + const hints = + monsters?.monsters?.map?.( + (monster: PartialMonsterInstance) => + specialMonsterHints[monster.monster.id] ?? "", + ) ?? []; const locationDetails = useLocation(); const specialLocation = useSpecialLocation(); @@ -82,6 +100,7 @@ export function Locations(): JSX.Element | null { direction, }, }); + refetchMonsters(); } catch (e: any) { if (e.graphQLErrors && e.graphQLErrors[0]?.extensions?.delay) { setDelay(e.graphQLErrors[0].extensions.remaining); @@ -96,6 +115,7 @@ export function Locations(): JSX.Element | null { y: teleportY, }, }); + refetchMonsters(); } catch (e: any) { if (e.graphQLErrors && e.graphQLErrors[0]?.extensions?.delay) { setDelay(e.graphQLErrors[0].extensions.remaining); @@ -288,6 +308,13 @@ export function Locations(): JSX.Element | null { {line} ))} + {hints + .filter((a) => !!a) + .map((hint) => ( + + {hint} + + ))} {/**/} {specialLocation?.type === "dock" && (