![]() |
Conquer Chess
Chess and Starcraft combined
|
#include "ccfwd.h"#include "piece_action_type.h"#include "game_coordinate.h"#include "game.h"#include "lobby_options.h"#include "side.h"#include "user_inputs.h"#include <map>#include <iosfwd>

Go to the source code of this file.
Classes | |
| class | game_controller |
| The class that acts as a controller for game}. More... | |
Functions | |
| void | add_user_input (game_controller &c, const user_input &input) |
| Add a user input. These will be processed in 'game::tick'. | |
| void | add_user_inputs (game_controller &c, const user_inputs &input) |
| Add a user_inputs. These will be processed in 'game::tick'. | |
| bool | can_attack (const game_controller &c, const side player_side) noexcept |
| Can the player attack? | |
| bool | can_attack_en_passant (const game_controller &c, const side player_side) noexcept |
| Can the player do an en-passant attack? | |
| bool | can_castle_kingside (const game_controller &c, const side player_side) noexcept |
| Can the player castle kingside? | |
| bool | can_castle_queenside (const game_controller &c, const side player_side) noexcept |
| Can the player castle queenside? | |
| bool | can_move (const game_controller &c, const side player_side) noexcept |
| bool | can_player_select_piece_at_cursor_pos (const game_controller &c, const chess_color cursor_color) |
| Can the player select a piece at the current cursor position? | |
| bool | can_player_select_piece_at_cursor_pos (const game_controller &c, const side player_side) |
| Can the player select a piece at the current cursor position? | |
| bool | can_promote (const game_controller &c, const side player_side) noexcept |
| bool | can_select (const game_controller &c, const side player_side) noexcept |
| bool | can_unselect (const game_controller &c, const side player_side) noexcept |
| std::vector< message > | collect_messages (const game_controller &g) noexcept |
| Get all the sound effects to be processed. | |
| std::vector< piece_id > | collect_selected_piece_ids (const game_controller &c) |
| Collect all the piece IDs of the selected pieces, if any. | |
| user_inputs | convert_move_to_user_inputs (const game_controller &c, const chess_move &move, const physical_controller_type t) |
| Convert a chess move, e.g. | |
| int | count_piece_actions (const game_controller &g) |
| Count the total number of actions to be done by pieces of both players. | |
| int | count_piece_actions (const game_controller &g, const chess_color player) |
| Count the total number of actions to be done by pieces of a player. | |
| int | count_selected_units (const game_controller &c, const chess_color player_color) |
| Count the number of selected units. | |
| int | count_user_inputs (const game_controller &c) noexcept |
| Count the total number of user_input}s to be done by the game_controller}. | |
| chess_color | get_color (const game_controller &c, const side s) |
| const game_coordinate & | get_cursor_pos (const game_controller &c, const side player_side) noexcept |
| Get the a player's cursor position. | |
| const game_coordinate & | get_cursor_pos (const game_controller &c, const chess_color cursor_color) |
| Get the cursor position for a chess color. | |
| square | get_cursor_square (const game_controller &c, const side player_side) |
| Get the a player's cursor position, as a square}. | |
| const in_game_time & | get_in_game_time (const game_controller &c) noexcept |
| std::vector< piece_action_type > | get_piece_actions (const game_controller &c, const side player_side) noexcept |
| Get the types of actions, if any, a player could by pressing an action key. | |
| piece & | get_piece_at (game_controller &c, const std::string &square_str) |
| piece & | get_piece_at (game_controller &c, const square &s) |
| std::vector< square > | get_possible_moves (const game_controller &c, const side player) |
| Get the possible moves for a player's selected pieces Will be empty if no pieces are selected. | |
| std::vector< piece > | get_selected_pieces (const game_controller &c, const chess_color player) |
| Get all the selected pieces. | |
| std::vector< piece > | get_selected_pieces (const game_controller &c, const side player) |
| Get all the selected pieces. | |
| const user_inputs & | get_user_inputs (const game_controller &c) noexcept |
| Get the game users' inputs. | |
| user_inputs | get_user_inputs_to_move_cursor_from_to (const game_controller &c, const square &from, const square &to, const side player_side, const physical_controller_type t) |
| Create the user inputs to move the cursor to a target square knowing it will be at the 'from' square. | |
| user_inputs | get_user_inputs_to_move_cursor_to (const game_controller &c, const square &to, const side player_side, const physical_controller_type t) |
| Create the user inputs to move the cursor to a target square. | |
| const std::optional< chess_color > & | get_winner (const game_controller &c) noexcept |
| bool | has_selected_pieces (const game_controller &c, const chess_color player_color) |
| See if there is at least 1 piece selected. | |
| bool | has_selected_pieces (const game_controller &c, const side player_side) |
| See if there is at least 1 piece selected. | |
| bool | has_winner (const game_controller &c) noexcept |
| Does the game have a winner? | |
| bool | is_cursor_on_selected_piece (const game_controller &c, const side player_side) noexcept |
| bool | is_draw (const game_controller &c) |
| Determine if the game is a draw. | |
| bool | is_piece_at (const game_controller &g, const square &coordinat) |
| Determine if there is a piece at the coordinat. | |
| bool | is_piece_at (const game_controller &g, const std::string &square_str) |
| Determine if there is a piece at the coordinat. | |
| bool | is_selected (const piece &p, const game_controller &c) |
| Determine if the piece is selected, based on its action history. | |
| bool | is_square_attacked (const game_controller &c, const square &s, const chess_color attacker_color) |
| Determine if the square is attacked by (another) piece of a certain color. | |
| void | move_cursor_to (game_controller &c, const std::string &square_str, const side player_side) |
| Put the cursor (i.e. | |
| void | move_cursor_to (game_controller &c, const square &s, const side player_side) |
| Put the cursor (i.e. | |
| game | play_random_game (const int n_turns=2, const int seed=42) |
| Play a random game, used for profiling. | |
| void | set_cursor_pos (game_controller &c, const game_coordinate &pos, const side player_side) noexcept |
| Set the cursor's position to the target position. | |
| void | test_game_controller () |
| Test this class and its free functions. | |
| std::string | to_board_str (const game_controller &c, const board_to_text_options &options=board_to_text_options()) noexcept |
| std::ostream & | operator<< (std::ostream &os, const game_controller &g) noexcept |
| void add_user_input | ( | game_controller & | c, |
| const user_input & | input | ||
| ) |
Add a user input. These will be processed in 'game::tick'.
| void add_user_inputs | ( | game_controller & | c, |
| const user_inputs & | input | ||
| ) |
Add a user_inputs. These will be processed in 'game::tick'.
|
noexcept |
Can the player attack?
|
noexcept |
Can the player do an en-passant attack?
|
noexcept |
Can the player castle kingside?
|
noexcept |
Can the player castle queenside?
|
noexcept |
| bool can_player_select_piece_at_cursor_pos | ( | const game_controller & | c, |
| const chess_color | cursor_color | ||
| ) |
Can the player select a piece at the current cursor position?
| bool can_player_select_piece_at_cursor_pos | ( | const game_controller & | c, |
| const side | player_side | ||
| ) |
Can the player select a piece at the current cursor position?
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
Get all the sound effects to be processed.
| std::vector< piece_id > collect_selected_piece_ids | ( | const game_controller & | c | ) |
Collect all the piece IDs of the selected pieces, if any.
| user_inputs convert_move_to_user_inputs | ( | const game_controller & | c, |
| const chess_move & | move, | ||
| const physical_controller_type | t | ||
| ) |
Convert a chess move, e.g.
e4, to the right user inputs
| int count_piece_actions | ( | const game_controller & | g | ) |
Count the total number of actions to be done by pieces of both players.
| int count_piece_actions | ( | const game_controller & | g, |
| const chess_color | player | ||
| ) |
Count the total number of actions to be done by pieces of a player.
| int count_selected_units | ( | const game_controller & | c, |
| const chess_color | player_color | ||
| ) |
Count the number of selected units.
As one can only select one unit, this is either zero or one.
|
noexcept |
Count the total number of user_input}s to be done by the game_controller}.
| chess_color get_color | ( | const game_controller & | c, |
| const side | s | ||
| ) |
| const game_coordinate & get_cursor_pos | ( | const game_controller & | c, |
| const chess_color | cursor_color | ||
| ) |
Get the cursor position for a chess color.
|
noexcept |
Get the a player's cursor position.
| square get_cursor_square | ( | const game_controller & | c, |
| const side | player_side | ||
| ) |
Get the a player's cursor position, as a square}.
|
noexcept |
|
noexcept |
Get the types of actions, if any, a player could by pressing an action key.
For example, action 1 typically un-/selects pieces, where action 4 is only used to promote to a knight.
| piece & get_piece_at | ( | game_controller & | c, |
| const square & | s | ||
| ) |
| piece & get_piece_at | ( | game_controller & | c, |
| const std::string & | square_str | ||
| ) |
| std::vector< square > get_possible_moves | ( | const game_controller & | c, |
| const side | player | ||
| ) |
Get the possible moves for a player's selected pieces Will be empty if no pieces are selected.
| std::vector< piece > get_selected_pieces | ( | const game_controller & | c, |
| const chess_color | player | ||
| ) |
Get all the selected pieces.
| g | a game |
| player | the color of the player, which is white for player 1 |
| std::vector< piece > get_selected_pieces | ( | const game_controller & | c, |
| const side | player | ||
| ) |
Get all the selected pieces.
| g | a game |
| side | the side of the player, which is white for player 1 |
|
noexcept |
Get the game users' inputs.
| user_inputs get_user_inputs_to_move_cursor_from_to | ( | const game_controller & | c, |
| const square & | from, | ||
| const square & | to, | ||
| const side | player_side, | ||
| const physical_controller_type | t | ||
| ) |
Create the user inputs to move the cursor to a target square knowing it will be at the 'from' square.
This is useful for creating future 'user_input's, e.g. for white doing e4, the cursor must be moved to e2 to select a pawn, then to e4 to select the target.
| user_inputs get_user_inputs_to_move_cursor_to | ( | const game_controller & | c, |
| const square & | to, | ||
| const side | player_side, | ||
| const physical_controller_type | t | ||
| ) |
Create the user inputs to move the cursor to a target square.
|
noexcept |
| bool has_selected_pieces | ( | const game_controller & | c, |
| const chess_color | player_color | ||
| ) |
See if there is at least 1 piece selected.
| g | a game |
| player | the color of the player, which is white for player 1 |
| bool has_selected_pieces | ( | const game_controller & | c, |
| const side | player_side | ||
| ) |
See if there is at least 1 piece selected.
|
noexcept |
Does the game have a winner?
|
noexcept |
| bool is_draw | ( | const game_controller & | c | ) |
Determine if the game is a draw.
| bool is_piece_at | ( | const game_controller & | g, |
| const square & | coordinat | ||
| ) |
Determine if there is a piece at the coordinat.
| bool is_piece_at | ( | const game_controller & | g, |
| const std::string & | square_str | ||
| ) |
Determine if there is a piece at the coordinat.
| bool is_selected | ( | const piece & | p, |
| const game_controller & | c | ||
| ) |
Determine if the piece is selected, based on its action history.
| bool is_square_attacked | ( | const game_controller & | c, |
| const square & | s, | ||
| const chess_color | attacker_color | ||
| ) |
Determine if the square is attacked by (another) piece of a certain color.
If the square is empty, it will determine if an enemy piece is looking at this square.
If the square is occupied, it will determine if an enemy piece is looking at that piece. That piece can be of any color.
| void move_cursor_to | ( | game_controller & | c, |
| const square & | s, | ||
| const side | player_side | ||
| ) |
Put the cursor (i.e.
the selector, not the mouse pointer) at the desired square. Does not select the square where the cursor is.
| void move_cursor_to | ( | game_controller & | c, |
| const std::string & | square_str, | ||
| const side | player_side | ||
| ) |
Put the cursor (i.e.
the selector, not the mouse pointer) at the desired square
|
noexcept |
| game play_random_game | ( | const int | n_turns = 2, |
| const int | seed = 42 |
||
| ) |
Play a random game, used for profiling.
|
noexcept |
Set the cursor's position to the target position.
| void test_game_controller | ( | ) |
Test this class and its free functions.
Test this class and its free functions.
|
noexcept |