From 10ecd24fa6f22c5b72e7cfb1b6e0025347821149 Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Fri, 19 Nov 2010 17:50:56 +0100 Subject: Add Action and State classes. --- common/action.h | 36 ++++++++++++++++++++++++++++++++++++ common/state.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 common/action.h create mode 100644 common/state.h diff --git a/common/action.h b/common/action.h new file mode 100644 index 0000000..21fc7d0 --- /dev/null +++ b/common/action.h @@ -0,0 +1,36 @@ +#ifndef ACTION_H +#define ACTION_H + +#include + +class Action { + public: + //! Action types. + enum Type { + Pass, // discard + Discard, // draw + Riichi, // draw + Chi, // discard + Pon, // discard + Kan, // draw, discard + Ron, // discard + Tsumo, // draw + Draw // draw + }; + + //! Type of action. + Type type; + + //! Target of action (if applicable). + int target; + + template + void serialize(Archive & ar, const unsigned int version) { + ar & type; + ar & target; + } +}; + +typedef std::vector Actions; + +#endif diff --git a/common/state.h b/common/state.h new file mode 100644 index 0000000..96f171f --- /dev/null +++ b/common/state.h @@ -0,0 +1,42 @@ +#ifndef STATE_H +#define STATE_H + +#include + +#include "tile.h" +#include "action.h" + +class State { + public: + typedef boost::shared_ptr p; + + struct Player { + //! Concealed tiles in hand. + Tiles hand; + //! Open tiles in hand. + Tiles open; + //! Discarded tiles. + Tiles pond; + + template + void serialize(Archive & ar, const unsigned int version) { + ar & hand; + ar & open; + ar & pond; + } + }; + + //! State of players. + Player players[4]; + + //! Possible actions. + Actions possible_actions; + + template + void serialize(Archive & ar, const unsigned int version) { + ar & players; + ar & possible_actions; + } +}; + +#endif \ No newline at end of file -- cgit v1.2.3