Fixed Issue 23.

This commit is contained in:
maurer.it 2010-12-30 09:47:10 -05:00
parent beb1830243
commit 8d60ade078

View file

@ -59,18 +59,25 @@ public class SacrificeEffect extends OneShotEffect<SacrificeEffect>{
@Override
public boolean apply(Game game, Ability source) {
boolean legalTargetsExist = false;
Player player = game.getPlayer(source.getTargets().getFirstTarget());
int numTargets = Math.min(1, game.getBattlefield().countAll(filter, player.getId()));
legalTargetsExist = numTargets > 0;
filter.setTargetController(TargetController.YOU);
TargetControlledPermanent target = new TargetControlledPermanent(numTargets, numTargets, filter, false);
while (!target.isChosen()) {
player.choose(Outcome.Sacrifice, target, game);
}
Permanent permanent = game.getPermanent(target.getFirstTarget());
//A spell or ability could have removed the only legal target this player
//had, if thats the case this ability should fizzle.
if ( legalTargetsExist ) {
while (!target.isChosen()) {
player.choose(Outcome.Sacrifice, target, game);
}
if ( permanent != null ) {
return permanent.sacrifice(source.getId(), game);
Permanent permanent = game.getPermanent(target.getFirstTarget());
if ( permanent != null ) {
return permanent.sacrifice(source.getId(), game);
}
}
return false;
}