mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
Fixed Issue 23.
This commit is contained in:
parent
beb1830243
commit
8d60ade078
1 changed files with 13 additions and 6 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue