diff --git a/Mage.Sets/src/mage/cards/t/TheSeriema.java b/Mage.Sets/src/mage/cards/t/TheSeriema.java new file mode 100644 index 00000000000..de7229e4af5 --- /dev/null +++ b/Mage.Sets/src/mage/cards/t/TheSeriema.java @@ -0,0 +1,74 @@ +package mage.cards.t; + +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.common.continuous.GainAbilityControlledEffect; +import mage.abilities.effects.common.search.SearchLibraryPutInHandEffect; +import mage.abilities.keyword.FlyingAbility; +import mage.abilities.keyword.IndestructibleAbility; +import mage.abilities.keyword.StationAbility; +import mage.abilities.keyword.StationLevelAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.SubType; +import mage.constants.SuperType; +import mage.filter.FilterCard; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterCreatureCard; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.permanent.TappedPredicate; +import mage.target.common.TargetCardInLibrary; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class TheSeriema extends CardImpl { + + private static final FilterCard filter = new FilterCreatureCard("legendary creature card"); + private static final FilterPermanent filter2 = new FilterCreaturePermanent("tapped legendary creatures"); + + static { + filter.add(SuperType.LEGENDARY.getPredicate()); + filter2.add(TappedPredicate.TAPPED); + filter2.add(SuperType.LEGENDARY.getPredicate()); + } + + public TheSeriema(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{1}{W}{W}"); + + this.supertype.add(SuperType.LEGENDARY); + this.subtype.add(SubType.SPACECRAFT); + + // When The Seriema enters, search your library for a legendary creature card, reveal it, put it into your hand, then shuffle. + this.addAbility(new EntersBattlefieldTriggeredAbility( + new SearchLibraryPutInHandEffect(new TargetCardInLibrary(filter), true) + )); + + // Station + this.addAbility(new StationAbility()); + + // STATION 7+ + // Flying + // Other tapped legendary creatures you control have indestructible. + // 5/5 + this.addAbility(new StationLevelAbility(7) + .withLevelAbility(FlyingAbility.getInstance()) + .withLevelAbility(new SimpleStaticAbility(new GainAbilityControlledEffect( + IndestructibleAbility.getInstance(), Duration.WhileOnBattlefield, filter2, true + ))) + .withPT(5, 5)); + } + + private TheSeriema(final TheSeriema card) { + super(card); + } + + @Override + public TheSeriema copy() { + return new TheSeriema(this); + } +} diff --git a/Mage.Sets/src/mage/sets/EdgeOfEternities.java b/Mage.Sets/src/mage/sets/EdgeOfEternities.java index f693de17b3d..8cbe3aa5046 100644 --- a/Mage.Sets/src/mage/sets/EdgeOfEternities.java +++ b/Mage.Sets/src/mage/sets/EdgeOfEternities.java @@ -89,6 +89,8 @@ public final class EdgeOfEternities extends ExpansionSet { cards.add(new SetCardInfo("Temporal Intervention", 120, Rarity.COMMON, mage.cards.t.TemporalIntervention.class)); cards.add(new SetCardInfo("Tezzeret, Cruel Captain", 2, Rarity.MYTHIC, mage.cards.t.TezzeretCruelCaptain.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Tezzeret, Cruel Captain", 287, Rarity.MYTHIC, mage.cards.t.TezzeretCruelCaptain.class, NON_FULL_USE_VARIOUS)); + cards.add(new SetCardInfo("The Seriema", 323, Rarity.RARE, mage.cards.t.TheSeriema.class, NON_FULL_USE_VARIOUS)); + cards.add(new SetCardInfo("The Seriema", 35, Rarity.RARE, mage.cards.t.TheSeriema.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Thrumming Hivepool", 247, Rarity.RARE, mage.cards.t.ThrummingHivepool.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Thrumming Hivepool", 356, Rarity.RARE, mage.cards.t.ThrummingHivepool.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Virulent Silencer", 248, Rarity.UNCOMMON, mage.cards.v.VirulentSilencer.class)); diff --git a/Mage/src/main/java/mage/abilities/keyword/StationAbility.java b/Mage/src/main/java/mage/abilities/keyword/StationAbility.java new file mode 100644 index 00000000000..b824e0e6f9c --- /dev/null +++ b/Mage/src/main/java/mage/abilities/keyword/StationAbility.java @@ -0,0 +1,74 @@ +package mage.abilities.keyword; + +import mage.MageInt; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.common.TapTargetCost; +import mage.abilities.effects.OneShotEffect; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.counters.CounterType; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.permanent.Permanent; + +import java.util.List; +import java.util.Optional; + +/** + * @author TheElk801 + */ +public class StationAbility extends SimpleActivatedAbility { + + public StationAbility() { + super(Zone.BATTLEFIELD, new StationAbilityEffect(), new TapTargetCost(StaticFilters.FILTER_OTHER_CONTROLLED_CREATURE)); + } + + private StationAbility(final StationAbility ability) { + super(ability); + } + + @Override + public StationAbility copy() { + return new StationAbility(this); + } + + @Override + public String getRule() { + return "station (Tap another creature you control: Put charge counters equal to its power on {this}. Station only as a sorcery.)"; + } +} + +class StationAbilityEffect extends OneShotEffect { + + StationAbilityEffect() { + super(Outcome.Benefit); + } + + private StationAbilityEffect(final StationAbilityEffect effect) { + super(effect); + } + + @Override + public StationAbilityEffect copy() { + return new StationAbilityEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent permanent = source.getSourcePermanentIfItStillExists(game); + if (permanent == null) { + return false; + } + int power = Optional + .ofNullable((List) getValue("tappedPermanents")) + .map(permanents -> permanents + .stream() + .map(MageObject::getPower) + .mapToInt(MageInt::getValue) + .sum()) + .orElse(0); + return power > 0 && permanent.addCounters(CounterType.CHARGE.createInstance(power), source, game); + } +} diff --git a/Mage/src/main/java/mage/abilities/keyword/StationLevelAbility.java b/Mage/src/main/java/mage/abilities/keyword/StationLevelAbility.java new file mode 100644 index 00000000000..b9531f0c51f --- /dev/null +++ b/Mage/src/main/java/mage/abilities/keyword/StationLevelAbility.java @@ -0,0 +1,155 @@ +package mage.abilities.keyword; + +import mage.abilities.Ability; +import mage.abilities.StaticAbility; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.constants.*; +import mage.counters.CounterType; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.util.CardUtil; + +import java.util.stream.Collectors; + +/** + * @author TheElk801 + */ +public class StationLevelAbility extends StaticAbility { + + private final int level; + + public StationLevelAbility(int level) { + super(Zone.BATTLEFIELD, null); + this.level = level; + } + + private StationLevelAbility(final StationLevelAbility ability) { + super(ability); + this.level = ability.level; + } + + @Override + public StationLevelAbility copy() { + return new StationLevelAbility(this); + } + + public StationLevelAbility withLevelAbility(Ability ability) { + this.addEffect(new StationLevelAbilityEffect(ability, level)); + return this; + } + + public StationLevelAbility withPT(int power, int toughness) { + this.addEffect(new StationLevelCreatureEffect(power, toughness, level)); + return this; + } + + @Override + public String getRule() { + return "STATION " + level + "+" + this + .getEffects() + .stream() + .map(effect -> effect.getText(this.getModes().getMode())) + .map(CardUtil::getTextWithFirstCharUpperCase) + .collect(Collectors.joining("
")); + } +} + +class StationLevelAbilityEffect extends ContinuousEffectImpl { + + private final Ability ability; + private final int level; + + StationLevelAbilityEffect(Ability ability, int level) { + super(Duration.WhileOnBattlefield, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility); + this.ability = ability; + this.level = level; + this.ability.setRuleVisible(false); + this.staticText = ability.getRule(); + } + + private StationLevelAbilityEffect(final StationLevelAbilityEffect effect) { + super(effect); + this.ability = effect.ability; + this.level = effect.level; + } + + @Override + public StationLevelAbilityEffect copy() { + return new StationLevelAbilityEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent permanent = source.getSourcePermanentIfItStillExists(game); + if (permanent == null || permanent.getCounters(game).getCount(CounterType.CHARGE) < level) { + return false; + } + permanent.addAbility(ability, source.getSourceId(), game); + return true; + } +} + +class StationLevelCreatureEffect extends ContinuousEffectImpl { + + private final int power; + private final int toughness; + private final int level; + + StationLevelCreatureEffect(int power, int toughness, int level) { + super(Duration.WhileOnBattlefield, Outcome.BecomeCreature); + this.power = power; + this.toughness = toughness; + this.level = level; + staticText = power + "/" + toughness; + } + + private StationLevelCreatureEffect(final StationLevelCreatureEffect effect) { + super(effect); + this.power = effect.power; + this.toughness = effect.toughness; + this.level = effect.level; + } + + @Override + public StationLevelCreatureEffect copy() { + return new StationLevelCreatureEffect(this); + } + + @Override + public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { + Permanent permanent = source.getSourcePermanentIfItStillExists(game); + if (permanent == null || permanent.getCounters(game).getCount(CounterType.CHARGE) < level) { + return false; + } + switch (layer) { + case TypeChangingEffects_4: + permanent.addCardType(game, CardType.ARTIFACT, CardType.CREATURE); + return true; + case PTChangingEffects_7: + if (sublayer != SubLayer.SetPT_7b) { + return false; + } + permanent.getPower().setModifiedBaseValue(power); + permanent.getToughness().setModifiedBaseValue(toughness); + return true; + default: + return false; + } + } + + @Override + public boolean apply(Game game, Ability source) { + return false; + } + + @Override + public boolean hasLayer(Layer layer) { + switch (layer) { + case TypeChangingEffects_4: + case PTChangingEffects_7: + return true; + default: + return false; + } + } +} diff --git a/Utils/keywords.txt b/Utils/keywords.txt index 724bdd48e22..5dd4945cf5d 100644 --- a/Utils/keywords.txt +++ b/Utils/keywords.txt @@ -128,6 +128,7 @@ Spectacle|card, cost| Spree|card| Squad|cost| Start your engines!|new| +Station|new| Storm|new| Sunburst|new| Suspend|number, cost, card|