mirror of
https://github.com/magefree/mage.git
synced 2026-01-23 11:49:56 -08:00
Added CastAsThoughtItHadFlashEffect and changed cards to use it.
This commit is contained in:
parent
77ac99b03f
commit
f9ecc06f6e
6 changed files with 160 additions and 132 deletions
|
|
@ -41,6 +41,12 @@ import mage.cards.CardImpl;
|
|||
import mage.game.Game;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.effects.common.continious.CastAsThoughItHadFlashEffect;
|
||||
import mage.filter.common.FilterCreatureCard;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.mageobject.CardTypePredicate;
|
||||
import mage.filter.predicate.mageobject.ColorPredicate;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -49,6 +55,11 @@ import java.util.UUID;
|
|||
*/
|
||||
public class AlchemistsRefuge extends CardImpl<AlchemistsRefuge> {
|
||||
|
||||
private static final FilterCreatureCard filter = new FilterCreatureCard("nonland cards");
|
||||
static {
|
||||
filter.add(Predicates.not(new CardTypePredicate(CardType.LAND)));
|
||||
}
|
||||
|
||||
public AlchemistsRefuge(UUID ownerId) {
|
||||
super(ownerId, 225, "Alchemist's Refuge", Rarity.RARE, new CardType[]{CardType.LAND}, "");
|
||||
this.expansionSetCode = "AVR";
|
||||
|
|
@ -57,7 +68,9 @@ public class AlchemistsRefuge extends CardImpl<AlchemistsRefuge> {
|
|||
this.addAbility(new ColorlessManaAbility());
|
||||
|
||||
// {G}{U}, {tap}: You may cast nonland cards this turn as though they had flash.
|
||||
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new AddContinuousEffectToGame(new AlchemistsRefugeEffect()), new CompositeCost(new ManaCostsImpl("{G}{U}"), new TapSourceCost(), "{G}{U}, {T}")));
|
||||
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD,
|
||||
new AddContinuousEffectToGame(new CastAsThoughItHadFlashEffect(Duration.EndOfTurn, filter)),
|
||||
new CompositeCost(new ManaCostsImpl("{G}{U}"), new TapSourceCost(), "{G}{U}, {T}")));
|
||||
}
|
||||
|
||||
public AlchemistsRefuge(final AlchemistsRefuge card) {
|
||||
|
|
@ -69,38 +82,3 @@ public class AlchemistsRefuge extends CardImpl<AlchemistsRefuge> {
|
|||
return new AlchemistsRefuge(this);
|
||||
}
|
||||
}
|
||||
|
||||
class AlchemistsRefugeEffect extends AsThoughEffectImpl<AlchemistsRefugeEffect> {
|
||||
|
||||
public AlchemistsRefugeEffect() {
|
||||
super(AsThoughEffectType.CAST, Duration.EndOfTurn, Outcome.Benefit);
|
||||
staticText = "You may cast nonland cards this turn as though they had flash";
|
||||
}
|
||||
|
||||
public AlchemistsRefugeEffect(final AlchemistsRefugeEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlchemistsRefugeEffect copy() {
|
||||
return new AlchemistsRefugeEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
Card card = game.getCard(sourceId);
|
||||
if (card != null) {
|
||||
if (!card.getCardType().contains(CardType.LAND) && card.getOwnerId().equals(source.getControllerId())) {
|
||||
// TODO: Check if this also works for cards that gained e.g. flashback from another source.
|
||||
return card.getSpellAbility().isInUseableZone(game, card, false);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,20 +28,18 @@
|
|||
package mage.sets.magic2013;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.constants.AsThoughEffectType;
|
||||
import mage.MageInt;
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.common.continious.CastAsThoughItHadFlashEffect;
|
||||
import mage.abilities.keyword.FlashAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.AsThoughEffectImpl;
|
||||
import mage.abilities.keyword.FlashAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.filter.common.FilterCreatureCard;
|
||||
import mage.filter.predicate.mageobject.ColorPredicate;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -49,6 +47,11 @@ import mage.game.Game;
|
|||
*/
|
||||
public class YevaNaturesHerald extends CardImpl<YevaNaturesHerald> {
|
||||
|
||||
private static final FilterCreatureCard filter = new FilterCreatureCard("green creature cards");
|
||||
static {
|
||||
filter.add(new ColorPredicate(ObjectColor.GREEN));
|
||||
}
|
||||
|
||||
public YevaNaturesHerald(UUID ownerId) {
|
||||
super(ownerId, 197, "Yeva, Nature's Herald", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{2}{G}{G}");
|
||||
this.expansionSetCode = "M13";
|
||||
|
|
@ -63,7 +66,7 @@ public class YevaNaturesHerald extends CardImpl<YevaNaturesHerald> {
|
|||
// Flash
|
||||
this.addAbility(FlashAbility.getInstance());
|
||||
// You may cast green creature cards as though they had flash.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new YevaNaturesHeraldEffect()));
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CastAsThoughItHadFlashEffect(Duration.WhileOnBattlefield, filter)));
|
||||
}
|
||||
|
||||
public YevaNaturesHerald(final YevaNaturesHerald card) {
|
||||
|
|
@ -75,38 +78,3 @@ public class YevaNaturesHerald extends CardImpl<YevaNaturesHerald> {
|
|||
return new YevaNaturesHerald(this);
|
||||
}
|
||||
}
|
||||
|
||||
class YevaNaturesHeraldEffect extends AsThoughEffectImpl<YevaNaturesHeraldEffect> {
|
||||
|
||||
public YevaNaturesHeraldEffect() {
|
||||
super(AsThoughEffectType.CAST, Duration.WhileOnBattlefield, Outcome.Benefit);
|
||||
staticText = "You may cast green creature cards as though they had flash";
|
||||
}
|
||||
|
||||
public YevaNaturesHeraldEffect(final YevaNaturesHeraldEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public YevaNaturesHeraldEffect copy() {
|
||||
return new YevaNaturesHeraldEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
Card card = game.getCard(sourceId);
|
||||
if (card != null) {
|
||||
if (card.getCardType().contains(CardType.CREATURE) && card.getColor().isGreen()
|
||||
&& card.getOwnerId().equals(source.getControllerId())) {
|
||||
// TODO: Maybe this check is not enough
|
||||
return card.getSpellAbility().isInUseableZone(game, card, false);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,6 @@
|
|||
package mage.sets.shardsofalara;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.constants.*;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.ActivatedAbilityImpl;
|
||||
|
|
@ -39,6 +37,11 @@ import mage.abilities.effects.OneShotEffect;
|
|||
import mage.abilities.keyword.ReachAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.TimingRule;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterControlledLandPermanent;
|
||||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||
import mage.game.Game;
|
||||
|
|
@ -66,7 +69,7 @@ public class QasaliAmbusher extends CardImpl<QasaliAmbusher> {
|
|||
this.addAbility(ReachAbility.getInstance());
|
||||
// If a creature is attacking you and you control a Forest and a Plains, you may casbt Qasali Ambusher without paying its mana cost and as though it had flash.
|
||||
this.addAbility(new QasaliAmbusherAbility());
|
||||
|
||||
|
||||
}
|
||||
|
||||
public QasaliAmbusher(final QasaliAmbusher card) {
|
||||
|
|
@ -79,15 +82,16 @@ public class QasaliAmbusher extends CardImpl<QasaliAmbusher> {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
class QasaliAmbusherAbility extends ActivatedAbilityImpl<QasaliAmbusherAbility> {
|
||||
|
||||
private static final FilterControlledLandPermanent filterPlains = new FilterControlledLandPermanent();
|
||||
private static final FilterControlledLandPermanent filterForest = new FilterControlledLandPermanent();
|
||||
|
||||
static {
|
||||
filterPlains.add(new SubtypePredicate("Plains"));
|
||||
filterForest.add(new SubtypePredicate("Forest"));
|
||||
}
|
||||
|
||||
public QasaliAmbusherAbility() {
|
||||
super(Zone.HAND, new QasaliAmbusherEffect(), new ManaCostsImpl());
|
||||
this.timing = TimingRule.INSTANT;
|
||||
|
|
@ -105,11 +109,11 @@ class QasaliAmbusherAbility extends ActivatedAbilityImpl<QasaliAmbusherAbility>
|
|||
|
||||
@Override
|
||||
public boolean canActivate(UUID playerId, Game game) {
|
||||
if(super.canActivate(playerId, game)){
|
||||
if(game.getBattlefield().getActivePermanents(filterPlains, this.getControllerId(), this.getSourceId(), game).size() > 0
|
||||
&& game.getBattlefield().getActivePermanents(filterForest, this.getControllerId(), this.getSourceId(), game).size() > 0){
|
||||
for(CombatGroup group : game.getCombat().getGroups()){
|
||||
if(group.getDefenderId().equals(getControllerId())){
|
||||
if (super.canActivate(playerId, game)) {
|
||||
if (game.getBattlefield().getActivePermanents(filterPlains, this.getControllerId(), this.getSourceId(), game).size() > 0
|
||||
&& game.getBattlefield().getActivePermanents(filterForest, this.getControllerId(), this.getSourceId(), game).size() > 0) {
|
||||
for (CombatGroup group : game.getCombat().getGroups()) {
|
||||
if (group.getDefenderId().equals(getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -118,8 +122,6 @@ class QasaliAmbusherAbility extends ActivatedAbilityImpl<QasaliAmbusherAbility>
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String getRule(boolean all) {
|
||||
return this.getRule();
|
||||
|
|
@ -127,7 +129,7 @@ class QasaliAmbusherAbility extends ActivatedAbilityImpl<QasaliAmbusherAbility>
|
|||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "If a creature is attacking you and you control a Forest and a Plains, you may casbt Qasali Ambusher without paying its mana cost and as though it had flash";
|
||||
return "If a creature is attacking you and you control a Forest and a Plains, you may cast {this} without paying its mana cost and as though it had flash.";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -154,7 +156,6 @@ class QasaliAmbusherEffect extends OneShotEffect<QasaliAmbusherEffect> {
|
|||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
SpellAbility spellAbility = card.getSpellAbility();
|
||||
|
||||
spellAbility.clear();
|
||||
return controller.cast(spellAbility, game, true);
|
||||
}
|
||||
|
|
@ -162,4 +163,3 @@ class QasaliAmbusherEffect extends OneShotEffect<QasaliAmbusherEffect> {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import mage.abilities.common.SimpleStaticAbility;
|
|||
import mage.abilities.effects.AsThoughEffectImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.UntapAllControllerEffect;
|
||||
import mage.abilities.effects.common.continious.CastAsThoughItHadFlashEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.AsThoughEffectType;
|
||||
|
|
@ -45,6 +46,7 @@ import mage.constants.Rarity;
|
|||
import mage.constants.TargetController;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.common.FilterCreatureCard;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.mageobject.CardTypePredicate;
|
||||
import mage.game.Game;
|
||||
|
|
@ -77,7 +79,7 @@ public class ProphetOfKruphix extends CardImpl<ProphetOfKruphix> {
|
|||
Effect effect = new UntapAllControllerEffect(filter, "Untap all creatures and lands you control");
|
||||
this.addAbility(new BeginningOfUntapTriggeredAbility(Zone.BATTLEFIELD, effect, TargetController.NOT_YOU, false));
|
||||
// You may cast creature cards as though they had flash.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ProphetOfKruphixEffect()));
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CastAsThoughItHadFlashEffect(Duration.WhileOnBattlefield, new FilterCreatureCard("creature cards"))));
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -90,37 +92,3 @@ public class ProphetOfKruphix extends CardImpl<ProphetOfKruphix> {
|
|||
return new ProphetOfKruphix(this);
|
||||
}
|
||||
}
|
||||
|
||||
class ProphetOfKruphixEffect extends AsThoughEffectImpl<ProphetOfKruphixEffect> {
|
||||
|
||||
public ProphetOfKruphixEffect() {
|
||||
super(AsThoughEffectType.CAST, Duration.WhileOnBattlefield, Outcome.Benefit);
|
||||
staticText = "You may cast creature cards as though they had flash";
|
||||
}
|
||||
|
||||
public ProphetOfKruphixEffect(final ProphetOfKruphixEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProphetOfKruphixEffect copy() {
|
||||
return new ProphetOfKruphixEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, Game game) {
|
||||
Card card = game.getCard(sourceId);
|
||||
if (card != null) {
|
||||
if (card.getCardType().contains(CardType.CREATURE)
|
||||
&& card.getOwnerId().equals(source.getControllerId())) {
|
||||
return card.getSpellAbility().isInUseableZone(game, card, false);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue