From 7465e89b96997b95666cb6e0d14cdbdf0af5264f Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Wed, 8 Jan 2020 16:18:35 -0500 Subject: [PATCH] fixed implementation of Thopter Assembly --- .../src/mage/cards/t/ThopterAssembly.java | 90 +++++++------------ 1 file changed, 32 insertions(+), 58 deletions(-) diff --git a/Mage.Sets/src/mage/cards/t/ThopterAssembly.java b/Mage.Sets/src/mage/cards/t/ThopterAssembly.java index f6ce244cc11..bdeb8121834 100644 --- a/Mage.Sets/src/mage/cards/t/ThopterAssembly.java +++ b/Mage.Sets/src/mage/cards/t/ThopterAssembly.java @@ -1,32 +1,41 @@ - package mage.cards.t; -import java.util.UUID; import mage.MageInt; -import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; +import mage.abilities.condition.Condition; +import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition; +import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility; import mage.abilities.effects.common.CreateTokenEffect; import mage.abilities.effects.common.ReturnToHandSourceEffect; import mage.abilities.keyword.FlyingAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; +import mage.constants.ComparisonType; import mage.constants.SubType; -import mage.constants.Zone; +import mage.constants.TargetController; import mage.filter.FilterPermanent; import mage.filter.predicate.permanent.AnotherPredicate; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.token.ThopterColorlessToken; +import java.util.UUID; + /** - * - * @author Loki + * @author TheElk801 */ public final class ThopterAssembly extends CardImpl { + private static final FilterPermanent filter = new FilterPermanent(SubType.THOPTER, ""); + + static { + filter.add(AnotherPredicate.instance); + } + + private static final Condition condition = new PermanentsOnTheBattlefieldCondition(filter, ComparisonType.EQUAL_TO, 0); + public ThopterAssembly(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT,CardType.CREATURE},"{6}"); + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{6}"); this.subtype.add(SubType.THOPTER); this.power = new MageInt(5); @@ -35,13 +44,21 @@ public final class ThopterAssembly extends CardImpl { // Flying this.addAbility(FlyingAbility.getInstance()); - // At the beginning of your upkeep, if you control no Thopters other than Thopter Assembly, - // return Thopter Assembly to its owner's hand and create five 1/1 colorless Thopter artifact - // creature tokens with flying. - this.addAbility(new ThopterAssemblyTriggeredAbility()); + // At the beginning of your upkeep, if you control no Thopters other than Thopter Assembly, return Thopter Assembly to its owner's hand and create five 1/1 colorless Thopter artifact creature tokens with flying. + Ability ability = new ConditionalInterveningIfTriggeredAbility( + new BeginningOfUpkeepTriggeredAbility( + new ReturnToHandSourceEffect(true), + TargetController.YOU, false + ), condition, "At the beginning of your upkeep, " + + "if you control no Thopters other than {this}, " + + "return {this} to its owner's hand and create five 1/1 colorless " + + "Thopter artifact creature tokens with flying." + ); + ability.addEffect(new CreateTokenEffect(new ThopterColorlessToken(), 5)); + this.addAbility(ability); } - public ThopterAssembly(final ThopterAssembly card) { + private ThopterAssembly(final ThopterAssembly card) { super(card); } @@ -50,46 +67,3 @@ public final class ThopterAssembly extends CardImpl { return new ThopterAssembly(this); } } - -class ThopterAssemblyTriggeredAbility extends TriggeredAbilityImpl { - - private static final FilterPermanent filter = new FilterPermanent(); - static { - filter.add(SubType.THOPTER.getPredicate()); - filter.add(AnotherPredicate.instance); - } - - ThopterAssemblyTriggeredAbility() { - super(Zone.BATTLEFIELD, new ReturnToHandSourceEffect(true)); - this.addEffect(new CreateTokenEffect(new ThopterColorlessToken(), 5)); - } - - ThopterAssemblyTriggeredAbility(final ThopterAssemblyTriggeredAbility ability) { - super(ability); - } - - @Override - public ThopterAssemblyTriggeredAbility copy() { - return new ThopterAssemblyTriggeredAbility(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 (event.getPlayerId().equals(this.controllerId)) { - if (game.getBattlefield().count(filter, this.getSourceId(), this.getControllerId(), game) == 0) { - return true; - } - } - return false; - } - - @Override - public String getRule() { - return "At the beginning of your upkeep, if you control no Thopters other than {this}, return {this} to its owner's hand and create five 1/1 colorless Thopter artifact creature tokens with flying"; - } -} \ No newline at end of file