Enum poke_a_mango::ops::GameState [] [src]

pub enum GameState {
    MainMenu,
    ChooseDifficulty,
    Playing {
        difficulty: Difficulty,
        score: u64,
        fruit: Option<usize>,
    },
    GameOver {
        difficulty: Difficulty,
        score: u64,
        name: String,
    },
    GameEnded {
        name: String,
        score: u64,
    },
    LoadLeaderboard,
    DisplayLeaderboard(Vec<Leader>),
    Exit,
}

Game's all possible states.

Widgets::update() takes care of proper state transformation.

Variants

Display the main menu.

Main menu contains a Start button, a button to Display Highscores, an Exit button.

Can transform into:

Display the screen where the player chooses the difficulty.

The screen contains one button for each difficulty and the Back button.

Can transform into:

The game is currently in progress.

This also contains the game's difficulty, the player's current score and whether the current fruit is a mango.

Can transform into GameOver.

Fields of Playing

The game difficulty, as chosen in the ChooseDifficulty stage.

The user's current score.

The current fruit index.

If None - it's a mango, else it's an index of fruit from util::FRUITS.

The game was lost after a valiant battle.

Contains the game's difficulty, the player's final score and the Back button.

In this stage the player enters its name.

Can transform into:

Fields of GameOver

The game difficulty, as same as in the Playing stage.

The user's final score.

The user's name, mostly partial.

The game cycle has ended. Semi-meta-state

Contains the game's difficulty and the players final score.

In this stage the player enters its name.

Transforms into MainMenu.

Fields of GameEnded

The user's name.

User's final score, weighted.

Meta-state indicating that the leaderboard needs to be loaded.

Needs to be handled in usercode, place the leaderboard into DisplayLeaderboard after loading it.

Leaderboards are loaded via Leader::load().

Transforms into DisplayLeaderboard

Display top 10 high scores.

This screen also contains the Back button.

Can transform into MainMenu

Pseudo-state, signifying that the game window should be closed.

Can transform into: nothing. This is the final state all others seek.

Methods

impl GameState
[src]

[src]

Check whether this state currently means that the game has ended.

Examples

assert!(GameState::Exit.should_exit());

[src]

Check whether this state requires usercode to load the leaderboard.

Examples

assert!(GameState::LoadLeaderboard.should_load_leaderboard());

Trait Implementations

impl Debug for GameState
[src]

[src]

Formats the value using the given formatter. Read more

impl Clone for GameState
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl PartialEq for GameState
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

impl Eq for GameState
[src]

impl PartialOrd for GameState
[src]

[src]

This method returns an ordering between self and other values if one exists. Read more

[src]

This method tests less than (for self and other) and is used by the < operator. Read more

[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Ord for GameState
[src]

[src]

This method returns an Ordering between self and other. Read more

1.21.0
[src]

Compares and returns the maximum of two values. Read more

1.21.0
[src]

Compares and returns the minimum of two values. Read more