Skip to content

Commit

Permalink
Show a clan dungeon tab with some basic info. More to come!
Browse files Browse the repository at this point in the history
  • Loading branch information
gausie committed Jul 18, 2023
1 parent 7c98be4 commit 163715d
Show file tree
Hide file tree
Showing 21 changed files with 489 additions and 240 deletions.
60 changes: 60 additions & 0 deletions packages/greenbox-data/data/items.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
export const specialItems = [
3138, // Hodgman's whackin' stick
3139, // Hodgman's imaginary hamster
3140, // old soft shoes
3246, // Ol' Scratch's ol' britches
3247, // Ol' Scratch's stovepipe hat
3248, // Ol' Scratch's ash can
3251, // Frosty's old silk hat
3252, // Frosty's carrot
3253, // Frosty's nailbat
3254, // Oscus's pelt
3255, // Wand of Oscus
3256, // Oscus's dumpster waders
3257, // Zombo's skullcap
3258, // Zombo's shield
3259, // Zombo's grievous greaves
3260, // Chester's moustache
3261, // Chester's bag of candy
3262, // Chester's cutoffs
3286, // Frosty's snowball sack
3310, // sealskin drum
3311, // washboard shield
3312, // spaghetti-box banjo
3313, // marinara jug
3314, // makeshift castanets
3315, // left-handed melodica
3328, // crumpled felt fedora
3329, // battered old top-hat
3330, // shapeless wide-brimmed hat
3331, // mostly rat-hide
3332, // hobo dungarees
3333, // old patched suit-pants
3334, // hobo stogie
3335, // rope with some soap on it
3380, // Ol' Scratch's infernal pitchfork
3381, // Ol' Scratch's stove door
3382, // Ol' Scratch's manacles
3383, // Chester's sunglasses
3384, // Chester's muscle shirt
3385, // Chester's Aquarius medallion
3386, // Zombo's shoulder blade
3387, // Zombo's skull ring
3388, // Zombo's empty eye
3389, // Frosty's arm
3390, // Staff of the Deepest Freeze
3391, // Frosty's iceball
3392, // Oscus's garbage can lid
3393, // Oscus's neverending soda
3394, // Oscus's flypaper pants
3395, // Hodgman's porkpie hat
3396, // Hodgman's lobsterskin pants
3397, // Hodgman's bow tie
3405, // Hodgman's lucky sock
3406, // Hodgman's varcolac paw
3407, // Hodgman's almanac
3408, // Hodgman's harmonica
3409, // Hodgman's garbage sticker
3410, // Hodgman's metal detector
3411, // Hodgman's cane
] as const;
4 changes: 4 additions & 0 deletions packages/greenbox-data/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import jsoncrush from "jsoncrush";

import { compressFamiliars, expandFamiliars, RawFamiliar } from "./familiars";
import { compressIotMs, expandIotMs, RawIotM } from "./iotms";
import { compressItems, expandItems, RawItem } from "./items";
import { compressMeta, expandMeta, Meta } from "./meta";
import { compressPaths, expandPaths, RawPath } from "./paths";
import { compressSkills, expandSkills, RawSkill } from "./skills";
Expand All @@ -26,6 +27,7 @@ export interface RawSnapshotData {
outfitTattoos: RawOutfitTattoo[];
paths: RawPath[];
iotms: RawIotM[];
items: RawItem[];
}

export type CompressedSnapshotData = { [key in keyof RawSnapshotData]: string };
Expand All @@ -39,6 +41,7 @@ export function compress(raw: RawSnapshotData): string {
outfitTattoos: compressOutfitTattoos(raw.outfitTattoos),
paths: compressPaths(raw.paths),
iotms: compressIotMs(raw.iotms),
items: compressItems(raw.items),
};

const compressedString = JSON.stringify(compressed);
Expand All @@ -57,5 +60,6 @@ export function expand(encoded: string): RawSnapshotData {
outfitTattoos: expandOutfitTattoos(compressed.outfitTattoos),
paths: expandPaths(compressed.paths),
iotms: expandIotMs(compressed.iotms),
items: expandItems(compressed.items),
};
}
20 changes: 20 additions & 0 deletions packages/greenbox-data/lib/items.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { specialItems } from "../data/items";

import { loadMafiaData } from "./utils";

export type ItemDef = {
Expand Down Expand Up @@ -27,3 +29,21 @@ export const loadItems = async (lastKnownSize: number) => {
data: raw.data.filter((p) => p.length > 2).map(parseItem),
};
};

export type RawItem = [id: number, quantity: number];

export const compressItems = (items: RawItem[]) => {
return items
.filter(([, q]) => q > 0)
.map(([id, q]) => `${id}${q > 1 ? `:${q}` : ""}`)
.sort()
.join(",");
};

export const expandItems = (s = "") =>
s.split(",").map((l) => {
const parts = l.split(":");
return [Number(parts[0]), parts[1] ? Number(parts[1]) : 1] as RawItem;
});

export { specialItems };
15 changes: 14 additions & 1 deletion packages/greenbox-script/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ const args = process.argv.slice(2);

const watch = args.some((a) => a === "--watch" || a === "-w");

const watchPlugin = {
name: "watch",
setup(build) {
if (!watch) return;
build.onEnd((result) => {
const date = new Date();
console.log(
`[${date.toISOString()}] Build ${result.errors.length ? "failed" : "succeeded"}.`,
);
});
},
};

const context = await esbuild.context({
entryPoints: {
greenbox: "src/greenbox.ts",
Expand All @@ -18,7 +31,7 @@ const context = await esbuild.context({
platform: "node",
target: "rhino1.7.14",
external: ["kolmafia"],
plugins: [babel()],
plugins: [babel(), watchPlugin],
outdir: "dist/scripts/greenbox",
loader: { ".json": "text" },
inject: ["./kolmafia-polyfill.js"],
Expand Down
24 changes: 21 additions & 3 deletions packages/greenbox-script/src/greenbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ import {
PathDef,
RawFamiliar,
RawIotM,
RawItem,
RawOutfitTattoo,
RawPath,
RawSkill,
RawTrophy,
SkillStatus,
specialItems,
TattooDef,
TattooStatus,
TrophyDef,
Expand Down Expand Up @@ -55,6 +57,21 @@ function checkIotMs(options: IotMOptions) {
);
}

/**
* Generates a list of items and ownership status.
* @returns array of 2-tuples of item id and status
*/

function checkItems(options: { force: number[] }) {
return specialItems.map(
(id) =>
[
id,
options.force.includes(id) || haveItem(Item.get(id)) ? ItemStatus.HAVE : ItemStatus.NONE,
] as RawItem,
);
}

/**
* Generates a list of all permable skills and their status.
* @returns list of 3-tuples of skill id, perm status and skill level, if any
Expand Down Expand Up @@ -255,8 +272,8 @@ function main(args = ""): void {

const tattoos = visitUrl("account_tattoos.php");

const forceIotMs = [];
if (hasFlag(args, "--force-florist")) forceIotMs.push(6413);
const forceItems = [];
if (hasFlag(args, "--force-florist")) forceItems.push(6413);

const code = compress({
meta: checkMeta(),
Expand All @@ -265,7 +282,8 @@ function main(args = ""): void {
trophies: checkTrophies(),
...checkTattoos(tattoos),
paths: checkPaths(tattoos),
iotms: checkIotMs({ force: forceIotMs }),
iotms: checkIotMs({ force: forceItems }),
items: checkItems({ force: forceItems }),
});

const link = `https://greenbox.loathers.net/?${keepPrivate ? `d=${code}` : `u=${myId()}`}`;
Expand Down
116 changes: 49 additions & 67 deletions packages/greenbox-web/src/components/DreadsylvaniaSkills.tsx
Original file line number Diff line number Diff line change
@@ -1,64 +1,16 @@
import {
Heading,
HStack,
Stack,
TableContainer,
Table,
Tbody,
Th,
Thead,
Td,
Tr,
} from "@chakra-ui/react";
import { SkillStatus } from "greenbox-data";
import { useMemo } from "react";

import { useAppSelector } from "../hooks";
import { createPlayerDataSelector } from "../store";
import { TableContainer, Table, Tbody, Th, Thead, Td, Tr } from "@chakra-ui/react";

import AlphaImage from "./AlphaImage";
import Skill from "./Skill";
import Subsection from "./Subsection";

function BlankCell() {
return <Td bg="chakra-border-color"></Td>;
}

const selectPlayerSkills = createPlayerDataSelector("skills");

export default function DreadsylvaniaSkills() {
const playerSkills = useAppSelector(selectPlayerSkills);
const skills = useAppSelector((state) => state.skills);
const dreadSkills = useMemo(
() =>
skills
.filter((s) => s.id >= 92 && s.id <= 106)
.reduce(
(acc, s) => ({ ...acc, [s.id]: s }),
{} as { [id: number]: (typeof skills)[number] },
),
[skills],
);
const idToSkill = useMemo(
() =>
playerSkills.reduce(
(acc, s) => ({ ...acc, [s[0]]: s }),
{} as { [id: number]: (typeof playerSkills)[number] },
),
[playerSkills],
);

const skillFor = (id: number) => (
<Skill skill={dreadSkills[id]} status={idToSkill[id]?.[1] ?? SkillStatus.NONE} />
);

return (
<Stack>
<HStack>
<AlphaImage src="itemimages/dv_skullcap.gif" />
<Heading as="h3" fontWeight="normal" fontSize="2xl">
The Machine
</Heading>
</HStack>
<Subsection title="The Machine" image="itemimages/dv_skullcap.gif">
<TableContainer>
<Table>
<Thead>
Expand All @@ -76,47 +28,77 @@ export default function DreadsylvaniaSkills() {
<Tbody>
<Tr>
<Th title="Turtle Tamer">TT</Th>
<Td padding={1}>{skillFor(92)}</Td>
<Td padding={1}>
<Skill id={92} />
</Td>
<BlankCell />
<BlankCell />
<BlankCell />
<BlankCell />
</Tr>
<Tr>
<Th title="Pastamancer">PA</Th>
<Td padding={1}>{skillFor(93)}</Td>
<Td padding={1}>{skillFor(97)}</Td>
<Td padding={1}>
<Skill id={93} />
</Td>
<Td padding={1}>
<Skill id={97} />
</Td>
<BlankCell />
<BlankCell />
<BlankCell />
</Tr>
<Tr>
<Th title="Sauceror">S</Th>
<Td padding={1}>{skillFor(94)}</Td>
<Td padding={1}>{skillFor(98)}</Td>
<Td padding={1}>{skillFor(101)}</Td>
<Td padding={1}>
<Skill id={94} />
</Td>
<Td padding={1}>
<Skill id={98} />
</Td>
<Td padding={1}>
<Skill id={101} />
</Td>
<BlankCell />
<BlankCell />
</Tr>
<Tr>
<Th title="Disco Bandit">DB</Th>
<Td padding={1}>{skillFor(95)}</Td>
<Td padding={1}>{skillFor(99)}</Td>
<Td padding={1}>{skillFor(102)}</Td>
<Td padding={1}>{skillFor(104)}</Td>
<Td padding={1}>
<Skill id={95} />
</Td>
<Td padding={1}>
<Skill id={99} />
</Td>
<Td padding={1}>
<Skill id={102} />
</Td>
<Td padding={1}>
<Skill id={104} />
</Td>
<BlankCell />
</Tr>
<Tr>
<Th title="Accordion Thief">AT</Th>
<Td padding={1}>{skillFor(96)}</Td>
<Td padding={1}>{skillFor(100)}</Td>
<Td padding={1}>{skillFor(103)}</Td>
<Td padding={1}>{skillFor(105)}</Td>
<Td padding={1}>{skillFor(106)}</Td>
<Td padding={1}>
<Skill id={96} />
</Td>
<Td padding={1}>
<Skill id={100} />
</Td>
<Td padding={1}>
<Skill id={103} />
</Td>
<Td padding={1}>
<Skill id={105} />
</Td>
<Td padding={1}>
<Skill id={106} />
</Td>
</Tr>
</Tbody>
</Table>
</TableContainer>
</Stack>
</Subsection>
);
}
Loading

0 comments on commit 163715d

Please sign in to comment.