Phase 4: Study effects (first 6)

This commit is contained in:
Refactoring Agent
2026-04-24 18:12:53 +02:00
parent edfc6f11c0
commit c8cabf3e4b
2 changed files with 73 additions and 2 deletions
+70 -2
View File
@@ -725,6 +725,9 @@ function makeInitial(overrides: Partial<GameState> = {}): GameState {
currentStudyTarget: null,
// Study momentum tracking (for STUDY_MOMENTUM effect)
consecutiveStudyHours: 0,
insight: overrides.insight || 0,
totalInsight: overrides.totalInsight || 0,
prestigeUpgrades: pu,
@@ -945,15 +948,57 @@ export const useGameStore = create<GameStore>()(
let spells = state.spells;
let log = state.log;
let unlockedEffects = state.unlockedEffects;
let consecutiveStudyHours = state.consecutiveStudyHours;
if (state.currentAction === 'study' && currentStudyTarget) {
const studySpeedMult = getStudySpeedMultiplier(skills);
const progressGain = HOURS_PER_TICK * studySpeedMult;
// Calculate base study speed
let studySpeedMult = getStudySpeedMultiplier(skills);
// DEEP_CONCENTRATION: +20% study speed when mana > 90%
if (hasSpecial(effects, SPECIAL_EFFECTS.DEEP_CONCENTRATION) && state.rawMana > maxMana * 0.9) {
studySpeedMult *= 1.20;
}
// STUDY_MOMENTUM: +5% study speed per consecutive hour
if (hasSpecial(effects, SPECIAL_EFFECTS.STUDY_MOMENTUM)) {
studySpeedMult *= (1 + consecutiveStudyHours * 0.05);
}
// QUICK_MASTERY: -20% study time for final 3 levels
if (hasSpecial(effects, SPECIAL_EFFECTS.QUICK_MASTERY) && currentStudyTarget.type === 'skill') {
const currentLevel = skills[currentStudyTarget.id] || 0;
const maxLevel = SKILLS_DEF[currentStudyTarget.id]?.max || 1;
if (currentLevel >= maxLevel - 3) {
// Reduce required time by 20% (multiply speed by 1.25)
studySpeedMult *= 1.25;
}
}
// Calculate progress gain
let progressGain = HOURS_PER_TICK * studySpeedMult;
// QUICK_GRASP: 5% chance double study progress per hour
if (hasSpecial(effects, SPECIAL_EFFECTS.QUICK_GRASP) && Math.random() < 0.05) {
progressGain *= 2;
log = [`⚡ Quick Grasp activated! Double progress!`, ...log.slice(0, 49)];
}
currentStudyTarget = {
...currentStudyTarget,
progress: currentStudyTarget.progress + progressGain,
};
// KNOWLEDGE_ECHO: 10% chance instant study
if (hasSpecial(effects, SPECIAL_EFFECTS.KNOWLEDGE_ECHO) && Math.random() < 0.10) {
currentStudyTarget = {
...currentStudyTarget,
progress: currentStudyTarget.required,
};
log = [`✨ Knowledge Echo! Study instantaneously completed!`, ...log.slice(0, 49)];
}
// Increment consecutive study hours for STUDY_MOMENTUM
consecutiveStudyHours++;
// Check if study is complete
if (currentStudyTarget.progress >= currentStudyTarget.required) {
if (currentStudyTarget.type === 'skill') {
@@ -992,6 +1037,27 @@ export const useGameStore = create<GameStore>()(
currentStudyTarget = null;
}
}
// Parallel Study processing (PARALLEL_STUDY special effect)
let parallelStudyTarget = state.parallelStudyTarget;
if (parallelStudyTarget && state.currentAction === 'study') {
// Parallel study progresses at 50% speed
const parallelProgressGain = HOURS_PER_TICK * 0.5;
parallelStudyTarget = {
...parallelStudyTarget,
progress: parallelStudyTarget.progress + parallelProgressGain,
};
// Check if parallel study is complete
if (parallelStudyTarget.progress >= parallelStudyTarget.required) {
const skillId = parallelStudyTarget.id;
const currentLevel = skills[skillId] || 0;
const newLevel = currentLevel + 1;
skills = { ...skills, [skillId]: newLevel };
skillProgress = { ...skillProgress, [skillId]: 0 };
log = [`${SKILLS_DEF[skillId]?.name} Lv.${newLevel} mastered (parallel study)!`, ...log.slice(0, 49)];
parallelStudyTarget = null;
}
}
// Convert action - auto convert mana
if (state.currentAction === 'convert') {
@@ -1469,6 +1535,7 @@ export const useGameStore = create<GameStore>()(
currentRoom,
incursionStrength,
currentStudyTarget,
parallelStudyTarget,
skills,
skillProgress,
spells,
@@ -1480,6 +1547,7 @@ export const useGameStore = create<GameStore>()(
flowSurgeEndTime,
comboHitCount,
floorHitCount,
consecutiveStudyHours,
...craftingUpdates,
});
},
+3
View File
@@ -174,6 +174,9 @@ export interface GameState {
// Parallel Study Target (for Parallel Mind milestone upgrade)
parallelStudyTarget: StudyTarget | null;
// Study Momentum tracking (for STUDY_MOMENTUM special effect)
consecutiveStudyHours: number; // Tracks consecutive hours of studying
// Golemancy (summoned golems)
golemancy: GolemancyState;