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:
@@ -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 };
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user