mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
* Polis Crusher - Fixed that it can't be the target of enchantments.
* Polis Crusher - Fixed that the targeted enchantment of it's second ability was chosen too late during resolution.
This commit is contained in:
parent
5a454cfad2
commit
8fa23501ee
5 changed files with 52 additions and 56 deletions
|
@ -33,22 +33,24 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
|
||||
import mage.abilities.condition.common.MonstrousCondition;
|
||||
import mage.abilities.decorator.ConditionalTriggeredAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.DestroyTargetEffect;
|
||||
import mage.abilities.keyword.MonstrosityAbility;
|
||||
import mage.abilities.keyword.ProtectionAbility;
|
||||
import mage.abilities.keyword.TrampleAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.common.FilterEnchantmentPermanent;
|
||||
import mage.filter.predicate.mageobject.CardTypePredicate;
|
||||
import mage.filter.predicate.permanent.ControllerIdPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.target.targetpointer.FirstTargetPointer;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -56,6 +58,12 @@ import mage.target.TargetPermanent;
|
|||
*/
|
||||
public class PolisCrusher extends CardImpl<PolisCrusher> {
|
||||
|
||||
private static final FilterCard filter = new FilterCard("enchantments");
|
||||
|
||||
static {
|
||||
filter.add(new CardTypePredicate(CardType.ENCHANTMENT));
|
||||
}
|
||||
|
||||
public PolisCrusher(UUID ownerId) {
|
||||
super(ownerId, 198, "Polis Crusher", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{2}{R}{G}");
|
||||
this.expansionSetCode = "THS";
|
||||
|
@ -69,12 +77,12 @@ public class PolisCrusher extends CardImpl<PolisCrusher> {
|
|||
// Trample
|
||||
this.addAbility(TrampleAbility.getInstance());
|
||||
// protection from enchantments
|
||||
this.addAbility(new ProtectionAbility(new FilterEnchantmentPermanent()));
|
||||
this.addAbility(new ProtectionAbility(filter));
|
||||
// {4}{R}{G}: Monstrosity 3.
|
||||
this.addAbility(new MonstrosityAbility("{4}{R}{G}", 3));
|
||||
// Whenever Polis Crusher deals combat damage to a player, if Polis Crusher is monstrous, destroy target enchantment that player controls.
|
||||
Ability ability = new ConditionalTriggeredAbility(
|
||||
new DealsCombatDamageToAPlayerTriggeredAbility(new PolisCrusherDestroyEffect(), false, true),
|
||||
new DealsCombatDamageToAPlayerTriggeredAbility(new DestroyTargetEffect(), false, true),
|
||||
MonstrousCondition.getInstance(),
|
||||
"Whenever {this} deals combat damage to a player, if {this} is monstrous, destroy target enchantment that player controls.");
|
||||
this.addAbility(ability);
|
||||
|
@ -84,45 +92,29 @@ public class PolisCrusher extends CardImpl<PolisCrusher> {
|
|||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustTargets(Ability ability, Game game) {
|
||||
if (ability instanceof ConditionalTriggeredAbility) {
|
||||
for (Effect effect : ability.getEffects()) {
|
||||
if (effect instanceof DestroyTargetEffect) {
|
||||
Player attackedPlayer = game.getPlayer(effect.getTargetPointer().getFirst(game, ability));
|
||||
if (attackedPlayer != null) {
|
||||
ability.getTargets().clear();
|
||||
FilterPermanent filterEnchantment = new FilterEnchantmentPermanent("enchantment attacked player controls");
|
||||
filter.add(new ControllerIdPredicate(attackedPlayer.getId()));
|
||||
Target target = new TargetPermanent(filterEnchantment);
|
||||
target.setRequired(true);
|
||||
ability.addTarget(target);
|
||||
effect.setTargetPointer(new FirstTargetPointer());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PolisCrusher copy() {
|
||||
return new PolisCrusher(this);
|
||||
}
|
||||
}
|
||||
|
||||
class PolisCrusherDestroyEffect extends OneShotEffect<PolisCrusherDestroyEffect> {
|
||||
|
||||
public PolisCrusherDestroyEffect() {
|
||||
super(Outcome.DestroyPermanent);
|
||||
this.staticText = "destroy target enchantment that player controls";
|
||||
}
|
||||
|
||||
public PolisCrusherDestroyEffect(final PolisCrusherDestroyEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PolisCrusherDestroyEffect copy() {
|
||||
return new PolisCrusherDestroyEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player attackedPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null && attackedPlayer != null) {
|
||||
FilterPermanent filter = new FilterEnchantmentPermanent("enchantment attacked player controls");
|
||||
filter.add(new ControllerIdPredicate(attackedPlayer.getId()));
|
||||
Target target = new TargetPermanent(filter);
|
||||
target.setRequired(true);
|
||||
if (target.canChoose(source.getSourceId(), source.getControllerId(), game)
|
||||
&& controller.chooseTarget(outcome, target, source, game)) {
|
||||
Permanent enchantment = game.getPermanent(target.getFirstTarget());
|
||||
if (enchantment != null) {
|
||||
return enchantment.destroy(source.getSourceId(), game, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package mage.abilities.decorator;
|
|||
import mage.abilities.TriggeredAbility;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.effects.Effects;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
|
@ -51,10 +52,7 @@ public class ConditionalTriggeredAbility extends TriggeredAbilityImpl<Conditiona
|
|||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
ability.setSourceId(this.getSourceId());
|
||||
ability.setControllerId(this.getControllerId());
|
||||
if (ability.checkTrigger(event, game)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return ability.checkTrigger(event, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -64,4 +62,10 @@ public class ConditionalTriggeredAbility extends TriggeredAbilityImpl<Conditiona
|
|||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Effects getEffects() {
|
||||
return ability.getEffects();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ public class GainAbilityTargetEffect extends ContinuousEffectImpl<GainAbilityTar
|
|||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Target target = mode.getTargets().get(0);
|
||||
if(target.getNumberOfTargets() > 1){
|
||||
if(target.getMaxNumberOfTargets() > 1){
|
||||
if (target.getNumberOfTargets() < target.getMaxNumberOfTargets()) {
|
||||
sb.append("Up to");
|
||||
}
|
||||
|
|
|
@ -39,12 +39,12 @@ import mage.cards.Card;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import static mage.constants.Layer.TypeChangingEffects_4;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
|
|
|
@ -97,8 +97,8 @@ public abstract class PermanentImpl<T extends PermanentImpl<T>> extends CardImpl
|
|||
protected int maxBlockedBy = 0;
|
||||
protected boolean loyaltyUsed;
|
||||
protected boolean deathtouched;
|
||||
protected List<UUID> attachments = new ArrayList<UUID>();
|
||||
protected Map<String, List<UUID>> connectedCards = new HashMap<String, List<UUID>>();
|
||||
protected List<UUID> attachments = new ArrayList<>();
|
||||
protected Map<String, List<UUID>> connectedCards = new HashMap<>();
|
||||
protected List<UUID> dealtDamageByThisTurn;
|
||||
protected UUID attachedTo;
|
||||
protected UUID pairedCard;
|
||||
|
@ -139,9 +139,9 @@ public abstract class PermanentImpl<T extends PermanentImpl<T>> extends CardImpl
|
|||
this.connectedCards.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
if (permanent.dealtDamageByThisTurn != null) {
|
||||
dealtDamageByThisTurn = new ArrayList<UUID>(permanent.dealtDamageByThisTurn);
|
||||
dealtDamageByThisTurn = new ArrayList<>(permanent.dealtDamageByThisTurn);
|
||||
if (permanent.markedDamage != null) {
|
||||
markedDamage = new ArrayList<Counter>();
|
||||
markedDamage = new ArrayList<>();
|
||||
for (Counter counter : permanent.markedDamage) {
|
||||
markedDamage.add(counter.copy());
|
||||
}
|
||||
|
@ -552,7 +552,7 @@ public abstract class PermanentImpl<T extends PermanentImpl<T>> extends CardImpl
|
|||
if (this.connectedCards.containsKey(key)) {
|
||||
this.connectedCards.get(key).add(connectedCard);
|
||||
} else {
|
||||
List<UUID> list = new ArrayList<UUID>();
|
||||
List<UUID> list = new ArrayList<>();
|
||||
list.add(connectedCard);
|
||||
this.connectedCards.put(key, list);
|
||||
}
|
||||
|
@ -643,7 +643,7 @@ public abstract class PermanentImpl<T extends PermanentImpl<T>> extends CardImpl
|
|||
deathtouched = true;
|
||||
}
|
||||
if (dealtDamageByThisTurn == null) {
|
||||
dealtDamageByThisTurn = new ArrayList<UUID>();
|
||||
dealtDamageByThisTurn = new ArrayList<>();
|
||||
}
|
||||
dealtDamageByThisTurn.add(sourceId);
|
||||
}
|
||||
|
@ -736,7 +736,7 @@ public abstract class PermanentImpl<T extends PermanentImpl<T>> extends CardImpl
|
|||
|
||||
private void markDamage(Counter counter) {
|
||||
if (markedDamage == null) {
|
||||
markedDamage = new ArrayList<Counter>();
|
||||
markedDamage = new ArrayList<>();
|
||||
}
|
||||
markedDamage.add(counter);
|
||||
}
|
||||
|
@ -1001,7 +1001,7 @@ public abstract class PermanentImpl<T extends PermanentImpl<T>> extends CardImpl
|
|||
if (connectedCards.containsKey("imprint")) {
|
||||
this.connectedCards.get("imprint").add(imprintedCard);
|
||||
} else {
|
||||
List<UUID> imprinted = new ArrayList<UUID>();
|
||||
List<UUID> imprinted = new ArrayList<>();
|
||||
imprinted.add(imprintedCard);
|
||||
this.connectedCards.put("imprint", imprinted);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue