summaryrefslogtreecommitdiff
path: root/src/hand.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/hand.h')
-rw-r--r--src/hand.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/hand.h b/src/hand.h
new file mode 100644
index 0000000..b7ae8d2
--- /dev/null
+++ b/src/hand.h
@@ -0,0 +1,43 @@
+#ifndef HAND_H
+#define HAND_H
+
+#include "../common/tile.h"
+#include "../common/set.h"
+
+namespace Hand {
+ //! Check if the tiles constitute a complete hand. Also valid for the concealed part of an open hand.
+ bool agari(const Tiles& tiles);
+
+ //! Check if the tiles miss only one from constituting a complete hand. Also valid for the concealed part of an open hand.
+ bool tenpai(const Tiles& tiles);
+
+ //! Get list of possible breakdowns of a complete hand.
+ List<Sets> get_breakdowns(const Tiles& tiles);
+
+ // Check if the tiles is matching the normal format of one pair and rest triplets.
+ bool basic_format(const Tiles& tiles, bool pair_eaten = false);
+ void basic_format(const Tiles& tiles, List<Sets>& hands, const Sets& hand = Sets(), bool pair_eaten = false);
+
+ // Check if the tiles is matching the normal format but missing one.
+ bool basic_format_tenpai(const Tiles& tiles, bool pair_eaten = false, bool wait_eaten = false);
+
+ // Eat a single tile (i.e. the tanki machi) from beginning of list and return success flag.
+ bool eat_tanki(Tiles& tiles);
+
+ // Eat two tiles waiting for a third to complete a chi (i.e. ryanmen, penchan or kanchan machi) if possible and return success flag.
+ bool eat_chi_wait(Tiles& tiles);
+
+ // Eat a pair from beginning of list if possible and return success flag.
+ bool eat_pair(Tiles& tiles);
+ bool eat_pair(Tiles& tiles, Sets& hand);
+
+ // Eat a pon from beginning of list if possible and return success flag.
+ bool eat_pon(Tiles& tiles);
+ bool eat_pon(Tiles& tiles, Sets& hand);
+
+ // Eat a chi from beginning of list if possible and return success flag.
+ bool eat_chi(Tiles& tiles);
+ bool eat_chi(Tiles& tiles, Sets& hand);
+}
+
+#endif