Skip to content

Commit 558563b

Browse files
unhappychoiceclaude
andcommitted
feat: rename GameState to SessionState for consistency
- Rename enum GameState to SessionState in typing_screen.rs - Update all 40+ references across typing_screen.rs and stage_manager.rs - Update import statement in stage_manager.rs - Maintain all existing functionality while improving semantic consistency This aligns with the session-based terminology established throughout the codebase. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 7fb0b5f commit 558563b

File tree

2 files changed

+46
-46
lines changed

2 files changed

+46
-46
lines changed

src/game/screens/typing_screen.rs

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub struct TypingScreen {
3131
repo_info: Option<GitRepository>,
3232
}
3333

34-
pub enum GameState {
34+
pub enum SessionState {
3535
Continue,
3636
Complete,
3737
Exit,
@@ -154,24 +154,24 @@ impl TypingScreen {
154154
if event::poll(std::time::Duration::from_millis(100))? {
155155
if let Event::Key(key_event) = event::read()? {
156156
match self.handle_key(key_event)? {
157-
GameState::Continue => {
157+
SessionState::Continue => {
158158
self.update_display()?;
159159
}
160-
GameState::Complete => {
160+
SessionState::Complete => {
161161
break;
162162
}
163-
GameState::Exit => {
163+
SessionState::Exit => {
164164
break;
165165
}
166-
GameState::Skip => {
166+
SessionState::Skip => {
167167
// Mark challenge as skipped and complete
168168
break;
169169
}
170-
GameState::Failed => {
170+
SessionState::Failed => {
171171
// Mark challenge as failed and complete
172172
break;
173173
}
174-
GameState::ShowDialog => {
174+
SessionState::ShowDialog => {
175175
// Dialog was opened, update display to show dialog
176176
self.update_display()?;
177177
}
@@ -210,24 +210,24 @@ impl TypingScreen {
210210
if event::poll(std::time::Duration::from_millis(100))? {
211211
if let Event::Key(key_event) = event::read()? {
212212
match self.handle_key(key_event)? {
213-
GameState::Continue => {
213+
SessionState::Continue => {
214214
self.update_display()?;
215215
}
216-
GameState::Complete => {
216+
SessionState::Complete => {
217217
break;
218218
}
219-
GameState::Exit => {
219+
SessionState::Exit => {
220220
break;
221221
}
222-
GameState::Skip => {
222+
SessionState::Skip => {
223223
// Mark challenge as skipped and complete
224224
break;
225225
}
226-
GameState::Failed => {
226+
SessionState::Failed => {
227227
// Mark challenge as failed and complete
228228
break;
229229
}
230-
GameState::ShowDialog => {
230+
SessionState::ShowDialog => {
231231
// Dialog was opened, update display to show dialog
232232
self.update_display()?;
233233
}
@@ -240,7 +240,7 @@ impl TypingScreen {
240240
Ok(self.calculate_result())
241241
}
242242

243-
pub fn show_with_state(&mut self) -> Result<(StageResult, GameState)> {
243+
pub fn show_with_state(&mut self) -> Result<(StageResult, SessionState)> {
244244
// For stage manager - assumes raw mode is already enabled
245245
self.start_time = std::time::Instant::now();
246246

@@ -263,16 +263,16 @@ impl TypingScreen {
263263
if event::poll(std::time::Duration::from_millis(100))? {
264264
if let Event::Key(key_event) = event::read()? {
265265
match self.handle_key(key_event)? {
266-
GameState::Continue => {
266+
SessionState::Continue => {
267267
self.update_display()?;
268268
}
269-
GameState::ShowDialog => {
269+
SessionState::ShowDialog => {
270270
self.update_display()?;
271271
}
272-
state @ (GameState::Complete
273-
| GameState::Exit
274-
| GameState::Skip
275-
| GameState::Failed) => {
272+
state @ (SessionState::Complete
273+
| SessionState::Exit
274+
| SessionState::Skip
275+
| SessionState::Failed) => {
276276
break state;
277277
}
278278
}
@@ -284,10 +284,10 @@ impl TypingScreen {
284284
Ok((self.calculate_result_with_state(&final_state), final_state))
285285
}
286286

287-
fn handle_key(&mut self, key_event: KeyEvent) -> Result<GameState> {
287+
fn handle_key(&mut self, key_event: KeyEvent) -> Result<SessionState> {
288288
// Only process key press events, ignore release/repeat
289289
if !matches!(key_event.kind, KeyEventKind::Press) {
290-
return Ok(GameState::Continue);
290+
return Ok(SessionState::Continue);
291291
}
292292

293293
match key_event.code {
@@ -296,12 +296,12 @@ impl TypingScreen {
296296
// Dialog is shown, Esc closes it
297297
self.dialog_shown = false;
298298
self.scoring_engine.resume();
299-
Ok(GameState::Continue)
299+
Ok(SessionState::Continue)
300300
} else {
301301
// No dialog, show Skip/Quit dialog
302302
self.dialog_shown = true;
303303
self.scoring_engine.pause();
304-
Ok(GameState::ShowDialog)
304+
Ok(SessionState::ShowDialog)
305305
}
306306
}
307307
KeyCode::Char('s') | KeyCode::Char('S') => {
@@ -310,9 +310,9 @@ impl TypingScreen {
310310
self.scoring_engine.resume();
311311
if self.skips_remaining > 0 {
312312
self.skips_remaining -= 1;
313-
Ok(GameState::Skip)
313+
Ok(SessionState::Skip)
314314
} else {
315-
Ok(GameState::Continue)
315+
Ok(SessionState::Continue)
316316
}
317317
} else {
318318
// Normal typing - handle as character input with actual character
@@ -328,7 +328,7 @@ impl TypingScreen {
328328
if self.dialog_shown {
329329
self.dialog_shown = false;
330330
self.scoring_engine.resume();
331-
Ok(GameState::Failed)
331+
Ok(SessionState::Failed)
332332
} else {
333333
// Normal typing - handle as character input with actual character
334334
let ch = if key_event.code == KeyCode::Char('Q') {
@@ -341,14 +341,14 @@ impl TypingScreen {
341341
}
342342
KeyCode::Char('c') if key_event.modifiers.contains(KeyModifiers::CONTROL) => {
343343
// Show session summary and exit
344-
Ok(GameState::Exit)
344+
Ok(SessionState::Exit)
345345
}
346346
KeyCode::Char(ch) => {
347347
if self.dialog_shown {
348348
// Dialog is shown, any other char closes it
349349
self.dialog_shown = false;
350350
self.scoring_engine.resume();
351-
Ok(GameState::Continue)
351+
Ok(SessionState::Continue)
352352
} else {
353353
// Normal typing
354354
self.handle_character_input(ch, key_event)
@@ -374,15 +374,15 @@ impl TypingScreen {
374374
// Skip over any non-typeable characters (comments, whitespace)
375375
self.advance_to_next_typeable_character();
376376
if self.current_position >= self.challenge_text.len() {
377-
return Ok(GameState::Complete);
377+
return Ok(SessionState::Complete);
378378
}
379379
} else {
380380
self.mistakes += 1;
381381
self.mistake_positions.push(self.current_position);
382382
self.current_mistake_position = Some(self.current_position);
383383
}
384384
}
385-
Ok(GameState::Continue)
385+
Ok(SessionState::Continue)
386386
}
387387
KeyCode::Enter => {
388388
// Auto-advance when reaching end of line (after last code character)
@@ -399,23 +399,23 @@ impl TypingScreen {
399399
self.current_mistake_position = None;
400400
self.advance_to_next_line()?;
401401
if self.current_position >= self.challenge_text.len() {
402-
return Ok(GameState::Complete);
402+
return Ok(SessionState::Complete);
403403
}
404404
} else {
405405
self.mistakes += 1;
406406
self.mistake_positions.push(self.current_position);
407407
self.current_mistake_position = Some(self.current_position);
408408
}
409409
}
410-
Ok(GameState::Continue)
410+
Ok(SessionState::Continue)
411411
}
412412
// Handle any other key
413413
_ => {
414414
if self.dialog_shown {
415415
self.dialog_shown = false;
416416
self.scoring_engine.resume();
417417
}
418-
Ok(GameState::Continue)
418+
Ok(SessionState::Continue)
419419
}
420420
}
421421
}
@@ -472,9 +472,9 @@ impl TypingScreen {
472472
.unwrap()
473473
}
474474

475-
pub fn calculate_result_with_state(&self, state: &GameState) -> StageResult {
476-
let was_skipped = matches!(state, GameState::Skip);
477-
let was_failed = matches!(state, GameState::Failed);
475+
pub fn calculate_result_with_state(&self, state: &SessionState) -> StageResult {
476+
let was_skipped = matches!(state, SessionState::Skip);
477+
let was_failed = matches!(state, SessionState::Failed);
478478
self.scoring_engine
479479
.calculate_result_with_status(was_skipped, was_failed)
480480
.unwrap()
@@ -502,7 +502,7 @@ impl TypingScreen {
502502
false // For now, we'll handle this in stage manager
503503
}
504504

505-
fn handle_character_input(&mut self, ch: char, _key_event: KeyEvent) -> Result<GameState> {
505+
fn handle_character_input(&mut self, ch: char, _key_event: KeyEvent) -> Result<SessionState> {
506506
if self.current_position < self.challenge_chars.len() {
507507
let expected_char = self.challenge_chars[self.current_position];
508508
let is_correct = ch == expected_char;
@@ -517,15 +517,15 @@ impl TypingScreen {
517517
// Skip over any non-typeable characters (comments, whitespace)
518518
self.advance_to_next_typeable_character();
519519
if self.current_position >= self.challenge_chars.len() {
520-
return Ok(GameState::Complete);
520+
return Ok(SessionState::Complete);
521521
}
522522
} else {
523523
self.mistakes += 1;
524524
self.mistake_positions.push(self.current_position);
525525
self.current_mistake_position = Some(self.current_position);
526526
}
527527
}
528-
Ok(GameState::Continue)
528+
Ok(SessionState::Continue)
529529
}
530530

531531
fn advance_to_next_typeable_character(&mut self) {

src/game/stage_manager.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use super::{
22
screens::{
33
exit_summary_screen::ExitAction, session_summary_screen::ResultAction,
4-
typing_screen::GameState, CancelScreen, CountdownScreen, ExitSummaryScreen, FailureScreen,
4+
typing_screen::SessionState, CancelScreen, CountdownScreen, ExitSummaryScreen, FailureScreen,
55
SessionSummaryScreen, SharingScreen, TitleAction, TitleScreen, TypingScreen,
66
},
77
session_tracker::SessionTracker,
@@ -190,7 +190,7 @@ impl StageManager {
190190

191191
// Handle different exit states
192192
match final_state {
193-
GameState::Complete => {
193+
SessionState::Complete => {
194194
// Normal completion - advance to next stage
195195
let stage_name = challenge.get_display_title();
196196
let engine = screen.get_scoring_engine().clone();
@@ -222,7 +222,7 @@ impl StageManager {
222222
// Move to next stage
223223
self.current_stage += 1;
224224
}
225-
GameState::Skip => {
225+
SessionState::Skip => {
226226
// Skipped - record skip and partial effort
227227
let engine = screen.get_scoring_engine();
228228
self.session_tracker.record_skip();
@@ -255,7 +255,7 @@ impl StageManager {
255255
}
256256
// Don't increment current_stage - retry same stage with new challenge
257257
}
258-
GameState::Failed => {
258+
SessionState::Failed => {
259259
// Failed - show fail result screen with navigation options
260260
let stage_name = challenge.get_display_title();
261261
let engine = screen.get_scoring_engine().clone();
@@ -280,7 +280,7 @@ impl StageManager {
280280
return Ok(false);
281281
}
282282
}
283-
GameState::Exit => {
283+
SessionState::Exit => {
284284
// User wants to exit - record partial effort only
285285
let engine = screen.get_scoring_engine();
286286
self.session_tracker.record_partial_effort(engine, &stage_result);
@@ -303,7 +303,7 @@ impl StageManager {
303303
return Ok(false);
304304
}
305305
}
306-
GameState::Continue | GameState::ShowDialog => {
306+
SessionState::Continue | SessionState::ShowDialog => {
307307
// This shouldn't happen in final state
308308
unreachable!("Continue/ShowDialog state should not be final");
309309
}

0 commit comments

Comments
 (0)