From aa3525bc668ac23a3cc82cefa78b96a766f72a53 Mon Sep 17 00:00:00 2001 From: Ole Daniel Evensen Date: Wed, 24 Nov 2010 16:20:46 +0100 Subject: Added server-handling for pon/kan-actions. --- server/standard.cpp | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) 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::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::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; -- cgit v1.2.3