1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-04-13 17:00:09 -09:00

Control turn implementation fix.

This commit is contained in:
magenoxx 2011-08-05 17:23:09 +04:00
parent 7ed6935c40
commit 9223fe63ad

View file

@ -572,13 +572,26 @@ 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 (gameSessions.containsKey(playerId)) if (game.getPlayer(playerId).getPlayersUnderYourControl().size() == 0) {
command.execute(playerId); // we have a problem with synchronization between priorityId and message sent
// now send the same command to those whose turns you control // so have to check the size of list of players controlled
Player player = game.getPlayer(playerId); if (gameSessions.containsKey(playerId))
for (UUID controlled : player.getPlayersUnderYourControl()) { command.execute(playerId);
if (gameSessions.containsKey(controlled)) } else {
command.execute(controlled); // if it's your priority (or game not started yet in which case it will be null)
// then execute only your action
//if (game.getPriorityPlayerId() == null || game.getPriorityPlayerId().equals(playerId)) {
if (gameSessions.containsKey(playerId))
command.execute(playerId);
//} // otherwise execute the action under other player's control
//else {
//System.out.println("asThough: " + playerId + " " + game.getPriorityPlayerId());
Player player = game.getPlayer(playerId);
for (UUID controlled : player.getPlayersUnderYourControl()) {
if (gameSessions.containsKey(controlled) && game.getPriorityPlayerId().equals(controlled))
command.execute(controlled);
}
//}
} }
} else { } else {
// ignore - no control over the turn // ignore - no control over the turn