diff options
author | Ole Daniel Evensen <ole_daniel_evensen@hotmail.com> | 2010-11-24 16:20:46 +0100 |
---|---|---|
committer | Ole Daniel Evensen <ole_daniel_evensen@hotmail.com> | 2010-11-24 16:20:46 +0100 |
commit | aa3525bc668ac23a3cc82cefa78b96a766f72a53 (patch) | |
tree | c3317352d81e5360f1ccf38c438021b8e0a142f4 | |
parent | 593cbaa0a81df937a5f34d7fa7cd85a732ba3936 (diff) |
Added server-handling for pon/kan-actions.
-rw-r--r-- | server/standard.cpp | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/server/standard.cpp b/server/standard.cpp index 8192152..78367b5 100644 --- a/server/standard.cpp +++ b/server/standard.cpp @@ -438,10 +438,62 @@ bool Standard::round_action(Action action) { } break; case Action::Pon: { - + Tile left_tile = game_state.players[current_player].pond.back(); + left_tile.rotated = true; + game_state.players[action.player].open.push_back(left_tile); + + int count = 0; + for(std::vector<int>::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++; + } + + Action discard; + discard.type = Action::Discard; + discard.player = action.player; + game_state.possible_actions.push_back(discard); + + draw_phase = false;//player must discard extra tile + + //Player steals round + if(current_player == 0) { + current_player = 3; + } else { + current_player = action.player-1; + } + } break; case Action::Kan: { + Tile left_tile = game_state.players[current_player].pond.back(); + left_tile.rotated = true; + game_state.players[action.player].open.push_back(left_tile); + + int count = 0; + for(std::vector<int>::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++; + } + + Action discard; + discard.type = Action::Discard; + discard.player = action.player; + game_state.possible_actions.push_back(discard); + + draw_phase = false;//player must discard extra tile + + //Player steals round + if(current_player == 0) { + current_player = 3; + } else { + current_player = action.player-1; + } } break; |