Skip to content

Commit

Permalink
Fix course certificate linting.
Browse files Browse the repository at this point in the history
  • Loading branch information
phulin committed Aug 31, 2024
1 parent 846f9e0 commit 7d21ab0
Showing 1 changed file with 37 additions and 31 deletions.
68 changes: 37 additions & 31 deletions client/src/sections/resources/2023/SITCourseCertificate.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
import { Box, Text, VStack } from "@chakra-ui/react";
import { $item, $skill, get, have } from "libram";
import { useEffect } from "react";
import { Text } from "@chakra-ui/react";
import { myHash } from "kolmafia";
import { $skill, get, have } from "libram";
import { ReactNode, useMemo } from "react";

import Line from "../../../components/Line";
import Tile from "../../../components/Tile";
import { NagPriority } from "../../../contexts/NagContext";
import useNag from "../../../hooks/useNag";
import { haveUnrestricted } from "../../../util/available";

const SITCertificate = () => {
const sitCertificate = $item`S.I.T. Course Completion Certificate`;
const completedSITToday = get("_sitCourseCompleted");
const inRun = get("kingLiberated") === false;
const hash = myHash();

const psychogeologist = $skill`Psychogeologist`;
const insectologist = $skill`Insectologist`;
const cryptobotanist = $skill`Cryptobotanist`;
const havePsychogeologist = have($skill`Psychogeologist`);
const haveInsectologist = have($skill`Insectologist`);
const haveCryptobotanist = have($skill`Cryptobotanist`);

const hasAnySkill =
have(psychogeologist) || have(insectologist) || have(cryptobotanist);
havePsychogeologist || haveInsectologist || haveCryptobotanist;

const miscPhrases = [
"Don't play hooky!",
Expand All @@ -32,16 +31,27 @@ const SITCertificate = () => {
const randomPhrase =
miscPhrases[Math.floor(Math.random() * miscPhrases.length)];

let subtitle = "";
if (have(psychogeologist))
subtitle =
"You have ML; consider <Text as='b'>Insectology</Text>, for meat?";
if (have(insectologist))
subtitle =
"You have Meat; consider <Text as='b'>Psychogeology</Text>, for ML?";
if (have(cryptobotanist))
subtitle =
"You have Init; consider <Text as='b'>Insectology</Text>, for meat?";
const subtitle: ReactNode = useMemo(() => {
if (havePsychogeologist) {
return (
<>
You have ML; consider <Text as="b">Insectology</Text>, for meat?
</>
);
} else if (haveInsectologist) {
return (
<>
You have Meat; consider <Text as="b">Psychogeology</Text>, for ML?
</>
);
} else if (haveCryptobotanist) {
return (
<>
You have Init; consider <Text as="b">Insectology</Text>, for meat?
</>
);
} else return <></>;
}, [haveCryptobotanist, haveInsectologist, havePsychogeologist]);

useNag(
() => ({
Expand All @@ -50,30 +60,26 @@ const SITCertificate = () => {
<Tile
header="S.I.T. Course Enrollment"
imageUrl="/images/itemimages/certificate.gif"
href="inv_use.php?pwd=&which=3&whichitem=11116"
href={`inv_use.php?pwd${hash}=&which=3&whichitem=11116`}
>
{!hasAnySkill && (
<Line>
<Text color="red.500">
{randomPhrase} Take your S.I.T. course!
</Text>
</Line>
<Line color="red.500">{randomPhrase} Take your S.I.T. course!</Line>
)}
{hasAnySkill && inRun && (
<Line>
Try changing your S.I.T. course to accumulate different items.
</Line>
)}
{hasAnySkill && !inRun && (
<VStack align="start">
<Text>Could change your S.I.T. skill, for new items...</Text>
<Text>{subtitle}</Text>
</VStack>
<>
<Line>Could change your S.I.T. skill, for new items...</Line>
<Line>{subtitle}</Line>
</>
)}
</Tile>
),
}),
[hasAnySkill, inRun, subtitle],
[hasAnySkill, hash, inRun, randomPhrase, subtitle],
);

return null;
Expand Down

0 comments on commit 7d21ab0

Please sign in to comment.