pub struct TicTacToeGame {
pub board: Board,
pub x_player: TicTacToePlayer,
pub o_player: TicTacToePlayer,
}Expand description
A Tic-Tac-Toe game
Fields§
§board: BoardThe game board
x_player: TicTacToePlayerThe x player
o_player: TicTacToePlayerThe o player
Implementations§
Source§impl TicTacToeGame
impl TicTacToeGame
Sourcepub(super) fn new(x_player: TicTacToePlayer, o_player: TicTacToePlayer) -> Self
pub(super) fn new(x_player: TicTacToePlayer, o_player: TicTacToePlayer) -> Self
Make a new TicTacToeGame.
Sourcepub fn get_team_turn(&self) -> Team
pub fn get_team_turn(&self) -> Team
Get whos turn it is
Sourcepub fn get_player(&self, team: Team) -> TicTacToePlayer
pub fn get_player(&self, team: Team) -> TicTacToePlayer
Get the player for the given team.
Sourcepub fn get_player_turn(&self) -> TicTacToePlayer
pub fn get_player_turn(&self) -> TicTacToePlayer
Get the player whos turn it is
Sourcepub fn get_opponent(&self, player: TicTacToePlayer) -> Option<TicTacToePlayer>
pub fn get_opponent(&self, player: TicTacToePlayer) -> Option<TicTacToePlayer>
Get the opponent of the given user in this TicTacToeGame.
Sourcepub fn iter_players(&self) -> impl Iterator<Item = TicTacToePlayer> + '_
pub fn iter_players(&self) -> impl Iterator<Item = TicTacToePlayer> + '_
Iterate over all TicTacToePlayers.
Order is X player, O player.
This will include computer players.
Convert players into UserIds and filter if you want human players.
Trait Implementations§
Source§impl Clone for TicTacToeGame
impl Clone for TicTacToeGame
Source§fn clone(&self) -> TicTacToeGame
fn clone(&self) -> TicTacToeGame
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TicTacToeGame
impl Debug for TicTacToeGame
impl Copy for TicTacToeGame
Auto Trait Implementations§
impl Freeze for TicTacToeGame
impl RefUnwindSafe for TicTacToeGame
impl Send for TicTacToeGame
impl Sync for TicTacToeGame
impl Unpin for TicTacToeGame
impl UnwindSafe for TicTacToeGame
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneDebuggableStorage for Twhere
T: DebuggableStorage + Clone,
impl<T> CloneDebuggableStorage for Twhere
T: DebuggableStorage + Clone,
fn clone_storage(&self) -> Box<dyn CloneDebuggableStorage>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> CloneableStorage for T
impl<T> CloneableStorage for T
fn clone_storage(&self) -> Box<dyn CloneableStorage>
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request