* AnnihilatorAbility - Fixed that the sacrifice effect was handled targeted.

This commit is contained in:
LevelX2 2015-08-06 16:21:42 +02:00
parent 0a341ea1eb
commit b14c5d059b

View file

@ -79,7 +79,7 @@ public class AnnihilatorAbility extends TriggeredAbilityImpl {
UUID defendingPlayerId = game.getCombat().getDefendingPlayerId(sourceId, game);
if (defendingPlayerId != null) {
// the id has to be set here because the source can be leave battlefield
for(Effect effect : getEffects()) {
for (Effect effect : getEffects()) {
effect.setValue("defendingPlayerId", defendingPlayerId);
}
return true;
@ -90,8 +90,8 @@ public class AnnihilatorAbility extends TriggeredAbilityImpl {
@Override
public String getRule() {
return "Annihilator " + count + "<i>(Whenever this creature attacks, defending player sacrifices " +
(count == 1 ? "a permanent": CardUtil.numberToText(count) + " permanents") + ".)</i>";
return "Annihilator " + count + "<i>(Whenever this creature attacks, defending player sacrifices "
+ (count == 1 ? "a permanent" : CardUtil.numberToText(count) + " permanents") + ".)</i>";
}
@Override
@ -121,17 +121,17 @@ class AnnihilatorEffect extends OneShotEffect {
UUID defendingPlayerId = (UUID) getValue("defendingPlayerId");
Player player = null;
if (defendingPlayerId != null) {
player= game.getPlayer(defendingPlayerId);
player = game.getPlayer(defendingPlayerId);
}
if (player != null) {
int amount = Math.min(count, game.getBattlefield().countAll(filter, player.getId(), game));
Target target = new TargetControlledPermanent(amount, amount, filter, false);
Target target = new TargetControlledPermanent(amount, amount, filter, true);
if (target.canChoose(player.getId(), game)) {
while (!target.isChosen() && target.canChoose(player.getId(), game) && player.canRespond()) {
player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
}
for (int idx = 0; idx < target.getTargets().size(); idx++) {
Permanent permanent = game.getPermanent((UUID) target.getTargets().get(idx));
Permanent permanent = game.getPermanent(target.getTargets().get(idx));
if (permanent != null) {
permanent.sacrifice(source.getSourceId(), game);
}