From 33fbb2451fdac7f36bf3934aab0f64bb0896bf08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atle=20Hellvik=20Havs=C3=B8?= Date: Tue, 23 Nov 2010 13:24:21 +0100 Subject: Added a second target to Action. --- common/action.h | 3 +++ server/standard.cpp | 30 ++++++++++++++---------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/common/action.h b/common/action.h index 1c07086..c4237e6 100644 --- a/common/action.h +++ b/common/action.h @@ -23,6 +23,8 @@ class Action { //! Target of action (if applicable). int target; + //! Second target of action (if applicable) + int target2; //! Player doing this action int player; @@ -31,6 +33,7 @@ class Action { void serialize(Archive & ar, const unsigned int version) { ar & type; ar & target; + ar & target2; ar & player; } }; diff --git a/server/standard.cpp b/server/standard.cpp index a45c018..7ffd6ac 100644 --- a/server/standard.cpp +++ b/server/standard.cpp @@ -148,9 +148,10 @@ State& Standard::round_update() { chi = true; } if(chi) { - temp_action.player = temp_next_player; - temp_action.target = tile_2u_id; - temp_action.type = Action::Chi; + temp_action.player = temp_next_player; + temp_action.target = tile_2u_id; + temp_action.target2 = tile_1u_id; + temp_action.type = Action::Chi; game_state.possible_actions.push_back(temp_action); #ifdef DEBUG @@ -173,9 +174,10 @@ State& Standard::round_update() { chi = true; } if(chi) { - temp_action.player = temp_next_player; - temp_action.target = tile_1u_id; - temp_action.type = Action::Chi; + temp_action.player = temp_next_player; + temp_action.target = tile_1u_id; + temp_action.target2 = tile_1o_id; + temp_action.type = Action::Chi; game_state.possible_actions.push_back(temp_action); #ifdef DEBUG @@ -199,9 +201,10 @@ State& Standard::round_update() { chi = true; } if(chi) { - temp_action.player = temp_next_player; - temp_action.target = tile_1o_id; - temp_action.type = Action::Chi; + temp_action.player = temp_next_player; + temp_action.target = tile_1o_id; + temp_action.target2 = tile_2o_id; + temp_action.type = Action::Chi; game_state.possible_actions.push_back(temp_action); #ifdef DEBUG @@ -380,17 +383,12 @@ bool Standard::round_action(Action action) { Tile middle_tile = game_state.players[action.player].hand[action.target]; chi.add_tile(middle_tile); - Tile right_tile; - if(Tile::Type(game_state.players[action.player].hand[action.target].type + 1) == left_tile.type) { - right_tile = game_state.players[action.player].hand[action.target + 2]; - } else { - right_tile = game_state.players[action.player].hand[action.target + 1]; - } + Tile right_tile = game_state.players[action.player].hand[action.target2]; chi.add_tile(right_tile); game_state.players[action.player].open.push_back(chi); 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); + game_state.players[action.player].hand.erase(game_state.players[action.player].hand.begin() + action.target2 - 1); } break; -- cgit v1.2.3