From ffde162fe9fd2da904c0072d5a182de7480c5ea6 Mon Sep 17 00:00:00 2001 From: Ole Daniel Evensen Date: Wed, 24 Nov 2010 16:01:20 +0100 Subject: Wrote server-check for pon/kan possible actions. --- server/standard.cpp | 50 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 3 deletions(-) (limited to 'server/standard.cpp') 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 -- cgit v1.2.3