feat: initial prototype — core game systems (#30)
Security Scan and Upload / Security & DefectDojo Upload (push) Successful in 1m1s
CI / Lint, Build & Test (push) Successful in 1m6s

## Summary

This PR represents the full v1 prototype, implementing the core game systems for Elysium.

- Full idle/clicker RPG loop: resource collection, crafting, boss fights, exploration, and quests
- Adventurer hiring with batch size selector and progressive tier cost scaling
- Prestige, transcendence, and apotheosis systems with auto-prestige support
- Character sheet, titles, leaderboards, companion system, and daily login bonuses
- Auto-quest and auto-boss toggles
- Discord webhook notifications on prestige/transcendence/apotheosis
- Discord role awarded on apotheosis
- Responsive design and overarching story/lore system
- In-game sound effects and browser notifications for key events
- Support link button in the resource bar
- Full test coverage (100% on `apps/api` and `packages/types`)
- CI pipeline: lint → build → test

## Closes

Closes #1
Closes #2
Closes #3
Closes #4
Closes #5
Closes #6
Closes #7
Closes #8
Closes #9
Closes #10
Closes #11
Closes #12
Closes #13
Closes #14
Closes #16
Closes #19
Closes #20
Closes #21
Closes #22
Closes #23
Closes #24
Closes #25
Closes #26
Closes #27
Closes #29

 This issue was created with help from Hikari~ 🌸

Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com>
Reviewed-on: #30
Co-authored-by: Hikari <hikari@nhcarrigan.com>
Co-committed-by: Hikari <hikari@nhcarrigan.com>
This commit was merged in pull request #30.
This commit is contained in:
2026-03-08 15:53:39 -07:00
committed by Naomi Carrigan
parent c69e155de3
commit 29c817230d
172 changed files with 50706 additions and 0 deletions
+103
View File
@@ -0,0 +1,103 @@
/* eslint-disable max-lines-per-function -- Test suites naturally have many cases */
/* eslint-disable max-nested-callbacks -- Vitest structure requires nesting */
/**
* @file Tests for daily challenge progress utilities.
* @copyright nhcarrigan
* @license Naomi's Public License
* @author Naomi Carrigan
*/
import { describe, expect, it } from "vitest";
import { updateChallengeProgress } from "../src/utils/dailyChallenges.js";
import type { DailyChallengeState } from "@elysium/types";
const makeState = (overrides: Partial<DailyChallengeState> = {}): DailyChallengeState => ({
challenges: [],
lastResetDay: "2024-01-01",
...overrides,
});
describe("updateChallengeProgress", () => {
it("should return unchanged state when there are no challenges", () => {
const state = makeState();
const { crystalsAwarded, updatedChallenges } = updateChallengeProgress(state, "clicks", 10);
expect(crystalsAwarded).toBe(0);
expect(updatedChallenges.challenges).toHaveLength(0);
});
it("should skip challenges of a different type", () => {
const state = makeState({
challenges: [
{ completed: false, progress: 0, rewardCrystals: 5, target: 10, type: "gold_earned" },
],
});
const { crystalsAwarded, updatedChallenges } = updateChallengeProgress(state, "clicks", 5);
expect(crystalsAwarded).toBe(0);
expect(updatedChallenges.challenges[0].progress).toBe(0);
});
it("should skip already-completed challenges", () => {
const state = makeState({
challenges: [
{ completed: true, progress: 10, rewardCrystals: 5, target: 10, type: "clicks" },
],
});
const { crystalsAwarded, updatedChallenges } = updateChallengeProgress(state, "clicks", 5);
expect(crystalsAwarded).toBe(0);
expect(updatedChallenges.challenges[0].progress).toBe(10);
});
it("should increment progress without completing the challenge", () => {
const state = makeState({
challenges: [
{ completed: false, progress: 0, rewardCrystals: 5, target: 10, type: "clicks" },
],
});
const { crystalsAwarded, updatedChallenges } = updateChallengeProgress(state, "clicks", 4);
expect(crystalsAwarded).toBe(0);
expect(updatedChallenges.challenges[0].progress).toBe(4);
expect(updatedChallenges.challenges[0].completed).toBe(false);
});
it("should complete the challenge and award crystals when progress meets target", () => {
const state = makeState({
challenges: [
{ completed: false, progress: 8, rewardCrystals: 5, target: 10, type: "clicks" },
],
});
const { crystalsAwarded, updatedChallenges } = updateChallengeProgress(state, "clicks", 2);
expect(crystalsAwarded).toBe(5);
expect(updatedChallenges.challenges[0].completed).toBe(true);
expect(updatedChallenges.challenges[0].progress).toBe(10);
});
it("should cap progress at the target when amount overshoots", () => {
const state = makeState({
challenges: [
{ completed: false, progress: 0, rewardCrystals: 3, target: 10, type: "clicks" },
],
});
const { crystalsAwarded, updatedChallenges } = updateChallengeProgress(state, "clicks", 100);
expect(crystalsAwarded).toBe(3);
expect(updatedChallenges.challenges[0].progress).toBe(10);
expect(updatedChallenges.challenges[0].completed).toBe(true);
});
it("should accumulate crystals from multiple completed challenges", () => {
const state = makeState({
challenges: [
{ completed: false, progress: 0, rewardCrystals: 5, target: 10, type: "clicks" },
{ completed: false, progress: 0, rewardCrystals: 10, target: 10, type: "clicks" },
],
});
const { crystalsAwarded, updatedChallenges } = updateChallengeProgress(state, "clicks", 10);
expect(crystalsAwarded).toBe(15);
expect(updatedChallenges.challenges[0].completed).toBe(true);
expect(updatedChallenges.challenges[1].completed).toBe(true);
});
it("should preserve the lastResetDay from the original state", () => {
const state = makeState({ lastResetDay: "2024-06-15" });
const { updatedChallenges } = updateChallengeProgress(state, "clicks", 1);
expect(updatedChallenges.lastResetDay).toBe("2024-06-15");
});
});
+144
View File
@@ -0,0 +1,144 @@
/* eslint-disable max-lines -- Test suites naturally have many cases */
/* eslint-disable max-lines-per-function -- Test suites naturally have many cases */
/* eslint-disable max-nested-callbacks -- Vitest structure requires nesting */
/**
* @file Tests for number formatting utilities.
* @copyright nhcarrigan
* @license Naomi's Public License
* @author Naomi Carrigan
*/
import { describe, expect, it } from "vitest";
import { formatNumber } from "../src/utils/format.js";
describe("formatNumber", () => {
describe("edge cases", () => {
it("should return '0' for NaN", () => {
expect(formatNumber(Number.NaN)).toBe("0");
});
it("should return '0' for Infinity", () => {
expect(formatNumber(Infinity)).toBe("0");
});
it("should return '0' for -Infinity", () => {
expect(formatNumber(-Infinity)).toBe("0");
});
it("should format negative numbers with a leading minus sign", () => {
expect(formatNumber(-1000)).toBe("-1.00K");
});
it("should format zero as '0.00'", () => {
expect(formatNumber(0)).toBe("0.00");
});
it("should format small decimal values with two decimal places", () => {
expect(formatNumber(0.01)).toBe("0.01");
});
});
describe("suffix format (default)", () => {
it("should format small numbers with one decimal place", () => {
expect(formatNumber(999)).toBe("999.0");
});
it("should format thousands with K suffix", () => {
expect(formatNumber(1000)).toBe("1.00K");
});
it("should format millions with M suffix", () => {
expect(formatNumber(1_000_000)).toBe("1.00M");
});
it("should format billions with B suffix", () => {
expect(formatNumber(1_000_000_000)).toBe("1.00B");
});
it("should format trillions with T suffix", () => {
expect(formatNumber(1e12)).toBe("1.00T");
});
it("should format quadrillions with Qa suffix", () => {
expect(formatNumber(1e15)).toBe("1.00Qa");
});
it("should format quintillions with Qi suffix", () => {
expect(formatNumber(1e18)).toBe("1.00Qi");
});
it("should format sextillions with Sx suffix", () => {
expect(formatNumber(1e21)).toBe("1.00Sx");
});
it("should format septillions with Sp suffix", () => {
expect(formatNumber(1e24)).toBe("1.00Sp");
});
it("should format octillions with Oc suffix", () => {
expect(formatNumber(1e27)).toBe("1.00Oc");
});
it("should format nonillions with No suffix", () => {
expect(formatNumber(1e30)).toBe("1.00No");
});
it("should format decillions with Dc suffix", () => {
expect(formatNumber(1e33)).toBe("1.00Dc");
});
it("should format values >= 1e36 with letter suffix 'a'", () => {
expect(formatNumber(1e36)).toBe("1.00a");
});
it("should format values >= 1e39 with letter suffix 'b'", () => {
expect(formatNumber(1e39)).toBe("1.00b");
});
it("should format values at 26th letter step with 'z'", () => {
expect(formatNumber(1e36 * Math.pow(10, 25 * 3))).toBe("1.00z");
});
it("should format values at 27th letter step with 'aa'", () => {
expect(formatNumber(1e36 * Math.pow(10, 26 * 3))).toBe("1.00aa");
});
});
describe("scientific format", () => {
it("should fall back to suffix format below 1e6", () => {
expect(formatNumber(500, "scientific")).toBe("500.0");
});
it("should format values >= 1e6 in scientific notation", () => {
expect(formatNumber(1_230_000, "scientific")).toBe("1.23e6");
});
it("should format large values in scientific notation", () => {
expect(formatNumber(1e18, "scientific")).toBe("1.00e18");
});
});
describe("engineering format", () => {
it("should fall back to suffix format below 1e6", () => {
expect(formatNumber(500, "engineering")).toBe("500.0");
});
it("should format values >= 1e6 with exponent multiple of 3", () => {
expect(formatNumber(1_230_000, "engineering")).toBe("1.23E6");
});
it("should format 1e9 correctly in engineering notation", () => {
expect(formatNumber(1e9, "engineering")).toBe("1.00E9");
});
it("should format 12350000 correctly in engineering notation", () => {
expect(formatNumber(12_350_000, "engineering")).toBe("12.35E6");
});
});
describe("unknown format (default branch)", () => {
it("should fall back to suffix format for an unrecognised format string", () => {
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Testing unreachable default branch */
expect(formatNumber(1000, "unknown" as never)).toBe("1.00K");
});
});
});