refactor(core): use saturating_add for move_count increments (M-19)

recycle_count already used saturating_add(1); move_count was
inconsistently using += 1 at all three call sites. No real-world
overflow risk (u32 at ~4 billion moves), but the inconsistency was
a code smell flagged by the review.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
funman300
2026-05-17 21:20:26 -07:00
parent 18d7937b51
commit 132fea911c
+3 -3
View File
@@ -247,7 +247,7 @@ impl GameState {
stock.cards.push(card); stock.cards.push(card);
} }
self.recycle_count = self.recycle_count.saturating_add(1); self.recycle_count = self.recycle_count.saturating_add(1);
self.move_count += 1; self.move_count = self.move_count.saturating_add(1);
return Ok(()); return Ok(());
} }
@@ -273,7 +273,7 @@ impl GameState {
waste.cards.push(card); waste.cards.push(card);
} }
self.move_count += 1; self.move_count = self.move_count.saturating_add(1);
Ok(()) Ok(())
} }
@@ -381,7 +381,7 @@ impl GameState {
self.piles.get_mut(&to).ok_or(MoveError::InvalidDestination)?.cards.append(&mut moved); self.piles.get_mut(&to).ok_or(MoveError::InvalidDestination)?.cards.append(&mut moved);
self.score = (self.score + score_delta).max(0); self.score = (self.score + score_delta).max(0);
self.move_count += 1; self.move_count = self.move_count.saturating_add(1);
self.is_won = self.check_win(); self.is_won = self.check_win();
if !self.is_won { if !self.is_won {