Skip to content

Commit

Permalink
boss hints
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisinajar committed Feb 14, 2024
1 parent caaa351 commit 5c01e54
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/game/locations/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ import { distance2d } from "src/helpers";
import {
useMoveLocationMutation,
MoveDirection,
useMonstersQuery,
useTeleportMutation,
MonsterInstance,
} from "src/generated/graphql";

import { Map } from "./map";
Expand All @@ -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<MonsterInstance, "monster" | "id">;

export function Locations(): JSX.Element | null {
const hero = useHero();
const [showSettlementManager, setIsShowingSettlement] =
Expand All @@ -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();
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -288,6 +308,13 @@ export function Locations(): JSX.Element | null {
{line}
</Typography>
))}
{hints
.filter((a) => !!a)
.map((hint) => (
<Typography variant="body1" key={hint}>
{hint}
</Typography>
))}
{/*<MapModal />*/}
</Grid>
{specialLocation?.type === "dock" && (
Expand Down

0 comments on commit 5c01e54

Please sign in to comment.