Implemented Nessian Boar

This commit is contained in:
Evan Kranzler 2020-01-02 18:56:25 -05:00
parent 732ed1aed8
commit 64ae38c632
3 changed files with 86 additions and 11 deletions

View file

@ -0,0 +1,74 @@
package mage.cards.n;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BecomesBlockedByCreatureTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.combat.MustBeBlockedByAllSourceEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class NessianBoar extends CardImpl {
public NessianBoar(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{G}{G}");
this.subtype.add(SubType.BOAR);
this.power = new MageInt(10);
this.toughness = new MageInt(6);
// All creatures able to block Nessian Boar do so.
this.addAbility(new SimpleStaticAbility(new MustBeBlockedByAllSourceEffect()));
// Whenever Nessian Boar becomes blocked by a creature, that creature's controller draws a card.
this.addAbility(new BecomesBlockedByCreatureTriggeredAbility(new NessianBoarEffect(), false));
}
private NessianBoar(final NessianBoar card) {
super(card);
}
@Override
public NessianBoar copy() {
return new NessianBoar(this);
}
}
class NessianBoarEffect extends OneShotEffect {
NessianBoarEffect() {
super(Outcome.Benefit);
staticText = "that creature's controller draws a card";
}
private NessianBoarEffect(final NessianBoarEffect effect) {
super(effect);
}
@Override
public NessianBoarEffect copy() {
return new NessianBoarEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (permanent == null) {
return false;
}
Player player = game.getPlayer(permanent.getControllerId());
return player != null && player.drawCards(1, game) > 0;
}
}

View file

@ -72,6 +72,7 @@ public final class TherosBeyondDeath extends ExpansionSet {
cards.add(new SetCardInfo("Mire's Grasp", 106, Rarity.COMMON, mage.cards.m.MiresGrasp.class));
cards.add(new SetCardInfo("Mountain", 253, Rarity.LAND, mage.cards.basiclands.Mountain.class, FULL_ART_BFZ_VARIOUS));
cards.add(new SetCardInfo("Nadir Kraken", 55, Rarity.RARE, mage.cards.n.NadirKraken.class));
cards.add(new SetCardInfo("Nessian Boar", 181, Rarity.RARE, mage.cards.n.NessianBoar.class));
cards.add(new SetCardInfo("Nylea's Intervention", 188, Rarity.RARE, mage.cards.n.NyleasIntervention.class));
cards.add(new SetCardInfo("Nylea, Keen-Eyed", 185, Rarity.MYTHIC, mage.cards.n.NyleaKeenEyed.class));
cards.add(new SetCardInfo("Nyx Herald", 189, Rarity.UNCOMMON, mage.cards.n.NyxHerald.class));

View file

@ -1,9 +1,9 @@
package mage.abilities.common;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.constants.Zone;
import mage.filter.StaticFilters;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.events.GameEvent;
@ -11,15 +11,14 @@ import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
/**
*
* @author North
*/
public class BecomesBlockedByCreatureTriggeredAbility extends TriggeredAbilityImpl {
private FilterCreaturePermanent filter = new FilterCreaturePermanent();
private final FilterCreaturePermanent filter;
public BecomesBlockedByCreatureTriggeredAbility(Effect effect, boolean optional) {
super(Zone.BATTLEFIELD, effect, optional);
this(effect, StaticFilters.FILTER_PERMANENT_CREATURE, optional);
}
public BecomesBlockedByCreatureTriggeredAbility(Effect effect, FilterCreaturePermanent filter, boolean optional) {
@ -39,14 +38,15 @@ public class BecomesBlockedByCreatureTriggeredAbility extends TriggeredAbilityIm
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getTargetId().equals(this.getSourceId())) {
Permanent blocker = game.getPermanent(event.getSourceId());
if (filter.match(blocker, game)) {
this.getEffects().setTargetPointer(new FixedTarget(blocker, game));
return true;
}
if (!event.getTargetId().equals(this.getSourceId())) {
return false;
}
return false;
Permanent blocker = game.getPermanent(event.getSourceId());
if (!filter.match(blocker, game)) {
return false;
}
this.getEffects().setTargetPointer(new FixedTarget(blocker, game));
return true;
}
@Override