generated from nhcarrigan/template
Compare commits
44 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 58f411285c | |||
|
de5570b5fc
|
|||
|
133c81fefe
|
|||
|
1408e067b7
|
|||
| 666a5b2d6d | |||
|
9926e7f639
|
|||
| 6bf1ac5e7d | |||
| b48beef474 | |||
| 6e573bea14 | |||
|
790d35420f
|
|||
|
9f9edae45e
|
|||
|
a7a255dab6
|
|||
|
e92cf3c9a1
|
|||
|
26d30c271d
|
|||
| 34d07bec95 | |||
| 3ac1d566cb | |||
|
7bd6b2d3e3
|
|||
| 354b7e372e | |||
| dc1782bec9 | |||
| 635c630e49 | |||
| bb60ae3390 | |||
| ee47c1e8c9 | |||
| 2236d1dc9f | |||
|
621f594018
|
|||
| 1e845b14ce | |||
| 81ae1f18e1 | |||
| 0057cfeaaa | |||
| 161127dc21 | |||
| a8a465f293 | |||
| 79c4b99e8a | |||
| 3d114f63d7 | |||
| 911e089a9e | |||
| 14de87d765 | |||
| c4b4fba4c9 | |||
| d723656743 | |||
| 7e10757e68 | |||
| ca2edb090e | |||
| cfcf763ce3 | |||
| aede55a13d | |||
| 744cbf121f | |||
| 03b6c847b3 | |||
| 219d299e9f | |||
| 9e5b8ed972 | |||
|
a20cf3ef87
|
@@ -14,7 +14,7 @@ Game art is generated via the Gemini API (`gemini-3-pro-image-preview`, ~$0.134/
|
||||
### Process
|
||||
1. Generate images with `curl` to `https://generativelanguage.googleapis.com/v1beta/models/gemini-3-pro-image-preview:generateContent?key=<API_KEY>`, requesting soft-shaded anime style
|
||||
2. Save responses to `/home/naomi/code/naomi/elysium/img/<category>/<id>.jpg`
|
||||
3. Upload to R2 with: `AWS_ACCESS_KEY_ID=dd0a3d73969143ada84d50f8940cc5e2 AWS_SECRET_ACCESS_KEY=f73e9907da1b2297e93e17f786d6446d33d4ac60e185879578a0d5020899b18e aws s3 sync img/ s3://nhcarrigan-cdn/elysium/ --endpoint-url https://751c386661d378cc032093493cfb0869.r2.cloudflarestorage.com`
|
||||
3. Upload to R2 with the AWS CLI — credentials are in the global `~/.claude/CLAUDE.md` (never commit them here)
|
||||
4. Delete the local `img/` directory before committing (images live on CDN only)
|
||||
|
||||
### CDN URL Helper
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@elysium/api",
|
||||
"version": "0.1.1",
|
||||
"version": "0.4.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./prod/src/index.js",
|
||||
|
||||
@@ -35,6 +35,7 @@ model Player {
|
||||
lifetimeAchievementsUnlocked Float @default(0)
|
||||
lastLoginDate String?
|
||||
loginStreak Int @default(1)
|
||||
inGuild Boolean @default(false)
|
||||
}
|
||||
|
||||
model GameState {
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
DISCORD_CLIENT_ID="op://Environment Variables - Naomi/Elysium/discord client id"
|
||||
DISCORD_CLIENT_SECRET="op://Environment Variables - Naomi/Elysium/discord client secret"
|
||||
DISCORD_REDIRECT_URI="op://Environment Variables - Naomi/Elysium/discord redirect uri"
|
||||
JWT_SECRET="op://Environment Variables - Naomi/Elysium/jwt secret"
|
||||
DATABASE_URL="op://Environment Variables - Naomi/Elysium/mongo url"
|
||||
ANTI_CHEAT_SECRET="op://Environment Variables - Naomi/Elysium/anti cheat secret"
|
||||
@@ -8,6 +6,4 @@ PORT="op://Environment Variables - Naomi/Elysium/port"
|
||||
CORS_ORIGIN="op://Environment Variables - Naomi/Elysium/origin"
|
||||
DISCORD_MILESTONE_WEBHOOK="op://Environment Variables - Naomi/Elysium/discord milestone webhook"
|
||||
DISCORD_BOT_TOKEN="op://Environment Variables - Naomi/Elysium/discord bot token"
|
||||
DISCORD_GUILD_ID="op://Environment Variables - Naomi/Elysium/discord guild id"
|
||||
DISCORD_APOTHEOSIS_ROLE_ID="op://Environment Variables - Naomi/Elysium/discord apotheosis role id"
|
||||
LOG_TOKEN="op://Environment Variables - Naomi/Alert Server/api_auth"
|
||||
@@ -149,7 +149,7 @@ export const defaultAchievements: Array<Achievement> = [
|
||||
},
|
||||
{
|
||||
condition: { amount: 18, type: "bossesDefeated" },
|
||||
description: "Defeat all 18 bosses, including the Devourer of Worlds.",
|
||||
description: "Defeat the 18 bosses of the mortal realms.",
|
||||
icon: "🌟",
|
||||
id: "devourer_slayer",
|
||||
name: "World Saver",
|
||||
@@ -223,8 +223,8 @@ export const defaultAchievements: Array<Achievement> = [
|
||||
unlockedAt: null,
|
||||
},
|
||||
{
|
||||
condition: { amount: 40, type: "equipmentOwned" },
|
||||
description: "Own 40 pieces of equipment.",
|
||||
condition: { amount: 78, type: "equipmentOwned" },
|
||||
description: "Own all 78 pieces of equipment.",
|
||||
icon: "🛡️",
|
||||
id: "fully_equipped",
|
||||
name: "Fully Equipped",
|
||||
@@ -269,6 +269,33 @@ export const defaultAchievements: Array<Achievement> = [
|
||||
reward: { crystals: 50_000 },
|
||||
unlockedAt: null,
|
||||
},
|
||||
{
|
||||
condition: { amount: 1e30, type: "totalGoldEarned" },
|
||||
description: "Earn 1 nonillion gold in total.",
|
||||
icon: "🌌",
|
||||
id: "cosmic_wealthy",
|
||||
name: "Cosmic Wealthy",
|
||||
reward: { crystals: 100_000 },
|
||||
unlockedAt: null,
|
||||
},
|
||||
{
|
||||
condition: { amount: 1e60, type: "totalGoldEarned" },
|
||||
description: "Earn a vigintillion gold in total.",
|
||||
icon: "♾️",
|
||||
id: "infinite_hoarder",
|
||||
name: "Infinite Hoarder",
|
||||
reward: { crystals: 250_000 },
|
||||
unlockedAt: null,
|
||||
},
|
||||
{
|
||||
condition: { amount: 1e90, type: "totalGoldEarned" },
|
||||
description: "Earn a trigintillion gold in total.",
|
||||
icon: "🔮",
|
||||
id: "omniversal_tycoon",
|
||||
name: "Omniversal Tycoon",
|
||||
reward: { crystals: 1_000_000 },
|
||||
unlockedAt: null,
|
||||
},
|
||||
// Higher quest milestones
|
||||
{
|
||||
condition: { amount: 30, type: "questsCompleted" },
|
||||
@@ -289,8 +316,26 @@ export const defaultAchievements: Array<Achievement> = [
|
||||
unlockedAt: null,
|
||||
},
|
||||
{
|
||||
condition: { amount: 72, type: "questsCompleted" },
|
||||
description: "Complete all 72 quests across the known multiverse.",
|
||||
condition: { amount: 75, type: "questsCompleted" },
|
||||
description: "Complete 75 quests.",
|
||||
icon: "🌠",
|
||||
id: "quest_hero",
|
||||
name: "Quest Hero",
|
||||
reward: { crystals: 10_000 },
|
||||
unlockedAt: null,
|
||||
},
|
||||
{
|
||||
condition: { amount: 100, type: "questsCompleted" },
|
||||
description: "Complete 100 quests.",
|
||||
icon: "💫",
|
||||
id: "quest_legend",
|
||||
name: "Quest Legend",
|
||||
reward: { crystals: 15_000 },
|
||||
unlockedAt: null,
|
||||
},
|
||||
{
|
||||
condition: { amount: 112, type: "questsCompleted" },
|
||||
description: "Complete all 112 quests across the known multiverse.",
|
||||
icon: "🌌",
|
||||
id: "quest_eternal",
|
||||
name: "Quest Eternal",
|
||||
@@ -317,8 +362,17 @@ export const defaultAchievements: Array<Achievement> = [
|
||||
unlockedAt: null,
|
||||
},
|
||||
{
|
||||
condition: { amount: 60, type: "bossesDefeated" },
|
||||
description: "Defeat all 60 bosses across every plane of existence.",
|
||||
condition: { amount: 50, type: "bossesDefeated" },
|
||||
description: "Defeat 50 bosses.",
|
||||
icon: "⚡",
|
||||
id: "boss_legend",
|
||||
name: "Legendary Vanquisher",
|
||||
reward: { crystals: 15_000 },
|
||||
unlockedAt: null,
|
||||
},
|
||||
{
|
||||
condition: { amount: 72, type: "bossesDefeated" },
|
||||
description: "Defeat all 72 bosses across every plane of existence.",
|
||||
icon: "💀",
|
||||
id: "boss_eternal",
|
||||
name: "Eternal Vanquisher",
|
||||
@@ -363,4 +417,40 @@ export const defaultAchievements: Array<Achievement> = [
|
||||
reward: { crystals: 25_000 },
|
||||
unlockedAt: null,
|
||||
},
|
||||
{
|
||||
condition: { amount: 50, type: "prestigeCount" },
|
||||
description: "Prestige 50 times.",
|
||||
icon: "✨",
|
||||
id: "prestige_transcendent",
|
||||
name: "Transcendent",
|
||||
reward: { runestones: 100 },
|
||||
unlockedAt: null,
|
||||
},
|
||||
{
|
||||
condition: { amount: 100, type: "prestigeCount" },
|
||||
description: "Prestige 100 times.",
|
||||
icon: "💎",
|
||||
id: "prestige_eternal",
|
||||
name: "Eternal Looper",
|
||||
reward: { runestones: 500 },
|
||||
unlockedAt: null,
|
||||
},
|
||||
{
|
||||
condition: { amount: 150, type: "prestigeCount" },
|
||||
description: "Prestige 150 times.",
|
||||
icon: "🌟",
|
||||
id: "prestige_immortal",
|
||||
name: "Immortal Cycler",
|
||||
reward: { runestones: 2000 },
|
||||
unlockedAt: null,
|
||||
},
|
||||
{
|
||||
condition: { amount: 200, type: "prestigeCount" },
|
||||
description: "Prestige 200 times.",
|
||||
icon: "👑",
|
||||
id: "prestige_absolute",
|
||||
name: "Absolute Champion",
|
||||
reward: { runestones: 10_000 },
|
||||
unlockedAt: null,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -26,7 +26,7 @@ export const defaultAdventurers: Array<Adventurer> = [
|
||||
combatPower: 3,
|
||||
count: 0,
|
||||
essencePerSecond: 0,
|
||||
goldPerSecond: 0.5,
|
||||
goldPerSecond: 0.7,
|
||||
id: "militia",
|
||||
level: 2,
|
||||
name: "Militia",
|
||||
@@ -129,50 +129,62 @@ export const defaultAdventurers: Array<Adventurer> = [
|
||||
unlocked: false,
|
||||
},
|
||||
{
|
||||
baseCost: 4_000_000_000,
|
||||
class: "rogue",
|
||||
combatPower: 18_000,
|
||||
baseCost: 2_850_000_000,
|
||||
class: "mage",
|
||||
combatPower: 13_000,
|
||||
count: 0,
|
||||
essencePerSecond: 6,
|
||||
goldPerSecond: 5000,
|
||||
id: "shadow_assassin",
|
||||
level: 11,
|
||||
name: "Shadow Assassin",
|
||||
unlocked: false,
|
||||
},
|
||||
{
|
||||
baseCost: 28_000_000_000,
|
||||
class: "mage",
|
||||
combatPower: 45_000,
|
||||
count: 0,
|
||||
essencePerSecond: 15,
|
||||
goldPerSecond: 14_000,
|
||||
goldPerSecond: 4500,
|
||||
id: "arcane_scholar",
|
||||
level: 12,
|
||||
level: 11,
|
||||
name: "Arcane Scholar",
|
||||
unlocked: false,
|
||||
},
|
||||
{
|
||||
baseCost: 200_000_000_000,
|
||||
baseCost: 13_500_000_000,
|
||||
class: "rogue",
|
||||
combatPower: 28_000,
|
||||
count: 0,
|
||||
essencePerSecond: 11,
|
||||
goldPerSecond: 9500,
|
||||
id: "shadow_assassin",
|
||||
level: 12,
|
||||
name: "Shadow Assassin",
|
||||
unlocked: false,
|
||||
},
|
||||
{
|
||||
baseCost: 64_000_000_000,
|
||||
class: "paladin",
|
||||
combatPower: 60_000,
|
||||
count: 0,
|
||||
essencePerSecond: 20,
|
||||
goldPerSecond: 20_000,
|
||||
id: "dark_templar",
|
||||
level: 13,
|
||||
name: "Dark Templar",
|
||||
unlocked: false,
|
||||
},
|
||||
{
|
||||
baseCost: 300_000_000_000,
|
||||
class: "rogue",
|
||||
combatPower: 130_000,
|
||||
count: 0,
|
||||
essencePerSecond: 35,
|
||||
goldPerSecond: 40_000,
|
||||
id: "void_walker",
|
||||
level: 13,
|
||||
level: 14,
|
||||
name: "Void Walker",
|
||||
unlocked: false,
|
||||
},
|
||||
{
|
||||
baseCost: 1_400_000_000_000,
|
||||
baseCost: 1_800_000_000_000,
|
||||
class: "paladin",
|
||||
combatPower: 400_000,
|
||||
count: 0,
|
||||
essencePerSecond: 100,
|
||||
goldPerSecond: 120_000,
|
||||
id: "celestial_guard",
|
||||
level: 14,
|
||||
level: 15,
|
||||
name: "Celestial Guard",
|
||||
unlocked: false,
|
||||
},
|
||||
@@ -184,7 +196,7 @@ export const defaultAdventurers: Array<Adventurer> = [
|
||||
essencePerSecond: 300,
|
||||
goldPerSecond: 400_000,
|
||||
id: "divine_champion",
|
||||
level: 15,
|
||||
level: 16,
|
||||
name: "Divine Champion",
|
||||
unlocked: false,
|
||||
},
|
||||
@@ -196,7 +208,7 @@ export const defaultAdventurers: Array<Adventurer> = [
|
||||
essencePerSecond: 800,
|
||||
goldPerSecond: 1_200_000,
|
||||
id: "seraph_knight",
|
||||
level: 16,
|
||||
level: 17,
|
||||
name: "Seraph Knight",
|
||||
unlocked: false,
|
||||
},
|
||||
@@ -208,7 +220,7 @@ export const defaultAdventurers: Array<Adventurer> = [
|
||||
essencePerSecond: 2000,
|
||||
goldPerSecond: 3_500_000,
|
||||
id: "abyss_diver",
|
||||
level: 17,
|
||||
level: 18,
|
||||
name: "Abyss Diver",
|
||||
unlocked: false,
|
||||
},
|
||||
@@ -220,7 +232,7 @@ export const defaultAdventurers: Array<Adventurer> = [
|
||||
essencePerSecond: 5000,
|
||||
goldPerSecond: 10_000_000,
|
||||
id: "infernal_warden",
|
||||
level: 18,
|
||||
level: 19,
|
||||
name: "Infernal Warden",
|
||||
unlocked: false,
|
||||
},
|
||||
@@ -232,7 +244,7 @@ export const defaultAdventurers: Array<Adventurer> = [
|
||||
essencePerSecond: 12_000,
|
||||
goldPerSecond: 30_000_000,
|
||||
id: "crystal_sage",
|
||||
level: 19,
|
||||
level: 20,
|
||||
name: "Crystal Sage",
|
||||
unlocked: false,
|
||||
},
|
||||
@@ -244,7 +256,7 @@ export const defaultAdventurers: Array<Adventurer> = [
|
||||
essencePerSecond: 30_000,
|
||||
goldPerSecond: 90_000_000,
|
||||
id: "void_sentinel",
|
||||
level: 20,
|
||||
level: 21,
|
||||
name: "Void Sentinel",
|
||||
unlocked: false,
|
||||
},
|
||||
@@ -256,7 +268,7 @@ export const defaultAdventurers: Array<Adventurer> = [
|
||||
essencePerSecond: 80_000,
|
||||
goldPerSecond: 270_000_000,
|
||||
id: "eternal_champion",
|
||||
level: 21,
|
||||
level: 22,
|
||||
name: "Eternal Champion",
|
||||
unlocked: false,
|
||||
},
|
||||
@@ -268,7 +280,7 @@ export const defaultAdventurers: Array<Adventurer> = [
|
||||
essencePerSecond: 220_000,
|
||||
goldPerSecond: 800_000_000,
|
||||
id: "aether_weaver",
|
||||
level: 22,
|
||||
level: 23,
|
||||
name: "Aether Weaver",
|
||||
unlocked: false,
|
||||
},
|
||||
@@ -280,7 +292,7 @@ export const defaultAdventurers: Array<Adventurer> = [
|
||||
essencePerSecond: 600_000,
|
||||
goldPerSecond: 2_500_000_000,
|
||||
id: "titan_warrior",
|
||||
level: 23,
|
||||
level: 24,
|
||||
name: "Titan Warrior",
|
||||
unlocked: false,
|
||||
},
|
||||
@@ -292,7 +304,7 @@ export const defaultAdventurers: Array<Adventurer> = [
|
||||
essencePerSecond: 1_600_000,
|
||||
goldPerSecond: 7_500_000_000,
|
||||
id: "nexus_sage",
|
||||
level: 24,
|
||||
level: 25,
|
||||
name: "Nexus Sage",
|
||||
unlocked: false,
|
||||
},
|
||||
@@ -304,7 +316,7 @@ export const defaultAdventurers: Array<Adventurer> = [
|
||||
essencePerSecond: 4_500_000,
|
||||
goldPerSecond: 22_000_000_000,
|
||||
id: "cosmos_knight",
|
||||
level: 25,
|
||||
level: 26,
|
||||
name: "Cosmos Knight",
|
||||
unlocked: false,
|
||||
},
|
||||
@@ -316,7 +328,7 @@ export const defaultAdventurers: Array<Adventurer> = [
|
||||
essencePerSecond: 12_000_000,
|
||||
goldPerSecond: 65_000_000_000,
|
||||
id: "astral_sovereign",
|
||||
level: 26,
|
||||
level: 27,
|
||||
name: "Astral Sovereign",
|
||||
unlocked: false,
|
||||
},
|
||||
@@ -328,7 +340,7 @@ export const defaultAdventurers: Array<Adventurer> = [
|
||||
essencePerSecond: 35_000_000,
|
||||
goldPerSecond: 200_000_000_000,
|
||||
id: "primordial_mage",
|
||||
level: 27,
|
||||
level: 28,
|
||||
name: "Primordial Mage",
|
||||
unlocked: false,
|
||||
},
|
||||
@@ -340,7 +352,7 @@ export const defaultAdventurers: Array<Adventurer> = [
|
||||
essencePerSecond: 100_000_000,
|
||||
goldPerSecond: 600_000_000_000,
|
||||
id: "reality_warden",
|
||||
level: 28,
|
||||
level: 29,
|
||||
name: "Reality Warden",
|
||||
unlocked: false,
|
||||
},
|
||||
@@ -352,7 +364,7 @@ export const defaultAdventurers: Array<Adventurer> = [
|
||||
essencePerSecond: 300_000_000,
|
||||
goldPerSecond: 1_800_000_000_000,
|
||||
id: "infinity_ranger",
|
||||
level: 29,
|
||||
level: 30,
|
||||
name: "Infinity Ranger",
|
||||
unlocked: false,
|
||||
},
|
||||
@@ -364,7 +376,7 @@ export const defaultAdventurers: Array<Adventurer> = [
|
||||
essencePerSecond: 850_000_000,
|
||||
goldPerSecond: 5_500_000_000_000,
|
||||
id: "oblivion_paladin",
|
||||
level: 30,
|
||||
level: 31,
|
||||
name: "Oblivion Paladin",
|
||||
unlocked: false,
|
||||
},
|
||||
@@ -376,7 +388,7 @@ export const defaultAdventurers: Array<Adventurer> = [
|
||||
essencePerSecond: 2_500_000_000,
|
||||
goldPerSecond: 16_000_000_000_000,
|
||||
id: "transcendent_rogue",
|
||||
level: 31,
|
||||
level: 32,
|
||||
name: "Transcendent Rogue",
|
||||
unlocked: false,
|
||||
},
|
||||
@@ -388,7 +400,7 @@ export const defaultAdventurers: Array<Adventurer> = [
|
||||
essencePerSecond: 7_000_000_000,
|
||||
goldPerSecond: 50_000_000_000_000,
|
||||
id: "omniversal_champion",
|
||||
level: 32,
|
||||
level: 33,
|
||||
name: "Omniversal Champion",
|
||||
unlocked: false,
|
||||
},
|
||||
|
||||
+172
-172
File diff suppressed because it is too large
Load Diff
+174
-12
@@ -101,7 +101,7 @@ export const defaultEquipment: Array<Equipment> = [
|
||||
type: "weapon",
|
||||
},
|
||||
{
|
||||
bonus: { combatMultiplier: 2.75 },
|
||||
bonus: { combatMultiplier: 3.25 },
|
||||
cost: { crystals: 500, essence: 2000, gold: 0 },
|
||||
description:
|
||||
"A blade made of compressed nothingness. It does not cut — it simply unmakes.",
|
||||
@@ -204,7 +204,7 @@ export const defaultEquipment: Array<Equipment> = [
|
||||
type: "armour",
|
||||
},
|
||||
{
|
||||
bonus: { goldMultiplier: 2.25 },
|
||||
bonus: { goldMultiplier: 2.75 },
|
||||
description:
|
||||
"Woven from threads of pure starlight harvested by the Astral Wraith. Income flows like cosmic energy.",
|
||||
equipped: false,
|
||||
@@ -269,7 +269,7 @@ export const defaultEquipment: Array<Equipment> = [
|
||||
type: "trinket",
|
||||
},
|
||||
{
|
||||
bonus: { clickMultiplier: 1.55, goldMultiplier: 1.1 },
|
||||
bonus: { clickMultiplier: 1.65, goldMultiplier: 1.2 },
|
||||
description:
|
||||
"A fragment of the Mud Kraken's crystallised essence. Focuses raw power into devastating strikes.",
|
||||
equipped: false,
|
||||
@@ -305,9 +305,9 @@ export const defaultEquipment: Array<Equipment> = [
|
||||
type: "trinket",
|
||||
},
|
||||
{
|
||||
bonus: { clickMultiplier: 2, goldMultiplier: 1.25 },
|
||||
bonus: { clickMultiplier: 2.5, goldMultiplier: 1.4 },
|
||||
description:
|
||||
"The legendary stone that grants mastery over gold and combat alike.",
|
||||
"The legendary stone that transmutes effort into wealth — every action fills the coffers.",
|
||||
equipped: false,
|
||||
id: "philosophers_stone",
|
||||
name: "Philosopher's Stone",
|
||||
@@ -316,7 +316,7 @@ export const defaultEquipment: Array<Equipment> = [
|
||||
type: "trinket",
|
||||
},
|
||||
{
|
||||
bonus: { clickMultiplier: 2.25, goldMultiplier: 1.15 },
|
||||
bonus: { clickMultiplier: 2.25, combatMultiplier: 1.1, goldMultiplier: 1.25 },
|
||||
description:
|
||||
"A flame that has never been extinguished, sealed in crystal by the Phoenix Lord. It burns with the power of rebirth.",
|
||||
equipped: false,
|
||||
@@ -695,9 +695,171 @@ export const defaultEquipment: Array<Equipment> = [
|
||||
setId: "eternal_throne",
|
||||
type: "trinket",
|
||||
},
|
||||
// ── Primordial Chaos ──────────────────────────────────────────────────────
|
||||
{
|
||||
bonus: { goldMultiplier: 9 },
|
||||
description:
|
||||
"The Primordial Titan's carapace — formed before the concept of armour existed. It simply is what armour aspires to be.",
|
||||
equipped: false,
|
||||
id: "chaos_mantle",
|
||||
name: "The Chaos Mantle",
|
||||
owned: false,
|
||||
rarity: "legendary",
|
||||
setId: "primordial_chaos",
|
||||
type: "armour",
|
||||
},
|
||||
{
|
||||
bonus: { clickMultiplier: 5, combatMultiplier: 2, goldMultiplier: 2.5 },
|
||||
description:
|
||||
"The crystallised core of the Titan itself — the first stable thing to emerge from chaos. It radiates in every direction simultaneously.",
|
||||
equipped: false,
|
||||
id: "titan_core",
|
||||
name: "The Titan Core",
|
||||
owned: false,
|
||||
rarity: "legendary",
|
||||
setId: "primordial_chaos",
|
||||
type: "trinket",
|
||||
},
|
||||
// ── Infinite Expanse ──────────────────────────────────────────────────────
|
||||
{
|
||||
bonus: { combatMultiplier: 14 },
|
||||
description:
|
||||
"Forged from the Expanse Sovereign's own reach — a blade that has no beginning and no end, only edge.",
|
||||
equipped: false,
|
||||
id: "expanse_blade",
|
||||
name: "The Expanse Blade",
|
||||
owned: false,
|
||||
rarity: "legendary",
|
||||
setId: "infinite_expanse",
|
||||
type: "weapon",
|
||||
},
|
||||
{
|
||||
bonus: { goldMultiplier: 10 },
|
||||
description:
|
||||
"A second iteration of the void's armour — the first was not enough. This one has never been tested to its limit.",
|
||||
equipped: false,
|
||||
id: "void_armour_mk2",
|
||||
name: "Void Armour Mk. II",
|
||||
owned: false,
|
||||
rarity: "legendary",
|
||||
setId: "infinite_expanse",
|
||||
type: "armour",
|
||||
},
|
||||
// ── Reality Forge ─────────────────────────────────────────────────────────
|
||||
{
|
||||
bonus: { combatMultiplier: 16 },
|
||||
description:
|
||||
"The Reality Architect's primary instrument — a sword that does not cut through things but rewrites what they are.",
|
||||
equipped: false,
|
||||
id: "cosmos_blade",
|
||||
name: "The Cosmos Blade",
|
||||
owned: false,
|
||||
rarity: "legendary",
|
||||
setId: "reality_forge",
|
||||
type: "weapon",
|
||||
},
|
||||
{
|
||||
bonus: { goldMultiplier: 12 },
|
||||
description:
|
||||
"Plated from the substance of reality itself — wearing it makes you feel slightly more real than everything around you.",
|
||||
equipped: false,
|
||||
id: "reality_plate",
|
||||
name: "The Reality Plate",
|
||||
owned: false,
|
||||
rarity: "legendary",
|
||||
setId: "reality_forge",
|
||||
type: "armour",
|
||||
},
|
||||
// ── Cosmic Maelstrom ──────────────────────────────────────────────────────
|
||||
{
|
||||
bonus: { combatMultiplier: 18 },
|
||||
description:
|
||||
"Torn from the eye of the Cosmic Annihilator — a weapon that carries the force of an ending universe in every swing.",
|
||||
equipped: false,
|
||||
id: "maelstrom_edge",
|
||||
name: "The Maelstrom Edge",
|
||||
owned: false,
|
||||
rarity: "legendary",
|
||||
setId: "cosmic_maelstrom",
|
||||
type: "weapon",
|
||||
},
|
||||
{
|
||||
bonus: { goldMultiplier: 14 },
|
||||
description:
|
||||
"Armour that has weathered the destruction of countless realities. It has learned not to flinch.",
|
||||
equipped: false,
|
||||
id: "cosmic_plate",
|
||||
name: "The Cosmic Plate",
|
||||
owned: false,
|
||||
rarity: "legendary",
|
||||
setId: "cosmic_maelstrom",
|
||||
type: "armour",
|
||||
},
|
||||
// ── Primeval Sanctum ──────────────────────────────────────────────────────
|
||||
{
|
||||
bonus: { combatMultiplier: 22 },
|
||||
description:
|
||||
"The first weapon — older than the concept of war, older than the concept of a weapon. It remembers what it was made for.",
|
||||
equipped: false,
|
||||
id: "primeval_blade",
|
||||
name: "The Primeval Blade",
|
||||
owned: false,
|
||||
rarity: "legendary",
|
||||
setId: "primeval_sanctum",
|
||||
type: "weapon",
|
||||
},
|
||||
{
|
||||
bonus: { goldMultiplier: 17 },
|
||||
description:
|
||||
"The shield-form of the Primeval God — absolute protection from before the concept of harm existed.",
|
||||
equipped: false,
|
||||
id: "ancient_aegis",
|
||||
name: "The Ancient Aegis",
|
||||
owned: false,
|
||||
rarity: "legendary",
|
||||
setId: "primeval_sanctum",
|
||||
type: "armour",
|
||||
},
|
||||
// ── The Absolute ──────────────────────────────────────────────────────────
|
||||
{
|
||||
bonus: { combatMultiplier: 28 },
|
||||
description:
|
||||
"There is no name for what this was before it became a sword. There is no name for what it is now. It ends things.",
|
||||
equipped: false,
|
||||
id: "absolute_blade",
|
||||
name: "The Absolute Blade",
|
||||
owned: false,
|
||||
rarity: "legendary",
|
||||
setId: "the_absolute",
|
||||
type: "weapon",
|
||||
},
|
||||
{
|
||||
bonus: { goldMultiplier: 20 },
|
||||
description:
|
||||
"Eternity given the shape of armour — it has always existed, it will always exist, and it has always protected its wearer.",
|
||||
equipped: false,
|
||||
id: "eternity_plate",
|
||||
name: "The Eternity Plate",
|
||||
owned: false,
|
||||
rarity: "legendary",
|
||||
setId: "the_absolute",
|
||||
type: "armour",
|
||||
},
|
||||
{
|
||||
bonus: { clickMultiplier: 6, combatMultiplier: 3, goldMultiplier: 3 },
|
||||
description:
|
||||
"The heart of everything — a thing so fundamental that its removal from the Absolute One ended all things, briefly. Briefly.",
|
||||
equipped: false,
|
||||
id: "omniversal_core",
|
||||
name: "The Omniversal Core",
|
||||
owned: false,
|
||||
rarity: "legendary",
|
||||
setId: "the_absolute",
|
||||
type: "trinket",
|
||||
},
|
||||
// ── Purchasable endgame sinks ─────────────────────────────────────────────
|
||||
{
|
||||
bonus: { clickMultiplier: 2.5 },
|
||||
bonus: { clickMultiplier: 4.25 },
|
||||
cost: { crystals: 0, essence: 20_000_000, gold: 0 },
|
||||
description:
|
||||
"A lens of compressed celestial light that sharpens every strike with divine precision.",
|
||||
@@ -709,7 +871,7 @@ export const defaultEquipment: Array<Equipment> = [
|
||||
type: "trinket",
|
||||
},
|
||||
{
|
||||
bonus: { goldMultiplier: 3 },
|
||||
bonus: { goldMultiplier: 3.75 },
|
||||
cost: { crystals: 0, essence: 50_000_000, gold: 0 },
|
||||
description:
|
||||
"A book written in the language of the deep — reading it aligns your guild's operations with abyssal efficiency.",
|
||||
@@ -721,7 +883,7 @@ export const defaultEquipment: Array<Equipment> = [
|
||||
type: "armour",
|
||||
},
|
||||
{
|
||||
bonus: { combatMultiplier: 4 },
|
||||
bonus: { combatMultiplier: 10.5 },
|
||||
cost: { crystals: 0, essence: 100_000_000, gold: 0 },
|
||||
description:
|
||||
"A weapon that channels void energy — the absence of resistance makes every strike devastating.",
|
||||
@@ -733,7 +895,7 @@ export const defaultEquipment: Array<Equipment> = [
|
||||
type: "weapon",
|
||||
},
|
||||
{
|
||||
bonus: { clickMultiplier: 3.5, goldMultiplier: 1.5 },
|
||||
bonus: { clickMultiplier: 4, goldMultiplier: 1.5 },
|
||||
cost: { crystals: 5_000_000, essence: 0, gold: 0 },
|
||||
description:
|
||||
"A gem forged in the heart of the Infernal Court — it burns with productivity and righteous fury in equal measure.",
|
||||
@@ -745,7 +907,7 @@ export const defaultEquipment: Array<Equipment> = [
|
||||
type: "trinket",
|
||||
},
|
||||
{
|
||||
bonus: { goldMultiplier: 4 },
|
||||
bonus: { goldMultiplier: 7.5 },
|
||||
cost: { crystals: 20_000_000, essence: 0, gold: 0 },
|
||||
description:
|
||||
"Armour structured around a crystalline lattice of optimal income calculations. Every gold piece finds you faster.",
|
||||
@@ -757,7 +919,7 @@ export const defaultEquipment: Array<Equipment> = [
|
||||
type: "armour",
|
||||
},
|
||||
{
|
||||
bonus: { clickMultiplier: 5, combatMultiplier: 1.5, goldMultiplier: 2 },
|
||||
bonus: { clickMultiplier: 5, combatMultiplier: 3, goldMultiplier: 2.5 },
|
||||
cost: { crystals: 100_000_000, essence: 0, gold: 0 },
|
||||
description:
|
||||
"An artifact from beyond all known planes — it refracts power through all dimensions simultaneously.",
|
||||
|
||||
+144
-144
File diff suppressed because it is too large
Load Diff
@@ -92,20 +92,20 @@ export const defaultPrestigeUpgrades: Array<PrestigeUpgrade> = [
|
||||
{
|
||||
category: "income",
|
||||
description:
|
||||
"The oldest runes, carved before memory began, yield their secrets at last. All production ×500.",
|
||||
"The oldest runes, carved before memory began, yield their secrets at last. All production ×200.",
|
||||
id: "income_10",
|
||||
multiplier: 500,
|
||||
multiplier: 200,
|
||||
name: "Eternal Rune I",
|
||||
runestonesCost: 30_000,
|
||||
runestonesCost: 22_500,
|
||||
},
|
||||
{
|
||||
category: "income",
|
||||
description:
|
||||
"Eternal runes resonate with the heartbeat of creation itself. All production ×1,000.",
|
||||
"Eternal runes resonate with the heartbeat of creation itself. All production ×500.",
|
||||
id: "income_11",
|
||||
multiplier: 1000,
|
||||
multiplier: 500,
|
||||
name: "Eternal Rune II",
|
||||
runestonesCost: 80_000,
|
||||
runestonesCost: 60_000,
|
||||
},
|
||||
// ── Click Power ───────────────────────────────────────────────────────────
|
||||
{
|
||||
@@ -210,6 +210,15 @@ export const defaultPrestigeUpgrades: Array<PrestigeUpgrade> = [
|
||||
runestonesCost: 1200,
|
||||
},
|
||||
// ── Utility Unlocks ───────────────────────────────────────────────────────
|
||||
{
|
||||
category: "utility",
|
||||
description:
|
||||
"Unlock the Auto-Adventurer toggle. When enabled, the tick engine will automatically purchase the highest-tier adventurer you can currently afford.",
|
||||
id: "auto_adventurer",
|
||||
multiplier: 1,
|
||||
name: "Autonomous Recruitment",
|
||||
runestonesCost: 50,
|
||||
},
|
||||
{
|
||||
category: "utility",
|
||||
description:
|
||||
|
||||
+604
-251
File diff suppressed because it is too large
Load Diff
@@ -23,7 +23,7 @@ export const defaultRecipes: Array<CraftingRecipe> = [
|
||||
zoneId: "verdant_vale",
|
||||
},
|
||||
{
|
||||
bonus: { type: "combat_power", value: 1.08 },
|
||||
bonus: { type: "combat_power", value: 1.2 },
|
||||
description:
|
||||
"A ward fashioned from bark older than the kingdom. Its presence on the battlefield is not merely physical — something ancient watches through it.",
|
||||
id: "elder_bark_shield",
|
||||
@@ -75,7 +75,7 @@ export const defaultRecipes: Array<CraftingRecipe> = [
|
||||
zoneId: "frozen_peaks",
|
||||
},
|
||||
{
|
||||
bonus: { type: "gold_income", value: 1.1 },
|
||||
bonus: { type: "gold_income", value: 1.15 },
|
||||
description:
|
||||
"The void shard set in frost crystal, creating something that should not be possible: a stable window into the spaces between spaces. Profitable beyond what physics suggests.",
|
||||
id: "void_fragment_amulet",
|
||||
@@ -101,7 +101,7 @@ export const defaultRecipes: Array<CraftingRecipe> = [
|
||||
zoneId: "shadow_marshes",
|
||||
},
|
||||
{
|
||||
bonus: { type: "combat_power", value: 1.1 },
|
||||
bonus: { type: "combat_power", value: 1.15 },
|
||||
description:
|
||||
"The cursed bone and shadow essence combined into a focus that doesn't so much help your party fight as make things afraid of them before the battle begins.",
|
||||
id: "cursed_focus",
|
||||
@@ -127,7 +127,7 @@ export const defaultRecipes: Array<CraftingRecipe> = [
|
||||
zoneId: "volcanic_depths",
|
||||
},
|
||||
{
|
||||
bonus: { type: "combat_power", value: 1.12 },
|
||||
bonus: { type: "combat_power", value: 1.2 },
|
||||
description:
|
||||
"The legendary ore, smelted in the volcanic forges with magma stone as fuel. What emerges is something the fire elementals recognise — and fear slightly.",
|
||||
id: "elemental_ore_ingot",
|
||||
@@ -193,7 +193,7 @@ export const defaultRecipes: Array<CraftingRecipe> = [
|
||||
|
||||
// Zone 8: abyssal_trench
|
||||
{
|
||||
bonus: { type: "combat_power", value: 1.15 },
|
||||
bonus: { type: "combat_power", value: 1.25 },
|
||||
description:
|
||||
"Trench coral and pressure gem combined under conditions that should have destroyed both. The result is something that survived conditions nothing should survive, which is ideal for combat.",
|
||||
id: "pressure_forged_core",
|
||||
@@ -231,7 +231,7 @@ export const defaultRecipes: Array<CraftingRecipe> = [
|
||||
zoneId: "infernal_court",
|
||||
},
|
||||
{
|
||||
bonus: { type: "essence_income", value: 1.15 },
|
||||
bonus: { type: "essence_income", value: 1.2 },
|
||||
description:
|
||||
"Soul residue and demon ichor worked into a catalyst that draws the essence from everything around it — gently, without drawing the court's attention. Usually.",
|
||||
id: "soul_bound_catalyst",
|
||||
@@ -271,7 +271,7 @@ export const defaultRecipes: Array<CraftingRecipe> = [
|
||||
|
||||
// Zone 11: void_sanctum
|
||||
{
|
||||
bonus: { type: "combat_power", value: 1.18 },
|
||||
bonus: { type: "combat_power", value: 1.28 },
|
||||
description:
|
||||
"Null matter and resonance fragments assembled into something that generates a field where the laws governing how hard things are to kill become negotiable.",
|
||||
id: "null_field_generator",
|
||||
@@ -309,7 +309,7 @@ export const defaultRecipes: Array<CraftingRecipe> = [
|
||||
zoneId: "eternal_throne",
|
||||
},
|
||||
{
|
||||
bonus: { type: "combat_power", value: 1.2 },
|
||||
bonus: { type: "combat_power", value: 1.3 },
|
||||
description:
|
||||
"An eternity splinter set into crown fragments, shaped into a ring. What it binds is unclear. Whatever it is, it makes your party significantly harder to kill.",
|
||||
id: "eternity_bound_ring",
|
||||
@@ -375,7 +375,7 @@ export const defaultRecipes: Array<CraftingRecipe> = [
|
||||
|
||||
// Zone 15: reality_forge
|
||||
{
|
||||
bonus: { type: "combat_power", value: 1.22 },
|
||||
bonus: { type: "combat_power", value: 1.35 },
|
||||
description:
|
||||
"Forge ash smelted with creation tools into an ingot of compressed reality. Your party hits harder when carrying it. Reality does not enjoy being concentrated like this.",
|
||||
id: "reality_ingot",
|
||||
@@ -427,7 +427,7 @@ export const defaultRecipes: Array<CraftingRecipe> = [
|
||||
|
||||
// Zone 17: primeval_sanctum
|
||||
{
|
||||
bonus: { type: "combat_power", value: 1.25 },
|
||||
bonus: { type: "combat_power", value: 1.4 },
|
||||
description:
|
||||
"Ancient dust and memory shards arranged into something that remembers how to fight before fighting was invented. Your party benefits from this instinct enormously.",
|
||||
id: "ancient_memory_array",
|
||||
@@ -451,7 +451,88 @@ export const defaultRecipes: Array<CraftingRecipe> = [
|
||||
zoneId: "primeval_sanctum",
|
||||
},
|
||||
|
||||
// ── Cross-zone recipes ─────────────────────────────────────────────────────
|
||||
{
|
||||
bonus: { type: "gold_income", value: 1.28 },
|
||||
description:
|
||||
"Verdant sap from the oldest trees, refined in ember crystal heat and bound by legendary ore from the volcanic forges. The resulting tincture fuses the forest's patient growth with fire's relentless drive — gold accumulates with unusual enthusiasm.",
|
||||
id: "verdant_pyre_seal",
|
||||
name: "Verdant Pyre Seal",
|
||||
requiredMaterials: [
|
||||
{ materialId: "verdant_sap", quantity: 8 },
|
||||
{ materialId: "ember_crystal", quantity: 6 },
|
||||
{ materialId: "legendary_ore", quantity: 2 },
|
||||
],
|
||||
zoneId: "volcanic_depths",
|
||||
},
|
||||
{
|
||||
bonus: { type: "click_power", value: 1.22 },
|
||||
description:
|
||||
"A void shard frozen into glacial ice and then submerged in shadow essence — the cold of nothing meeting the dark of everything. The resulting weave sharpens strikes with an emptiness that the shadows themselves cannot resist.",
|
||||
id: "voidfrost_weave",
|
||||
name: "Voidfrost Weave",
|
||||
requiredMaterials: [
|
||||
{ materialId: "glacial_ice", quantity: 8 },
|
||||
{ materialId: "void_shard", quantity: 3 },
|
||||
{ materialId: "shadow_essence", quantity: 5 },
|
||||
],
|
||||
zoneId: "shadow_marshes",
|
||||
},
|
||||
{
|
||||
bonus: { type: "essence_income", value: 1.28 },
|
||||
description:
|
||||
"A choir shard from the celestial reaches lowered into the crushing dark of the abyssal trench and set alongside an ancient tooth. The celestial harmonic does not stop in the deep — it deepens. Essence flows toward it from every direction simultaneously.",
|
||||
id: "choir_of_the_deep",
|
||||
name: "Choir of the Deep",
|
||||
requiredMaterials: [
|
||||
{ materialId: "celestial_dust", quantity: 8 },
|
||||
{ materialId: "choir_shard", quantity: 2 },
|
||||
{ materialId: "ancient_tooth", quantity: 2 },
|
||||
{ materialId: "pressure_gem", quantity: 5 },
|
||||
],
|
||||
zoneId: "abyssal_trench",
|
||||
},
|
||||
{
|
||||
bonus: { type: "click_power", value: 1.38 },
|
||||
description:
|
||||
"A primeval relic submerged at the absolute boundary of existence alongside omega crystals and boundary shards — the first and last thing, unified. Every action your guild takes through it is simultaneously the most ancient and most final thing that has ever happened. It does not miss.",
|
||||
id: "primal_omega_lens",
|
||||
name: "Primal Omega Lens",
|
||||
requiredMaterials: [
|
||||
{ materialId: "primeval_relic", quantity: 2 },
|
||||
{ materialId: "boundary_shard", quantity: 4 },
|
||||
{ materialId: "omega_crystal", quantity: 2 },
|
||||
],
|
||||
zoneId: "the_absolute",
|
||||
},
|
||||
{
|
||||
bonus: { type: "combat_power", value: 1.65 },
|
||||
description:
|
||||
"An eternity splinter from the eternal throne, set at the boundary between everything and nothing with an omega crystal and bound by boundary shards. Where eternity meets the absolute, something is forged that has never existed and will never exist again. Your party fights as if they know this.",
|
||||
id: "eternal_omega",
|
||||
name: "Eternal Omega",
|
||||
requiredMaterials: [
|
||||
{ materialId: "crown_fragment", quantity: 6 },
|
||||
{ materialId: "eternity_splinter", quantity: 2 },
|
||||
{ materialId: "boundary_shard", quantity: 4 },
|
||||
{ materialId: "omega_crystal", quantity: 2 },
|
||||
],
|
||||
zoneId: "the_absolute",
|
||||
},
|
||||
|
||||
// Zone 18: the_absolute
|
||||
{
|
||||
bonus: { type: "click_power", value: 1.28 },
|
||||
description:
|
||||
"Absolute fragments ground and set in an omega crystal lattice — an instrument of pure finality. Every action your guild takes through it carries the weight of an ending. It does not miss.",
|
||||
id: "absolute_focus",
|
||||
name: "Absolute Focus",
|
||||
requiredMaterials: [
|
||||
{ materialId: "absolute_fragment", quantity: 8 },
|
||||
{ materialId: "omega_crystal", quantity: 3 },
|
||||
],
|
||||
zoneId: "the_absolute",
|
||||
},
|
||||
{
|
||||
bonus: { type: "gold_income", value: 1.3 },
|
||||
description:
|
||||
@@ -465,7 +546,7 @@ export const defaultRecipes: Array<CraftingRecipe> = [
|
||||
zoneId: "the_absolute",
|
||||
},
|
||||
{
|
||||
bonus: { type: "combat_power", value: 1.3 },
|
||||
bonus: { type: "combat_power", value: 1.55 },
|
||||
description:
|
||||
"The last omega crystal, set at the convergence of boundary shards in the precise arrangement of an ending. What it does to combat is what endings do to everything: make it final.",
|
||||
id: "omega_convergence",
|
||||
|
||||
@@ -8,4 +8,4 @@
|
||||
/**
|
||||
* The current game state schema version. Bump this whenever a breaking change is made to GameState.
|
||||
*/
|
||||
export const currentSchemaVersion = 1;
|
||||
export const currentSchemaVersion = 2;
|
||||
|
||||
@@ -11,7 +11,7 @@ export const defaultTranscendenceUpgrades: Array<TranscendenceUpgrade> = [
|
||||
// ── Income multipliers ──────────────────────────────────────────────────────
|
||||
{
|
||||
category: "income",
|
||||
cost: 5,
|
||||
cost: 2,
|
||||
description:
|
||||
"The echoes of past runs linger, amplifying your guild's income by 25%.",
|
||||
id: "echo_income_1",
|
||||
@@ -20,7 +20,7 @@ export const defaultTranscendenceUpgrades: Array<TranscendenceUpgrade> = [
|
||||
},
|
||||
{
|
||||
category: "income",
|
||||
cost: 10,
|
||||
cost: 4,
|
||||
description:
|
||||
"Your transcendent experience resonates through your guild, boosting income by 50%.",
|
||||
id: "echo_income_2",
|
||||
@@ -29,7 +29,7 @@ export const defaultTranscendenceUpgrades: Array<TranscendenceUpgrade> = [
|
||||
},
|
||||
{
|
||||
category: "income",
|
||||
cost: 20,
|
||||
cost: 8,
|
||||
description:
|
||||
"The harmony of multiple timelines surges through your guild, doubling its income.",
|
||||
id: "echo_income_3",
|
||||
@@ -38,7 +38,7 @@ export const defaultTranscendenceUpgrades: Array<TranscendenceUpgrade> = [
|
||||
},
|
||||
{
|
||||
category: "income",
|
||||
cost: 40,
|
||||
cost: 16,
|
||||
description:
|
||||
"Ethereal energy overflows from your transcendence, tripling your guild's income.",
|
||||
id: "echo_income_4",
|
||||
@@ -47,7 +47,7 @@ export const defaultTranscendenceUpgrades: Array<TranscendenceUpgrade> = [
|
||||
},
|
||||
{
|
||||
category: "income",
|
||||
cost: 80,
|
||||
cost: 32,
|
||||
description:
|
||||
"The infinite chorus of every run you've ever played amplifies your guild fivefold.",
|
||||
id: "echo_income_5",
|
||||
@@ -58,7 +58,7 @@ export const defaultTranscendenceUpgrades: Array<TranscendenceUpgrade> = [
|
||||
// ── Combat multipliers ──────────────────────────────────────────────────────
|
||||
{
|
||||
category: "combat",
|
||||
cost: 5,
|
||||
cost: 2,
|
||||
description:
|
||||
"Memories of countless battles harden your adventurers, increasing party DPS by 25%.",
|
||||
id: "echo_combat_1",
|
||||
@@ -67,7 +67,7 @@ export const defaultTranscendenceUpgrades: Array<TranscendenceUpgrade> = [
|
||||
},
|
||||
{
|
||||
category: "combat",
|
||||
cost: 15,
|
||||
cost: 6,
|
||||
description:
|
||||
"Veterans of transcendence know how to fight smarter, boosting party DPS by 50%.",
|
||||
id: "echo_combat_2",
|
||||
@@ -76,7 +76,7 @@ export const defaultTranscendenceUpgrades: Array<TranscendenceUpgrade> = [
|
||||
},
|
||||
{
|
||||
category: "combat",
|
||||
cost: 35,
|
||||
cost: 12,
|
||||
description:
|
||||
"Your warriors carry the strength of every fallen timeline, doubling party DPS.",
|
||||
id: "echo_combat_3",
|
||||
@@ -87,7 +87,7 @@ export const defaultTranscendenceUpgrades: Array<TranscendenceUpgrade> = [
|
||||
// ── Prestige threshold reductions ──────────────────────────────────────────
|
||||
{
|
||||
category: "prestige_threshold",
|
||||
cost: 8,
|
||||
cost: 3,
|
||||
description:
|
||||
"Experience from past lives shortens the road to prestige — threshold reduced by 10%.",
|
||||
id: "echo_prestige_threshold_1",
|
||||
@@ -96,7 +96,7 @@ export const defaultTranscendenceUpgrades: Array<TranscendenceUpgrade> = [
|
||||
},
|
||||
{
|
||||
category: "prestige_threshold",
|
||||
cost: 20,
|
||||
cost: 6,
|
||||
description:
|
||||
"You've walked this path so many times you know every shortcut — threshold reduced by 20%.",
|
||||
id: "echo_prestige_threshold_2",
|
||||
@@ -107,7 +107,7 @@ export const defaultTranscendenceUpgrades: Array<TranscendenceUpgrade> = [
|
||||
// ── Prestige runestone multipliers ─────────────────────────────────────────
|
||||
{
|
||||
category: "prestige_runestones",
|
||||
cost: 8,
|
||||
cost: 3,
|
||||
description:
|
||||
"Transcendent insight attunes you to the runestones, earning 50% more per prestige.",
|
||||
id: "echo_prestige_runestones_1",
|
||||
@@ -116,7 +116,7 @@ export const defaultTranscendenceUpgrades: Array<TranscendenceUpgrade> = [
|
||||
},
|
||||
{
|
||||
category: "prestige_runestones",
|
||||
cost: 20,
|
||||
cost: 6,
|
||||
description:
|
||||
"You have mastered the art of runestone crafting, doubling your prestige runestone yield.",
|
||||
id: "echo_prestige_runestones_2",
|
||||
@@ -127,7 +127,7 @@ export const defaultTranscendenceUpgrades: Array<TranscendenceUpgrade> = [
|
||||
// ── Echo meta multipliers ───────────────────────────────────────────────────
|
||||
{
|
||||
category: "echo_meta",
|
||||
cost: 10,
|
||||
cost: 15,
|
||||
description:
|
||||
"Your transcendence resonates deeper, amplifying future echo yields by 25%.",
|
||||
id: "echo_meta_1",
|
||||
@@ -136,7 +136,7 @@ export const defaultTranscendenceUpgrades: Array<TranscendenceUpgrade> = [
|
||||
},
|
||||
{
|
||||
category: "echo_meta",
|
||||
cost: 25,
|
||||
cost: 45,
|
||||
description:
|
||||
"Each loop of existence makes the next more powerful — future echo yields +50%.",
|
||||
id: "echo_meta_2",
|
||||
@@ -145,7 +145,7 @@ export const defaultTranscendenceUpgrades: Array<TranscendenceUpgrade> = [
|
||||
},
|
||||
{
|
||||
category: "echo_meta",
|
||||
cost: 50,
|
||||
cost: 100,
|
||||
description:
|
||||
"You have mastered the infinite spiral of transcendence, doubling all future echo yields.",
|
||||
id: "echo_meta_3",
|
||||
|
||||
+130
-22
@@ -48,7 +48,7 @@ export const defaultUpgrades: Array<Upgrade> = [
|
||||
unlocked: false,
|
||||
},
|
||||
{
|
||||
costCrystals: 100,
|
||||
costCrystals: 50,
|
||||
costEssence: 0,
|
||||
costGold: 0,
|
||||
description:
|
||||
@@ -104,7 +104,7 @@ export const defaultUpgrades: Array<Upgrade> = [
|
||||
description:
|
||||
"Forge partnerships with mage guilds across the realm. All income +50%.",
|
||||
id: "essence_guild",
|
||||
multiplier: 1.5,
|
||||
multiplier: 2,
|
||||
name: "Essence Guild",
|
||||
purchased: false,
|
||||
target: "global",
|
||||
@@ -162,6 +162,34 @@ export const defaultUpgrades: Array<Upgrade> = [
|
||||
target: "adventurer",
|
||||
unlocked: false,
|
||||
},
|
||||
{
|
||||
adventurerId: "peasant",
|
||||
costCrystals: 0,
|
||||
costEssence: 20,
|
||||
costGold: 0,
|
||||
description:
|
||||
"Organised labour guilds and proper scheduling make peasants ten times more productive.",
|
||||
id: "peasant_2",
|
||||
multiplier: 10,
|
||||
name: "Guild Organisation",
|
||||
purchased: false,
|
||||
target: "adventurer",
|
||||
unlocked: false,
|
||||
},
|
||||
{
|
||||
adventurerId: "peasant",
|
||||
costCrystals: 50,
|
||||
costEssence: 0,
|
||||
costGold: 0,
|
||||
description:
|
||||
"Magical augmentation through crystalline resonance supercharges even the humblest worker.",
|
||||
id: "peasant_3",
|
||||
multiplier: 50,
|
||||
name: "Crystal Augmentation",
|
||||
purchased: false,
|
||||
target: "adventurer",
|
||||
unlocked: false,
|
||||
},
|
||||
{
|
||||
adventurerId: "militia",
|
||||
costCrystals: 0,
|
||||
@@ -181,7 +209,7 @@ export const defaultUpgrades: Array<Upgrade> = [
|
||||
costEssence: 2,
|
||||
costGold: 5000,
|
||||
description: "Ancient books of magic double mage output.",
|
||||
id: "mage_1",
|
||||
id: "apprentice_1",
|
||||
multiplier: 2,
|
||||
name: "Arcane Tomes",
|
||||
purchased: false,
|
||||
@@ -194,7 +222,7 @@ export const defaultUpgrades: Array<Upgrade> = [
|
||||
costEssence: 3,
|
||||
costGold: 8000,
|
||||
description: "Sacred ceremonies double the output of your clerics.",
|
||||
id: "cleric_1",
|
||||
id: "acolyte_1",
|
||||
multiplier: 2,
|
||||
name: "Holy Rites",
|
||||
purchased: false,
|
||||
@@ -269,23 +297,10 @@ export const defaultUpgrades: Array<Upgrade> = [
|
||||
target: "adventurer",
|
||||
unlocked: false,
|
||||
},
|
||||
{
|
||||
adventurerId: "shadow_assassin",
|
||||
costCrystals: 0,
|
||||
costEssence: 50,
|
||||
costGold: 0,
|
||||
description: "Mastery of the shadow arts doubles assassin effectiveness.",
|
||||
id: "shadow_assassin_1",
|
||||
multiplier: 2,
|
||||
name: "Shadow Arts",
|
||||
purchased: false,
|
||||
target: "adventurer",
|
||||
unlocked: false,
|
||||
},
|
||||
{
|
||||
adventurerId: "arcane_scholar",
|
||||
costCrystals: 0,
|
||||
costEssence: 150,
|
||||
costEssence: 1000,
|
||||
costGold: 0,
|
||||
description: "Access to forbidden libraries doubles scholar output.",
|
||||
id: "arcane_scholar_1",
|
||||
@@ -295,10 +310,37 @@ export const defaultUpgrades: Array<Upgrade> = [
|
||||
target: "adventurer",
|
||||
unlocked: false,
|
||||
},
|
||||
{
|
||||
adventurerId: "shadow_assassin",
|
||||
costCrystals: 0,
|
||||
costEssence: 5000,
|
||||
costGold: 0,
|
||||
description: "Mastery of the shadow arts doubles assassin effectiveness.",
|
||||
id: "shadow_assassin_1",
|
||||
multiplier: 2,
|
||||
name: "Shadow Arts",
|
||||
purchased: false,
|
||||
target: "adventurer",
|
||||
unlocked: false,
|
||||
},
|
||||
{
|
||||
adventurerId: "dark_templar",
|
||||
costCrystals: 0,
|
||||
costEssence: 25_000,
|
||||
costGold: 0,
|
||||
description:
|
||||
"A sworn oath to the darkness of the marshes doubles templar output.",
|
||||
id: "dark_templar_1",
|
||||
multiplier: 2,
|
||||
name: "Templar's Oath",
|
||||
purchased: false,
|
||||
target: "adventurer",
|
||||
unlocked: false,
|
||||
},
|
||||
{
|
||||
adventurerId: "void_walker",
|
||||
costCrystals: 0,
|
||||
costEssence: 300,
|
||||
costEssence: 100_000,
|
||||
costGold: 0,
|
||||
description:
|
||||
"Walking through the void itself doubles the output of your void walkers.",
|
||||
@@ -312,7 +354,7 @@ export const defaultUpgrades: Array<Upgrade> = [
|
||||
{
|
||||
adventurerId: "celestial_guard",
|
||||
costCrystals: 0,
|
||||
costEssence: 750,
|
||||
costEssence: 500_000,
|
||||
costGold: 0,
|
||||
description:
|
||||
"A blessing from the celestials themselves doubles guard output.",
|
||||
@@ -326,7 +368,7 @@ export const defaultUpgrades: Array<Upgrade> = [
|
||||
{
|
||||
adventurerId: "divine_champion",
|
||||
costCrystals: 0,
|
||||
costEssence: 2000,
|
||||
costEssence: 2_000_000,
|
||||
costGold: 0,
|
||||
description: "An unbreakable oath to the divine doubles champion output.",
|
||||
id: "divine_champion_1",
|
||||
@@ -417,7 +459,7 @@ export const defaultUpgrades: Array<Upgrade> = [
|
||||
unlocked: false,
|
||||
},
|
||||
{
|
||||
costCrystals: 10_000_000,
|
||||
costCrystals: 50_000_000,
|
||||
costEssence: 0,
|
||||
costGold: 0,
|
||||
description: "Transcend mortal limits through void energy. All income x3.",
|
||||
@@ -767,4 +809,70 @@ export const defaultUpgrades: Array<Upgrade> = [
|
||||
target: "adventurer",
|
||||
unlocked: false,
|
||||
},
|
||||
// ── Essence Sinks ─────────────────────────────────────────────────────────
|
||||
{
|
||||
costCrystals: 0,
|
||||
costEssence: 1e12,
|
||||
costGold: 0,
|
||||
description:
|
||||
"Channel a vast reservoir of essence into the guild's core — all production ×2.",
|
||||
id: "essence_sink_1",
|
||||
multiplier: 2,
|
||||
name: "Essence Infusion I",
|
||||
purchased: false,
|
||||
target: "global",
|
||||
unlocked: true,
|
||||
},
|
||||
{
|
||||
costCrystals: 0,
|
||||
costEssence: 5e12,
|
||||
costGold: 0,
|
||||
description:
|
||||
"A deeper infusion saturates every operation with raw essence — all production ×2.",
|
||||
id: "essence_sink_2",
|
||||
multiplier: 2,
|
||||
name: "Essence Infusion II",
|
||||
purchased: false,
|
||||
target: "global",
|
||||
unlocked: true,
|
||||
},
|
||||
{
|
||||
costCrystals: 0,
|
||||
costEssence: 2.5e13,
|
||||
costGold: 0,
|
||||
description:
|
||||
"Essence floods the ley-lines binding your guild — all production ×2.",
|
||||
id: "essence_sink_3",
|
||||
multiplier: 2,
|
||||
name: "Essence Infusion III",
|
||||
purchased: false,
|
||||
target: "global",
|
||||
unlocked: true,
|
||||
},
|
||||
{
|
||||
costCrystals: 0,
|
||||
costEssence: 1e14,
|
||||
costGold: 0,
|
||||
description:
|
||||
"The guild breathes essence as its very lifeblood — all production ×3.",
|
||||
id: "essence_sink_4",
|
||||
multiplier: 3,
|
||||
name: "Essence Infusion IV",
|
||||
purchased: false,
|
||||
target: "global",
|
||||
unlocked: true,
|
||||
},
|
||||
{
|
||||
costCrystals: 0,
|
||||
costEssence: 5e14,
|
||||
costGold: 0,
|
||||
description:
|
||||
"Essence transcends material form and reshapes reality itself — all production ×5.",
|
||||
id: "essence_sink_5",
|
||||
multiplier: 5,
|
||||
name: "Essence Infusion V",
|
||||
purchased: false,
|
||||
target: "global",
|
||||
unlocked: true,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -13,6 +13,7 @@ import { apotheosisRouter } from "./routes/apotheosis.js";
|
||||
import { authRouter } from "./routes/auth.js";
|
||||
import { bossRouter } from "./routes/boss.js";
|
||||
import { craftRouter } from "./routes/craft.js";
|
||||
import { debugRouter } from "./routes/debug.js";
|
||||
import { exploreRouter } from "./routes/explore.js";
|
||||
import { frontendRouter } from "./routes/frontend.js";
|
||||
import { gameRouter } from "./routes/game.js";
|
||||
@@ -20,6 +21,7 @@ import { leaderboardRouter } from "./routes/leaderboards.js";
|
||||
import { prestigeRouter } from "./routes/prestige.js";
|
||||
import { profileRouter } from "./routes/profile.js";
|
||||
import { transcendenceRouter } from "./routes/transcendence.js";
|
||||
import { connectGateway } from "./services/gateway.js";
|
||||
import { logger } from "./services/logger.js";
|
||||
|
||||
const app = new Hono();
|
||||
@@ -35,6 +37,7 @@ app.use(
|
||||
);
|
||||
|
||||
app.route("/about", aboutRouter);
|
||||
app.route("/debug", debugRouter);
|
||||
app.route("/fe", frontendRouter);
|
||||
app.route("/auth", authRouter);
|
||||
app.route("/game", gameRouter);
|
||||
@@ -66,6 +69,7 @@ const port = Number(process.env.PORT ?? 3001);
|
||||
try {
|
||||
serve({ fetch: app.fetch, port: port }, () => {
|
||||
process.stdout.write(`Elysium API running on port ${String(port)}\n`);
|
||||
connectGateway();
|
||||
});
|
||||
} catch (error) {
|
||||
void logger.error(
|
||||
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
} from "../services/discord.js";
|
||||
import { signToken } from "../services/jwt.js";
|
||||
import { logger } from "../services/logger.js";
|
||||
import { grantElysianRole } from "../services/webhook.js";
|
||||
import type { Player } from "@elysium/types";
|
||||
|
||||
const authRouter = new Hono();
|
||||
@@ -92,6 +93,12 @@ authRouter.get("/callback", async(context) => {
|
||||
},
|
||||
});
|
||||
|
||||
const inGuild = await grantElysianRole(player.discordId);
|
||||
await prisma.player.update({
|
||||
data: { inGuild },
|
||||
where: { discordId: player.discordId },
|
||||
});
|
||||
|
||||
const jwtToken = signToken(player.discordId);
|
||||
void logger.log("info", `New player registered: ${player.discordId}`);
|
||||
void logger.metric("user_registered", 1, { discordId: player.discordId });
|
||||
@@ -104,10 +111,12 @@ authRouter.get("/callback", async(context) => {
|
||||
);
|
||||
}
|
||||
|
||||
const inGuild = await grantElysianRole(discordUser.id);
|
||||
const updated = await prisma.player.update({
|
||||
data: {
|
||||
avatar: discordUser.avatar,
|
||||
discriminator: discordUser.discriminator,
|
||||
inGuild: inGuild,
|
||||
username: discordUser.username,
|
||||
},
|
||||
where: { discordId: discordUser.id },
|
||||
|
||||
@@ -24,6 +24,13 @@ import { updateChallengeProgress } from "../services/dailyChallenges.js";
|
||||
import { logger } from "../services/logger.js";
|
||||
import type { HonoEnvironment } from "../types/hono.js";
|
||||
|
||||
/**
|
||||
* Exponential base for the prestige combat multiplier: Math.pow(base, prestigeCount).
|
||||
* Replaces the former linear formula (1 + count * 0.1) to enable late-game zone progression.
|
||||
* Must be kept in sync with prestigeCombatBase in apps/web/src/engine/tick.ts.
|
||||
*/
|
||||
const prestigeCombatBase = 4;
|
||||
|
||||
const bossRouter = new Hono<HonoEnvironment>();
|
||||
|
||||
bossRouter.use("*", authMiddleware);
|
||||
@@ -38,8 +45,7 @@ const calculatePartyStats = (
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line stylistic/no-mixed-operators -- prestige count * factor is clear
|
||||
const prestigeMultiplier = 1 + state.prestige.count * 0.1;
|
||||
const prestigeMultiplier = Math.pow(prestigeCombatBase, state.prestige.count);
|
||||
|
||||
// Apply equipped weapon's combat bonus
|
||||
// eslint-disable-next-line capitalized-comments -- v8 ignore
|
||||
|
||||
@@ -148,11 +148,22 @@ craftRouter.post("/", async(context) => {
|
||||
|
||||
const bonusType = recipe.bonus.type;
|
||||
const bonusValue = recipe.bonus.value;
|
||||
const { materials } = state.exploration;
|
||||
const {
|
||||
craftedGoldMultiplier,
|
||||
craftedEssenceMultiplier,
|
||||
craftedClickMultiplier,
|
||||
craftedCombatMultiplier,
|
||||
} = updatedMultipliers;
|
||||
const response: CraftRecipeResponse = {
|
||||
bonusType,
|
||||
bonusValue,
|
||||
craftedClickMultiplier,
|
||||
craftedCombatMultiplier,
|
||||
craftedEssenceMultiplier,
|
||||
craftedGoldMultiplier,
|
||||
materials,
|
||||
recipeId,
|
||||
...updatedMultipliers,
|
||||
};
|
||||
return context.json(response);
|
||||
} catch (error) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -7,6 +7,7 @@
|
||||
/* eslint-disable max-lines-per-function -- Route handlers require many steps */
|
||||
/* eslint-disable max-statements -- Route handlers require many statements */
|
||||
/* eslint-disable complexity -- Route handlers have inherent complexity */
|
||||
/* eslint-disable max-lines -- Route file requires multiple handlers */
|
||||
import { Hono } from "hono";
|
||||
import { defaultExplorations } from "../data/explorations.js";
|
||||
import { initialExploration } from "../data/initialState.js";
|
||||
@@ -15,6 +16,7 @@ import { authMiddleware } from "../middleware/auth.js";
|
||||
import { logger } from "../services/logger.js";
|
||||
import type { HonoEnvironment } from "../types/hono.js";
|
||||
import type {
|
||||
ExploreClaimableResponse,
|
||||
ExploreCollectEventResult,
|
||||
ExploreCollectRequest,
|
||||
ExploreCollectResponse,
|
||||
@@ -49,6 +51,64 @@ const pickNothingMessage = (): string => {
|
||||
return nothingMessages[index] ?? nothingMessages[0] ?? "";
|
||||
};
|
||||
|
||||
exploreRouter.get("/claimable", async(context) => {
|
||||
try {
|
||||
const discordId = context.get("discordId");
|
||||
const areaId = context.req.query("areaId");
|
||||
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions -- Runtime query validation
|
||||
if (!areaId) {
|
||||
return context.json({ error: "areaId is required" }, 400);
|
||||
}
|
||||
|
||||
const explorationArea = defaultExplorations.find((a) => {
|
||||
return a.id === areaId;
|
||||
});
|
||||
if (!explorationArea) {
|
||||
return context.json({ error: "Unknown exploration area" }, 404);
|
||||
}
|
||||
|
||||
const record = await prisma.gameState.findUnique({ where: { discordId } });
|
||||
if (!record) {
|
||||
return context.json({ error: "No save found" }, 404);
|
||||
}
|
||||
|
||||
const rawState: unknown = record.state;
|
||||
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Prisma returns JsonValue; cast to GameState */
|
||||
const state = rawState as GameState;
|
||||
|
||||
if (!state.exploration) {
|
||||
const response: ExploreClaimableResponse = { claimable: false };
|
||||
return context.json(response);
|
||||
}
|
||||
|
||||
const area = state.exploration.areas.find((a) => {
|
||||
return a.id === areaId;
|
||||
});
|
||||
|
||||
if (!area || area.status !== "in_progress") {
|
||||
const response: ExploreClaimableResponse = { claimable: false };
|
||||
return context.json(response);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line capitalized-comments -- v8 ignore
|
||||
/* v8 ignore next -- @preserve */
|
||||
const startedAt = area.startedAt ?? 0;
|
||||
const durationMs = explorationArea.durationSeconds * 1000;
|
||||
const expiresAt = startedAt + durationMs;
|
||||
const claimable = Date.now() >= expiresAt;
|
||||
const response: ExploreClaimableResponse = { claimable };
|
||||
return context.json(response);
|
||||
} catch (error) {
|
||||
void logger.error(
|
||||
"explore_claimable",
|
||||
error instanceof Error
|
||||
? error
|
||||
: new Error(String(error)),
|
||||
);
|
||||
return context.json({ error: "Internal server error" }, 500);
|
||||
}
|
||||
});
|
||||
|
||||
exploreRouter.post("/start", async(context) => {
|
||||
try {
|
||||
const discordId = context.get("discordId");
|
||||
|
||||
@@ -27,6 +27,7 @@ import { currentSchemaVersion } from "../data/schemaVersion.js";
|
||||
import { prisma } from "../db/client.js";
|
||||
import { authMiddleware } from "../middleware/auth.js";
|
||||
import { getOrResetDailyChallenges } from "../services/dailyChallenges.js";
|
||||
import { fetchDiscordUserById } from "../services/discord.js";
|
||||
import { logger } from "../services/logger.js";
|
||||
import { calculateOfflineEarnings } from "../services/offlineProgress.js";
|
||||
import {
|
||||
@@ -685,11 +686,34 @@ gameRouter.get("/load", async(context) => {
|
||||
try {
|
||||
const discordId = context.get("discordId");
|
||||
|
||||
const [ record, playerRecord ] = await Promise.all([
|
||||
prisma.gameState.findUnique({ where: { discordId } }),
|
||||
prisma.player.findUnique({ where: { discordId } }),
|
||||
const [ [ record, playerRecord ], freshDiscordUser ] = await Promise.all([
|
||||
Promise.all([
|
||||
prisma.gameState.findUnique({ where: { discordId } }),
|
||||
prisma.player.findUnique({ where: { discordId } }),
|
||||
]),
|
||||
fetchDiscordUserById(discordId),
|
||||
]);
|
||||
|
||||
// Refresh avatar in DB when Discord returns an updated hash
|
||||
if (
|
||||
freshDiscordUser !== null
|
||||
&& playerRecord !== null
|
||||
&& freshDiscordUser.avatar !== playerRecord.avatar
|
||||
) {
|
||||
playerRecord.avatar = freshDiscordUser.avatar;
|
||||
void prisma.player.update({
|
||||
data: { avatar: freshDiscordUser.avatar },
|
||||
where: { discordId },
|
||||
}).catch((error: unknown) => {
|
||||
void logger.error(
|
||||
"avatar_refresh",
|
||||
error instanceof Error
|
||||
? error
|
||||
: new Error(String(error)),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
if (!record) {
|
||||
// No save found — create a fresh state (handles nuked DB or first-time load race)
|
||||
if (!playerRecord) {
|
||||
@@ -736,6 +760,7 @@ gameRouter.get("/load", async(context) => {
|
||||
: computeHmac(JSON.stringify(freshState), secret);
|
||||
return context.json({
|
||||
currentSchemaVersion: currentSchemaVersion,
|
||||
inGuild: playerRecord.inGuild,
|
||||
loginBonus: null,
|
||||
loginStreak: playerRecord.loginStreak,
|
||||
offlineEssence: 0,
|
||||
@@ -757,6 +782,7 @@ gameRouter.get("/load", async(context) => {
|
||||
*/
|
||||
if (playerRecord !== null) {
|
||||
state.player.characterName = playerRecord.characterName;
|
||||
state.player.avatar = playerRecord.avatar;
|
||||
}
|
||||
|
||||
const now = Date.now();
|
||||
@@ -873,8 +899,10 @@ gameRouter.get("/load", async(context) => {
|
||||
const signature = secret === undefined
|
||||
? undefined
|
||||
: computeHmac(JSON.stringify(state), secret);
|
||||
const inGuild = playerRecord?.inGuild ?? false;
|
||||
return context.json({
|
||||
currentSchemaVersion,
|
||||
inGuild,
|
||||
loginBonus,
|
||||
loginStreak,
|
||||
offlineEssence,
|
||||
|
||||
@@ -102,12 +102,23 @@ prestigeRouter.post("/", async(context) => {
|
||||
}).length;
|
||||
|
||||
const now = Date.now();
|
||||
await prisma.gameState.update({
|
||||
const { updatedAt } = record;
|
||||
|
||||
/*
|
||||
* Use the record's current updatedAt as an optimistic lock — if another
|
||||
* concurrent prestige request already committed, this update will match
|
||||
* 0 rows and we can safely reject the duplicate without a double webhook.
|
||||
*/
|
||||
const updateResult = await prisma.gameState.updateMany({
|
||||
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Prisma requires object */
|
||||
data: { state: finalState as object, updatedAt: now },
|
||||
where: { discordId },
|
||||
where: { discordId, updatedAt },
|
||||
});
|
||||
|
||||
if (updateResult.count === 0) {
|
||||
return context.json({ error: "Prestige already in progress" }, 409);
|
||||
}
|
||||
|
||||
await prisma.player.update({
|
||||
data: {
|
||||
characterName: state.player.characterName,
|
||||
@@ -136,17 +147,30 @@ prestigeRouter.post("/", async(context) => {
|
||||
|
||||
const prestigeCount = prestigeData.count;
|
||||
void logger.metric("prestige", 1, { discordId, prestigeCount });
|
||||
void postMilestoneWebhook(discordId, "prestige", {
|
||||
// eslint-disable-next-line capitalized-comments -- v8 ignore
|
||||
/* v8 ignore next -- @preserve */
|
||||
apotheosis: prestigeState.apotheosis?.count ?? 0,
|
||||
|
||||
prestige: prestigeData.count,
|
||||
|
||||
// eslint-disable-next-line capitalized-comments -- v8 ignore
|
||||
/* v8 ignore next 2 -- @preserve */
|
||||
transcendence: prestigeState.transcendence?.count ?? 0,
|
||||
const playerRecord = await prisma.player.findUnique({
|
||||
select: { profileSettings: true },
|
||||
where: { discordId },
|
||||
});
|
||||
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Runtime shape check for JSON field */
|
||||
const playerSettings = playerRecord?.profileSettings as
|
||||
Record<string, unknown> | null | undefined;
|
||||
const announcementsEnabled
|
||||
= playerSettings?.enablePrestigeAnnouncements !== false;
|
||||
|
||||
if (announcementsEnabled) {
|
||||
void postMilestoneWebhook(discordId, "prestige", {
|
||||
// eslint-disable-next-line capitalized-comments -- v8 ignore
|
||||
/* v8 ignore next -- @preserve */
|
||||
apotheosis: prestigeState.apotheosis?.count ?? 0,
|
||||
|
||||
prestige: prestigeData.count,
|
||||
|
||||
// eslint-disable-next-line capitalized-comments -- v8 ignore
|
||||
/* v8 ignore next 2 -- @preserve */
|
||||
transcendence: prestigeState.transcendence?.count ?? 0,
|
||||
});
|
||||
}
|
||||
|
||||
return context.json({
|
||||
milestoneRunestones: milestoneRunestones,
|
||||
|
||||
@@ -47,6 +47,7 @@ const parseProfileSettings = (raw: unknown): ProfileSettings => {
|
||||
: "suffix";
|
||||
return {
|
||||
enableNotifications: rawObject.enableNotifications === true,
|
||||
enablePrestigeAnnouncements: rawObject.enablePrestigeAnnouncements !== false,
|
||||
enableSounds: rawObject.enableSounds === true,
|
||||
numberFormat: numberFormat,
|
||||
showAchievementsUnlocked: rawObject.showAchievementsUnlocked !== false,
|
||||
@@ -222,6 +223,7 @@ profileRouter.put("/", authMiddleware, async(context) => {
|
||||
: "suffix";
|
||||
const profileSettings: ProfileSettings = {
|
||||
enableNotifications: body.profileSettings.enableNotifications ?? false,
|
||||
enablePrestigeAnnouncements: body.profileSettings.enablePrestigeAnnouncements ?? true,
|
||||
enableSounds: body.profileSettings.enableSounds ?? false,
|
||||
numberFormat: numberFormat,
|
||||
showAchievementsUnlocked: body.profileSettings.showAchievementsUnlocked ?? true,
|
||||
|
||||
@@ -71,8 +71,7 @@ const shuffleWithSeed = <T>(array: Array<T>, seed: number): Array<T> => {
|
||||
return result;
|
||||
};
|
||||
|
||||
const challengeTypes: Array<DailyChallengeType> = [
|
||||
"clicks",
|
||||
const progressionChallengeTypes: Array<DailyChallengeType> = [
|
||||
"bossesDefeated",
|
||||
"questsCompleted",
|
||||
"prestige",
|
||||
@@ -80,7 +79,8 @@ const challengeTypes: Array<DailyChallengeType> = [
|
||||
|
||||
/**
|
||||
* Generates 3 daily challenges for the given date string, deterministically.
|
||||
* Picks one challenge from 3 different randomly-selected types.
|
||||
* Always includes a "clicks" challenge (always completable regardless of
|
||||
* progression), then picks 2 more from the remaining types.
|
||||
* @param dateString - The date string (YYYY-MM-DD) to generate challenges for.
|
||||
* @returns An array of 3 DailyChallenge objects.
|
||||
*/
|
||||
@@ -88,8 +88,10 @@ const generateDailyChallenges = (
|
||||
dateString: string,
|
||||
): Array<DailyChallenge> => {
|
||||
const seed = dateSeed(dateString);
|
||||
const selectedTypes = shuffleWithSeed([ ...challengeTypes ], seed).
|
||||
slice(0, 3);
|
||||
const selectedTypes: Array<DailyChallengeType> = [
|
||||
"clicks",
|
||||
...shuffleWithSeed([ ...progressionChallengeTypes ], seed).slice(0, 2),
|
||||
];
|
||||
|
||||
return selectedTypes.map((type, index) => {
|
||||
const templates = dailyChallengeTemplates.filter((template) => {
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention -- Discord API requires snake_case fields and HTTP headers require Pascal-Case */
|
||||
import { logger } from "./logger.js";
|
||||
|
||||
const discordClientId = "1479551654264049908";
|
||||
const discordRedirectUri = "https://elysium.nhcarrigan.com/api/auth/callback";
|
||||
|
||||
interface DiscordTokenResponse {
|
||||
access_token: string;
|
||||
token_type: string;
|
||||
@@ -31,24 +34,18 @@ interface DiscordUser {
|
||||
const exchangeCode = async(
|
||||
code: string,
|
||||
): Promise<DiscordTokenResponse> => {
|
||||
const clientId = process.env.DISCORD_CLIENT_ID;
|
||||
const clientSecret = process.env.DISCORD_CLIENT_SECRET;
|
||||
const redirectUri = process.env.DISCORD_REDIRECT_URI;
|
||||
|
||||
if (
|
||||
clientId === undefined || clientId === ""
|
||||
|| clientSecret === undefined || clientSecret === ""
|
||||
|| redirectUri === undefined || redirectUri === ""
|
||||
) {
|
||||
if (clientSecret === undefined || clientSecret === "") {
|
||||
throw new Error("Discord OAuth environment variables are required");
|
||||
}
|
||||
|
||||
const parameters = new URLSearchParams({
|
||||
client_id: clientId,
|
||||
client_id: discordClientId,
|
||||
client_secret: clientSecret,
|
||||
code: code,
|
||||
grant_type: "authorization_code",
|
||||
redirect_uri: redirectUri,
|
||||
redirect_uri: discordRedirectUri,
|
||||
});
|
||||
|
||||
try {
|
||||
@@ -106,25 +103,49 @@ const fetchDiscordUser = async(
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetches a Discord user's profile by their Discord ID using the bot token.
|
||||
* Returns null on any failure so callers are never blocked by Discord API issues.
|
||||
* @param discordId - The Discord user ID to look up.
|
||||
* @returns The Discord user object, or null if the fetch fails.
|
||||
*/
|
||||
const fetchDiscordUserById = async(
|
||||
discordId: string,
|
||||
): Promise<DiscordUser | null> => {
|
||||
const botToken = process.env.DISCORD_BOT_TOKEN;
|
||||
if (botToken === undefined || botToken === "") {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
const response = await fetch(
|
||||
`https://discord.com/api/v10/users/${discordId}`,
|
||||
{ headers: { Authorization: `Bot ${botToken}` } },
|
||||
);
|
||||
if (!response.ok) {
|
||||
return null;
|
||||
}
|
||||
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Response JSON matches DiscordUser shape */
|
||||
return await (response.json() as Promise<DiscordUser>);
|
||||
} catch (error) {
|
||||
void logger.error(
|
||||
"discord_fetch_user_by_id",
|
||||
error instanceof Error
|
||||
? error
|
||||
: new Error(String(error)),
|
||||
);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Builds the Discord OAuth authorisation URL.
|
||||
* @returns The full OAuth URL to redirect the user to.
|
||||
* @throws {Error} If OAuth environment variables are missing.
|
||||
*/
|
||||
const buildOAuthUrl = (): string => {
|
||||
const clientId = process.env.DISCORD_CLIENT_ID;
|
||||
const redirectUri = process.env.DISCORD_REDIRECT_URI;
|
||||
|
||||
if (
|
||||
clientId === undefined || clientId === ""
|
||||
|| redirectUri === undefined || redirectUri === ""
|
||||
) {
|
||||
throw new Error("Discord OAuth environment variables are required");
|
||||
}
|
||||
|
||||
const parameters = new URLSearchParams({
|
||||
client_id: clientId,
|
||||
redirect_uri: redirectUri,
|
||||
client_id: discordClientId,
|
||||
redirect_uri: discordRedirectUri,
|
||||
response_type: "code",
|
||||
scope: "identify",
|
||||
});
|
||||
@@ -133,4 +154,4 @@ const buildOAuthUrl = (): string => {
|
||||
};
|
||||
|
||||
export type { DiscordTokenResponse, DiscordUser };
|
||||
export { buildOAuthUrl, exchangeCode, fetchDiscordUser };
|
||||
export { buildOAuthUrl, exchangeCode, fetchDiscordUser, fetchDiscordUserById };
|
||||
|
||||
@@ -0,0 +1,182 @@
|
||||
/**
|
||||
* @file Discord Gateway WebSocket client for listening to guild member events.
|
||||
* @copyright nhcarrigan
|
||||
* @license Naomi's Public License
|
||||
* @author Naomi Carrigan
|
||||
*/
|
||||
/* eslint-disable max-lines-per-function -- WebSocket gateway requires sequential event handler setup */
|
||||
import { prisma } from "../db/client.js";
|
||||
import { logger } from "./logger.js";
|
||||
|
||||
const discordGuildId = "1354624415861833870";
|
||||
|
||||
/**
|
||||
* Discord Gateway opcodes used by this client.
|
||||
*/
|
||||
const gatewayOpcodes = {
|
||||
dispatch: 0,
|
||||
heartbeat: 1,
|
||||
heartbeatAck: 11,
|
||||
hello: 10,
|
||||
identify: 2,
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* GUILD_MEMBERS privileged intent bitmask.
|
||||
*/
|
||||
/* eslint-disable-next-line no-bitwise -- Bitwise shift required for Discord intent bitmask */
|
||||
const guildMembersIntent = 1 << 1;
|
||||
|
||||
/**
|
||||
* Updates the inGuild flag for a player when they join the configured guild.
|
||||
* No-ops silently if the Discord user has no player record.
|
||||
* @param discordId - The Discord user ID of the member who joined.
|
||||
* @param guildId - The ID of the guild they joined.
|
||||
* @returns A promise that resolves when the update attempt completes.
|
||||
*/
|
||||
const handleGuildMemberAdd = async(
|
||||
discordId: string,
|
||||
guildId: string,
|
||||
): Promise<void> => {
|
||||
if (guildId !== discordGuildId) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await prisma.player.updateMany({
|
||||
data: { inGuild: true },
|
||||
where: { discordId },
|
||||
});
|
||||
} catch (error) {
|
||||
void logger.error(
|
||||
"gateway_member_add",
|
||||
error instanceof Error
|
||||
? error
|
||||
: new Error(String(error)),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Updates the inGuild flag for a player when they leave the configured guild.
|
||||
* No-ops silently if the Discord user has no player record.
|
||||
* @param discordId - The Discord user ID of the member who left.
|
||||
* @param guildId - The ID of the guild they left.
|
||||
* @returns A promise that resolves when the update attempt completes.
|
||||
*/
|
||||
const handleGuildMemberRemove = async(
|
||||
discordId: string,
|
||||
guildId: string,
|
||||
): Promise<void> => {
|
||||
if (guildId !== discordGuildId) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await prisma.player.updateMany({
|
||||
data: { inGuild: false },
|
||||
where: { discordId },
|
||||
});
|
||||
} catch (error) {
|
||||
void logger.error(
|
||||
"gateway_member_remove",
|
||||
error instanceof Error
|
||||
? error
|
||||
: new Error(String(error)),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
// eslint-disable-next-line capitalized-comments -- v8 ignore directive must be lowercase
|
||||
/* v8 ignore next 95 -- @preserve */
|
||||
/**
|
||||
* Connects to the Discord Gateway and listens for guild member events.
|
||||
* Reconnects automatically on close or error.
|
||||
* Requires the GUILD_MEMBERS privileged intent to be enabled in the Discord Developer Portal.
|
||||
*/
|
||||
const connectGateway = (): void => {
|
||||
const botToken = process.env.DISCORD_BOT_TOKEN;
|
||||
if (botToken === undefined || botToken === "") {
|
||||
void logger.log("info", "Gateway: no bot token configured, skipping");
|
||||
return;
|
||||
}
|
||||
|
||||
const ws = new WebSocket("wss://gateway.discord.gg/?v=10&encoding=json");
|
||||
let heartbeatInterval: ReturnType<typeof setInterval> | null = null;
|
||||
let lastSequence: number | null = null;
|
||||
|
||||
const stopHeartbeat = (): void => {
|
||||
if (heartbeatInterval !== null) {
|
||||
clearInterval(heartbeatInterval);
|
||||
heartbeatInterval = null;
|
||||
}
|
||||
};
|
||||
|
||||
ws.addEventListener("message", (event) => {
|
||||
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Gateway payload is JSON */
|
||||
const payload = JSON.parse(event.data as string) as {
|
||||
op: number;
|
||||
d: unknown;
|
||||
s: number | null;
|
||||
t: string | null;
|
||||
};
|
||||
|
||||
if (payload.s !== null) {
|
||||
lastSequence = payload.s;
|
||||
}
|
||||
|
||||
if (payload.op === gatewayOpcodes.hello) {
|
||||
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions, @typescript-eslint/naming-convention -- HELLO d shape; Discord API snake_case */
|
||||
const helloData = payload.d as { heartbeat_interval: number };
|
||||
const heartbeatMs = helloData.heartbeat_interval;
|
||||
heartbeatInterval = setInterval(() => {
|
||||
ws.send(JSON.stringify({
|
||||
d: lastSequence,
|
||||
op: gatewayOpcodes.heartbeat,
|
||||
}));
|
||||
}, heartbeatMs);
|
||||
|
||||
ws.send(JSON.stringify({
|
||||
d: {
|
||||
intents: guildMembersIntent,
|
||||
properties: { browser: "elysium", device: "elysium", os: "linux" },
|
||||
token: botToken,
|
||||
},
|
||||
op: gatewayOpcodes.identify,
|
||||
}));
|
||||
}
|
||||
|
||||
if (payload.op === gatewayOpcodes.dispatch && payload.t !== null) {
|
||||
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions, @typescript-eslint/naming-convention -- dispatch payload shape; Discord API snake_case */
|
||||
const data = payload.d as { user?: { id: string }; guild_id?: string };
|
||||
const discordId = data.user?.id;
|
||||
const guildId = data.guild_id;
|
||||
|
||||
if (discordId === undefined || guildId === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (payload.t === "GUILD_MEMBER_ADD") {
|
||||
void handleGuildMemberAdd(discordId, guildId);
|
||||
} else if (payload.t === "GUILD_MEMBER_REMOVE") {
|
||||
void handleGuildMemberRemove(discordId, guildId);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ws.addEventListener("close", () => {
|
||||
stopHeartbeat();
|
||||
void logger.log("info", "Gateway: connection closed, reconnecting in 5s");
|
||||
setTimeout(connectGateway, 5000);
|
||||
});
|
||||
|
||||
ws.addEventListener("error", (event) => {
|
||||
const message
|
||||
= event instanceof ErrorEvent
|
||||
? event.message
|
||||
: "WebSocket error";
|
||||
void logger.error("gateway_error", new Error(message));
|
||||
stopHeartbeat();
|
||||
ws.close();
|
||||
});
|
||||
};
|
||||
|
||||
export { connectGateway, handleGuildMemberAdd, handleGuildMemberRemove };
|
||||
@@ -5,6 +5,7 @@
|
||||
* @author Naomi Carrigan
|
||||
*/
|
||||
/* eslint-disable max-lines-per-function -- buildPostPrestigeState requires constructing a large composite state object */
|
||||
/* eslint-disable complexity -- buildPostPrestigeState has many optional fields that each add a branch point */
|
||||
import { initialGameState } from "../data/initialState.js";
|
||||
import { defaultPrestigeUpgrades } from "../data/prestigeUpgrades.js";
|
||||
import type {
|
||||
@@ -14,14 +15,21 @@ import type {
|
||||
} from "@elysium/types";
|
||||
|
||||
const basePrestigeGoldThreshold = 1_000_000;
|
||||
const thresholdScaleFactor = 5;
|
||||
const runestonesPerPrestigeLevel = 10;
|
||||
const runestonesPerPrestigeLevel = 15;
|
||||
const milestoneInterval = 5;
|
||||
const milestoneRunestonesPerInterval = 25;
|
||||
|
||||
/*
|
||||
* Hard cap on the base runestone yield (before multipliers) to prevent
|
||||
* extreme AFK accumulation from producing game-breaking runestone counts.
|
||||
* With all upgrades (5.625× max) this caps out at ~1,125 per prestige.
|
||||
*/
|
||||
const maxBaseRunestones = 200;
|
||||
|
||||
/**
|
||||
* Calculates the gold threshold required for the next prestige.
|
||||
* Formula: BASE * SCALE_FACTOR^prestigeCount — each prestige makes the next threshold harder.
|
||||
* Formula: BASE * (count + 1)^2 — polynomial growth that peaks around prestige 8–10
|
||||
* then gets easier as the production multiplier overtakes it.
|
||||
* @param prestigeCount - The current number of prestiges completed.
|
||||
* @param thresholdMultiplier - An optional echo-upgrade multiplier applied to the threshold.
|
||||
* @returns The gold amount required to prestige.
|
||||
@@ -32,7 +40,7 @@ const calculatePrestigeThreshold = (
|
||||
): number => {
|
||||
return (
|
||||
basePrestigeGoldThreshold
|
||||
* Math.pow(thresholdScaleFactor, prestigeCount)
|
||||
* Math.pow(prestigeCount + 1, 2)
|
||||
* thresholdMultiplier
|
||||
);
|
||||
};
|
||||
@@ -106,7 +114,9 @@ interface RunestoneParameters {
|
||||
|
||||
/**
|
||||
* Calculates how many runestones the player earns from a prestige.
|
||||
* Formula: floor(sqrt(totalGoldEarned / threshold)) * RUNESTONES_PER_PRESTIGE_LEVEL * runestoneMultiplier.
|
||||
* Formula: min(floor(cbrt(totalGoldEarned / threshold)) * RUNESTONES_PER_PRESTIGE_LEVEL, MAX_BASE) * multipliers.
|
||||
* Uses cube root for stronger diminishing returns than sqrt, and caps the base before multipliers
|
||||
* to prevent extended AFK sessions from producing runestone windfalls.
|
||||
* @param parameters - The parameters for the runestone calculation.
|
||||
* @param parameters.totalGoldEarned - The total gold earned in the current run.
|
||||
* @param parameters.prestigeCount - The current prestige count.
|
||||
@@ -122,9 +132,11 @@ const calculateRunestones = (parameters: RunestoneParameters): number => {
|
||||
echoRunestoneMultiplier = 1,
|
||||
} = parameters;
|
||||
const threshold = calculatePrestigeThreshold(prestigeCount);
|
||||
const base
|
||||
= Math.floor(Math.sqrt(totalGoldEarned / threshold))
|
||||
* runestonesPerPrestigeLevel;
|
||||
const base = Math.min(
|
||||
Math.floor(Math.cbrt(totalGoldEarned / threshold))
|
||||
* runestonesPerPrestigeLevel,
|
||||
maxBaseRunestones,
|
||||
);
|
||||
const runestoneMult = getCategoryMultiplier(
|
||||
purchasedUpgradeIds,
|
||||
"runestones",
|
||||
@@ -134,19 +146,20 @@ const calculateRunestones = (parameters: RunestoneParameters): number => {
|
||||
|
||||
/**
|
||||
* Calculates the new prestige production multiplier.
|
||||
* Formula: 1.15^prestigeCount — exponential scaling per prestige.
|
||||
* Formula: 1.3^prestigeCount — exponential scaling per prestige that eventually
|
||||
* overtakes the polynomial threshold growth, making late prestiges progressively easier.
|
||||
* @param prestigeCount - The new prestige count.
|
||||
* @returns The production multiplier for the new prestige level.
|
||||
*/
|
||||
const calculateProductionMultiplier = (
|
||||
prestigeCount: number,
|
||||
): number => {
|
||||
return Math.pow(1.15, prestigeCount);
|
||||
return Math.pow(1.3, prestigeCount);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the milestone runestone bonus for the given prestige count.
|
||||
* Every MILESTONE_INTERVAL prestiges awards milestone_number * MILESTONE_RUNESTONES_PER_INTERVAL stones.
|
||||
* Every MILESTONE_INTERVAL prestiges awards milestone_number² * MILESTONE_RUNESTONES_PER_INTERVAL stones.
|
||||
* @param prestigeCount - The prestige count after the current prestige.
|
||||
* @returns The milestone runestone bonus, or 0 if not a milestone prestige.
|
||||
*/
|
||||
@@ -155,7 +168,7 @@ const calculateMilestoneBonus = (prestigeCount: number): number => {
|
||||
return 0;
|
||||
}
|
||||
const milestoneNumber = prestigeCount / milestoneInterval;
|
||||
return milestoneNumber * milestoneRunestonesPerInterval;
|
||||
return milestoneNumber * milestoneNumber * milestoneRunestonesPerInterval;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -214,7 +227,10 @@ const buildPostPrestigeState = (
|
||||
const currentBoss = currentState.bosses.find((candidate) => {
|
||||
return candidate.id === freshBoss.id;
|
||||
});
|
||||
if (currentBoss?.bountyRunestonesClaimed === true) {
|
||||
if (
|
||||
currentBoss?.bountyRunestonesClaimed === true
|
||||
|| currentBoss?.status === "defeated"
|
||||
) {
|
||||
return { ...freshBoss, bountyRunestonesClaimed: true };
|
||||
}
|
||||
return freshBoss;
|
||||
@@ -239,11 +255,21 @@ const buildPostPrestigeState = (
|
||||
|
||||
const prestigeState: GameState = {
|
||||
...freshState,
|
||||
|
||||
// Achievements are permanent — earned achievements survive all prestiges
|
||||
achievements: currentState.achievements,
|
||||
|
||||
/*
|
||||
* Preserve automation preferences across prestige — the player explicitly
|
||||
* opted into these settings and would not expect them to silently reset.
|
||||
*/
|
||||
autoAdventurer: currentState.autoAdventurer ?? false,
|
||||
autoBoss: currentState.autoBoss ?? false,
|
||||
|
||||
autoQuest: currentState.autoQuest ?? false,
|
||||
// Boss statuses reset for gameplay, but first-kill claimed flag is preserved
|
||||
bosses: bossesWithBountyClaimed,
|
||||
lastTickAt: Date.now(),
|
||||
bosses: bossesWithBountyClaimed,
|
||||
lastTickAt: Date.now(),
|
||||
|
||||
/*
|
||||
* Fold current-run totals into lifetime stats so the GameState reflects
|
||||
|
||||
@@ -20,7 +20,7 @@ const finalBossId = "the_absolute_one";
|
||||
/**
|
||||
* Base constant used in the echo yield formula.
|
||||
*/
|
||||
const echoFormulaConstant = 853;
|
||||
const echoFormulaConstant = 224;
|
||||
|
||||
const getCategoryMultiplier = (
|
||||
purchasedIds: Array<string>,
|
||||
|
||||
@@ -15,6 +15,49 @@ const discordApi = "https://discord.com/api/v10";
|
||||
*/
|
||||
const suppressNotifications = 4096;
|
||||
|
||||
/**
|
||||
* The Discord role ID for the Elysian role granted to all Elysium players.
|
||||
*/
|
||||
const discordGuildId = "1354624415861833870";
|
||||
const elysianRoleId = "1486144823684628490";
|
||||
const apotheosisRoleId = "1479966598210129991";
|
||||
|
||||
/**
|
||||
* Grants the Elysian Discord role to the given player and returns whether they are in the guild.
|
||||
* Fails silently so role grant errors do not affect the auth flow.
|
||||
* @param discordId - The Discord user ID to grant the role to.
|
||||
* @returns True if the player is in the guild and the role was granted, false otherwise.
|
||||
*/
|
||||
const grantElysianRole = async(discordId: string): Promise<boolean> => {
|
||||
const botToken = process.env.DISCORD_BOT_TOKEN;
|
||||
|
||||
if (botToken === undefined || botToken === "") {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${discordApi}/guilds/${discordGuildId}/members/${discordId}/roles/${elysianRoleId}`,
|
||||
{
|
||||
headers: {
|
||||
"Authorization": `Bot ${botToken}`,
|
||||
"User-Agent": "DiscordBot (https://elysium.nhcarrigan.com, 1.0.0)",
|
||||
},
|
||||
method: "PUT",
|
||||
},
|
||||
);
|
||||
return response.ok || response.status === 204;
|
||||
} catch (error) {
|
||||
void logger.error(
|
||||
"webhook_elysian_role",
|
||||
error instanceof Error
|
||||
? error
|
||||
: new Error(String(error)),
|
||||
);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Grants the apotheosis Discord role to the given player if configured.
|
||||
* Fails silently so role grant errors do not affect the game action.
|
||||
@@ -23,23 +66,20 @@ const suppressNotifications = 4096;
|
||||
*/
|
||||
const grantApotheosisRole = async(discordId: string): Promise<void> => {
|
||||
const botToken = process.env.DISCORD_BOT_TOKEN;
|
||||
const guildId = process.env.DISCORD_GUILD_ID;
|
||||
const roleId = process.env.DISCORD_APOTHEOSIS_ROLE_ID;
|
||||
|
||||
if (
|
||||
botToken === undefined || botToken === ""
|
||||
|| guildId === undefined || guildId === ""
|
||||
|| roleId === undefined || roleId === ""
|
||||
) {
|
||||
if (botToken === undefined || botToken === "") {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await fetch(
|
||||
`${discordApi}/guilds/${guildId}/members/${discordId}/roles/${roleId}`,
|
||||
`${discordApi}/guilds/${discordGuildId}/members/${discordId}/roles/${apotheosisRoleId}`,
|
||||
{
|
||||
headers: { Authorization: `Bot ${botToken}` },
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"Authorization": `Bot ${botToken}`,
|
||||
"User-Agent": "DiscordBot (https://elysium.nhcarrigan.com, 1.0.0)",
|
||||
},
|
||||
method: "PUT",
|
||||
},
|
||||
);
|
||||
} catch (error) {
|
||||
@@ -109,4 +149,4 @@ const postMilestoneWebhook = async(
|
||||
}
|
||||
};
|
||||
|
||||
export { grantApotheosisRole, postMilestoneWebhook };
|
||||
export { grantApotheosisRole, grantElysianRole, postMilestoneWebhook };
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -77,6 +77,99 @@ describe("explore route", () => {
|
||||
body: JSON.stringify(body),
|
||||
}));
|
||||
|
||||
const getClaimable = (areaId?: string) => {
|
||||
const url = areaId === undefined
|
||||
? "http://localhost/explore/claimable"
|
||||
: `http://localhost/explore/claimable?areaId=${areaId}`;
|
||||
return app.fetch(new Request(url));
|
||||
};
|
||||
|
||||
describe("GET /claimable", () => {
|
||||
it("returns 400 when areaId is missing", async () => {
|
||||
const res = await getClaimable();
|
||||
expect(res.status).toBe(400);
|
||||
});
|
||||
|
||||
it("returns 404 for unknown area", async () => {
|
||||
const res = await getClaimable("nonexistent_area");
|
||||
expect(res.status).toBe(404);
|
||||
});
|
||||
|
||||
it("returns 404 when no save is found", async () => {
|
||||
vi.mocked(prisma.gameState.findUnique).mockResolvedValueOnce(null);
|
||||
const res = await getClaimable(TEST_AREA_ID);
|
||||
expect(res.status).toBe(404);
|
||||
});
|
||||
|
||||
it("returns claimable=false when no exploration state exists", async () => {
|
||||
const state = makeState({ exploration: undefined });
|
||||
vi.mocked(prisma.gameState.findUnique).mockResolvedValueOnce({ state } as never);
|
||||
const res = await getClaimable(TEST_AREA_ID);
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.json() as { claimable: boolean };
|
||||
expect(body.claimable).toBe(false);
|
||||
});
|
||||
|
||||
it("returns claimable=false when area is not in_progress", async () => {
|
||||
const state = makeState();
|
||||
vi.mocked(prisma.gameState.findUnique).mockResolvedValueOnce({ state } as never);
|
||||
const res = await getClaimable(TEST_AREA_ID);
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.json() as { claimable: boolean };
|
||||
expect(body.claimable).toBe(false);
|
||||
});
|
||||
|
||||
it("returns claimable=false when exploration is still in progress", async () => {
|
||||
const state = makeState({
|
||||
exploration: {
|
||||
areas: [{ id: TEST_AREA_ID, status: "in_progress", startedAt: Date.now(), completedOnce: false }] as GameState["exploration"]["areas"],
|
||||
materials: [],
|
||||
craftedRecipeIds: [],
|
||||
craftedGoldMultiplier: 1,
|
||||
craftedEssenceMultiplier: 1,
|
||||
craftedClickMultiplier: 1,
|
||||
craftedCombatMultiplier: 1,
|
||||
},
|
||||
});
|
||||
vi.mocked(prisma.gameState.findUnique).mockResolvedValueOnce({ state } as never);
|
||||
const res = await getClaimable(TEST_AREA_ID);
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.json() as { claimable: boolean };
|
||||
expect(body.claimable).toBe(false);
|
||||
});
|
||||
|
||||
it("returns claimable=true when exploration is complete", async () => {
|
||||
const state = makeState({
|
||||
exploration: {
|
||||
areas: [{ id: TEST_AREA_ID, status: "in_progress", startedAt: 0, completedOnce: false }] as GameState["exploration"]["areas"],
|
||||
materials: [],
|
||||
craftedRecipeIds: [],
|
||||
craftedGoldMultiplier: 1,
|
||||
craftedEssenceMultiplier: 1,
|
||||
craftedClickMultiplier: 1,
|
||||
craftedCombatMultiplier: 1,
|
||||
},
|
||||
});
|
||||
vi.mocked(prisma.gameState.findUnique).mockResolvedValueOnce({ state } as never);
|
||||
const res = await getClaimable(TEST_AREA_ID);
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.json() as { claimable: boolean };
|
||||
expect(body.claimable).toBe(true);
|
||||
});
|
||||
|
||||
it("returns 500 when the database throws", async () => {
|
||||
vi.mocked(prisma.gameState.findUnique).mockRejectedValueOnce(new Error("DB error"));
|
||||
const res = await getClaimable(TEST_AREA_ID);
|
||||
expect(res.status).toBe(500);
|
||||
});
|
||||
|
||||
it("returns 500 when the database throws a non-Error value", async () => {
|
||||
vi.mocked(prisma.gameState.findUnique).mockRejectedValueOnce("raw string error");
|
||||
const res = await getClaimable(TEST_AREA_ID);
|
||||
expect(res.status).toBe(500);
|
||||
});
|
||||
});
|
||||
|
||||
describe("POST /start", () => {
|
||||
it("returns 400 when areaId is missing", async () => {
|
||||
const res = await postStart({});
|
||||
|
||||
@@ -19,8 +19,12 @@ vi.mock("../../src/middleware/auth.js", () => ({
|
||||
}),
|
||||
}));
|
||||
|
||||
vi.mock("../../src/services/discord.js", () => ({
|
||||
fetchDiscordUserById: vi.fn().mockResolvedValue(null),
|
||||
}));
|
||||
|
||||
const DISCORD_ID = "test_discord_id";
|
||||
const CURRENT_SCHEMA_VERSION = 1;
|
||||
const CURRENT_SCHEMA_VERSION = 2;
|
||||
|
||||
const makeState = (overrides: Partial<GameState> = {}): GameState => ({
|
||||
player: { discordId: DISCORD_ID, username: "u", discriminator: "0", avatar: null, totalGoldEarned: 0, totalClicks: 0, characterName: "T" },
|
||||
@@ -200,6 +204,75 @@ describe("game route", () => {
|
||||
expect(body.offlineGold).toBeGreaterThan(0);
|
||||
expect(body.offlineEssence).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it("syncs updated avatar from Discord into the returned state", async () => {
|
||||
const todayUTC = new Date().toISOString().slice(0, 10);
|
||||
const state = makeState();
|
||||
vi.mocked(prisma.gameState.findUnique).mockResolvedValueOnce({ state } as never);
|
||||
vi.mocked(prisma.player.findUnique).mockResolvedValueOnce(
|
||||
makePlayer({ lastLoginDate: todayUTC, avatar: "old_hash" }) as never,
|
||||
);
|
||||
vi.mocked(prisma.gameState.update).mockResolvedValueOnce({} as never);
|
||||
vi.mocked(prisma.player.update).mockResolvedValueOnce({} as never);
|
||||
const { fetchDiscordUserById } = await import("../../src/services/discord.js");
|
||||
vi.mocked(fetchDiscordUserById).mockResolvedValueOnce({
|
||||
id: DISCORD_ID, username: "u", discriminator: "0", avatar: "new_hash",
|
||||
});
|
||||
const res = await app.fetch(new Request("http://localhost/game/load"));
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.json() as { state: GameState };
|
||||
expect(body.state.player.avatar).toBe("new_hash");
|
||||
});
|
||||
|
||||
it("continues loading when the avatar DB update fails", async () => {
|
||||
const todayUTC = new Date().toISOString().slice(0, 10);
|
||||
const state = makeState();
|
||||
vi.mocked(prisma.gameState.findUnique).mockResolvedValueOnce({ state } as never);
|
||||
vi.mocked(prisma.player.findUnique).mockResolvedValueOnce(
|
||||
makePlayer({ lastLoginDate: todayUTC, avatar: "old_hash" }) as never,
|
||||
);
|
||||
vi.mocked(prisma.gameState.update).mockResolvedValueOnce({} as never);
|
||||
vi.mocked(prisma.player.update).mockRejectedValueOnce(new Error("db error"));
|
||||
const { fetchDiscordUserById } = await import("../../src/services/discord.js");
|
||||
vi.mocked(fetchDiscordUserById).mockResolvedValueOnce({
|
||||
id: DISCORD_ID, username: "u", discriminator: "0", avatar: "new_hash",
|
||||
});
|
||||
const res = await app.fetch(new Request("http://localhost/game/load"));
|
||||
expect(res.status).toBe(200);
|
||||
});
|
||||
|
||||
it("continues loading when the avatar DB update fails with a non-Error value", async () => {
|
||||
const todayUTC = new Date().toISOString().slice(0, 10);
|
||||
const state = makeState();
|
||||
vi.mocked(prisma.gameState.findUnique).mockResolvedValueOnce({ state } as never);
|
||||
vi.mocked(prisma.player.findUnique).mockResolvedValueOnce(
|
||||
makePlayer({ lastLoginDate: todayUTC, avatar: "old_hash" }) as never,
|
||||
);
|
||||
vi.mocked(prisma.gameState.update).mockResolvedValueOnce({} as never);
|
||||
vi.mocked(prisma.player.update).mockRejectedValueOnce("raw string error");
|
||||
const { fetchDiscordUserById } = await import("../../src/services/discord.js");
|
||||
vi.mocked(fetchDiscordUserById).mockResolvedValueOnce({
|
||||
id: DISCORD_ID, username: "u", discriminator: "0", avatar: "new_hash",
|
||||
});
|
||||
const res = await app.fetch(new Request("http://localhost/game/load"));
|
||||
expect(res.status).toBe(200);
|
||||
});
|
||||
|
||||
it("keeps stored avatar when Discord returns null", async () => {
|
||||
const todayUTC = new Date().toISOString().slice(0, 10);
|
||||
const state = makeState();
|
||||
vi.mocked(prisma.gameState.findUnique).mockResolvedValueOnce({ state } as never);
|
||||
vi.mocked(prisma.player.findUnique).mockResolvedValueOnce(
|
||||
makePlayer({ lastLoginDate: todayUTC, avatar: "stored_hash" }) as never,
|
||||
);
|
||||
vi.mocked(prisma.gameState.update).mockResolvedValueOnce({} as never);
|
||||
const { fetchDiscordUserById } = await import("../../src/services/discord.js");
|
||||
vi.mocked(fetchDiscordUserById).mockResolvedValueOnce(null);
|
||||
const res = await app.fetch(new Request("http://localhost/game/load"));
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.json() as { state: GameState };
|
||||
expect(body.state.player.avatar).toBe("stored_hash");
|
||||
});
|
||||
});
|
||||
|
||||
describe("POST /save", () => {
|
||||
|
||||
@@ -7,8 +7,8 @@ import type { GameState } from "@elysium/types";
|
||||
|
||||
vi.mock("../../src/db/client.js", () => ({
|
||||
prisma: {
|
||||
player: { update: vi.fn() },
|
||||
gameState: { findUnique: vi.fn(), update: vi.fn() },
|
||||
player: { findUnique: vi.fn(), update: vi.fn() },
|
||||
gameState: { findUnique: vi.fn(), update: vi.fn(), updateMany: vi.fn() },
|
||||
},
|
||||
}));
|
||||
|
||||
@@ -47,8 +47,8 @@ const makeState = (overrides: Partial<GameState> = {}): GameState => ({
|
||||
describe("prestige route", () => {
|
||||
let app: Hono;
|
||||
let prisma: {
|
||||
player: { update: ReturnType<typeof vi.fn> };
|
||||
gameState: { findUnique: ReturnType<typeof vi.fn>; update: ReturnType<typeof vi.fn> };
|
||||
player: { findUnique: ReturnType<typeof vi.fn>; update: ReturnType<typeof vi.fn> };
|
||||
gameState: { findUnique: ReturnType<typeof vi.fn>; update: ReturnType<typeof vi.fn>; updateMany: ReturnType<typeof vi.fn> };
|
||||
};
|
||||
|
||||
beforeEach(async () => {
|
||||
@@ -83,8 +83,8 @@ describe("prestige route", () => {
|
||||
|
||||
it("returns runestones on successful prestige", async () => {
|
||||
const state = makeState();
|
||||
vi.mocked(prisma.gameState.findUnique).mockResolvedValueOnce({ state } as never);
|
||||
vi.mocked(prisma.gameState.update).mockResolvedValueOnce({} as never);
|
||||
vi.mocked(prisma.gameState.findUnique).mockResolvedValueOnce({ state, updatedAt: 0 } as never);
|
||||
vi.mocked(prisma.gameState.updateMany).mockResolvedValueOnce({ count: 1 } as never);
|
||||
vi.mocked(prisma.player.update).mockResolvedValueOnce({} as never);
|
||||
const res = await post("");
|
||||
expect(res.status).toBe(200);
|
||||
@@ -93,6 +93,14 @@ describe("prestige route", () => {
|
||||
expect(body.runestones).toBeGreaterThanOrEqual(0);
|
||||
});
|
||||
|
||||
it("returns 409 when a concurrent prestige already committed", async () => {
|
||||
const state = makeState();
|
||||
vi.mocked(prisma.gameState.findUnique).mockResolvedValueOnce({ state, updatedAt: 0 } as never);
|
||||
vi.mocked(prisma.gameState.updateMany).mockResolvedValueOnce({ count: 0 } as never);
|
||||
const res = await post("");
|
||||
expect(res.status).toBe(409);
|
||||
});
|
||||
|
||||
it("returns 500 when the database throws during prestige", async () => {
|
||||
vi.mocked(prisma.gameState.findUnique).mockRejectedValueOnce(new Error("DB error"));
|
||||
const res = await post("");
|
||||
@@ -112,14 +120,26 @@ describe("prestige route", () => {
|
||||
challenges: [{ id: "prestige_challenge", type: "prestige", target: 2, progress: 0, completed: false, crystalReward: 5 }],
|
||||
} as GameState["dailyChallenges"],
|
||||
});
|
||||
vi.mocked(prisma.gameState.findUnique).mockResolvedValueOnce({ state } as never);
|
||||
vi.mocked(prisma.gameState.update).mockResolvedValueOnce({} as never);
|
||||
vi.mocked(prisma.gameState.findUnique).mockResolvedValueOnce({ state, updatedAt: 0 } as never);
|
||||
vi.mocked(prisma.gameState.updateMany).mockResolvedValueOnce({ count: 1 } as never);
|
||||
vi.mocked(prisma.player.update).mockResolvedValueOnce({} as never);
|
||||
const res = await post("");
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.json() as { runestones: number; newPrestigeCount: number };
|
||||
expect(body.newPrestigeCount).toBe(1);
|
||||
});
|
||||
|
||||
it("skips webhook when enablePrestigeAnnouncements is false", async () => {
|
||||
const { postMilestoneWebhook } = await import("../../src/services/webhook.js");
|
||||
const state = makeState();
|
||||
vi.mocked(prisma.gameState.findUnique).mockResolvedValueOnce({ state, updatedAt: 0 } as never);
|
||||
vi.mocked(prisma.gameState.updateMany).mockResolvedValueOnce({ count: 1 } as never);
|
||||
vi.mocked(prisma.player.update).mockResolvedValueOnce({} as never);
|
||||
vi.mocked(prisma.player.findUnique).mockResolvedValueOnce({ profileSettings: { enablePrestigeAnnouncements: false } } as never);
|
||||
const res = await post("");
|
||||
expect(res.status).toBe(200);
|
||||
expect(postMilestoneWebhook).not.toHaveBeenCalledWith(expect.anything(), "prestige", expect.anything());
|
||||
});
|
||||
});
|
||||
|
||||
describe("POST /buy-upgrade", () => {
|
||||
|
||||
@@ -158,7 +158,7 @@ describe("transcendence route", () => {
|
||||
const res = await post("/buy-upgrade", { upgradeId: "echo_income_1" });
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.json() as { echoesRemaining: number; purchasedUpgradeIds: string[] };
|
||||
expect(body.echoesRemaining).toBe(95); // 100 - 5
|
||||
expect(body.echoesRemaining).toBe(98); // 100 - 2
|
||||
expect(body.purchasedUpgradeIds).toContain("echo_income_1");
|
||||
});
|
||||
|
||||
|
||||
@@ -46,13 +46,24 @@ describe("generateDailyChallenges", () => {
|
||||
expect(a.map((c) => c.id)).toEqual(b.map((c) => c.id));
|
||||
});
|
||||
|
||||
it("always includes a clicks challenge regardless of date", async () => {
|
||||
vi.setSystemTime(LA_MIDNIGHT_2024_01_15);
|
||||
const { generateDailyChallenges } = await import("../../src/services/dailyChallenges.js");
|
||||
const day1 = generateDailyChallenges("2024-01-15");
|
||||
const day2 = generateDailyChallenges("2024-01-16");
|
||||
expect(day1.some((c) => c.type === "clicks")).toBe(true);
|
||||
expect(day2.some((c) => c.type === "clicks")).toBe(true);
|
||||
});
|
||||
|
||||
it("generates different challenges for different dates", async () => {
|
||||
vi.setSystemTime(LA_MIDNIGHT_2024_01_15);
|
||||
const { generateDailyChallenges } = await import("../../src/services/dailyChallenges.js");
|
||||
const day1 = generateDailyChallenges("2024-01-15");
|
||||
const day2 = generateDailyChallenges("2024-01-16");
|
||||
// They should differ in at least one challenge ID (types vary by seed)
|
||||
expect(day1.map((c) => c.type)).not.toEqual(day2.map((c) => c.type));
|
||||
// The 2 non-clicks types should vary by seed between dates
|
||||
const day1NonClicks = day1.filter((c) => c.type !== "clicks").map((c) => c.type);
|
||||
const day2NonClicks = day2.filter((c) => c.type !== "clicks").map((c) => c.type);
|
||||
expect(day1NonClicks).not.toEqual(day2NonClicks);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -18,51 +18,31 @@ describe("discord service", () => {
|
||||
});
|
||||
|
||||
describe("buildOAuthUrl", () => {
|
||||
it("throws when DISCORD_CLIENT_ID is missing", async () => {
|
||||
delete process.env["DISCORD_CLIENT_ID"];
|
||||
process.env["DISCORD_REDIRECT_URI"] = "http://localhost/callback";
|
||||
const { buildOAuthUrl } = await import("../../src/services/discord.js");
|
||||
expect(() => buildOAuthUrl()).toThrow("Discord OAuth environment variables are required");
|
||||
});
|
||||
|
||||
it("throws when DISCORD_REDIRECT_URI is missing", async () => {
|
||||
process.env["DISCORD_CLIENT_ID"] = "client123";
|
||||
delete process.env["DISCORD_REDIRECT_URI"];
|
||||
const { buildOAuthUrl } = await import("../../src/services/discord.js");
|
||||
expect(() => buildOAuthUrl()).toThrow("Discord OAuth environment variables are required");
|
||||
});
|
||||
|
||||
it("returns a URL with correct query params", async () => {
|
||||
process.env["DISCORD_CLIENT_ID"] = "client123";
|
||||
process.env["DISCORD_REDIRECT_URI"] = "http://localhost/callback";
|
||||
const { buildOAuthUrl } = await import("../../src/services/discord.js");
|
||||
const url = buildOAuthUrl();
|
||||
expect(url).toContain("client_id=client123");
|
||||
expect(url).toContain("client_id=1479551654264049908");
|
||||
expect(url).toContain("response_type=code");
|
||||
expect(url).toContain("scope=identify");
|
||||
});
|
||||
});
|
||||
|
||||
describe("exchangeCode", () => {
|
||||
it("throws when env vars are missing", async () => {
|
||||
delete process.env["DISCORD_CLIENT_ID"];
|
||||
it("throws when DISCORD_CLIENT_SECRET is missing", async () => {
|
||||
delete process.env["DISCORD_CLIENT_SECRET"];
|
||||
const { exchangeCode } = await import("../../src/services/discord.js");
|
||||
await expect(exchangeCode("mycode")).rejects.toThrow("Discord OAuth environment variables are required");
|
||||
});
|
||||
|
||||
it("throws when response is not ok", async () => {
|
||||
process.env["DISCORD_CLIENT_ID"] = "cid";
|
||||
process.env["DISCORD_CLIENT_SECRET"] = "secret";
|
||||
process.env["DISCORD_REDIRECT_URI"] = "http://localhost/cb";
|
||||
mockFetch.mockResolvedValueOnce({ ok: false, statusText: "Unauthorized" });
|
||||
const { exchangeCode } = await import("../../src/services/discord.js");
|
||||
await expect(exchangeCode("bad_code")).rejects.toThrow("Discord token exchange failed");
|
||||
});
|
||||
|
||||
it("returns parsed body on success", async () => {
|
||||
process.env["DISCORD_CLIENT_ID"] = "cid";
|
||||
process.env["DISCORD_CLIENT_SECRET"] = "secret";
|
||||
process.env["DISCORD_REDIRECT_URI"] = "http://localhost/cb";
|
||||
const tokenData = { access_token: "tok", token_type: "Bearer", expires_in: 3600, refresh_token: "ref", scope: "identify" };
|
||||
mockFetch.mockResolvedValueOnce({ ok: true, json: () => Promise.resolve(tokenData) });
|
||||
const { exchangeCode } = await import("../../src/services/discord.js");
|
||||
@@ -96,12 +76,59 @@ describe("discord service", () => {
|
||||
|
||||
describe("exchangeCode non-Error throw", () => {
|
||||
it("re-throws when fetch rejects with a non-Error value", async () => {
|
||||
process.env["DISCORD_CLIENT_ID"] = "cid";
|
||||
process.env["DISCORD_CLIENT_SECRET"] = "secret";
|
||||
process.env["DISCORD_REDIRECT_URI"] = "http://localhost/cb";
|
||||
mockFetch.mockRejectedValueOnce("raw string error");
|
||||
const { exchangeCode } = await import("../../src/services/discord.js");
|
||||
await expect(exchangeCode("some_code")).rejects.toBe("raw string error");
|
||||
});
|
||||
});
|
||||
|
||||
describe("fetchDiscordUserById", () => {
|
||||
it("returns null when DISCORD_BOT_TOKEN is missing", async () => {
|
||||
delete process.env["DISCORD_BOT_TOKEN"];
|
||||
const { fetchDiscordUserById } = await import("../../src/services/discord.js");
|
||||
const result = await fetchDiscordUserById("123456");
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
|
||||
it("returns null when DISCORD_BOT_TOKEN is empty", async () => {
|
||||
process.env["DISCORD_BOT_TOKEN"] = "";
|
||||
const { fetchDiscordUserById } = await import("../../src/services/discord.js");
|
||||
const result = await fetchDiscordUserById("123456");
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
|
||||
it("returns null when response is not ok", async () => {
|
||||
process.env["DISCORD_BOT_TOKEN"] = "bot_token";
|
||||
mockFetch.mockResolvedValueOnce({ ok: false, statusText: "Not Found" });
|
||||
const { fetchDiscordUserById } = await import("../../src/services/discord.js");
|
||||
const result = await fetchDiscordUserById("123456");
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
|
||||
it("returns null when fetch throws", async () => {
|
||||
process.env["DISCORD_BOT_TOKEN"] = "bot_token";
|
||||
mockFetch.mockRejectedValueOnce(new Error("network error"));
|
||||
const { fetchDiscordUserById } = await import("../../src/services/discord.js");
|
||||
const result = await fetchDiscordUserById("123456");
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
|
||||
it("returns null when fetch throws a non-Error value", async () => {
|
||||
process.env["DISCORD_BOT_TOKEN"] = "bot_token";
|
||||
mockFetch.mockRejectedValueOnce("raw string error");
|
||||
const { fetchDiscordUserById } = await import("../../src/services/discord.js");
|
||||
const result = await fetchDiscordUserById("123456");
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
|
||||
it("returns the user on success", async () => {
|
||||
process.env["DISCORD_BOT_TOKEN"] = "bot_token";
|
||||
const user = { id: "123456", username: "testuser", discriminator: "0", avatar: "abc123" };
|
||||
mockFetch.mockResolvedValueOnce({ ok: true, json: () => Promise.resolve(user) });
|
||||
const { fetchDiscordUserById } = await import("../../src/services/discord.js");
|
||||
const result = await fetchDiscordUserById("123456");
|
||||
expect(result).toMatchObject({ id: "123456", avatar: "abc123" });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
/* eslint-disable max-lines-per-function -- Test suites naturally have many cases */
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
vi.mock("../../src/db/client.js", () => ({
|
||||
prisma: {
|
||||
player: { updateMany: vi.fn() },
|
||||
},
|
||||
}));
|
||||
|
||||
vi.mock("../../src/services/logger.js", () => ({
|
||||
logger: {
|
||||
error: vi.fn().mockResolvedValue(undefined),
|
||||
log: vi.fn().mockResolvedValue(undefined),
|
||||
},
|
||||
}));
|
||||
|
||||
import { prisma } from "../../src/db/client.js";
|
||||
|
||||
const discordGuildId = "1354624415861833870";
|
||||
|
||||
describe("gateway service", () => {
|
||||
beforeEach(() => {
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
describe("handleGuildMemberAdd", () => {
|
||||
it("sets inGuild to true for the matching guild", async () => {
|
||||
vi.mocked(prisma.player.updateMany).mockResolvedValueOnce({ count: 1 });
|
||||
const { handleGuildMemberAdd } = await import("../../src/services/gateway.js");
|
||||
await handleGuildMemberAdd("user123", discordGuildId);
|
||||
expect(prisma.player.updateMany).toHaveBeenCalledWith({
|
||||
data: { inGuild: true },
|
||||
where: { discordId: "user123" },
|
||||
});
|
||||
});
|
||||
|
||||
it("no-ops when guild id does not match the configured guild", async () => {
|
||||
const { handleGuildMemberAdd } = await import("../../src/services/gateway.js");
|
||||
await handleGuildMemberAdd("user123", "other_guild");
|
||||
expect(prisma.player.updateMany).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("logs error when prisma throws an Error", async () => {
|
||||
const dbError = new Error("DB failure");
|
||||
vi.mocked(prisma.player.updateMany).mockRejectedValueOnce(dbError);
|
||||
const { handleGuildMemberAdd } = await import("../../src/services/gateway.js");
|
||||
const { logger } = await import("../../src/services/logger.js");
|
||||
await handleGuildMemberAdd("user123", discordGuildId);
|
||||
expect(logger.error).toHaveBeenCalledWith("gateway_member_add", dbError);
|
||||
});
|
||||
|
||||
it("logs error when prisma throws a non-Error", async () => {
|
||||
vi.mocked(prisma.player.updateMany).mockRejectedValueOnce("raw error");
|
||||
const { handleGuildMemberAdd } = await import("../../src/services/gateway.js");
|
||||
const { logger } = await import("../../src/services/logger.js");
|
||||
await handleGuildMemberAdd("user123", discordGuildId);
|
||||
expect(logger.error).toHaveBeenCalledWith(
|
||||
"gateway_member_add",
|
||||
new Error("raw error"),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("handleGuildMemberRemove", () => {
|
||||
it("sets inGuild to false for the matching guild", async () => {
|
||||
vi.mocked(prisma.player.updateMany).mockResolvedValueOnce({ count: 1 });
|
||||
const { handleGuildMemberRemove } = await import("../../src/services/gateway.js");
|
||||
await handleGuildMemberRemove("user123", discordGuildId);
|
||||
expect(prisma.player.updateMany).toHaveBeenCalledWith({
|
||||
data: { inGuild: false },
|
||||
where: { discordId: "user123" },
|
||||
});
|
||||
});
|
||||
|
||||
it("no-ops when guild id does not match the configured guild", async () => {
|
||||
const { handleGuildMemberRemove } = await import("../../src/services/gateway.js");
|
||||
await handleGuildMemberRemove("user123", "other_guild");
|
||||
expect(prisma.player.updateMany).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("logs error when prisma throws an Error", async () => {
|
||||
const dbError = new Error("DB failure");
|
||||
vi.mocked(prisma.player.updateMany).mockRejectedValueOnce(dbError);
|
||||
const { handleGuildMemberRemove } = await import("../../src/services/gateway.js");
|
||||
const { logger } = await import("../../src/services/logger.js");
|
||||
await handleGuildMemberRemove("user123", discordGuildId);
|
||||
expect(logger.error).toHaveBeenCalledWith("gateway_member_remove", dbError);
|
||||
});
|
||||
|
||||
it("logs error when prisma throws a non-Error", async () => {
|
||||
vi.mocked(prisma.player.updateMany).mockRejectedValueOnce("raw error");
|
||||
const { handleGuildMemberRemove } = await import("../../src/services/gateway.js");
|
||||
const { logger } = await import("../../src/services/logger.js");
|
||||
await handleGuildMemberRemove("user123", discordGuildId);
|
||||
expect(logger.error).toHaveBeenCalledWith(
|
||||
"gateway_member_remove",
|
||||
new Error("raw error"),
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -55,15 +55,18 @@ const makeMinimalState = (overrides: Partial<GameState> = {}): GameState =>
|
||||
|
||||
describe("calculatePrestigeThreshold", () => {
|
||||
it("returns base threshold at count 0", () => {
|
||||
// base × (0+1)^2 = 1_000_000 × 1 = 1_000_000
|
||||
expect(calculatePrestigeThreshold(0)).toBe(1_000_000);
|
||||
});
|
||||
|
||||
it("returns 5× at count 1", () => {
|
||||
expect(calculatePrestigeThreshold(1)).toBe(5_000_000);
|
||||
it("returns 4× base at count 1", () => {
|
||||
// base × (1+1)^2 = 1_000_000 × 4 = 4_000_000
|
||||
expect(calculatePrestigeThreshold(1)).toBe(4_000_000);
|
||||
});
|
||||
|
||||
it("returns 25× at count 2", () => {
|
||||
expect(calculatePrestigeThreshold(2)).toBe(25_000_000);
|
||||
it("returns 9× base at count 2", () => {
|
||||
// base × (2+1)^2 = 1_000_000 × 9 = 9_000_000
|
||||
expect(calculatePrestigeThreshold(2)).toBe(9_000_000);
|
||||
});
|
||||
|
||||
it("applies threshold multiplier correctly", () => {
|
||||
@@ -99,21 +102,27 @@ describe("isEligibleForPrestige", () => {
|
||||
|
||||
describe("calculateRunestones", () => {
|
||||
it("calculates basic runestones formula", () => {
|
||||
// floor(sqrt(4_000_000 / 1_000_000)) × 10 = floor(2) × 10 = 20
|
||||
// floor(cbrt(4_000_000 / 1_000_000)) × 15 = floor(cbrt(4)) × 15 = 1 × 15 = 15
|
||||
const result = calculateRunestones({ totalGoldEarned: 4_000_000, prestigeCount: 0, purchasedUpgradeIds: [] });
|
||||
expect(result).toBe(20);
|
||||
expect(result).toBe(15);
|
||||
});
|
||||
|
||||
it("applies echo runestone multiplier", () => {
|
||||
// floor(sqrt(4) × 10) = 20; × 2 = 40
|
||||
// floor(cbrt(4)) × 15 = 15; × 2 = 30
|
||||
const result = calculateRunestones({ totalGoldEarned: 4_000_000, prestigeCount: 0, purchasedUpgradeIds: [], echoRunestoneMultiplier: 2 });
|
||||
expect(result).toBe(40);
|
||||
expect(result).toBe(30);
|
||||
});
|
||||
|
||||
it("applies purchased runestone upgrade multiplier", () => {
|
||||
// With "runestones_1" purchased (multiplier 1.25): floor(20 × 1.25) = 25
|
||||
// With "runestone_gain_1" purchased (multiplier 1.25): floor(15 × 1.25) = 18
|
||||
const result = calculateRunestones({ totalGoldEarned: 4_000_000, prestigeCount: 0, purchasedUpgradeIds: ["runestone_gain_1"] });
|
||||
expect(result).toBeGreaterThan(20);
|
||||
expect(result).toBe(18);
|
||||
});
|
||||
|
||||
it("caps base runestones before multipliers", () => {
|
||||
// cbrt(9_261_000_000 / 1_000_000) = cbrt(9261) = 21 → 21 × 10 = 210, capped at 200
|
||||
const result = calculateRunestones({ totalGoldEarned: 9_261_000_000, prestigeCount: 0, purchasedUpgradeIds: [] });
|
||||
expect(result).toBe(200);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -122,12 +131,12 @@ describe("calculateProductionMultiplier", () => {
|
||||
expect(calculateProductionMultiplier(0)).toBe(1);
|
||||
});
|
||||
|
||||
it("returns 1.15 at count 1", () => {
|
||||
expect(calculateProductionMultiplier(1)).toBeCloseTo(1.15);
|
||||
it("returns 1.3 at count 1", () => {
|
||||
expect(calculateProductionMultiplier(1)).toBeCloseTo(1.3);
|
||||
});
|
||||
|
||||
it("scales exponentially", () => {
|
||||
expect(calculateProductionMultiplier(10)).toBeCloseTo(Math.pow(1.15, 10));
|
||||
expect(calculateProductionMultiplier(10)).toBeCloseTo(Math.pow(1.3, 10));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -142,12 +151,12 @@ describe("calculateMilestoneBonus", () => {
|
||||
expect(calculateMilestoneBonus(5)).toBe(25);
|
||||
});
|
||||
|
||||
it("returns 50 at prestige 10", () => {
|
||||
expect(calculateMilestoneBonus(10)).toBe(50);
|
||||
it("returns 100 at prestige 10", () => {
|
||||
expect(calculateMilestoneBonus(10)).toBe(100);
|
||||
});
|
||||
|
||||
it("returns 75 at prestige 15", () => {
|
||||
expect(calculateMilestoneBonus(15)).toBe(75);
|
||||
it("returns 225 at prestige 15", () => {
|
||||
expect(calculateMilestoneBonus(15)).toBe(225);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -319,6 +328,32 @@ describe("buildPostPrestigeState", () => {
|
||||
expect(matchingBoss?.bountyRunestonesClaimed).toBe(true);
|
||||
});
|
||||
|
||||
it("sets bountyRunestonesClaimed on bosses defeated before the flag was introduced", () => {
|
||||
const legacyDefeatedBoss = {
|
||||
bountyRunestones: 5,
|
||||
crystalReward: 0,
|
||||
currentHp: 0,
|
||||
damagePerSecond: 10,
|
||||
description: "A boss",
|
||||
equipmentRewards: [] as string[],
|
||||
essenceReward: 0,
|
||||
goldReward: 100,
|
||||
id: "troll_king",
|
||||
maxHp: 100,
|
||||
name: "Troll King",
|
||||
prestigeRequirement: 0,
|
||||
status: "defeated" as const,
|
||||
upgradeRewards: [] as string[],
|
||||
zoneId: "verdant_vale",
|
||||
};
|
||||
const state = makeMinimalState({ bosses: [ legacyDefeatedBoss ] as GameState["bosses"] });
|
||||
const { prestigeState } = buildPostPrestigeState(state, "Tester");
|
||||
const matchingBoss = prestigeState.bosses.find((boss) => {
|
||||
return boss.id === "troll_king";
|
||||
});
|
||||
expect(matchingBoss?.bountyRunestonesClaimed).toBe(true);
|
||||
});
|
||||
|
||||
it("accumulates completed quests into lifetime total", () => {
|
||||
const quest = {
|
||||
id: "q_1",
|
||||
|
||||
@@ -97,20 +97,21 @@ describe("isEligibleForTranscendence", () => {
|
||||
|
||||
describe("calculateEchoes", () => {
|
||||
it("handles prestige count of 0 by treating it as 1", () => {
|
||||
// safeCount = max(0, 1) = 1; floor(853 / sqrt(1)) = 853
|
||||
expect(calculateEchoes(0, 1)).toBe(853);
|
||||
// safeCount = max(0, 1) = 1; floor(224 / sqrt(1)) = 224
|
||||
expect(calculateEchoes(0, 1)).toBe(224);
|
||||
});
|
||||
|
||||
it("calculates echoes at count 1", () => {
|
||||
expect(calculateEchoes(1, 1)).toBe(853);
|
||||
// floor(224 / sqrt(1)) = 224
|
||||
expect(calculateEchoes(1, 1)).toBe(224);
|
||||
});
|
||||
|
||||
it("decreases echoes with higher prestige count", () => {
|
||||
const echoesAt1 = calculateEchoes(1, 1);
|
||||
const echoesAt4 = calculateEchoes(4, 1);
|
||||
expect(echoesAt4).toBeLessThan(echoesAt1);
|
||||
// floor(853 / sqrt(4)) = floor(853 / 2) = 426
|
||||
expect(echoesAt4).toBe(426);
|
||||
// floor(224 / sqrt(4)) = floor(224 / 2) = 112
|
||||
expect(echoesAt4).toBe(112);
|
||||
});
|
||||
|
||||
it("applies echoMetaMultiplier", () => {
|
||||
@@ -118,6 +119,11 @@ describe("calculateEchoes", () => {
|
||||
const withMult = calculateEchoes(1, 2);
|
||||
expect(withMult).toBe(base * 2);
|
||||
});
|
||||
|
||||
it("returns 50 echoes at the target prestige 20", () => {
|
||||
// floor(224 / sqrt(20)) = floor(224 / 4.472) = floor(50.09) = 50
|
||||
expect(calculateEchoes(20, 1)).toBe(50);
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildPostTranscendenceState", () => {
|
||||
|
||||
@@ -20,42 +20,20 @@ describe("webhook service", () => {
|
||||
describe("grantApotheosisRole", () => {
|
||||
it("does nothing when bot token is missing", async () => {
|
||||
delete process.env["DISCORD_BOT_TOKEN"];
|
||||
process.env["DISCORD_GUILD_ID"] = "guild123";
|
||||
process.env["DISCORD_APOTHEOSIS_ROLE_ID"] = "role123";
|
||||
const { grantApotheosisRole } = await import("../../src/services/webhook.js");
|
||||
await grantApotheosisRole("user123");
|
||||
expect(mockFetch).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("does nothing when guild id is missing", async () => {
|
||||
process.env["DISCORD_BOT_TOKEN"] = "token";
|
||||
delete process.env["DISCORD_GUILD_ID"];
|
||||
process.env["DISCORD_APOTHEOSIS_ROLE_ID"] = "role123";
|
||||
const { grantApotheosisRole } = await import("../../src/services/webhook.js");
|
||||
await grantApotheosisRole("user123");
|
||||
expect(mockFetch).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("does nothing when role id is missing", async () => {
|
||||
process.env["DISCORD_BOT_TOKEN"] = "token";
|
||||
process.env["DISCORD_GUILD_ID"] = "guild123";
|
||||
delete process.env["DISCORD_APOTHEOSIS_ROLE_ID"];
|
||||
const { grantApotheosisRole } = await import("../../src/services/webhook.js");
|
||||
await grantApotheosisRole("user123");
|
||||
expect(mockFetch).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("calls Discord API with correct URL and auth when env vars are set", async () => {
|
||||
it("calls Discord API with correct URL and auth when bot token is set", async () => {
|
||||
process.env["DISCORD_BOT_TOKEN"] = "bot_token";
|
||||
process.env["DISCORD_GUILD_ID"] = "guild123";
|
||||
process.env["DISCORD_APOTHEOSIS_ROLE_ID"] = "role456";
|
||||
mockFetch.mockResolvedValueOnce({ ok: true });
|
||||
const { grantApotheosisRole } = await import("../../src/services/webhook.js");
|
||||
await grantApotheosisRole("user789");
|
||||
expect(mockFetch).toHaveBeenCalledWith(
|
||||
"https://discord.com/api/v10/guilds/guild123/members/user789/roles/role456",
|
||||
"https://discord.com/api/v10/guilds/1354624415861833870/members/user789/roles/1479966598210129991",
|
||||
expect.objectContaining({
|
||||
method: "PUT",
|
||||
method: "PUT",
|
||||
headers: expect.objectContaining({ Authorization: "Bot bot_token" }),
|
||||
}),
|
||||
);
|
||||
@@ -63,8 +41,6 @@ describe("webhook service", () => {
|
||||
|
||||
it("swallows fetch errors gracefully", async () => {
|
||||
process.env["DISCORD_BOT_TOKEN"] = "tok";
|
||||
process.env["DISCORD_GUILD_ID"] = "g";
|
||||
process.env["DISCORD_APOTHEOSIS_ROLE_ID"] = "r";
|
||||
mockFetch.mockRejectedValueOnce(new Error("Network error"));
|
||||
const { grantApotheosisRole } = await import("../../src/services/webhook.js");
|
||||
await expect(grantApotheosisRole("user")).resolves.toBeUndefined();
|
||||
@@ -72,14 +48,69 @@ describe("webhook service", () => {
|
||||
|
||||
it("swallows non-Error fetch rejections gracefully", async () => {
|
||||
process.env["DISCORD_BOT_TOKEN"] = "tok";
|
||||
process.env["DISCORD_GUILD_ID"] = "g";
|
||||
process.env["DISCORD_APOTHEOSIS_ROLE_ID"] = "r";
|
||||
mockFetch.mockRejectedValueOnce("raw string error");
|
||||
const { grantApotheosisRole } = await import("../../src/services/webhook.js");
|
||||
await expect(grantApotheosisRole("user")).resolves.toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("grantElysianRole", () => {
|
||||
it("does nothing when bot token is missing", async () => {
|
||||
delete process.env["DISCORD_BOT_TOKEN"];
|
||||
const { grantElysianRole } = await import("../../src/services/webhook.js");
|
||||
const result = await grantElysianRole("user123");
|
||||
expect(mockFetch).not.toHaveBeenCalled();
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
it("returns true when Discord API responds with ok", async () => {
|
||||
process.env["DISCORD_BOT_TOKEN"] = "bot_token";
|
||||
mockFetch.mockResolvedValueOnce({ ok: true, status: 200 });
|
||||
const { grantElysianRole } = await import("../../src/services/webhook.js");
|
||||
const result = await grantElysianRole("user789");
|
||||
expect(mockFetch).toHaveBeenCalledWith(
|
||||
"https://discord.com/api/v10/guilds/1354624415861833870/members/user789/roles/1486144823684628490",
|
||||
expect.objectContaining({
|
||||
method: "PUT",
|
||||
headers: expect.objectContaining({ Authorization: "Bot bot_token" }),
|
||||
}),
|
||||
);
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
it("returns true when Discord API responds with 204", async () => {
|
||||
process.env["DISCORD_BOT_TOKEN"] = "tok";
|
||||
mockFetch.mockResolvedValueOnce({ ok: false, status: 204 });
|
||||
const { grantElysianRole } = await import("../../src/services/webhook.js");
|
||||
const result = await grantElysianRole("user");
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
it("returns false when Discord API responds with an error status", async () => {
|
||||
process.env["DISCORD_BOT_TOKEN"] = "tok";
|
||||
mockFetch.mockResolvedValueOnce({ ok: false, status: 403 });
|
||||
const { grantElysianRole } = await import("../../src/services/webhook.js");
|
||||
const result = await grantElysianRole("user");
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
it("returns false and swallows fetch errors gracefully", async () => {
|
||||
process.env["DISCORD_BOT_TOKEN"] = "tok";
|
||||
mockFetch.mockRejectedValueOnce(new Error("Network error"));
|
||||
const { grantElysianRole } = await import("../../src/services/webhook.js");
|
||||
const result = await grantElysianRole("user");
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
it("returns false and swallows non-Error fetch rejections", async () => {
|
||||
process.env["DISCORD_BOT_TOKEN"] = "tok";
|
||||
mockFetch.mockRejectedValueOnce("raw string error");
|
||||
const { grantElysianRole } = await import("../../src/services/webhook.js");
|
||||
const result = await grantElysianRole("user");
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("postMilestoneWebhook", () => {
|
||||
const counts = { prestige: 1, transcendence: 0, apotheosis: 0 };
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@elysium/web",
|
||||
"version": "0.1.1",
|
||||
"version": "0.4.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
||||
@@ -17,16 +17,19 @@ import type {
|
||||
BuyPrestigeUpgradeResponse,
|
||||
CraftRecipeRequest,
|
||||
CraftRecipeResponse,
|
||||
ExploreClaimableResponse,
|
||||
ExploreCollectRequest,
|
||||
ExploreCollectResponse,
|
||||
ExploreStartRequest,
|
||||
ExploreStartResponse,
|
||||
ForceUnlocksResponse,
|
||||
LoadResponse,
|
||||
PrestigeRequest,
|
||||
PrestigeResponse,
|
||||
PublicProfileResponse,
|
||||
SaveRequest,
|
||||
SaveResponse,
|
||||
SyncNewContentResponse,
|
||||
TranscendenceRequest,
|
||||
TranscendenceResponse,
|
||||
UpdateProfileRequest,
|
||||
@@ -242,6 +245,19 @@ const collectExploration = async(
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks whether a given exploration area is ready to claim on the server.
|
||||
* @param areaId - The area ID to check.
|
||||
* @returns Whether the exploration is claimable.
|
||||
*/
|
||||
const checkExplorationClaimable = async(
|
||||
areaId: string,
|
||||
): Promise<ExploreClaimableResponse> => {
|
||||
return await fetchJson<ExploreClaimableResponse>(
|
||||
`/explore/claimable?areaId=${encodeURIComponent(areaId)}`,
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Crafts a recipe on the server.
|
||||
* @param body - The craft recipe request payload.
|
||||
@@ -256,6 +272,34 @@ const craftRecipe = async(
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Sends a request to fix any missing unlocks in the player's game state.
|
||||
* @returns The corrected game state and counts of what was unlocked.
|
||||
*/
|
||||
const forceUnlocks = async(): Promise<ForceUnlocksResponse> => {
|
||||
return await fetchJson<ForceUnlocksResponse>("/debug/force-unlocks", {
|
||||
method: "POST",
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Syncs any content added after the player's save was created into their save.
|
||||
* @returns The updated game state and counts of what was added per content type.
|
||||
*/
|
||||
const syncNewContent = async(): Promise<SyncNewContentResponse> => {
|
||||
return await fetchJson<SyncNewContentResponse>("/debug/sync-new-content", {
|
||||
method: "POST",
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Performs a complete hard reset of the player's game state via the debug endpoint.
|
||||
* @returns The fresh game state as a LoadResponse.
|
||||
*/
|
||||
const debugHardReset = async(): Promise<LoadResponse> => {
|
||||
return await fetchJson<LoadResponse>("/debug/hard-reset", { method: "POST" });
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetches a public player profile by Discord ID.
|
||||
* @param discordId - The Discord ID of the player to look up.
|
||||
@@ -286,8 +330,12 @@ export {
|
||||
buyEchoUpgrade,
|
||||
buyPrestigeUpgrade,
|
||||
challengeBoss,
|
||||
checkExplorationClaimable,
|
||||
collectExploration,
|
||||
craftRecipe,
|
||||
debugHardReset,
|
||||
forceUnlocks,
|
||||
syncNewContent,
|
||||
getAbout,
|
||||
getAuthUrl,
|
||||
getPublicProfile,
|
||||
|
||||
@@ -31,14 +31,24 @@ const howToPlay = [
|
||||
body:
|
||||
"Purchase upgrades to multiply the gold and essence output of specific"
|
||||
+ " adventurer tiers, or boost your whole guild. Upgrades are permanent"
|
||||
+ " for the current run and compound with each other.",
|
||||
+ " for the current run and stack multiplicatively — two ×2 upgrades"
|
||||
+ " targeting the same adventurer combine to give ×4, not ×3. Global"
|
||||
+ " upgrades multiply on top of adventurer-specific ones, so stacking"
|
||||
+ " both types compounds the effect significantly. Late in a run, look"
|
||||
+ " for the Essence Infusion upgrades — five powerful global multipliers"
|
||||
+ " purchasable purely with essence, giving that resource an ongoing"
|
||||
+ " use when gold upgrades are all bought.",
|
||||
title: "🔧 Upgrades",
|
||||
},
|
||||
{
|
||||
body:
|
||||
"Send your guild on quests that complete over time and reward gold,"
|
||||
+ " essence, crystals, equipment, and upgrades. Multiple quests can run"
|
||||
+ " simultaneously. Completing quests also unlocks new zones.",
|
||||
+ " simultaneously. Completing quests also unlocks new zones."
|
||||
+ " Each quest has a failure chance that increases in later zones"
|
||||
+ " (from 10% in the starting zone up to 40% in the hardest zones)."
|
||||
+ " If a quest fails, no rewards are granted and the quest resets —"
|
||||
+ " your party must be sent again to retry it.",
|
||||
title: "📜 Quests",
|
||||
},
|
||||
{
|
||||
@@ -59,10 +69,12 @@ const howToPlay = [
|
||||
{
|
||||
body:
|
||||
"Earn equipment from boss drops and quest rewards. Each piece provides"
|
||||
+ " bonuses to gold income, click power, or combat. Rarer equipment"
|
||||
+ " provides stronger bonuses. Equip matching set pieces (2 or 3 of a"
|
||||
+ " named set) to unlock escalating set bonuses shown at the top of the"
|
||||
+ " Equipment panel.",
|
||||
+ " bonuses to gold income, click power, or boss combat DPS. Rarer"
|
||||
+ " equipment provides stronger bonuses. Note: combat bonuses only"
|
||||
+ " affect boss fights — quest combat power is determined solely by"
|
||||
+ " your adventurers. Equip matching set pieces (2 or 3 of a named set)"
|
||||
+ " to unlock escalating set bonuses shown at the top of the Equipment"
|
||||
+ " panel.",
|
||||
title: "🗡️ Equipment & Sets",
|
||||
},
|
||||
{
|
||||
@@ -111,7 +123,11 @@ const howToPlay = [
|
||||
+ " real-time and reward gold, essence, and crafting materials when"
|
||||
+ " collected. Each area has a set duration — short explorations are"
|
||||
+ " faster but longer ones offer rarer finds. A 📖 icon marks areas"
|
||||
+ " you've collected from at least once, unlocking a Codex entry.",
|
||||
+ " you've collected from at least once, unlocking a Codex entry."
|
||||
+ " Exploration zones are locked until the corresponding main-game"
|
||||
+ " zone is unlocked — which requires defeating that zone's final boss"
|
||||
+ " and completing its final quest. The Exploration tab shows the"
|
||||
+ " specific boss and quest required for each locked zone.",
|
||||
title: "🗺️ Exploration",
|
||||
},
|
||||
{
|
||||
@@ -154,10 +170,12 @@ const howToPlay = [
|
||||
{
|
||||
body:
|
||||
"Defeat bosses to earn equipment drops: weapons, armour, and trinkets."
|
||||
+ " Each item provides bonuses to gold income, combat power, or click"
|
||||
+ " power. Only one item per slot can be equipped at a time — visit the"
|
||||
+ " Equipment panel to manage your loadout. Your currently equipped"
|
||||
+ " items are displayed on your character sheet and public profile.",
|
||||
+ " Each item provides bonuses to gold income, boss combat DPS, or click"
|
||||
+ " power. Combat bonuses only affect boss fights — quest combat power"
|
||||
+ " is determined solely by your adventurers. Only one item per slot"
|
||||
+ " can be equipped at a time — visit the Equipment panel to manage"
|
||||
+ " your loadout. Your currently equipped items are displayed on your"
|
||||
+ " character sheet and public profile.",
|
||||
title: "🗡️ Equipment",
|
||||
},
|
||||
{
|
||||
@@ -181,14 +199,16 @@ const howToPlay = [
|
||||
},
|
||||
{
|
||||
body:
|
||||
"Toggle automation in the Quests and Boss Encounters panels! Auto-Quest"
|
||||
+ " automatically sends your party on the highest-zone available quest"
|
||||
+ " as soon as one completes, skipping quests whose combat power"
|
||||
+ " requirement isn't met. Auto-Boss automatically challenges the"
|
||||
+ " highest available boss as soon as one is ready. Both can be toggled"
|
||||
+ " on or off at any time using the 🤖 Auto button in each panel"
|
||||
+ " header.",
|
||||
title: "🤖 Auto-Quest & Auto-Boss",
|
||||
"Toggle automation in the Quests, Boss Encounters, and Prestige Shop"
|
||||
+ " panels! Auto-Quest automatically sends your party on the"
|
||||
+ " highest-zone available quest as soon as one completes, skipping"
|
||||
+ " quests whose combat power requirement isn't met. Auto-Boss"
|
||||
+ " automatically challenges the highest available boss as soon as one"
|
||||
+ " is ready. Auto-Adventurer (unlocked via the Prestige Shop for 50"
|
||||
+ " runestones) automatically purchases the highest-tier adventurer you"
|
||||
+ " can currently afford each tick, keeping your income growing after a"
|
||||
+ " prestige without any manual clicks.",
|
||||
title: "🤖 Auto-Quest, Auto-Boss & Auto-Adventurer",
|
||||
},
|
||||
{
|
||||
body:
|
||||
|
||||
@@ -9,7 +9,7 @@ import { type JSX, useState } from "react";
|
||||
import { useGame } from "../../context/gameContext.js";
|
||||
import { cdnImage } from "../../utils/cdn.js";
|
||||
import { LockToggle } from "../ui/lockToggle.js";
|
||||
import type { Achievement } from "@elysium/types";
|
||||
import type { Achievement, GameState } from "@elysium/types";
|
||||
|
||||
/**
|
||||
* Returns the plural form of a word based on a count.
|
||||
@@ -54,9 +54,50 @@ const conditionDescription = (
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the player's current progress value toward an achievement's unlock condition,
|
||||
* mirroring the logic used by the tick engine's checkAchievements function.
|
||||
* @param achievement - The achievement to evaluate progress for.
|
||||
* @param state - The current game state.
|
||||
* @returns The current numeric progress toward the achievement condition.
|
||||
*/
|
||||
const getCurrentProgress = (
|
||||
achievement: Achievement,
|
||||
state: GameState,
|
||||
): number => {
|
||||
const { condition } = achievement;
|
||||
switch (condition.type) {
|
||||
case "totalGoldEarned":
|
||||
return state.player.totalGoldEarned;
|
||||
case "totalClicks":
|
||||
return state.player.totalClicks;
|
||||
case "bossesDefeated":
|
||||
return state.bosses.filter((boss) => {
|
||||
return boss.status === "defeated";
|
||||
}).length;
|
||||
case "questsCompleted":
|
||||
return state.quests.filter((quest) => {
|
||||
return quest.status === "completed";
|
||||
}).length;
|
||||
case "adventurerTotal":
|
||||
return state.adventurers.reduce((sum, adventurer) => {
|
||||
return sum + adventurer.count;
|
||||
}, 0);
|
||||
case "prestigeCount":
|
||||
return state.prestige.count;
|
||||
case "equipmentOwned":
|
||||
return state.equipment.filter((item) => {
|
||||
return item.owned;
|
||||
}).length;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
interface AchievementCardProperties {
|
||||
readonly achievement: Achievement;
|
||||
readonly formatNumber: (n: number)=> string;
|
||||
readonly achievement: Achievement;
|
||||
readonly formatNumber: (n: number)=> string;
|
||||
readonly progressValue: number;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,14 +105,18 @@ interface AchievementCardProperties {
|
||||
* @param props - The achievement card properties.
|
||||
* @param props.achievement - The achievement to display.
|
||||
* @param props.formatNumber - The number formatting utility function.
|
||||
* @param props.progressValue - The player's current progress toward the unlock condition.
|
||||
* @returns The JSX element.
|
||||
*/
|
||||
// eslint-disable-next-line max-lines-per-function -- Progress bar adds necessary lines for locked state
|
||||
const AchievementCard = ({
|
||||
achievement,
|
||||
formatNumber,
|
||||
progressValue,
|
||||
}: AchievementCardProperties): JSX.Element => {
|
||||
const isUnlocked = achievement.unlockedAt !== null;
|
||||
const crystals = achievement.reward?.crystals;
|
||||
const cappedProgress = Math.min(progressValue, achievement.condition.amount);
|
||||
|
||||
return (
|
||||
<div className={`achievement-card ${isUnlocked
|
||||
@@ -88,6 +133,19 @@ const AchievementCard = ({
|
||||
<p className="achievement-condition">
|
||||
{conditionDescription(achievement, formatNumber)}
|
||||
</p>
|
||||
{!isUnlocked
|
||||
&& <div className="achievement-progress">
|
||||
<progress
|
||||
max={achievement.condition.amount}
|
||||
value={cappedProgress}
|
||||
/>
|
||||
<span className="achievement-progress-label">
|
||||
{formatNumber(progressValue)}
|
||||
{" / "}
|
||||
{formatNumber(achievement.condition.amount)}
|
||||
</span>
|
||||
</div>
|
||||
}
|
||||
{crystals !== undefined
|
||||
&& <p className="achievement-reward">
|
||||
{"💎 +"}
|
||||
@@ -163,6 +221,7 @@ const AchievementPanel = (): JSX.Element => {
|
||||
achievement={achievement}
|
||||
formatNumber={formatNumber}
|
||||
key={achievement.id}
|
||||
progressValue={getCurrentProgress(achievement, state)}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
/* eslint-disable complexity -- Complex component with many render paths */
|
||||
import { type JSX, useState } from "react";
|
||||
import { useGame } from "../../context/gameContext.js";
|
||||
import { computeEffectiveAdventurerStats } from "../../engine/tick.js";
|
||||
import { cdnImage } from "../../utils/cdn.js";
|
||||
import { LockToggle } from "../ui/lockToggle.js";
|
||||
import type { Adventurer } from "@elysium/types";
|
||||
@@ -76,12 +77,19 @@ const computeMaxAffordable = (adventurer: Adventurer, gold: number): number => {
|
||||
return quantity;
|
||||
};
|
||||
|
||||
interface EffectiveAdventurerStats {
|
||||
readonly combatPower: number;
|
||||
readonly essencePerSecond: number;
|
||||
readonly goldPerSecond: number;
|
||||
}
|
||||
|
||||
interface AdventurerCardProperties {
|
||||
readonly adventurer: Adventurer;
|
||||
readonly currentGold: number;
|
||||
readonly batchSize: BatchSize;
|
||||
readonly unlockHint: string | undefined;
|
||||
readonly formatNumber: (n: number)=> string;
|
||||
readonly adventurer: Adventurer;
|
||||
readonly currentGold: number;
|
||||
readonly batchSize: BatchSize;
|
||||
readonly unlockHint: string | undefined;
|
||||
readonly formatNumber: (n: number)=> string;
|
||||
readonly effectiveStats: EffectiveAdventurerStats;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,6 +100,7 @@ interface AdventurerCardProperties {
|
||||
* @param props.batchSize - The selected batch size.
|
||||
* @param props.unlockHint - Optional quest name that unlocks this adventurer.
|
||||
* @param props.formatNumber - The number formatting utility function.
|
||||
* @param props.effectiveStats - The post-multiplier per-unit stats.
|
||||
* @returns The JSX element.
|
||||
*/
|
||||
const AdventurerCard = ({
|
||||
@@ -100,6 +109,7 @@ const AdventurerCard = ({
|
||||
batchSize,
|
||||
unlockHint,
|
||||
formatNumber,
|
||||
effectiveStats,
|
||||
}: AdventurerCardProperties): JSX.Element => {
|
||||
const { buyAdventurer } = useGame();
|
||||
|
||||
@@ -134,15 +144,19 @@ const AdventurerCard = ({
|
||||
<div className="adventurer-info">
|
||||
<h3>{adventurer.name}</h3>
|
||||
<p>
|
||||
{formatNumber(adventurer.goldPerSecond)}
|
||||
{formatNumber(effectiveStats.goldPerSecond)}
|
||||
{" gold/s each"}
|
||||
</p>
|
||||
{adventurer.essencePerSecond > 0
|
||||
&& <p>
|
||||
{formatNumber(adventurer.essencePerSecond)}
|
||||
{formatNumber(effectiveStats.essencePerSecond)}
|
||||
{" essence/s each"}
|
||||
</p>
|
||||
}
|
||||
<p>
|
||||
{formatNumber(effectiveStats.combatPower)}
|
||||
{" combat power each"}
|
||||
</p>
|
||||
</div>
|
||||
<div className="adventurer-count">
|
||||
{"×"}
|
||||
@@ -171,7 +185,7 @@ const AdventurerCard = ({
|
||||
* @returns The JSX element.
|
||||
*/
|
||||
const AdventurerPanel = (): JSX.Element => {
|
||||
const { state, formatNumber } = useGame();
|
||||
const { state, formatNumber, toggleAutoAdventurer } = useGame();
|
||||
const [ showLocked, setShowLocked ] = useState(true);
|
||||
const [ batchSize, setBatchSize ] = useState<BatchSize>(() => {
|
||||
return parseBatchSize(localStorage.getItem("elysium_batch_size"));
|
||||
@@ -203,6 +217,11 @@ const AdventurerPanel = (): JSX.Element => {
|
||||
}
|
||||
}
|
||||
|
||||
const autoAdventurerUnlocked = state.prestige.purchasedUpgradeIds.includes(
|
||||
"auto_adventurer",
|
||||
);
|
||||
const autoAdventurerOn = state.autoAdventurer === true;
|
||||
|
||||
function handleToggle(): void {
|
||||
setShowLocked((current) => {
|
||||
return !current;
|
||||
@@ -213,11 +232,34 @@ const AdventurerPanel = (): JSX.Element => {
|
||||
<section className="panel adventurer-panel">
|
||||
<div className="panel-header">
|
||||
<h2>{"Adventurers"}</h2>
|
||||
<LockToggle
|
||||
lockedCount={locked.length}
|
||||
onToggle={handleToggle}
|
||||
showLocked={showLocked}
|
||||
/>
|
||||
<div className="panel-header-controls">
|
||||
{autoAdventurerUnlocked
|
||||
? <button
|
||||
className={`auto-toggle-btn ${
|
||||
autoAdventurerOn
|
||||
? "auto-toggle-on"
|
||||
: "auto-toggle-off"
|
||||
}`}
|
||||
onClick={toggleAutoAdventurer}
|
||||
title={
|
||||
"Automatically purchase the highest-tier"
|
||||
+ " affordable adventurer"
|
||||
}
|
||||
type="button"
|
||||
>
|
||||
{"🤖 Auto: "}
|
||||
{autoAdventurerOn
|
||||
? "ON"
|
||||
: "OFF"}
|
||||
</button>
|
||||
: null
|
||||
}
|
||||
<LockToggle
|
||||
lockedCount={locked.length}
|
||||
onToggle={handleToggle}
|
||||
showLocked={showLocked}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="batch-selector">
|
||||
{batchOptions.map((option) => {
|
||||
@@ -248,6 +290,10 @@ const AdventurerPanel = (): JSX.Element => {
|
||||
adventurer={adventurer}
|
||||
batchSize={batchSize}
|
||||
currentGold={state.resources.gold}
|
||||
effectiveStats={computeEffectiveAdventurerStats(
|
||||
state,
|
||||
adventurer.id,
|
||||
)}
|
||||
formatNumber={formatNumber}
|
||||
key={adventurer.id}
|
||||
unlockHint={adventurerUnlockHints.get(adventurer.id)}
|
||||
|
||||
@@ -11,10 +11,11 @@
|
||||
/* eslint-disable max-lines -- Boss panel with sub-component and helper function */
|
||||
import { type JSX, useState } from "react";
|
||||
import { useGame } from "../../context/gameContext.js";
|
||||
import { computePartyCombatPower } from "../../engine/tick.js";
|
||||
import { cdnImage } from "../../utils/cdn.js";
|
||||
import { LockToggle } from "../ui/lockToggle.js";
|
||||
import { ZoneSelector } from "./zoneSelector.js";
|
||||
import type { Boss, GameState } from "@elysium/types";
|
||||
import type { Boss } from "@elysium/types";
|
||||
|
||||
interface BossCardProperties {
|
||||
readonly boss: Boss;
|
||||
@@ -157,72 +158,6 @@ const BossCard = ({
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Computes party DPS and HP from the current game state.
|
||||
* @param state - The full game state.
|
||||
* @returns The computed party DPS and HP values.
|
||||
*/
|
||||
const computePartyStats = (
|
||||
state: GameState,
|
||||
): {
|
||||
partyDps: number;
|
||||
partyHp: number;
|
||||
} => {
|
||||
const { upgrades, adventurers, equipment, prestige } = state;
|
||||
let globalMultiplier = 1;
|
||||
for (const upgrade of upgrades) {
|
||||
const { purchased, target, multiplier } = upgrade;
|
||||
if (purchased && target === "global") {
|
||||
globalMultiplier = globalMultiplier * multiplier;
|
||||
}
|
||||
}
|
||||
const prestigeBonus = prestige.count * 0.1;
|
||||
const prestigeMultiplier = 1 + prestigeBonus;
|
||||
const equipmentCombatMultiplier = equipment.
|
||||
filter((item) => {
|
||||
return item.equipped && item.bonus.combatMultiplier !== undefined;
|
||||
}).
|
||||
reduce((multiplier, item) => {
|
||||
return multiplier * (item.bonus.combatMultiplier ?? 1);
|
||||
}, 1);
|
||||
|
||||
let partyDps = 0;
|
||||
let partyHp = 0;
|
||||
for (const adventurer of adventurers) {
|
||||
const { count, id: adventurerId, combatPower, level } = adventurer;
|
||||
if (count === 0) {
|
||||
continue;
|
||||
}
|
||||
let adventurerMultiplier = 1;
|
||||
for (const upgrade of upgrades) {
|
||||
const {
|
||||
purchased,
|
||||
target,
|
||||
multiplier,
|
||||
adventurerId: upgradeAdventurerId,
|
||||
} = upgrade;
|
||||
if (
|
||||
purchased
|
||||
&& target === "adventurer"
|
||||
&& upgradeAdventurerId === adventurerId
|
||||
) {
|
||||
adventurerMultiplier = adventurerMultiplier * multiplier;
|
||||
}
|
||||
}
|
||||
const dps
|
||||
= combatPower
|
||||
* count
|
||||
* adventurerMultiplier
|
||||
* globalMultiplier
|
||||
* prestigeMultiplier;
|
||||
partyDps = partyDps + dps;
|
||||
const hp = level * 50 * count;
|
||||
partyHp = partyHp + hp;
|
||||
}
|
||||
partyDps = partyDps * equipmentCombatMultiplier;
|
||||
return { partyDps, partyHp };
|
||||
};
|
||||
|
||||
/**
|
||||
* Renders the boss panel with zone selection and boss list.
|
||||
* @returns The JSX element.
|
||||
@@ -235,6 +170,7 @@ const BossPanel = (): JSX.Element => {
|
||||
toggleAutoBoss,
|
||||
autoBossLastResult,
|
||||
autoBossError,
|
||||
bossError,
|
||||
} = useGame();
|
||||
const [ challengingBossId, setChallengingBossId ] = useState<string | null>(
|
||||
null,
|
||||
@@ -265,7 +201,31 @@ const BossPanel = (): JSX.Element => {
|
||||
void handleChallenge(bossId);
|
||||
}
|
||||
|
||||
const { zones, bosses, quests, autoBoss, prestige: playerPrestige } = state;
|
||||
const {
|
||||
adventurers,
|
||||
autoBoss,
|
||||
bosses,
|
||||
prestige: playerPrestige,
|
||||
quests,
|
||||
zones,
|
||||
} = state;
|
||||
|
||||
const activeZone = zones.find((zone) => {
|
||||
return zone.id === activeZoneId;
|
||||
});
|
||||
const zoneIsLocked = activeZone?.status === "locked";
|
||||
const unlockBoss = activeZone?.unlockBossId === null
|
||||
|| activeZone?.unlockBossId === undefined
|
||||
? undefined
|
||||
: bosses.find((boss) => {
|
||||
return boss.id === activeZone.unlockBossId;
|
||||
});
|
||||
const unlockQuest = activeZone?.unlockQuestId === null
|
||||
|| activeZone?.unlockQuestId === undefined
|
||||
? undefined
|
||||
: quests.find((quest) => {
|
||||
return quest.id === activeZone.unlockQuestId;
|
||||
});
|
||||
const zoneBosses = bosses.filter((boss) => {
|
||||
return boss.zoneId === activeZoneId;
|
||||
});
|
||||
@@ -331,7 +291,12 @@ const BossPanel = (): JSX.Element => {
|
||||
}
|
||||
|
||||
const autoBossOn = autoBoss === true;
|
||||
const { partyDps, partyHp } = computePartyStats(state);
|
||||
const partyDps = computePartyCombatPower(state);
|
||||
let partyHp = 0;
|
||||
for (const { level, count } of adventurers) {
|
||||
// eslint-disable-next-line stylistic/no-mixed-operators -- level * 50 * count is clear
|
||||
partyHp = partyHp + level * 50 * count;
|
||||
}
|
||||
const { count: prestigeCount } = playerPrestige;
|
||||
|
||||
return (
|
||||
@@ -362,6 +327,13 @@ const BossPanel = (): JSX.Element => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{bossError === null
|
||||
? null
|
||||
: <p className="auto-boss-error">
|
||||
{"⚠️ "}
|
||||
{bossError}
|
||||
</p>
|
||||
}
|
||||
{autoBossError === null
|
||||
? null
|
||||
: <p className="auto-boss-error">
|
||||
@@ -385,6 +357,27 @@ const BossPanel = (): JSX.Element => {
|
||||
zones={zones}
|
||||
/>
|
||||
|
||||
{zoneIsLocked && (unlockBoss !== undefined || unlockQuest !== undefined)
|
||||
? <div className="exploration-zone-locked-hint">
|
||||
<p>{"🔒 This zone is locked. Unlock bosses by:"}</p>
|
||||
{unlockBoss === undefined
|
||||
? null
|
||||
: <p>
|
||||
{"⚔️ Defeat: "}
|
||||
{unlockBoss.name}
|
||||
</p>
|
||||
}
|
||||
{unlockQuest === undefined
|
||||
? null
|
||||
: <p>
|
||||
{"📜 Complete: "}
|
||||
{unlockQuest.name}
|
||||
</p>
|
||||
}
|
||||
</div>
|
||||
: null
|
||||
}
|
||||
|
||||
<div className="party-combat-stats">
|
||||
<div className="combat-stat">
|
||||
<span className="stat-label">{"⚔️ Party DPS"}</span>
|
||||
|
||||
@@ -49,6 +49,40 @@ const sourceTypeFolder: Record<CodexEntry["sourceType"], string> = {
|
||||
zone: "zones",
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts a snake_case ID to a Title Case display name.
|
||||
* @param id - The snake_case identifier to format.
|
||||
* @returns The formatted display name.
|
||||
*/
|
||||
const formatId = (id: string): string => {
|
||||
return id.split("_").
|
||||
map((word) => {
|
||||
return word.charAt(0).toUpperCase() + word.slice(1);
|
||||
}).
|
||||
join(" ");
|
||||
};
|
||||
|
||||
/**
|
||||
* Generates a human-readable unlock hint for a locked codex entry.
|
||||
* @param entry - The locked codex entry.
|
||||
* @returns A string describing how to unlock the entry.
|
||||
*/
|
||||
const buildUnlockHint = (entry: CodexEntry): string => {
|
||||
const name = formatId(entry.sourceId);
|
||||
switch (entry.sourceType) {
|
||||
case "boss": return `Defeat ${name}`;
|
||||
case "quest": return `Complete: ${name}`;
|
||||
case "equipment": return `Obtain: ${name}`;
|
||||
case "adventurer": return `Recruit a ${name}`;
|
||||
case "upgrade": return `Purchase: ${name}`;
|
||||
case "prestige": return `Purchase runestone upgrade: ${name}`;
|
||||
case "zone": return `Explore: ${name}`;
|
||||
case "exploration": return `Discover: ${name}`;
|
||||
case "recipe": return `Craft: ${name}`;
|
||||
default: return "Keep playing to unlock";
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Renders the codex panel with lore entries grouped by zone.
|
||||
* @returns The JSX element.
|
||||
@@ -136,6 +170,9 @@ const CodexPanel = (): JSX.Element => {
|
||||
<span className="codex-lock">{"🔒"}</span>
|
||||
<span className="codex-entry-title">{"???"}</span>
|
||||
</div>
|
||||
<p className="codex-unlock-hint">
|
||||
{buildUnlockHint(entry)}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,278 @@
|
||||
/**
|
||||
* @file Debug panel component with administrative tools for correcting player state.
|
||||
* @copyright nhcarrigan
|
||||
* @license Naomi's Public License
|
||||
* @author Naomi Carrigan
|
||||
*/
|
||||
/* eslint-disable max-lines-per-function -- Panel has multiple async handlers and conditional renders */
|
||||
/* eslint-disable stylistic/max-len -- Debug descriptions require full explanatory text */
|
||||
import { type JSX, useState } from "react";
|
||||
import { useGame } from "../../context/gameContext.js";
|
||||
import { ConfirmationModal } from "../ui/confirmationModal.js";
|
||||
|
||||
type ActiveModal = "force-unlocks" | "hard-reset" | "sync-new-content" | null;
|
||||
|
||||
interface SyncNewContentResult {
|
||||
achievementsAdded: number | undefined;
|
||||
achievementsPatched: number | undefined;
|
||||
adventurersAdded: number | undefined;
|
||||
adventurerStatsPatched: number | undefined;
|
||||
bossesAdded: number | undefined;
|
||||
bossesPatched: number | undefined;
|
||||
bossRewardsPatched: number | undefined;
|
||||
craftingRecipesReapplied: number | undefined;
|
||||
equipmentAdded: number | undefined;
|
||||
equipmentPatched: number | undefined;
|
||||
explorationAreasAdded: number | undefined;
|
||||
questRewardsPatched: number | undefined;
|
||||
questsAdded: number | undefined;
|
||||
questsPatched: number | undefined;
|
||||
upgradesAdded: number | undefined;
|
||||
upgradesPatched: number | undefined;
|
||||
zonesAdded: number | undefined;
|
||||
zonesPatched: number | undefined;
|
||||
}
|
||||
|
||||
const safeNumber = (value: number | undefined): number => {
|
||||
return value ?? 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Builds a human-readable summary of what the sync-new-content operation added.
|
||||
* @param result - The counts returned by the operation.
|
||||
* @returns A message string describing what was added, or a confirmation nothing was needed.
|
||||
*/
|
||||
const buildSyncNewContentMessage = (result: SyncNewContentResult): string => {
|
||||
const entries: Array<[ number, string ]> = [
|
||||
[ safeNumber(result.zonesAdded), "zone(s)" ],
|
||||
[ safeNumber(result.questsAdded), "quest(s)" ],
|
||||
[ safeNumber(result.questRewardsPatched), "quest reward(s) patched" ],
|
||||
[ safeNumber(result.bossesAdded), "boss(es)" ],
|
||||
[ safeNumber(result.bossRewardsPatched), "boss reward(s) patched" ],
|
||||
[ safeNumber(result.explorationAreasAdded), "exploration area(s)" ],
|
||||
[ safeNumber(result.adventurersAdded), "adventurer tier(s)" ],
|
||||
[ safeNumber(result.adventurerStatsPatched), "adventurer stat(s) patched" ],
|
||||
[ safeNumber(result.upgradesAdded), "upgrade(s)" ],
|
||||
[ safeNumber(result.equipmentAdded), "equipment item(s)" ],
|
||||
[ safeNumber(result.achievementsAdded), "achievement(s)" ],
|
||||
[ safeNumber(result.questsPatched), "quest stat(s) patched" ],
|
||||
[ safeNumber(result.bossesPatched), "boss stat(s) patched" ],
|
||||
[ safeNumber(result.zonesPatched), "zone stat(s) patched" ],
|
||||
[ safeNumber(result.upgradesPatched), "upgrade stat(s) patched" ],
|
||||
[ safeNumber(result.equipmentPatched), "equipment stat(s) patched" ],
|
||||
[ safeNumber(result.achievementsPatched), "achievement stat(s) patched" ],
|
||||
[ safeNumber(result.craftingRecipesReapplied), "crafting recipe(s) reapplied" ],
|
||||
];
|
||||
const parts = entries.
|
||||
filter(([ count ]) => {
|
||||
return count > 0;
|
||||
}).
|
||||
map(([ count, label ]) => {
|
||||
return `${String(count)} ${label}`;
|
||||
});
|
||||
if (parts.length === 0) {
|
||||
return "Your save is already up to date — no new content was found.";
|
||||
}
|
||||
const total = entries.reduce((sum, [ count ]) => {
|
||||
return sum + count;
|
||||
}, 0);
|
||||
return `Synced ${String(total)} item(s): ${parts.join(", ")}.`;
|
||||
};
|
||||
|
||||
interface ForceUnlocksResult {
|
||||
adventurersUnlocked: number | undefined;
|
||||
bossesUnlocked: number | undefined;
|
||||
equipmentUnlocked: number | undefined;
|
||||
explorationUnlocked: number | undefined;
|
||||
questsUnlocked: number | undefined;
|
||||
storyUnlocked: number | undefined;
|
||||
upgradesUnlocked: number | undefined;
|
||||
zonesUnlocked: number | undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a human-readable summary of what the force-unlock operation corrected.
|
||||
* @param result - The counts returned by the force-unlock operation.
|
||||
* @returns A message string describing what was fixed, or a confirmation that nothing needed fixing.
|
||||
*/
|
||||
const buildForceUnlocksMessage = (result: ForceUnlocksResult): string => {
|
||||
const entries: Array<[ number, string ]> = [
|
||||
[ safeNumber(result.zonesUnlocked), "zone(s)" ],
|
||||
[ safeNumber(result.questsUnlocked), "quest(s)" ],
|
||||
[ safeNumber(result.bossesUnlocked), "boss(es)" ],
|
||||
[ safeNumber(result.explorationUnlocked), "exploration area(s)" ],
|
||||
[ safeNumber(result.adventurersUnlocked), "adventurer tier(s)" ],
|
||||
[ safeNumber(result.upgradesUnlocked), "upgrade(s)" ],
|
||||
[ safeNumber(result.equipmentUnlocked), "equipment item(s)" ],
|
||||
[ safeNumber(result.storyUnlocked), "story chapter(s)" ],
|
||||
];
|
||||
const parts = entries.
|
||||
filter(([ count ]) => {
|
||||
return count > 0;
|
||||
}).
|
||||
map(([ count, label ]) => {
|
||||
return `${String(count)} ${label}`;
|
||||
});
|
||||
if (parts.length === 0) {
|
||||
return "Everything looks correct — no missing unlocks were found.";
|
||||
}
|
||||
const total = entries.reduce((sum, [ count ]) => {
|
||||
return sum + count;
|
||||
}, 0);
|
||||
return `Fixed ${String(total)} unlock(s): ${parts.join(", ")}.`;
|
||||
};
|
||||
|
||||
/**
|
||||
* Renders the debug panel with tools for fixing stuck game state.
|
||||
* @returns The JSX element.
|
||||
*/
|
||||
const DebugPanel = (): JSX.Element => {
|
||||
const { forceUnlocks, debugHardReset, syncNewContent, isLoading } = useGame();
|
||||
const [ activeModal, setActiveModal ] = useState<ActiveModal>(null);
|
||||
const [ forceUnlocksResult, setForceUnlocksResult ] = useState<string | null>(null);
|
||||
const [ syncNewContentResult, setSyncNewContentResult ] = useState<string | null>(null);
|
||||
|
||||
function handleOpenForceUnlocks(): void {
|
||||
setForceUnlocksResult(null);
|
||||
setActiveModal("force-unlocks");
|
||||
}
|
||||
|
||||
function handleOpenSyncNewContent(): void {
|
||||
setSyncNewContentResult(null);
|
||||
setActiveModal("sync-new-content");
|
||||
}
|
||||
|
||||
function handleOpenHardReset(): void {
|
||||
setActiveModal("hard-reset");
|
||||
}
|
||||
|
||||
function handleCancel(): void {
|
||||
setActiveModal(null);
|
||||
}
|
||||
|
||||
function handleConfirmForceUnlocks(): void {
|
||||
setActiveModal(null);
|
||||
void (async(): Promise<void> => {
|
||||
const result = await forceUnlocks();
|
||||
setForceUnlocksResult(buildForceUnlocksMessage(result));
|
||||
})();
|
||||
}
|
||||
|
||||
function handleConfirmSyncNewContent(): void {
|
||||
setActiveModal(null);
|
||||
void (async(): Promise<void> => {
|
||||
const result = await syncNewContent();
|
||||
setSyncNewContentResult(buildSyncNewContentMessage(result));
|
||||
})();
|
||||
}
|
||||
|
||||
function handleConfirmHardReset(): void {
|
||||
setActiveModal(null);
|
||||
void debugHardReset();
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="panel">
|
||||
<h2>{"🔧 Debug Tools"}</h2>
|
||||
<p className="panel-description">
|
||||
{
|
||||
"These tools are intended to fix broken game state. Use them with care — some operations are irreversible."
|
||||
}
|
||||
</p>
|
||||
|
||||
<div className="debug-actions">
|
||||
<div className="debug-action-card">
|
||||
<h3>{"🔓 Force Unlocks"}</h3>
|
||||
<p>
|
||||
{
|
||||
"Scans your game state and unlocks any zones, quests, and bosses that you have earned but that are still incorrectly locked."
|
||||
}
|
||||
</p>
|
||||
<button
|
||||
className="action-button"
|
||||
disabled={isLoading}
|
||||
onClick={handleOpenForceUnlocks}
|
||||
type="button"
|
||||
>
|
||||
{"Force Unlocks"}
|
||||
</button>
|
||||
{forceUnlocksResult !== null
|
||||
&& <p className="debug-result-message">{forceUnlocksResult}</p>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div className="debug-action-card">
|
||||
<h3>{"🔄 Sync New Content"}</h3>
|
||||
<p>
|
||||
{
|
||||
"If the game has been updated since your save was created, this will add any missing adventurers, quests, bosses, equipment, upgrades, and more to your save without affecting your existing progress."
|
||||
}
|
||||
</p>
|
||||
<button
|
||||
className="action-button"
|
||||
disabled={isLoading}
|
||||
onClick={handleOpenSyncNewContent}
|
||||
type="button"
|
||||
>
|
||||
{"Sync New Content"}
|
||||
</button>
|
||||
{syncNewContentResult !== null
|
||||
&& <p className="debug-result-message">{syncNewContentResult}</p>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div className="debug-action-card">
|
||||
<h3>{"💀 Hard Reset"}</h3>
|
||||
<p>
|
||||
{
|
||||
"Completely wipes all progress and resets your account to a brand-new state. This cannot be undone."
|
||||
}
|
||||
</p>
|
||||
<button
|
||||
className="action-button action-button-danger"
|
||||
disabled={isLoading}
|
||||
onClick={handleOpenHardReset}
|
||||
type="button"
|
||||
>
|
||||
{"Hard Reset"}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{activeModal === "force-unlocks"
|
||||
&& <ConfirmationModal
|
||||
confirmLabel="Yes, Force Unlocks"
|
||||
description="This will scan your save data and grant access to any zones, quests, and bosses that you have already earned but are incorrectly locked. This operation is safe and non-destructive."
|
||||
isLoading={isLoading}
|
||||
onCancel={handleCancel}
|
||||
onConfirm={handleConfirmForceUnlocks}
|
||||
title="Force Unlocks"
|
||||
/>
|
||||
}
|
||||
|
||||
{activeModal === "sync-new-content"
|
||||
&& <ConfirmationModal
|
||||
confirmLabel="Yes, Sync New Content"
|
||||
description="This will scan for any adventurers, quests, bosses, equipment, upgrades, achievements, and zones added to the game after your save was created, and add them to your save. This operation is safe and non-destructive — your existing progress will not be affected."
|
||||
isLoading={isLoading}
|
||||
onCancel={handleCancel}
|
||||
onConfirm={handleConfirmSyncNewContent}
|
||||
title="Sync New Content"
|
||||
/>
|
||||
}
|
||||
|
||||
{activeModal === "hard-reset"
|
||||
&& <ConfirmationModal
|
||||
confirmLabel="Yes, Wipe Everything"
|
||||
description="This will permanently delete all of your current progress — gold, adventurers, upgrades, bosses, quests, and zones — and reset your account to a brand-new state. Lifetime stats are preserved, but everything else will be gone forever."
|
||||
isLoading={isLoading}
|
||||
onCancel={handleCancel}
|
||||
onConfirm={handleConfirmHardReset}
|
||||
title="⚠️ Hard Reset — This Cannot Be Undone"
|
||||
/>
|
||||
}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export { DebugPanel };
|
||||
@@ -225,6 +225,10 @@ const EditProfileModal = ({
|
||||
void handleNotificationsEnable();
|
||||
}
|
||||
|
||||
function handlePrestigeAnnouncementsToggle(): void {
|
||||
toggleSetting("enablePrestigeAnnouncements");
|
||||
}
|
||||
|
||||
const isSaveDisabled = saving || characterName.trim() === "";
|
||||
|
||||
let saveLabel = "Save Profile";
|
||||
@@ -417,6 +421,23 @@ const EditProfileModal = ({
|
||||
}
|
||||
</span>
|
||||
</button>
|
||||
<button
|
||||
className={`stat-toggle-btn ${
|
||||
profileSettings.enablePrestigeAnnouncements
|
||||
? "stat-toggle-on"
|
||||
: "stat-toggle-off"
|
||||
}`}
|
||||
onClick={handlePrestigeAnnouncementsToggle}
|
||||
type="button"
|
||||
>
|
||||
<span>{"⭐ Prestige Bot Announcements"}</span>
|
||||
<span className="stat-toggle-indicator">
|
||||
{profileSettings.enablePrestigeAnnouncements
|
||||
? "✓ On"
|
||||
: "Off"
|
||||
}
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="edit-profile-section">
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
/* eslint-disable react/no-multi-comp -- Sub-component is tightly coupled to the panel */
|
||||
/* eslint-disable max-lines-per-function -- Complex component with many render paths */
|
||||
/* eslint-disable complexity -- Complex component with many conditional render paths */
|
||||
/* eslint-disable max-lines -- Equipment panel with set bonus display and sort logic */
|
||||
import { type JSX, useState } from "react";
|
||||
import { useGame } from "../../context/gameContext.js";
|
||||
import { EQUIPMENT_SETS } from "../../data/equipmentSets.js";
|
||||
@@ -30,7 +31,7 @@ const bonusDescription = (item: Equipment): string => {
|
||||
const parts: Array<string> = [];
|
||||
if (item.bonus.combatMultiplier !== undefined) {
|
||||
const pct = Math.round((item.bonus.combatMultiplier - 1) * 100);
|
||||
parts.push(`+${String(pct)}% Combat`);
|
||||
parts.push(`+${String(pct)}% Boss Combat`);
|
||||
}
|
||||
if (item.bonus.goldMultiplier !== undefined) {
|
||||
const pct = Math.round((item.bonus.goldMultiplier - 1) * 100);
|
||||
@@ -188,6 +189,20 @@ const EquipmentCard = ({
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Computes a combined power score for sorting — sum of all bonus multipliers.
|
||||
* Using the sum (rather than a single stat) keeps hybrid items in sensible order.
|
||||
* @param item - The equipment piece whose bonus multipliers are summed.
|
||||
* @returns The combined bonus value.
|
||||
*/
|
||||
const equipmentPower = (item: Equipment): number => {
|
||||
return (
|
||||
(item.bonus.combatMultiplier ?? 1)
|
||||
+ (item.bonus.goldMultiplier ?? 1)
|
||||
+ (item.bonus.clickMultiplier ?? 1)
|
||||
);
|
||||
};
|
||||
|
||||
const slotOrder: Array<EquipmentType> = [ "weapon", "armour", "trinket" ];
|
||||
const slotLabel: Record<EquipmentType, string> = {
|
||||
armour: "🛡️ Armour",
|
||||
@@ -261,7 +276,7 @@ const EquipmentPanel = (): JSX.Element => {
|
||||
}
|
||||
if (bonus.combatMultiplier !== undefined) {
|
||||
const pct = Math.round((bonus.combatMultiplier - 1) * 100);
|
||||
parts.push(`+${String(pct)}% Combat (${String(threshold)}pc)`);
|
||||
parts.push(`+${String(pct)}% Boss Combat (${String(threshold)}pc)`);
|
||||
}
|
||||
if (bonus.clickMultiplier !== undefined) {
|
||||
const pct = Math.round((bonus.clickMultiplier - 1) * 100);
|
||||
@@ -320,6 +335,8 @@ const EquipmentPanel = (): JSX.Element => {
|
||||
{slotOrder.map((slotType) => {
|
||||
const items = equipment.filter((item) => {
|
||||
return item.type === slotType && (showLocked || item.owned);
|
||||
}).sort((a, b) => {
|
||||
return equipmentPower(a) - equipmentPower(b);
|
||||
});
|
||||
return (
|
||||
<div className="equipment-slot-section" key={slotType}>
|
||||
|
||||
@@ -6,12 +6,18 @@
|
||||
*/
|
||||
/* eslint-disable max-lines-per-function -- Complex component with many render paths */
|
||||
/* eslint-disable complexity -- Complex component with many conditional render paths */
|
||||
import { type JSX, useState } from "react";
|
||||
/* eslint-disable max-lines -- Exploration panel requires many render paths and result display */
|
||||
/* eslint-disable max-statements -- Component function requires many state declarations and handlers */
|
||||
import { type JSX, useEffect, useRef, useState } from "react";
|
||||
import { checkExplorationClaimable } from "../../api/client.js";
|
||||
import { useGame } from "../../context/gameContext.js";
|
||||
import { EXPLORATION_AREAS } from "../../data/explorations.js";
|
||||
import { cdnImage } from "../../utils/cdn.js";
|
||||
import { ZoneSelector } from "./zoneSelector.js";
|
||||
import type { ExploreCollectResponse } from "@elysium/types";
|
||||
import type {
|
||||
ExploreClaimableResponse,
|
||||
ExploreCollectResponse,
|
||||
} from "@elysium/types";
|
||||
|
||||
/**
|
||||
* Formats a duration in seconds to a human-readable string.
|
||||
@@ -46,11 +52,21 @@ const formatDuration = (seconds: number): string => {
|
||||
|
||||
/**
|
||||
* Computes the time remaining for an exploration in progress.
|
||||
* Uses endsAt (server-computed) when available to avoid client/server clock drift.
|
||||
* Falls back to startedAt + durationSeconds for saves predating the endsAt field.
|
||||
* @param endsAt - The server-computed completion timestamp, if available.
|
||||
* @param startedAt - The timestamp when exploration started.
|
||||
* @param durationSeconds - The total duration in seconds.
|
||||
* @returns The remaining seconds.
|
||||
*/
|
||||
const timeRemaining = (startedAt: number, durationSeconds: number): number => {
|
||||
const timeRemaining = (
|
||||
endsAt: number | undefined,
|
||||
startedAt: number,
|
||||
durationSeconds: number,
|
||||
): number => {
|
||||
if (endsAt !== undefined) {
|
||||
return Math.max(0, (endsAt - Date.now()) / 1000);
|
||||
}
|
||||
const elapsed = (Date.now() - startedAt) / 1000;
|
||||
return Math.max(0, durationSeconds - elapsed);
|
||||
};
|
||||
@@ -72,6 +88,61 @@ const ExplorationPanel = (): JSX.Element => {
|
||||
});
|
||||
const [ pendingAreaId, setPendingAreaId ] = useState<string | null>(null);
|
||||
const [ lastResult, setLastResult ] = useState<CollectResult | null>(null);
|
||||
const [ claimableAreaIds, setClaimableAreaIds ]
|
||||
= useState<ReadonlySet<string>>(new Set());
|
||||
|
||||
const stateReference = useRef(state);
|
||||
stateReference.current = state;
|
||||
|
||||
const claimableReference = useRef(claimableAreaIds);
|
||||
claimableReference.current = claimableAreaIds;
|
||||
|
||||
useEffect(() => {
|
||||
const pollClaimable = async(): Promise<void> => {
|
||||
const currentState = stateReference.current;
|
||||
if (currentState === null) {
|
||||
return;
|
||||
}
|
||||
const inProgressArea = currentState.exploration?.areas.find((a) => {
|
||||
return a.status === "in_progress";
|
||||
});
|
||||
if (inProgressArea === undefined) {
|
||||
return;
|
||||
}
|
||||
if (claimableReference.current.has(inProgressArea.id)) {
|
||||
return;
|
||||
}
|
||||
const areaData = EXPLORATION_AREAS.find((a) => {
|
||||
return a.id === inProgressArea.id;
|
||||
});
|
||||
if (areaData === undefined) {
|
||||
return;
|
||||
}
|
||||
const remaining = timeRemaining(
|
||||
inProgressArea.endsAt,
|
||||
inProgressArea.startedAt ?? 0,
|
||||
areaData.durationSeconds,
|
||||
);
|
||||
if (remaining > 0) {
|
||||
return;
|
||||
}
|
||||
const result: ExploreClaimableResponse
|
||||
= await checkExplorationClaimable(inProgressArea.id);
|
||||
if (result.claimable) {
|
||||
setClaimableAreaIds((previous) => {
|
||||
return new Set([ ...previous, inProgressArea.id ]);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const intervalId = setInterval(() => {
|
||||
void pollClaimable();
|
||||
}, 1000);
|
||||
|
||||
return (): void => {
|
||||
clearInterval(intervalId);
|
||||
};
|
||||
}, []);
|
||||
|
||||
if (state === null) {
|
||||
return (
|
||||
@@ -81,7 +152,24 @@ const ExplorationPanel = (): JSX.Element => {
|
||||
);
|
||||
}
|
||||
|
||||
const { zones, exploration: explorationState } = state;
|
||||
const { zones, exploration: explorationState, bosses, quests } = state;
|
||||
|
||||
const activeZone = zones.find((zone) => {
|
||||
return zone.id === activeZoneId;
|
||||
});
|
||||
const zoneIsLocked = activeZone?.status === "locked";
|
||||
const unlockBoss = activeZone?.unlockBossId === null
|
||||
|| activeZone?.unlockBossId === undefined
|
||||
? undefined
|
||||
: bosses.find((boss) => {
|
||||
return boss.id === activeZone.unlockBossId;
|
||||
});
|
||||
const unlockQuest = activeZone?.unlockQuestId === null
|
||||
|| activeZone?.unlockQuestId === undefined
|
||||
? undefined
|
||||
: quests.find((quest) => {
|
||||
return quest.id === activeZone.unlockQuestId;
|
||||
});
|
||||
|
||||
const zoneAreas = EXPLORATION_AREAS.filter((area) => {
|
||||
return area.zoneId === activeZoneId;
|
||||
@@ -106,6 +194,11 @@ const ExplorationPanel = (): JSX.Element => {
|
||||
try {
|
||||
const result = await collectExploration(areaId);
|
||||
setLastResult({ areaId: areaId, response: result });
|
||||
setClaimableAreaIds((previous) => {
|
||||
const next = new Set(previous);
|
||||
next.delete(areaId);
|
||||
return next;
|
||||
});
|
||||
} finally {
|
||||
setPendingAreaId(null);
|
||||
}
|
||||
@@ -210,6 +303,27 @@ const ExplorationPanel = (): JSX.Element => {
|
||||
zones={zones}
|
||||
/>
|
||||
|
||||
{zoneIsLocked && (unlockBoss !== undefined || unlockQuest !== undefined)
|
||||
? <div className="exploration-zone-locked-hint">
|
||||
<p>{"🔒 This zone is locked. Unlock exploration by:"}</p>
|
||||
{unlockBoss === undefined
|
||||
? null
|
||||
: <p>
|
||||
{"⚔️ Defeat: "}
|
||||
{unlockBoss.name}
|
||||
</p>
|
||||
}
|
||||
{unlockQuest === undefined
|
||||
? null
|
||||
: <p>
|
||||
{"📜 Complete: "}
|
||||
{unlockQuest.name}
|
||||
</p>
|
||||
}
|
||||
</div>
|
||||
: null
|
||||
}
|
||||
|
||||
<div className="exploration-list">
|
||||
{zoneAreas.map((area) => {
|
||||
const areaState = explorationState?.areas.find((explorationArea) => {
|
||||
@@ -217,9 +331,10 @@ const ExplorationPanel = (): JSX.Element => {
|
||||
});
|
||||
const status = areaState?.status ?? "locked";
|
||||
const startedAt = areaState?.startedAt ?? 0;
|
||||
const endsAt = areaState?.endsAt;
|
||||
const isReady
|
||||
= status === "in_progress"
|
||||
&& timeRemaining(startedAt, area.durationSeconds) <= 0;
|
||||
&& claimableAreaIds.has(area.id);
|
||||
const isPending = pendingAreaId === area.id;
|
||||
|
||||
function handleStartClick(): void {
|
||||
@@ -276,9 +391,8 @@ const ExplorationPanel = (): JSX.Element => {
|
||||
{status === "in_progress" && !isReady
|
||||
&& <span className="quest-badge active">
|
||||
{"⏳ "}
|
||||
{formatDuration(
|
||||
Math.ceil(timeRemaining(startedAt, area.durationSeconds)),
|
||||
)}
|
||||
{/* eslint-disable-next-line stylistic/max-len -- long call cannot be shortened */}
|
||||
{formatDuration(Math.ceil(timeRemaining(endsAt, startedAt, area.durationSeconds)))}
|
||||
{" remaining"}
|
||||
</span>
|
||||
}
|
||||
|
||||
@@ -23,9 +23,11 @@ import { CodexToast } from "./codexToast.js";
|
||||
import { CompanionPanel } from "./companionPanel.js";
|
||||
import { CraftingPanel } from "./craftingPanel.js";
|
||||
import { DailyChallengePanel } from "./dailyChallengePanel.js";
|
||||
import { DebugPanel } from "./debugPanel.js";
|
||||
import { EditProfileModal } from "./editProfileModal.js";
|
||||
import { EquipmentPanel } from "./equipmentPanel.js";
|
||||
import { ExplorationPanel } from "./explorationPanel.js";
|
||||
import { JoinCommunityModal } from "./joinCommunityModal.js";
|
||||
import { LoginBonusModal } from "./loginBonusModal.js";
|
||||
import { MilestoneToast } from "./milestoneToast.js";
|
||||
import { OfflineModal } from "./offlineModal.js";
|
||||
@@ -57,7 +59,8 @@ type Tab =
|
||||
| "crafting"
|
||||
| "character"
|
||||
| "companions"
|
||||
| "story";
|
||||
| "story"
|
||||
| "debug";
|
||||
|
||||
const baseTabs: Array<{ id: Tab; label: string }> = [
|
||||
{ id: "adventurers", label: "⚔️ Adventurers" },
|
||||
@@ -78,6 +81,7 @@ const baseTabs: Array<{ id: Tab; label: string }> = [
|
||||
{ id: "story", label: "📖 Story" },
|
||||
{ id: "codex", label: "🗺️ Codex" },
|
||||
{ id: "about", label: "ℹ️ About" },
|
||||
{ id: "debug", label: "🔧 Debug" },
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -132,7 +136,6 @@ const GameLayout = (): JSX.Element => {
|
||||
);
|
||||
}
|
||||
|
||||
const profileUrl = `/profile/${state.player.discordId}`;
|
||||
const codexBadgeCount = pendingCodexEntryIds.length;
|
||||
const storyBadgeCount = pendingStoryChapterIds.length;
|
||||
|
||||
@@ -157,12 +160,12 @@ const GameLayout = (): JSX.Element => {
|
||||
onEditProfile={handleOpenEditProfile}
|
||||
onForceSync={forceSync}
|
||||
prestigeCount={state.prestige.count}
|
||||
profileUrl={profileUrl}
|
||||
resources={state.resources}
|
||||
runestones={state.prestige.runestones}
|
||||
transcendenceCount={state.transcendence?.count ?? 0}
|
||||
/>
|
||||
<OfflineModal />
|
||||
<JoinCommunityModal />
|
||||
{schemaOutdated && !dismissedOutdatedWarning
|
||||
? <OutdatedSchemaModal onDismiss={handleDismissOutdated} />
|
||||
: null}
|
||||
@@ -242,6 +245,7 @@ const GameLayout = (): JSX.Element => {
|
||||
{activeTab === "story" && <StoryPanel />}
|
||||
{activeTab === "codex" && <CodexPanel />}
|
||||
{activeTab === "about" && <AboutPanel />}
|
||||
{activeTab === "debug" && <DebugPanel />}
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* @file Modal prompting players to join the NHCarrigan Discord community.
|
||||
* @copyright nhcarrigan
|
||||
* @license Naomi's Public License
|
||||
* @author Naomi Carrigan
|
||||
*/
|
||||
import { useCallback, useState, type JSX } from "react";
|
||||
import { useGame } from "../../context/gameContext.js";
|
||||
|
||||
const sessionKey = "elysium_join_community_dismissed";
|
||||
|
||||
/**
|
||||
* Renders a modal prompting the player to join the NHCarrigan Discord server.
|
||||
* Shown once per session when the player is not already in the guild.
|
||||
* @returns The JSX element or null if the player is in the guild or dismissed.
|
||||
*/
|
||||
const JoinCommunityModal = (): JSX.Element | null => {
|
||||
const { inGuild } = useGame();
|
||||
const [ dismissed, setDismissed ] = useState(
|
||||
() => {
|
||||
return sessionStorage.getItem(sessionKey) === "true";
|
||||
},
|
||||
);
|
||||
|
||||
const handleDismiss = useCallback((): void => {
|
||||
sessionStorage.setItem(sessionKey, "true");
|
||||
setDismissed(true);
|
||||
}, []);
|
||||
|
||||
if (inGuild || dismissed) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="modal-overlay">
|
||||
<div className="modal">
|
||||
<h2>{"Join Our Community!"}</h2>
|
||||
<p>
|
||||
{"Did you know Elysium has an active Discord community? "}
|
||||
{"Join to chat with other players, get updates, and earn "}
|
||||
{"the exclusive Elysian role!"}
|
||||
</p>
|
||||
<p className="modal-note">
|
||||
{"You already earn the Elysian role just by playing — "}
|
||||
{"joining lets us show it off in the server!"}
|
||||
</p>
|
||||
<div className="modal-actions">
|
||||
<a
|
||||
className="modal-close-button"
|
||||
href="https://discord.gg/KKe7BaEnQB"
|
||||
onClick={handleDismiss}
|
||||
rel="noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
{"Join Discord"}
|
||||
</a>
|
||||
<button
|
||||
className="modal-close-button"
|
||||
onClick={handleDismiss}
|
||||
type="button"
|
||||
>
|
||||
{"Maybe later"}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export { JoinCommunityModal };
|
||||
@@ -156,6 +156,9 @@ const LeaderboardPage = (): JSX.Element => {
|
||||
<p className="leaderboard-subtitle">
|
||||
{"The mightiest adventurers in Elysium"}
|
||||
</p>
|
||||
<p className="leaderboard-update-note">
|
||||
{"🔄 Rankings update when you prestige."}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="leaderboard-tabs">
|
||||
|
||||
@@ -12,25 +12,27 @@ import { useState, type JSX } from "react";
|
||||
import { prestige } from "../../api/client.js";
|
||||
import { useGame } from "../../context/gameContext.js";
|
||||
import {
|
||||
PRESTIGE_UPGRADES,
|
||||
PRESTIGE_UPGRADE_CATEGORY_LABELS,
|
||||
PRESTIGE_UPGRADES,
|
||||
} from "../../data/prestigeUpgrades.js";
|
||||
import {
|
||||
computeProjectedRunestones,
|
||||
} from "../../engine/tick.js";
|
||||
import { cdnImage } from "../../utils/cdn.js";
|
||||
import { sendNotification } from "../../utils/notification.js";
|
||||
import { playSound } from "../../utils/sound.js";
|
||||
import type { PrestigeUpgradeCategory } from "@elysium/types";
|
||||
|
||||
const baseThreshold = 1_000_000;
|
||||
const thresholdScale = 5;
|
||||
const runestonesPerLevel = 10;
|
||||
|
||||
/**
|
||||
* Calculates the prestige threshold for a given prestige count.
|
||||
* Mirrors the server formula: BASE * (count + 1)^2.
|
||||
* @param prestigeCount - The current prestige count.
|
||||
* @returns The required gold to prestige.
|
||||
*/
|
||||
const calculateThreshold = (prestigeCount: number): number => {
|
||||
return baseThreshold * Math.pow(thresholdScale, prestigeCount);
|
||||
return baseThreshold * Math.pow(prestigeCount + 1, 2);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -42,32 +44,6 @@ const calculateProductionMultiplier = (prestigeCount: number): number => {
|
||||
return Math.pow(1.15, prestigeCount);
|
||||
};
|
||||
|
||||
/**
|
||||
* Calculates the runestone preview for a prestige.
|
||||
* @param totalGoldEarned - Total gold earned this run.
|
||||
* @param prestigeCount - The current prestige count.
|
||||
* @param purchasedUpgradeIds - IDs of purchased prestige upgrades.
|
||||
* @returns The predicted runestone reward.
|
||||
*/
|
||||
const calculateRunestonePreview = (
|
||||
totalGoldEarned: number,
|
||||
prestigeCount: number,
|
||||
purchasedUpgradeIds: Array<string>,
|
||||
): number => {
|
||||
const threshold = calculateThreshold(prestigeCount);
|
||||
const base
|
||||
= Math.floor(Math.sqrt(totalGoldEarned / threshold)) * runestonesPerLevel;
|
||||
const runestoneMult = PRESTIGE_UPGRADES.filter((upgrade) => {
|
||||
return (
|
||||
upgrade.category === "runestones"
|
||||
&& purchasedUpgradeIds.includes(upgrade.id)
|
||||
);
|
||||
}).reduce((mult, upgrade) => {
|
||||
return mult * upgrade.multiplier;
|
||||
}, 1);
|
||||
return Math.floor(base * runestoneMult);
|
||||
};
|
||||
|
||||
const categoryOrder: Array<PrestigeUpgradeCategory> = [
|
||||
"income",
|
||||
"click",
|
||||
@@ -84,11 +60,12 @@ const categoryOrder: Array<PrestigeUpgradeCategory> = [
|
||||
const PrestigePanel = (): JSX.Element => {
|
||||
const {
|
||||
state,
|
||||
reload,
|
||||
reloadSilent,
|
||||
formatNumber,
|
||||
buyPrestigeUpgrade,
|
||||
enableNotifications,
|
||||
enableSounds,
|
||||
toggleAutoAdventurer,
|
||||
toggleAutoPrestige,
|
||||
triggerPrestigeToast,
|
||||
} = useGame();
|
||||
@@ -110,14 +87,10 @@ const PrestigePanel = (): JSX.Element => {
|
||||
);
|
||||
}
|
||||
|
||||
const { prestige: prestigeData, player } = state;
|
||||
const { autoAdventurer, prestige: prestigeData, player } = state;
|
||||
const threshold = calculateThreshold(prestigeData.count);
|
||||
const isEligible = player.totalGoldEarned >= threshold;
|
||||
const runestonePreview = calculateRunestonePreview(
|
||||
player.totalGoldEarned,
|
||||
prestigeData.count,
|
||||
prestigeData.purchasedUpgradeIds,
|
||||
);
|
||||
const runestonePreview = computeProjectedRunestones(state);
|
||||
const nextMultiplier = calculateProductionMultiplier(prestigeData.count + 1);
|
||||
|
||||
async function handlePrestige(): Promise<void> {
|
||||
@@ -140,7 +113,7 @@ const PrestigePanel = (): JSX.Element => {
|
||||
`You've reached prestige level ${data.newPrestigeCount.toString()}!`,
|
||||
);
|
||||
}
|
||||
await reload();
|
||||
await reloadSilent();
|
||||
} catch (error_: unknown) {
|
||||
setPrestigeError(
|
||||
error_ instanceof Error
|
||||
@@ -173,6 +146,10 @@ const PrestigePanel = (): JSX.Element => {
|
||||
void handlePrestige();
|
||||
}
|
||||
|
||||
function handleAutoAdventurerToggle(): void {
|
||||
toggleAutoAdventurer();
|
||||
}
|
||||
|
||||
function handleAutoPrestigeToggle(): void {
|
||||
toggleAutoPrestige();
|
||||
}
|
||||
@@ -347,6 +324,9 @@ const PrestigePanel = (): JSX.Element => {
|
||||
= prestigeData.runestones >= upgrade.runestonesCost;
|
||||
const isLoading = buyingId === upgrade.id;
|
||||
|
||||
const isAutoAdventurerToggle
|
||||
= upgrade.id === "auto_adventurer" && purchased;
|
||||
const autoAdventurerEnabled = autoAdventurer ?? false;
|
||||
const isAutoPrestigeToggle
|
||||
= upgrade.id === "auto_prestige" && purchased;
|
||||
const autoPrestigeEnabled
|
||||
@@ -381,6 +361,21 @@ const PrestigePanel = (): JSX.Element => {
|
||||
: `🔮 ${formatNumber(upgrade.runestonesCost)} Runestones`}
|
||||
</p>
|
||||
</div>
|
||||
{isAutoAdventurerToggle
|
||||
? <button
|
||||
className={`auto-prestige-toggle ${
|
||||
autoAdventurerEnabled
|
||||
? "enabled"
|
||||
: "disabled"
|
||||
}`}
|
||||
onClick={handleAutoAdventurerToggle}
|
||||
type="button"
|
||||
>
|
||||
{autoAdventurerEnabled
|
||||
? "⚡ Auto ON"
|
||||
: "⏸ Auto OFF"}
|
||||
</button>
|
||||
: null}
|
||||
{isAutoPrestigeToggle
|
||||
? <button
|
||||
className={`auto-prestige-toggle ${
|
||||
|
||||
@@ -4,12 +4,17 @@
|
||||
* @license Naomi's Public License
|
||||
* @author Naomi Carrigan
|
||||
*/
|
||||
/* eslint-disable max-lines -- QuestPanel with sub-component and helper functions */
|
||||
/* eslint-disable react/no-multi-comp -- QuestCard sub-component is tightly coupled */
|
||||
/* eslint-disable max-lines-per-function -- Complex component with many render paths */
|
||||
/* eslint-disable complexity -- Many conditional render paths */
|
||||
/* eslint-disable max-statements -- Many local variables needed for quest state */
|
||||
import { useState, type JSX } from "react";
|
||||
import { useGame } from "../../context/gameContext.js";
|
||||
import {
|
||||
computePartyCombatPower,
|
||||
zoneFailureChance,
|
||||
} from "../../engine/tick.js";
|
||||
import { cdnImage } from "../../utils/cdn.js";
|
||||
import { LockToggle } from "../ui/lockToggle.js";
|
||||
import { ZoneSelector } from "./zoneSelector.js";
|
||||
@@ -143,8 +148,17 @@ const QuestCard = ({
|
||||
: null}
|
||||
</>
|
||||
}
|
||||
{quest.status === "available"
|
||||
&& <p className="quest-failure-chance">
|
||||
{"🎲 "}
|
||||
{String(Math.round((zoneFailureChance[quest.zoneId] ?? 0) * 100))}
|
||||
{"% failure chance"}
|
||||
</p>
|
||||
}
|
||||
{quest.status === "available" && quest.lastFailedAt !== undefined
|
||||
&& <p className="quest-failed-hint">{"⚠️ Last attempt failed"}</p>
|
||||
&& <p className="quest-failed-hint">
|
||||
{"⚠️ Last attempt failed — no rewards were granted."}
|
||||
</p>
|
||||
}
|
||||
{quest.status === "available"
|
||||
&& <button
|
||||
@@ -197,12 +211,25 @@ const QuestPanel = (): JSX.Element => {
|
||||
);
|
||||
}
|
||||
|
||||
const { adventurers, autoQuest, quests, zones } = state;
|
||||
let partyCombatPower = 0;
|
||||
for (const adventurer of adventurers) {
|
||||
const contribution = adventurer.combatPower * adventurer.count;
|
||||
partyCombatPower = partyCombatPower + contribution;
|
||||
}
|
||||
const { autoQuest, bosses, quests, zones } = state;
|
||||
|
||||
const activeZone = zones.find((zone) => {
|
||||
return zone.id === activeZoneId;
|
||||
});
|
||||
const zoneIsLocked = activeZone?.status === "locked";
|
||||
const unlockBoss = activeZone?.unlockBossId === null
|
||||
|| activeZone?.unlockBossId === undefined
|
||||
? undefined
|
||||
: bosses.find((boss) => {
|
||||
return boss.id === activeZone.unlockBossId;
|
||||
});
|
||||
const unlockQuest = activeZone?.unlockQuestId === null
|
||||
|| activeZone?.unlockQuestId === undefined
|
||||
? undefined
|
||||
: quests.find((quest) => {
|
||||
return quest.id === activeZone.unlockQuestId;
|
||||
});
|
||||
const partyCombatPower = computePartyCombatPower(state);
|
||||
const zoneQuests = quests.filter(({ zoneId }) => {
|
||||
return zoneId === activeZoneId;
|
||||
});
|
||||
@@ -296,6 +323,31 @@ const QuestPanel = (): JSX.Element => {
|
||||
zones={zones}
|
||||
/>
|
||||
|
||||
{zoneIsLocked && (unlockBoss !== undefined || unlockQuest !== undefined)
|
||||
? <div className="exploration-zone-locked-hint">
|
||||
<p>{"🔒 This zone is locked. Unlock quests by:"}</p>
|
||||
{unlockBoss === undefined
|
||||
? null
|
||||
: <p>
|
||||
{"⚔️ Defeat: "}
|
||||
{unlockBoss.name}
|
||||
</p>
|
||||
}
|
||||
{unlockQuest === undefined
|
||||
? null
|
||||
: <p>
|
||||
{"📜 Complete: "}
|
||||
{unlockQuest.name}
|
||||
</p>
|
||||
}
|
||||
</div>
|
||||
: null
|
||||
}
|
||||
|
||||
<p className="quest-failure-note">
|
||||
{"⚠️ If a quest fails, it resets with no rewards — you must retry."}
|
||||
</p>
|
||||
|
||||
<div className="quest-list">
|
||||
{visibleQuests.map((quest) => {
|
||||
return (
|
||||
|
||||
@@ -7,11 +7,13 @@
|
||||
/* eslint-disable react/no-multi-comp -- Sub-component is tightly coupled to the panel */
|
||||
/* eslint-disable max-lines-per-function -- Complex component with many render paths */
|
||||
/* eslint-disable complexity -- UpgradeCard has many conditional render paths for states */
|
||||
/* eslint-disable max-statements -- UpgradePanel builds hints from three sources */
|
||||
/* eslint-disable max-lines -- Upgrade panel with sub-component exceeds line limit */
|
||||
import { type JSX, useState } from "react";
|
||||
import { useGame } from "../../context/gameContext.js";
|
||||
import { cdnImage } from "../../utils/cdn.js";
|
||||
import { LockToggle } from "../ui/lockToggle.js";
|
||||
import type { Upgrade } from "@elysium/types";
|
||||
import type { Adventurer, Upgrade } from "@elysium/types";
|
||||
|
||||
interface UpgradeCardProperties {
|
||||
readonly upgrade: Upgrade;
|
||||
@@ -20,6 +22,7 @@ interface UpgradeCardProperties {
|
||||
readonly currentCrystals: number;
|
||||
readonly unlockHint: string | undefined;
|
||||
readonly formatNumber: (n: number)=> string;
|
||||
readonly adventurers: ReadonlyArray<Adventurer>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -31,6 +34,7 @@ interface UpgradeCardProperties {
|
||||
* @param props.currentCrystals - The current crystals amount.
|
||||
* @param props.unlockHint - Optional hint for how to unlock this upgrade.
|
||||
* @param props.formatNumber - The number formatting utility function.
|
||||
* @param props.adventurers - The list of adventurers, used to resolve the affected adventurer name.
|
||||
* @returns The JSX element.
|
||||
*/
|
||||
const UpgradeCard = ({
|
||||
@@ -40,8 +44,14 @@ const UpgradeCard = ({
|
||||
currentCrystals,
|
||||
unlockHint,
|
||||
formatNumber,
|
||||
adventurers,
|
||||
}: UpgradeCardProperties): JSX.Element => {
|
||||
const { buyUpgrade } = useGame();
|
||||
const adventurerName = upgrade.adventurerId === undefined
|
||||
? undefined
|
||||
: adventurers.find((adventurer) => {
|
||||
return adventurer.id === upgrade.adventurerId;
|
||||
})?.name;
|
||||
const canAfford
|
||||
= currentGold >= upgrade.costGold
|
||||
&& currentEssence >= upgrade.costEssence
|
||||
@@ -64,6 +74,13 @@ const UpgradeCard = ({
|
||||
{upgrade.name}
|
||||
</span>
|
||||
<span className="upgrade-desc">{upgrade.description}</span>
|
||||
{adventurerName === undefined
|
||||
? null
|
||||
: <span className="upgrade-target">
|
||||
{"🗡️ Affects: "}
|
||||
{adventurerName}
|
||||
</span>
|
||||
}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -79,6 +96,13 @@ const UpgradeCard = ({
|
||||
<div className="upgrade-info">
|
||||
<h3>{upgrade.name}</h3>
|
||||
<p>{upgrade.description}</p>
|
||||
{adventurerName === undefined
|
||||
? null
|
||||
: <p className="upgrade-target">
|
||||
{"🗡️ Affects: "}
|
||||
{adventurerName}
|
||||
</p>
|
||||
}
|
||||
<p className="upgrade-multiplier">
|
||||
{"×"}
|
||||
{upgrade.multiplier}
|
||||
@@ -130,6 +154,13 @@ const UpgradeCard = ({
|
||||
{upgrade.name}
|
||||
</h3>
|
||||
<p>{upgrade.description}</p>
|
||||
{adventurerName === undefined
|
||||
? null
|
||||
: <p className="upgrade-target">
|
||||
{"🗡️ Affects: "}
|
||||
{adventurerName}
|
||||
</p>
|
||||
}
|
||||
<p className="upgrade-multiplier">
|
||||
{"×"}
|
||||
{upgrade.multiplier}
|
||||
@@ -181,7 +212,7 @@ const UpgradePanel = (): JSX.Element => {
|
||||
);
|
||||
}
|
||||
|
||||
const { bosses, quests, upgrades, resources } = state;
|
||||
const { adventurers, bosses, quests, upgrades, resources } = state;
|
||||
const purchased = upgrades.filter((upgrade) => {
|
||||
return upgrade.purchased;
|
||||
});
|
||||
@@ -209,6 +240,22 @@ const UpgradePanel = (): JSX.Element => {
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const upgrade of locked) {
|
||||
if (
|
||||
!upgradeUnlockHints.has(upgrade.id)
|
||||
&& upgrade.adventurerId !== undefined
|
||||
) {
|
||||
const adventurerForHint = adventurers.find((a) => {
|
||||
return a.id === upgrade.adventurerId;
|
||||
});
|
||||
if (adventurerForHint !== undefined) {
|
||||
upgradeUnlockHints.set(
|
||||
upgrade.id,
|
||||
`🗡️ Recruit: ${adventurerForHint.name}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function handleToggle(): void {
|
||||
setShowLocked((current) => {
|
||||
@@ -232,6 +279,10 @@ const UpgradePanel = (): JSX.Element => {
|
||||
{upgrades.length}
|
||||
{" purchased"}
|
||||
</p>
|
||||
<p className="upgrade-stacking-note">
|
||||
{"💡 Upgrade multipliers stack multiplicatively — two ×2 upgrades"
|
||||
+ " combine to give ×4, not ×3."}
|
||||
</p>
|
||||
{upgrades.length === 0
|
||||
? <p className="empty-state">
|
||||
{"No upgrades available yet — keep adventuring!"}
|
||||
@@ -240,6 +291,7 @@ const UpgradePanel = (): JSX.Element => {
|
||||
{available.map((upgrade) => {
|
||||
return (
|
||||
<UpgradeCard
|
||||
adventurers={adventurers}
|
||||
currentCrystals={resources.crystals}
|
||||
currentEssence={resources.essence}
|
||||
currentGold={resources.gold}
|
||||
@@ -253,6 +305,7 @@ const UpgradePanel = (): JSX.Element => {
|
||||
{purchased.map((upgrade) => {
|
||||
return (
|
||||
<UpgradeCard
|
||||
adventurers={adventurers}
|
||||
currentCrystals={resources.crystals}
|
||||
currentEssence={resources.essence}
|
||||
currentGold={resources.gold}
|
||||
@@ -267,6 +320,7 @@ const UpgradePanel = (): JSX.Element => {
|
||||
? locked.map((upgrade) => {
|
||||
return (
|
||||
<UpgradeCard
|
||||
adventurers={adventurers}
|
||||
currentCrystals={resources.crystals}
|
||||
currentEssence={resources.essence}
|
||||
currentGold={resources.gold}
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* @file Reusable confirmation modal component for destructive operations.
|
||||
* @copyright nhcarrigan
|
||||
* @license Naomi's Public License
|
||||
* @author Naomi Carrigan
|
||||
*/
|
||||
import type { JSX } from "react";
|
||||
|
||||
interface ConfirmationModalProperties {
|
||||
readonly title: string;
|
||||
readonly description: string;
|
||||
readonly confirmLabel: string;
|
||||
readonly onConfirm: ()=> void;
|
||||
readonly onCancel: ()=> void;
|
||||
readonly isLoading: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a confirmation modal for destructive operations.
|
||||
* @param props - The modal properties.
|
||||
* @param props.title - The modal heading.
|
||||
* @param props.description - Warning text explaining what the operation does.
|
||||
* @param props.confirmLabel - Label for the confirm button.
|
||||
* @param props.onConfirm - Callback fired when the player confirms.
|
||||
* @param props.onCancel - Callback fired when the player cancels.
|
||||
* @param props.isLoading - Whether the operation is currently in progress.
|
||||
* @returns The JSX element.
|
||||
*/
|
||||
const ConfirmationModal = ({
|
||||
title,
|
||||
description,
|
||||
confirmLabel,
|
||||
onConfirm,
|
||||
onCancel,
|
||||
isLoading,
|
||||
}: ConfirmationModalProperties): JSX.Element => {
|
||||
return (
|
||||
<div className="modal-overlay">
|
||||
<div className="modal">
|
||||
<h2>{title}</h2>
|
||||
<p>{description}</p>
|
||||
<p className="modal-note">{"Are you sure you want to do this?"}</p>
|
||||
<div className="modal-actions">
|
||||
<button
|
||||
className="modal-close-button modal-button-danger"
|
||||
disabled={isLoading}
|
||||
onClick={onConfirm}
|
||||
type="button"
|
||||
>
|
||||
{isLoading
|
||||
? "Working..."
|
||||
: confirmLabel}
|
||||
</button>
|
||||
<button
|
||||
className="modal-close-button"
|
||||
disabled={isLoading}
|
||||
onClick={onCancel}
|
||||
type="button"
|
||||
>
|
||||
{"Cancel"}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export { ConfirmationModal };
|
||||
@@ -4,12 +4,20 @@
|
||||
* @license Naomi's Public License
|
||||
* @author Naomi Carrigan
|
||||
*/
|
||||
/* eslint-disable max-lines -- Resource bar has many resource and action elements */
|
||||
/* eslint-disable max-lines-per-function -- Large header with many resource and action elements */
|
||||
/* eslint-disable max-statements -- Resource bar requires many local computations and handlers */
|
||||
/* eslint-disable complexity -- Many conditional resource and badge render paths */
|
||||
import { useState, type FocusEvent, type JSX } from "react";
|
||||
import { useGame } from "../../context/gameContext.js";
|
||||
import { RESOURCE_CAP } from "../../engine/tick.js";
|
||||
import {
|
||||
RESOURCE_CAP,
|
||||
computeEssencePerSecond,
|
||||
computeGoldPerSecond,
|
||||
computePartyCombatPower,
|
||||
computeProjectedRunestones,
|
||||
} from "../../engine/tick.js";
|
||||
import type { Resource } from "@elysium/types";
|
||||
import type { JSX } from "react";
|
||||
|
||||
interface ResourceBarProperties {
|
||||
readonly resources: Resource;
|
||||
@@ -17,7 +25,6 @@ interface ResourceBarProperties {
|
||||
readonly prestigeCount: number;
|
||||
readonly transcendenceCount: number;
|
||||
readonly apotheosisCount: number;
|
||||
readonly profileUrl: string;
|
||||
readonly onEditProfile: ()=> void;
|
||||
readonly lastSavedAt: number | null;
|
||||
readonly isSyncing: boolean;
|
||||
@@ -58,7 +65,6 @@ const resourceFullTooltip = [
|
||||
* @param props.prestigeCount - The number of prestiges completed.
|
||||
* @param props.transcendenceCount - The number of transcendences completed.
|
||||
* @param props.apotheosisCount - The number of apotheoses completed.
|
||||
* @param props.profileUrl - The URL of the player's public profile.
|
||||
* @param props.onEditProfile - Callback to open the edit profile modal.
|
||||
* @param props.lastSavedAt - Timestamp of the last cloud save.
|
||||
* @param props.isSyncing - Whether a sync is currently in progress.
|
||||
@@ -71,70 +77,183 @@ const ResourceBar = ({
|
||||
prestigeCount,
|
||||
transcendenceCount,
|
||||
apotheosisCount,
|
||||
profileUrl,
|
||||
onEditProfile,
|
||||
lastSavedAt,
|
||||
isSyncing,
|
||||
onForceSync,
|
||||
}: ResourceBarProperties): JSX.Element => {
|
||||
const { formatNumber, syncError } = useGame();
|
||||
const { formatNumber, syncError, state } = useGame();
|
||||
const [ isProfileOpen, setIsProfileOpen ] = useState(false);
|
||||
const [ isResourcesOpen, setIsResourcesOpen ] = useState(false);
|
||||
|
||||
const { gold, essence, crystals } = resources;
|
||||
const resourceValues = [ gold, essence, crystals ];
|
||||
const anyFull = resourceValues.some((v) => {
|
||||
return v >= RESOURCE_CAP;
|
||||
});
|
||||
let partyCombatPower = 0;
|
||||
let goldPerSecond = 0;
|
||||
let essencePerSecond = 0;
|
||||
let projectedRunestones = 0;
|
||||
if (state !== null) {
|
||||
partyCombatPower = computePartyCombatPower(state);
|
||||
goldPerSecond = computeGoldPerSecond(state);
|
||||
essencePerSecond = computeEssencePerSecond(state);
|
||||
projectedRunestones = computeProjectedRunestones(state);
|
||||
}
|
||||
|
||||
let avatarUrl: string | null = null;
|
||||
if (state !== null) {
|
||||
avatarUrl = state.player.avatar === null
|
||||
? `https://cdn.discordapp.com/embed/avatars/${String(Number.parseInt(state.player.discordId, 10) % 5)}.png`
|
||||
: `https://cdn.discordapp.com/avatars/${state.player.discordId}/${state.player.avatar}.png?size=64`;
|
||||
}
|
||||
const profileUrl = state === null
|
||||
? "#"
|
||||
: `/profile/${state.player.discordId}`;
|
||||
|
||||
const goldFull = gold >= RESOURCE_CAP;
|
||||
const essenceFull = essence >= RESOURCE_CAP;
|
||||
const crystalsFull = crystals >= RESOURCE_CAP;
|
||||
const anyFull = goldFull || essenceFull || crystalsFull;
|
||||
const hiddenResourcesFull = essenceFull || crystalsFull;
|
||||
|
||||
function handleForceSync(): void {
|
||||
void onForceSync();
|
||||
}
|
||||
|
||||
function handleToggleResources(): void {
|
||||
setIsResourcesOpen((previous) => {
|
||||
return !previous;
|
||||
});
|
||||
}
|
||||
|
||||
function handleResourceBlur(event: FocusEvent<HTMLDivElement>): void {
|
||||
if (!event.currentTarget.contains(event.relatedTarget)) {
|
||||
setIsResourcesOpen(false);
|
||||
}
|
||||
}
|
||||
|
||||
function handleToggleProfile(): void {
|
||||
setIsProfileOpen((previous) => {
|
||||
return !previous;
|
||||
});
|
||||
}
|
||||
|
||||
function handleProfileBlur(event: FocusEvent<HTMLDivElement>): void {
|
||||
if (!event.currentTarget.contains(event.relatedTarget)) {
|
||||
setIsProfileOpen(false);
|
||||
}
|
||||
}
|
||||
|
||||
function handleEditProfile(): void {
|
||||
setIsProfileOpen(false);
|
||||
onEditProfile();
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<header className="resource-bar">
|
||||
<div className={`resource${goldFull
|
||||
? " resource-full"
|
||||
: ""}`}>
|
||||
<span className="resource-icon">{"🪙"}</span>
|
||||
<span className="resource-value">{formatNumber(gold)}</span>
|
||||
<span className="resource-label">{"Gold"}</span>
|
||||
{goldFull
|
||||
? <span className="resource-cap-badge" title={resourceFullTooltip}>
|
||||
{"FULL"}
|
||||
</span>
|
||||
<div
|
||||
className="resource-menu"
|
||||
onBlur={handleResourceBlur}
|
||||
>
|
||||
<button
|
||||
className={`resource resource-toggle${goldFull
|
||||
? " resource-full"
|
||||
: ""}`}
|
||||
onClick={handleToggleResources}
|
||||
title="Click to see all resources"
|
||||
type="button"
|
||||
>
|
||||
<span className="resource-icon">{"🪙"}</span>
|
||||
<span className="resource-value">{formatNumber(gold)}</span>
|
||||
<span className="resource-label">{"Gold"}</span>
|
||||
{goldFull
|
||||
? <span
|
||||
className="resource-cap-badge"
|
||||
title={resourceFullTooltip}
|
||||
>
|
||||
{"FULL"}
|
||||
</span>
|
||||
: null}
|
||||
{hiddenResourcesFull
|
||||
? <span
|
||||
className="resource-alert-dot"
|
||||
title={"One or more resources are full!"}
|
||||
/>
|
||||
: null}
|
||||
</button>
|
||||
{isResourcesOpen
|
||||
? <div className="resources-dropdown">
|
||||
<div className="resource">
|
||||
<span className="resource-icon">{"📈"}</span>
|
||||
<span className="resource-value">
|
||||
{formatNumber(goldPerSecond)}
|
||||
</span>
|
||||
<span className="resource-label">{"Gold/s"}</span>
|
||||
</div>
|
||||
<div className="resource">
|
||||
<span className="resource-icon">{"⚡"}</span>
|
||||
<span className="resource-value">
|
||||
{formatNumber(essencePerSecond)}
|
||||
</span>
|
||||
<span className="resource-label">{"Essence/s"}</span>
|
||||
</div>
|
||||
<div className={`resource${essenceFull
|
||||
? " resource-full"
|
||||
: ""}`}>
|
||||
<span className="resource-icon">{"✨"}</span>
|
||||
<span className="resource-value">
|
||||
{formatNumber(essence)}
|
||||
</span>
|
||||
<span className="resource-label">{"Essence"}</span>
|
||||
{essenceFull
|
||||
? <span
|
||||
className="resource-cap-badge"
|
||||
title={resourceFullTooltip}
|
||||
>
|
||||
{"FULL"}
|
||||
</span>
|
||||
: null}
|
||||
</div>
|
||||
<div className={`resource${crystalsFull
|
||||
? " resource-full"
|
||||
: ""}`}>
|
||||
<span className="resource-icon">{"💎"}</span>
|
||||
<span className="resource-value">
|
||||
{formatNumber(crystals)}
|
||||
</span>
|
||||
<span className="resource-label">{"Crystals"}</span>
|
||||
{crystalsFull
|
||||
? <span
|
||||
className="resource-cap-badge"
|
||||
title={resourceFullTooltip}
|
||||
>
|
||||
{"FULL"}
|
||||
</span>
|
||||
: null}
|
||||
</div>
|
||||
<div className="resource">
|
||||
<span className="resource-icon">{"🔮"}</span>
|
||||
<span className="resource-value">
|
||||
{formatNumber(runestones)}
|
||||
</span>
|
||||
<span className="resource-label">{"Runestones"}</span>
|
||||
</div>
|
||||
<div className="resource">
|
||||
<span className="resource-icon">{"⭐"}</span>
|
||||
<span className="resource-value">
|
||||
{`+${formatNumber(projectedRunestones)}`}
|
||||
</span>
|
||||
<span className="resource-label">{"On Prestige"}</span>
|
||||
</div>
|
||||
<div className="resource">
|
||||
<span className="resource-icon">{"⚔️"}</span>
|
||||
<span className="resource-value">
|
||||
{formatNumber(partyCombatPower)}
|
||||
</span>
|
||||
<span className="resource-label">{"Combat Power"}</span>
|
||||
</div>
|
||||
</div>
|
||||
: null}
|
||||
</div>
|
||||
<div className={`resource${essenceFull
|
||||
? " resource-full"
|
||||
: ""}`}>
|
||||
<span className="resource-icon">{"✨"}</span>
|
||||
<span className="resource-value">{formatNumber(essence)}</span>
|
||||
<span className="resource-label">{"Essence"}</span>
|
||||
{essenceFull
|
||||
? <span className="resource-cap-badge" title={resourceFullTooltip}>
|
||||
{"FULL"}
|
||||
</span>
|
||||
: null}
|
||||
</div>
|
||||
<div className={`resource${crystalsFull
|
||||
? " resource-full"
|
||||
: ""}`}>
|
||||
<span className="resource-icon">{"💎"}</span>
|
||||
<span className="resource-value">{formatNumber(crystals)}</span>
|
||||
<span className="resource-label">{"Crystals"}</span>
|
||||
{crystalsFull
|
||||
? <span className="resource-cap-badge" title={resourceFullTooltip}>
|
||||
{"FULL"}
|
||||
</span>
|
||||
: null}
|
||||
</div>
|
||||
<div className="resource">
|
||||
<span className="resource-icon">{"🔮"}</span>
|
||||
<span className="resource-value">{formatNumber(runestones)}</span>
|
||||
<span className="resource-label">{"Runestones"}</span>
|
||||
</div>
|
||||
{apotheosisCount > 0
|
||||
&& <div className="apotheosis-badge">
|
||||
{"✨ Apotheosis "}
|
||||
@@ -153,34 +272,7 @@ const ResourceBar = ({
|
||||
{prestigeCount}
|
||||
</div>
|
||||
}
|
||||
<div className="profile-buttons">
|
||||
<a
|
||||
className="profile-link-button"
|
||||
href="https://donate.nhcarrigan.com"
|
||||
rel="noreferrer"
|
||||
target="_blank"
|
||||
title="Support the developer"
|
||||
>
|
||||
{"💜"} <span className="btn-label">{"Donate"}</span>
|
||||
</a>
|
||||
<a
|
||||
className="profile-link-button"
|
||||
href="https://chat.nhcarrigan.com"
|
||||
rel="noreferrer"
|
||||
target="_blank"
|
||||
title="Join our Discord"
|
||||
>
|
||||
{"💬"} <span className="btn-label">{"Discord"}</span>
|
||||
</a>
|
||||
<a
|
||||
className="profile-link-button"
|
||||
href="https://support.nhcarrigan.com"
|
||||
rel="noreferrer"
|
||||
target="_blank"
|
||||
title="Get support on our forum"
|
||||
>
|
||||
{"🆘"} <span className="btn-label">{"Support"}</span>
|
||||
</a>
|
||||
<div className="resource-bar-actions">
|
||||
{syncError === null
|
||||
? null
|
||||
: <span className="save-status save-error" title={syncError}>
|
||||
@@ -207,23 +299,69 @@ const ResourceBar = ({
|
||||
? "⏳"
|
||||
: "💾"}
|
||||
</button>
|
||||
<a
|
||||
className="profile-link-button"
|
||||
href={profileUrl}
|
||||
rel="noreferrer"
|
||||
target="_blank"
|
||||
title="View your public profile"
|
||||
>
|
||||
{"👤"} <span className="btn-label">{"Profile"}</span>
|
||||
</a>
|
||||
<button
|
||||
className="profile-edit-button"
|
||||
onClick={onEditProfile}
|
||||
title="Edit your profile"
|
||||
type="button"
|
||||
>
|
||||
{"✏️"}
|
||||
</button>
|
||||
{avatarUrl === null
|
||||
? null
|
||||
: <div
|
||||
className="profile-menu"
|
||||
onBlur={handleProfileBlur}
|
||||
>
|
||||
<button
|
||||
className="profile-avatar-button"
|
||||
onClick={handleToggleProfile}
|
||||
title="Account"
|
||||
type="button"
|
||||
>
|
||||
<img
|
||||
alt="Profile"
|
||||
className="profile-avatar-img"
|
||||
src={avatarUrl}
|
||||
/>
|
||||
</button>
|
||||
{isProfileOpen
|
||||
? <div className="profile-dropdown">
|
||||
<a
|
||||
className="profile-dropdown-item"
|
||||
href={profileUrl}
|
||||
rel="noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
{"👤 View Profile"}
|
||||
</a>
|
||||
<button
|
||||
className="profile-dropdown-item"
|
||||
onClick={handleEditProfile}
|
||||
type="button"
|
||||
>
|
||||
{"✏️ Edit Profile"}
|
||||
</button>
|
||||
<hr className="profile-dropdown-divider" />
|
||||
<a
|
||||
className="profile-dropdown-item"
|
||||
href="https://donate.nhcarrigan.com"
|
||||
rel="noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
{"💜 Donate"}
|
||||
</a>
|
||||
<a
|
||||
className="profile-dropdown-item"
|
||||
href="https://chat.nhcarrigan.com"
|
||||
rel="noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
{"💬 Discord"}
|
||||
</a>
|
||||
<a
|
||||
className="profile-dropdown-item"
|
||||
href="https://support.nhcarrigan.com"
|
||||
rel="noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
{"🆘 Support"}
|
||||
</a>
|
||||
</div>
|
||||
: null}
|
||||
</div>}
|
||||
</div>
|
||||
</header>
|
||||
{anyFull
|
||||
|
||||
@@ -42,6 +42,9 @@ import {
|
||||
challengeBoss as challengeBossApi,
|
||||
collectExploration as collectExplorationApi,
|
||||
craftRecipe as craftRecipeApi,
|
||||
debugHardReset as debugHardResetApi,
|
||||
forceUnlocks as forceUnlocksApi,
|
||||
syncNewContent as syncNewContentApi,
|
||||
loadGame,
|
||||
prestige as prestigeApi,
|
||||
resetProgress as resetProgressApi,
|
||||
@@ -56,6 +59,7 @@ import {
|
||||
RESOURCE_CAP,
|
||||
applyTick,
|
||||
calculateClickPower,
|
||||
computePartyCombatPower,
|
||||
} from "../engine/tick.js";
|
||||
import { updateChallengeProgress } from "../utils/dailyChallenges.js";
|
||||
import { formatNumber as formatNumberUtil } from "../utils/format.js";
|
||||
@@ -113,6 +117,9 @@ const applyBossResult = (
|
||||
}).
|
||||
filter(Boolean),
|
||||
);
|
||||
const newlyUnlockedZoneIds = new Set(unlockedZones.map((z) => {
|
||||
return z.id;
|
||||
}));
|
||||
|
||||
const challengeUpdate
|
||||
= previous.dailyChallenges === undefined
|
||||
@@ -213,6 +220,23 @@ const applyBossResult = (
|
||||
? { ...u, unlocked: true }
|
||||
: u;
|
||||
}),
|
||||
...newlyUnlockedZoneIds.size === 0 || previous.exploration === undefined
|
||||
? {}
|
||||
: {
|
||||
exploration: {
|
||||
...previous.exploration,
|
||||
areas: previous.exploration.areas.map((area) => {
|
||||
const areaDefinition = EXPLORATION_AREAS.find((definition) => {
|
||||
return definition.id === area.id;
|
||||
});
|
||||
return areaDefinition !== undefined
|
||||
&& newlyUnlockedZoneIds.has(areaDefinition.zoneId)
|
||||
&& area.status === "locked"
|
||||
? { ...area, status: "available" as const }
|
||||
: area;
|
||||
}),
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -241,6 +265,11 @@ interface GameContextValue {
|
||||
isLoading: boolean;
|
||||
error: string | null;
|
||||
|
||||
/**
|
||||
* Whether the player is currently a member of the NHCarrigan Discord server.
|
||||
*/
|
||||
inGuild: boolean;
|
||||
|
||||
/**
|
||||
* Click the crystal to earn gold.
|
||||
*/
|
||||
@@ -281,6 +310,12 @@ interface GameContextValue {
|
||||
*/
|
||||
reload: ()=> Promise<void>;
|
||||
|
||||
/**
|
||||
* Reload state from the server without showing the loading screen (used
|
||||
* after prestige to avoid the visible flash/hang).
|
||||
*/
|
||||
reloadSilent: ()=> Promise<void>;
|
||||
|
||||
/**
|
||||
* Unix timestamp of the last successful cloud save (null until first save response).
|
||||
*/
|
||||
@@ -446,6 +481,11 @@ interface GameContextValue {
|
||||
*/
|
||||
toggleAutoBoss: ()=> void;
|
||||
|
||||
/**
|
||||
* Toggle the auto-adventurer setting on/off (requires auto_adventurer prestige upgrade).
|
||||
*/
|
||||
toggleAutoAdventurer: ()=> void;
|
||||
|
||||
/**
|
||||
* Queue of newly unlocked codex entry IDs (for toast notifications).
|
||||
*/
|
||||
@@ -546,6 +586,53 @@ interface GameContextValue {
|
||||
*/
|
||||
resetProgress: ()=> Promise<void>;
|
||||
|
||||
/**
|
||||
* Force-unlock any zones, quests, and bosses the player has earned but that
|
||||
* are still incorrectly locked due to a state bug.
|
||||
* @returns Counts of what was corrected.
|
||||
*/
|
||||
forceUnlocks: ()=> Promise<{
|
||||
adventurersUnlocked: number;
|
||||
bossesUnlocked: number;
|
||||
equipmentUnlocked: number;
|
||||
explorationUnlocked: number;
|
||||
questsUnlocked: number;
|
||||
storyUnlocked: number;
|
||||
upgradesUnlocked: number;
|
||||
zonesUnlocked: number;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* Completely wipe the player's progress back to a brand-new save via the
|
||||
* debug endpoint.
|
||||
*/
|
||||
debugHardReset: ()=> Promise<void>;
|
||||
|
||||
/**
|
||||
* Syncs any content added to the game after the player's save was created.
|
||||
* @returns Counts of what was added per content type.
|
||||
*/
|
||||
syncNewContent: ()=> Promise<{
|
||||
achievementsAdded: number;
|
||||
achievementsPatched: number;
|
||||
adventurerStatsPatched: number;
|
||||
adventurersAdded: number;
|
||||
bossRewardsPatched: number;
|
||||
bossesAdded: number;
|
||||
bossesPatched: number;
|
||||
craftingRecipesReapplied: number;
|
||||
equipmentAdded: number;
|
||||
equipmentPatched: number;
|
||||
explorationAreasAdded: number;
|
||||
questRewardsPatched: number;
|
||||
questsAdded: number;
|
||||
questsPatched: number;
|
||||
upgradesAdded: number;
|
||||
upgradesPatched: number;
|
||||
zonesAdded: number;
|
||||
zonesPatched: number;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* Last auto-boss fight result — null until the first auto fight completes or
|
||||
* when auto-boss is toggled off.
|
||||
@@ -557,6 +644,12 @@ interface GameContextValue {
|
||||
* when no error). Cleared automatically when the player re-enables auto-boss.
|
||||
*/
|
||||
autoBossError: string | null;
|
||||
|
||||
/**
|
||||
* Error message from the most recent manual boss challenge (null when no
|
||||
* error). Cleared automatically when a new challenge is initiated.
|
||||
*/
|
||||
bossError: string | null;
|
||||
}
|
||||
|
||||
export interface BattleResult {
|
||||
@@ -606,6 +699,7 @@ export const GameProvider = ({
|
||||
at: number;
|
||||
} | null>(null);
|
||||
const [ autoBossError, setAutoBossError ] = useState<string | null>(null);
|
||||
const [ bossError, setBossError ] = useState<string | null>(null);
|
||||
const syncErrorTimerReference = useRef<ReturnType<typeof setTimeout> | null>(
|
||||
null,
|
||||
);
|
||||
@@ -630,9 +724,14 @@ export const GameProvider = ({
|
||||
|
||||
/* No-op placeholder */
|
||||
});
|
||||
const reloadSilentReference = useRef<()=> Promise<void>>(async() => {
|
||||
|
||||
/* No-op placeholder */
|
||||
});
|
||||
const [ schemaOutdated, setSchemaOutdated ] = useState(false);
|
||||
const [ saveSchemaVersion, setSaveSchemaVersion ] = useState(0);
|
||||
const [ currentSchemaVersion, setCurrentSchemaVersion ] = useState(0);
|
||||
const [ inGuild, setInGuild ] = useState(false);
|
||||
const [ unlockedCodexEntryIds, setUnlockedCodexEntryIds ] = useState<
|
||||
Array<string>
|
||||
>([]);
|
||||
@@ -670,6 +769,7 @@ export const GameProvider = ({
|
||||
setSchemaOutdated(data.schemaOutdated);
|
||||
setSaveSchemaVersion(data.state.schemaVersion ?? 0);
|
||||
setCurrentSchemaVersion(data.currentSchemaVersion);
|
||||
setInGuild(data.inGuild);
|
||||
|
||||
// Fetch number format preference from profile (fire-and-forget, non-blocking)
|
||||
void fetch(`/api/profile/${data.state.player.discordId}`).
|
||||
@@ -715,6 +815,32 @@ export const GameProvider = ({
|
||||
|
||||
reloadReference.current = reload;
|
||||
|
||||
const reloadSilent = useCallback(async() => {
|
||||
setError(null);
|
||||
try {
|
||||
const data = await loadGame();
|
||||
setState(data.state);
|
||||
setLastSavedAt(data.state.player.lastSavedAt);
|
||||
if (data.signature !== undefined) {
|
||||
signatureReference.current = data.signature;
|
||||
localStorage.setItem("elysium_save_signature", data.signature);
|
||||
}
|
||||
setLoginStreak(data.loginStreak);
|
||||
setSchemaOutdated(data.schemaOutdated);
|
||||
setSaveSchemaVersion(data.state.schemaVersion ?? 0);
|
||||
setCurrentSchemaVersion(data.currentSchemaVersion);
|
||||
setInGuild(data.inGuild);
|
||||
} catch (error_: unknown) {
|
||||
setError(
|
||||
error_ instanceof Error
|
||||
? error_.message
|
||||
: "Failed to load game",
|
||||
);
|
||||
}
|
||||
}, []);
|
||||
|
||||
reloadSilentReference.current = reloadSilent;
|
||||
|
||||
useEffect(() => {
|
||||
enableSoundsReference.current = enableSounds;
|
||||
}, [ enableSounds ]);
|
||||
@@ -1010,11 +1136,7 @@ export const GameProvider = ({
|
||||
return q.status === "active";
|
||||
});
|
||||
if (!hasActiveQuest) {
|
||||
// eslint-disable-next-line unicorn/no-array-reduce -- Need the total!
|
||||
const partyCombatPower = next.adventurers.reduce((total, a) => {
|
||||
const power = total + a.combatPower;
|
||||
return power * a.count;
|
||||
}, 0);
|
||||
const partyCombatPower = computePartyCombatPower(next);
|
||||
const zoneOrder = new Map(
|
||||
next.zones.map((z, index) => {
|
||||
return [ z.id, index ];
|
||||
@@ -1047,6 +1169,55 @@ export const GameProvider = ({
|
||||
}
|
||||
}
|
||||
|
||||
// Auto-adventurer: buy one of the highest-tier affordable unlocked adventurer per tick
|
||||
if (
|
||||
next.autoAdventurer === true
|
||||
&& next.prestige.purchasedUpgradeIds.includes("auto_adventurer")
|
||||
) {
|
||||
const maxAdventurerLevel = Math.max(
|
||||
...next.adventurers.
|
||||
filter((a) => {
|
||||
return a.unlocked;
|
||||
}).
|
||||
map((a) => {
|
||||
return a.level;
|
||||
}),
|
||||
);
|
||||
const autoBuyCap = 100;
|
||||
const [ bestAdventurer ] = next.adventurers.
|
||||
filter((adventurer) => {
|
||||
const cost
|
||||
= adventurer.baseCost * Math.pow(1.15, adventurer.count);
|
||||
const isMaxTier = adventurer.level === maxAdventurerLevel;
|
||||
const withinCap
|
||||
= isMaxTier || adventurer.count < autoBuyCap;
|
||||
return (
|
||||
adventurer.unlocked
|
||||
&& next.resources.gold >= cost
|
||||
&& withinCap
|
||||
);
|
||||
}).
|
||||
sort((adventurerA, adventurerB) => {
|
||||
return adventurerB.level - adventurerA.level;
|
||||
});
|
||||
if (bestAdventurer !== undefined) {
|
||||
const purchaseCost
|
||||
= bestAdventurer.baseCost * Math.pow(1.15, bestAdventurer.count);
|
||||
next = {
|
||||
...next,
|
||||
adventurers: next.adventurers.map((adventurer) => {
|
||||
return adventurer.id === bestAdventurer.id
|
||||
? { ...adventurer, count: adventurer.count + 1 }
|
||||
: adventurer;
|
||||
}),
|
||||
resources: {
|
||||
...next.resources,
|
||||
gold: next.resources.gold - purchaseCost,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Detect newly unlocked achievements
|
||||
unlockedAchievementsReference.current = next.achievements.filter(
|
||||
(a, index) => {
|
||||
@@ -1077,14 +1248,6 @@ export const GameProvider = ({
|
||||
},
|
||||
);
|
||||
|
||||
// Quest failure — turn off auto-quest so the player can reassess
|
||||
if (
|
||||
newlyFailedQuestsReference.current.length > 0
|
||||
&& next.autoQuest === true
|
||||
) {
|
||||
next = { ...next, autoQuest: false };
|
||||
}
|
||||
|
||||
return next;
|
||||
});
|
||||
|
||||
@@ -1157,9 +1320,12 @@ export const GameProvider = ({
|
||||
) {
|
||||
signatureReference.current = null;
|
||||
localStorage.removeItem("elysium_save_signature");
|
||||
} else {
|
||||
logError("auto_save", error_);
|
||||
}
|
||||
|
||||
/*
|
||||
* Network failures during background auto-save are expected on
|
||||
* flaky connections — the next tick will retry, so no telemetry needed
|
||||
*/
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1185,12 +1351,11 @@ export const GameProvider = ({
|
||||
if (enableNotificationsReference.current) {
|
||||
sendNotification("⭐ Prestige!", "You have ascended!");
|
||||
}
|
||||
await reloadReference.current();
|
||||
await reloadSilentReference.current();
|
||||
}).
|
||||
catch((error_: unknown) => {
|
||||
logError("auto_prestige", error_);
|
||||
catch(() => {
|
||||
|
||||
/* Silently ignore — will retry next tick */
|
||||
/* Silently ignore — eligibility is re-checked every tick */
|
||||
}).
|
||||
finally(() => {
|
||||
isAutoPrestigingReference.current = false;
|
||||
@@ -1220,7 +1385,26 @@ export const GameProvider = ({
|
||||
if (availableBoss !== undefined) {
|
||||
const { id: bossId, name: bossName } = availableBoss;
|
||||
isAutoBossingReference.current = true;
|
||||
void challengeBossApi({ bossId }).
|
||||
const syncBeforeBoss
|
||||
= stateReference.current !== null && !isSyncingReference.current
|
||||
? saveGame({
|
||||
state: stateReference.current,
|
||||
...signatureReference.current === null
|
||||
? {}
|
||||
: { signature: signatureReference.current },
|
||||
}).then((response) => {
|
||||
if (response.signature !== undefined) {
|
||||
signatureReference.current = response.signature;
|
||||
localStorage.setItem(
|
||||
"elysium_save_signature",
|
||||
response.signature,
|
||||
);
|
||||
}
|
||||
})
|
||||
: Promise.resolve();
|
||||
void syncBeforeBoss.then(async() => {
|
||||
return await challengeBossApi({ bossId });
|
||||
}).
|
||||
then((result) => {
|
||||
setState((previous) => {
|
||||
if (previous === null) {
|
||||
@@ -1233,6 +1417,13 @@ export const GameProvider = ({
|
||||
}
|
||||
return afterBoss;
|
||||
});
|
||||
|
||||
/*
|
||||
* Boss fight modifies server state; clear stale signature so
|
||||
* the next pre-save or auto-save does not send a mismatched one.
|
||||
*/
|
||||
signatureReference.current = null;
|
||||
localStorage.removeItem("elysium_save_signature");
|
||||
setAutoBossLastResult({
|
||||
at: Date.now(),
|
||||
bossName: bossName,
|
||||
@@ -1240,11 +1431,20 @@ export const GameProvider = ({
|
||||
});
|
||||
}).
|
||||
catch((error_: unknown) => {
|
||||
logError("auto_boss", error_);
|
||||
const message
|
||||
= error_ instanceof Error
|
||||
? error_.message
|
||||
: String(error_);
|
||||
|
||||
/*
|
||||
* "Boss is not currently available" is an expected race condition
|
||||
* when the client is ahead of the server save — silently skip and
|
||||
* let the next tick retry rather than halting automation.
|
||||
*/
|
||||
if (message === "Boss is not currently available") {
|
||||
return;
|
||||
}
|
||||
logError("auto_boss", error_);
|
||||
setAutoBossError(message);
|
||||
setState((previous) => {
|
||||
if (previous === null) {
|
||||
@@ -1642,118 +1842,115 @@ export const GameProvider = ({
|
||||
}, []);
|
||||
|
||||
const startExploration = useCallback(async(areaId: string) => {
|
||||
try {
|
||||
const response = await startExplorationApi({ areaId });
|
||||
const areaData = EXPLORATION_AREAS.find((a) => {
|
||||
return a.id === areaId;
|
||||
});
|
||||
if (areaData === undefined) {
|
||||
return;
|
||||
const response = await startExplorationApi({ areaId });
|
||||
setState((previous) => {
|
||||
if (previous?.exploration === undefined) {
|
||||
return previous;
|
||||
}
|
||||
// eslint-disable-next-line stylistic/no-mixed-operators -- duration * 1000 is clear
|
||||
const startedAt = response.endsAt - areaData.durationSeconds * 1000;
|
||||
return {
|
||||
...previous,
|
||||
exploration: {
|
||||
...previous.exploration,
|
||||
areas: previous.exploration.areas.map((a) => {
|
||||
return a.id === areaId
|
||||
? {
|
||||
...a,
|
||||
endsAt: response.endsAt,
|
||||
status: "in_progress" as const,
|
||||
}
|
||||
: a;
|
||||
}),
|
||||
},
|
||||
};
|
||||
});
|
||||
}, []);
|
||||
|
||||
const collectExploration = useCallback(
|
||||
async(areaId: string): Promise<ExploreCollectResponse> => {
|
||||
isSyncingReference.current = true;
|
||||
const result = await collectExplorationApi({ areaId });
|
||||
|
||||
/*
|
||||
* Collect mutates server state outside the normal save flow — clear the
|
||||
* stale HMAC signature and reset the timer so the next auto-save fires
|
||||
* after React has re-rendered with the new materials in stateReference.
|
||||
*/
|
||||
signatureReference.current = null;
|
||||
localStorage.removeItem("elysium_save_signature");
|
||||
lastSaveReference.current = Date.now();
|
||||
isSyncingReference.current = false;
|
||||
setState((previous) => {
|
||||
if (previous?.exploration === undefined) {
|
||||
return previous;
|
||||
}
|
||||
let materials = [ ...previous.exploration.materials ];
|
||||
|
||||
// Apply material drops from the random loot roll
|
||||
for (const drop of result.materialsFound) {
|
||||
const existing = materials.find((mat) => {
|
||||
return mat.materialId === drop.materialId;
|
||||
});
|
||||
if (existing === undefined) {
|
||||
materials = [
|
||||
...materials,
|
||||
{ materialId: drop.materialId, quantity: drop.quantity },
|
||||
];
|
||||
} else {
|
||||
materials = materials.map((mat) => {
|
||||
return mat.materialId === drop.materialId
|
||||
? { ...mat, quantity: mat.quantity + drop.quantity }
|
||||
: mat;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Apply material from event (if any)
|
||||
const materialGained = result.event?.materialGained;
|
||||
if (materialGained !== null && materialGained !== undefined) {
|
||||
const { materialId, quantity } = materialGained;
|
||||
const existing = materials.find((mat) => {
|
||||
return mat.materialId === materialId;
|
||||
});
|
||||
if (existing === undefined) {
|
||||
materials = [ ...materials, { materialId, quantity } ];
|
||||
} else {
|
||||
materials = materials.map((mat) => {
|
||||
return mat.materialId === materialId
|
||||
? { ...mat, quantity: mat.quantity + quantity }
|
||||
: mat;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
...previous,
|
||||
exploration: {
|
||||
...previous.exploration,
|
||||
areas: previous.exploration.areas.map((a) => {
|
||||
return a.id === areaId
|
||||
? { ...a, startedAt: startedAt, status: "in_progress" as const }
|
||||
? { ...a, completedOnce: true, status: "available" as const }
|
||||
: a;
|
||||
}),
|
||||
materials: materials,
|
||||
},
|
||||
player: {
|
||||
...previous.player,
|
||||
totalGoldEarned:
|
||||
previous.player.totalGoldEarned
|
||||
+ Math.max(0, result.event?.goldChange ?? 0),
|
||||
},
|
||||
resources: {
|
||||
...previous.resources,
|
||||
essence:
|
||||
previous.resources.essence + (result.event?.essenceChange ?? 0),
|
||||
gold: Math.max(
|
||||
0,
|
||||
previous.resources.gold + (result.event?.goldChange ?? 0),
|
||||
),
|
||||
},
|
||||
};
|
||||
});
|
||||
} catch (error_: unknown) {
|
||||
logError("start_exploration", error_);
|
||||
throw error_;
|
||||
}
|
||||
}, []);
|
||||
|
||||
const collectExploration = useCallback(
|
||||
async(areaId: string): Promise<ExploreCollectResponse> => {
|
||||
try {
|
||||
const result = await collectExplorationApi({ areaId });
|
||||
setState((previous) => {
|
||||
if (previous?.exploration === undefined) {
|
||||
return previous;
|
||||
}
|
||||
let materials = [ ...previous.exploration.materials ];
|
||||
|
||||
// Apply material drops from the random loot roll
|
||||
for (const drop of result.materialsFound) {
|
||||
const existing = materials.find((mat) => {
|
||||
return mat.materialId === drop.materialId;
|
||||
});
|
||||
if (existing === undefined) {
|
||||
materials = [
|
||||
...materials,
|
||||
{ materialId: drop.materialId, quantity: drop.quantity },
|
||||
];
|
||||
} else {
|
||||
materials = materials.map((mat) => {
|
||||
return mat.materialId === drop.materialId
|
||||
? { ...mat, quantity: mat.quantity + drop.quantity }
|
||||
: mat;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Apply material from event (if any)
|
||||
const materialGained = result.event?.materialGained;
|
||||
if (materialGained !== null && materialGained !== undefined) {
|
||||
const { materialId, quantity } = materialGained;
|
||||
const existing = materials.find((mat) => {
|
||||
return mat.materialId === materialId;
|
||||
});
|
||||
if (existing === undefined) {
|
||||
materials = [ ...materials, { materialId, quantity } ];
|
||||
} else {
|
||||
materials = materials.map((mat) => {
|
||||
return mat.materialId === materialId
|
||||
? { ...mat, quantity: mat.quantity + quantity }
|
||||
: mat;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
...previous,
|
||||
exploration: {
|
||||
...previous.exploration,
|
||||
areas: previous.exploration.areas.map((a) => {
|
||||
return a.id === areaId
|
||||
? { ...a, completedOnce: true, status: "available" as const }
|
||||
: a;
|
||||
}),
|
||||
materials: materials,
|
||||
},
|
||||
player: {
|
||||
...previous.player,
|
||||
totalGoldEarned:
|
||||
previous.player.totalGoldEarned
|
||||
+ Math.max(0, result.event?.goldChange ?? 0),
|
||||
},
|
||||
resources: {
|
||||
...previous.resources,
|
||||
essence:
|
||||
previous.resources.essence + (result.event?.essenceChange ?? 0),
|
||||
gold: Math.max(
|
||||
0,
|
||||
previous.resources.gold + (result.event?.goldChange ?? 0),
|
||||
),
|
||||
},
|
||||
};
|
||||
});
|
||||
return result;
|
||||
} catch (error_: unknown) {
|
||||
logError("collect_exploration", error_);
|
||||
throw error_;
|
||||
}
|
||||
return result;
|
||||
},
|
||||
[],
|
||||
);
|
||||
@@ -1771,14 +1968,6 @@ export const GameProvider = ({
|
||||
if (previous?.exploration === undefined) {
|
||||
return previous;
|
||||
}
|
||||
let materials = [ ...previous.exploration.materials ];
|
||||
for (const request of recipe.requiredMaterials) {
|
||||
materials = materials.map((mat) => {
|
||||
return mat.materialId === request.materialId
|
||||
? { ...mat, quantity: mat.quantity - request.quantity }
|
||||
: mat;
|
||||
});
|
||||
}
|
||||
return {
|
||||
...previous,
|
||||
exploration: {
|
||||
@@ -1791,7 +1980,7 @@ export const GameProvider = ({
|
||||
...previous.exploration.craftedRecipeIds,
|
||||
recipeId,
|
||||
],
|
||||
materials: materials,
|
||||
materials: result.materials,
|
||||
},
|
||||
};
|
||||
});
|
||||
@@ -1836,6 +2025,18 @@ export const GameProvider = ({
|
||||
});
|
||||
}, []);
|
||||
|
||||
const toggleAutoAdventurer = useCallback(() => {
|
||||
setState((previous) => {
|
||||
if (previous === null) {
|
||||
return previous;
|
||||
}
|
||||
return {
|
||||
...previous,
|
||||
autoAdventurer: previous.autoAdventurer !== true,
|
||||
};
|
||||
});
|
||||
}, []);
|
||||
|
||||
const setActiveCompanion = useCallback((companionId: string | null) => {
|
||||
setState((previous) => {
|
||||
if (previous === null) {
|
||||
@@ -1867,6 +2068,14 @@ export const GameProvider = ({
|
||||
return;
|
||||
}
|
||||
|
||||
setBossError(null);
|
||||
|
||||
/*
|
||||
* Flush any pending state (e.g. newly equipped items) to the server before
|
||||
* the fight so the server-side calculation uses the player's live stats.
|
||||
*/
|
||||
await forceSync();
|
||||
|
||||
try {
|
||||
const result = await challengeBossApi({ bossId });
|
||||
setState((previous) => {
|
||||
@@ -1877,10 +2086,23 @@ export const GameProvider = ({
|
||||
});
|
||||
setBattleResult({ bossName: boss.name, result: result });
|
||||
} catch (error_: unknown) {
|
||||
logError("challenge_boss", error_);
|
||||
// Silently ignore — server errors shouldn't crash the UI
|
||||
const bossErrorMessage
|
||||
= error_ instanceof Error
|
||||
? error_.message
|
||||
: "Failed to challenge boss";
|
||||
|
||||
/*
|
||||
* "Boss is not currently available" is an expected server rejection
|
||||
* (race condition between UI state and server state) — suppress telemetry
|
||||
*/
|
||||
if (bossErrorMessage !== "Boss is not currently available") {
|
||||
logError("challenge_boss", error_);
|
||||
}
|
||||
setBossError(
|
||||
bossErrorMessage,
|
||||
);
|
||||
}
|
||||
}, []);
|
||||
}, [ forceSync ]);
|
||||
|
||||
const dismissOfflineGold = useCallback(() => {
|
||||
setOfflineGold(0);
|
||||
@@ -2006,6 +2228,126 @@ export const GameProvider = ({
|
||||
}
|
||||
}, []);
|
||||
|
||||
const forceUnlocks = useCallback(async() => {
|
||||
try {
|
||||
const data = await forceUnlocksApi();
|
||||
setState(data.state);
|
||||
if (data.signature !== undefined) {
|
||||
signatureReference.current = data.signature;
|
||||
localStorage.setItem("elysium_save_signature", data.signature);
|
||||
}
|
||||
return {
|
||||
adventurersUnlocked: data.adventurersUnlocked,
|
||||
bossesUnlocked: data.bossesUnlocked,
|
||||
equipmentUnlocked: data.equipmentUnlocked,
|
||||
explorationUnlocked: data.explorationUnlocked,
|
||||
questsUnlocked: data.questsUnlocked,
|
||||
storyUnlocked: data.storyUnlocked,
|
||||
upgradesUnlocked: data.upgradesUnlocked,
|
||||
zonesUnlocked: data.zonesUnlocked,
|
||||
};
|
||||
} catch (error_: unknown) {
|
||||
setError(
|
||||
error_ instanceof Error
|
||||
? error_.message
|
||||
: "Failed to force unlocks",
|
||||
);
|
||||
return {
|
||||
adventurersUnlocked: 0,
|
||||
bossesUnlocked: 0,
|
||||
equipmentUnlocked: 0,
|
||||
explorationUnlocked: 0,
|
||||
questsUnlocked: 0,
|
||||
storyUnlocked: 0,
|
||||
upgradesUnlocked: 0,
|
||||
zonesUnlocked: 0,
|
||||
};
|
||||
}
|
||||
}, []);
|
||||
|
||||
const syncNewContent = useCallback(async() => {
|
||||
try {
|
||||
const data = await syncNewContentApi();
|
||||
setState(data.state);
|
||||
if (data.signature !== undefined) {
|
||||
signatureReference.current = data.signature;
|
||||
localStorage.setItem("elysium_save_signature", data.signature);
|
||||
}
|
||||
return {
|
||||
achievementsAdded: data.achievementsAdded,
|
||||
achievementsPatched: data.achievementsPatched,
|
||||
adventurerStatsPatched: data.adventurerStatsPatched,
|
||||
adventurersAdded: data.adventurersAdded,
|
||||
bossRewardsPatched: data.bossRewardsPatched,
|
||||
bossesAdded: data.bossesAdded,
|
||||
bossesPatched: data.bossesPatched,
|
||||
craftingRecipesReapplied: data.craftingRecipesReapplied,
|
||||
equipmentAdded: data.equipmentAdded,
|
||||
equipmentPatched: data.equipmentPatched,
|
||||
explorationAreasAdded: data.explorationAreasAdded,
|
||||
questRewardsPatched: data.questRewardsPatched,
|
||||
questsAdded: data.questsAdded,
|
||||
questsPatched: data.questsPatched,
|
||||
upgradesAdded: data.upgradesAdded,
|
||||
upgradesPatched: data.upgradesPatched,
|
||||
zonesAdded: data.zonesAdded,
|
||||
zonesPatched: data.zonesPatched,
|
||||
};
|
||||
} catch (error_: unknown) {
|
||||
setError(
|
||||
error_ instanceof Error
|
||||
? error_.message
|
||||
: "Failed to sync new content",
|
||||
);
|
||||
return {
|
||||
achievementsAdded: 0,
|
||||
achievementsPatched: 0,
|
||||
adventurerStatsPatched: 0,
|
||||
adventurersAdded: 0,
|
||||
bossRewardsPatched: 0,
|
||||
bossesAdded: 0,
|
||||
bossesPatched: 0,
|
||||
craftingRecipesReapplied: 0,
|
||||
equipmentAdded: 0,
|
||||
equipmentPatched: 0,
|
||||
explorationAreasAdded: 0,
|
||||
questRewardsPatched: 0,
|
||||
questsAdded: 0,
|
||||
questsPatched: 0,
|
||||
upgradesAdded: 0,
|
||||
upgradesPatched: 0,
|
||||
zonesAdded: 0,
|
||||
zonesPatched: 0,
|
||||
};
|
||||
}
|
||||
}, []);
|
||||
|
||||
const debugHardReset = useCallback(async() => {
|
||||
setIsLoading(true);
|
||||
setError(null);
|
||||
try {
|
||||
const data = await debugHardResetApi();
|
||||
setState(data.state);
|
||||
setLastSavedAt(data.state.player.lastSavedAt);
|
||||
setSchemaOutdated(false);
|
||||
setOfflineGold(0);
|
||||
setOfflineEssence(0);
|
||||
setLoginBonus(null);
|
||||
if (data.signature !== undefined) {
|
||||
signatureReference.current = data.signature;
|
||||
localStorage.setItem("elysium_save_signature", data.signature);
|
||||
}
|
||||
} catch (error_: unknown) {
|
||||
setError(
|
||||
error_ instanceof Error
|
||||
? error_.message
|
||||
: "Failed to reset progress",
|
||||
);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
}, []);
|
||||
|
||||
const dismissLoginBonus = useCallback(() => {
|
||||
setLoginBonus(null);
|
||||
}, []);
|
||||
@@ -2023,6 +2365,7 @@ export const GameProvider = ({
|
||||
autoBossError,
|
||||
autoBossLastResult,
|
||||
battleResult,
|
||||
bossError,
|
||||
buyAdventurer,
|
||||
buyEchoUpgrade,
|
||||
buyEquipment,
|
||||
@@ -2034,6 +2377,7 @@ export const GameProvider = ({
|
||||
completedQuestToasts,
|
||||
craftRecipe,
|
||||
currentSchemaVersion,
|
||||
debugHardReset,
|
||||
dismissAchievement,
|
||||
dismissApotheosisToast,
|
||||
dismissBattle,
|
||||
@@ -2052,8 +2396,10 @@ export const GameProvider = ({
|
||||
failedQuestToasts,
|
||||
flushBossLoreToasts,
|
||||
forceSync,
|
||||
forceUnlocks,
|
||||
formatNumber,
|
||||
handleClick,
|
||||
inGuild,
|
||||
isLoading,
|
||||
isSyncing,
|
||||
lastSavedAt,
|
||||
@@ -2063,6 +2409,7 @@ export const GameProvider = ({
|
||||
offlineEssence,
|
||||
offlineGold,
|
||||
reload,
|
||||
reloadSilent,
|
||||
resetProgress,
|
||||
saveSchemaVersion,
|
||||
schemaOutdated,
|
||||
@@ -2077,6 +2424,8 @@ export const GameProvider = ({
|
||||
startQuest,
|
||||
state,
|
||||
syncError,
|
||||
syncNewContent,
|
||||
toggleAutoAdventurer,
|
||||
toggleAutoBoss,
|
||||
toggleAutoPrestige,
|
||||
toggleAutoQuest,
|
||||
@@ -2091,6 +2440,7 @@ export const GameProvider = ({
|
||||
autoBossError,
|
||||
autoBossLastResult,
|
||||
battleResult,
|
||||
bossError,
|
||||
completedQuestToasts,
|
||||
failedQuestToasts,
|
||||
formatNumber,
|
||||
@@ -2104,6 +2454,7 @@ export const GameProvider = ({
|
||||
completeChapter,
|
||||
craftRecipe,
|
||||
currentSchemaVersion,
|
||||
debugHardReset,
|
||||
dismissAchievement,
|
||||
dismissApotheosisToast,
|
||||
dismissBattle,
|
||||
@@ -2121,6 +2472,8 @@ export const GameProvider = ({
|
||||
error,
|
||||
flushBossLoreToasts,
|
||||
forceSync,
|
||||
inGuild,
|
||||
forceUnlocks,
|
||||
handleClick,
|
||||
isLoading,
|
||||
isSyncing,
|
||||
@@ -2145,6 +2498,8 @@ export const GameProvider = ({
|
||||
startQuest,
|
||||
state,
|
||||
syncError,
|
||||
syncNewContent,
|
||||
toggleAutoAdventurer,
|
||||
toggleAutoBoss,
|
||||
toggleAutoPrestige,
|
||||
toggleAutoQuest,
|
||||
|
||||
@@ -2752,8 +2752,8 @@ export const CODEX_ENTRIES: Array<CodexEntry> = [
|
||||
{
|
||||
content:
|
||||
"The ancient books of magic acquired for the guild's mages contained techniques that their trainers had either not known or had chosen not to teach. The omission, in most cases, appeared to be deliberate — the techniques worked but produced results that the academies found uncomfortable to endorse. Your guild finds them extremely comfortable to have, and the mage output doubled from the application of knowledge that had been sitting in books waiting for someone to act on it.",
|
||||
id: "upgrade_mage_1",
|
||||
sourceId: "mage_1",
|
||||
id: "upgrade_apprentice_1",
|
||||
sourceId: "apprentice_1",
|
||||
sourceType: "upgrade",
|
||||
title: "Arcane Tomes: The Written Knowledge",
|
||||
zoneId: "guild_library",
|
||||
@@ -2761,8 +2761,8 @@ export const CODEX_ENTRIES: Array<CodexEntry> = [
|
||||
{
|
||||
content:
|
||||
"The sacred ceremonies that your clerics now perform before and during operations were developed by your head cleric over six months of experimentation that their deity appears to have sanctioned, based on the results. The rites formalise the relationship between divine power and operational output into a repeatable process. Doubled cleric output is the result of making the exceptional ordinary through the discipline of ceremony.",
|
||||
id: "upgrade_cleric_1",
|
||||
sourceId: "cleric_1",
|
||||
id: "upgrade_acolyte_1",
|
||||
sourceId: "acolyte_1",
|
||||
sourceType: "upgrade",
|
||||
title: "Holy Rites: The Sacred Routine",
|
||||
zoneId: "guild_library",
|
||||
|
||||
@@ -212,6 +212,15 @@ export const PRESTIGE_UPGRADES: Array<PrestigeUpgrade> = [
|
||||
runestonesCost: 1200,
|
||||
},
|
||||
// ── Utility Unlocks ───────────────────────────────────────────────────────
|
||||
{
|
||||
category: "utility",
|
||||
description:
|
||||
"Unlock the Auto-Adventurer toggle. When enabled, the tick engine will automatically purchase the highest-tier adventurer you can currently afford.",
|
||||
id: "auto_adventurer",
|
||||
multiplier: 1,
|
||||
name: "Autonomous Recruitment",
|
||||
runestonesCost: 50,
|
||||
},
|
||||
{
|
||||
category: "utility",
|
||||
description:
|
||||
|
||||
@@ -24,7 +24,7 @@ export const RECIPES: Array<CraftingRecipe> = [
|
||||
zoneId: "verdant_vale",
|
||||
},
|
||||
{
|
||||
bonus: { type: "combat_power", value: 1.08 },
|
||||
bonus: { type: "combat_power", value: 1.2 },
|
||||
description:
|
||||
"A ward fashioned from bark older than the kingdom. Its presence on the battlefield is not merely physical — something ancient watches through it.",
|
||||
id: "elder_bark_shield",
|
||||
@@ -102,7 +102,7 @@ export const RECIPES: Array<CraftingRecipe> = [
|
||||
zoneId: "shadow_marshes",
|
||||
},
|
||||
{
|
||||
bonus: { type: "combat_power", value: 1.1 },
|
||||
bonus: { type: "combat_power", value: 1.15 },
|
||||
description:
|
||||
"The cursed bone and shadow essence combined into a focus that doesn't so much help your party fight as make things afraid of them before the battle begins.",
|
||||
id: "cursed_focus",
|
||||
@@ -128,7 +128,7 @@ export const RECIPES: Array<CraftingRecipe> = [
|
||||
zoneId: "volcanic_depths",
|
||||
},
|
||||
{
|
||||
bonus: { type: "combat_power", value: 1.12 },
|
||||
bonus: { type: "combat_power", value: 1.2 },
|
||||
description:
|
||||
"The legendary ore, smelted in the volcanic forges with magma stone as fuel. What emerges is something the fire elementals recognise — and fear slightly.",
|
||||
id: "elemental_ore_ingot",
|
||||
@@ -194,7 +194,7 @@ export const RECIPES: Array<CraftingRecipe> = [
|
||||
|
||||
// Zone 8: abyssal_trench
|
||||
{
|
||||
bonus: { type: "combat_power", value: 1.15 },
|
||||
bonus: { type: "combat_power", value: 1.25 },
|
||||
description:
|
||||
"Trench coral and pressure gem combined under conditions that should have destroyed both. The result is something that survived conditions nothing should survive, which is ideal for combat.",
|
||||
id: "pressure_forged_core",
|
||||
@@ -272,7 +272,7 @@ export const RECIPES: Array<CraftingRecipe> = [
|
||||
|
||||
// Zone 11: void_sanctum
|
||||
{
|
||||
bonus: { type: "combat_power", value: 1.18 },
|
||||
bonus: { type: "combat_power", value: 1.28 },
|
||||
description:
|
||||
"Null matter and resonance fragments assembled into something that generates a field where the laws governing how hard things are to kill become negotiable.",
|
||||
id: "null_field_generator",
|
||||
@@ -310,7 +310,7 @@ export const RECIPES: Array<CraftingRecipe> = [
|
||||
zoneId: "eternal_throne",
|
||||
},
|
||||
{
|
||||
bonus: { type: "combat_power", value: 1.2 },
|
||||
bonus: { type: "combat_power", value: 1.3 },
|
||||
description:
|
||||
"An eternity splinter set into crown fragments, shaped into a ring. What it binds is unclear. Whatever it is, it makes your party significantly harder to kill.",
|
||||
id: "eternity_bound_ring",
|
||||
@@ -376,7 +376,7 @@ export const RECIPES: Array<CraftingRecipe> = [
|
||||
|
||||
// Zone 15: reality_forge
|
||||
{
|
||||
bonus: { type: "combat_power", value: 1.22 },
|
||||
bonus: { type: "combat_power", value: 1.35 },
|
||||
description:
|
||||
"Forge ash smelted with creation tools into an ingot of compressed reality. Your party hits harder when carrying it. Reality does not enjoy being concentrated like this.",
|
||||
id: "reality_ingot",
|
||||
@@ -428,7 +428,7 @@ export const RECIPES: Array<CraftingRecipe> = [
|
||||
|
||||
// Zone 17: primeval_sanctum
|
||||
{
|
||||
bonus: { type: "combat_power", value: 1.25 },
|
||||
bonus: { type: "combat_power", value: 1.4 },
|
||||
description:
|
||||
"Ancient dust and memory shards arranged into something that remembers how to fight before fighting was invented. Your party benefits from this instinct enormously.",
|
||||
id: "ancient_memory_array",
|
||||
@@ -466,7 +466,7 @@ export const RECIPES: Array<CraftingRecipe> = [
|
||||
zoneId: "the_absolute",
|
||||
},
|
||||
{
|
||||
bonus: { type: "combat_power", value: 1.3 },
|
||||
bonus: { type: "combat_power", value: 1.55 },
|
||||
description:
|
||||
"The last omega crystal, set at the convergence of boundary shards in the precise arrangement of an ending. What it does to combat is what endings do to everything: make it final.",
|
||||
id: "omega_convergence",
|
||||
|
||||
+408
-15
@@ -11,7 +11,6 @@
|
||||
/* eslint-disable max-lines -- Engine file necessarily exceeds line limit */
|
||||
/* eslint-disable import/group-exports -- Exports appear alongside their definitions for readability */
|
||||
/* eslint-disable import/exports-last -- Exports appear alongside their definitions for readability */
|
||||
/* eslint-disable unicorn/no-array-reduce -- reduce is the most readable approach for multiplier chains */
|
||||
/* eslint-disable max-nested-callbacks -- Tick engine requires nested array operations for game logic */
|
||||
import {
|
||||
type Achievement,
|
||||
@@ -21,6 +20,7 @@ import {
|
||||
getActiveCompanionBonus,
|
||||
} from "@elysium/types";
|
||||
import { EQUIPMENT_SETS } from "../data/equipmentSets.js";
|
||||
import { EXPLORATION_AREAS } from "../data/explorations.js";
|
||||
import { updateChallengeProgress } from "../utils/dailyChallenges.js";
|
||||
|
||||
/**
|
||||
@@ -83,6 +83,12 @@ const checkAchievements = (state: GameState): Array<Achievement> => {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Exponential base for the prestige combat multiplier: Math.pow(base, prestigeCount).
|
||||
* Replaces the former linear formula (1 + count * 0.1) to enable late-game zone progression.
|
||||
*/
|
||||
export const PRESTIGE_COMBAT_BASE = 4;
|
||||
|
||||
/**
|
||||
* Maximum value any resource can accumulate to. Beyond this JS floats lose all useful precision.
|
||||
*/
|
||||
@@ -93,7 +99,7 @@ export const RESOURCE_CAP = 1e300;
|
||||
* On failure the quest resets to "available" with no rewards; the player must wait the
|
||||
* full duration again on their next attempt.
|
||||
*/
|
||||
const zoneFailureChance: Record<string, number> = {
|
||||
export const zoneFailureChance: Record<string, number> = {
|
||||
abyssal_trench: 0.24,
|
||||
astral_void: 0.2,
|
||||
celestial_reaches: 0.22,
|
||||
@@ -123,6 +129,357 @@ const capResource = (value: number): number => {
|
||||
return Math.min(value, RESOURCE_CAP);
|
||||
};
|
||||
|
||||
/**
|
||||
* Pure function — applies one game tick to the state.
|
||||
* DeltaSeconds: time elapsed since last tick.
|
||||
* Returns a new GameState (does not mutate the original).
|
||||
* @param state - The current game state.
|
||||
* @param deltaSeconds - Time elapsed since last tick in seconds.
|
||||
* @returns A new GameState with the tick applied.
|
||||
*/
|
||||
/**
|
||||
* Computes the effective gold earned per second across all adventurers,
|
||||
* including all active multipliers (upgrades, prestige, equipment, etc.).
|
||||
* @param state - The current game state.
|
||||
* @returns Gold per second as a number.
|
||||
*/
|
||||
export const computeGoldPerSecond = (state: GameState): number => {
|
||||
const equippedItems: Array<Equipment> = state.equipment.filter((item) => {
|
||||
return item.equipped;
|
||||
});
|
||||
const equipmentGoldMultiplier = equippedItems.reduce((mult, item) => {
|
||||
return mult * (item.bonus.goldMultiplier ?? 1);
|
||||
}, 1);
|
||||
const setGoldMultiplier = computeSetBonuses(
|
||||
equippedItems.map((item) => {
|
||||
return item.id;
|
||||
}),
|
||||
EQUIPMENT_SETS,
|
||||
).goldMultiplier;
|
||||
|
||||
const runestonesIncome = state.prestige.runestonesIncomeMultiplier ?? 1;
|
||||
const echoIncome = state.transcendence?.echoIncomeMultiplier ?? 1;
|
||||
const craftedGoldMultiplier = state.exploration?.craftedGoldMultiplier ?? 1;
|
||||
const companionBonus = getActiveCompanionBonus(
|
||||
state.companions?.activeCompanionId,
|
||||
state.companions?.unlockedCompanionIds ?? [],
|
||||
);
|
||||
const companionGoldMult
|
||||
= companionBonus?.type === "passiveGold"
|
||||
? 1 + companionBonus.value
|
||||
: 1;
|
||||
|
||||
let goldPerSecond = 0;
|
||||
for (const adventurer of state.adventurers) {
|
||||
if (!adventurer.unlocked || adventurer.count === 0) {
|
||||
continue;
|
||||
}
|
||||
const upgradeMultiplier = state.upgrades.
|
||||
filter((upgrade) => {
|
||||
const isGlobal = upgrade.target === "global";
|
||||
const isThisAdventurer
|
||||
= upgrade.target === "adventurer"
|
||||
&& upgrade.adventurerId === adventurer.id;
|
||||
return upgrade.purchased && (isGlobal || isThisAdventurer);
|
||||
}).
|
||||
reduce((mult, upgrade) => {
|
||||
return mult * upgrade.multiplier;
|
||||
}, 1);
|
||||
const contribution
|
||||
= adventurer.goldPerSecond
|
||||
* adventurer.count
|
||||
* upgradeMultiplier
|
||||
* state.prestige.productionMultiplier
|
||||
* runestonesIncome
|
||||
* echoIncome
|
||||
* equipmentGoldMultiplier
|
||||
* setGoldMultiplier
|
||||
* craftedGoldMultiplier
|
||||
* companionGoldMult;
|
||||
goldPerSecond = goldPerSecond + contribution;
|
||||
}
|
||||
return goldPerSecond;
|
||||
};
|
||||
|
||||
/**
|
||||
* Computes the current essence per second for the given game state,
|
||||
* applying all relevant multipliers (upgrades, prestige, echo, crafted, companion).
|
||||
* @param state - The current game state.
|
||||
* @returns The total essence per second.
|
||||
*/
|
||||
export const computeEssencePerSecond = (state: GameState): number => {
|
||||
const runestonesEssence = state.prestige.runestonesEssenceMultiplier ?? 1;
|
||||
const craftedEssenceMultiplier
|
||||
= state.exploration?.craftedEssenceMultiplier ?? 1;
|
||||
const companionBonus = getActiveCompanionBonus(
|
||||
state.companions?.activeCompanionId,
|
||||
state.companions?.unlockedCompanionIds ?? [],
|
||||
);
|
||||
const companionEssenceMult
|
||||
= companionBonus?.type === "essenceIncome"
|
||||
? 1 + companionBonus.value
|
||||
: 1;
|
||||
|
||||
let essencePerSecond = 0;
|
||||
for (const adventurer of state.adventurers) {
|
||||
if (!adventurer.unlocked || adventurer.count === 0) {
|
||||
continue;
|
||||
}
|
||||
const upgradeMultiplier = state.upgrades.
|
||||
filter((upgrade) => {
|
||||
const isGlobal = upgrade.target === "global";
|
||||
const isThisAdventurer
|
||||
= upgrade.target === "adventurer"
|
||||
&& upgrade.adventurerId === adventurer.id;
|
||||
return upgrade.purchased && (isGlobal || isThisAdventurer);
|
||||
}).
|
||||
reduce((mult, upgrade) => {
|
||||
return mult * upgrade.multiplier;
|
||||
}, 1);
|
||||
const contribution
|
||||
= adventurer.essencePerSecond
|
||||
* adventurer.count
|
||||
* upgradeMultiplier
|
||||
* state.prestige.productionMultiplier
|
||||
* runestonesEssence
|
||||
* craftedEssenceMultiplier
|
||||
* companionEssenceMult;
|
||||
essencePerSecond = essencePerSecond + contribution;
|
||||
}
|
||||
return essencePerSecond;
|
||||
};
|
||||
|
||||
/**
|
||||
* Computes the effective per-unit stats for a single adventurer type,
|
||||
* applying all active multipliers (upgrades, prestige, equipment, echo,
|
||||
* crafted, companion). The returned values represent what a single
|
||||
* adventurer of this type currently contributes per second, matching the
|
||||
* per-unit contribution used by computeGoldPerSecond and
|
||||
* computeEssencePerSecond.
|
||||
* @param state - The current game state.
|
||||
* @param adventurerId - The ID of the adventurer to compute stats for.
|
||||
* @returns Effective per-unit goldPerSecond, essencePerSecond, and combatPower.
|
||||
*/
|
||||
export const computeEffectiveAdventurerStats = (
|
||||
state: GameState,
|
||||
adventurerId: string,
|
||||
): { combatPower: number; essencePerSecond: number; goldPerSecond: number } => {
|
||||
const adventurer = state.adventurers.find((a) => {
|
||||
return a.id === adventurerId;
|
||||
});
|
||||
|
||||
/* V8 ignore next 3 -- @preserve */
|
||||
if (adventurer === undefined) {
|
||||
return { combatPower: 0, essencePerSecond: 0, goldPerSecond: 0 };
|
||||
}
|
||||
|
||||
const upgradeMultiplier = state.upgrades.
|
||||
filter((upgrade) => {
|
||||
const isGlobal = upgrade.target === "global";
|
||||
const isThisAdventurer
|
||||
= upgrade.target === "adventurer"
|
||||
&& upgrade.adventurerId === adventurerId;
|
||||
return upgrade.purchased && (isGlobal || isThisAdventurer);
|
||||
}).
|
||||
reduce((mult, upgrade) => {
|
||||
return mult * upgrade.multiplier;
|
||||
}, 1);
|
||||
|
||||
const equippedItems = state.equipment.filter((item) => {
|
||||
return item.equipped;
|
||||
});
|
||||
const equipmentGoldMultiplier = equippedItems.reduce((mult, item) => {
|
||||
return mult * (item.bonus.goldMultiplier ?? 1);
|
||||
}, 1);
|
||||
const equipmentCombatMultiplier = equippedItems.reduce((mult, item) => {
|
||||
return mult * (item.bonus.combatMultiplier ?? 1);
|
||||
}, 1);
|
||||
const equippedItemIds = equippedItems.map((item) => {
|
||||
return item.id;
|
||||
});
|
||||
const setBonuses = computeSetBonuses(equippedItemIds, EQUIPMENT_SETS);
|
||||
|
||||
const runestonesIncome = state.prestige.runestonesIncomeMultiplier ?? 1;
|
||||
const runestonesEssence = state.prestige.runestonesEssenceMultiplier ?? 1;
|
||||
const prestigeCombatMultiplier = PRESTIGE_COMBAT_BASE ** state.prestige.count;
|
||||
const echoIncome = state.transcendence?.echoIncomeMultiplier ?? 1;
|
||||
const echoCombatMultiplier = state.transcendence?.echoCombatMultiplier ?? 1;
|
||||
const craftedGoldMultiplier
|
||||
= state.exploration?.craftedGoldMultiplier ?? 1;
|
||||
const craftedEssenceMultiplier
|
||||
= state.exploration?.craftedEssenceMultiplier ?? 1;
|
||||
const craftedCombatMultiplier
|
||||
= state.exploration?.craftedCombatMultiplier ?? 1;
|
||||
|
||||
const companionBonus = getActiveCompanionBonus(
|
||||
state.companions?.activeCompanionId,
|
||||
state.companions?.unlockedCompanionIds ?? [],
|
||||
);
|
||||
const companionGoldMult
|
||||
= companionBonus?.type === "passiveGold"
|
||||
? 1 + companionBonus.value
|
||||
: 1;
|
||||
const companionEssenceMult
|
||||
= companionBonus?.type === "essenceIncome"
|
||||
? 1 + companionBonus.value
|
||||
: 1;
|
||||
const companionCombatMult
|
||||
= companionBonus?.type === "bossDamage"
|
||||
? 1 + companionBonus.value
|
||||
: 1;
|
||||
|
||||
const goldPerSecond
|
||||
= adventurer.goldPerSecond
|
||||
* upgradeMultiplier
|
||||
* state.prestige.productionMultiplier
|
||||
* runestonesIncome
|
||||
* echoIncome
|
||||
* equipmentGoldMultiplier
|
||||
* setBonuses.goldMultiplier
|
||||
* craftedGoldMultiplier
|
||||
* companionGoldMult;
|
||||
|
||||
const essencePerSecond
|
||||
= adventurer.essencePerSecond
|
||||
* upgradeMultiplier
|
||||
* state.prestige.productionMultiplier
|
||||
* runestonesEssence
|
||||
* craftedEssenceMultiplier
|
||||
* companionEssenceMult;
|
||||
|
||||
const combatPower
|
||||
= adventurer.combatPower
|
||||
* upgradeMultiplier
|
||||
* prestigeCombatMultiplier
|
||||
* equipmentCombatMultiplier
|
||||
* setBonuses.combatMultiplier
|
||||
* echoCombatMultiplier
|
||||
* craftedCombatMultiplier
|
||||
* companionCombatMult;
|
||||
|
||||
return { combatPower, essencePerSecond, goldPerSecond };
|
||||
};
|
||||
|
||||
/**
|
||||
* Computes the party's total combat power, applying all active multipliers
|
||||
* (upgrades, prestige, equipment, set bonuses, echo, crafted, companion).
|
||||
* This mirrors the server-side calculatePartyStats in boss.ts and is the
|
||||
* single source of truth for all combat-power checks in the client:
|
||||
* - Displayed as "Combat Power" in the resource bar
|
||||
* - Displayed as "Party DPS" in the boss panel
|
||||
* - Used to gate quest availability
|
||||
* Note: the active companion's bossDamage bonus is intentionally included
|
||||
* here, as it applies to the full combat power calculation (boss fights and
|
||||
* quest gating alike), matching the server-side behaviour.
|
||||
* @param state - The current game state.
|
||||
* @returns The total party combat power.
|
||||
*/
|
||||
export const computePartyCombatPower = (state: GameState): number => {
|
||||
let globalMultiplier = 1;
|
||||
for (const upgrade of state.upgrades) {
|
||||
if (upgrade.purchased && upgrade.target === "global") {
|
||||
globalMultiplier = globalMultiplier * upgrade.multiplier;
|
||||
}
|
||||
}
|
||||
|
||||
const prestigeMultiplier = PRESTIGE_COMBAT_BASE ** state.prestige.count;
|
||||
|
||||
const equipmentCombatMultiplier = state.equipment.
|
||||
filter((item) => {
|
||||
return item.equipped && item.bonus.combatMultiplier !== undefined;
|
||||
}).
|
||||
reduce((mult, item) => {
|
||||
return mult * (item.bonus.combatMultiplier ?? 1);
|
||||
}, 1);
|
||||
|
||||
const equippedItemIds = state.equipment.
|
||||
filter((item) => {
|
||||
return item.equipped;
|
||||
}).
|
||||
map((item) => {
|
||||
return item.id;
|
||||
});
|
||||
const { combatMultiplier: setCombatMultiplier } = computeSetBonuses(
|
||||
equippedItemIds,
|
||||
EQUIPMENT_SETS,
|
||||
);
|
||||
|
||||
const echoCombatMultiplier
|
||||
= state.transcendence?.echoCombatMultiplier ?? 1;
|
||||
const craftedCombatMultiplier
|
||||
= state.exploration?.craftedCombatMultiplier ?? 1;
|
||||
|
||||
const companionBonus = getActiveCompanionBonus(
|
||||
state.companions?.activeCompanionId,
|
||||
state.companions?.unlockedCompanionIds ?? [],
|
||||
);
|
||||
const companionCombatMult
|
||||
= companionBonus?.type === "bossDamage"
|
||||
? 1 + companionBonus.value
|
||||
: 1;
|
||||
|
||||
let partyCombatPower = 0;
|
||||
for (const adventurer of state.adventurers) {
|
||||
if (adventurer.count === 0) {
|
||||
continue;
|
||||
}
|
||||
let adventurerMultiplier = 1;
|
||||
for (const upgrade of state.upgrades) {
|
||||
if (
|
||||
upgrade.purchased
|
||||
&& upgrade.target === "adventurer"
|
||||
&& upgrade.adventurerId === adventurer.id
|
||||
) {
|
||||
adventurerMultiplier = adventurerMultiplier * upgrade.multiplier;
|
||||
}
|
||||
}
|
||||
const contribution
|
||||
= adventurer.combatPower
|
||||
* adventurer.count
|
||||
* adventurerMultiplier
|
||||
* globalMultiplier
|
||||
* prestigeMultiplier;
|
||||
partyCombatPower = partyCombatPower + contribution;
|
||||
}
|
||||
|
||||
return partyCombatPower
|
||||
* equipmentCombatMultiplier
|
||||
* setCombatMultiplier
|
||||
* echoCombatMultiplier
|
||||
* craftedCombatMultiplier
|
||||
* companionCombatMult;
|
||||
};
|
||||
|
||||
const basePrestigeThreshold = 1_000_000;
|
||||
const runestonesPerPrestigeLevelClient = 15;
|
||||
const maxBaseRunestones = 200;
|
||||
|
||||
/**
|
||||
* Computes the projected runestone reward if the player were to prestige right now.
|
||||
* Mirrors the server-side calculateRunestones formula exactly.
|
||||
* @param state - The current game state.
|
||||
* @returns The number of runestones the player would earn from a prestige now.
|
||||
*/
|
||||
export const computeProjectedRunestones = (state: GameState): number => {
|
||||
const { count, purchasedUpgradeIds } = state.prestige;
|
||||
const threshold = basePrestigeThreshold * Math.pow(count + 1, 2);
|
||||
const base = Math.min(
|
||||
Math.floor(Math.cbrt(state.player.totalGoldEarned / threshold))
|
||||
* runestonesPerPrestigeLevelClient,
|
||||
maxBaseRunestones,
|
||||
);
|
||||
const gain1Mult = purchasedUpgradeIds.includes("runestone_gain_1")
|
||||
? 1.25
|
||||
: 1;
|
||||
const gain2Mult = purchasedUpgradeIds.includes("runestone_gain_2")
|
||||
? 1.5
|
||||
: 1;
|
||||
const runestoneMult = gain1Mult * gain2Mult;
|
||||
const echoMult: number
|
||||
= state.transcendence?.echoPrestigeRunestoneMultiplier ?? 1;
|
||||
return Math.floor(base * runestoneMult * echoMult);
|
||||
};
|
||||
|
||||
/**
|
||||
* Pure function — applies one game tick to the state.
|
||||
* DeltaSeconds: time elapsed since last tick.
|
||||
@@ -397,6 +754,19 @@ export const applyTick = (
|
||||
challengeCrystals = result.crystalsAwarded;
|
||||
}
|
||||
|
||||
// Auto-unlock adventurer-specific upgrades when their adventurer is recruited
|
||||
updatedUpgrades = updatedUpgrades.map((upgrade) => {
|
||||
if (upgrade.unlocked || upgrade.adventurerId === undefined) {
|
||||
return upgrade;
|
||||
}
|
||||
const adventurer = updatedAdventurers.find((a) => {
|
||||
return a.id === upgrade.adventurerId;
|
||||
});
|
||||
return adventurer !== undefined && adventurer.count > 0
|
||||
? { ...upgrade, unlocked: true }
|
||||
: upgrade;
|
||||
});
|
||||
|
||||
const goldValue = capResource(state.resources.gold + goldGained + questGold);
|
||||
const essenceValue = capResource(
|
||||
state.resources.essence + essenceGained + questEssence,
|
||||
@@ -417,6 +787,23 @@ export const applyTick = (
|
||||
...updatedDailyChallenges === undefined
|
||||
? {}
|
||||
: { dailyChallenges: updatedDailyChallenges },
|
||||
...newlyUnlockedZoneIds.size === 0 || state.exploration === undefined
|
||||
? {}
|
||||
: {
|
||||
exploration: {
|
||||
...state.exploration,
|
||||
areas: state.exploration.areas.map((area) => {
|
||||
const areaDefinition = EXPLORATION_AREAS.find((definition) => {
|
||||
return definition.id === area.id;
|
||||
});
|
||||
return areaDefinition !== undefined
|
||||
&& newlyUnlockedZoneIds.has(areaDefinition.zoneId)
|
||||
&& area.status === "locked"
|
||||
? { ...area, status: "available" as const }
|
||||
: area;
|
||||
}),
|
||||
},
|
||||
},
|
||||
adventurers: updatedAdventurers,
|
||||
bosses: updatedBosses,
|
||||
equipment: updatedEquipmentReference,
|
||||
@@ -430,24 +817,30 @@ export const applyTick = (
|
||||
zones: updatedZones,
|
||||
};
|
||||
|
||||
// Check achievements and apply crystal rewards for newly unlocked ones
|
||||
// Check achievements and apply crystal and runestone rewards for newly unlocked ones
|
||||
const updatedAchievements = checkAchievements(partialState);
|
||||
const crystalsFromAchievements = updatedAchievements.reduce(
|
||||
(sum, achievement, index) => {
|
||||
const wasLocked = state.achievements[index]?.unlockedAt === null;
|
||||
const isNowUnlocked = achievement.unlockedAt !== null;
|
||||
if (wasLocked && isNowUnlocked) {
|
||||
return sum + (achievement.reward?.crystals ?? 0);
|
||||
}
|
||||
return sum;
|
||||
},
|
||||
0,
|
||||
);
|
||||
let crystalsFromAchievements = 0;
|
||||
let runestonesFromAchievements = 0;
|
||||
for (const [ index, achievement ] of updatedAchievements.entries()) {
|
||||
const wasLocked = state.achievements[index]?.unlockedAt === null;
|
||||
const isNowUnlocked = achievement.unlockedAt !== null;
|
||||
if (wasLocked && isNowUnlocked) {
|
||||
crystalsFromAchievements
|
||||
= crystalsFromAchievements + (achievement.reward?.crystals ?? 0);
|
||||
runestonesFromAchievements
|
||||
= runestonesFromAchievements + (achievement.reward?.runestones ?? 0);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
...partialState,
|
||||
achievements: updatedAchievements,
|
||||
resources: {
|
||||
prestige: {
|
||||
...partialState.prestige,
|
||||
runestones:
|
||||
partialState.prestige.runestones + runestonesFromAchievements,
|
||||
},
|
||||
resources: {
|
||||
...partialState.resources,
|
||||
crystals: capResource(
|
||||
partialState.resources.crystals + crystalsFromAchievements,
|
||||
|
||||
+205
-43
@@ -116,6 +116,66 @@ body::before {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* ── Resource toggle + dropdown ─────────────────────────────────────────── */
|
||||
|
||||
.resource-menu {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.resource-toggle {
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
border: 1px solid rgba(147, 51, 234, 0.4);
|
||||
border-radius: 0.5rem;
|
||||
color: inherit;
|
||||
cursor: pointer;
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
padding: 0.3rem 0.6rem;
|
||||
position: relative;
|
||||
transition: background 0.2s, border-color 0.2s;
|
||||
}
|
||||
|
||||
.resource-toggle:hover {
|
||||
background: rgba(147, 51, 234, 0.2);
|
||||
border-color: var(--colour-primary);
|
||||
}
|
||||
|
||||
.resource-alert-dot {
|
||||
background: var(--colour-warning, #f59e0b);
|
||||
border-radius: 50%;
|
||||
height: 0.45rem;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
width: 0.45rem;
|
||||
}
|
||||
|
||||
.resources-dropdown {
|
||||
background: var(--colour-surface);
|
||||
border: 1px solid rgba(147, 51, 234, 0.4);
|
||||
border-radius: 0.5rem;
|
||||
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.1rem;
|
||||
left: 0;
|
||||
padding: 0.4rem;
|
||||
position: absolute;
|
||||
top: calc(100% + 0.4rem);
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.resources-dropdown .resource {
|
||||
border-radius: 0.35rem;
|
||||
gap: 0.5rem;
|
||||
padding: 0.3rem 0.5rem;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.resources-dropdown .resource:hover {
|
||||
background: rgba(255, 255, 255, 0.04);
|
||||
}
|
||||
|
||||
/* ===================== GAME LAYOUT ===================== */
|
||||
.game-layout {
|
||||
display: flex;
|
||||
@@ -1492,57 +1552,87 @@ body::before {
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
/* ── Profile buttons in ResourceBar ────────────────────────────────────── */
|
||||
/* ── Resource bar actions (save + profile menu) ─────────────────────────── */
|
||||
|
||||
.profile-buttons {
|
||||
.resource-bar-actions {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
gap: 0.35rem;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.profile-link-button {
|
||||
align-items: center;
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
border: 1px solid rgba(147, 51, 234, 0.4);
|
||||
border-radius: 1rem;
|
||||
color: var(--colour-text-muted);
|
||||
display: flex;
|
||||
font-size: 0.8rem;
|
||||
gap: 0.3rem;
|
||||
padding: 0.3rem 0.8rem;
|
||||
text-decoration: none;
|
||||
transition: all 0.2s;
|
||||
white-space: nowrap;
|
||||
.profile-menu {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.profile-link-button:hover {
|
||||
background: rgba(147, 51, 234, 0.2);
|
||||
border-color: var(--colour-primary);
|
||||
color: var(--colour-text);
|
||||
}
|
||||
|
||||
.profile-edit-button {
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
border: 1px solid rgba(147, 51, 234, 0.4);
|
||||
.profile-avatar-button {
|
||||
background: none;
|
||||
border: 2px solid rgba(147, 51, 234, 0.4);
|
||||
border-radius: 50%;
|
||||
color: var(--colour-text-muted);
|
||||
cursor: pointer;
|
||||
font-family: inherit;
|
||||
font-size: 0.85rem;
|
||||
display: flex;
|
||||
height: 2rem;
|
||||
line-height: 1;
|
||||
overflow: hidden;
|
||||
padding: 0;
|
||||
transition: all 0.2s;
|
||||
transition: border-color 0.2s;
|
||||
width: 2rem;
|
||||
}
|
||||
|
||||
.profile-edit-button:hover {
|
||||
background: rgba(147, 51, 234, 0.2);
|
||||
.profile-avatar-button:hover {
|
||||
border-color: var(--colour-primary);
|
||||
}
|
||||
|
||||
.profile-avatar-img {
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.profile-dropdown {
|
||||
background: var(--colour-surface);
|
||||
border: 1px solid rgba(147, 51, 234, 0.4);
|
||||
border-radius: 0.5rem;
|
||||
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 10rem;
|
||||
padding: 0.25rem;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: calc(100% + 0.4rem);
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.profile-dropdown-item {
|
||||
align-items: center;
|
||||
background: none;
|
||||
border: none;
|
||||
border-radius: 0.35rem;
|
||||
color: var(--colour-text-muted);
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
font-family: inherit;
|
||||
font-size: 0.85rem;
|
||||
gap: 0.4rem;
|
||||
padding: 0.45rem 0.75rem;
|
||||
text-align: left;
|
||||
text-decoration: none;
|
||||
transition: background 0.15s, color 0.15s;
|
||||
white-space: nowrap;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.profile-dropdown-item:hover {
|
||||
background: rgba(147, 51, 234, 0.15);
|
||||
color: var(--colour-text);
|
||||
}
|
||||
|
||||
.profile-dropdown-divider {
|
||||
border: none;
|
||||
border-top: 1px solid rgba(147, 51, 234, 0.2);
|
||||
margin: 0.25rem 0;
|
||||
}
|
||||
|
||||
.save-status {
|
||||
color: var(--colour-text-muted);
|
||||
font-size: 0.75rem;
|
||||
@@ -3167,10 +3257,10 @@ body::before {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Profile buttons fill their own row, aligned right */
|
||||
.profile-buttons {
|
||||
margin-left: 0;
|
||||
/* Resource bar actions fill their own row, aligned right */
|
||||
.resource-bar-actions {
|
||||
justify-content: flex-end;
|
||||
margin-left: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@@ -3240,15 +3330,6 @@ body::before {
|
||||
|
||||
/* --- Small mobile (≤ 480px) --------------------------- */
|
||||
@media (max-width: 480px) {
|
||||
/* Icon-only profile link buttons to save horizontal space */
|
||||
.btn-label {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.profile-link-button {
|
||||
padding: 0.3rem 0.5rem;
|
||||
}
|
||||
|
||||
/* Slightly smaller tab buttons */
|
||||
.tab-button {
|
||||
font-size: 0.8rem;
|
||||
@@ -4515,3 +4596,84 @@ body::before {
|
||||
object-fit: cover;
|
||||
width: 80px;
|
||||
}
|
||||
|
||||
/* ===================== ACTION BUTTONS ===================== */
|
||||
.action-button {
|
||||
background: var(--colour-accent);
|
||||
border: none;
|
||||
border-radius: var(--radius);
|
||||
color: #fff;
|
||||
cursor: pointer;
|
||||
font-size: 0.9rem;
|
||||
font-weight: 700;
|
||||
margin-top: 0.5rem;
|
||||
padding: 0.55rem 1.25rem;
|
||||
transition: background 0.15s;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.action-button:hover:not(:disabled) {
|
||||
background: var(--colour-accent-light);
|
||||
}
|
||||
|
||||
.action-button:disabled {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.action-button-danger {
|
||||
background: var(--colour-error);
|
||||
}
|
||||
|
||||
.action-button-danger:hover:not(:disabled) {
|
||||
background: #f87171;
|
||||
}
|
||||
|
||||
/* ===================== MODAL VARIANTS ===================== */
|
||||
.modal-button-danger {
|
||||
background: var(--colour-error);
|
||||
}
|
||||
|
||||
.modal-button-danger:hover:not(:disabled) {
|
||||
background: #f87171;
|
||||
}
|
||||
|
||||
/* ===================== DEBUG PANEL ===================== */
|
||||
.debug-actions {
|
||||
display: grid;
|
||||
gap: 1rem;
|
||||
grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.debug-action-card {
|
||||
background: var(--colour-surface);
|
||||
border: 1px solid var(--colour-border);
|
||||
border-radius: var(--radius-lg);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 1.25rem;
|
||||
}
|
||||
|
||||
.debug-action-card h3 {
|
||||
color: var(--colour-accent-light);
|
||||
font-size: 1rem;
|
||||
margin: 0 0 0.5rem;
|
||||
}
|
||||
|
||||
.debug-action-card > p {
|
||||
color: var(--colour-text-muted);
|
||||
flex: 1;
|
||||
font-size: 0.875rem;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.debug-result-message {
|
||||
background: rgba(16, 185, 129, 0.1);
|
||||
border: 1px solid var(--colour-success);
|
||||
border-radius: var(--radius);
|
||||
color: var(--colour-success);
|
||||
font-size: 0.8rem;
|
||||
margin-top: 0.75rem;
|
||||
padding: 0.5rem 0.75rem;
|
||||
}
|
||||
|
||||
@@ -49,6 +49,18 @@ const initialiseFrontendLogger = (): void => {
|
||||
? argument
|
||||
: JSON.stringify(argument);
|
||||
}).join(" ");
|
||||
|
||||
/*
|
||||
* Ignore errors originating entirely from third-party scripts (e.g. AdSense).
|
||||
* Stack frames from our own code reference elysium.nhcarrigan.com or localhost;
|
||||
* if none are present but external URLs are, the error is not actionable.
|
||||
*/
|
||||
const hasExternalUrl = (/https?:\/\//u).test(message);
|
||||
const hasOurDomain = message.includes("elysium.nhcarrigan.com");
|
||||
const hasOwnFrame = hasOurDomain || message.includes("localhost");
|
||||
if (hasExternalUrl && !hasOwnFrame) {
|
||||
return;
|
||||
}
|
||||
const context = "console.error";
|
||||
post("/api/fe/error", { context, message });
|
||||
};
|
||||
|
||||
+150
@@ -0,0 +1,150 @@
|
||||
/**
|
||||
* Dev Puppeteer script — intercepts /api/game/load and injects a fresh
|
||||
* game state built from the actual compiled data files, so we can browse
|
||||
* the game UI without auth or a real DB record.
|
||||
*/
|
||||
import puppeteer from "puppeteer";
|
||||
import { createRequire } from "module";
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
|
||||
// Load actual game data from compiled API output
|
||||
const { defaultAchievements } = require("./apps/api/prod/src/data/achievements.js");
|
||||
const { defaultEquipment } = require("./apps/api/prod/src/data/equipment.js");
|
||||
const { defaultBosses } = require("./apps/api/prod/src/data/bosses.js");
|
||||
const { defaultQuests } = require("./apps/api/prod/src/data/quests.js");
|
||||
const { defaultAdventurers } = require("./apps/api/prod/src/data/adventurers.js");
|
||||
const { defaultUpgrades } = require("./apps/api/prod/src/data/upgrades.js");
|
||||
const { defaultZones } = require("./apps/api/prod/src/data/zones.js");
|
||||
|
||||
console.log("📦 Data loaded:");
|
||||
console.log(` achievements : ${defaultAchievements.length}`);
|
||||
console.log(` equipment : ${defaultEquipment.length}`);
|
||||
console.log(` bosses : ${defaultBosses.length}`);
|
||||
console.log(` quests : ${defaultQuests.length}`);
|
||||
|
||||
// Spot-check for our new items
|
||||
const newEquipIds = [
|
||||
"chaos_mantle", "titan_core", "expanse_blade", "void_armour_mk2",
|
||||
"cosmos_blade", "reality_plate", "maelstrom_edge", "cosmic_plate",
|
||||
"primeval_blade", "ancient_aegis", "absolute_blade", "eternity_plate",
|
||||
"omniversal_core",
|
||||
];
|
||||
const foundNew = newEquipIds.filter(id => defaultEquipment.some(e => e.id === id));
|
||||
const missingNew = newEquipIds.filter(id => !defaultEquipment.some(e => e.id === id));
|
||||
console.log(`\n🗡️ New equipment found (${foundNew.length}/13): ${foundNew.join(", ")}`);
|
||||
if (missingNew.length > 0) console.log(` ❌ Missing: ${missingNew.join(", ")}`);
|
||||
|
||||
const questEternal = defaultAchievements.find(a => a.id === "quest_eternal");
|
||||
const fullyEquipped = defaultAchievements.find(a => a.id === "fully_equipped");
|
||||
console.log(`\n🏆 quest_eternal condition amount : ${questEternal?.condition?.amount}`);
|
||||
console.log(`🏆 fully_equipped condition amount: ${fullyEquipped?.condition?.amount}`);
|
||||
|
||||
// Build a minimal but valid mock game state
|
||||
const mockState = {
|
||||
achievements : defaultAchievements,
|
||||
adventurers : defaultAdventurers,
|
||||
baseClickPower: 1,
|
||||
bosses : defaultBosses,
|
||||
equipment : defaultEquipment,
|
||||
lastTickAt : Date.now(),
|
||||
player : {
|
||||
avatar : null,
|
||||
characterName : "Hikari Test",
|
||||
createdAt : Date.now(),
|
||||
discordId : "000000000000000001",
|
||||
discriminator : "0",
|
||||
lastSavedAt : Date.now(),
|
||||
lifetimeAchievementsUnlocked: 0,
|
||||
lifetimeAdventurersRecruited: 0,
|
||||
lifetimeBossesDefeated : 0,
|
||||
lifetimeClicks : 0,
|
||||
lifetimeGoldEarned : 0,
|
||||
lifetimeQuestsCompleted : 0,
|
||||
totalClicks : 0,
|
||||
totalGoldEarned : 0,
|
||||
username : "HikariTest",
|
||||
},
|
||||
prestige : {
|
||||
count : 0,
|
||||
runestones : 0,
|
||||
},
|
||||
quests : defaultQuests,
|
||||
resources : {
|
||||
crystals : 0,
|
||||
essence : 0,
|
||||
gold : 0,
|
||||
},
|
||||
upgrades : defaultUpgrades,
|
||||
zones : defaultZones,
|
||||
};
|
||||
|
||||
const mockLoadResponse = {
|
||||
currentSchemaVersion: 1,
|
||||
inGuild : true,
|
||||
loginBonus : null,
|
||||
loginStreak : 0,
|
||||
offlineEssence : 0,
|
||||
offlineGold : 0,
|
||||
offlineSeconds : 0,
|
||||
schemaOutdated : false,
|
||||
signature : undefined,
|
||||
state : mockState,
|
||||
};
|
||||
|
||||
console.log("\n🌐 Launching browser...");
|
||||
const browser = await puppeteer.launch({
|
||||
args : ["--no-sandbox", "--disable-setuid-sandbox"],
|
||||
headless: false,
|
||||
});
|
||||
|
||||
const page = await browser.newPage();
|
||||
await page.setViewport({ height: 900, width: 1400 });
|
||||
|
||||
// Intercept the game load call and inject our mock state
|
||||
await page.setRequestInterception(true);
|
||||
page.on("request", (req) => {
|
||||
if (req.url().includes("/api/game/load") && req.method() === "GET") {
|
||||
console.log(" ↩️ Intercepted /api/game/load — injecting mock state");
|
||||
req.respond({
|
||||
body : JSON.stringify(mockLoadResponse),
|
||||
contentType : "application/json",
|
||||
headers : { "Content-Type": "application/json" },
|
||||
status : 200,
|
||||
});
|
||||
} else {
|
||||
req.continue();
|
||||
}
|
||||
});
|
||||
|
||||
// Set a fake token so the frontend thinks we're logged in
|
||||
await page.evaluateOnNewDocument(() => {
|
||||
localStorage.setItem("elysium_token", "dev.fake.token");
|
||||
});
|
||||
|
||||
console.log(" 🔗 Navigating to http://localhost:5173 ...");
|
||||
await page.goto("http://localhost:5173", { waitUntil: "networkidle2" });
|
||||
|
||||
// Give the game a moment to tick and render
|
||||
await new Promise(r => setTimeout(r, 3000));
|
||||
|
||||
await page.screenshot({ path: "/tmp/elysium-01-game.png" });
|
||||
console.log(" 📸 Screenshot: /tmp/elysium-01-game.png");
|
||||
|
||||
// Try to find the equipment panel
|
||||
const equipmentTab = await page.$("button, a, [role='tab']");
|
||||
console.log(`\n🔍 Checking page title: ${await page.title()}`);
|
||||
|
||||
// Log any visible text that mentions our new items
|
||||
const pageText = await page.evaluate(() => document.body.innerText);
|
||||
const newItemsVisible = newEquipIds.filter(id => pageText.toLowerCase().includes(id.replace(/_/g, " ").toLowerCase().slice(0, 8)));
|
||||
console.log(`\n🗡️ New item names visible in UI: ${newItemsVisible.length > 0 ? newItemsVisible.join(", ") : "none yet (may need to navigate to equipment panel)"}`);
|
||||
|
||||
// Check achievement counts visible in page
|
||||
const hasQuestEternal = pageText.includes("112");
|
||||
const hasFullyEquipped = pageText.includes("78");
|
||||
console.log(` quest_eternal (112) visible: ${hasQuestEternal}`);
|
||||
console.log(` fully_equipped (78) visible: ${hasFullyEquipped}`);
|
||||
|
||||
console.log("\n✅ Browser open — take a look around! Close it when done.");
|
||||
console.log(" (or Ctrl+C to exit)\n");
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "elysium",
|
||||
"version": "0.1.1",
|
||||
"version": "0.4.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
@@ -11,6 +11,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nhcarrigan/typescript-config": "4.0.0",
|
||||
"typescript": "5.8.2"
|
||||
"typescript": "6.0.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@elysium/types",
|
||||
"version": "0.1.1",
|
||||
"version": "0.4.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./prod/src/index.js",
|
||||
|
||||
@@ -55,11 +55,13 @@ export type {
|
||||
BuyPrestigeUpgradeResponse,
|
||||
CraftRecipeRequest,
|
||||
CraftRecipeResponse,
|
||||
ExploreClaimableResponse,
|
||||
ExploreCollectEventResult,
|
||||
ExploreCollectRequest,
|
||||
ExploreCollectResponse,
|
||||
ExploreStartRequest,
|
||||
ExploreStartResponse,
|
||||
ForceUnlocksResponse,
|
||||
GiteaRelease,
|
||||
LeaderboardCategory,
|
||||
LeaderboardEntry,
|
||||
@@ -71,6 +73,7 @@ export type {
|
||||
PublicProfileResponse,
|
||||
SaveRequest,
|
||||
SaveResponse,
|
||||
SyncNewContentResponse,
|
||||
TranscendenceRequest,
|
||||
TranscendenceResponse,
|
||||
UpdateProfileRequest,
|
||||
|
||||
@@ -20,7 +20,8 @@ interface AchievementCondition {
|
||||
}
|
||||
|
||||
interface AchievementReward {
|
||||
crystals?: number;
|
||||
crystals?: number;
|
||||
runestones?: number;
|
||||
}
|
||||
|
||||
interface Achievement {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
* @license Naomi's Public License
|
||||
* @author Naomi Carrigan
|
||||
*/
|
||||
/* eslint-disable max-lines -- API types file grows with each new endpoint */
|
||||
import type {
|
||||
EquipmentBonus,
|
||||
EquipmentRarity,
|
||||
@@ -69,6 +70,11 @@ interface LoginBonusResult {
|
||||
interface LoadResponse {
|
||||
state: GameState;
|
||||
|
||||
/**
|
||||
* Whether the player is currently a member of the NHCarrigan Discord server.
|
||||
*/
|
||||
inGuild: boolean;
|
||||
|
||||
/**
|
||||
* Offline gold earned since last save (server-calculated).
|
||||
*/
|
||||
@@ -384,6 +390,10 @@ interface ExploreCollectResponse {
|
||||
event: ExploreCollectEventResult | null;
|
||||
}
|
||||
|
||||
interface ExploreClaimableResponse {
|
||||
claimable: boolean;
|
||||
}
|
||||
|
||||
interface CraftRecipeRequest {
|
||||
recipeId: string;
|
||||
}
|
||||
@@ -396,6 +406,163 @@ interface CraftRecipeResponse {
|
||||
craftedEssenceMultiplier: number;
|
||||
craftedClickMultiplier: number;
|
||||
craftedCombatMultiplier: number;
|
||||
materials: Array<{ materialId: string; quantity: number }>;
|
||||
}
|
||||
|
||||
interface ForceUnlocksResponse {
|
||||
|
||||
/**
|
||||
* The corrected game state after applying all missing unlocks.
|
||||
*/
|
||||
state: GameState;
|
||||
|
||||
/**
|
||||
* Number of zones that were unlocked by this operation.
|
||||
*/
|
||||
zonesUnlocked: number;
|
||||
|
||||
/**
|
||||
* Number of quests that were made available by this operation.
|
||||
*/
|
||||
questsUnlocked: number;
|
||||
|
||||
/**
|
||||
* Number of bosses that were made available by this operation.
|
||||
*/
|
||||
bossesUnlocked: number;
|
||||
|
||||
/**
|
||||
* Number of exploration areas that were made available by this operation.
|
||||
*/
|
||||
explorationUnlocked: number;
|
||||
|
||||
/**
|
||||
* Number of adventurer tiers that were unlocked by this operation.
|
||||
*/
|
||||
adventurersUnlocked: number;
|
||||
|
||||
/**
|
||||
* Number of upgrades that were unlocked by this operation.
|
||||
*/
|
||||
upgradesUnlocked: number;
|
||||
|
||||
/**
|
||||
* Number of equipment items that were marked as owned by this operation.
|
||||
*/
|
||||
equipmentUnlocked: number;
|
||||
|
||||
/**
|
||||
* Number of story chapters that were unlocked by this operation.
|
||||
*/
|
||||
storyUnlocked: number;
|
||||
|
||||
/**
|
||||
* HMAC-SHA256 signature of the corrected state for anti-cheat chain continuity.
|
||||
*/
|
||||
signature?: string;
|
||||
}
|
||||
|
||||
interface SyncNewContentResponse {
|
||||
|
||||
/**
|
||||
* The updated game state after injecting all missing content entries.
|
||||
*/
|
||||
state: GameState;
|
||||
|
||||
/**
|
||||
* Number of adventurer tiers added to the save.
|
||||
*/
|
||||
adventurersAdded: number;
|
||||
|
||||
/**
|
||||
* Number of existing adventurer entries whose stats were patched to match current defaults.
|
||||
*/
|
||||
adventurerStatsPatched: number;
|
||||
|
||||
/**
|
||||
* Number of upgrades added to the save.
|
||||
*/
|
||||
upgradesAdded: number;
|
||||
|
||||
/**
|
||||
* Number of rewards patched onto existing quests.
|
||||
*/
|
||||
questRewardsPatched: number;
|
||||
|
||||
/**
|
||||
* Number of quests added to the save.
|
||||
*/
|
||||
questsAdded: number;
|
||||
|
||||
/**
|
||||
* Number of bosses added to the save.
|
||||
*/
|
||||
bossesAdded: number;
|
||||
|
||||
/**
|
||||
* Number of upgrade reward IDs patched onto existing bosses.
|
||||
*/
|
||||
bossRewardsPatched: number;
|
||||
|
||||
/**
|
||||
* Number of equipment items added to the save.
|
||||
*/
|
||||
equipmentAdded: number;
|
||||
|
||||
/**
|
||||
* Number of achievements added to the save.
|
||||
*/
|
||||
achievementsAdded: number;
|
||||
|
||||
/**
|
||||
* Number of zones added to the save.
|
||||
*/
|
||||
zonesAdded: number;
|
||||
|
||||
/**
|
||||
* Number of exploration areas added to the save.
|
||||
*/
|
||||
explorationAreasAdded: number;
|
||||
|
||||
/**
|
||||
* Number of achievements whose stats were updated to match current defaults.
|
||||
*/
|
||||
achievementsPatched: number;
|
||||
|
||||
/**
|
||||
* Number of bosses whose stats were updated to match current defaults.
|
||||
*/
|
||||
bossesPatched: number;
|
||||
|
||||
/**
|
||||
* Number of crafted recipes whose multiplier contribution was reapplied during recompute.
|
||||
*/
|
||||
craftingRecipesReapplied: number;
|
||||
|
||||
/**
|
||||
* Number of equipment items whose stats were updated to match current defaults.
|
||||
*/
|
||||
equipmentPatched: number;
|
||||
|
||||
/**
|
||||
* Number of quests whose stats were updated to match current defaults.
|
||||
*/
|
||||
questsPatched: number;
|
||||
|
||||
/**
|
||||
* Number of upgrades whose stats were updated to match current defaults.
|
||||
*/
|
||||
upgradesPatched: number;
|
||||
|
||||
/**
|
||||
* Number of zones whose stats were updated to match current defaults.
|
||||
*/
|
||||
zonesPatched: number;
|
||||
|
||||
/**
|
||||
* HMAC-SHA256 signature of the updated state for anti-cheat chain continuity.
|
||||
*/
|
||||
signature?: string;
|
||||
}
|
||||
|
||||
export type {
|
||||
@@ -412,11 +579,13 @@ export type {
|
||||
BuyPrestigeUpgradeResponse,
|
||||
CraftRecipeRequest,
|
||||
CraftRecipeResponse,
|
||||
ExploreClaimableResponse,
|
||||
ExploreCollectEventResult,
|
||||
ExploreCollectRequest,
|
||||
ExploreCollectResponse,
|
||||
ExploreStartRequest,
|
||||
ExploreStartResponse,
|
||||
ForceUnlocksResponse,
|
||||
GiteaRelease,
|
||||
LeaderboardCategory,
|
||||
LeaderboardEntry,
|
||||
@@ -428,6 +597,7 @@ export type {
|
||||
PublicProfileResponse,
|
||||
SaveRequest,
|
||||
SaveResponse,
|
||||
SyncNewContentResponse,
|
||||
TranscendenceRequest,
|
||||
TranscendenceResponse,
|
||||
UpdateProfileRequest,
|
||||
|
||||
@@ -72,6 +72,12 @@ interface ExplorationAreaState {
|
||||
*/
|
||||
startedAt?: number;
|
||||
|
||||
/**
|
||||
* Unix timestamp when the exploration will complete (server-computed, used for
|
||||
* accurate client-side countdown that is immune to client/server clock drift).
|
||||
*/
|
||||
endsAt?: number;
|
||||
|
||||
/**
|
||||
* True after the first successful collect — used for codex unlock detection.
|
||||
*/
|
||||
|
||||
@@ -79,6 +79,11 @@ interface GameState {
|
||||
*/
|
||||
autoBoss?: boolean;
|
||||
|
||||
/**
|
||||
* When true, the tick engine automatically purchases the highest-tier affordable adventurer.
|
||||
*/
|
||||
autoAdventurer?: boolean;
|
||||
|
||||
/**
|
||||
* Companion unlock and active selection state — optional for backwards compatibility.
|
||||
*/
|
||||
|
||||
@@ -48,11 +48,17 @@ interface ProfileSettings {
|
||||
* Whether browser system notifications are enabled.
|
||||
*/
|
||||
enableNotifications: boolean;
|
||||
|
||||
/**
|
||||
* Whether prestige milestones are announced in the Discord server.
|
||||
*/
|
||||
enablePrestigeAnnouncements: boolean;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention -- intentional constant name
|
||||
const DEFAULT_PROFILE_SETTINGS: ProfileSettings = {
|
||||
enableNotifications: false,
|
||||
enablePrestigeAnnouncements: true,
|
||||
enableSounds: false,
|
||||
numberFormat: "suffix",
|
||||
showAchievementsUnlocked: true,
|
||||
|
||||
Generated
+14
-3
@@ -10,10 +10,10 @@ importers:
|
||||
devDependencies:
|
||||
'@nhcarrigan/typescript-config':
|
||||
specifier: 4.0.0
|
||||
version: 4.0.0(typescript@5.8.2)
|
||||
version: 4.0.0(typescript@6.0.2)
|
||||
typescript:
|
||||
specifier: 5.8.2
|
||||
version: 5.8.2
|
||||
specifier: 6.0.2
|
||||
version: 6.0.2
|
||||
|
||||
apps/api:
|
||||
dependencies:
|
||||
@@ -2833,6 +2833,11 @@ packages:
|
||||
engines: {node: '>=14.17'}
|
||||
hasBin: true
|
||||
|
||||
typescript@6.0.2:
|
||||
resolution: {integrity: sha512-bGdAIrZ0wiGDo5l8c++HWtbaNCWTS4UTv7RaTH/ThVIgjkveJt83m74bBHMJkuCbslY8ixgLBVZJIOiQlQTjfQ==}
|
||||
engines: {node: '>=14.17'}
|
||||
hasBin: true
|
||||
|
||||
unbox-primitive@1.1.0:
|
||||
resolution: {integrity: sha512-nWJ91DjeOkej/TA8pXQ3myruKpKEYgqvpw9lz4OPHj/NWFNluYrjbz9j01CJ8yKQd2g4jFoOkINCTW2I5LEEyw==}
|
||||
engines: {node: '>= 0.4'}
|
||||
@@ -3502,6 +3507,10 @@ snapshots:
|
||||
dependencies:
|
||||
typescript: 5.8.2
|
||||
|
||||
'@nhcarrigan/typescript-config@4.0.0(typescript@6.0.2)':
|
||||
dependencies:
|
||||
typescript: 6.0.2
|
||||
|
||||
'@nodelib/fs.scandir@2.1.5':
|
||||
dependencies:
|
||||
'@nodelib/fs.stat': 2.0.5
|
||||
@@ -6138,6 +6147,8 @@ snapshots:
|
||||
|
||||
typescript@5.8.2: {}
|
||||
|
||||
typescript@6.0.2: {}
|
||||
|
||||
unbox-primitive@1.1.0:
|
||||
dependencies:
|
||||
call-bound: 1.0.4
|
||||
|
||||
Reference in New Issue
Block a user