diff --git a/Mage.Sets/src/mage/cards/c/Cocoon.java b/Mage.Sets/src/mage/cards/c/Cocoon.java new file mode 100644 index 0000000000..ce5d8be5c5 --- /dev/null +++ b/Mage.Sets/src/mage/cards/c/Cocoon.java @@ -0,0 +1,115 @@ + +package mage.cards.c; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.condition.common.SourceHasCounterCondition; +import mage.abilities.decorator.ConditionalContinuousRuleModifyingEffect; +import mage.abilities.effects.ContinuousEffect; +import mage.abilities.effects.Effect; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.AttachEffect; +import mage.abilities.effects.common.DontUntapInControllersUntapStepEnchantedEffect; +import mage.abilities.effects.common.TapEnchantedEffect; +import mage.abilities.effects.common.continuous.GainAbilityTargetEffect; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.abilities.effects.common.counter.AddCountersTargetEffect; +import mage.abilities.keyword.EnchantAbility; +import mage.abilities.keyword.FlyingAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.TargetController; +import mage.constants.Zone; +import mage.counters.CounterType; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.target.TargetPermanent; +import mage.target.common.TargetControlledCreaturePermanent; +import mage.target.targetpointer.FixedTarget; + +/** + * @author L_J + */ +public final class Cocoon extends CardImpl { + + public Cocoon(UUID ownerId, CardSetInfo setInfo) { + super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{G}"); + this.subtype.add(SubType.AURA); + + // Enchant creature you control + TargetPermanent auraTarget = new TargetControlledCreaturePermanent(); + this.getSpellAbility().addTarget(auraTarget); + this.getSpellAbility().addEffect(new AttachEffect(Outcome.Detriment)); + this.addAbility(new EnchantAbility(auraTarget.getTargetName())); + + // When Cocoon enters the battlefield, tap enchanted creature and put three pupa counters on Cocoon. + Ability ability = new EntersBattlefieldTriggeredAbility(new TapEnchantedEffect()); + ability.addEffect(new AddCountersSourceEffect(CounterType.PUPA.createInstance(3))); + this.addAbility(ability); + + // Enchanted creature doesn’t untap during your untap step if Cocoon has a pupa counter on it. + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ConditionalContinuousRuleModifyingEffect(new DontUntapInControllersUntapStepEnchantedEffect(), + new SourceHasCounterCondition(CounterType.PUPA)).setText("Enchanted creature doesn't untap during its controller's untap step if Cocoon has a pupa counter on it"))); + + // At the beginning of your upkeep, remove a pupa counter from Cocoon. If you can’t, sacrifice it, put a +1/+1 counter on enchanted creature, and that creature gains flying. + this.addAbility(new BeginningOfUpkeepTriggeredAbility(new CocoonEffect(), TargetController.YOU, false)); + + } + + public Cocoon(final Cocoon card) { + super(card); + } + + @Override + public Cocoon copy() { + return new Cocoon(this); + } +} + +class CocoonEffect extends OneShotEffect { + + CocoonEffect() { + super(Outcome.Sacrifice); + staticText = "remove a pupa counter from {this}. If you can’t, sacrifice it, put a +1/+1 counter on enchanted creature, and that creature gains flying"; + } + + CocoonEffect(final CocoonEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); + if (permanent != null) { + int amount = permanent.getCounters(game).getCount(CounterType.PUPA); + if (amount > 0) { + permanent.removeCounters(CounterType.PUPA.createInstance(), game); + } else { + Permanent enchantedPermanent = game.getPermanent(permanent.getAttachedTo()); + permanent.sacrifice(source.getSourceId(), game); + if (enchantedPermanent != null) { + Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance()); + effect.setTargetPointer(new FixedTarget(enchantedPermanent, game)); + effect.apply(game, source); + ContinuousEffect effect2 = new GainAbilityTargetEffect(FlyingAbility.getInstance(), Duration.Custom); + effect2.setTargetPointer(new FixedTarget(enchantedPermanent, game)); + game.addEffect(effect2, source); + } + } + return true; + } + return false; + } + + @Override + public CocoonEffect copy() { + return new CocoonEffect(this); + } +} diff --git a/Mage.Sets/src/mage/cards/f/Feint.java b/Mage.Sets/src/mage/cards/f/Feint.java new file mode 100644 index 0000000000..bccd33ddce --- /dev/null +++ b/Mage.Sets/src/mage/cards/f/Feint.java @@ -0,0 +1,85 @@ + +package mage.cards.f; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.PreventionEffect; +import mage.abilities.effects.common.PreventDamageByTargetEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.game.Game; +import mage.game.combat.CombatGroup; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.common.TargetAttackingCreature; +import mage.target.targetpointer.FixedTarget; + +/** + * + * @author L_J + */ +public final class Feint extends CardImpl { + + public Feint(UUID ownerId, CardSetInfo setInfo) { + super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{R}"); + + // Tap all creatures blocking target attacking creature. Prevent all combat damage that would be dealt this turn by that creature and each creature blocking it. + this.getSpellAbility().addEffect(new PreventDamageByTargetEffect(Duration.EndOfTurn, true).setText("")); + this.getSpellAbility().addEffect(new FeintEffect()); + this.getSpellAbility().addTarget(new TargetAttackingCreature()); + } + + public Feint(final Feint card) { + super(card); + } + + @Override + public Feint copy() { + return new Feint(this); + } + +} + +class FeintEffect extends OneShotEffect { + + public FeintEffect() { + super(Outcome.ReturnToHand); + this.staticText = "Tap all creatures blocking target attacking creature. Prevent all combat damage that would be dealt this turn by that creature and each creature blocking it"; + } + + public FeintEffect(final FeintEffect effect) { + super(effect); + } + + @Override + public FeintEffect copy() { + return new FeintEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + Permanent creature = game.getPermanent(getTargetPointer().getFirst(game, source)); + if (controller != null && creature != null) { + for (CombatGroup combatGroup : game.getCombat().getGroups()) { + if (combatGroup.getAttackers().contains(creature.getId())) { + for (UUID blockerId : combatGroup.getBlockers()) { + Permanent blocker = game.getPermanent(blockerId); + if (blocker != null) { + blocker.tap(game); + PreventionEffect effect = new PreventDamageByTargetEffect(Duration.EndOfTurn, true); + effect.setTargetPointer(new FixedTarget(blocker.getId())); + game.addEffect(effect, source); + } + } + } + } + return true; + } + return false; + } +} diff --git a/Mage.Sets/src/mage/cards/g/GiantSlug.java b/Mage.Sets/src/mage/cards/g/GiantSlug.java new file mode 100644 index 0000000000..8cfc8d42f3 --- /dev/null +++ b/Mage.Sets/src/mage/cards/g/GiantSlug.java @@ -0,0 +1,104 @@ + +package mage.cards.g; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.common.delayed.AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect; +import mage.abilities.effects.common.continuous.GainAbilitySourceEffect; +import mage.abilities.keyword.LandwalkAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.choices.ChoiceBasicLandType; +import mage.choices.ChoiceImpl; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.filter.common.FilterLandPermanent; +import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; + +/** + * + * @author L_J + */ +public final class GiantSlug extends CardImpl { + + public GiantSlug(UUID ownerId, CardSetInfo setInfo) { + super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{B}"); + this.subtype.add(SubType.SLUG); + this.power = new MageInt(1); + this.toughness = new MageInt(1); + + // {5}: At the beginning of your next upkeep, choose a basic land type. Giant Slug gains landwalk of the chosen type until the end of that turn. + AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility ability = new AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility(new GiantSlugEffect()); + this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new CreateDelayedTriggeredAbilityEffect(ability), new ManaCostsImpl("{5}"))); + } + + public GiantSlug(final GiantSlug card) { + super(card); + } + + @Override + public GiantSlug copy() { + return new GiantSlug(this); + } + +} + +class GiantSlugEffect extends OneShotEffect { + + public GiantSlugEffect() { + super(Outcome.AddAbility); + this.staticText = "At the beginning of your next upkeep, choose a basic land type. {this} gains landwalk of the chosen type until the end of that turn"; + } + + public GiantSlugEffect(final GiantSlugEffect effect) { + super(effect); + } + + @Override + public GiantSlugEffect copy() { + return new GiantSlugEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); + if (controller != null && sourcePermanent != null) { + ChoiceImpl choices = new ChoiceBasicLandType(); + if (controller.choose(outcome, choices, game)) { + game.informPlayers(sourcePermanent.getName() + ": Chosen basic land type is " + choices.getChoice()); + FilterLandPermanent filter = new FilterLandPermanent(choices.getChoice()); + if (choices.getChoice().equals("Plains")) { + filter.add(new SubtypePredicate(SubType.PLAINS)); + } + if (choices.getChoice().equals("Island")) { + filter.add(new SubtypePredicate(SubType.ISLAND)); + } + if (choices.getChoice().equals("Swamp")) { + filter.add(new SubtypePredicate(SubType.SWAMP)); + } + if (choices.getChoice().equals("Mountain")) { + filter.add(new SubtypePredicate(SubType.MOUNTAIN)); + } + if (choices.getChoice().equals("Forest")) { + filter.add(new SubtypePredicate(SubType.FOREST)); + } + Ability landwalkAbility = new LandwalkAbility(filter); + game.addEffect(new GainAbilitySourceEffect(landwalkAbility, Duration.EndOfTurn, false), source); + return true; + } + } + return false; + } +} diff --git a/Mage.Sets/src/mage/cards/g/GlyphOfReincarnation.java b/Mage.Sets/src/mage/cards/g/GlyphOfReincarnation.java new file mode 100644 index 0000000000..94068e41ef --- /dev/null +++ b/Mage.Sets/src/mage/cards/g/GlyphOfReincarnation.java @@ -0,0 +1,129 @@ + +package mage.cards.g; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import mage.MageObjectReference; +import mage.abilities.Ability; +import mage.abilities.common.CastOnlyDuringPhaseStepSourceAbility; +import mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility; +import mage.abilities.condition.common.AfterCombatCondition; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.InfoEffect; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.filter.StaticFilters; +import mage.filter.common.FilterCreatureCard; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.predicate.other.OwnerIdPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.Target; +import mage.target.common.TargetCardInGraveyard; +import mage.target.common.TargetCreaturePermanent; +import mage.watchers.common.BlockedAttackerWatcher; + +/** + * + * @author L_J + */ +public final class GlyphOfReincarnation extends CardImpl { + + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("Wall creature"); + + static { + filter.add(new SubtypePredicate(SubType.WALL)); + } + + public GlyphOfReincarnation(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{G}"); + + // Cast this spell only after combat. + this.addAbility(new CastOnlyDuringPhaseStepSourceAbility(null, null, AfterCombatCondition.instance, "Cast this spell only after combat")); + + // Destroy all creatures that were blocked by target Wall this turn. They can’t be regenerated. For each creature that died this way, put a creature card from the graveyard of the player who controlled that creature the last time it became blocked by that Wall onto the battlefield under its owner’s control. + this.getSpellAbility().addTarget(new TargetCreaturePermanent(filter)); + this.getSpellAbility().addEffect(new GlyphOfReincarnationEffect()); + this.getSpellAbility().addWatcher(new BlockedAttackerWatcher()); + } + + public GlyphOfReincarnation(final GlyphOfReincarnation card) { + super(card); + } + + @Override + public GlyphOfReincarnation copy() { + return new GlyphOfReincarnation(this); + } +} + +class GlyphOfReincarnationEffect extends OneShotEffect { + + public GlyphOfReincarnationEffect() { + super(Outcome.DestroyPermanent); + this.staticText = "Destroy all creatures that were blocked by target Wall this turn. They can’t be regenerated. For each creature that died this way, put a creature card from the graveyard of the player who controlled that creature the last time it became blocked by that Wall onto the battlefield under its owner’s control"; + } + + public GlyphOfReincarnationEffect(final GlyphOfReincarnationEffect effect) { + super(effect); + } + + @Override + public GlyphOfReincarnationEffect copy() { + return new GlyphOfReincarnationEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + Permanent targetWall = game.getPermanentOrLKIBattlefield(source.getFirstTarget()); + if (controller != null && targetWall != null) { + BlockedAttackerWatcher watcher = (BlockedAttackerWatcher) game.getState().getWatchers().get(BlockedAttackerWatcher.class.getSimpleName()); + if (watcher != null) { + Map destroyed = new HashMap<>(); + for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) { + if (!creature.getId().equals(targetWall.getId())) { + if (watcher.creatureHasBlockedAttacker(new MageObjectReference(creature, game), new MageObjectReference(targetWall, game), game)) { + if (creature.destroy(source.getSourceId(), game, true) + && game.getState().getZone(creature.getId()) == Zone.GRAVEYARD) { // If a commander is replaced to command zone, the creature does not die + Player permController = game.getPlayer(creature.getControllerId()); + if (permController != null) { + destroyed.put(creature.getId(), permController); + } + } + } + } + } + // For each creature that died this way, put a creature card from the graveyard of the player who controlled that creature the last time it became blocked by that Wall + // onto the battlefield under its owner’s control + for (Map.Entry entry : destroyed.entrySet()) { + Permanent permanent = (Permanent) game.getLastKnownInformation(entry.getKey(), Zone.BATTLEFIELD); + Player player = entry.getValue(); + if (permanent != null && player != null) { + FilterCreatureCard filter = new FilterCreatureCard("a creature card from " + player.getName() + "'s graveyard"); + filter.add(new OwnerIdPredicate(player.getId())); + Target targetCreature = new TargetCardInGraveyard(filter); + targetCreature.setNotTarget(true); + if (targetCreature.canChoose(source.getSourceId(), controller.getId(), game) + && controller.chooseTarget(outcome, targetCreature, source, game)) { + Card card = game.getCard(targetCreature.getFirstTarget()); + if (card != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD) { + controller.moveCards(card, Zone.BATTLEFIELD, source, game, false, false, true, null); + } + } + } + } + return true; + } + } + return false; + } +} diff --git a/Mage.Sets/src/mage/cards/l/LesserWerewolf.java b/Mage.Sets/src/mage/cards/l/LesserWerewolf.java new file mode 100644 index 0000000000..84d836b950 --- /dev/null +++ b/Mage.Sets/src/mage/cards/l/LesserWerewolf.java @@ -0,0 +1,93 @@ + +package mage.cards.l; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.condition.common.IsStepCondition; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.decorator.ConditionalActivatedAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.continuous.BoostSourceEffect; +import mage.abilities.effects.common.counter.AddCountersTargetEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.PhaseStep; +import mage.constants.Zone; +import mage.counters.BoostCounter; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.permanent.BlockedByIdPredicate; +import mage.filter.predicate.permanent.BlockingAttackerIdPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.common.TargetCreaturePermanent; + +/** + * + * @author L_J + */ +public final class LesserWerewolf extends CardImpl { + + public LesserWerewolf(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{B}"); + this.subtype.add(SubType.WEREWOLF); + this.power = new MageInt(2); + this.toughness = new MageInt(4); + + // {B}: If Lesser Werewolf’s power is 1 or more, it gets -1/-0 until end of turn and put a -0/-1 counter on target creature blocking or blocked by Lesser Werewolf. Activate this ability only during the declare blockers step. + Ability ability = new ConditionalActivatedAbility(Zone.BATTLEFIELD, new LesserWerewolfEffect(), new ManaCostsImpl("{B}"), new IsStepCondition(PhaseStep.DECLARE_BLOCKERS, false)); + FilterCreaturePermanent filter = new FilterCreaturePermanent("creature blocking or blocked by Lesser Werewolf"); + filter.add(Predicates.or(new BlockedByIdPredicate(this.getId()), + new BlockingAttackerIdPredicate(this.getId()))); + ability.addTarget(new TargetCreaturePermanent(filter)); + this.addAbility(ability); + + } + + public LesserWerewolf(final LesserWerewolf card) { + super(card); + } + + @Override + public LesserWerewolf copy() { + return new LesserWerewolf(this); + } +} + +class LesserWerewolfEffect extends OneShotEffect { + + public LesserWerewolfEffect() { + super(Outcome.Detriment); + this.staticText = "If {this}’s power is 1 or more, it gets -1/-0 until end of turn and put a -0/-1 counter on target creature blocking or blocked by {this}"; + } + + public LesserWerewolfEffect(final LesserWerewolfEffect effect) { + super(effect); + } + + @Override + public LesserWerewolfEffect copy() { + return new LesserWerewolfEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); + Permanent targetPermanent = game.getPermanentOrLKIBattlefield(targetPointer.getFirst(game, source)); + if (controller != null && sourcePermanent != null && targetPermanent != null) { + if (sourcePermanent.getPower().getValue() >= 1) { + game.addEffect(new BoostSourceEffect(-1, 0, Duration.EndOfTurn), source); + new AddCountersTargetEffect(new BoostCounter(0, -1), outcome).apply(game, source); + } + return true; + } + return false; + } +} diff --git a/Mage.Sets/src/mage/cards/p/PuppetMaster.java b/Mage.Sets/src/mage/cards/p/PuppetMaster.java new file mode 100644 index 0000000000..7b4a6f874b --- /dev/null +++ b/Mage.Sets/src/mage/cards/p/PuppetMaster.java @@ -0,0 +1,95 @@ + +package mage.cards.p; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.common.DiesAttachedTriggeredAbility; +import mage.abilities.costs.Cost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.AttachEffect; +import mage.abilities.keyword.EnchantAbility; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetPermanent; +import mage.target.common.TargetCreaturePermanent; + +/** + * + * @author L_J + */ +public final class PuppetMaster extends CardImpl { + + public PuppetMaster(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{U}{U}{U}"); + this.subtype.add(SubType.AURA); + + // Enchant creature + TargetPermanent auraTarget = new TargetCreaturePermanent(); + this.getSpellAbility().addTarget(auraTarget); + this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature)); + Ability ability = new EnchantAbility(auraTarget.getTargetName()); + this.addAbility(ability); + + // When enchanted creature dies, return that card to its owner's hand. If that card is returned to its owner’s hand this way, you may pay {U}{U}{U}. If you do, return Puppet Master to its owner’s hand. + this.addAbility(new DiesAttachedTriggeredAbility(new PuppetMasterEffect(), "enchanted creature")); + } + + public PuppetMaster(final PuppetMaster card) { + super(card); + } + + @Override + public PuppetMaster copy() { + return new PuppetMaster(this); + } +} + +class PuppetMasterEffect extends OneShotEffect { + + public PuppetMasterEffect() { + super(Outcome.ReturnToHand); + staticText = "return that card to its owner's hand. If that card is returned to its owner’s hand this way, you may pay {U}{U}{U}. If you do, return {this} to its owner’s hand"; + } + + public PuppetMasterEffect(final PuppetMasterEffect effect) { + super(effect); + } + + @Override + public PuppetMasterEffect copy() { + return new PuppetMasterEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Object object = getValue("attachedTo"); + if (object instanceof Permanent) { + Card card = game.getCard(((Permanent)object).getId()); + if (card != null) { + if (card.moveToZone(Zone.HAND, source.getSourceId(), game, false)) { + Cost cost = new ManaCostsImpl("{U}{U}{U}"); + Player controller = game.getPlayer(source.getControllerId()); + Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); + if (controller != null && sourcePermanent != null) { + if (controller.chooseUse(Outcome.Neutral, "Pay " + cost.getText() + " to return " + sourcePermanent.getLogName() + " to its owner's hand?", source, game) + && cost.pay(source, game, source.getSourceId(), controller.getId(), false, null)) { + sourcePermanent.moveToZone(Zone.HAND, source.getSourceId(), game, false); + } + } + return true; + } + } + } + return false; + } + +} diff --git a/Mage.Sets/src/mage/cards/r/RapidFire.java b/Mage.Sets/src/mage/cards/r/RapidFire.java new file mode 100644 index 0000000000..a57b9181ed --- /dev/null +++ b/Mage.Sets/src/mage/cards/r/RapidFire.java @@ -0,0 +1,82 @@ + +package mage.cards.r; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.common.CastOnlyDuringPhaseStepSourceAbility; +import mage.abilities.condition.common.BeforeBlockersAreDeclaredCondition; +import mage.abilities.effects.ContinuousEffect; +import mage.abilities.effects.Effect; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.continuous.GainAbilityTargetEffect; +import mage.abilities.keyword.FirstStrikeAbility; +import mage.abilities.keyword.RampageAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.common.TargetCreaturePermanent; +import mage.target.targetpointer.FixedTarget; + +/** + * + * @author L_J + */ +public final class RapidFire extends CardImpl { + + public RapidFire(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{3}{W}"); + + // Cast this spell only before blockers are declared. + this.addAbility(new CastOnlyDuringPhaseStepSourceAbility(null, null, BeforeBlockersAreDeclaredCondition.instance, "Cast this spell only before blockers are declared")); + + // Target creature gains first strike until end of turn. If it doesn’t have rampage, that creature gains rampage 2 until end of turn. + this.getSpellAbility().addEffect(new GainAbilityTargetEffect(FirstStrikeAbility.getInstance(), Duration.EndOfTurn)); + this.getSpellAbility().addEffect(new RapidFireEffect()); + this.getSpellAbility().addTarget(new TargetCreaturePermanent()); + + } + + public RapidFire(final RapidFire card) { + super(card); + } + + @Override + public RapidFire copy() { + return new RapidFire(this); + } + +} + +class RapidFireEffect extends OneShotEffect { + + public RapidFireEffect() { + super(Outcome.AddAbility); + this.staticText = "If it doesn’t have rampage, that creature gains rampage 2 until end of turn"; + } + + public RapidFireEffect(final RapidFireEffect effect) { + super(effect); + } + + @Override + public RapidFireEffect copy() { + return new RapidFireEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source)); + if (controller != null && permanent != null) { + if (!permanent.getAbilities().containsClass(RampageAbility.class)) { + ContinuousEffect effect = new GainAbilityTargetEffect(new RampageAbility(2), Duration.EndOfTurn); + effect.setTargetPointer(new FixedTarget(permanent, game)); + game.addEffect(effect, source); + } + } + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/Legends.java b/Mage.Sets/src/mage/sets/Legends.java index 134bb3b75c..f62c528b51 100644 --- a/Mage.Sets/src/mage/sets/Legends.java +++ b/Mage.Sets/src/mage/sets/Legends.java @@ -70,6 +70,7 @@ public final class Legends extends ExpansionSet { cards.add(new SetCardInfo("Cleanse", 5, Rarity.RARE, mage.cards.c.Cleanse.class)); cards.add(new SetCardInfo("Clergy of the Holy Nimbus", 6, Rarity.COMMON, mage.cards.c.ClergyOfTheHolyNimbus.class)); cards.add(new SetCardInfo("Concordant Crossroads", 179, Rarity.RARE, mage.cards.c.ConcordantCrossroads.class)); + cards.add(new SetCardInfo("Cocoon", 178, Rarity.UNCOMMON, mage.cards.c.Cocoon.class)); cards.add(new SetCardInfo("Cosmic Horror", 92, Rarity.RARE, mage.cards.c.CosmicHorror.class)); cards.add(new SetCardInfo("Craw Giant", 180, Rarity.UNCOMMON, mage.cards.c.CrawGiant.class)); cards.add(new SetCardInfo("Crevasse", 138, Rarity.UNCOMMON, mage.cards.c.Crevasse.class)); @@ -101,6 +102,7 @@ public final class Legends extends ExpansionSet { cards.add(new SetCardInfo("Eureka", 185, Rarity.RARE, mage.cards.e.Eureka.class)); cards.add(new SetCardInfo("Evil Eye of Orms-by-Gore", 96, Rarity.UNCOMMON, mage.cards.e.EvilEyeOfOrmsByGore.class)); cards.add(new SetCardInfo("Fallen Angel", 97, Rarity.UNCOMMON, mage.cards.f.FallenAngel.class)); + cards.add(new SetCardInfo("Feint", 146, Rarity.COMMON, mage.cards.f.Feint.class)); cards.add(new SetCardInfo("Field of Dreams", 55, Rarity.RARE, mage.cards.f.FieldOfDreams.class)); cards.add(new SetCardInfo("Fire Sprites", 186, Rarity.COMMON, mage.cards.f.FireSprites.class)); cards.add(new SetCardInfo("Flash Counter", 56, Rarity.COMMON, mage.cards.f.FlashCounter.class)); @@ -114,11 +116,13 @@ public final class Legends extends ExpansionSet { cards.add(new SetCardInfo("Gaseous Form", 59, Rarity.COMMON, mage.cards.g.GaseousForm.class)); cards.add(new SetCardInfo("Gauntlets of Chaos", 278, Rarity.RARE, mage.cards.g.GauntletsOfChaos.class)); cards.add(new SetCardInfo("Ghosts of the Damned", 98, Rarity.COMMON, mage.cards.g.GhostsOfTheDamned.class)); + cards.add(new SetCardInfo("Giant Slug", 99, Rarity.COMMON, mage.cards.g.GiantSlug.class)); cards.add(new SetCardInfo("Giant Strength", 149, Rarity.COMMON, mage.cards.g.GiantStrength.class)); cards.add(new SetCardInfo("Giant Turtle", 188, Rarity.COMMON, mage.cards.g.GiantTurtle.class)); cards.add(new SetCardInfo("Glyph of Destruction", 150, Rarity.COMMON, mage.cards.g.GlyphOfDestruction.class)); cards.add(new SetCardInfo("Glyph of Doom", 100, Rarity.COMMON, mage.cards.g.GlyphOfDoom.class)); cards.add(new SetCardInfo("Glyph of Life", 15, Rarity.COMMON, mage.cards.g.GlyphOfLife.class)); + cards.add(new SetCardInfo("Glyph of Reincarnation", 189, Rarity.COMMON, mage.cards.g.GlyphOfReincarnation.class)); cards.add(new SetCardInfo("Gosta Dirk", 227, Rarity.RARE, mage.cards.g.GostaDirk.class)); cards.add(new SetCardInfo("Gravity Sphere", 151, Rarity.RARE, mage.cards.g.GravitySphere.class)); cards.add(new SetCardInfo("Great Defender", 16, Rarity.UNCOMMON, mage.cards.g.GreatDefender.class)); @@ -172,6 +176,7 @@ public final class Legends extends ExpansionSet { cards.add(new SetCardInfo("Land Equilibrium", 64, Rarity.RARE, mage.cards.l.LandEquilibrium.class)); cards.add(new SetCardInfo("Land Tax", 26, Rarity.UNCOMMON, mage.cards.l.LandTax.class)); cards.add(new SetCardInfo("Land's Edge", 158, Rarity.RARE, mage.cards.l.LandsEdge.class)); + cards.add(new SetCardInfo("Lesser Werewolf", 110, Rarity.UNCOMMON, mage.cards.l.LesserWerewolf.class)); cards.add(new SetCardInfo("Life Chisel", 283, Rarity.UNCOMMON, mage.cards.l.LifeChisel.class)); cards.add(new SetCardInfo("Lifeblood", 27, Rarity.RARE, mage.cards.l.Lifeblood.class)); cards.add(new SetCardInfo("Living Plane", 193, Rarity.RARE, mage.cards.l.LivingPlane.class)); @@ -208,6 +213,7 @@ public final class Legends extends ExpansionSet { cards.add(new SetCardInfo("Princess Lucrezia", 249, Rarity.UNCOMMON, mage.cards.p.PrincessLucrezia.class)); cards.add(new SetCardInfo("Psionic Entity", 67, Rarity.RARE, mage.cards.p.PsionicEntity.class)); cards.add(new SetCardInfo("Psychic Purge", 68, Rarity.COMMON, mage.cards.p.PsychicPurge.class)); + cards.add(new SetCardInfo("Puppet Master", 69, Rarity.UNCOMMON, mage.cards.p.PuppetMaster.class)); cards.add(new SetCardInfo("Pyrotechnics", 161, Rarity.COMMON, mage.cards.p.Pyrotechnics.class)); cards.add(new SetCardInfo("Quagmire", 115, Rarity.UNCOMMON, mage.cards.q.Quagmire.class)); cards.add(new SetCardInfo("Rabid Wombat", 198, Rarity.UNCOMMON, mage.cards.r.RabidWombat.class)); @@ -216,6 +222,7 @@ public final class Legends extends ExpansionSet { cards.add(new SetCardInfo("Ragnar", 250, Rarity.RARE, mage.cards.r.Ragnar.class)); cards.add(new SetCardInfo("Ramirez DePietro", 251, Rarity.UNCOMMON, mage.cards.r.RamirezDePietro.class)); cards.add(new SetCardInfo("Ramses Overdark", 252, Rarity.RARE, mage.cards.r.RamsesOverdark.class)); + cards.add(new SetCardInfo("Rapid Fire", 32, Rarity.RARE, mage.cards.r.RapidFire.class)); cards.add(new SetCardInfo("Rasputin Dreamweaver", 253, Rarity.RARE, mage.cards.r.RasputinDreamweaver.class)); cards.add(new SetCardInfo("Recall", 70, Rarity.RARE, mage.cards.r.Recall.class)); cards.add(new SetCardInfo("Red Mana Battery", 291, Rarity.UNCOMMON, mage.cards.r.RedManaBattery.class)); diff --git a/Mage/src/main/java/mage/abilities/condition/common/AfterCombatCondition.java b/Mage/src/main/java/mage/abilities/condition/common/AfterCombatCondition.java new file mode 100644 index 0000000000..76bdc4be62 --- /dev/null +++ b/Mage/src/main/java/mage/abilities/condition/common/AfterCombatCondition.java @@ -0,0 +1,25 @@ + +package mage.abilities.condition.common; + +import mage.abilities.Ability; +import mage.abilities.condition.Condition; +import mage.constants.PhaseStep; +import mage.game.Game; + +/** + * @author L_J + */ +public enum AfterCombatCondition implements Condition { + + instance; + @Override + + public boolean apply(Game game, Ability source) { + return game.getStep().getType().isAfter(PhaseStep.END_COMBAT); + } + + @Override + public String toString() { + return "after combat"; + } +}