Fix Nivix Cyclops and clean up some similar cards

This commit is contained in:
Alex W. Jackson 2021-12-18 19:53:27 -05:00
parent 18db39f131
commit 3ac82adb4d
8 changed files with 48 additions and 129 deletions

View file

@ -1,12 +1,10 @@
package mage.cards.m;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.LimitedTimesPerTurnActivatedAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.Effect;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.common.combat.CanAttackAsThoughItDidntHaveDefenderSourceEffect;
import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.abilities.keyword.DefenderAbility;
@ -33,10 +31,8 @@ public final class MobileFort extends CardImpl {
this.addAbility(DefenderAbility.getInstance());
// {3}: Mobile Fort gets +3/-1 until end of turn and can attack this turn as though it didn't have defender. Activate this ability only once each turn.
Effect effect = new CanAttackAsThoughItDidntHaveDefenderSourceEffect(Duration.EndOfTurn);
effect.setText("and can attack this turn as though it didn't have defender");
Ability ability = new LimitedTimesPerTurnActivatedAbility(Zone.BATTLEFIELD, new BoostSourceEffect(3, -1, Duration.EndOfTurn), new ManaCostsImpl("{3}"));
ability.addEffect(effect);
Ability ability = new LimitedTimesPerTurnActivatedAbility(Zone.BATTLEFIELD, new BoostSourceEffect(3, -1, Duration.EndOfTurn), new GenericManaCost(3));
ability.addEffect(new CanAttackAsThoughItDidntHaveDefenderSourceEffect(Duration.EndOfTurn, "and"));
this.addAbility(ability);
}

View file

@ -4,19 +4,15 @@ import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SpellCastControllerTriggeredAbility;
import mage.abilities.effects.AsThoughEffectImpl;
import mage.abilities.effects.common.combat.CanAttackAsThoughItDidntHaveDefenderSourceEffect;
import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.abilities.keyword.DefenderAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AsThoughEffectType;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
@ -40,9 +36,8 @@ public final class NivixCyclops extends CardImpl {
StaticFilters.FILTER_SPELL_AN_INSTANT_OR_SORCERY,
false
);
ability.addEffect(new AsThoughNoDefenderEffect());
ability.addEffect(new CanAttackAsThoughItDidntHaveDefenderSourceEffect(Duration.EndOfTurn, "and"));
this.addAbility(ability);
}
private NivixCyclops(final NivixCyclops card) {
@ -54,35 +49,3 @@ public final class NivixCyclops extends CardImpl {
return new NivixCyclops(this);
}
}
class AsThoughNoDefenderEffect extends AsThoughEffectImpl {
public AsThoughNoDefenderEffect() {
super(AsThoughEffectType.ATTACK, Duration.EndOfTurn, Outcome.Benefit);
staticText = "and it can attack as though it didn't have defender";
}
public AsThoughNoDefenderEffect(final AsThoughNoDefenderEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public AsThoughNoDefenderEffect copy() {
return new AsThoughNoDefenderEffect(this);
}
@Override
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
Permanent nivixCyclops = game.getPermanent(source.getSourceId());
if (nivixCyclops != null
&& nivixCyclops.getAbilities().containsKey(DefenderAbility.getInstance().getId())) {
return true;
}
return false;
}
}

View file

@ -4,15 +4,16 @@ import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.AsThoughEffectImpl;
import mage.constants.SubType;
import mage.abilities.condition.Condition;
import mage.abilities.decorator.ConditionalAsThoughEffect;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.combat.CanAttackAsThoughItDidntHaveDefenderSourceEffect;
import mage.abilities.keyword.DefenderAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AsThoughEffectType;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -35,9 +36,11 @@ public final class NoviceKnight extends CardImpl {
this.addAbility(DefenderAbility.getInstance());
// As long as Novice Knight is enchanted or equipped, it can attack as though it didn't have defender.
this.addAbility(new SimpleStaticAbility(
Zone.BATTLEFIELD, new NoviceKnightEffect()
));
Effect effect = new ConditionalAsThoughEffect(
new CanAttackAsThoughItDidntHaveDefenderSourceEffect(Duration.WhileOnBattlefield),
EnchantedOrEquippedSourceCondition.instance);
effect.setText("As long as {this} is enchanted or equipped, it can attack as though it didn't have defender");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
}
private NoviceKnight(final NoviceKnight card) {
@ -50,44 +53,28 @@ public final class NoviceKnight extends CardImpl {
}
}
class NoviceKnightEffect extends AsThoughEffectImpl {
enum EnchantedOrEquippedSourceCondition implements Condition {
public NoviceKnightEffect() {
super(AsThoughEffectType.ATTACK, Duration.WhileOnBattlefield, Outcome.Benefit);
staticText = "As long as {this} is enchanted or equipped, "
+ "it can attack as though it didn't have defender.";
}
public NoviceKnightEffect(final NoviceKnightEffect effect) {
super(effect);
}
instance;
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public NoviceKnightEffect copy() {
return new NoviceKnightEffect(this);
}
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
if (!objectId.equals(source.getSourceId())) {
return false;
}
Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId());
if (permanent != null) {
for (UUID uuid : permanent.getAttachments()) {
Permanent attached = game.getBattlefield().getPermanent(uuid);
if (attached != null
&& (attached.hasSubtype(SubType.EQUIPMENT, game)
|| attached.hasSubtype(SubType.AURA, game))) {
&& (attached.isEnchantment(game)
|| attached.hasSubtype(SubType.EQUIPMENT, game))) {
return true;
}
}
}
return false;
}
@Override
public String toString() {
return "{this} is enchanted or equipped";
}
}

View file

@ -1,18 +1,17 @@
package mage.cards.o;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition;
import mage.abilities.effects.AsThoughEffectImpl;
import mage.abilities.decorator.ConditionalAsThoughEffect;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.combat.CanAttackAsThoughItDidntHaveDefenderSourceEffect;
import mage.abilities.keyword.DefenderAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.filter.FilterPermanent;
import mage.game.Game;
/**
*
@ -20,6 +19,12 @@ import mage.game.Game;
*/
public final class OgreJailbreaker extends CardImpl {
private static final FilterPermanent filter = new FilterPermanent("Gate");
static {
filter.add(SubType.GATE.getPredicate());
}
public OgreJailbreaker(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{B}");
this.subtype.add(SubType.OGRE);
@ -30,8 +35,13 @@ public final class OgreJailbreaker extends CardImpl {
// Defender
this.addAbility(DefenderAbility.getInstance());
// Ogre Jailbreaker can attack as though it didn't have defender as long as you control a Gate.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new OgreJailbreakerEffect()));
Effect effect = new ConditionalAsThoughEffect(
new CanAttackAsThoughItDidntHaveDefenderSourceEffect(Duration.WhileOnBattlefield),
new PermanentsOnTheBattlefieldCondition(filter));
effect.setText("{this} can attack as though it didn't have defender as long as you control a Gate");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
}
@ -44,42 +54,3 @@ public final class OgreJailbreaker extends CardImpl {
return new OgreJailbreaker(this);
}
}
class OgreJailbreakerEffect extends AsThoughEffectImpl {
private static final FilterPermanent filter = new FilterPermanent();
private PermanentsOnTheBattlefieldCondition gateCondition;
static {
filter.add(SubType.GATE.getPredicate());
}
public OgreJailbreakerEffect() {
super(AsThoughEffectType.ATTACK, Duration.WhileOnBattlefield, Outcome.Benefit);
staticText = "{this} can attack as though it didn't have defender as long as you control a Gate";
gateCondition = new PermanentsOnTheBattlefieldCondition(filter);
}
public OgreJailbreakerEffect(final OgreJailbreakerEffect effect) {
super(effect);
this.gateCondition = effect.gateCondition;
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public OgreJailbreakerEffect copy() {
return new OgreJailbreakerEffect(this);
}
@Override
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
if (sourceId.equals(source.getSourceId()) && gateCondition.apply(game, source)) {
return true;
}
return false;
}
}

View file

@ -40,8 +40,7 @@ public final class RovingKeep extends CardImpl {
ability.addEffect(new GainAbilitySourceEffect(
TrampleAbility.getInstance(), Duration.EndOfTurn
).setText("and gains trample until end of turn"));
ability.addEffect(new CanAttackAsThoughItDidntHaveDefenderSourceEffect(Duration.EndOfTurn)
.setText("It can attack this turn as though it didn't have defender"));
ability.addEffect(new CanAttackAsThoughItDidntHaveDefenderSourceEffect(Duration.EndOfTurn, "it"));
this.addAbility(ability);
}

View file

@ -1,4 +1,3 @@
package mage.cards.w;
import java.util.UUID;
@ -33,7 +32,7 @@ public final class WalkingWall extends CardImpl {
// {3}: Walking Wall gets +3/-1 until end of turn and can attack this turn as though it didn't have defender. Activate this ability only once each turn.
Ability ability = new LimitedTimesPerTurnActivatedAbility(Zone.BATTLEFIELD, new BoostSourceEffect(3, -1, Duration.EndOfTurn), new GenericManaCost(3));
ability.addEffect(new CanAttackAsThoughItDidntHaveDefenderSourceEffect(Duration.EndOfTurn));
ability.addEffect(new CanAttackAsThoughItDidntHaveDefenderSourceEffect(Duration.EndOfTurn, "and"));
this.addAbility(ability);
}

View file

@ -34,7 +34,7 @@ public final class WallOfWonder extends CardImpl {
// {2}{U}{U}: Wall of Wonder gets +4/-4 until end of turn and can attack this turn as though it didn't have defender.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BoostSourceEffect(4, -4, Duration.EndOfTurn),
new ManaCostsImpl("{2}{U}{U}"));
ability.addEffect(new CanAttackAsThoughItDidntHaveDefenderSourceEffect(Duration.EndOfTurn));
ability.addEffect(new CanAttackAsThoughItDidntHaveDefenderSourceEffect(Duration.EndOfTurn, "and"));
this.addAbility(ability);
}

View file

@ -16,8 +16,12 @@ import mage.game.Game;
public class CanAttackAsThoughItDidntHaveDefenderSourceEffect extends AsThoughEffectImpl {
public CanAttackAsThoughItDidntHaveDefenderSourceEffect(Duration duration) {
this(duration, "{this}");
}
public CanAttackAsThoughItDidntHaveDefenderSourceEffect(Duration duration, String description) {
super(AsThoughEffectType.ATTACK, duration, Outcome.Benefit);
staticText = "{this} can attack "
staticText = description + " can attack "
+ (duration == Duration.EndOfTurn ? "this turn " : "")
+ "as though it didn't have defender";
}