Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
softy-dev authored Dec 5, 2024
2 parents 9df8a85 + 6f0e937 commit 46c1f21
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 44 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,25 +76,25 @@ Below are some incredible people that the website wouldn't be without today.
</a>
</td>
<td align="center">
<a href="https://github.com/TheLDB">
<img src="https://avatars.githubusercontent.com/u/29960599?v=4" width="100;" alt="TheLDB"/>
<a href="https://github.com/softy-dev">
<img src="https://avatars.githubusercontent.com/u/161766793?v=4" width="100;" alt="softy-dev"/>
<br />
<sub><b>Landon</b></sub>
<sub><b>Softy</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/brandonsaldan">
<img src="https://avatars.githubusercontent.com/u/26472557?v=4" width="100;" alt="brandonsaldan"/>
<a href="https://github.com/TheLDB">
<img src="https://avatars.githubusercontent.com/u/29960599?v=4" width="100;" alt="TheLDB"/>
<br />
<sub><b>Brandon Saldan</b></sub>
<sub><b>Landon</b></sub>
</a>
</td></tr>
<tr>
<td align="center">
<a href="https://github.com/nekosoffy">
<img src="https://avatars.githubusercontent.com/u/161766793?v=4" width="100;" alt="nekosoffy"/>
<a href="https://github.com/brandonsaldan">
<img src="https://avatars.githubusercontent.com/u/26472557?v=4" width="100;" alt="brandonsaldan"/>
<br />
<sub><b>Null</b></sub>
<sub><b>Brandon Saldan</b></sub>
</a>
</td>
<td align="center">
Expand Down
67 changes: 32 additions & 35 deletions src/pages/museum.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import achievements from "@/data/achievements.json";
import museum from "@/data/museum.json";

import { MuseumItem } from "@/types/items";
import { useEffect, useState } from "react";
import { useState, useMemo } from "react";

import { AchievementCard } from "@/components/cards/achievement-card";
import { BooleanCard } from "@/components/cards/boolean-card";
Expand All @@ -20,64 +20,61 @@ import {
import { usePlayers } from "@/contexts/players-context";
import { usePreferences } from "@/contexts/preferences-context";

const reqs: Record<string, number> = {
"A Complete Collection": Object.values(museum).flatMap((item) =>
Object.values(item),
).length,
"Treasure Trove": 40,
};

export default function Museum() {
const [open, setIsOpen] = useState(false);
const [museumArtifact, setMuseumArtifact] = useState<MuseumItem | null>(null);

const [_artifactFilter, setArtifactFilter] = useState("all");
const [_mineralFilter, setMineralFilter] = useState("all");

const [museumArtifactCollected, setMuseumArtifactCollected] = useState<
Set<string>
>(new Set());

const [museumMineralCollected, setMuseumMineralCollected] = useState<
Set<string>
>(new Set());

const { activePlayer } = usePlayers();
const { show, toggleShow } = usePreferences();

// unblur dialog
const [showPrompt, setPromptOpen] = useState(false);

useEffect(() => {
if (activePlayer) {
setMuseumArtifactCollected(
new Set(activePlayer?.museum?.artifacts ?? []),
);
setMuseumMineralCollected(new Set(activePlayer?.museum?.minerals ?? []));
}
}, [activePlayer]);
const [museumArtifactCollected, museumMineralCollected] = useMemo(
() => [
new Set<string>(activePlayer?.museum?.artifacts ?? []),
new Set<string>(activePlayer?.museum?.minerals ?? []),
],
[activePlayer],
);

const getAchievementProgress = (name: string) => {
let completed = false;
let additionalDescription = "";

if (!activePlayer || !activePlayer.museum)
return { completed, additionalDescription };

const collection =
museumArtifactCollected.size + museumMineralCollected.size;

if (name === "Treasure Trove") {
completed =
museumArtifactCollected.size + museumMineralCollected.size >= 40;
if (Object.hasOwn(reqs, name)) {
completed = collection >= reqs[name];
if (!completed) {
additionalDescription = ` - ${
40 - (museumArtifactCollected.size + museumMineralCollected.size)
} left`;
}
} else {
completed =
museumArtifactCollected.size + museumMineralCollected.size >= 95;
if (!completed) {
additionalDescription = ` - ${
95 - (museumArtifactCollected.size + museumMineralCollected.size)
} left`;
additionalDescription = ` - ${reqs[name] - collection} left`;
}
}

return { completed, additionalDescription };
};

const remainingDonations = {
artifacts:
Object.values(museum.artifacts).length - museumArtifactCollected.size,
minerals:
Object.values(museum.minerals).length - museumMineralCollected.size,
};

return (
<>
<Head>
Expand Down Expand Up @@ -152,13 +149,13 @@ export default function Museum() {
<FilterButton
target={"0"}
_filter={_artifactFilter}
title="Not Donated"
title={`Not Donated (${remainingDonations.artifacts})`}
setFilter={setArtifactFilter}
/>
<FilterButton
target={"2"}
_filter={_artifactFilter}
title="Donated"
title={`Donated (${museumArtifactCollected.size})`}
setFilter={setArtifactFilter}
/>
</div>
Expand Down Expand Up @@ -197,13 +194,13 @@ export default function Museum() {
<FilterButton
target={"0"}
_filter={_mineralFilter}
title="Not Donated"
title={`Not Donated (${remainingDonations.minerals})`}
setFilter={setMineralFilter}
/>
<FilterButton
target={"2"}
_filter={_mineralFilter}
title="Donated"
title={`Donated (${museumMineralCollected.size})`}
setFilter={setMineralFilter}
/>
</div>
Expand Down

0 comments on commit 46c1f21

Please sign in to comment.