diff --git a/Mage.Sets/src/mage/cards/b/Blitzball.java b/Mage.Sets/src/mage/cards/b/Blitzball.java new file mode 100644 index 00000000000..9221a957099 --- /dev/null +++ b/Mage.Sets/src/mage/cards/b/Blitzball.java @@ -0,0 +1,111 @@ +package mage.cards.b; + +import mage.abilities.Ability; +import mage.abilities.common.ActivateIfConditionActivatedAbility; +import mage.abilities.condition.Condition; +import mage.abilities.costs.common.SacrificeSourceCost; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.abilities.hint.ConditionHint; +import mage.abilities.hint.Hint; +import mage.abilities.mana.AnyColorManaAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.WatcherScope; +import mage.game.Game; +import mage.game.events.DamagedPlayerEvent; +import mage.game.events.GameEvent; +import mage.watchers.Watcher; + +import java.util.HashSet; +import java.util.Optional; +import java.util.Set; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class Blitzball extends CardImpl { + + public Blitzball(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}"); + + // {T}: Add one mana of any color. + this.addAbility(new AnyColorManaAbility()); + + // GOOOOAAAALLL! -- {T}, Sacrifice this artifact: Draw two cards. Activate only if an opponent was dealt combat damage by a legendary creature this turn. + Ability ability = new ActivateIfConditionActivatedAbility( + new DrawCardSourceControllerEffect(2), + new TapSourceCost(), BlitzballCondition.instance + ); + ability.addCost(new SacrificeSourceCost()); + this.addAbility(ability.addHint(BlitzballCondition.getHint()).withFlavorWord("GOOOOAAAALLL!"), new BlitzballWatcher()); + } + + private Blitzball(final Blitzball card) { + super(card); + } + + @Override + public Blitzball copy() { + return new Blitzball(this); + } +} + +enum BlitzballCondition implements Condition { + instance; + private static final Hint hint = new ConditionHint(instance); + + public static Hint getHint() { + return hint; + } + + @Override + public boolean apply(Game game, Ability source) { + return BlitzballWatcher.checkPlayer(game, source); + } + + @Override + public String toString() { + return "an opponent was dealt combat damage by a legendary creature this turn"; + } +} + +class BlitzballWatcher extends Watcher { + + private final Set set = new HashSet<>(); + + BlitzballWatcher() { + super(WatcherScope.GAME); + } + + @Override + public void watch(GameEvent event, Game game) { + if (event.getType() == GameEvent.EventType.DAMAGED_PLAYER + && ((DamagedPlayerEvent) event).isCombatDamage() + && Optional + .ofNullable(event) + .map(GameEvent::getSourceId) + .map(game::getPermanent) + .filter(permanent -> permanent.isLegendary(game)) + .filter(permanent -> permanent.isCreature(game)) + .isPresent()) { + set.addAll(game.getOpponents(event.getTargetId())); + } + } + + @Override + public void reset() { + super.reset(); + set.clear(); + } + + static boolean checkPlayer(Game game, Ability source) { + return game + .getState() + .getWatcher(BlitzballWatcher.class) + .set + .contains(source.getControllerId()); + } +} diff --git a/Mage.Sets/src/mage/sets/FinalFantasy.java b/Mage.Sets/src/mage/sets/FinalFantasy.java index ed3bf333a5e..af4e8ba81f3 100644 --- a/Mage.Sets/src/mage/sets/FinalFantasy.java +++ b/Mage.Sets/src/mage/sets/FinalFantasy.java @@ -83,6 +83,7 @@ public final class FinalFantasy extends ExpansionSet { cards.add(new SetCardInfo("Black Waltz No. 3", 214, Rarity.UNCOMMON, mage.cards.b.BlackWaltzNo3.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Black Waltz No. 3", 478, Rarity.UNCOMMON, mage.cards.b.BlackWaltzNo3.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Blazing Bomb", 130, Rarity.COMMON, mage.cards.b.BlazingBomb.class)); + cards.add(new SetCardInfo("Blitzball", 254, Rarity.COMMON, mage.cards.b.Blitzball.class)); cards.add(new SetCardInfo("Blitzball Shot", 176, Rarity.COMMON, mage.cards.b.BlitzballShot.class)); cards.add(new SetCardInfo("Braska's Final Aeon", 104, Rarity.RARE, mage.cards.b.BraskasFinalAeon.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Braska's Final Aeon", 363, Rarity.RARE, mage.cards.b.BraskasFinalAeon.class, NON_FULL_USE_VARIOUS)); diff --git a/Utils/mtg-cards-data.txt b/Utils/mtg-cards-data.txt index c75350a1c78..56207e45070 100644 --- a/Utils/mtg-cards-data.txt +++ b/Utils/mtg-cards-data.txt @@ -57901,6 +57901,7 @@ Yuna, Hope of Spira|Final Fantasy|250|M|{3}{G}{W}|Legendary Creature - Human Cle Zidane, Tantalus Thief|Final Fantasy|251|U|{3}{R}{W}|Legendary Creature - Human Mutant Scout|3|3|When Zidane enters, gain control of target creature an opponent controls until end of turn. Untap it. It gains lifelink and haste until end of turn.$Whenever an opponent gains control of a permanent from you, create a Treasure token.| Adventurer's Airship|Final Fantasy|252|C|{3}|Artifact - Vehicle|3|2|Flying$When this Vehicle attacks, draw a card then discard a card.$Crew 2| Aettir and Priwen|Final Fantasy|253|M|{6}|Legendary Artifact - Equipment|||Equipped creature has base power and toughness X/X, where X is your life total.$Equip {5}| +Blitzball|Final Fantasy|254|C|{3}|Artifact|||{T}: Add one mana of any color.$GOOOOAAAALLL! -- {T}, Sacrifice this artifact: Draw two cards. Activate only if an opponent was dealt combat damage by a legendary creature this turn.| Buster Sword|Final Fantasy|255|M|{3}|Artifact - Equipment|||Equipped creature gets +3/+2.$Whenever equipped creature deals combat damage to a player, draw a card, then you may cast a spell from your hand with mana value less than or equal to that damage without paying its mana cost.$Equip {2}| Elixir|Final Fantasy|256|U|{1}|Artifact|||This artifact enters tapped.${5}, {T}, Exile this artifact: Shuffle all nonland cards from your graveyard into your library. You gain life equal to the number of cards shuffled into your library this way.| Excalibur II|Final Fantasy|257|R|{1}|Legendary Artifact - Equipment|||Whenever you gain life, put a charge counter on Excalibur II.$Equipped creature gets +1/+1 for each charge counter on Excalibur II.$Equip {3}|