Implemented Davriel, Rogue Shadowmage

This commit is contained in:
Evan Kranzler 2019-04-01 18:52:22 -04:00
parent 9cd5560e01
commit 7fec2e9837
4 changed files with 89 additions and 91 deletions

View file

@ -0,0 +1,65 @@
package mage.cards.d;
import mage.abilities.Ability;
import mage.abilities.LoyaltyAbility;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.PlaneswalkerEntersWithLoyaltyCountersAbility;
import mage.abilities.condition.Condition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.discard.DiscardTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetPlayer;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class DavrielRogueShadowmage extends CardImpl {
public DavrielRogueShadowmage(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.PLANESWALKER}, "{2}{B}");
this.addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.DAVRIEL);
this.addAbility(new PlaneswalkerEntersWithLoyaltyCountersAbility(3));
// At the beginning of each opponent's upkeep, if that player has one or fewer cards in hand, Davriel, Rogue Shadowmage deals 2 damage to them.
this.addAbility(new ConditionalInterveningIfTriggeredAbility(
new BeginningOfUpkeepTriggeredAbility(
Zone.BATTLEFIELD, new DamageTargetEffect(2),
TargetController.OPPONENT, false, true
), DavrielRogueShadowmageCondition.instance, "At the beginning of each opponent's upkeep, " +
"if that player has one or fewer cards in hand, {this} deals 2 damage to them."
));
// -1: Target player discards a card.
Ability ability = new LoyaltyAbility(new DiscardTargetEffect(1), -1);
ability.addTarget(new TargetPlayer());
this.addAbility(ability);
}
private DavrielRogueShadowmage(final DavrielRogueShadowmage card) {
super(card);
}
@Override
public DavrielRogueShadowmage copy() {
return new DavrielRogueShadowmage(this);
}
}
enum DavrielRogueShadowmageCondition implements Condition {
instance;
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(game.getActivePlayerId());
return player != null && player.getHand().size() < 2;
}
}

View file

@ -1,47 +1,40 @@
package mage.cards.s;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.condition.Condition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.LoseLifeTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
/**
* http://www.wizards.com/magic/magazine/article.aspx?x=mtg/faq/rtr
* Shrieking Affliction's ability will trigger only if an opponent begins his or
* her upkeep with one or fewer cards in hand.
* The ability will check the number of cards in that player's hand again when
* it tries to resolve. If that player has two or more cards in hand at that time,
* that player won't lose life.
*
* @author LevelX2
*/
public final class ShriekingAffliction extends CardImpl {
static final String rule = "At the beginning of the upkeep of enchanted creature's controller, that player loses 2 life";
public ShriekingAffliction (UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{B}");
public ShriekingAffliction(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{B}");
// At the beginning of each opponent's upkeep, if that player has one or fewer cards in hand, he or she loses 3 life.
this.addAbility(new ShriekingAfflictionTriggeredAbility());
this.addAbility(new ConditionalInterveningIfTriggeredAbility(
new BeginningOfUpkeepTriggeredAbility(
Zone.BATTLEFIELD, new LoseLifeTargetEffect(3),
TargetController.OPPONENT, false, true
), ShriekingAfflictionCondition.instance, "At the beginning of each opponents upkeep, " +
"if that player has one or fewer cards in hand, they lose 3 life."
));
}
public ShriekingAffliction (final ShriekingAffliction card) {
private ShriekingAffliction(final ShriekingAffliction card) {
super(card);
}
@ -51,74 +44,12 @@ public final class ShriekingAffliction extends CardImpl {
}
}
class ShriekingAfflictionTriggeredAbility extends TriggeredAbilityImpl {
public ShriekingAfflictionTriggeredAbility() {
super(Zone.BATTLEFIELD, null);
}
public ShriekingAfflictionTriggeredAbility(final ShriekingAfflictionTriggeredAbility ability) {
super(ability);
}
@Override
public ShriekingAfflictionTriggeredAbility copy() {
return new ShriekingAfflictionTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == EventType.UPKEEP_STEP_PRE;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (game.getOpponents(controllerId).contains(event.getPlayerId())) {
Player player = game.getPlayer(event.getPlayerId());
if (player != null && player.getHand().size() < 2) {
this.getEffects().clear();
ShriekingAfflictionTargetEffect effect = new ShriekingAfflictionTargetEffect();
effect.setTargetPointer(new FixedTarget(player.getId()));
this.addEffect(effect);
return true;
}
}
return false;
}
@Override
public String getRule() {
return "At the beginning of each opponent's upkeep, if that player has one or fewer cards in hand, he or she loses 3 life.";
}
}
class ShriekingAfflictionTargetEffect extends OneShotEffect {
public ShriekingAfflictionTargetEffect() {
super(Outcome.Damage);
staticText = "he or she loses 3 life";
}
public ShriekingAfflictionTargetEffect(final ShriekingAfflictionTargetEffect effect) {
super(effect);
}
@Override
public ShriekingAfflictionTargetEffect copy() {
return new ShriekingAfflictionTargetEffect(this);
}
enum ShriekingAfflictionCondition implements Condition {
instance;
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source));
if (player != null && player.getHand().size() < 2) {
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (sourcePermanent != null) {
game.informPlayers(sourcePermanent.getName() + ": " + player.getLogName() + " loses 3 life");
}
player.loseLife(3, game, false);
return true;
}
return false;
Player player = game.getPlayer(game.getActivePlayerId());
return player != null && player.getHand().size() < 2;
}
}
}

View file

@ -32,6 +32,7 @@ public final class WarOfTheSpark extends ExpansionSet {
cards.add(new SetCardInfo("Cruel Celebrant", 188, Rarity.UNCOMMON, mage.cards.c.CruelCelebrant.class));
cards.add(new SetCardInfo("Crush Dissent", 47, Rarity.COMMON, mage.cards.c.CrushDissent.class));
cards.add(new SetCardInfo("Davriel's Shadowfuge", 84, Rarity.COMMON, mage.cards.d.DavrielsShadowfuge.class));
cards.add(new SetCardInfo("Davriel, Rogue Shadowmage", 83, Rarity.UNCOMMON, mage.cards.d.DavrielRogueShadowmage.class));
cards.add(new SetCardInfo("Dovin's Veto", 193, Rarity.COMMON, mage.cards.d.DovinsVeto.class));
cards.add(new SetCardInfo("Dreadhorde Invasion", 86, Rarity.RARE, mage.cards.d.DreadhordeInvasion.class));
cards.add(new SetCardInfo("Emergence Zone", 245, Rarity.UNCOMMON, mage.cards.e.EmergenceZone.class));