Allow only actions for current priority.

This commit is contained in:
magenoxx 2011-08-05 19:46:41 +04:00
parent a6c3e03885
commit 4cafa3fc52

View file

@ -572,27 +572,20 @@ public class GameController implements GameCallback {
private void sendMessage(UUID userId, Command command) { private void sendMessage(UUID userId, Command command) {
final UUID playerId = userPlayerMap.get(userId); final UUID playerId = userPlayerMap.get(userId);
if (game.getPlayer(playerId).isGameUnderControl()) { if (game.getPlayer(playerId).isGameUnderControl()) {
if (game.getPlayer(playerId).getPlayersUnderYourControl().size() == 0) {
// we have a problem with synchronization between priorityId and message sent
// so have to check the size of list of players controlled
if (gameSessions.containsKey(playerId))
command.execute(playerId);
} else {
// if it's your priority (or game not started yet in which case it will be null) // if it's your priority (or game not started yet in which case it will be null)
// then execute only your action // then execute only your action
//if (game.getPriorityPlayerId() == null || game.getPriorityPlayerId().equals(playerId)) { if (game.getPriorityPlayerId() == null || game.getPriorityPlayerId().equals(playerId)) {
if (gameSessions.containsKey(playerId)) if (gameSessions.containsKey(playerId))
command.execute(playerId); command.execute(playerId);
//} // otherwise execute the action under other player's control } // otherwise execute the action under other player's control
//else { else {
//System.out.println("asThough: " + playerId + " " + game.getPriorityPlayerId()); //System.out.println("asThough: " + playerId + " " + game.getPriorityPlayerId());
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);
for (UUID controlled : player.getPlayersUnderYourControl()) { for (UUID controlled : player.getPlayersUnderYourControl()) {
if (gameSessions.containsKey(controlled) && game.getPriorityPlayerId().equals(controlled)) if (gameSessions.containsKey(controlled) && game.getPriorityPlayerId().equals(controlled))
command.execute(controlled); command.execute(controlled);
} }
//} }
}
} else { } else {
// ignore - no control over the turn // ignore - no control over the turn
return; return;