From 0736e72be71331b843e2f49c3af0cb9071ee93ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atle=20Hellvik=20Havs=C3=B8?= Date: Tue, 23 Nov 2010 15:08:48 +0100 Subject: Changed the target in action from 2 ints into a vector. Making it easier to scale when we start with kan and riichi. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Atle Hellvik Havsø --- server/standard.cpp | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'server') diff --git a/server/standard.cpp b/server/standard.cpp index 08012d1..015308d 100644 --- a/server/standard.cpp +++ b/server/standard.cpp @@ -149,14 +149,14 @@ State& Standard::round_update() { } if(chi) { temp_action.player = temp_next_player; - temp_action.target = tile_2u_id; - temp_action.target2 = tile_1u_id; + temp_action.target.push_back(tile_2u_id); + temp_action.target.push_back(tile_1u_id); temp_action.type = Action::Chi; game_state.possible_actions.push_back(temp_action); #ifdef DEBUG time_t current_time = std::time(0); - std::cout << std::ctime(¤t_time) << " Player: " << temp_action.player << " Can do action: " << temp_action.type << " On target: " << temp_action.target << std::endl; + std::cout << std::ctime(¤t_time) << " Player: " << temp_action.player << " Can do action: " << temp_action.type << " On target: " << temp_action.target[0] << std::endl; #endif } @@ -175,15 +175,15 @@ State& Standard::round_update() { } if(chi) { temp_action.player = temp_next_player; - temp_action.target = tile_1u_id; - temp_action.target2 = tile_1o_id; + temp_action.target.push_back(tile_1u_id); + temp_action.target.push_back(tile_1o_id); temp_action.type = Action::Chi; game_state.possible_actions.push_back(temp_action); #ifdef DEBUG time_t current_time = std::time(0); - std::cout << std::ctime(¤t_time) << " Player: " << temp_action.player << " Can do action: " << temp_action.type << " On target: " << temp_action.target << std::endl; + std::cout << std::ctime(¤t_time) << " Player: " << temp_action.player << " Can do action: " << temp_action.type << " On target: " << temp_action.target[0] << std::endl; #endif } @@ -202,15 +202,15 @@ State& Standard::round_update() { } if(chi) { temp_action.player = temp_next_player; - temp_action.target = tile_1o_id; - temp_action.target2 = tile_2o_id; + temp_action.target.push_back(tile_1o_id); + temp_action.target.push_back(tile_2o_id); temp_action.type = Action::Chi; game_state.possible_actions.push_back(temp_action); #ifdef DEBUG time_t current_time = std::time(0); - std::cout << std::ctime(¤t_time) << " Player: " << temp_action.player << " Can do action: " << temp_action.type << " On target: " << temp_action.target << std::endl; + std::cout << std::ctime(¤t_time) << " Player: " << temp_action.player << " Can do action: " << temp_action.type << " On target: " << temp_action.target[0] << std::endl; #endif } @@ -274,7 +274,7 @@ bool Standard::round_action(Action action) { #ifdef DEBUG time_t current_time = std::time(0); - std::cout << std::ctime(¤t_time) << " Player: " << action.player << " Did action: " << action.type << " On target: " << action.target << std::endl; + std::cout << std::ctime(¤t_time) << " Player: " << action.player << " Did action: " << action.type << " On target: " << action.target[0] << std::endl; #endif @@ -305,9 +305,9 @@ bool Standard::round_action(Action action) { } break; case Action::Discard: { - Tile discarded_tile = game_state.players[action.player].hand[action.target]; + Tile discarded_tile = game_state.players[action.player].hand[action.target[0]]; game_state.players[action.player].pond.push_back(discarded_tile); - game_state.players[action.player].hand.erase(game_state.players[action.player].hand.begin() + action.target); + game_state.players[action.player].hand.erase(game_state.players[action.player].hand.begin() + action.target[0]); } break; @@ -379,14 +379,14 @@ bool Standard::round_action(Action action) { left_tile.rotated = true; game_state.players[action.player].open.push_back(left_tile); - Tile middle_tile = game_state.players[action.player].hand[action.target]; - game_state.players[action.player].open.push_back(middle_tile); - - Tile right_tile = game_state.players[action.player].hand[action.target2]; - game_state.players[action.player].open.push_back(right_tile); - - game_state.players[action.player].hand.erase(game_state.players[action.player].hand.begin() + action.target); - game_state.players[action.player].hand.erase(game_state.players[action.player].hand.begin() + action.target2 - 1); + int count = 0; + for(std::vector::iterator it = most_value_action.target.begin(); it != most_value_action.target.end(); ++it) { + Tile target_tile = game_state.players[action.player].hand[(*it) - count]; + game_state.players[action.player].open.push_back(target_tile); + game_state.players[action.player].hand.erase(game_state.players[action.player].hand.begin() + (*it) - count); + + count++; + } } break; -- cgit v1.2.3