fixed Novice Knight not working correctly

This commit is contained in:
Evan Kranzler 2018-06-24 18:21:16 -04:00
parent c4b274d666
commit 4455937158

View file

@ -2,19 +2,20 @@ package mage.cards.n;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.OrCondition;
import mage.abilities.condition.common.EnchantedSourceCondition;
import mage.abilities.condition.common.EquippedSourceCondition;
import mage.abilities.decorator.ConditionalContinuousEffect;
import mage.abilities.effects.common.combat.CanAttackAsThoughItDidntHaveDefenderSourceEffect;
import mage.abilities.effects.AsThoughEffectImpl;
import mage.constants.SubType;
import mage.abilities.keyword.DefenderAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AsThoughEffectType;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
@ -35,18 +36,7 @@ public final class NoviceKnight extends CardImpl {
// 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 ConditionalContinuousEffect(
new CanAttackAsThoughItDidntHaveDefenderSourceEffect(
Duration.WhileOnBattlefield
),
new OrCondition(
EquippedSourceCondition.instance,
new EnchantedSourceCondition()
),
"As long as {this} is enchanted or equipped, "
+ "it can attack as though it didn't have defender."
)
Zone.BATTLEFIELD, new NoviceKnightEffect()
));
}
@ -59,3 +49,45 @@ public final class NoviceKnight extends CardImpl {
return new NoviceKnight(this);
}
}
class NoviceKnightEffect extends AsThoughEffectImpl {
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);
}
@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))) {
return true;
}
}
}
return false;
}
}