diff --git a/Mage.Sets/src/mage/cards/b/BloodfeatherPhoenix.java b/Mage.Sets/src/mage/cards/b/BloodfeatherPhoenix.java new file mode 100644 index 0000000000..a2f58542d9 --- /dev/null +++ b/Mage.Sets/src/mage/cards/b/BloodfeatherPhoenix.java @@ -0,0 +1,127 @@ +package mage.cards.b; + +import mage.MageInt; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.CantBlockAbility; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.DoIfCostPaid; +import mage.abilities.effects.common.continuous.GainAbilityTargetEffect; +import mage.abilities.keyword.FlyingAbility; +import mage.abilities.keyword.HasteAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.game.stack.Spell; +import mage.players.Player; +import mage.target.targetpointer.FixedTarget; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class BloodfeatherPhoenix extends CardImpl { + + public BloodfeatherPhoenix(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{R}"); + + this.subtype.add(SubType.PHOENIX); + this.power = new MageInt(2); + this.toughness = new MageInt(2); + + // Flying + this.addAbility(FlyingAbility.getInstance()); + + // Bloodfeather Phoenix can't block. + this.addAbility(new CantBlockAbility()); + + // Whenever an instant or sorcery spell you control deals damage to an opponent or battle, you may pay {R}. If you do, return Bloodfeather Phoenix from your graveyard to the battlefield. It gains haste until end of turn. + this.addAbility(new BloodfeatherPhoenixTriggeredAbility()); + } + + private BloodfeatherPhoenix(final BloodfeatherPhoenix card) { + super(card); + } + + @Override + public BloodfeatherPhoenix copy() { + return new BloodfeatherPhoenix(this); + } +} + +class BloodfeatherPhoenixTriggeredAbility extends TriggeredAbilityImpl { + + BloodfeatherPhoenixTriggeredAbility() { + super(Zone.GRAVEYARD, new DoIfCostPaid(new BloodfeatherPhoenixEffect(), new ManaCostsImpl<>("{R}"))); + setTriggerPhrase("Whenever an instant or sorcery spell you control deals damage to an opponent or battle, "); + } + + private BloodfeatherPhoenixTriggeredAbility(final BloodfeatherPhoenixTriggeredAbility ability) { + super(ability); + } + + @Override + public BloodfeatherPhoenixTriggeredAbility copy() { + return new BloodfeatherPhoenixTriggeredAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT + || event.getType() == GameEvent.EventType.DAMAGED_PLAYER; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + Spell spell = game.getSpellOrLKIStack(event.getSourceId()); + if (spell == null || !isControlledBy(spell.getControllerId()) || !spell.isInstantOrSorcery(game)) { + return false; + } + if (game.getOpponents(event.getTargetId()).contains(getControllerId())) { + return true; + } + Permanent permanent = game.getPermanent(event.getTargetId()); + return permanent != null && permanent.isBattle(game); + } +} + +class BloodfeatherPhoenixEffect extends OneShotEffect { + + BloodfeatherPhoenixEffect() { + super(Outcome.Benefit); + staticText = "return {this} from your graveyard to the battlefield. It gains haste until end of turn"; + } + + private BloodfeatherPhoenixEffect(final BloodfeatherPhoenixEffect effect) { + super(effect); + } + + @Override + public BloodfeatherPhoenixEffect copy() { + return new BloodfeatherPhoenixEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + MageObject sourceObject = source.getSourceObjectIfItStillExists(game); + if (player == null || sourceObject == null) { + return false; + } + player.moveCards(game.getCard(sourceObject.getId()), Zone.BATTLEFIELD, source, game); + if (game.getPermanent(source.getId()) != null) { + game.addEffect(new GainAbilityTargetEffect(HasteAbility.getInstance()) + .setTargetPointer(new FixedTarget(source.getSourceId(), game)), source); + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/MarchOfTheMachine.java b/Mage.Sets/src/mage/sets/MarchOfTheMachine.java index 0119632013..5f4f64e781 100644 --- a/Mage.Sets/src/mage/sets/MarchOfTheMachine.java +++ b/Mage.Sets/src/mage/sets/MarchOfTheMachine.java @@ -51,6 +51,7 @@ public final class MarchOfTheMachine extends ExpansionSet { cards.add(new SetCardInfo("Bladed Battle-Fan", 91, Rarity.COMMON, mage.cards.b.BladedBattleFan.class)); cards.add(new SetCardInfo("Blighted Burgeoning", 177, Rarity.COMMON, mage.cards.b.BlightedBurgeoning.class)); cards.add(new SetCardInfo("Bloated Processor", 93, Rarity.RARE, mage.cards.b.BloatedProcessor.class)); + cards.add(new SetCardInfo("Bloodfeather Phoenix", 132, Rarity.RARE, mage.cards.b.BloodfeatherPhoenix.class)); cards.add(new SetCardInfo("Bloodfell Caves", 267, Rarity.COMMON, mage.cards.b.BloodfellCaves.class)); cards.add(new SetCardInfo("Bloomwielder Dryads", 237, Rarity.UNCOMMON, mage.cards.b.BloomwielderDryads.class)); cards.add(new SetCardInfo("Blossoming Sands", 268, Rarity.COMMON, mage.cards.b.BlossomingSands.class));