-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Uses slices and batchs signal updates when using the gamestate signal
- Loading branch information
Showing
29 changed files
with
416 additions
and
298 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use hive_lib::{Piece, Position}; | ||
|
||
#[derive(Debug, Clone, PartialEq)] | ||
pub struct MoveInfo { | ||
// the piece (either from reserve or board) that has been clicked last | ||
pub active: Option<Piece>, | ||
// the position of the board piece that has been clicked last | ||
pub current_position: Option<Position>, | ||
// possible destinations of selected piece | ||
pub target_positions: Vec<Position>, | ||
// the position of the target that got clicked last | ||
pub target_position: Option<Position>, | ||
// the position of the reserve piece that got clicked last | ||
pub reserve_position: Option<Position>, | ||
} | ||
|
||
impl Default for MoveInfo { | ||
fn default() -> Self { | ||
Self::new() | ||
} | ||
} | ||
|
||
impl MoveInfo { | ||
pub fn new() -> Self { | ||
Self { | ||
active: None, | ||
current_position: None, | ||
target_positions: vec![], | ||
target_position: None, | ||
reserve_position: None, | ||
} | ||
} | ||
|
||
pub fn reset(&mut self) { | ||
self.target_positions.clear(); | ||
self.active = None; | ||
self.target_position = None; | ||
self.current_position = None; | ||
self.reserve_position = None; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use crate::responses::GameResponse; | ||
|
||
#[derive(Clone, PartialEq)] | ||
pub struct RatingChangeInfo { | ||
pub white_rating_change: i64, | ||
pub white_rating: u64, | ||
pub black_rating_change: i64, | ||
pub black_rating: u64, | ||
} | ||
|
||
impl RatingChangeInfo { | ||
pub fn from_game_response(gr: &GameResponse) -> Self { | ||
RatingChangeInfo { | ||
white_rating_change: gr.white_rating_change.unwrap_or_default() as i64, | ||
white_rating: gr.white_rating.unwrap_or_default() as u64, | ||
black_rating_change: gr.black_rating_change.unwrap_or_default() as i64, | ||
black_rating: gr.black_rating.unwrap_or_default() as u64, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.