From 6df5dc6a53db5fccfa35b76fd2f1a8a622b62d09 Mon Sep 17 00:00:00 2001 From: Z User Date: Thu, 2 Apr 2026 10:03:52 +0000 Subject: [PATCH] fix: remove unused imports from GolemancyTab and fix build error --- src/components/game/tabs/GolemancyTab.tsx | 11 +-- src/lib/game/data/golems.ts | 113 ++++++++++++++++++++++ src/lib/game/store.ts | 2 +- 3 files changed, 118 insertions(+), 8 deletions(-) diff --git a/src/components/game/tabs/GolemancyTab.tsx b/src/components/game/tabs/GolemancyTab.tsx index 88c7c4b..557ff55 100644 --- a/src/components/game/tabs/GolemancyTab.tsx +++ b/src/components/game/tabs/GolemancyTab.tsx @@ -1,18 +1,15 @@ 'use client'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; -import { Button } from '@/components/ui/button'; import { Badge } from '@/components/ui/badge'; import { ScrollArea } from '@/components/ui/scroll-area'; import { Separator } from '@/components/ui/separator'; import { - Golem, Zap, Clock, Swords, Shield, Target, Sparkles, Lock, Check, X + Mountain, Zap, Clock, Swords, Target, Sparkles, Lock, Check, X } from 'lucide-react'; import { GOLEMS_DEF, getGolemSlots, isGolemUnlocked, getGolemDamage, getGolemAttackSpeed, getGolemFloorDuration } from '@/lib/game/data/golems'; import { ELEMENTS } from '@/lib/game/constants'; -import { fmt } from '@/lib/game/store'; import type { GameStore } from '@/lib/game/store'; -import type { GolemancyState, AttunementState, ElementState } from '@/lib/game/types'; export interface GolemancyTabProps { store: GameStore; @@ -108,7 +105,7 @@ export function GolemancyTab({ store }: GolemancyTabProps) {
- + {golem.name}
@@ -215,7 +212,7 @@ export function GolemancyTab({ store }: GolemancyTabProps) { - + Golemancy @@ -278,7 +275,7 @@ export function GolemancyTab({ store }: GolemancyTabProps) { return ( - + {golem?.name} ); diff --git a/src/lib/game/data/golems.ts b/src/lib/game/data/golems.ts index 13e6dc0..2d3a1bc 100644 --- a/src/lib/game/data/golems.ts +++ b/src/lib/game/data/golems.ts @@ -356,3 +356,116 @@ export function getGolemAttackSpeed( export function getGolemFloorDuration(skills: Record): number { return 1 + (skills.golemLongevity || 0); } + +// Get maintenance cost multiplier (Golem Siphon reduces by 10% per level) +export function getGolemMaintenanceMultiplier(skills: Record): number { + return 1 - (skills.golemSiphon || 0) * 0.1; +} + +// Check if player can afford golem summon cost +export function canAffordGolemSummon( + golemId: string, + rawMana: number, + elements: Record +): boolean { + const golem = GOLEMS_DEF[golemId]; + if (!golem) return false; + + for (const cost of golem.summonCost) { + if (cost.type === 'raw') { + if (rawMana < cost.amount) return false; + } else if (cost.element) { + const elem = elements[cost.element]; + if (!elem || !elem.unlocked || elem.current < cost.amount) return false; + } + } + + return true; +} + +// Deduct golem summon cost from mana pools +export function deductGolemSummonCost( + golemId: string, + rawMana: number, + elements: Record +): { rawMana: number; elements: Record } { + const golem = GOLEMS_DEF[golemId]; + if (!golem) return { rawMana, elements }; + + let newRawMana = rawMana; + let newElements = { ...elements }; + + for (const cost of golem.summonCost) { + if (cost.type === 'raw') { + newRawMana -= cost.amount; + } else if (cost.element && newElements[cost.element]) { + newElements = { + ...newElements, + [cost.element]: { + ...newElements[cost.element], + current: newElements[cost.element].current - cost.amount, + }, + }; + } + } + + return { rawMana: newRawMana, elements: newElements }; +} + +// Check if player can afford golem maintenance for one tick +export function canAffordGolemMaintenance( + golemId: string, + rawMana: number, + elements: Record, + skills: Record +): boolean { + const golem = GOLEMS_DEF[golemId]; + if (!golem) return false; + + const maintenanceMult = getGolemMaintenanceMultiplier(skills); + + for (const cost of golem.maintenanceCost) { + const adjustedAmount = cost.amount * maintenanceMult; + if (cost.type === 'raw') { + if (rawMana < adjustedAmount) return false; + } else if (cost.element) { + const elem = elements[cost.element]; + if (!elem || !elem.unlocked || elem.current < adjustedAmount) return false; + } + } + + return true; +} + +// Deduct golem maintenance cost for one tick +export function deductGolemMaintenance( + golemId: string, + rawMana: number, + elements: Record, + skills: Record +): { rawMana: number; elements: Record } { + const golem = GOLEMS_DEF[golemId]; + if (!golem) return { rawMana, elements }; + + const maintenanceMult = getGolemMaintenanceMultiplier(skills); + + let newRawMana = rawMana; + let newElements = { ...elements }; + + for (const cost of golem.maintenanceCost) { + const adjustedAmount = cost.amount * maintenanceMult; + if (cost.type === 'raw') { + newRawMana -= adjustedAmount; + } else if (cost.element && newElements[cost.element]) { + newElements = { + ...newElements, + [cost.element]: { + ...newElements[cost.element], + current: newElements[cost.element].current - adjustedAmount, + }, + }; + } + } + + return { rawMana: newRawMana, elements: newElements }; +} diff --git a/src/lib/game/store.ts b/src/lib/game/store.ts index b0529eb..9d9ebbf 100755 --- a/src/lib/game/store.ts +++ b/src/lib/game/store.ts @@ -48,7 +48,7 @@ import { import { EQUIPMENT_TYPES } from './data/equipment'; import { ENCHANTMENT_EFFECTS, calculateEffectCapacityCost } from './data/enchantment-effects'; import { ATTUNEMENTS_DEF, getTotalAttunementRegen, getAttunementConversionRate, getAttunementXPForLevel, MAX_ATTUNEMENT_LEVEL } from './data/attunements'; -import { GOLEMS_DEF, getGolemSlots, isGolemUnlocked, getGolemDamage, getGolemAttackSpeed, getGolemFloorDuration } from './data/golems'; +import { GOLEMS_DEF, getGolemSlots, isGolemUnlocked, getGolemDamage, getGolemAttackSpeed, getGolemFloorDuration, canAffordGolemSummon, deductGolemSummonCost, canAffordGolemMaintenance, deductGolemMaintenance } from './data/golems'; // Default empty effects for when effects aren't provided const DEFAULT_EFFECTS: ComputedEffects = {