summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAtle Hellvik Havsø <atle@havso.net>2010-11-23 13:24:21 +0100
committerAtle Hellvik Havsø <atle@havso.net>2010-11-23 13:24:21 +0100
commit33fbb2451fdac7f36bf3934aab0f64bb0896bf08 (patch)
tree2713be52cc1b524ba124e332fdb79c56d62f6f07
parent62a05732e05a25f40fbb409e49ff30e3fc8bd28c (diff)
Added a second target to Action.
-rw-r--r--common/action.h3
-rw-r--r--server/standard.cpp30
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;