diff options
-rw-r--r-- | server/player.h | 2 | ||||
-rw-r--r-- | server/standard.cpp | 50 | ||||
-rw-r--r-- | server/standard.h | 2 |
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" |