cleanup: delete computed-stats.ts shim and store/index.ts
Build and Publish Mana Loop Docker Image / build-and-publish (push) Failing after 57s
Build and Publish Mana Loop Docker Image / build-and-publish (push) Failing after 57s
- Delete src/lib/game/computed-stats.ts (root-level re-export shim) - Delete src/lib/game/store/index.ts (nothing imports from it) - Update __tests__/computed-stats.test.ts to import from ../utils instead - Clean up craftingStore.ts imports (remove unused useGameStore, CraftingApply) Typecheck and lint pass (pre-existing DisciplinesTab.tsx errors unchanged)
This commit is contained in:
@@ -11,7 +11,7 @@ import {
|
||||
computeClickMana,
|
||||
getMeditationBonus,
|
||||
getIncursionStrength,
|
||||
} from '../computed-stats';
|
||||
} from '../utils';
|
||||
import { MAX_DAY, INCURSION_START_DAY, HOURS_PER_TICK } from '../constants';
|
||||
|
||||
describe('fmt', () => {
|
||||
|
||||
@@ -1,345 +0,0 @@
|
||||
// ─── Attunement Definitions ─────────────────────────────────────────
|
||||
// Data file containing all attunement definitions
|
||||
|
||||
import type { AttunementDef, AttunementType } from '../types';
|
||||
|
||||
export const ATTUNEMENTS: Record<AttunementType, AttunementDef> = {
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
// ENCHANTER - Right Hand
|
||||
// The starting attunement. Grants access to enchanting and transference magic.
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
enchanter: {
|
||||
id: 'enchanter',
|
||||
name: 'Enchanter',
|
||||
slot: 'rightHand',
|
||||
description: 'Channel mana through your right hand to imbue equipment with magical properties.',
|
||||
capability: 'Unlock enchanting. Apply enchantments using transference mana.',
|
||||
primaryManaType: 'transference',
|
||||
rawManaRegen: 0.5,
|
||||
autoConvertRate: 0.2, // 0.2 transference per hour per raw regen
|
||||
icon: 'Wand2',
|
||||
color: '#8B5CF6', // Purple
|
||||
skills: {
|
||||
// Core enchanting skills
|
||||
enchanting: {
|
||||
name: 'Enchanting',
|
||||
desc: 'Apply magical effects to equipment',
|
||||
cat: 'enchanter',
|
||||
max: 10,
|
||||
base: 100,
|
||||
studyTime: 8,
|
||||
},
|
||||
efficientEnchant: {
|
||||
name: 'Efficient Enchanting',
|
||||
desc: 'Reduce enchantment mana costs',
|
||||
cat: 'enchanter',
|
||||
max: 5,
|
||||
base: 200,
|
||||
studyTime: 12,
|
||||
req: { enchanting: 3 },
|
||||
},
|
||||
|
||||
enchantSpeed: {
|
||||
name: 'Swift Enchanting',
|
||||
desc: 'Faster enchantment application',
|
||||
cat: 'enchanter',
|
||||
max: 5,
|
||||
base: 175,
|
||||
studyTime: 10,
|
||||
req: { enchanting: 2 },
|
||||
},
|
||||
transferenceMastery: {
|
||||
name: 'Transference Mastery',
|
||||
desc: 'Increased transference mana pool and regen',
|
||||
cat: 'enchanter',
|
||||
max: 10,
|
||||
base: 250,
|
||||
studyTime: 15,
|
||||
},
|
||||
},
|
||||
},
|
||||
// ... rest of attunement definitions (same as original data.ts)
|
||||
caster: {
|
||||
id: 'caster',
|
||||
name: 'Caster',
|
||||
slot: 'leftHand',
|
||||
description: 'Shape mana into devastating spell patterns through your left hand.',
|
||||
capability: 'Form mana shaping. +25% spell damage bonus.',
|
||||
primaryManaType: 'form',
|
||||
rawManaRegen: 0.3,
|
||||
autoConvertRate: 0.15,
|
||||
icon: 'Hand',
|
||||
color: '#3B82F6', // Blue
|
||||
skills: {
|
||||
spellShaping: {
|
||||
name: 'Spell Shaping',
|
||||
desc: 'Increase spell damage and efficiency',
|
||||
cat: 'caster',
|
||||
max: 10,
|
||||
base: 100,
|
||||
studyTime: 8,
|
||||
},
|
||||
quickCast: {
|
||||
name: 'Quick Cast',
|
||||
desc: 'Faster spell casting speed',
|
||||
cat: 'caster',
|
||||
max: 10,
|
||||
base: 120,
|
||||
studyTime: 8,
|
||||
},
|
||||
spellEcho: {
|
||||
name: 'Spell Echo',
|
||||
desc: 'Chance to cast spells twice',
|
||||
cat: 'caster',
|
||||
max: 5,
|
||||
base: 300,
|
||||
studyTime: 15,
|
||||
req: { spellShaping: 5 },
|
||||
},
|
||||
formMastery: {
|
||||
name: 'Form Mastery',
|
||||
desc: 'Increased form mana pool and regen',
|
||||
cat: 'caster',
|
||||
max: 10,
|
||||
base: 250,
|
||||
studyTime: 15,
|
||||
},
|
||||
},
|
||||
},
|
||||
seer: {
|
||||
id: 'seer',
|
||||
name: 'Seer',
|
||||
slot: 'head',
|
||||
description: 'See beyond the veil. Reveal hidden truths and enemy weaknesses.',
|
||||
capability: 'Reveal floor weaknesses. +20% critical hit chance.',
|
||||
primaryManaType: 'vision',
|
||||
rawManaRegen: 0.2,
|
||||
autoConvertRate: 0.1,
|
||||
icon: 'Eye',
|
||||
color: '#F59E0B', // Amber
|
||||
skills: {
|
||||
insight: {
|
||||
name: 'Insight',
|
||||
desc: 'Increased critical hit chance',
|
||||
cat: 'seer',
|
||||
max: 10,
|
||||
base: 100,
|
||||
studyTime: 8,
|
||||
},
|
||||
revealWeakness: {
|
||||
name: 'Reveal Weakness',
|
||||
desc: 'Show enemy elemental weaknesses',
|
||||
cat: 'seer',
|
||||
max: 5,
|
||||
base: 200,
|
||||
studyTime: 12,
|
||||
},
|
||||
foresight: {
|
||||
name: 'Foresight',
|
||||
desc: 'Chance to anticipate and dodge attacks',
|
||||
cat: 'seer',
|
||||
max: 5,
|
||||
base: 250,
|
||||
studyTime: 15,
|
||||
req: { insight: 5 },
|
||||
},
|
||||
visionMastery: {
|
||||
name: 'Vision Mastery',
|
||||
desc: 'Increased vision mana pool and regen',
|
||||
cat: 'seer',
|
||||
max: 10,
|
||||
base: 250,
|
||||
studyTime: 15,
|
||||
},
|
||||
},
|
||||
},
|
||||
warden: {
|
||||
id: 'warden',
|
||||
name: 'Warden',
|
||||
slot: 'back',
|
||||
description: 'Shield yourself with protective wards and barriers.',
|
||||
capability: 'Generate protective shields. -10% damage taken.',
|
||||
primaryManaType: 'barrier',
|
||||
rawManaRegen: 0.25,
|
||||
autoConvertRate: 0.12,
|
||||
icon: 'Shield',
|
||||
color: '#10B981', // Green
|
||||
skills: {
|
||||
warding: {
|
||||
name: 'Warding',
|
||||
desc: 'Generate protective shields',
|
||||
cat: 'warden',
|
||||
max: 10,
|
||||
base: 100,
|
||||
studyTime: 8,
|
||||
},
|
||||
fortitude: {
|
||||
name: 'Fortitude',
|
||||
desc: 'Reduce damage taken',
|
||||
cat: 'warden',
|
||||
max: 10,
|
||||
base: 150,
|
||||
studyTime: 10,
|
||||
},
|
||||
reflection: {
|
||||
name: 'Reflection',
|
||||
desc: 'Chance to reflect damage to attacker',
|
||||
cat: 'warden',
|
||||
max: 5,
|
||||
base: 300,
|
||||
studyTime: 15,
|
||||
req: { warding: 5 },
|
||||
},
|
||||
barrierMastery: {
|
||||
name: 'Barrier Mastery',
|
||||
desc: 'Increased barrier mana pool and regen',
|
||||
cat: 'warden',
|
||||
max: 10,
|
||||
base: 250,
|
||||
studyTime: 15,
|
||||
},
|
||||
},
|
||||
},
|
||||
invoker: {
|
||||
id: 'invoker',
|
||||
name: 'Invoker',
|
||||
slot: 'chest',
|
||||
description: 'Form pacts with spire guardians and channel their elemental power.',
|
||||
capability: 'Pact with guardians. Gain mana types from pacted guardians.',
|
||||
primaryManaType: null, // Uses guardian types instead
|
||||
rawManaRegen: 0.4,
|
||||
autoConvertRate: 0, // No auto-convert; mana comes from guardian pacts
|
||||
icon: 'Heart',
|
||||
color: '#EF4444', // Red
|
||||
skills: {
|
||||
pactMaking: {
|
||||
name: 'Pact Making',
|
||||
desc: 'Form stronger pacts with guardians',
|
||||
cat: 'invoker',
|
||||
max: 10,
|
||||
base: 100,
|
||||
studyTime: 8,
|
||||
},
|
||||
guardianChannel: {
|
||||
name: 'Guardian Channeling',
|
||||
desc: 'Channel guardian powers more effectively',
|
||||
cat: 'invoker',
|
||||
max: 10,
|
||||
base: 150,
|
||||
studyTime: 10,
|
||||
},
|
||||
elementalBurst: {
|
||||
name: 'Elemental Burst',
|
||||
desc: 'Unleash stored guardian energy',
|
||||
cat: 'invoker',
|
||||
max: 5,
|
||||
base: 300,
|
||||
studyTime: 15,
|
||||
req: { pactMaking: 5, guardianChannel: 3 },
|
||||
},
|
||||
soulResonance: {
|
||||
name: 'Soul Resonance',
|
||||
desc: 'Deep bond with pacted guardians',
|
||||
cat: 'invoker',
|
||||
max: 5,
|
||||
base: 400,
|
||||
studyTime: 20,
|
||||
req: { pactMaking: 8 },
|
||||
},
|
||||
},
|
||||
},
|
||||
strider: {
|
||||
id: 'strider',
|
||||
name: 'Strider',
|
||||
slot: 'leftLeg',
|
||||
description: 'Move with supernatural speed and grace.',
|
||||
capability: 'Enhanced mobility. +15% attack speed.',
|
||||
primaryManaType: 'flow',
|
||||
rawManaRegen: 0.3,
|
||||
autoConvertRate: 0.15,
|
||||
icon: 'Zap',
|
||||
color: '#06B6D4', // Cyan
|
||||
skills: {
|
||||
swiftness: {
|
||||
name: 'Swiftness',
|
||||
desc: 'Increased attack and movement speed',
|
||||
cat: 'strider',
|
||||
max: 10,
|
||||
base: 100,
|
||||
studyTime: 8,
|
||||
},
|
||||
evasive: {
|
||||
name: 'Evasive',
|
||||
desc: 'Chance to avoid damage',
|
||||
cat: 'strider',
|
||||
max: 5,
|
||||
base: 200,
|
||||
studyTime: 12,
|
||||
},
|
||||
momentum: {
|
||||
name: 'Momentum',
|
||||
desc: 'Build speed over consecutive attacks',
|
||||
cat: 'strider',
|
||||
max: 5,
|
||||
base: 250,
|
||||
studyTime: 15,
|
||||
req: { swiftness: 5 },
|
||||
},
|
||||
flowMastery: {
|
||||
name: 'Flow Mastery',
|
||||
desc: 'Increased flow mana pool and regen',
|
||||
cat: 'strider',
|
||||
max: 10,
|
||||
base: 250,
|
||||
studyTime: 15,
|
||||
},
|
||||
},
|
||||
},
|
||||
anchor: {
|
||||
id: 'anchor',
|
||||
name: 'Anchor',
|
||||
slot: 'rightLeg',
|
||||
description: 'Stand firm against any force. Your foundation is unshakeable.',
|
||||
capability: 'Increased stability. +100 max mana.',
|
||||
primaryManaType: 'stability',
|
||||
rawManaRegen: 0.35,
|
||||
autoConvertRate: 0.18,
|
||||
icon: 'Mountain',
|
||||
color: '#78716C', // Stone gray
|
||||
skills: {
|
||||
grounding: {
|
||||
name: 'Grounding',
|
||||
desc: 'Increased max mana and stability',
|
||||
cat: 'anchor',
|
||||
max: 10,
|
||||
base: 100,
|
||||
studyTime: 8,
|
||||
},
|
||||
endurance: {
|
||||
name: 'Endurance',
|
||||
desc: 'Reduced mana costs when below 50% mana',
|
||||
cat: 'anchor',
|
||||
max: 5,
|
||||
base: 200,
|
||||
studyTime: 12,
|
||||
},
|
||||
ironWill: {
|
||||
name: 'Iron Will',
|
||||
desc: 'Prevent mana drain effects',
|
||||
cat: 'anchor',
|
||||
max: 5,
|
||||
base: 250,
|
||||
studyTime: 15,
|
||||
req: { grounding: 5 },
|
||||
},
|
||||
stabilityMastery: {
|
||||
name: 'Stability Mastery',
|
||||
desc: 'Increased stability mana pool and regen',
|
||||
cat: 'anchor',
|
||||
max: 10,
|
||||
base: 250,
|
||||
studyTime: 15,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -1,30 +0,0 @@
|
||||
// ─── Attunement System ─────────────────────────────────────────────────
|
||||
// Attunements are powerful magical bonds tied to specific body locations
|
||||
// Each grants a unique capability, primary mana type, and skill tree
|
||||
|
||||
// Re-export types
|
||||
export type {
|
||||
AttunementSlot,
|
||||
AttunementType,
|
||||
AttunementDef,
|
||||
AttunementState,
|
||||
ManaType
|
||||
} from './types';
|
||||
|
||||
export {
|
||||
ATTUNEMENT_SLOTS,
|
||||
ATTUNEMENT_SLOT_NAMES
|
||||
} from './types';
|
||||
|
||||
// Re-export data
|
||||
export { ATTUNEMENTS } from './data';
|
||||
|
||||
// Re-export utils
|
||||
export {
|
||||
getAttunementForSlot,
|
||||
getStartingAttunement,
|
||||
isAttunementUnlocked,
|
||||
getTotalAttunementRegen,
|
||||
getManaTypeName,
|
||||
getManaTypeColor,
|
||||
} from './utils';
|
||||
@@ -1,100 +0,0 @@
|
||||
// ─── Attunement Types ─────────────────────────────────────────────────────────
|
||||
|
||||
export type AttunementSlot =
|
||||
| 'rightHand'
|
||||
| 'leftHand'
|
||||
| 'head'
|
||||
| 'back'
|
||||
| 'chest'
|
||||
| 'leftLeg'
|
||||
| 'rightLeg';
|
||||
|
||||
export const ATTUNEMENT_SLOTS: AttunementSlot[] = [
|
||||
'rightHand',
|
||||
'leftHand',
|
||||
'head',
|
||||
'back',
|
||||
'chest',
|
||||
'leftLeg',
|
||||
'rightLeg',
|
||||
];
|
||||
|
||||
// Slot display names
|
||||
export const ATTUNEMENT_SLOT_NAMES: Record<AttunementSlot, string> = {
|
||||
rightHand: 'Right Hand',
|
||||
leftHand: 'Left Hand',
|
||||
head: 'Head',
|
||||
back: 'Back',
|
||||
chest: 'Heart',
|
||||
leftLeg: 'Left Leg',
|
||||
rightLeg: 'Right Leg',
|
||||
};
|
||||
|
||||
// ─── Mana Types ───────────────────────────────────────────────────────────────
|
||||
|
||||
export type ManaType =
|
||||
// Primary mana types from attunements
|
||||
| 'transference' // Enchanter - moving/enchanting
|
||||
| 'form' // Caster - shaping spells
|
||||
| 'vision' // Seer - perception/revelation
|
||||
| 'barrier' // Warden - protection/defense
|
||||
| 'flow' // Strider - movement/swiftness
|
||||
| 'stability' // Anchor - grounding/endurance
|
||||
// Guardian pact types (Invoker)
|
||||
| 'fire'
|
||||
| 'water'
|
||||
| 'earth'
|
||||
| 'air'
|
||||
| 'light'
|
||||
| 'dark'
|
||||
| 'life'
|
||||
| 'death'
|
||||
// Raw mana
|
||||
| 'raw';
|
||||
|
||||
// ─── Attunement Types ─────────────────────────────────────────────────────────
|
||||
|
||||
export type AttunementType =
|
||||
| 'enchanter'
|
||||
| 'caster'
|
||||
| 'seer'
|
||||
| 'warden'
|
||||
| 'invoker'
|
||||
| 'strider'
|
||||
| 'anchor';
|
||||
|
||||
// ─── Attunement Definition ────────────────────────────────────────────────────
|
||||
|
||||
export interface AttunementDef {
|
||||
id: AttunementType;
|
||||
name: string;
|
||||
slot: AttunementSlot;
|
||||
description: string;
|
||||
capability: string; // What this attunement unlocks
|
||||
primaryManaType: ManaType | null; // null for Invoker (uses guardian types)
|
||||
rawManaRegen: number; // Base raw mana regen bonus
|
||||
autoConvertRate: number; // Raw mana -> primary mana per hour
|
||||
skills: Record<string, SkillDef>; // Attunement-specific skills
|
||||
icon: string; // Lucide icon name
|
||||
color: string; // Theme color
|
||||
}
|
||||
|
||||
// ─── Attunement State ─────────────────────────────────────────────────────────
|
||||
|
||||
export interface AttunementState {
|
||||
unlocked: boolean;
|
||||
level: number; // Attunement level (from challenges)
|
||||
manaPool: number; // Current primary mana
|
||||
maxMana: number; // Max primary mana pool
|
||||
}
|
||||
|
||||
// Skill definition (imported from types but re-defined here for clarity)
|
||||
export interface SkillDef {
|
||||
name: string;
|
||||
desc: string;
|
||||
cat: string;
|
||||
max: number;
|
||||
base: number;
|
||||
studyTime: number;
|
||||
req?: Record<string, number>;
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
// ─── Attunement Helper Functions ─────────────────────────
|
||||
|
||||
import type { AttunementSlot, AttunementType, AttunementState, ManaType, AttunementDef } from './types';
|
||||
import { ATTUNEMENTS } from './data';
|
||||
|
||||
/**
|
||||
* Get the attunement for a specific body slot
|
||||
*/
|
||||
export function getAttunementForSlot(slot: AttunementSlot): AttunementDef | undefined {
|
||||
return Object.values(ATTUNEMENTS).find(a => a.slot === slot) as AttunementDef | undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the starting attunement (Enchanter - right hand)
|
||||
*/
|
||||
export function getStartingAttunement(): AttunementDef {
|
||||
return ATTUNEMENTS.enchanter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an attunement is unlocked for the player
|
||||
*/
|
||||
export function isAttunementUnlocked(
|
||||
attunementStates: Record<AttunementType, AttunementState>,
|
||||
attunementType: AttunementType
|
||||
): boolean {
|
||||
return attunementStates[attunementType]?.unlocked ?? false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get total raw mana regen from all unlocked attunements
|
||||
*/
|
||||
export function getTotalAttunementRegen(
|
||||
attunementStates: Record<AttunementType, AttunementState>
|
||||
): number {
|
||||
let total = 0;
|
||||
for (const [type, state] of Object.entries(attunementStates)) {
|
||||
if (state.unlocked) {
|
||||
const def = ATTUNEMENTS[type as AttunementType];
|
||||
if (def) {
|
||||
total += def.rawManaRegen * (1 + state.level * 0.1); // +10% per level
|
||||
}
|
||||
}
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get mana type display name
|
||||
*/
|
||||
export function getManaTypeName(type: ManaType): string {
|
||||
const names: Record<ManaType, string> = {
|
||||
raw: 'Raw Mana',
|
||||
transference: 'Transference',
|
||||
form: 'Form',
|
||||
vision: 'Vision',
|
||||
barrier: 'Barrier',
|
||||
flow: 'Flow',
|
||||
stability: 'Stability',
|
||||
fire: 'Fire',
|
||||
water: 'Water',
|
||||
earth: 'Earth',
|
||||
air: 'Air',
|
||||
light: 'Light',
|
||||
dark: 'Dark',
|
||||
life: 'Life',
|
||||
death: 'Death',
|
||||
};
|
||||
return names[type] || type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get mana type color
|
||||
*/
|
||||
export function getManaTypeColor(type: ManaType): string {
|
||||
const colors: Record<ManaType, string> = {
|
||||
raw: '#A78BFA', // Light purple
|
||||
transference: '#8B5CF6', // Purple
|
||||
form: '#3B82F6', // Blue
|
||||
vision: '#F59E0B', // Amber
|
||||
barrier: '#10B981', // Green
|
||||
flow: '#06B6D4', // Cyan
|
||||
stability: '#78716C', // Stone
|
||||
fire: '#EF4444', // Red
|
||||
water: '#3B82F6', // Blue
|
||||
earth: '#A16207', // Brown
|
||||
air: '#94A3B8', // Slate
|
||||
light: '#FCD34D', // Yellow
|
||||
dark: '#6B7280', // Gray
|
||||
life: '#22C55E', // Green
|
||||
death: '#7C3AED', // Violet
|
||||
};
|
||||
return colors[type] || '#A78BFA';
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
// ─── Computed Stats and Utility Functions ───────────────────────────────────────
|
||||
// This module now re-exports from focused utility modules for better organization
|
||||
//
|
||||
// The functions have been split into:
|
||||
// - ./utils/formatting.ts - Number formatting (fmt, fmtDec)
|
||||
// - ./utils/floor-utils.ts - Floor functions (getFloorMaxHP, getFloorElement)
|
||||
// - ./utils/mana-utils.ts - Mana calculations (computeMaxMana, computeElementMax, etc.)
|
||||
// - ./utils/combat-utils.ts - Combat functions (calcDamage, calcInsight, getTotalDPS, etc.)
|
||||
//
|
||||
// All exports are maintained for backward compatibility.
|
||||
|
||||
export * from './utils/index';
|
||||
@@ -1,12 +0,0 @@
|
||||
|
||||
/**
|
||||
* Helper to get unified effects from game state
|
||||
*/
|
||||
export function getUnifiedEffects(state: Pick<GameState, 'skillUpgrades' | 'skillTiers' | 'equipmentInstances' | 'equippedInstances'>): UnifiedEffects {
|
||||
return computeAllEffects(
|
||||
state.skillUpgrades || {},
|
||||
state.skillTiers || {},
|
||||
state.equipmentInstances || {},
|
||||
state.equippedInstances || {}
|
||||
);
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
// ─── Shared Formatting Utilities ─────────────────────────────────────────────────
|
||||
// Utility functions for consistent formatting across components
|
||||
|
||||
import { ELEMENTS } from '@/lib/game/constants';
|
||||
import type { SpellCost } from '@/lib/game/types';
|
||||
|
||||
// Re-export number formatting functions from computed-stats.ts
|
||||
export { fmt, fmtDec } from './computed-stats';
|
||||
|
||||
/**
|
||||
* Format a spell cost for display
|
||||
*/
|
||||
export function formatSpellCost(cost: SpellCost): string {
|
||||
if (cost.type === 'raw') {
|
||||
return `${cost.amount} raw`;
|
||||
}
|
||||
const elemDef = ELEMENTS[cost.element || ''];
|
||||
return `${cost.amount} ${elemDef?.sym || '?'}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the display color for a spell cost
|
||||
*/
|
||||
export function getSpellCostColor(cost: SpellCost): string {
|
||||
if (cost.type === 'raw') {
|
||||
return '#60A5FA'; // Blue for raw mana
|
||||
}
|
||||
return ELEMENTS[cost.element || '']?.color || '#9CA3AF';
|
||||
}
|
||||
|
||||
/**
|
||||
* Format study time in hours to human-readable string
|
||||
*/
|
||||
export function formatStudyTime(hours: number): string {
|
||||
if (hours < 1) return `${Math.round(hours * 60)}m`;
|
||||
return `${hours.toFixed(1)}h`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format time (hour of day) to HH:MM format
|
||||
*/
|
||||
export function formatHour(hour: number): string {
|
||||
const h = Math.floor(hour);
|
||||
const m = Math.floor((hour % 1) * 60);
|
||||
return `${h.toString().padStart(2, '0')}:${m.toString().padStart(2, '0')}`;
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
// ─── Navigation Slice ─────────────────────────────────────────────────────────
|
||||
// Actions for floor navigation: climbing direction and manual floor changes
|
||||
|
||||
import type { GameState } from './types';
|
||||
import { getFloorMaxHP } from './computed-stats';
|
||||
|
||||
// ─── Navigation Actions Interface ─────────────────────────────────────────────
|
||||
|
||||
export interface NavigationActions {
|
||||
// Floor Navigation
|
||||
setClimbDirection: (direction: 'up' | 'down') => void;
|
||||
changeFloor: (direction: 'up' | 'down') => void;
|
||||
resetFloorHP: () => void;
|
||||
}
|
||||
|
||||
// ─── Navigation Slice Factory ─────────────────────────────────────────────────
|
||||
|
||||
export function createNavigationSlice(
|
||||
set: (partial: Partial<GameState> | ((state: GameState) => Partial<GameState>)) => void,
|
||||
get: () => GameState
|
||||
): NavigationActions {
|
||||
return {
|
||||
// Set the climbing direction (up or down)
|
||||
setClimbDirection: (direction: 'up' | 'down') => {
|
||||
set({ climbDirection: direction });
|
||||
},
|
||||
|
||||
// Manually change floors by one
|
||||
changeFloor: (direction: 'up' | 'down') => {
|
||||
const state = get();
|
||||
const currentFloor = state.currentFloor;
|
||||
|
||||
// Calculate next floor
|
||||
const nextFloor = direction === 'up'
|
||||
? Math.min(currentFloor + 1, 100)
|
||||
: Math.max(currentFloor - 1, 1);
|
||||
|
||||
// Can't stay on same floor
|
||||
if (nextFloor === currentFloor) return;
|
||||
|
||||
// Mark current floor as cleared (it will respawn when we come back)
|
||||
const clearedFloors = { ...state.clearedFloors };
|
||||
clearedFloors[currentFloor] = true;
|
||||
|
||||
// Check if next floor was cleared (needs respawn)
|
||||
const nextFloorCleared = clearedFloors[nextFloor];
|
||||
if (nextFloorCleared) {
|
||||
// Respawn the floor
|
||||
delete clearedFloors[nextFloor];
|
||||
}
|
||||
|
||||
set({
|
||||
currentFloor: nextFloor,
|
||||
floorMaxHP: getFloorMaxHP(nextFloor),
|
||||
floorHP: getFloorMaxHP(nextFloor),
|
||||
maxFloorReached: Math.max(state.maxFloorReached, nextFloor),
|
||||
clearedFloors,
|
||||
climbDirection: direction,
|
||||
equipmentSpellStates: state.equipmentSpellStates.map(s => ({ ...s, castProgress: 0 })),
|
||||
log: [`🚶 Moved to floor ${nextFloor}${nextFloorCleared ? ' (respawned)' : ''}.`, ...state.log.slice(0, 49)],
|
||||
});
|
||||
},
|
||||
|
||||
// Reset current floor HP to max (useful when floor HP gets stuck)
|
||||
resetFloorHP: () => {
|
||||
const state = get();
|
||||
const maxHP = getFloorMaxHP(state.currentFloor);
|
||||
set({
|
||||
floorMaxHP: maxHP,
|
||||
floorHP: maxHP,
|
||||
log: [`🔄 Floor ${state.currentFloor} HP reset to full.`, ...state.log.slice(0, 49)],
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -5,50 +5,36 @@
|
||||
import type { GameState, SpellCost, StudyTarget } from '../types';
|
||||
import type { ComputedEffects } from '../upgrade-effects.types';
|
||||
import type { UnifiedEffects } from '../effects';
|
||||
import { SPELLS_DEF, GUARDIANS, ELEMENT_OPPOSITES, SKILLS_DEF, HOURS_PER_TICK, TICK_MS, INCURSION_START_DAY, MAX_DAY, ELEMENTS } from '../constants';
|
||||
import { SPELLS_DEF, GUARDIANS, ELEMENT_OPPOSITES, HOURS_PER_TICK, TICK_MS, INCURSION_START_DAY, MAX_DAY, ELEMENTS } from '../constants';
|
||||
import { getUnifiedEffects } from '../effects';
|
||||
import { getTotalAttunementRegen, getTotalAttunementConversionDrain } from '../data/attunements';
|
||||
import { hasSpecial, SPECIAL_EFFECTS } from '../special-effects';
|
||||
|
||||
// Helper to get effective skill level accounting for tiers
|
||||
function getEffectiveSkillLevel(
|
||||
skills: Record<string, number>,
|
||||
baseSkillId: string,
|
||||
skillTiers: Record<string, number> = {}
|
||||
): { level: number; tier: number; tierMultiplier: number } {
|
||||
const currentTier = skillTiers[baseSkillId] || 1;
|
||||
const tieredSkillId = currentTier > 1 ? `${baseSkillId}_t${currentTier}` : baseSkillId;
|
||||
const level = skills[tieredSkillId] || skills[baseSkillId] || 0;
|
||||
const tierMultiplier = Math.pow(10, currentTier - 1);
|
||||
return { level, tier: currentTier, tierMultiplier };
|
||||
}
|
||||
|
||||
export function computeMaxMana(
|
||||
state: GameState,
|
||||
effects?: ComputedEffects | UnifiedEffects
|
||||
): number {
|
||||
const pu = state.prestigeUpgrades;
|
||||
const skillMult = (effects as any)?.skillLevelMultiplier || 1;
|
||||
const base = 100 + ((state.skills || {}).manaWell || 0) * 100 * skillMult + ((pu || {}).manaWell || 0) * 500;
|
||||
|
||||
const base = 100 + ((pu || {}).manaWell || 0) * 500;
|
||||
|
||||
// Check if we need to compute effects from equipment
|
||||
if (!effects && state.equipmentInstances && state.equippedInstances) {
|
||||
effects = getUnifiedEffects(state as any);
|
||||
}
|
||||
|
||||
|
||||
let maxMana: number;
|
||||
if (effects) {
|
||||
maxMana = Math.floor((base + effects.maxManaBonus) * effects.maxManaMultiplier);
|
||||
} else {
|
||||
maxMana = base;
|
||||
}
|
||||
|
||||
|
||||
if (effects && hasSpecial(effects, SPECIAL_EFFECTS.MANA_CONDENSE)) {
|
||||
const totalGathered = state.totalManaGathered || 0;
|
||||
const condensesBonus = Math.floor(totalGathered / 1000);
|
||||
maxMana = Math.floor(maxMana * (1 + condensesBonus * 0.01));
|
||||
}
|
||||
|
||||
|
||||
return maxMana;
|
||||
}
|
||||
|
||||
@@ -58,15 +44,15 @@ export function computeElementMax(
|
||||
element?: string
|
||||
): number {
|
||||
const pu = state.prestigeUpgrades;
|
||||
const base = 10 + (state.skills.elemAttune || 0) * 50 + (pu.elementalAttune || 0) * 25;
|
||||
|
||||
const base = 10 + (pu.elementalAttune || 0) * 25;
|
||||
|
||||
let adjustedBase = base;
|
||||
if (element && state.unlockedManaTypeUpgrades) {
|
||||
const typeUpgrades = state.unlockedManaTypeUpgrades.filter(u => u.typeId === element);
|
||||
const totalLevels = typeUpgrades.reduce((sum, u) => sum + u.level, 0);
|
||||
adjustedBase = base + (totalLevels * 10);
|
||||
}
|
||||
|
||||
|
||||
if (effects) {
|
||||
let bonus = effects.elementCapBonus || 0;
|
||||
if (element && (effects as UnifiedEffects).perElementCapBonus) {
|
||||
@@ -86,17 +72,16 @@ export function computeRegen(
|
||||
): number {
|
||||
const pu = state.prestigeUpgrades;
|
||||
const temporalBonus = 1 + (pu.temporalEcho || 0) * 0.1;
|
||||
const skillMult = (effects as any)?.skillLevelMultiplier || 1;
|
||||
const base = 2 + (state.skills.manaFlow || 0) * 1 * skillMult + (state.skills.manaSpring || 0) * 2 * skillMult + (pu.manaFlow || 0) * 0.5;
|
||||
|
||||
const base = 2 + (pu.manaFlow || 0) * 0.5;
|
||||
|
||||
let regen = base * temporalBonus;
|
||||
const attunementRegen = getTotalAttunementRegen(state.attunements || {});
|
||||
regen += attunementRegen;
|
||||
|
||||
|
||||
if (!effects && state.equipmentInstances && state.equippedInstances) {
|
||||
effects = getUnifiedEffects(state as any);
|
||||
}
|
||||
|
||||
|
||||
if (effects) {
|
||||
regen = (regen + effects.regenBonus + effects.permanentRegenBonus) * effects.regenMultiplier;
|
||||
}
|
||||
@@ -127,13 +112,12 @@ export function computeClickMana(
|
||||
state: GameState,
|
||||
effects?: ComputedEffects | UnifiedEffects
|
||||
): number {
|
||||
const skillMult = (effects as any)?.skillLevelMultiplier || 1;
|
||||
const base = 1 + (state.skills.manaTap || 0) * 1 * skillMult + (state.skills.manaSurge || 0) * 3 * skillMult;
|
||||
|
||||
const base = 1;
|
||||
|
||||
if (!effects && state.equipmentInstances && state.equippedInstances) {
|
||||
effects = getUnifiedEffects(state as any);
|
||||
}
|
||||
|
||||
|
||||
if (effects) {
|
||||
return Math.floor((base + effects.clickManaBonus) * effects.clickManaMultiplier);
|
||||
}
|
||||
@@ -156,14 +140,12 @@ export function calcDamage(
|
||||
): number {
|
||||
const sp = SPELLS_DEF[spellId];
|
||||
if (!sp) return 5;
|
||||
const skills = state.skills;
|
||||
const skillMult = (effects as any)?.skillLevelMultiplier || 1;
|
||||
const baseDmg = sp.dmg + (skills.combatTrain || 0) * 5 * skillMult;
|
||||
const pct = 1 + (skills.arcaneFury || 0) * 0.1 * skillMult;
|
||||
const elemMasteryBonus = 1 + (skills.elementalMastery || 0) * 0.15 * skillMult;
|
||||
const critChance = (skills.precision || 0) * 0.05;
|
||||
const baseDmg = sp.dmg;
|
||||
const pct = 1;
|
||||
const elemMasteryBonus = 1;
|
||||
const critChance = 0;
|
||||
const pactMult = state.signedPacts.reduce((m, f) => m * ((GUARDIANS as any)[f]?.pact || 1), 1);
|
||||
|
||||
|
||||
let damage = baseDmg * pct * pactMult * elemMasteryBonus;
|
||||
if (floorElem) {
|
||||
damage *= getElementalBonus(sp.elem, floorElem);
|
||||
@@ -176,20 +158,13 @@ export function calcDamage(
|
||||
|
||||
export function calcInsight(state: Pick<GameState, 'maxFloorReached' | 'totalManaGathered' | 'signedPacts' | 'prestigeUpgrades' | 'skills'>): number {
|
||||
const pu = state.prestigeUpgrades;
|
||||
const skillBonus = 1 + (state.skills.insightHarvest || 0) * 0.1;
|
||||
const mult = (1 + (pu.insightAmp || 0) * 0.25) * skillBonus;
|
||||
const mult = (1 + (pu.insightAmp || 0) * 0.25);
|
||||
return Math.floor((state.maxFloorReached * 15 + state.totalManaGathered / 500 + state.signedPacts.length * 150) * mult);
|
||||
}
|
||||
|
||||
export function getMeditationBonus(meditateTicks: number, skills: Record<string, number>, meditationEfficiency: number = 1): number {
|
||||
const hasMeditation = skills.meditation === 1;
|
||||
const hasDeepTrance = skills.deepTrance === 1;
|
||||
const hasVoidMeditation = skills.voidMeditation === 1;
|
||||
export function getMeditationBonus(meditateTicks: number, meditationEfficiency: number = 1): number {
|
||||
const hours = meditateTicks * HOURS_PER_TICK;
|
||||
let bonus = 1 + Math.min(hours / 4, 0.5);
|
||||
if (hasMeditation && hours >= 4) bonus = 2.5;
|
||||
if (hasDeepTrance && hours >= 6) bonus = 3.0;
|
||||
if (hasVoidMeditation && hours >= 8) bonus = 5.0;
|
||||
bonus *= meditationEfficiency;
|
||||
return bonus;
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
// ─── Store Module Exports ─────────────────────────────────────────────────────
|
||||
// Re-exports from main store and adds new computed utilities
|
||||
// This allows gradual migration while keeping existing functionality
|
||||
|
||||
// Re-export everything from the main store
|
||||
export * from '../store';
|
||||
|
||||
// Export new computed utilities
|
||||
export * from './computed';
|
||||
@@ -10,7 +10,6 @@ import { usePrestigeStore } from './prestigeStore';
|
||||
export function processCombatTick(
|
||||
get: () => CombatState,
|
||||
set: (state: Partial<CombatState>) => void,
|
||||
skills: Record<string, number>,
|
||||
rawMana: number,
|
||||
elements: Record<string, { current: number; max: number; unlocked: boolean }>,
|
||||
maxMana: number,
|
||||
@@ -36,9 +35,8 @@ export function processCombatTick(
|
||||
return { rawMana, elements, logMessages, totalManaGathered };
|
||||
}
|
||||
|
||||
// Calculate cast speed
|
||||
const baseAttackSpeed = 1 + (skills.quickCast || 0) * 0.05;
|
||||
const totalAttackSpeed = baseAttackSpeed * attackSpeedMult;
|
||||
// Calculate cast speed (no skill bonus)
|
||||
const totalAttackSpeed = attackSpeedMult;
|
||||
const spellCastSpeed = spellDef.castSpeed || 1;
|
||||
const progressPerTick = HOURS_PER_TICK * spellCastSpeed * totalAttackSpeed;
|
||||
|
||||
@@ -58,12 +56,12 @@ export function processCombatTick(
|
||||
// Calculate base damage
|
||||
const floorElement = getFloorElement(currentFloor);
|
||||
const damage = calcDamage(
|
||||
{ skills, signedPacts: usePrestigeStore.getState().signedPacts },
|
||||
{ skills: {}, signedPacts: usePrestigeStore.getState().signedPacts },
|
||||
spellId,
|
||||
floorElement,
|
||||
);
|
||||
|
||||
// Let gameStore apply damage modifiers (executioner, berserker, spell echo)
|
||||
// Let gameStore apply damage modifiers (executioner, berserker)
|
||||
const result = onDamageDealt(damage);
|
||||
rawMana = result.rawMana;
|
||||
elements = result.elements;
|
||||
@@ -114,7 +112,7 @@ export function processCombatTick(
|
||||
// Calculate damage
|
||||
const eFloorElement = getFloorElement(currentFloor);
|
||||
const eDamage = calcDamage(
|
||||
{ skills, signedPacts: usePrestigeStore.getState().signedPacts },
|
||||
{ skills: {}, signedPacts: usePrestigeStore.getState().signedPacts },
|
||||
eSpell.spellId,
|
||||
eFloorElement,
|
||||
);
|
||||
@@ -151,11 +149,11 @@ export function makeInitialSpells(spellsToKeep: string[] = []): Record<string, S
|
||||
const startSpells: Record<string, SpellState> = {
|
||||
manaBolt: { learned: true, level: 1, studyProgress: 0 },
|
||||
};
|
||||
|
||||
|
||||
// Add kept spells
|
||||
for (const spellId of spellsToKeep) {
|
||||
startSpells[spellId] = { learned: true, level: 1, studyProgress: 0 };
|
||||
}
|
||||
|
||||
|
||||
return startSpells;
|
||||
}
|
||||
|
||||
@@ -17,60 +17,60 @@ export interface CombatState {
|
||||
floorHP: number;
|
||||
floorMaxHP: number;
|
||||
maxFloorReached: number;
|
||||
|
||||
|
||||
// Action state
|
||||
activeSpell: string;
|
||||
currentAction: GameAction;
|
||||
castProgress: number;
|
||||
|
||||
|
||||
// Spire mode
|
||||
spireMode: boolean;
|
||||
|
||||
|
||||
// Room system for special floors
|
||||
currentRoom: FloorState;
|
||||
|
||||
|
||||
// Spire climbing state
|
||||
clearedFloors: Record<number, boolean>;
|
||||
climbDirection: 'up' | 'down' | null;
|
||||
isDescending: boolean;
|
||||
|
||||
|
||||
// Golemancy (summoned golems)
|
||||
golemancy: GolemancyState;
|
||||
|
||||
|
||||
// Equipment spell states for multi-casting
|
||||
equipmentSpellStates: EquipmentSpellState[];
|
||||
|
||||
|
||||
// Combat special effect tracking
|
||||
comboHitCount: number;
|
||||
floorHitCount: number;
|
||||
|
||||
|
||||
// Spells
|
||||
spells: Record<string, SpellState>;
|
||||
|
||||
|
||||
// Activity Log (for Spire Mode UI)
|
||||
activityLog: ActivityLogEntry[];
|
||||
|
||||
|
||||
// Achievements
|
||||
achievements: AchievementState;
|
||||
|
||||
|
||||
// Stats tracking
|
||||
totalSpellsCast: number;
|
||||
totalDamageDealt: number;
|
||||
totalCraftsCompleted: number;
|
||||
|
||||
|
||||
// Actions
|
||||
setCurrentFloor: (floor: number) => void;
|
||||
advanceFloor: () => void;
|
||||
setFloorHP: (hp: number) => void;
|
||||
setMaxFloorReached: (floor: number) => void;
|
||||
|
||||
|
||||
setAction: (action: GameAction) => void;
|
||||
setSpell: (spellId: string) => void;
|
||||
setCastProgress: (progress: number) => void;
|
||||
|
||||
|
||||
// Room state
|
||||
setCurrentRoom: (room: FloorState) => void;
|
||||
|
||||
|
||||
// Spire climbing
|
||||
setClimbDirection: (direction: 'up' | 'down' | null) => void;
|
||||
setClearedFloor: (floor: number, cleared: boolean) => void;
|
||||
@@ -79,29 +79,28 @@ export interface CombatState {
|
||||
exitSpireMode: () => void;
|
||||
startClimbUp: () => void;
|
||||
startClimbDown: () => void;
|
||||
|
||||
|
||||
// Golemancy
|
||||
toggleGolem: (golemId: string) => void;
|
||||
setEnabledGolems: (golemIds: string[]) => void;
|
||||
|
||||
|
||||
// Spells
|
||||
learnSpell: (spellId: string) => void;
|
||||
setSpellState: (spellId: string, state: Partial<SpellState>) => void;
|
||||
|
||||
|
||||
// Activity Log
|
||||
addActivityLog: (eventType: ActivityEventType, message: string, details?: ActivityLogEntry['details']) => void;
|
||||
|
||||
|
||||
// Stats
|
||||
incrementSpellsCast: () => void;
|
||||
addDamageDealt: (damage: number) => void;
|
||||
incrementCraftsCompleted: () => void;
|
||||
|
||||
|
||||
// Spire mode
|
||||
enterSpireMode: () => void;
|
||||
|
||||
|
||||
// Combat tick
|
||||
processCombatTick: (
|
||||
skills: Record<string, number>,
|
||||
rawMana: number,
|
||||
elements: Record<string, { current: number; max: number; unlocked: boolean }>,
|
||||
maxMana: number,
|
||||
@@ -109,10 +108,10 @@ export interface CombatState {
|
||||
onFloorCleared: (floor: number, wasGuardian: boolean) => void,
|
||||
onDamageDealt: (damage: number) => { rawMana: number; elements: Record<string, { current: number; max: number; unlocked: boolean }> },
|
||||
) => { rawMana: number; elements: Record<string, { current: number; max: number; unlocked: boolean }>; logMessages: string[]; totalManaGathered: number };
|
||||
|
||||
|
||||
// Reset
|
||||
resetCombat: (startFloor: number, spellsToKeep?: string[]) => void;
|
||||
|
||||
|
||||
// Debug helpers
|
||||
debugSetFloor: (floor: number) => void;
|
||||
resetFloorHP: () => void;
|
||||
@@ -130,48 +129,48 @@ export const useCombatStore = create<CombatState>()(
|
||||
currentAction: 'meditate',
|
||||
castProgress: 0,
|
||||
spireMode: false,
|
||||
|
||||
|
||||
// Room system
|
||||
currentRoom: generateFloorState(1),
|
||||
|
||||
|
||||
// Spire climbing state
|
||||
clearedFloors: {},
|
||||
climbDirection: null,
|
||||
isDescending: false,
|
||||
|
||||
|
||||
// Golemancy
|
||||
golemancy: {
|
||||
enabledGolems: [],
|
||||
summonedGolems: [],
|
||||
lastSummonFloor: 0,
|
||||
},
|
||||
|
||||
|
||||
// Equipment spell states
|
||||
equipmentSpellStates: [],
|
||||
|
||||
|
||||
// Combat tracking
|
||||
comboHitCount: 0,
|
||||
floorHitCount: 0,
|
||||
|
||||
|
||||
// Spells
|
||||
spells: {
|
||||
manaBolt: { learned: true, level: 1, studyProgress: 0 },
|
||||
},
|
||||
|
||||
|
||||
// Activity Log
|
||||
activityLog: [],
|
||||
|
||||
|
||||
// Achievements
|
||||
achievements: {
|
||||
unlocked: [],
|
||||
progress: {},
|
||||
},
|
||||
|
||||
|
||||
// Stats tracking
|
||||
totalSpellsCast: 0,
|
||||
totalDamageDealt: 0,
|
||||
totalCraftsCompleted: 0,
|
||||
|
||||
|
||||
setCurrentFloor: (floor: number) => {
|
||||
set({
|
||||
currentFloor: floor,
|
||||
@@ -179,7 +178,7 @@ export const useCombatStore = create<CombatState>()(
|
||||
floorMaxHP: getFloorMaxHP(floor),
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
advanceFloor: () => {
|
||||
set((state) => {
|
||||
const newFloor = Math.min(state.currentFloor + 1, 100);
|
||||
@@ -192,52 +191,52 @@ export const useCombatStore = create<CombatState>()(
|
||||
};
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
setFloorHP: (hp: number) => {
|
||||
set({ floorHP: Math.max(0, hp) });
|
||||
},
|
||||
|
||||
|
||||
setMaxFloorReached: (floor: number) => {
|
||||
set((state) => ({
|
||||
maxFloorReached: Math.max(state.maxFloorReached, floor),
|
||||
}));
|
||||
},
|
||||
|
||||
|
||||
setAction: (action: GameAction) => {
|
||||
set({ currentAction: action });
|
||||
},
|
||||
|
||||
|
||||
setSpell: (spellId: string) => {
|
||||
const state = get();
|
||||
if (state.spells[spellId]?.learned) {
|
||||
set({ activeSpell: spellId });
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
setCastProgress: (progress: number) => {
|
||||
set({ castProgress: progress });
|
||||
},
|
||||
|
||||
|
||||
// Room state
|
||||
setCurrentRoom: (room: FloorState) => {
|
||||
set({ currentRoom: room });
|
||||
},
|
||||
|
||||
|
||||
// Spire climbing
|
||||
setClimbDirection: (direction: 'up' | 'down' | null) => {
|
||||
set({ climbDirection: direction });
|
||||
},
|
||||
|
||||
|
||||
setClearedFloor: (floor: number, cleared: boolean) => {
|
||||
set((state) => ({
|
||||
clearedFloors: { ...state.clearedFloors, [floor]: cleared },
|
||||
}));
|
||||
},
|
||||
|
||||
|
||||
setIsDescending: (descending: boolean) => {
|
||||
set({ isDescending: descending });
|
||||
},
|
||||
|
||||
|
||||
climbDownFloor: () => {
|
||||
set((s) => {
|
||||
if (s.currentFloor <= 1) return s;
|
||||
@@ -251,41 +250,41 @@ export const useCombatStore = create<CombatState>()(
|
||||
};
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
exitSpireMode: () => {
|
||||
set({ spireMode: false, currentAction: 'meditate', climbDirection: null, isDescending: false });
|
||||
},
|
||||
|
||||
|
||||
startClimbUp: () => set({ climbDirection: 'up', currentAction: 'climb' }),
|
||||
|
||||
|
||||
startClimbDown: () => set({ climbDirection: 'down', currentAction: 'climb' }),
|
||||
|
||||
|
||||
// Golemancy
|
||||
toggleGolem: (golemId: string) => {
|
||||
set((s) => {
|
||||
const enabledGolems = s.golemancy?.enabledGolems || [];
|
||||
const isEnabled = enabledGolems.includes(golemId);
|
||||
return {
|
||||
golemancy: {
|
||||
...s.golemancy,
|
||||
enabledGolems: isEnabled
|
||||
? enabledGolems.filter(id => id !== golemId)
|
||||
: [...enabledGolems, golemId]
|
||||
golemancy: {
|
||||
...s.golemancy,
|
||||
enabledGolems: isEnabled
|
||||
? enabledGolems.filter(id => id !== golemId)
|
||||
: [...enabledGolems, golemId]
|
||||
},
|
||||
};
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
setEnabledGolems: (golemIds: string[]) => {
|
||||
set((s) => ({
|
||||
golemancy: { ...s.golemancy, enabledGolems: golemIds },
|
||||
}));
|
||||
},
|
||||
|
||||
|
||||
enterSpireMode: () => {
|
||||
set({ spireMode: true });
|
||||
},
|
||||
|
||||
|
||||
learnSpell: (spellId: string) => {
|
||||
set((state) => ({
|
||||
spells: {
|
||||
@@ -294,7 +293,7 @@ export const useCombatStore = create<CombatState>()(
|
||||
},
|
||||
}));
|
||||
},
|
||||
|
||||
|
||||
setSpellState: (spellId: string, spellState: Partial<SpellState>) => {
|
||||
set((state) => ({
|
||||
spells: {
|
||||
@@ -303,29 +302,28 @@ export const useCombatStore = create<CombatState>()(
|
||||
},
|
||||
}));
|
||||
},
|
||||
|
||||
|
||||
// Activity Log
|
||||
addActivityLog: (eventType: ActivityEventType, message: string, details?: ActivityLogEntry['details']) => {
|
||||
set((state) => ({
|
||||
activityLog: addActivityLogEntry(state, eventType, message, details),
|
||||
}));
|
||||
},
|
||||
|
||||
|
||||
// Stats
|
||||
incrementSpellsCast: () => {
|
||||
set((state) => ({ totalSpellsCast: state.totalSpellsCast + 1 }));
|
||||
},
|
||||
|
||||
|
||||
addDamageDealt: (damage: number) => {
|
||||
set((state) => ({ totalDamageDealt: state.totalDamageDealt + damage }));
|
||||
},
|
||||
|
||||
|
||||
incrementCraftsCompleted: () => {
|
||||
set((state) => ({ totalCraftsCompleted: state.totalCraftsCompleted + 1 }));
|
||||
},
|
||||
|
||||
|
||||
processCombatTick: (
|
||||
skills: Record<string, number>,
|
||||
rawMana: number,
|
||||
elements: Record<string, { current: number; max: number; unlocked: boolean }>,
|
||||
maxMana: number,
|
||||
@@ -336,7 +334,6 @@ export const useCombatStore = create<CombatState>()(
|
||||
return processCombatTick(
|
||||
get,
|
||||
set,
|
||||
skills,
|
||||
rawMana,
|
||||
elements,
|
||||
maxMana,
|
||||
@@ -345,10 +342,10 @@ export const useCombatStore = create<CombatState>()(
|
||||
onDamageDealt,
|
||||
);
|
||||
},
|
||||
|
||||
|
||||
resetCombat: (startFloor: number, spellsToKeep: string[] = []) => {
|
||||
const startSpells = makeInitialSpells(spellsToKeep);
|
||||
|
||||
|
||||
set({
|
||||
currentFloor: startFloor,
|
||||
floorHP: getFloorMaxHP(startFloor),
|
||||
@@ -360,7 +357,7 @@ export const useCombatStore = create<CombatState>()(
|
||||
spells: startSpells,
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
// Debug helpers
|
||||
debugSetFloor: (floor: number) => {
|
||||
set({
|
||||
@@ -369,13 +366,13 @@ export const useCombatStore = create<CombatState>()(
|
||||
floorMaxHP: getFloorMaxHP(floor),
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
resetFloorHP: () => {
|
||||
set((state) => ({
|
||||
floorHP: state.floorMaxHP,
|
||||
}));
|
||||
},
|
||||
|
||||
|
||||
debugSetTime: (day: number, hour: number) => {
|
||||
useGameStore.setState({ day, hour });
|
||||
},
|
||||
@@ -386,7 +383,7 @@ export const useCombatStore = create<CombatState>()(
|
||||
currentFloor: state.currentFloor,
|
||||
maxFloorReached: state.maxFloorReached,
|
||||
spells: state.spells,
|
||||
activeSpell: state.activeSpell,
|
||||
activeSpell: state.activeAction,
|
||||
}),
|
||||
}
|
||||
)
|
||||
|
||||
@@ -1,28 +1,14 @@
|
||||
// ─── Crafting Store ─────────────────────────────────────────────────────
|
||||
// Handles equipment crafting, enchantment design, and crafting progress
|
||||
// This is a modular store that manages all crafting-related state
|
||||
|
||||
import { create } from 'zustand';
|
||||
import { persist } from 'zustand/middleware';
|
||||
import type { DesignProgress, PreparationProgress, ApplicationProgress, EquipmentCraftingProgress, EnchantmentDesign, EquipmentInstance, DesignEffect } from '../types';
|
||||
|
||||
// Import crafting modules for action logic
|
||||
import * as CraftingUtils from '../crafting-utils';
|
||||
import * as CraftingDesign from '../crafting-design';
|
||||
import { computeEffects } from '../upgrade-effects';
|
||||
import { hasSpecial, SPECIAL_EFFECTS } from '../special-effects';
|
||||
|
||||
// Import other stores to access required state
|
||||
import { useSkillStore } from './skillStore';
|
||||
import { useGameStore } from './gameStore';
|
||||
import { useManaStore } from './manaStore';
|
||||
import { useCombatStore } from './combatStore';
|
||||
import { createStartingEquipment } from '../store/crafting-modules/starting-equipment';
|
||||
import { createStartingEquipment } from '../crafting-slice';
|
||||
import { useUIStore } from './uiStore';
|
||||
|
||||
// Import action modules
|
||||
import * as ApplicationActions from '../crafting-actions/application-actions';
|
||||
import * as CraftingApply from '../crafting-apply';
|
||||
import * as PreparationActions from '../crafting-actions/preparation-actions';
|
||||
import * as CraftingEquipment from '../crafting-equipment';
|
||||
|
||||
@@ -142,25 +128,18 @@ export const useCraftingStore = create<CraftingStore>()(
|
||||
|
||||
// Enchantment design actions
|
||||
startDesigningEnchantment: (name, equipmentTypeId, effects) => {
|
||||
// Get state from other stores
|
||||
const skillState = useSkillStore.getState();
|
||||
const state = get(); // crafting state
|
||||
|
||||
const enchantingLevel = skillState.skills?.enchanting || 0;
|
||||
const validation = CraftingDesign.validateDesignEffects(effects, equipmentTypeId, enchantingLevel);
|
||||
const validation = CraftingDesign.validateDesignEffects(effects, equipmentTypeId, 0);
|
||||
if (!validation.valid) return false;
|
||||
|
||||
const equipType = CraftingUtils.getEquipmentType(equipmentTypeId);
|
||||
if (!equipType) return false;
|
||||
|
||||
const efficiencyBonus = (skillState.skillUpgrades?.['efficientEnchant'] || []).length * 0.05 || 0;
|
||||
const totalCapacityCost = CraftingDesign.calculateDesignCapacityCost(effects, efficiencyBonus);
|
||||
const totalCapacityCost = CraftingDesign.calculateDesignCapacityCost(effects, 0);
|
||||
|
||||
if (totalCapacityCost > equipType.baseCapacity) return false;
|
||||
|
||||
const computedEffects = computeEffects(skillState.skillUpgrades || {}, skillState.skillTiers || {});
|
||||
const hasEnchantMastery = hasSpecial(computedEffects, SPECIAL_EFFECTS.ENCHANT_MASTERY);
|
||||
|
||||
let updates: Partial<CraftingState> = {};
|
||||
|
||||
if (!state.designProgress) {
|
||||
@@ -176,17 +155,6 @@ export const useCraftingStore = create<CraftingStore>()(
|
||||
};
|
||||
// Update currentAction in combatStore
|
||||
useCombatStore.setState({ currentAction: 'design' });
|
||||
} else if (hasEnchantMastery && !state.designProgress2) {
|
||||
updates = {
|
||||
designProgress2: {
|
||||
designId: CraftingUtils.generateDesignId(),
|
||||
progress: 0,
|
||||
required: CraftingDesign.calculateDesignTime(effects),
|
||||
name,
|
||||
equipmentType: equipmentTypeId,
|
||||
effects,
|
||||
},
|
||||
};
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import { computeMaxMana } from '../utils';
|
||||
import { computeEffects } from '../upgrade-effects';
|
||||
import { useUIStore } from './uiStore';
|
||||
import { usePrestigeStore } from './prestigeStore';
|
||||
import { useManaStore } from './manaStore';
|
||||
import { useSkillStore } from './skillStore';
|
||||
import { useCombatStore } from './combatStore';
|
||||
|
||||
export const createResetGame = (set: (state: any) => void, initialState: any) => () => {
|
||||
@@ -12,7 +10,6 @@ export const createResetGame = (set: (state: any) => void, initialState: any) =>
|
||||
localStorage.removeItem('mana-loop-ui-storage');
|
||||
localStorage.removeItem('mana-loop-prestige-storage');
|
||||
localStorage.removeItem('mana-loop-mana-storage');
|
||||
localStorage.removeItem('mana-loop-skill-storage');
|
||||
localStorage.removeItem('mana-loop-combat-storage');
|
||||
localStorage.removeItem('mana-loop-game-storage');
|
||||
localStorage.removeItem('mana-loop-crafting-storage');
|
||||
@@ -24,7 +21,6 @@ export const createResetGame = (set: (state: any) => void, initialState: any) =>
|
||||
useUIStore.getState().resetUI();
|
||||
usePrestigeStore.getState().resetPrestige();
|
||||
useManaStore.getState().resetMana({}, {}, {}, {});
|
||||
useSkillStore.getState().resetSkills();
|
||||
useCombatStore.getState().resetCombat(startFloor);
|
||||
|
||||
set({
|
||||
@@ -34,28 +30,20 @@ export const createResetGame = (set: (state: any) => void, initialState: any) =>
|
||||
};
|
||||
|
||||
export const createGatherMana = () => () => {
|
||||
const skillState = useSkillStore.getState();
|
||||
const manaState = useManaStore.getState();
|
||||
const prestigeState = usePrestigeStore.getState();
|
||||
|
||||
// Compute click mana
|
||||
let cm = 1 +
|
||||
(skillState.skills.manaTap || 0) * 1 +
|
||||
(skillState.skills.manaSurge || 0) * 3;
|
||||
// Base click mana (no skill bonuses)
|
||||
const cm = 1;
|
||||
|
||||
// Mana overflow bonus
|
||||
const overflowBonus = 1 + (skillState.skills.manaOverflow || 0) * 0.25;
|
||||
cm = Math.floor(cm * overflowBonus);
|
||||
|
||||
const effects = computeEffects(skillState.skillUpgrades || {}, skillState.skillTiers || {});
|
||||
const max = computeMaxMana(
|
||||
{
|
||||
skills: skillState.skills,
|
||||
prestigeUpgrades: prestigeState.prestigeUpgrades,
|
||||
skillUpgrades: skillState.skillUpgrades,
|
||||
skillTiers: skillState.skillTiers
|
||||
{
|
||||
skills: {},
|
||||
prestigeUpgrades: prestigeState.prestigeUpgrades,
|
||||
skillUpgrades: {},
|
||||
skillTiers: {}
|
||||
},
|
||||
effects
|
||||
undefined
|
||||
);
|
||||
|
||||
useManaStore.getState().gatherMana(cm, max);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { useEffect } from 'react';
|
||||
import { useGameStore } from './gameStore';
|
||||
import { useManaStore } from './manaStore';
|
||||
import { useSkillStore } from './skillStore';
|
||||
import { usePrestigeStore } from './prestigeStore';
|
||||
import { useCombatStore } from './combatStore';
|
||||
import { useUIStore } from './uiStore';
|
||||
@@ -28,17 +27,15 @@ export function useGameLoop() {
|
||||
// ─── Shared Selector Hooks for Common Derived State ────────────────────────────
|
||||
|
||||
/**
|
||||
* Get unified effects from all relevant stores
|
||||
* Get unified effects from equipment only (skills removed)
|
||||
*/
|
||||
export function useUnifiedEffects() {
|
||||
const skillUpgrades = useSkillStore((s) => s.skillUpgrades);
|
||||
const skillTiers = useSkillStore((s) => s.skillTiers);
|
||||
const equippedInstances = useCraftingStore((s) => s.equippedInstances);
|
||||
const equipmentInstances = useCraftingStore((s) => s.equipmentInstances);
|
||||
|
||||
return getUnifiedEffects({
|
||||
skillUpgrades,
|
||||
skillTiers,
|
||||
skillUpgrades: {},
|
||||
skillTiers: {},
|
||||
equippedInstances,
|
||||
equipmentInstances,
|
||||
});
|
||||
@@ -48,10 +45,7 @@ export function useUnifiedEffects() {
|
||||
* Get computed mana stats (maxMana, baseRegen, clickMana, meditationMultiplier, effectiveRegen)
|
||||
*/
|
||||
export function useManaStats() {
|
||||
const skills = useSkillStore((s) => s.skills);
|
||||
const prestigeUpgrades = usePrestigeStore((s) => s.prestigeUpgrades);
|
||||
const skillUpgrades = useSkillStore((s) => s.skillUpgrades);
|
||||
const skillTiers = useSkillStore((s) => s.skillTiers);
|
||||
const meditateTicks = useManaStore((s) => s.meditateTicks);
|
||||
const day = useGameStore((s) => s.day);
|
||||
const hour = useGameStore((s) => s.hour);
|
||||
@@ -59,30 +53,27 @@ export function useManaStats() {
|
||||
const equipmentInstances = useCraftingStore((s) => s.equipmentInstances);
|
||||
|
||||
const upgradeEffects = getUnifiedEffects({
|
||||
skillUpgrades,
|
||||
skillTiers,
|
||||
skillUpgrades: {},
|
||||
skillTiers: {},
|
||||
equippedInstances,
|
||||
equipmentInstances,
|
||||
});
|
||||
|
||||
const maxMana = computeMaxMana(
|
||||
{ skills, prestigeUpgrades, skillUpgrades, skillTiers },
|
||||
{ skills: {}, prestigeUpgrades, skillUpgrades: {}, skillTiers: {} },
|
||||
upgradeEffects
|
||||
);
|
||||
|
||||
const baseRegen = computeRegen(
|
||||
{ skills, prestigeUpgrades, skillUpgrades, skillTiers },
|
||||
{ skills: {}, prestigeUpgrades, skillUpgrades: {}, skillTiers: {} },
|
||||
upgradeEffects
|
||||
);
|
||||
|
||||
const clickMana = computeClickMana({
|
||||
skills,
|
||||
prestigeUpgrades,
|
||||
skillUpgrades,
|
||||
skillTiers,
|
||||
skills: {},
|
||||
});
|
||||
|
||||
const meditationMultiplier = getMeditationBonus(meditateTicks, skills, upgradeEffects.meditationEfficiency);
|
||||
const meditationMultiplier = getMeditationBonus(meditateTicks, {}, upgradeEffects.meditationEfficiency);
|
||||
const incursionStrength = getIncursionStrength(day, hour);
|
||||
const effectiveRegenWithSpecials = baseRegen * (1 - incursionStrength);
|
||||
|
||||
@@ -115,22 +106,18 @@ export function useManaStats() {
|
||||
* Get combat-related derived state
|
||||
*/
|
||||
export function useCombatStats() {
|
||||
const skills = useSkillStore((s) => s.skills);
|
||||
const signedPacts = usePrestigeStore((s) => s.signedPacts);
|
||||
const equippedInstances = useCraftingStore((s) => s.equippedInstances);
|
||||
const equipmentInstances = useCraftingStore((s) => s.equipmentInstances);
|
||||
const skillUpgrades = useSkillStore((s) => s.skillUpgrades);
|
||||
const skillTiers = useSkillStore((s) => s.skillTiers);
|
||||
|
||||
const upgradeEffects = getUnifiedEffects({
|
||||
skillUpgrades,
|
||||
skillTiers,
|
||||
skillUpgrades: {},
|
||||
skillTiers: {},
|
||||
equippedInstances,
|
||||
equipmentInstances,
|
||||
});
|
||||
|
||||
return {
|
||||
skills,
|
||||
signedPacts,
|
||||
equippedInstances,
|
||||
equipmentInstances,
|
||||
|
||||
@@ -4,21 +4,19 @@ import { SPELLS_DEF } from '../constants';
|
||||
import { useUIStore } from './uiStore';
|
||||
import { usePrestigeStore } from './prestigeStore';
|
||||
import { useManaStore } from './manaStore';
|
||||
import { useSkillStore } from './skillStore';
|
||||
import { useCombatStore } from './combatStore';
|
||||
|
||||
export const createStartNewLoop = (set: (state: any) => void) => () => {
|
||||
const prestigeState = usePrestigeStore.getState();
|
||||
const combatState = useCombatStore.getState();
|
||||
const manaState = useManaStore.getState();
|
||||
const skillState = useSkillStore.getState();
|
||||
|
||||
const insightGained = prestigeState.loopInsight || calcInsight({
|
||||
maxFloorReached: combatState.maxFloorReached,
|
||||
totalManaGathered: manaState.totalManaGathered,
|
||||
signedPacts: prestigeState.signedPacts,
|
||||
prestigeUpgrades: prestigeState.prestigeUpgrades,
|
||||
skills: skillState.skills,
|
||||
skills: {},
|
||||
});
|
||||
|
||||
const total = prestigeState.insight + insightGained;
|
||||
@@ -26,25 +24,6 @@ export const createStartNewLoop = (set: (state: any) => void) => () => {
|
||||
const pu = prestigeState.prestigeUpgrades;
|
||||
const startFloor = 1 + (pu.spireKey || 0) * 2;
|
||||
|
||||
// Apply saved memories - restore skill levels, tiers, and upgrades
|
||||
const memories = prestigeState.memories || [];
|
||||
const newSkills: Record<string, number> = {};
|
||||
const newSkillTiers: Record<string, number> = {};
|
||||
const newSkillUpgrades: Record<string, string[]> = {};
|
||||
|
||||
if (memories.length > 0) {
|
||||
for (const memory of memories) {
|
||||
const tieredSkillId = memory.tier > 1 ? `${memory.skillId}_t${memory.tier}` : memory.skillId;
|
||||
newSkills[tieredSkillId] = memory.level;
|
||||
|
||||
if (memory.tier > 1) {
|
||||
newSkillTiers[memory.skillId] = memory.tier;
|
||||
}
|
||||
|
||||
newSkillUpgrades[tieredSkillId] = memory.upgrades || [];
|
||||
}
|
||||
}
|
||||
|
||||
// Reset and update all stores for new loop
|
||||
useUIStore.setState({
|
||||
gameOver: false,
|
||||
@@ -61,9 +40,7 @@ export const createStartNewLoop = (set: (state: any) => void) => () => {
|
||||
);
|
||||
usePrestigeStore.getState().incrementLoopCount();
|
||||
|
||||
useManaStore.getState().resetMana(pu, newSkills, newSkillUpgrades, newSkillTiers);
|
||||
|
||||
useSkillStore.getState().resetSkills(newSkills, newSkillUpgrades, newSkillTiers);
|
||||
useManaStore.getState().resetMana(pu, {}, {}, {});
|
||||
|
||||
// Reset combat with starting floor and any spells from prestige upgrades
|
||||
const startSpells = makeInitialSpells();
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
import { create } from 'zustand';
|
||||
import { persist } from 'zustand/middleware';
|
||||
import { TICK_MS, HOURS_PER_TICK, MAX_DAY, SPELLS_DEF, GUARDIANS, getStudySpeedMultiplier } from '../constants';
|
||||
import { computeEffects } from '../upgrade-effects';
|
||||
import { hasSpecial, SPECIAL_EFFECTS } from '../special-effects';
|
||||
import {
|
||||
computeMaxMana,
|
||||
@@ -22,7 +21,6 @@ import {
|
||||
import { useUIStore } from './uiStore';
|
||||
import { usePrestigeStore } from './prestigeStore';
|
||||
import { useManaStore } from './manaStore';
|
||||
import { useSkillStore } from './skillStore';
|
||||
import { useCombatStore, makeInitialSpells } from './combatStore';
|
||||
import { useAttunementStore } from './attunementStore';
|
||||
import { ATTUNEMENTS_DEF, getAttunementConversionRate } from '../data/attunements';
|
||||
@@ -66,26 +64,22 @@ export const useGameStore = create<GameCoordinatorStore>()(
|
||||
tick: () => {
|
||||
const uiState = useUIStore.getState();
|
||||
if (uiState.gameOver || uiState.paused) return;
|
||||
|
||||
|
||||
// Helper for logging
|
||||
const addLog = (msg: string) => useUIStore.getState().addLog(msg);
|
||||
|
||||
// Get all store states
|
||||
const prestigeState = usePrestigeStore.getState();
|
||||
const manaState = useManaStore.getState();
|
||||
const skillState = useSkillStore.getState();
|
||||
const combatState = useCombatStore.getState();
|
||||
|
||||
// Compute effects from upgrades
|
||||
const effects = computeEffects(skillState.skillUpgrades || {}, skillState.skillTiers || {});
|
||||
|
||||
const maxMana = computeMaxMana(
|
||||
{ skills: skillState.skills, prestigeUpgrades: prestigeState.prestigeUpgrades, skillUpgrades: skillState.skillUpgrades, skillTiers: skillState.skillTiers },
|
||||
effects
|
||||
{ skills: {}, prestigeUpgrades: prestigeState.prestigeUpgrades, skillUpgrades: {}, skillTiers: {} },
|
||||
undefined
|
||||
);
|
||||
const baseRegen = computeRegen(
|
||||
{ skills: skillState.skills, prestigeUpgrades: prestigeState.prestigeUpgrades, skillUpgrades: skillState.skillUpgrades, skillTiers: skillState.skillTiers },
|
||||
effects
|
||||
{ skills: {}, prestigeUpgrades: prestigeState.prestigeUpgrades, skillUpgrades: {}, skillTiers: {}, attunement: {} },
|
||||
undefined
|
||||
);
|
||||
|
||||
// Time progression
|
||||
@@ -103,9 +97,9 @@ export const useGameStore = create<GameCoordinatorStore>()(
|
||||
totalManaGathered: manaState.totalManaGathered,
|
||||
signedPacts: prestigeState.signedPacts,
|
||||
prestigeUpgrades: prestigeState.prestigeUpgrades,
|
||||
skills: skillState.skills,
|
||||
skills: {},
|
||||
});
|
||||
|
||||
|
||||
addLog(`⏰ The loop ends. Gained ${insightGained} Insight.`);
|
||||
useUIStore.getState().setGameOver(true, false);
|
||||
usePrestigeStore.getState().setLoopInsight(insightGained);
|
||||
@@ -120,9 +114,9 @@ export const useGameStore = create<GameCoordinatorStore>()(
|
||||
totalManaGathered: manaState.totalManaGathered,
|
||||
signedPacts: prestigeState.signedPacts,
|
||||
prestigeUpgrades: prestigeState.prestigeUpgrades,
|
||||
skills: skillState.skills,
|
||||
skills: {},
|
||||
}) * 3;
|
||||
|
||||
|
||||
addLog(`🏆 VICTORY! The Awakened One falls! Gained ${insightGained} Insight!`);
|
||||
useUIStore.getState().setGameOver(true, true);
|
||||
usePrestigeStore.getState().setLoopInsight(insightGained);
|
||||
@@ -135,10 +129,10 @@ export const useGameStore = create<GameCoordinatorStore>()(
|
||||
// Meditation bonus tracking and regen calculation
|
||||
let meditateTicks = manaState.meditateTicks;
|
||||
let meditationMultiplier = 1;
|
||||
|
||||
|
||||
if (combatState.currentAction === 'meditate') {
|
||||
meditateTicks++;
|
||||
meditationMultiplier = getMeditationBonus(meditateTicks, skillState.skills, effects.meditationEfficiency);
|
||||
meditationMultiplier = getMeditationBonus(meditateTicks, {}, 1);
|
||||
} else {
|
||||
meditateTicks = 0;
|
||||
}
|
||||
@@ -150,7 +144,7 @@ export const useGameStore = create<GameCoordinatorStore>()(
|
||||
if (!state.active) return;
|
||||
const def = ATTUNEMENTS_DEF[id];
|
||||
if (!def || def.conversionRate <= 0 || !def.primaryManaType) return;
|
||||
|
||||
|
||||
const scaledRate = getAttunementConversionRate(id, state.level || 1);
|
||||
totalConversionPerTick += scaledRate * HOURS_PER_TICK;
|
||||
});
|
||||
@@ -167,10 +161,10 @@ export const useGameStore = create<GameCoordinatorStore>()(
|
||||
if (!state.active) return;
|
||||
const def = ATTUNEMENTS_DEF[id];
|
||||
if (!def || def.conversionRate <= 0 || !def.primaryManaType) return;
|
||||
|
||||
|
||||
const scaledRate = getAttunementConversionRate(id, state.level || 1);
|
||||
const conversionThisTick = scaledRate * HOURS_PER_TICK; // per tick
|
||||
|
||||
const conversionThisTick = scaledRate * HOURS_PER_TICK;
|
||||
|
||||
// Add to primary mana type (cost already deducted from regen)
|
||||
if (elements[def.primaryManaType]) {
|
||||
elements[def.primaryManaType].current = Math.min(
|
||||
@@ -181,32 +175,6 @@ export const useGameStore = create<GameCoordinatorStore>()(
|
||||
});
|
||||
let totalManaGathered = manaState.totalManaGathered;
|
||||
|
||||
// Study progress - handled by skillStore
|
||||
if (combatState.currentAction === 'study' && skillState.currentStudyTarget) {
|
||||
const studySpeedMult = getStudySpeedMultiplier(skillState.skills);
|
||||
const progressGain = HOURS_PER_TICK * studySpeedMult;
|
||||
|
||||
const result = useSkillStore.getState().updateStudyProgress(progressGain);
|
||||
|
||||
if (result.completed && result.target) {
|
||||
if (result.target.type === 'skill') {
|
||||
const skillId = result.target.id;
|
||||
const currentLevel = skillState.skills[skillId] || 0;
|
||||
// Update skill level
|
||||
useSkillStore.getState().incrementSkillLevel(skillId);
|
||||
useSkillStore.getState().clearPaidStudySkill(skillId);
|
||||
useCombatStore.getState().setAction('meditate');
|
||||
addLog(`✅ ${skillId} Lv.${currentLevel + 1} mastered!`);
|
||||
} else if (result.target.type === 'spell') {
|
||||
const spellId = result.target.id;
|
||||
useCombatStore.getState().learnSpell(spellId);
|
||||
useSkillStore.getState().setCurrentStudyTarget(null);
|
||||
useCombatStore.getState().setAction('meditate');
|
||||
addLog(`📖 ${SPELLS_DEF[spellId]?.name || spellId} learned!`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Convert action - delegate to manaStore
|
||||
if (combatState.currentAction === 'convert') {
|
||||
const convertResult = useManaStore.getState().processConvertAction(rawMana);
|
||||
@@ -238,11 +206,11 @@ export const useGameStore = create<GameCoordinatorStore>()(
|
||||
// Combat - delegate to combatStore
|
||||
if (combatState.currentAction === 'climb') {
|
||||
const combatResult = useCombatStore.getState().processCombatTick(
|
||||
skillState.skills,
|
||||
{},
|
||||
rawMana,
|
||||
elements,
|
||||
maxMana,
|
||||
effects.attackSpeedMultiplier,
|
||||
1,
|
||||
(floor, wasGuardian) => {
|
||||
if (wasGuardian) {
|
||||
addLog(`⚔️ ${GUARDIANS[floor]?.name || 'Guardian'} defeated! Visit the Grimoire to sign a pact.`);
|
||||
@@ -252,25 +220,18 @@ export const useGameStore = create<GameCoordinatorStore>()(
|
||||
},
|
||||
(damage) => {
|
||||
// Apply upgrade damage multipliers and bonuses
|
||||
let dmg = damage * effects.baseDamageMultiplier + effects.baseDamageBonus;
|
||||
let dmg = damage;
|
||||
|
||||
// Executioner: +100% damage to enemies below 25% HP
|
||||
if (hasSpecial(effects, SPECIAL_EFFECTS.EXECUTIONER) && combatState.floorHP / combatState.floorMaxHP < 0.25) {
|
||||
if (hasSpecial({}, SPECIAL_EFFECTS.EXECUTIONER) && combatState.floorHP / combatState.floorMaxHP < 0.25) {
|
||||
dmg *= 2;
|
||||
}
|
||||
|
||||
// Berserker: +50% damage when below 50% mana
|
||||
if (hasSpecial(effects, SPECIAL_EFFECTS.BERSERKER) && rawMana < maxMana * 0.5) {
|
||||
if (hasSpecial({}, SPECIAL_EFFECTS.BERSERKER) && rawMana < maxMana * 0.5) {
|
||||
dmg *= 1.5;
|
||||
}
|
||||
|
||||
// Spell echo - chance to cast again
|
||||
const echoChance = (skillState.skills.spellEcho || 0) * 0.1;
|
||||
if (Math.random() < echoChance) {
|
||||
dmg *= 2;
|
||||
addLog(`✨ Spell Echo! Double damage!`);
|
||||
}
|
||||
|
||||
return { rawMana, elements, modifiedDamage: dmg };
|
||||
}
|
||||
);
|
||||
|
||||
@@ -11,9 +11,6 @@ export type { PrestigeState } from './prestigeStore';
|
||||
export { useManaStore, makeInitialElements } from './manaStore';
|
||||
export type { ManaState } from './manaStore';
|
||||
|
||||
export { useSkillStore } from './skillStore';
|
||||
export type { SkillState } from './skillStore';
|
||||
|
||||
export { useCombatStore, makeInitialSpells } from './combatStore';
|
||||
export type { CombatState } from './combatStore';
|
||||
|
||||
|
||||
@@ -1,211 +0,0 @@
|
||||
// ─── Study Slice ─────────────────────────────────────────────────────────────
|
||||
// Actions for studying skills and spells
|
||||
|
||||
import type { GameState } from './types';
|
||||
import { SKILLS_DEF, SPELLS_DEF, getStudyCostMultiplier } from './constants';
|
||||
import { computeEffects } from './upgrade-effects';
|
||||
import { hasSpecial, SPECIAL_EFFECTS } from './special-effects';
|
||||
|
||||
// ─── Study Actions Interface ──────────────────────────────────────────────────
|
||||
|
||||
export interface StudyActions {
|
||||
startStudyingSkill: (skillId: string) => void;
|
||||
startStudyingSpell: (spellId: string) => void;
|
||||
cancelStudy: () => void;
|
||||
startParallelStudySkill: (skillId: string) => void;
|
||||
cancelParallelStudy: () => void;
|
||||
}
|
||||
|
||||
// ─── Study Slice Factory ──────────────────────────────────────────────────────
|
||||
|
||||
export function createStudySlice(
|
||||
set: (partial: Partial<GameState> | ((state: GameState) => Partial<GameState>)) => void,
|
||||
get: () => GameState
|
||||
): StudyActions {
|
||||
return {
|
||||
// Start studying a skill - mana is deducted per hour, not upfront
|
||||
startStudyingSkill: (skillId: string) => {
|
||||
const state = get();
|
||||
const sk = SKILLS_DEF[skillId];
|
||||
if (!sk) return;
|
||||
|
||||
const currentLevel = state.skills[skillId] || 0;
|
||||
if (currentLevel >= sk.max) return;
|
||||
|
||||
// Check prerequisites
|
||||
if (sk.req) {
|
||||
for (const [r, rl] of Object.entries(sk.req)) {
|
||||
if ((state.skills[r] || 0) < rl) return;
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate total mana cost and cost per hour
|
||||
const costMult = getStudyCostMultiplier(state.skills);
|
||||
let totalCost = Math.floor(sk.base * (currentLevel + 1) * costMult);
|
||||
|
||||
// CHAIN_STUDY: -5% cost per maxed skill
|
||||
const effects = computeEffects(state.skillUpgrades || {}, state.skillTiers || {});
|
||||
if (hasSpecial(effects, SPECIAL_EFFECTS.CHAIN_STUDY)) {
|
||||
const maxedSkills = Object.entries(SKILLS_DEF).filter(([id, sk]) =>
|
||||
(state.skills[id] || 0) >= sk.max
|
||||
).length;
|
||||
const discount = Math.pow(0.95, maxedSkills); // -5% per maxed skill
|
||||
totalCost = Math.floor(totalCost * discount);
|
||||
}
|
||||
|
||||
const manaCostPerHour = Math.ceil(totalCost / sk.studyTime);
|
||||
|
||||
// Must have at least 1 hour worth of mana to start
|
||||
if (state.rawMana < manaCostPerHour) return;
|
||||
|
||||
// KNOWLEDGE_TRANSFER: New skills start at 10% progress
|
||||
let initialProgress = state.skillProgress[skillId] || 0;
|
||||
if (hasSpecial(effects, SPECIAL_EFFECTS.KNOWLEDGE_TRANSFER) && initialProgress === 0) {
|
||||
initialProgress = sk.studyTime * 0.10; // 10% of required time
|
||||
log = [`📖 Knowledge Transfer: Starting with 10% progress!`, ...state.log.slice(0, 49)];
|
||||
}
|
||||
|
||||
// Start studying (no upfront cost - mana is deducted per hour during study)
|
||||
set({
|
||||
currentAction: 'study',
|
||||
currentStudyTarget: {
|
||||
type: 'skill',
|
||||
id: skillId,
|
||||
progress: initialProgress,
|
||||
required: sk.studyTime,
|
||||
manaCostPerHour: manaCostPerHour,
|
||||
totalCost: totalCost,
|
||||
},
|
||||
log: [`📚 Started studying ${sk.name} (${manaCostPerHour} mana/hr)...`, ...state.log.slice(0, 49)],
|
||||
});
|
||||
},
|
||||
|
||||
// Start studying a spell
|
||||
startStudyingSpell: (spellId: string) => {
|
||||
const state = get();
|
||||
const sp = SPELLS_DEF[spellId];
|
||||
if (!sp || state.spells[spellId]?.learned) return;
|
||||
|
||||
// Calculate total mana cost and cost per hour
|
||||
const costMult = getStudyCostMultiplier(state.skills);
|
||||
let totalCost = Math.floor(sp.unlock * costMult);
|
||||
|
||||
// CHAIN_STUDY: -5% cost per maxed skill
|
||||
const effects = computeEffects(state.skillUpgrades || {}, state.skillTiers || {});
|
||||
if (hasSpecial(effects, SPECIAL_EFFECTS.CHAIN_STUDY)) {
|
||||
const maxedSkills = Object.entries(SKILLS_DEF).filter(([id, sk]) =>
|
||||
(state.skills[id] || 0) >= sk.max
|
||||
).length;
|
||||
const discount = Math.pow(0.95, maxedSkills); // -5% per maxed skill
|
||||
totalCost = Math.floor(totalCost * discount);
|
||||
}
|
||||
|
||||
const studyTime = sp.studyTime || (sp.tier * 4);
|
||||
const manaCostPerHour = Math.ceil(totalCost / studyTime);
|
||||
|
||||
// Must have at least 1 hour worth of mana to start
|
||||
if (state.rawMana < manaCostPerHour) return;
|
||||
|
||||
// Start studying (no upfront cost - mana is deducted per hour during study)
|
||||
set({
|
||||
currentAction: 'study',
|
||||
currentStudyTarget: {
|
||||
type: 'spell',
|
||||
id: spellId,
|
||||
progress: state.spells[spellId]?.studyProgress || 0,
|
||||
required: studyTime,
|
||||
manaCostPerHour: manaCostPerHour,
|
||||
totalCost: totalCost,
|
||||
},
|
||||
spells: {
|
||||
...state.spells,
|
||||
[spellId]: { ...(state.spells[spellId] || { learned: false, level: 0 }), studyProgress: state.spells[spellId]?.studyProgress || 0 },
|
||||
},
|
||||
log: [`📚 Started studying ${sp.name} (${manaCostPerHour} mana/hr)...`, ...state.log.slice(0, 49)],
|
||||
});
|
||||
},
|
||||
|
||||
// Cancel current study (saves progress)
|
||||
cancelStudy: () => {
|
||||
const state = get();
|
||||
if (!state.currentStudyTarget) return;
|
||||
|
||||
// Knowledge retention bonus
|
||||
const retentionBonus = 1 + (state.skills.knowledgeRetention || 0) * 0.2;
|
||||
const savedProgress = Math.min(
|
||||
state.currentStudyTarget.progress,
|
||||
state.currentStudyTarget.required * retentionBonus
|
||||
);
|
||||
|
||||
// Save progress
|
||||
if (state.currentStudyTarget.type === 'skill') {
|
||||
set({
|
||||
currentStudyTarget: null,
|
||||
currentAction: 'meditate',
|
||||
skillProgress: {
|
||||
...state.skillProgress,
|
||||
[state.currentStudyTarget.id]: savedProgress,
|
||||
},
|
||||
log: [`📖 Study interrupted. Progress saved.`, ...state.log.slice(0, 49)],
|
||||
});
|
||||
} else if (state.currentStudyTarget.type === 'spell') {
|
||||
set({
|
||||
currentStudyTarget: null,
|
||||
currentAction: 'meditate',
|
||||
spells: {
|
||||
...state.spells,
|
||||
[state.currentStudyTarget.id]: {
|
||||
...(state.spells[state.currentStudyTarget.id] || { learned: false, level: 0 }),
|
||||
studyProgress: savedProgress,
|
||||
},
|
||||
},
|
||||
log: [`📖 Study interrupted. Progress saved.`, ...state.log.slice(0, 49)],
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// Start parallel study of a skill (requires Parallel Mind upgrade)
|
||||
startParallelStudySkill: (skillId: string) => {
|
||||
const state = get();
|
||||
if (state.parallelStudyTarget) return; // Already have parallel study
|
||||
if (!state.currentStudyTarget) return; // Need primary study
|
||||
|
||||
const sk = SKILLS_DEF[skillId];
|
||||
if (!sk) return;
|
||||
|
||||
const currentLevel = state.skills[skillId] || 0;
|
||||
if (currentLevel >= sk.max) return;
|
||||
|
||||
// Can't study same thing in parallel
|
||||
if (state.currentStudyTarget.id === skillId) return;
|
||||
|
||||
// Calculate mana cost for parallel study
|
||||
const costMult = getStudyCostMultiplier(state.skills);
|
||||
const totalCost = Math.floor(sk.base * (currentLevel + 1) * costMult);
|
||||
const manaCostPerHour = Math.ceil(totalCost / sk.studyTime);
|
||||
|
||||
set({
|
||||
parallelStudyTarget: {
|
||||
type: 'skill',
|
||||
id: skillId,
|
||||
progress: state.skillProgress[skillId] || 0,
|
||||
required: sk.studyTime,
|
||||
manaCostPerHour: Math.ceil(manaCostPerHour / 2), // Half speed = half mana cost per tick
|
||||
totalCost: totalCost,
|
||||
},
|
||||
log: [`📚 Started parallel study of ${sk.name}... (50% speed)`, ...state.log.slice(0, 49)],
|
||||
});
|
||||
},
|
||||
|
||||
// Cancel parallel study
|
||||
cancelParallelStudy: () => {
|
||||
set((state) => {
|
||||
if (!state.parallelStudyTarget) return state;
|
||||
return {
|
||||
parallelStudyTarget: null,
|
||||
log: ['📖 Parallel study cancelled.', ...state.log.slice(0, 49)],
|
||||
};
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
+26
-57
@@ -11,67 +11,36 @@ export type { AttunementSlot, AttunementDef, AttunementState, GuardianBoon, Guar
|
||||
// Spell types
|
||||
export type { SpellCost, SpellDef, SpellEffect, SpellState } from './spells';
|
||||
|
||||
// Skill types
|
||||
export type {
|
||||
SkillDef,
|
||||
SkillUpgradeDef,
|
||||
SkillUpgradeEffect,
|
||||
SkillEvolutionPath,
|
||||
SkillTierDef,
|
||||
SkillPerkChoice,
|
||||
SkillUpgradeChoice,
|
||||
PrestigeDef,
|
||||
SkillCost
|
||||
} from './skills';
|
||||
|
||||
// Equipment types
|
||||
export type {
|
||||
EquipmentDef,
|
||||
EquipmentInstance,
|
||||
AppliedEnchantment,
|
||||
EnchantmentDesign,
|
||||
DesignEffect,
|
||||
DesignProgress,
|
||||
PreparationProgress,
|
||||
ApplicationProgress,
|
||||
EquipmentCraftingProgress,
|
||||
EquipmentSpellState,
|
||||
BlueprintDef,
|
||||
LootInventory,
|
||||
EquipmentSlot
|
||||
export type {
|
||||
EquipmentDef,
|
||||
EquipmentInstance,
|
||||
AppliedEnchantment,
|
||||
EnchantmentDesign,
|
||||
DesignEffect,
|
||||
DesignProgress,
|
||||
PreparationProgress,
|
||||
ApplicationProgress,
|
||||
EquipmentCraftingProgress,
|
||||
EquipmentSpellState,
|
||||
BlueprintDef,
|
||||
LootInventory,
|
||||
EquipmentSlot
|
||||
} from './equipmentSlot';
|
||||
|
||||
// Game state types
|
||||
export type {
|
||||
RoomType,
|
||||
EnemyState,
|
||||
FloorState,
|
||||
AchievementDef,
|
||||
AchievementState,
|
||||
GameAction,
|
||||
ScheduleBlock,
|
||||
StudyTarget,
|
||||
SummonedGolem,
|
||||
GolemancyState,
|
||||
GameState,
|
||||
GameActionType,
|
||||
ActivityEventType,
|
||||
ActivityLogEntry,
|
||||
} from './game';
|
||||
|
||||
// Game state types
|
||||
export type {
|
||||
RoomType,
|
||||
EnemyState,
|
||||
FloorState,
|
||||
AchievementDef,
|
||||
AchievementState,
|
||||
GameAction,
|
||||
ScheduleBlock,
|
||||
StudyTarget,
|
||||
SummonedGolem,
|
||||
GolemancyState,
|
||||
GameState,
|
||||
export type {
|
||||
RoomType,
|
||||
EnemyState,
|
||||
FloorState,
|
||||
AchievementDef,
|
||||
AchievementState,
|
||||
GameAction,
|
||||
ScheduleBlock,
|
||||
StudyTarget,
|
||||
SummonedGolem,
|
||||
GolemancyState,
|
||||
GameState,
|
||||
GameActionType,
|
||||
ActivityEventType,
|
||||
ActivityLogEntry,
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
// ─── Formatting Functions ─────────────────────────────────────────────────────
|
||||
|
||||
import { ELEMENTS } from '@/lib/game/constants';
|
||||
import type { SpellCost } from '@/lib/game/types';
|
||||
|
||||
export function fmt(n: number): string {
|
||||
if (!isFinite(n) || isNaN(n)) return '0';
|
||||
if (n >= 1e9) return (n / 1e9).toFixed(2) + 'B';
|
||||
@@ -11,3 +14,41 @@ export function fmt(n: number): string {
|
||||
export function fmtDec(n: number, d: number = 1): string {
|
||||
return isFinite(n) ? n.toFixed(d) : '0';
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a spell cost for display
|
||||
*/
|
||||
export function formatSpellCost(cost: SpellCost): string {
|
||||
if (cost.type === 'raw') {
|
||||
return `${cost.amount} raw`;
|
||||
}
|
||||
const elemDef = ELEMENTS[cost.element || ''];
|
||||
return `${cost.amount} ${elemDef?.sym || '?'}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the display color for a spell cost
|
||||
*/
|
||||
export function getSpellCostColor(cost: SpellCost): string {
|
||||
if (cost.type === 'raw') {
|
||||
return '#60A5FA'; // Blue for raw mana
|
||||
}
|
||||
return ELEMENTS[cost.element || '']?.color || '#9CA3AF';
|
||||
}
|
||||
|
||||
/**
|
||||
* Format study time in hours to human-readable string
|
||||
*/
|
||||
export function formatStudyTime(hours: number): string {
|
||||
if (hours < 1) return `${Math.round(hours * 60)}m`;
|
||||
return `${hours.toFixed(1)}h`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format time (hour of day) to HH:MM format
|
||||
*/
|
||||
export function formatHour(hour: number): string {
|
||||
const h = Math.floor(hour);
|
||||
const m = Math.floor((hour % 1) * 60);
|
||||
return `${h.toString().padStart(2, '0')}:${m.toString().padStart(2, '0')}`;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// ─── Game Utilities - Barrel Export ──────────────────────────────────────────
|
||||
|
||||
// Re-export everything from the focused modules
|
||||
export { fmt, fmtDec } from './formatting';
|
||||
export { fmt, fmtDec, formatSpellCost, getSpellCostColor, formatStudyTime, formatHour } from './formatting';
|
||||
export { getFloorMaxHP, getFloorElement } from './floor-utils';
|
||||
export {
|
||||
computeMaxMana,
|
||||
|
||||
Reference in New Issue
Block a user