diff options
author | Vegard Storheil Eriksen <zyp@jvnv.net> | 2010-12-03 10:31:26 +0100 |
---|---|---|
committer | Vegard Storheil Eriksen <zyp@jvnv.net> | 2010-12-03 10:31:26 +0100 |
commit | 391b6e2ad7541100191c2f2d4dd9ea5163de8f19 (patch) | |
tree | 422870cc813b9c773ad1f2b99b88cab66ea9492c | |
parent | 98bb8a87572fa4ebfac4faf54670b6686b41943b (diff) |
Add PlayerState and GameState-structs to bundle together related information.
-rw-r--r-- | common/state.h | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/common/state.h b/common/state.h new file mode 100644 index 0000000..d9b24c4 --- /dev/null +++ b/common/state.h @@ -0,0 +1,64 @@ +#ifndef STATE_H +#define STATE_H + +#include "tile.h" + +//! Class containing the game state related to each player. +struct PlayerState { + //! Player's hand. Concealed tiles is first set, open sets follow in the order they was called in. + Tilegroups hand; + + //! Discarded tiles. + Tiles pond; + + //! Flag indicating whether player has declared riichi. + bool riichi; + + //! Player's score. + int score; + + //! Player's seat wind. + int wind; + + template<class Archive> + void serialize(Archive & ar, const unsigned int v) { + ar & hand; + ar & pond; + ar & riichi; + ar & score; + ar & wind; + } +}; + +//! Class containing the game state unrelated to the players. +struct GameState { + //! List of dora/kandora. + Tiles dora; + + //! Current player, relative to context. 0 = self, 1 = shimocha and so on. + int current_player; + + //! Round (prevalent) wind. + int round_wind; + + //! Round number (of this wind). + int round_number; + + //! Count of riichi sticks on table (current and leftovers). + int riichibou; + + //! Count of honba sticks on table (indicating renchan). + int honba; + + template<class Archive> + void serialize(Archive & ar, const unsigned int v) { + ar & dora; + ar & current_player; + ar & round_wind; + ar & round_number; + ar & riichibou; + ar & honba; + } +}; + +#endif |