forked from eros/curltastic
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 <clio-agent@sisyphuslabs.ai>
This commit is contained in:
parent
0ca0f0e3ff
commit
0ef0dc3d78
@ -94,15 +94,6 @@ impl Game {
|
|||||||
None
|
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 {
|
pub fn can_start(&self) -> bool {
|
||||||
self.red.is_some() && self.yellow.is_some()
|
self.red.is_some() && self.yellow.is_some()
|
||||||
}
|
}
|
||||||
@ -131,12 +122,6 @@ impl Game {
|
|||||||
Some(&p.id)
|
Some(&p.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn current_team_for_player(&self, player_id: &str) -> Option<Team> {
|
|
||||||
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<Vec<(f32, f32, f32)>, String> {
|
pub fn handle_throw(&mut self, player_id: &str, broom_x: f32, broom_y: f32, weight: u8, curl: i8, friction: f32) -> Result<Vec<(f32, f32, f32)>, String> {
|
||||||
let current_id = self.current_player_id().ok_or("No current player")?;
|
let current_id = self.current_player_id().ok_or("No current player")?;
|
||||||
if current_id != player_id {
|
if current_id != player_id {
|
||||||
@ -201,10 +186,6 @@ impl Game {
|
|||||||
self.score_end_internal(false);
|
self.score_end_internal(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn score_end(&mut self) {
|
|
||||||
self.score_end_internal(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn score_end_internal(&mut self, force: bool) {
|
fn score_end_internal(&mut self, force: bool) {
|
||||||
let end_done = force || (self.stones_red == 0 && self.stones_yellow == 0);
|
let end_done = force || (self.stones_red == 0 && self.stones_yellow == 0);
|
||||||
if !end_done {
|
if !end_done {
|
||||||
@ -273,10 +254,6 @@ impl Game {
|
|||||||
self.phase = GamePhase::Playing;
|
self.phase = GamePhase::Playing;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn phase(&self) -> GamePhase {
|
|
||||||
self.phase
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn take_last_end_scored(&mut self) -> Option<ServerMessage> {
|
pub fn take_last_end_scored(&mut self) -> Option<ServerMessage> {
|
||||||
let msg = self.last_end_scored.map(|(end, points, scoring_team)| {
|
let msg = self.last_end_scored.map(|(end, points, scoring_team)| {
|
||||||
ServerMessage::EndScored { end, points, scoring_team }
|
ServerMessage::EndScored { end, points, scoring_team }
|
||||||
@ -318,19 +295,15 @@ impl Game {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type RoomId = String;
|
|
||||||
|
|
||||||
pub struct Room {
|
pub struct Room {
|
||||||
pub id: RoomId,
|
|
||||||
pub game: Game,
|
pub game: Game,
|
||||||
pub tx: tokio::sync::broadcast::Sender<ServerMessage>,
|
pub tx: tokio::sync::broadcast::Sender<ServerMessage>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Room {
|
impl Room {
|
||||||
pub fn new(id: &str) -> Self {
|
pub fn new(_id: &str) -> Self {
|
||||||
let (tx, _) = tokio::sync::broadcast::channel(256);
|
let (tx, _) = tokio::sync::broadcast::channel(256);
|
||||||
Self {
|
Self {
|
||||||
id: id.to_string(),
|
|
||||||
game: Game::new(),
|
game: Game::new(),
|
||||||
tx,
|
tx,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,10 +13,6 @@ pub const SHEET_WIDTH: f32 = 5.0;
|
|||||||
pub const SHEET_LENGTH: f32 = 45.0;
|
pub const SHEET_LENGTH: f32 = 45.0;
|
||||||
pub const HOUSE_CENTER: (f32, f32) = (0.0, 38.5);
|
pub const HOUSE_CENTER: (f32, f32) = (0.0, 38.5);
|
||||||
pub const HOUSE_RADIUS: f32 = 1.83; // 12 ft
|
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 HOG_LINE_Y: f32 = 21.0;
|
||||||
pub const BACK_LINE_Y: f32 = 42.0;
|
pub const BACK_LINE_Y: f32 = 42.0;
|
||||||
pub const HACK_Y: f32 = 2.0;
|
pub const HACK_Y: f32 = 2.0;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user