Conquer Chess
Chess and Starcraft combined
Loading...
Searching...
No Matches
Public Member Functions | List of all members
piece Class Reference

A chess piece. More...

#include <piece.h>

Public Member Functions

 piece (const chess_color color, const piece_type type, const square &coordinat, const race r=race::classic)
 
 piece (const chess_color color, const piece_type type, const std::string &coordinat, const race r=race::classic)
 
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.
 
void add_message (const message_type &message)
 Add a message, i.e. a thing to say for this piece.
 
void clear_messages () noexcept
 Clear all the sound effects, i.e. remove all.
 
const auto & get_actions () const noexcept
 Get all the piece actions.
 
auto & get_actions () noexcept
 Get all the piece actions.
 
const auto & get_action_history () const noexcept
 Get the actions history.
 
const auto & get_color () const noexcept
 Get the color of the piece, i.e. white or black.
 
delta_t get_current_action_progress () const
 The progress of the current action, which is a value from zero to (and including) one.
 
const auto & get_current_square () const noexcept
 
double get_health () const noexcept
 Get the health of the unit.
 
const piece_idget_id () const noexcept
 The unique piece ID.
 
const auto & get_in_game_time () const noexcept
 Get the in-game time according to this piece.
 
int get_kill_count () const noexcept
 Get the number of pieces this piece has killd.
 
double get_max_health () const noexcept
 Get the maximum health of the unit.
 
double get_max_shield () const
 Get the maximum shield value of the unit.
 
const auto & get_messages () const noexcept
 The things this piece wants to say.
 
const auto & get_race () const noexcept
 Get the race of a piece.
 
double get_shield () const
 Get the shield value of the unit.
 
const auto & get_type () const noexcept
 Get the type of piece, e.g. king, queen, rook, bishop, knight, pawn.
 
bool has_moved () const noexcept
 Has this piece (attempted to) moved?
 
void increase_kill_count () noexcept
 Increase the kill count by one.
 
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.
 
void receive_damage (const double damage)
 Receive damage.
 
void set_current_action_progress (const delta_t &t) noexcept
 Set the current progres an action has passed.
 
void set_current_square (const square &s) noexcept
 Set the current/occupied square.
 
void tick (const delta_t &dt, game &g)
 Do one frame of movement, resulting in a piece movement of 1 * delta_t.
 

Detailed Description

A chess piece.

@seealso for drawing a piece and/or its health bar properly use piece_layout}

Constructor & Destructor Documentation

◆ piece() [1/2]

piece::piece ( const chess_color  color,
const piece_type  type,
const square coordinat,
const race  r = race::classic 
)
explicit

◆ piece() [2/2]

piece::piece ( const chess_color  color,
const piece_type  type,
const std::string &  coordinat,
const race  r = race::classic 
)
explicit

Member Function Documentation

◆ add_action()

void piece::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.

See also
'tick' processes the actions

◆ add_message()

void piece::add_message ( const message_type message)

Add a message, i.e. a thing to say for this piece.

◆ clear_messages()

void piece::clear_messages ( )
noexcept

Clear all the sound effects, i.e. remove all.

◆ get_action_history()

const auto & piece::get_action_history ( ) const
inlinenoexcept

Get the actions history.

◆ get_actions() [1/2]

const auto & piece::get_actions ( ) const
inlinenoexcept

Get all the piece actions.

◆ get_actions() [2/2]

auto & piece::get_actions ( )
inlinenoexcept

Get all the piece actions.

◆ get_color()

const auto & piece::get_color ( ) const
inlinenoexcept

Get the color of the piece, i.e. white or black.

◆ get_current_action_progress()

delta_t piece::get_current_action_progress ( ) const

The progress of the current action, which is a value from zero to (and including) one.

◆ get_current_square()

const auto & piece::get_current_square ( ) const
inlinenoexcept

◆ get_health()

double piece::get_health ( ) const
inlinenoexcept

Get the health of the unit.

◆ get_id()

const piece_id & piece::get_id ( ) const
inlinenoexcept

The unique piece ID.

◆ get_in_game_time()

const auto & piece::get_in_game_time ( ) const
inlinenoexcept

Get the in-game time according to this piece.

◆ get_kill_count()

int piece::get_kill_count ( ) const
inlinenoexcept

Get the number of pieces this piece has killd.

◆ get_max_health()

double piece::get_max_health ( ) const
inlinenoexcept

Get the maximum health of the unit.

◆ get_max_shield()

double piece::get_max_shield ( ) const

Get the maximum shield value of the unit.

Assume this unit is a Rooxx unit

◆ get_messages()

const auto & piece::get_messages ( ) const
inlinenoexcept

The things this piece wants to say.

◆ get_race()

const auto & piece::get_race ( ) const
inlinenoexcept

Get the race of a piece.

◆ get_shield()

double piece::get_shield ( ) const

Get the shield value of the unit.

Assumes this unit is a Rooxx unit

◆ get_type()

const auto & piece::get_type ( ) const
inlinenoexcept

Get the type of piece, e.g. king, queen, rook, bishop, knight, pawn.

◆ has_moved()

bool piece::has_moved ( ) const
inlinenoexcept

Has this piece (attempted to) moved?

◆ increase_kill_count()

void piece::increase_kill_count ( )
inlinenoexcept

Increase the kill count by one.

◆ is_enpassantable()

bool piece::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.

◆ receive_damage()

void piece::receive_damage ( const double  damage)

Receive damage.

Parameters
damagea positive value

◆ set_current_action_progress()

void piece::set_current_action_progress ( const delta_t t)
noexcept

Set the current progres an action has passed.

◆ set_current_square()

void piece::set_current_square ( const square s)
inlinenoexcept

Set the current/occupied square.

◆ tick()

void piece::tick ( const delta_t dt,
game g 
)

Do one frame of movement, resulting in a piece movement of 1 * delta_t.

Parameters
delta_tthe fraction of a full move that is done, where 0.01 means that only 1% of the full move is done and 1.0 denotes doing a full move.
occupied_squaresthe squares that are occupied
See also
use 'add_action' to add an action to be processed

The documentation for this class was generated from the following files: