Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/components/BonusesSidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { Collapse, ScrollArea, Stack, Text, Title, UnstyledButton } from "@mantine/core";
import {
Collapse,
ScrollArea,
Stack,
Text,
Title,
UnstyledButton,
} from "@mantine/core";
import { useState } from "react";
import { BOOSTERS } from "../data/boosters";
import { useGameStore } from "../store";
Expand Down
12 changes: 8 additions & 4 deletions src/engine/upgradeEngine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,12 @@ describe("computeAllGeneratorsCps", () => {
it("shows 100% for the only owned generator", () => {
const owned = { "test-upgrade": 4 };
const rows = computeAllGeneratorsCps([mockUpgrade, mockUpgrade2], owned);
const active = rows.find((r) => r.id === "test-upgrade")!;
const inactive = rows.find((r) => r.id === "test-upgrade-2")!;
const active = rows.find(
(r) => r.id === "test-upgrade",
) as (typeof rows)[0];
const inactive = rows.find(
(r) => r.id === "test-upgrade-2",
) as (typeof rows)[0];
expect(active.percentOfTotal).toBeCloseTo(100);
expect(inactive.percentOfTotal).toBeCloseTo(0);
});
Expand All @@ -450,8 +454,8 @@ describe("computeAllGeneratorsCps", () => {
it("percentages reflect each generator's share correctly", () => {
const owned = { "test-upgrade": 2, "test-upgrade-2": 1 };
const rows = computeAllGeneratorsCps([mockUpgrade, mockUpgrade2], owned);
const r1 = rows.find((r) => r.id === "test-upgrade")!;
const r2 = rows.find((r) => r.id === "test-upgrade-2")!;
const r1 = rows.find((r) => r.id === "test-upgrade") as (typeof rows)[0];
const r2 = rows.find((r) => r.id === "test-upgrade-2") as (typeof rows)[0];
// 3 / 8 * 100 = 37.5 and 5 / 8 * 100 = 62.5
expect(r1.percentOfTotal).toBeCloseTo(37.5, 1);
expect(r2.percentOfTotal).toBeCloseTo(62.5, 1);
Expand Down
Loading