forked from External/mage
Refactor effects which disable the "legend rule" (#9662)
This commit is contained in:
parent
1fece87819
commit
3ed26a2b1f
15 changed files with 243 additions and 211 deletions
|
|
@ -36,6 +36,7 @@ import mage.filter.StaticFilters;
|
|||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.mageobject.NamePredicate;
|
||||
import mage.filter.predicate.permanent.ControllerIdPredicate;
|
||||
import mage.filter.predicate.permanent.LegendRuleAppliesPredicate;
|
||||
import mage.game.combat.Combat;
|
||||
import mage.game.command.*;
|
||||
import mage.game.command.dungeons.UndercityDungeon;
|
||||
|
|
@ -2478,7 +2479,7 @@ public abstract class GameImpl implements Game {
|
|||
somethingHappened = true;
|
||||
}
|
||||
}
|
||||
if (this.getState().isLegendaryRuleActive() && StaticFilters.FILTER_PERMANENT_LEGENDARY.match(perm, this)) {
|
||||
if (perm.isLegendary() && perm.legendRuleApplies()) {
|
||||
legendary.add(perm);
|
||||
}
|
||||
if (StaticFilters.FILTER_PERMANENT_EQUIPMENT.match(perm, this)) {
|
||||
|
|
@ -2571,22 +2572,24 @@ public abstract class GameImpl implements Game {
|
|||
filterLegendName.add(SuperType.LEGENDARY.getPredicate());
|
||||
filterLegendName.add(new NamePredicate(legend.getName()));
|
||||
filterLegendName.add(new ControllerIdPredicate(legend.getControllerId()));
|
||||
if (getBattlefield().contains(filterLegendName, legend.getControllerId(), null, this, 2)) {
|
||||
if (!replaceEvent(GameEvent.getEvent(GameEvent.EventType.DESTROY_PERMANENT_BY_LEGENDARY_RULE, legend.getId(), legend.getControllerId()))) {
|
||||
Player controller = this.getPlayer(legend.getControllerId());
|
||||
if (controller != null) {
|
||||
Target targetLegendaryToKeep = new TargetPermanent(filterLegendName);
|
||||
targetLegendaryToKeep.setTargetName(legend.getName() + " to keep (Legendary Rule)?");
|
||||
controller.chooseTarget(Outcome.Benefit, targetLegendaryToKeep, null, this);
|
||||
for (Permanent dupLegend : getBattlefield().getActivePermanents(filterLegendName, legend.getControllerId(), this)) {
|
||||
if (!targetLegendaryToKeep.getTargets().contains(dupLegend.getId())) {
|
||||
movePermanentToGraveyardWithInfo(dupLegend);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
filterLegendName.add(LegendRuleAppliesPredicate.instance);
|
||||
if (!getBattlefield().contains(filterLegendName, legend.getControllerId(), null, this, 2)) {
|
||||
continue;
|
||||
}
|
||||
Player controller = this.getPlayer(legend.getControllerId());
|
||||
if (controller == null) {
|
||||
continue;
|
||||
}
|
||||
Target targetLegendaryToKeep = new TargetPermanent(filterLegendName);
|
||||
targetLegendaryToKeep.setNotTarget(true);
|
||||
targetLegendaryToKeep.setTargetName(legend.getName() + " to keep (Legendary Rule)?");
|
||||
controller.choose(Outcome.Benefit, targetLegendaryToKeep, null, this);
|
||||
for (Permanent dupLegend : getBattlefield().getActivePermanents(filterLegendName, legend.getControllerId(), this)) {
|
||||
if (!targetLegendaryToKeep.getTargets().contains(dupLegend.getId())) {
|
||||
movePermanentToGraveyardWithInfo(dupLegend);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//704.5k - World Enchantments
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue