pub struct Game { /* private fields */ }
Expand description
A Wrapper over State
that manages
creation and playing of games
Implementations
sourceimpl Game
impl Game
sourcepub fn new(word_set: WordSet<'static>) -> Result<Self>
pub fn new(word_set: WordSet<'static>) -> Result<Self>
Create a new game based on the current date (official style)
sourcepub fn custom(solution: String, word_set: WordSet<'static>) -> Result<Self>
pub fn custom(solution: String, word_set: WordSet<'static>) -> Result<Self>
Create a new game based on the given word
sourcepub fn from_date(date: Date, word_set: WordSet<'static>) -> Self
pub fn from_date(date: Date, word_set: WordSet<'static>) -> Self
Create a new game based on the given date
sourcepub fn from_day(day: usize, word_set: WordSet<'static>) -> Self
pub fn from_day(day: usize, word_set: WordSet<'static>) -> Self
Create a new game based on the given day number
sourcepub fn hard_mode(&mut self)
pub fn hard_mode(&mut self)
Sets the play style of this game to ‘hard mode’. This means that any exact matches found must be re-used in later guesses
sourcepub fn guess(&mut self, word: &str) -> Result<Matches, GuessError>
pub fn guess(&mut self, word: &str) -> Result<Matches, GuessError>
Make a guess.
Errors
If the guess is an invalid word, or if it doesn’t match the requirements of hard mode, this function will return an error
Display the share card for this game
use cl_wordle::game::Game;
let mut game = Game::from_day(0, cl_wordle::words::NYTIMES);
game.guess("crane").unwrap();
game.guess("carts").unwrap();
game.guess("chair").unwrap();
game.guess("cigar").unwrap();
let share = game.share();
let score_card = format!("{}", share);
assert_eq!(score_card, r"Wordle 0 4/6
🟩🟨🟨⬛⬛
🟩🟨🟨⬛⬛
🟩⬛🟨🟨🟩
🟩🟩🟩🟩🟩");
Methods from Deref<Target = State>
sourcepub fn guesses(&self) -> StateIter<'_>ⓘNotable traits for StateIter<'a>impl<'a> Iterator for StateIter<'a> type Item = Guess<'a>;
pub fn guesses(&self) -> StateIter<'_>ⓘNotable traits for StateIter<'a>impl<'a> Iterator for StateIter<'a> type Item = Guess<'a>;
Returns an iterator over the previous guesses
sourcepub fn display_score_card(&self, w: impl Write, hard: bool) -> Result
pub fn display_score_card(&self, w: impl Write, hard: bool) -> Result
Displays the score card for this game state to the given fmt::Write
.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Game
impl Send for Game
impl Sync for Game
impl Unpin for Game
impl UnwindSafe for Game
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more