- Cleanup and NPE protection.

This commit is contained in:
Sloth
2015-02-08 13:36:17 +00:00
parent 2c2139e3d6
commit b5dd19867a
3 changed files with 20 additions and 25 deletions

View File

@@ -110,13 +110,15 @@ public class GameCopier {
} }
} }
} }
newSa.setActivatingPlayer(map.map(origSa.getActivatingPlayer())); if (newSa != null) {
if (origSa.usesTargeting()) { newSa.setActivatingPlayer(map.map(origSa.getActivatingPlayer()));
for (GameObject o : origSa.getTargets().getTargets()) { if (origSa.usesTargeting()) {
newSa.getTargets().add(map.map(o)); for (GameObject o : origSa.getTargets().getTargets()) {
} newSa.getTargets().add(map.map(o));
}
}
newGame.getStack().add(newSa);
} }
newGame.getStack().add(newSa);
} }
} }

View File

@@ -162,13 +162,8 @@ public class GameSimulator {
return Integer.MIN_VALUE; return Integer.MIN_VALUE;
} }
// TODO: Support multiple opponents. // TODO: Support multiple opponents.
Player opponent = null; Player opponent = aiPlayer.getOpponent();
for (Player p : simGame.getPlayers()) {
if (p != aiPlayer) {
opponent = p;
break;
}
}
resolveStack(simGame, opponent); resolveStack(simGame, opponent);
// TODO: If this is during combat, before blockers are declared, // TODO: If this is during combat, before blockers are declared,

View File

@@ -1407,19 +1407,17 @@ public class GameAction {
} }
// Power Play - Each player with a Power Play in the CommandZone becomes the Starting Player // Power Play - Each player with a Power Play in the CommandZone becomes the Starting Player
CardCollectionView commandCards = game.getCardsIn(ZoneType.Command); Set<Player> powerPlayers = new HashSet<>();
if (commandCards.size() > 0) { for (Card c : game.getCardsIn(ZoneType.Command)) {
CardCollection powerPlays = CardLists.getValidCards(commandCards, "Card.namedPower Play", game.getPlayers().getFirst(), commandCards.getFirst()); if (c.getName().equals("Power Play")) {
Set<Player> powerPlayers = new HashSet<>(); powerPlayers.add(c.getOwner());
for (Card c : powerPlays) { }
powerPlayers.add(c.getOwner()); }
}
if (powerPlayers.size() > 0) { if (!powerPlayers.isEmpty()) {
ArrayList<Player> players = Lists.newArrayList(powerPlayers); ArrayList<Player> players = Lists.newArrayList(powerPlayers);
Collections.shuffle(players); Collections.shuffle(players);
return players.get(0); return players.get(0);
}
} }
boolean isFirstGame = lastGameOutcome == null; boolean isFirstGame = lastGameOutcome == null;