mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
- Refactor AnnihilatorAbility().
This commit is contained in:
parent
7ffcf39260
commit
469ddcea6b
1 changed files with 16 additions and 13 deletions
|
@ -30,7 +30,6 @@ package mage.abilities.keyword;
|
|||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
|
@ -79,9 +78,9 @@ 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()) {
|
||||
getEffects().forEach((effect) -> {
|
||||
effect.setValue("defendingPlayerId", defendingPlayerId);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -125,19 +124,23 @@ class AnnihilatorEffect extends OneShotEffect {
|
|||
}
|
||||
if (player != null) {
|
||||
int amount = Math.min(count, game.getBattlefield().countAll(FILTER, player.getId(), game));
|
||||
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(target.getTargets().get(idx));
|
||||
if (permanent != null) {
|
||||
permanent.sacrifice(source.getSourceId(), game);
|
||||
if (amount > 0) {
|
||||
Target target = new TargetControlledPermanent(amount, amount, FILTER, true);
|
||||
if (target.canChoose(player.getId(), game)) {
|
||||
while (player.canRespond()
|
||||
&& target.canChoose(player.getId(), game)
|
||||
&& !target.isChosen()) {
|
||||
player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
|
||||
}
|
||||
for (int idx = 0; idx < target.getTargets().size(); idx++) {
|
||||
Permanent permanent = game.getPermanent(target.getTargets().get(idx));
|
||||
if (permanent != null) {
|
||||
permanent.sacrifice(source.getSourceId(), game);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue