35 const std::string& coordinat,
51 const auto&
get_actions() const noexcept {
return m_actions; }
138 std::vector<piece_action> m_actions;
149 delta_t m_current_action_progress;
179 std::vector<message_type> m_messages;
341std::ostream& operator<<(std::ostream& os, const
piece& p) noexcept;
chess_color
A chess piece color.
Definition chess_color.h:10
The collected in-game times of actions, in chrononical order.
Definition action_history.h:17
A change of in_game_time}.
Definition delta_t.h:12
The game logic.
Definition game.h:28
The in-game time, in chess moves.
Definition in_game_time.h:16
A message.
Definition message.h:15
An action to be done by a piece.
Definition piece_action.h:18
A unique ID.
Definition piece_id.h:12
A chess piece.
Definition piece.h:24
const piece_id & get_id() const noexcept
The unique piece ID.
Definition piece.h:72
void increase_kill_count() noexcept
Increase the kill count by one.
Definition piece.h:106
double get_shield() const
Get the shield value of the unit.
Definition piece.cpp:329
void tick(const delta_t &dt, game &g)
Do one frame of movement, resulting in a piece movement of 1 * delta_t.
Definition piece.cpp:1061
const auto & get_in_game_time() const noexcept
Get the in-game time according to this piece.
Definition piece.h:75
void set_current_action_progress(const delta_t &t) noexcept
Set the current progres an action has passed.
Definition piece.cpp:435
double get_health() const noexcept
Get the health of the unit.
Definition piece.h:69
bool has_moved() const noexcept
Has this piece (attempted to) moved?
Definition piece.h:103
bool is_enpassantable(const in_game_time &when) const
Can the unit be captured by en-passant? Will fail if the piece is not a pawn.
Definition piece.cpp:386
void add_action(const piece_action &action)
Add an action for the piece to do This function will split up the action in smaller atomic actions.
Definition piece.cpp:68
auto & get_actions() noexcept
Get all the piece actions.
Definition piece.h:54
const auto & get_action_history() const noexcept
Get the actions history.
Definition piece.h:57
int get_kill_count() const noexcept
Get the number of pieces this piece has killd.
Definition piece.h:78
delta_t get_current_action_progress() const
The progress of the current action, which is a value from zero to (and including) one.
Definition piece.cpp:300
void set_current_square(const square &s) noexcept
Set the current/occupied square.
Definition piece.h:121
const auto & get_actions() const noexcept
Get all the piece actions.
Definition piece.h:51
double get_max_health() const noexcept
Get the maximum health of the unit.
Definition piece.h:81
double get_max_shield() const
Get the maximum shield value of the unit.
Definition piece.cpp:318
const auto & get_race() const noexcept
Get the race of a piece.
Definition piece.h:92
void clear_messages() noexcept
Clear all the sound effects, i.e. remove all.
Definition piece.cpp:272
const auto & get_type() const noexcept
Get the type of piece, e.g. king, queen, rook, bishop, knight, pawn.
Definition piece.h:100
const auto & get_current_square() const noexcept
Definition piece.h:66
void add_message(const message_type &message)
Add a message, i.e. a thing to say for this piece.
Definition piece.cpp:145
const auto & get_color() const noexcept
Get the color of the piece, i.e. white or black.
Definition piece.h:60
void receive_damage(const double damage)
Receive damage.
Definition piece.cpp:423
const auto & get_messages() const noexcept
The things this piece wants to say.
Definition piece.h:89
A copyable read-only value.
Definition read_only.h:14
const T & get_value() const
Definition read_only.h:21
A chess square.
Definition square.h:58
message_type
The type of a message.
Definition message_type.h:10
bool is_idle(const piece &p) noexcept
Is the unit idle?
Definition piece.cpp:402
bool can_attack_on_empty_board(const chess_color color, const piece_type &p, const square &from, const square &to)
Can a piece attack from 'from' to 'to'? This function assumes the board is empty.
Definition piece.cpp:150
void tick_castle_queenside(piece &p, const delta_t &dt, game &g)
Process a tick, when the current action is a castling to queenside.
Definition piece.cpp:1274
bool can_move_on_empty_board(const chess_color color, const piece_type &p, const square &from, const square &to)
Can a piece move from 'from' to 'to'? This function assumes the board is empty.
Definition piece.cpp:195
void tick_move(piece &p, const delta_t &dt, game &g)
Process a tick, when the current action is a move.
Definition piece.cpp:1355
piece get_test_white_king() noexcept
Create a piece to be used in testing: a white king on e1.
Definition piece.cpp:335
bool is_dead(const piece &p) noexcept
Is the unit dead?
Definition piece.cpp:381
square get_occupied_square(const piece &p) noexcept
Get the square that this piece occupies now.
Definition piece.cpp:324
void clear_actions(piece &p)
Clear all the actions.
Definition piece.cpp:266
bool is_on_starting_rank(const chess_color c, const square &q) noexcept
Is this piece (a pawn) on the starting rank?
Definition piece.cpp:407
bool is_selected(const piece &p)
Determine from the action history if the piece is selected.
Definition piece.cpp:418
bool can_promote(const chess_color color, const piece_type &p, const square &s) noexcept
Can this piece promote?
Definition piece.cpp:245
int count_piece_actions(const piece &p)
Count the number of actions a piece has.
Definition piece.cpp:278
void tick_attack_en_passant(piece &p, const delta_t &dt, game &g)
Definition piece.cpp:1159
void tick_attack(piece &p, const delta_t &dt, game &g)
Process a tick, when the current action is an attack.
Definition piece.cpp:1127
bool has_moved(const piece &p) noexcept
Has this piece (attempted to) move?
Definition piece.cpp:376
bool has_actions(const piece &p) noexcept
Does the piece have actions to do?
Definition piece.cpp:363
bool is_pawn(const piece &p) noexcept
Is the piece a pawn?
Definition piece.cpp:413
std::string describe_actions(const piece &p)
Describe the actions a piece have, e.g. 'idle', or 'moving to (3, 4)'.
Definition piece.cpp:283
double get_f_shield(const piece &p) noexcept
Get the fraction of the shield, where 1.0 denotes full shields.
Definition piece.cpp:312
bool is_enpassantable(const piece &p, const in_game_time &when)
Can the unit be captured by en-passant?
Definition piece.cpp:394
bool has_just_double_moved(const piece &p, const in_game_time &when) noexcept
Has this piece (i.e.
Definition piece.cpp:368
void tick_castle_kingside(piece &p, const delta_t &dt, game &g)
Process a tick, when the current action is a castling to kingside.
Definition piece.cpp:1192
bool can_capture(const piece_type &p, const square &from, const square &to, const chess_color color)
Can a piece capture from 'from' to 'to'? This function assumes the board is empty.
void test_piece()
Test this class and its free functions.
Definition piece.cpp:440
piece get_test_white_knight(const race r=race::classic) noexcept
Create a piece to be used in testing: a white knight on c3.
Definition piece.cpp:344
double get_f_health(const piece &p) noexcept
Get the fraction of the health, where 1.0 denotes full health.
Definition piece.cpp:307
char to_fen_char(const piece &p) noexcept
Convert the piece to a FEN character.
Definition piece.cpp:1435
piece_type
The type of chess piece.
Definition piece_type.h:9
race
The chess race.
Definition race.h:10