summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/game.h3
-rw-r--r--server/player.cpp37
-rw-r--r--server/wall.cpp2
3 files changed, 32 insertions, 10 deletions
diff --git a/server/game.h b/server/game.h
index bf7d37f..fca71fa 100644
--- a/server/game.h
+++ b/server/game.h
@@ -9,6 +9,7 @@
#include "wall.h"
#include "client.h"
#include "../common/action.h"
+#include "../common/set.h"
#include "../common/state.h"
#include "../common/cyclicint.h"
@@ -28,7 +29,7 @@ class Game : public boost::enable_shared_from_this<Game> {
ClientBase::p client;
Tiles hand;
- Tilegroups open;
+ Sets open;
Tiles pond;
bool riichi;
int score;
diff --git a/server/player.cpp b/server/player.cpp
index ae07360..2454a98 100644
--- a/server/player.cpp
+++ b/server/player.cpp
@@ -17,16 +17,24 @@ void Game::Player::round_start(int w) {
}
PlayerState Game::Player::get_state() {
- Tilegroups h = open;
- h.insert(h.begin(), hand);
+ Tilegroups h;
+ h.push_back(hand);
+
+ for(Sets::iterator it = open.begin(); it != open.end(); it++) {
+ h.push_back(it->tiles);
+ }
PlayerState state = {h, pond, riichi, score, wind};
return state;
}
PlayerState Game::Player::get_state_filtered() {
- Tilegroups h = open;
- h.insert(h.begin(), hand);
+ Tilegroups h;
+ h.push_back(hand);
+
+ for(Sets::iterator it = open.begin(); it != open.end(); it++) {
+ h.push_back(it->tiles);
+ }
PlayerState state = {h, pond, riichi, score, wind};
return state;
@@ -87,6 +95,8 @@ Actions Game::Player::get_actions_draw() {
}
Actions Game::Player::get_actions_discard(Tile tile, PlayerNum discarder) {
+ std::cout << "Fisk:" << std::endl;
+
Actions possible_actions;
if(!riichi) {
@@ -102,11 +112,12 @@ Actions Game::Player::get_actions_discard(Tile tile, PlayerNum discarder) {
// Check if tile can be called for a pon.
int target = can_pon(tile);
- if(target > 0) {
+ if(target >= 0) {
possible_actions.push_back(Action(Action::Pon, Action::Index, target + 1));
// Check if tile can be called for a kan.
if(can_kan(tile, target)) {
+ std::cout << "Can kan!" << std::endl;
possible_actions.push_back(Action(Action::Kan, Action::Index, target + 2));
}
}
@@ -215,7 +226,15 @@ Game::Player::Targets Game::Player::can_kan() {
}
Game::Player::Targets Game::Player::can_kan_extend() {
- return Targets(); // TODO: Waiting for sets.
+ Targets targets;
+
+ for(Sets::iterator it = open.begin(); it != open.end(); it++) {
+ if(it->type == Set::Pon && hand.contains(it->tiles.front())) {
+ targets.push_back(it - open.begin() + 1);
+ }
+ }
+
+ return targets;
}
bool Game::Player::can_kan(Tile tile, int target) {
@@ -303,7 +322,7 @@ void Game::Player::make_chi(Tile tile, int target) {
hand.erase(it);
}
- open.push_back(chi);
+ open.push_back(Set(Set::Chi, chi, true));
}
void Game::Player::make_pon(Tile tile, int target, PlayerNum discarder) {
@@ -329,7 +348,7 @@ void Game::Player::make_pon(Tile tile, int target, PlayerNum discarder) {
pon.push_back(tile);
}
- open.push_back(pon);
+ open.push_back(Set(Set::Pon, pon, true));
}
void Game::Player::make_kan(Tile tile, int target, PlayerNum discarder) {
@@ -358,5 +377,5 @@ void Game::Player::make_kan(Tile tile, int target, PlayerNum discarder) {
kan.push_back(tile);
}
- open.push_back(kan);
+ open.push_back(Set(Set::Kan, kan, true));
}
diff --git a/server/wall.cpp b/server/wall.cpp
index 1c9ec04..714e519 100644
--- a/server/wall.cpp
+++ b/server/wall.cpp
@@ -27,6 +27,8 @@ int Wall::remaining() {
}
Tile Wall::take_one() {
+ return wall.front();
+
boost::uniform_int<> range(0, wall.size() - 1);
boost::variate_generator<boost::mt19937&, boost::uniform_int<> > die(rand_gen, range);