summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOle Daniel Evensen <ole_daniel_evensen@hotmail.com>2010-11-24 16:01:20 +0100
committerOle Daniel Evensen <ole_daniel_evensen@hotmail.com>2010-11-24 16:01:28 +0100
commitffde162fe9fd2da904c0072d5a182de7480c5ea6 (patch)
treeaeb120a2dced76b85e8ab1ecbb34ea3eca36ffdc
parent3756ecd1de73169f9eee32a65d35fab76abb212f (diff)
Wrote server-check for pon/kan possible actions.
-rw-r--r--server/player.h2
-rw-r--r--server/standard.cpp50
-rw-r--r--server/standard.h2
3 files changed, 50 insertions, 4 deletions
diff --git a/server/player.h b/server/player.h
index f558711..af9c59e 100644
--- a/server/player.h
+++ b/server/player.h
@@ -65,4 +65,6 @@ class Player : public boost::enable_shared_from_this<Player> {
void kill_action();
};
+typedef std::vector<Player> Players;
+
#endif
diff --git a/server/standard.cpp b/server/standard.cpp
index 4b54c37..2dbc038 100644
--- a/server/standard.cpp
+++ b/server/standard.cpp
@@ -88,8 +88,6 @@ State& Standard::round_update() {
draw_phase = false;
smart = smart | (1 << current_player);
} else {
- //We chwck to see if player can chi from last discard
-
int temp_next_player;
if (current_player == 3) {
@@ -101,11 +99,57 @@ State& Standard::round_update() {
Tiles* pond = &game_state.players[current_player].pond;
Tile temp_tile = pond->back();
Tiles::iterator it;
+
+ //We check to see if any players have kan/pon
+ //Tile* tile_m1, tile_m2, tile_m3;
+ //int tile_m1_id, tile_m2_id, tile_m3_id;
+ unsigned int tile_match_ids[3];
+ //Tile* tile_matches[3] = {NULL, NULL, NULL};
+ unsigned int count, count_m;
+ for(unsigned int array_counter = 0; array_counter < 4; array_counter++) {
+ State::Player* temp_player = &game_state.players[array_counter];
+ //tile_m1 = NULL;
+ //tile_m2 = NULL;
+ //tile_m3 = NULL;
+ //tile_matches = {NULL, NULL, NULL};
+ count = 0;
+ count_m = 0;
+ for(it = temp_player->hand.begin(); it != temp_player->hand.end(); ++it) {
+ if(it->type == temp_tile.type) {
+ //tile_matches[count_m] = *it;
+ tile_match_ids[count_m] = count;
+ count_m++;
+ }
+ count++;
+ }
+
+ if(tile_match_ids[1]) {
+ Action temp_action;
+ temp_action.player = array_counter;
+ temp_action.target.push_back(tile_match_ids[0]);
+ temp_action.target.push_back(tile_match_ids[1]);
+ temp_action.type = Action::Pon;
+ game_state.possible_actions.push_back(temp_action);
+ }
+
+ if(tile_match_ids[2]) {
+ Action temp_action;
+ temp_action.player = array_counter;
+ temp_action.target.push_back(tile_match_ids[0]);
+ temp_action.target.push_back(tile_match_ids[1]);
+ temp_action.target.push_back(tile_match_ids[2]);
+ temp_action.type = Action::Kan;
+ game_state.possible_actions.push_back(temp_action);
+ }
+ }
+
+ //We check to see if player can chi from last discard
Tile* tile_2u = NULL;
Tile* tile_1u = NULL;
Tile* tile_1o = NULL;
Tile* tile_2o = NULL;
- unsigned int count = 0, tile_2u_id,tile_1u_id,tile_1o_id,tile_2o_id;
+ unsigned int tile_2u_id,tile_1u_id,tile_1o_id,tile_2o_id;
+ count = 0;
Tile::Type check_tile;
for(it = game_state.players[temp_next_player].hand.begin(); it != game_state.players[temp_next_player].hand.end(); ++it) {
#ifdef DEBUG
diff --git a/server/standard.h b/server/standard.h
index de81e7f..4e5e4fb 100644
--- a/server/standard.h
+++ b/server/standard.h
@@ -2,7 +2,7 @@
#define STANDARD_H
#include "gamevariant.h"
-
+#include "player.h"
#include "wall.h"
#include "../common/set.h"