Fixed range fro SacrificeAllEffect and Burning Inquiry

This commit is contained in:
North 2012-06-20 00:15:13 +03:00
parent 239a4fb100
commit a6a333422b
2 changed files with 123 additions and 109 deletions

View file

@ -84,7 +84,12 @@ class BurningInquiryEffect extends OneShotEffect<BurningInquiryEffect> {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
for (UUID playerId : game.getPlayerList()) { Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
for (UUID playerId : controller.getInRange()) {
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);
if (player != null) { if (player != null) {
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {

View file

@ -74,21 +74,30 @@ public class SacrificeAllEffect extends OneShotEffect<SacrificeAllEffect> {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
List<UUID> perms = new ArrayList<UUID>(); List<UUID> perms = new ArrayList<UUID>();
for (Player player: game.getPlayers().values()) { for (UUID playerId : controller.getInRange()) {
int numTargets = Math.min(amount, game.getBattlefield().countAll(filter, player.getId(), game)); Player player = game.getPlayer(playerId);
TargetControlledPermanent target = new TargetControlledPermanent(numTargets, numTargets, filter, false); if (player != null) {
if (target.canChoose(player.getId(), game)) { int numTargets = Math.min(amount, game.getBattlefield().countAll(filter, player.getId(), game));
while (!target.isChosen()) { TargetControlledPermanent target = new TargetControlledPermanent(numTargets, numTargets, filter, false);
player.choose(Outcome.Sacrifice, target, source.getSourceId(), game); if (target.canChoose(player.getId(), game)) {
while (!target.isChosen()) {
player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
}
perms.addAll(target.getTargets());
} }
perms.addAll(target.getTargets());
} }
} }
for (UUID permID: perms) { for (UUID permID : perms) {
Permanent permanent = game.getPermanent(permID); Permanent permanent = game.getPermanent(permID);
if (permanent != null) if (permanent != null) {
permanent.sacrifice(source.getSourceId(), game); permanent.sacrifice(source.getSourceId(), game);
}
} }
return true; return true;
} }