From 0ef0dc3d78bf0c43fc09d7bb1e517395a03e4a6b Mon Sep 17 00:00:00 2001 From: eros Date: Wed, 24 Jun 2026 10:58:35 -0700 Subject: [PATCH] refactor(backend): remove remaining dead code and unused constants Drop unused Game methods, Room.id field, and backend-only sheet ring constants that duplicated frontend definitions. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- backend/src/game.rs | 29 +---------------------------- backend/src/protocol.rs | 4 ---- 2 files changed, 1 insertion(+), 32 deletions(-) diff --git a/backend/src/game.rs b/backend/src/game.rs index 84516a0..785a63c 100644 --- a/backend/src/game.rs +++ b/backend/src/game.rs @@ -94,15 +94,6 @@ impl Game { None } - pub fn set_player_connected(&mut self, id: &str, connected: bool) { - if let Some(p) = self.red.as_mut().filter(|p| p.id == id) { - p.connected = connected; - } - if let Some(p) = self.yellow.as_mut().filter(|p| p.id == id) { - p.connected = connected; - } - } - pub fn can_start(&self) -> bool { self.red.is_some() && self.yellow.is_some() } @@ -131,12 +122,6 @@ impl Game { Some(&p.id) } - pub fn current_team_for_player(&self, player_id: &str) -> Option { - if let Some(p) = self.red.as_ref() { if p.id == player_id { return Some(Team::Red); } } - if let Some(p) = self.yellow.as_ref() { if p.id == player_id { return Some(Team::Yellow); } } - None - } - pub fn handle_throw(&mut self, player_id: &str, broom_x: f32, broom_y: f32, weight: u8, curl: i8, friction: f32) -> Result, String> { let current_id = self.current_player_id().ok_or("No current player")?; if current_id != player_id { @@ -201,10 +186,6 @@ impl Game { self.score_end_internal(false); } - pub fn score_end(&mut self) { - self.score_end_internal(true); - } - fn score_end_internal(&mut self, force: bool) { let end_done = force || (self.stones_red == 0 && self.stones_yellow == 0); if !end_done { @@ -273,10 +254,6 @@ impl Game { self.phase = GamePhase::Playing; } - pub fn phase(&self) -> GamePhase { - self.phase - } - pub fn take_last_end_scored(&mut self) -> Option { let msg = self.last_end_scored.map(|(end, points, scoring_team)| { ServerMessage::EndScored { end, points, scoring_team } @@ -318,19 +295,15 @@ impl Game { } } -pub type RoomId = String; - pub struct Room { - pub id: RoomId, pub game: Game, pub tx: tokio::sync::broadcast::Sender, } impl Room { - pub fn new(id: &str) -> Self { + pub fn new(_id: &str) -> Self { let (tx, _) = tokio::sync::broadcast::channel(256); Self { - id: id.to_string(), game: Game::new(), tx, } diff --git a/backend/src/protocol.rs b/backend/src/protocol.rs index 4589e91..925b216 100644 --- a/backend/src/protocol.rs +++ b/backend/src/protocol.rs @@ -13,10 +13,6 @@ pub const SHEET_WIDTH: f32 = 5.0; pub const SHEET_LENGTH: f32 = 45.0; pub const HOUSE_CENTER: (f32, f32) = (0.0, 38.5); pub const HOUSE_RADIUS: f32 = 1.83; // 12 ft -pub const BUTTON_RADIUS: f32 = 0.1524; // 0.5 ft -pub const FOUR_FT_RADIUS: f32 = 0.6096; -pub const EIGHT_FT_RADIUS: f32 = 1.2192; -pub const TWELVE_FT_RADIUS: f32 = 1.8288; pub const HOG_LINE_Y: f32 = 21.0; pub const BACK_LINE_Y: f32 = 42.0; pub const HACK_Y: f32 = 2.0;