|
| trick () |
| Constructs a new trick object.
|
|
| trick (const std::string &id) |
| Constructs a new trick object (from_diff).
|
|
| trick (const std::string &id, const std::vector< std::pair< card *, player * > > &cards, serializable_value< int > *trick_color, serializable_value< int > *trump_color) |
| Constructs a new trick object during deserialization.
|
|
| trick (int trump) |
| Constructs a new trick object.
|
|
| ~trick () override |
| Destructs a trick object.
|
|
int | get_trick_color () const |
| Gets the trick color.
|
|
std::vector< std::pair< card *, player * > > | get_cards_and_players () const |
| Gets the played cards and players who played them as pairs.
|
|
int | get_trump_color () const |
| Gets the trump color.
|
|
void | set_up_round (int trump, std::string &err) |
| Sets up a trick.
|
|
player * | wrap_up_trick (std::string &err) const |
| Wraps up a trick at the end of a trick or round.
|
|
bool | add_card (card *played_card, player *current_player, std::string &err) |
| Adds a card to the trick.
|
|
void | set_trick_color (int color) const |
| Sets the trick color.
|
|
void | write_into_json (rapidjson::Value &json, rapidjson::Document::AllocatorType &allocator) const override |
| Serializes a trick object into a json object.
|
|
std::string | get_id () const |
|
virtual void | write_into_json (rapidjson::Value &json, rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > &allocator) const override |
|
virtual rapidjson::Document * | to_json () const |
|
Represents the trick in the game.
This class encapsulates all information about a trick, including the trick color (suit of the trick), the trump color, and the cards played in the trick.
Every round consists of round-number-many tricks. In each trick, each player plays exactly one card. The first played color determines the trick color, and other players must play cards of that color if they hold any (exception: wizards and jesters can always be played). Each trick has one winner, which is determined by the player who played the first wizard, or by the player who played the highest trump color card, or by the player who played the highest trick color card (in that order).
player * trick::wrap_up_trick |
( |
std::string & | err | ) |
const |
Wraps up a trick at the end of a trick or round.
- Parameters
-
err | The error message updated in case something does not work. |
- Returns
- The player who won the trick.
To wrap up the trick, this function determines the winner of the trick. This is done considering the cards that have been played during the trick, and considering the trump color. The round is won by the player who played the first wizard, or the first jester in case all players play jesters. If neither wizards nor 4 jesters are played, the player who played the highest card of the trump color wins the trick. If no such card is played, the player with the highest trick color (suit) card wins.