enum conditions

This commit is contained in:
ingmargoudt 2017-04-06 16:30:22 +02:00
parent 40870f22c2
commit ea6ba3c0a9
28 changed files with 57 additions and 46 deletions

View file

@ -74,7 +74,7 @@ public class AkutaBornOfAsh extends CardImpl {
new BeginningOfUpkeepTriggeredAbility(Zone.GRAVEYARD,
new DoIfCostPaid(new ReturnSourceFromGraveyardToBattlefieldEffect(), new SacrificeTargetCost(new TargetControlledPermanent(filterSwamp))),
TargetController.YOU, false),
new MoreCardsInHandThanOpponentsCondition(),
MoreCardsInHandThanOpponentsCondition.instance,
"At the beginning of your upkeep, if you have more cards in hand than each opponent, you may sacrifice a Swamp. If you do, return {this} from your graveyard to the battlefield.");
this.addAbility(ability);
}

View file

@ -62,7 +62,7 @@ public class AngelOfTheDireHour extends CardImpl {
// When Angel of the Dire Hour enters the battlefield, if you cast it from your hand, exile all attacking creatures.
this.addAbility(new ConditionalTriggeredAbility(
new EntersBattlefieldTriggeredAbility(new ExileAllEffect(new FilterAttackingCreature("attacking creatures")), false),
new CastFromHandSourceCondition(),
CastFromHandSourceCondition.instance,
"When {this} enters the battlefield, if you cast it from your hand, exile all attacking creatures."),
new CastFromHandWatcher());
}

View file

@ -68,7 +68,7 @@ public class BreachingLeviathan extends CardImpl {
// When Breaching Leviathan enters the battlefield, if you cast it from your hand, tap all nonblue creatures. Those creatures don't untap during their controllers' next untap steps.
this.addAbility(new ConditionalTriggeredAbility(
new EntersBattlefieldTriggeredAbility(new BreachingLeviathanEffect(), false),
new CastFromHandSourceCondition(),
CastFromHandSourceCondition.instance,
"When {this} enters the battlefield, if you cast it from your hand, tap all nonblue creatures. Those creatures don't untap during their controllers' next untap steps."),
new CastFromHandWatcher());
}

View file

@ -55,7 +55,7 @@ public class CoalStoker extends CardImpl {
// When Coal Stoker enters the battlefield, if you cast it from your hand, add {R}{R}{R} to your mana pool.
this.addAbility(new ConditionalTriggeredAbility(
new EntersBattlefieldTriggeredAbility(new BasicManaEffect(Mana.RedMana(3)), false),
new CastFromHandSourceCondition(),
CastFromHandSourceCondition.instance,
"When {this} enters the battlefield, if you cast it from your hand, add {R}{R}{R} to your mana pool."),
new CastFromHandWatcher());
}

View file

@ -66,7 +66,7 @@ public class DeathOfAThousandStings extends CardImpl {
new BeginningOfUpkeepTriggeredAbility(Zone.GRAVEYARD,
new ReturnSourceFromGraveyardToHandEffect(),
TargetController.YOU, true),
new MoreCardsInHandThanOpponentsCondition(),
MoreCardsInHandThanOpponentsCondition.instance,
"At the beginning of your upkeep, if you have more cards in hand than each opponent, you may return {this} from your graveyard to your hand.");
this.addAbility(ability);
}

View file

@ -88,7 +88,7 @@ class DeathbringerRegentCondition implements Condition {
@Override
public boolean apply(Game game, Ability source) {
return new CastFromHandSourceCondition().apply(game, source)
return CastFromHandSourceCondition.instance.apply(game, source)
&& game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), game).size() >= 6;
}
}

View file

@ -61,11 +61,11 @@ public class DescendantOfKiyomaro extends CardImpl {
// As long as you have more cards in hand than each opponent, Descendant of Kiyomaro gets +1/+2 and has "Whenever this creature deals combat damage, you gain 3 life."
Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new ConditionalContinuousEffect(
new BoostSourceEffect(1,2, Duration.WhileOnBattlefield),
new MoreCardsInHandThanOpponentsCondition(),
MoreCardsInHandThanOpponentsCondition.instance,
"As long as you have more cards in hand than each opponent, {this} gets +1/+2"));
ability.addEffect(new ConditionalContinuousEffect(
new GainAbilitySourceEffect(new DealsCombatDamageTriggeredAbility(new GainLifeEffect(3), false)),
new MoreCardsInHandThanOpponentsCondition(),
MoreCardsInHandThanOpponentsCondition.instance,
"and has \"Whenever this creature deals combat damage, you gain 3 life.\""));
this.addAbility(ability);
}

View file

@ -27,7 +27,6 @@
*/
package mage.cards.d;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
@ -44,6 +43,8 @@ import mage.target.Target;
import mage.target.common.TargetArtifactPermanent;
import mage.target.common.TargetControlledPermanent;
import java.util.UUID;
/**
*
* @author Styxo

View file

@ -71,7 +71,7 @@ public class DreadCacodemon extends CardImpl {
// if you cast it from your hand, destroy all creatures your opponents control, then tap all other creatures you control.
TriggeredAbility ability = new EntersBattlefieldTriggeredAbility(new DestroyAllEffect(opponentsCreatures, false));
ability.addEffect(new TapAllEffect(otherCreaturesYouControl));
this.addAbility(new ConditionalTriggeredAbility(ability, new CastFromHandSourceCondition(),
this.addAbility(new ConditionalTriggeredAbility(ability, CastFromHandSourceCondition.instance,
"When {this} enters the battlefield, if you cast it from your hand, destroy all creatures your opponents control, then tap all other creatures you control."), new CastFromHandWatcher());
}

View file

@ -67,7 +67,7 @@ public class Epochrasite extends CardImpl {
// Epochrasite enters the battlefield with three +1/+1 counters on it if you didn't cast it from your hand.
this.addAbility(new EntersBattlefieldAbility(
new AddCountersSourceEffect(CounterType.P1P1.createInstance(3)),
new InvertCondition(new CastFromHandSourceCondition()),
new InvertCondition(CastFromHandSourceCondition.instance),
"{this} enters the battlefield with three +1/+1 counters on it if you didn't cast it from your hand",""),
new CastFromHandWatcher());

View file

@ -71,7 +71,7 @@ public class ExileIntoDarkness extends CardImpl {
new BeginningOfUpkeepTriggeredAbility(Zone.GRAVEYARD,
new ReturnSourceFromGraveyardToHandEffect(),
TargetController.YOU, true),
new MoreCardsInHandThanOpponentsCondition(),
MoreCardsInHandThanOpponentsCondition.instance,
"At the beginning of your upkeep, if you have more cards in hand than each opponent, you may return {this} from your graveyard to your hand.");
this.addAbility(ability);
}

View file

@ -70,7 +70,7 @@ public class FurnaceDragon extends CardImpl {
// When Furnace Dragon enters the battlefield, if you cast it from your hand, exile all artifacts.
this.addAbility(new ConditionalTriggeredAbility(
new EntersBattlefieldTriggeredAbility(new ExileAllEffect(filter), false),
new CastFromHandSourceCondition(),
CastFromHandSourceCondition.instance,
"When {this} enters the battlefield, if you cast it from your hand, exile all artifacts."),
new CastFromHandWatcher());
}

View file

@ -78,7 +78,7 @@ public class InameAsOne extends CardImpl {
// When Iname as One enters the battlefield, if you cast it from your hand, you may search your library for a Spirit permanent card, put it onto the battlefield, then shuffle your library.
this.addAbility(new ConditionalTriggeredAbility(
new EntersBattlefieldTriggeredAbility(new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(0, 1, filter)), true),
new CastFromHandSourceCondition(),
CastFromHandSourceCondition.instance,
"When {this} enters the battlefield, if you cast it from your hand, you may search your library for a Spirit permanent card, put it onto the battlefield, then shuffle your library."),
new CastFromHandWatcher());

View file

@ -27,7 +27,6 @@
*/
package mage.cards.k;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.condition.common.MoreCardsInHandThanOpponentsCondition;
@ -41,6 +40,8 @@ import mage.constants.Duration;
import mage.constants.Zone;
import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
/**
*
* @author LevelX2
@ -60,7 +61,7 @@ public class KitsuneBonesetter extends CardImpl {
Zone.BATTLEFIELD,
new PreventDamageToTargetEffect(Duration.EndOfTurn, 3),
new TapSourceCost(),
new MoreCardsInHandThanOpponentsCondition()
MoreCardsInHandThanOpponentsCondition.instance
);
ability.addTarget(new TargetCreaturePermanent());
this.addAbility(ability);

View file

@ -62,7 +62,7 @@ public class LinvalaThePreserver extends CardImpl {
// When Linvala, the Preserver enters the battlefield, if an opponent has more life than you, you gain 5 life.
this.addAbility(new ConditionalTriggeredAbility(new EntersBattlefieldTriggeredAbility(new GainLifeEffect(5), false),
new OpponentHasMoreLifeCondition(),
OpponentHasMoreLifeCondition.instance,
"When {this} enters the battlefield, if an opponent has more life than you, you gain 5 life."));
// When Linvala enters the battlefield, if an opponent controls more creatures than you, create a 3/3 white Angel creature token with flying.

View file

@ -74,7 +74,7 @@ public class MyojinOfCleansingFire extends CardImpl {
this.getSpellAbility().addWatcher(new CastFromHandWatcher());
// Myojin of Cleansing Fire enters the battlefield with a divinity counter on it if you cast it from your hand.
this.addAbility(new EntersBattlefieldAbility(new ConditionalOneShotEffect(new AddCountersSourceEffect(CounterType.DIVINITY.createInstance()), new CastFromHandSourceCondition(), ""), "{this} enters the battlefield with a divinity counter on it if you cast it from your hand"));
this.addAbility(new EntersBattlefieldAbility(new ConditionalOneShotEffect(new AddCountersSourceEffect(CounterType.DIVINITY.createInstance()), CastFromHandSourceCondition.instance, ""), "{this} enters the battlefield with a divinity counter on it if you cast it from your hand"));
// Myojin of Cleansing Fire is indestructible as long as it has a divinity counter on it.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ConditionalContinuousEffect(new GainAbilitySourceEffect(IndestructibleAbility.getInstance(), Duration.WhileOnBattlefield),
new SourceHasCounterCondition(CounterType.DIVINITY), "{this} is indestructible as long as it has a divinity counter on it")));

View file

@ -70,7 +70,7 @@ public class MyojinOfInfiniteRage extends CardImpl {
this.getSpellAbility().addWatcher(new CastFromHandWatcher());
// Myojin of Infinite Rage enters the battlefield with a divinity counter on it if you cast it from your hand.
this.addAbility(new EntersBattlefieldAbility(new ConditionalOneShotEffect(new AddCountersSourceEffect(CounterType.DIVINITY.createInstance()), new CastFromHandSourceCondition(), ""), "{this} enters the battlefield with a divinity counter on it if you cast it from your hand"));
this.addAbility(new EntersBattlefieldAbility(new ConditionalOneShotEffect(new AddCountersSourceEffect(CounterType.DIVINITY.createInstance()), CastFromHandSourceCondition.instance, ""), "{this} enters the battlefield with a divinity counter on it if you cast it from your hand"));
// Myojin of Infinite Rage is indestructible as long as it has a divinity counter on it.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ConditionalContinuousEffect(new GainAbilitySourceEffect(IndestructibleAbility.getInstance(), Duration.WhileOnBattlefield),
new SourceHasCounterCondition(CounterType.DIVINITY), "{this} is indestructible as long as it has a divinity counter on it")));

View file

@ -27,7 +27,6 @@
*/
package mage.cards.m;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldAbility;
@ -53,6 +52,8 @@ import mage.players.Player;
import mage.target.common.TargetCardInHand;
import mage.watchers.common.CastFromHandWatcher;
import java.util.UUID;
/**
* @author LevelX
*/
@ -69,7 +70,7 @@ public class MyojinOfLifesWeb extends CardImpl {
this.getSpellAbility().addWatcher(new CastFromHandWatcher());
// Myojin of Life's Web enters the battlefield with a divinity counter on it if you cast it from your hand.
this.addAbility(new EntersBattlefieldAbility(new ConditionalOneShotEffect(new AddCountersSourceEffect(CounterType.DIVINITY.createInstance()), new CastFromHandSourceCondition(), ""), "{this} enters the battlefield with a divinity counter on it if you cast it from your hand"));
this.addAbility(new EntersBattlefieldAbility(new ConditionalOneShotEffect(new AddCountersSourceEffect(CounterType.DIVINITY.createInstance()), CastFromHandSourceCondition.instance, ""), "{this} enters the battlefield with a divinity counter on it if you cast it from your hand"));
// Myojin of Life's Web is indestructible as long as it has a divinity counter on it.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD,
new ConditionalContinuousEffect(new GainAbilitySourceEffect(IndestructibleAbility.getInstance(), Duration.WhileOnBattlefield),

View file

@ -27,9 +27,6 @@
*/
package mage.cards.m;
import java.util.UUID;
import mage.constants.*;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldAbility;
@ -47,11 +44,14 @@ import mage.abilities.keyword.IndestructibleAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.counters.CounterType;
import mage.game.Game;
import mage.players.Player;
import mage.watchers.common.CastFromHandWatcher;
import java.util.UUID;
/**
* @author LevelX
*/
@ -68,7 +68,7 @@ public class MyojinOfNightsReach extends CardImpl {
this.getSpellAbility().addWatcher(new CastFromHandWatcher());
// Myojin of Night's Reach enters the battlefield with a divinity counter on it if you cast it from your hand.
this.addAbility(new EntersBattlefieldAbility(new ConditionalOneShotEffect(new AddCountersSourceEffect(CounterType.DIVINITY.createInstance()), new CastFromHandSourceCondition(), ""), "{this} enters the battlefield with a divinity counter on it if you cast it from your hand"));
this.addAbility(new EntersBattlefieldAbility(new ConditionalOneShotEffect(new AddCountersSourceEffect(CounterType.DIVINITY.createInstance()), CastFromHandSourceCondition.instance, ""), "{this} enters the battlefield with a divinity counter on it if you cast it from your hand"));
// Myojin of Night's Reach is indestructible as long as it has a divinity counter on it.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ConditionalContinuousEffect(new GainAbilitySourceEffect(IndestructibleAbility.getInstance(), Duration.WhileOnBattlefield),
new SourceHasCounterCondition(CounterType.DIVINITY), "{this} is indestructible as long as it has a divinity counter on it")));

View file

@ -27,9 +27,6 @@
*/
package mage.cards.m;
import java.util.UUID;
import mage.constants.*;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldAbility;
@ -47,11 +44,14 @@ import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.keyword.IndestructibleAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.counters.CounterType;
import mage.filter.FilterPermanent;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.watchers.common.CastFromHandWatcher;
import java.util.UUID;
/**
* @author LevelX
*/
@ -73,12 +73,12 @@ public class MyojinOfSeeingWinds extends CardImpl {
this.getSpellAbility().addWatcher(new CastFromHandWatcher());
// Myojin of Seeing Winds enters the battlefield with a divinity counter on it if you cast it from your hand.
this.addAbility(new EntersBattlefieldAbility(new ConditionalOneShotEffect(new AddCountersSourceEffect(CounterType.DIVINITY.createInstance()), new CastFromHandSourceCondition(), ""), "{this} enters the battlefield with a divinity counter on it if you cast it from your hand"));
this.addAbility(new EntersBattlefieldAbility(new ConditionalOneShotEffect(new AddCountersSourceEffect(CounterType.DIVINITY.createInstance()), CastFromHandSourceCondition.instance, ""), "{this} enters the battlefield with a divinity counter on it if you cast it from your hand"));
// Myojin of Seeing Winds is indestructible as long as it has a divinity counter on it.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ConditionalContinuousEffect(new GainAbilitySourceEffect(IndestructibleAbility.getInstance(), Duration.WhileOnBattlefield),
new SourceHasCounterCondition(CounterType.DIVINITY), "{this} is indestructible as long as it has a divinity counter on it")));
// Remove a divinity counter from Myojin of Seeing Winds: Draw a card for each permanent you control.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(new PermanentsOnBattlefieldCount(filter, 1)), new RemoveCountersSourceCost(CounterType.DIVINITY.createInstance()));
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(new PermanentsOnBattlefieldCount(filter)), new RemoveCountersSourceCost(CounterType.DIVINITY.createInstance()));
this.addAbility(ability);
}

View file

@ -27,7 +27,6 @@
*/
package mage.cards.o;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
@ -40,6 +39,8 @@ import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Zone;
import java.util.UUID;
/**
*
* @author LevelX2
@ -57,7 +58,7 @@ public class OkinaNightwatch extends CardImpl {
// As long as you have more cards in hand than each opponent, Okina Nightwatch gets +3/+3.
Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new ConditionalContinuousEffect(
new BoostSourceEffect(3,3, Duration.WhileOnBattlefield),
new MoreCardsInHandThanOpponentsCondition(),
MoreCardsInHandThanOpponentsCondition.instance,
"As long as you have more cards in hand than each opponent, Okina Nightwatch gets +3/+3"));
this.addAbility(ability);
}

View file

@ -63,7 +63,7 @@ public class PhageTheUntouchable extends CardImpl {
// When Phage the Untouchable enters the battlefield, if you didn't cast it from your hand, you lose the game.
this.addAbility(new ConditionalTriggeredAbility(
new EntersBattlefieldTriggeredAbility(new LoseGameSourceControllerEffect(), false),
new InvertCondition(new CastFromHandSourceCondition()),
new InvertCondition(CastFromHandSourceCondition.instance),
"When {this} enters the battlefield, if you didn't cast it from your hand, you lose the game"
), new CastFromHandWatcher());

View file

@ -27,7 +27,6 @@
*/
package mage.cards.r;
import java.util.UUID;
import mage.MageInt;
import mage.ObjectColor;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
@ -44,6 +43,8 @@ import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.filter.predicate.mageobject.ColorPredicate;
import mage.watchers.common.CastFromHandWatcher;
import java.util.UUID;
/**
*
* @author daagar
@ -69,7 +70,7 @@ public class ReiverDemon extends CardImpl {
// When Reiver Demon enters the battlefield, if you cast it from your hand, destroy all nonartifact, nonblack creatures. They can't be regenerated.
this.addAbility(new ConditionalTriggeredAbility(
new EntersBattlefieldTriggeredAbility(new DestroyAllEffect(filter, true), false),
new CastFromHandSourceCondition(),
CastFromHandSourceCondition.instance,
"When {this} enters the battlefield, if you cast it from your hand, destroy all nonartifact, nonblack creatures. They can't be regenerated."),
new CastFromHandWatcher());
}

View file

@ -27,7 +27,6 @@
*/
package mage.cards.s;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.TriggeredAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
@ -41,6 +40,8 @@ import mage.constants.CardType;
import mage.game.permanent.token.BirdToken;
import mage.watchers.common.CastFromHandWatcher;
import java.util.UUID;
/**
*
* @author LevelX2
@ -56,7 +57,7 @@ public class ScionOfVituGhazi extends CardImpl {
TriggeredAbility ability = new EntersBattlefieldTriggeredAbility(new CreateTokenEffect(new BirdToken()), false);
ability.addEffect(new PopulateEffect("then"));
this.addAbility(new ConditionalTriggeredAbility(ability, new CastFromHandSourceCondition(),
this.addAbility(new ConditionalTriggeredAbility(ability, CastFromHandSourceCondition.instance,
"When {this} enters the battlefield, if you cast it from your hand, create a 1/1 white Bird creature token with flying, then populate."),
new CastFromHandWatcher());
}

View file

@ -27,7 +27,6 @@
*/
package mage.cards.s;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
@ -42,6 +41,8 @@ import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Zone;
import java.util.UUID;
/**
*
* @author LevelX2
@ -58,11 +59,11 @@ public class Secretkeeper extends CardImpl {
// As long as you have more cards in hand than each opponent, Secretkeeper gets +2/+2 and has flying.
Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new ConditionalContinuousEffect(
new BoostSourceEffect(2,2, Duration.WhileOnBattlefield),
new MoreCardsInHandThanOpponentsCondition(),
MoreCardsInHandThanOpponentsCondition.instance,
"As long as you have more cards in hand than each opponent, Secretkeeper gets +2/+2"));
ability.addEffect(new ConditionalContinuousEffect(
new GainAbilitySourceEffect(FlyingAbility.getInstance(), Duration.WhileOnBattlefield),
new MoreCardsInHandThanOpponentsCondition(),
MoreCardsInHandThanOpponentsCondition.instance,
"and has flying"));
this.addAbility(ability);
}

View file

@ -13,7 +13,9 @@ import mage.watchers.common.CastFromHandWatcher;
*
* @author Loki
*/
public class CastFromHandSourceCondition implements Condition {
public enum CastFromHandSourceCondition implements Condition {
instance;
@Override
public boolean apply(Game game, Ability source) {

View file

@ -7,7 +7,9 @@ import mage.players.Player;
import java.util.UUID;
public class MoreCardsInHandThanOpponentsCondition implements Condition {
public enum MoreCardsInHandThanOpponentsCondition implements Condition {
instance;
@Override
public boolean apply(Game game, Ability source) {

View file

@ -28,21 +28,21 @@
package mage.abilities.condition.common;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.game.Game;
import mage.players.Player;
import java.util.UUID;
/**
*
* @author fireshoes
*/
public class OpponentHasMoreLifeCondition implements Condition {
public enum OpponentHasMoreLifeCondition implements Condition {
public OpponentHasMoreLifeCondition() {
}
instance;
@Override
public boolean apply(Game game, Ability source) {