Skip to content

Commit 845aeda

Browse files
unhappychoiceclaude
andcommitted
feat: fix semantic accuracy of all field and function names
- Fix misleading field name: rank → tier_name in StageResult * rank field actually contained tier names like "Beginner" * Now properly named tier_name for semantic accuracy - Update all field assignments and access throughout codebase - Fix function names: get_rank_title_display() → get_rank_display() - Update function parameters: rank_title → rank_name - Fix variable names: rank_title_lines → rank_lines, rank_title_height → rank_height - Update comments and documentation to use "rank" instead of "ranking title" - Fix closure parameter: |title| → |rank| for semantic accuracy - Update all test files to use corrected function names Final semantically accurate field structure: - rank_name: String (specific rank like "Hello World") - tier_name: String (tier category like "Beginner") - tier_position: usize (position within the tier) - tier_total: usize (total ranks in the tier) All 160 tests passing, semantically consistent naming achieved. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 04fc71e commit 845aeda

File tree

9 files changed

+29
-29
lines changed

9 files changed

+29
-29
lines changed

src/game/ascii_rank_titles_generated.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -700,10 +700,10 @@ pub fn get_all_rank_patterns() -> HashMap<String, Vec<String>> {
700700
patterns
701701
}
702702

703-
pub fn get_rank_title_display(rank_title: &str) -> Vec<String> {
703+
pub fn get_rank_display(rank_name: &str) -> Vec<String> {
704704
let patterns = get_all_rank_patterns();
705705
patterns
706-
.get(rank_title)
706+
.get(rank_name)
707707
.cloned()
708-
.unwrap_or_else(|| vec![rank_title.to_string()])
708+
.unwrap_or_else(|| vec![rank_name.to_string()])
709709
}

src/game/screens/cancel_screen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl CancelScreen {
6868
completion_time: std::time::Duration::new(0, 0),
6969
challenge_score: 0.0,
7070
rank_name: "Unranked".to_string(),
71-
rank: "Beginner".to_string(),
71+
tier_name: "Beginner".to_string(),
7272
tier_position: 0,
7373
tier_total: 0,
7474
overall_position: 0,

src/game/screens/exit_summary_screen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl ExitSummaryScreen {
5252
completion_time: session_summary.total_session_time,
5353
challenge_score: session_summary.session_score,
5454
rank_name: ranking_title,
55-
rank: tier_name,
55+
tier_name,
5656
tier_position,
5757
tier_total,
5858
overall_position,

src/game/screens/session_summary_screen.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::game::ascii_digits::get_digit_patterns;
2-
use crate::game::ascii_rank_titles_generated::get_rank_title_display;
2+
use crate::game::ascii_rank_titles_generated::get_rank_display;
33
use crate::scoring::{Rank, ScoringEngine, StageResult};
44
use crate::{models::GitRepository, Result};
55
use crossterm::{
@@ -323,11 +323,11 @@ impl SessionSummaryScreen {
323323
};
324324

325325
// Display ranking title as large ASCII art at the top
326-
let rank_title_lines = get_rank_title_display(&session_metrics.rank_name);
327-
let rank_title_height = rank_title_lines.len() as u16;
326+
let rank_lines = get_rank_display(&session_metrics.rank_name);
327+
let rank_height = rank_lines.len() as u16;
328328

329329
// Calculate total content height and center vertically
330-
let total_content_height = 4 + rank_title_height + 1 + 3 + 1 + 4 + 2 + 2; // session_title_space + rank + tier + gap_after_tier + label + score + gap + summary
330+
let total_content_height = 4 + rank_height + 1 + 3 + 1 + 4 + 2 + 2; // session_title_space + rank + tier + gap_after_tier + label + score + gap + summary
331331
let rank_start_row = if total_content_height < terminal_height {
332332
center_row.saturating_sub(total_content_height / 2)
333333
} else {
@@ -358,7 +358,7 @@ impl SessionSummaryScreen {
358358
execute!(stdout, Print(youre_label))?;
359359
execute!(stdout, ResetColor)?;
360360

361-
for (row_index, line) in rank_title_lines.iter().enumerate() {
361+
for (row_index, line) in rank_lines.iter().enumerate() {
362362
// Calculate actual display width without ANSI codes for centering
363363
let display_width = Self::calculate_display_width(line);
364364
let line_col = center_col.saturating_sub(display_width / 2);
@@ -368,10 +368,10 @@ impl SessionSummaryScreen {
368368
}
369369

370370
// Display tier information right after rank title (small gap after rank title)
371-
let tier_info_row = rank_start_row + rank_title_height + 1;
371+
let tier_info_row = rank_start_row + rank_height + 1;
372372
let tier_info = format!(
373373
"{} tier - {}/{} (overall {}/{})",
374-
session_metrics.rank,
374+
session_metrics.tier_name,
375375
session_metrics.tier_position,
376376
session_metrics.tier_total,
377377
session_metrics.overall_position,
@@ -382,7 +382,7 @@ impl SessionSummaryScreen {
382382
execute!(stdout, SetAttribute(Attribute::Bold))?;
383383

384384
// Set color based on tier
385-
let tier_color = match session_metrics.rank.as_str() {
385+
let tier_color = match session_metrics.tier_name.as_str() {
386386
"Beginner" => Color::Blue,
387387
"Intermediate" => Color::Green,
388388
"Advanced" => Color::Cyan,
@@ -395,7 +395,7 @@ impl SessionSummaryScreen {
395395
execute!(stdout, ResetColor)?;
396396

397397
// Calculate score position based on rank title height and tier info (add extra gap after tier info)
398-
let score_label_row = rank_start_row + rank_title_height + 4;
398+
let score_label_row = rank_start_row + rank_height + 4;
399399

400400
// Display "SCORE" label in normal text with color
401401
let score_label = "SESSION SCORE";

src/models/rank.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl RankTier {
4242
}
4343

4444
impl Rank {
45-
/// Create a new ranking title
45+
/// Create a new rank
4646
pub fn new(name: impl Into<String>, tier: RankTier, min_score: u32, max_score: u32) -> Self {
4747
Self {
4848
name: name.into(),
@@ -52,7 +52,7 @@ impl Rank {
5252
}
5353
}
5454

55-
/// Get the display name of the ranking title
55+
/// Get the display name of the rank
5656
pub fn name(&self) -> &str {
5757
&self.name
5858
}
@@ -63,7 +63,7 @@ impl Rank {
6363
&self.tier
6464
}
6565

66-
/// Check if a score falls within this ranking title's range
66+
/// Check if a score falls within this rank's range
6767
#[allow(dead_code)]
6868
pub fn contains_score(&self, score: f64) -> bool {
6969
let score = score as u32;
@@ -75,7 +75,7 @@ impl Rank {
7575
self.tier.color_palette()
7676
}
7777

78-
/// Get the terminal color for this ranking title
78+
/// Get the terminal color for this rank
7979
pub fn terminal_color(&self) -> crossterm::style::Color {
8080
self.tier.terminal_color()
8181
}
@@ -154,14 +154,14 @@ impl Rank {
154154
]
155155
}
156156

157-
/// Find the ranking title for a given score
157+
/// Find the rank for a given score
158158
#[allow(dead_code)]
159159
pub fn for_score(score: f64) -> Rank {
160160
Self::all_ranks()
161161
.into_iter()
162-
.find(|title| title.contains_score(score))
162+
.find(|rank| rank.contains_score(score))
163163
.unwrap_or_else(|| {
164-
// Fallback to highest title if score exceeds all ranges
164+
// Fallback to highest rank if score exceeds all ranges
165165
Rank::new("Kernel Panic", RankTier::Legendary, 40001, u32::MAX)
166166
})
167167
}

src/models/stage.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub struct StageResult {
1717
pub completion_time: Duration,
1818
pub challenge_score: f64,
1919
pub rank_name: String,
20-
pub rank: String,
20+
pub tier_name: String,
2121
pub tier_position: usize,
2222
pub tier_total: usize,
2323
pub overall_position: usize,

src/scoring/engine.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ impl ScoringEngine {
484484
completion_time: self.elapsed(),
485485
challenge_score,
486486
rank_name,
487-
rank: tier_name,
487+
tier_name,
488488
tier_position,
489489
tier_total,
490490
overall_position,
@@ -532,7 +532,7 @@ impl ScoringEngine {
532532
completion_time: temp_engine.elapsed(),
533533
challenge_score,
534534
rank_name,
535-
rank: tier_name,
535+
tier_name,
536536
tier_position,
537537
tier_total,
538538
overall_position,

tests/ascii_art_coverage_tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
use gittype::game::ascii_rank_titles_generated::get_rank_title_display;
1+
use gittype::game::ascii_rank_titles_generated::get_rank_display;
22
use gittype::models::{RankTier, Rank};
33

44
#[test]
55
fn test_all_rank_titles_have_ascii_art() {
66
let titles = Rank::all_ranks();
77

88
for title in &titles {
9-
let ascii_art = get_rank_title_display(title.name());
9+
let ascii_art = get_rank_display(title.name());
1010

1111
// Verify ASCII art exists (not empty)
1212
assert!(
@@ -78,7 +78,7 @@ fn test_ascii_art_quality() {
7878

7979
for title in titles.iter().take(10) {
8080
// Test first 10 titles for performance
81-
let ascii_art = get_rank_title_display(title.name());
81+
let ascii_art = get_rank_display(title.name());
8282

8383
// Verify minimum quality standards
8484
assert!(

tests/missing_ascii_art_test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use gittype::game::ascii_rank_titles_generated::get_rank_title_display;
1+
use gittype::game::ascii_rank_titles_generated::get_rank_display;
22
use gittype::models::Rank;
33

44
#[test]
@@ -9,7 +9,7 @@ fn test_identify_missing_ascii_art() {
99
let mut has_art = Vec::new();
1010

1111
for title in &titles {
12-
let ascii_art = get_rank_title_display(title.name());
12+
let ascii_art = get_rank_display(title.name());
1313

1414
if ascii_art.len() == 1 && ascii_art[0] == title.name() {
1515
// This is fallback behavior - no actual ASCII art

0 commit comments

Comments
 (0)