From 62a605d3e7bada748bf162eb785b926f927a2829 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Tue, 2 Dec 2014 16:58:31 +0100 Subject: [PATCH] * Some changes to token handling and some cards. --- .../sets/commander2014/FlamekinVillage.java | 2 +- .../commander2014/NahiriTheLithomancer.java | 55 +++++++++++-------- .../mage/sets/darkascension/RequiemAngel.java | 2 +- .../IbHalfheartGoblinTactician.java | 2 +- .../sets/gatecrash/DiluvianPrimordial.java | 36 ++++++------ .../sets/khansoftarkir/HordelingOutburst.java | 2 +- .../sets/khansoftarkir/MarduAscendancy.java | 2 +- .../sets/khansoftarkir/PonybackBrigade.java | 7 ++- .../mirrodinbesieged/ContestedWarZone.java | 8 ++- .../sets/planechase2012/BeetlebackChief.java | 2 +- .../scarsofmirrodin/LiquimetalCoating.java | 2 + .../sets/scarsofmirrodin/PanicSpellbomb.java | 6 +- .../game/permanent/token/GoblinToken.java | 20 +++++-- 13 files changed, 91 insertions(+), 55 deletions(-) diff --git a/Mage.Sets/src/mage/sets/commander2014/FlamekinVillage.java b/Mage.Sets/src/mage/sets/commander2014/FlamekinVillage.java index 75e683573e..e38616cebd 100644 --- a/Mage.Sets/src/mage/sets/commander2014/FlamekinVillage.java +++ b/Mage.Sets/src/mage/sets/commander2014/FlamekinVillage.java @@ -64,7 +64,7 @@ public class FlamekinVillage extends CardImpl { this.expansionSetCode = "C14"; // As Flamekin Village enters the battlefield, you may reveal an Elemental card from your hand. If you don't, Flamekin Village enters the battlefield tapped. - this.addAbility(new AsEntersBattlefieldAbility(new TapSourceUnlessPaysEffect(new RevealTargetFromHandCost(new TargetCardInHand(filter))), "you may reveal a Merfolk card from your hand. If you don't, {this} enters the battlefield tapped")); + this.addAbility(new AsEntersBattlefieldAbility(new TapSourceUnlessPaysEffect(new RevealTargetFromHandCost(new TargetCardInHand(filter))), "you may reveal a Elemental card from your hand. If you don't, {this} enters the battlefield tapped")); // {tap}: Add {R} to your mana pool. this.addAbility(new RedManaAbility()); diff --git a/Mage.Sets/src/mage/sets/commander2014/NahiriTheLithomancer.java b/Mage.Sets/src/mage/sets/commander2014/NahiriTheLithomancer.java index b22f99914c..530b1c5c76 100644 --- a/Mage.Sets/src/mage/sets/commander2014/NahiriTheLithomancer.java +++ b/Mage.Sets/src/mage/sets/commander2014/NahiriTheLithomancer.java @@ -27,6 +27,9 @@ */ package mage.sets.commander2014; +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; @@ -128,25 +131,33 @@ class NahiriTheLithomancerFirstAbilityEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Token token = new NahiriTheLithomancerKorSoldierToken(); - if (token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId())) { - Permanent tokenPermanent = game.getPermanent(token.getLastAddedToken()); - if (tokenPermanent != null) { - //TODO: Make sure the Equipment can legally enchant the token, preferably on targetting. - Target target = new TargetControlledPermanent(0, 1, filter, true); - if (target.choose(Outcome.Neutral, source.getControllerId(), source.getSourceId(), game)) { - Permanent equipmentPermanent = game.getPermanent(target.getFirstTarget()); - if (equipmentPermanent != null) { - Permanent attachedTo = game.getPermanent(equipmentPermanent.getAttachedTo()); - if (attachedTo != null) { - attachedTo.removeAttachment(equipmentPermanent.getId(), game); + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + Token token = new NahiriTheLithomancerKorSoldierToken(); + if (token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId())) { + Permanent tokenPermanent = game.getPermanent(token.getLastAddedToken()); + if (tokenPermanent != null) { + //TODO: Make sure the Equipment can legally enchant the token, preferably on targetting. + Target target = new TargetControlledPermanent(0, 1, filter, true); + if (target.canChoose(source.getSourceId(), controller.getId(), game) && + controller.chooseUse(outcome, "Attach an Equipment you control to the created Token?", game)) { + if (target.choose(Outcome.Neutral, source.getControllerId(), source.getSourceId(), game)) { + Permanent equipmentPermanent = game.getPermanent(target.getFirstTarget()); + if (equipmentPermanent != null) { + Permanent attachedTo = game.getPermanent(equipmentPermanent.getAttachedTo()); + if (attachedTo != null) { + attachedTo.removeAttachment(equipmentPermanent.getId(), game); + } + tokenPermanent.addAttachment(equipmentPermanent.getId(), game); + } } - tokenPermanent.addAttachment(equipmentPermanent.getId(), game); } } } + return true; + } - return true; + return false; } } @@ -187,22 +198,22 @@ class NahiriTheLithomancerSecondAbilityEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player != null) { - if (player.chooseUse(Outcome.PutCardInPlay, "Put an Equipment from hand? (No = from graveyard)", game)) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + if (controller.chooseUse(Outcome.PutCardInPlay, "Put an Equipment from hand? (No = from graveyard)", game)) { Target target = new TargetCardInHand(0, 1, filter); - target.choose(Outcome.PutCardInPlay, source.getControllerId(), source.getSourceId(), game); - Card card = player.getHand().get(target.getFirstTarget(), game); + controller.choose(outcome, target, source.getSourceId(), game); + Card card = controller.getHand().get(target.getFirstTarget(), game); if (card != null) { - player.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getSourceId()); + controller.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getSourceId()); } } else { Target target = new TargetCardInYourGraveyard(0, 1, filter); target.choose(Outcome.PutCardInPlay, source.getControllerId(), source.getSourceId(), game); - Card card = player.getGraveyard().get(target.getFirstTarget(), game); + Card card = controller.getGraveyard().get(target.getFirstTarget(), game); if (card != null) { - player.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId()); + controller.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId()); } } return true; diff --git a/Mage.Sets/src/mage/sets/darkascension/RequiemAngel.java b/Mage.Sets/src/mage/sets/darkascension/RequiemAngel.java index 8f08f3a38a..e2508697ae 100644 --- a/Mage.Sets/src/mage/sets/darkascension/RequiemAngel.java +++ b/Mage.Sets/src/mage/sets/darkascension/RequiemAngel.java @@ -68,7 +68,7 @@ public class RequiemAngel extends CardImpl { this.addAbility(FlyingAbility.getInstance()); // Whenever another non-Spirit creature you control dies, put a 1/1 white Spirit creature token with flying onto the battlefield. - this.addAbility(new DiesCreatureTriggeredAbility(new CreateTokenEffect(new SpiritWhiteToken(), 1), false, filter)); + this.addAbility(new DiesCreatureTriggeredAbility(new CreateTokenEffect(new SpiritWhiteToken(expansionSetCode), 1), false, filter)); } public RequiemAngel(final RequiemAngel card) { diff --git a/Mage.Sets/src/mage/sets/elvesvsgoblins/IbHalfheartGoblinTactician.java b/Mage.Sets/src/mage/sets/elvesvsgoblins/IbHalfheartGoblinTactician.java index a5a1659335..8180daf1ca 100644 --- a/Mage.Sets/src/mage/sets/elvesvsgoblins/IbHalfheartGoblinTactician.java +++ b/Mage.Sets/src/mage/sets/elvesvsgoblins/IbHalfheartGoblinTactician.java @@ -87,7 +87,7 @@ public class IbHalfheartGoblinTactician extends CardImpl { // Sacrifice two Mountains: Put two 1/1 red Goblin creature tokens onto the battlefield. this.addAbility(new SimpleActivatedAbility( Zone.BATTLEFIELD, - new CreateTokenEffect(new GoblinToken("EVG"), 2), + new CreateTokenEffect(new GoblinToken(expansionSetCode), 2), new SacrificeTargetCost(new TargetControlledPermanent(2, 2, filter, true)))); } diff --git a/Mage.Sets/src/mage/sets/gatecrash/DiluvianPrimordial.java b/Mage.Sets/src/mage/sets/gatecrash/DiluvianPrimordial.java index 214b5f6f7f..30b39a3593 100644 --- a/Mage.Sets/src/mage/sets/gatecrash/DiluvianPrimordial.java +++ b/Mage.Sets/src/mage/sets/gatecrash/DiluvianPrimordial.java @@ -36,6 +36,7 @@ import mage.constants.Zone; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.keyword.FlyingAbility; @@ -49,11 +50,10 @@ import mage.game.Game; import mage.game.events.GameEvent; import mage.game.events.GameEvent.EventType; import mage.game.events.ZoneChangeEvent; -import mage.game.stack.Spell; -import mage.game.stack.StackObject; import mage.players.Player; import mage.target.Target; import mage.target.common.TargetCardInOpponentsGraveyard; +import mage.target.targetpointer.FixedTarget; /** * @@ -127,8 +127,12 @@ class DiluvianPrimordialEffect extends OneShotEffect { if (target instanceof TargetCardInOpponentsGraveyard) { Card targetCard = game.getCard(target.getFirstTarget()); if (player != null && targetCard != null) { - player.cast(targetCard.getSpellAbility(), game, true); - game.addEffect(new DiluvianPrimordialReplacementEffect(targetCard.getId()), source); + if (player.chooseUse(outcome, "Cast " + targetCard.getName() +"?", game)) { + player.cast(targetCard.getSpellAbility(), game, true); + ContinuousEffect effect = new DiluvianPrimordialReplacementEffect(); + effect.setTargetPointer(new FixedTarget(targetCard.getId())); + game.addEffect(effect, source); + } } } } @@ -138,16 +142,13 @@ class DiluvianPrimordialEffect extends OneShotEffect { class DiluvianPrimordialReplacementEffect extends ReplacementEffectImpl { - private UUID cardid; - - public DiluvianPrimordialReplacementEffect(UUID cardid) { + public DiluvianPrimordialReplacementEffect() { super(Duration.EndOfTurn, Outcome.Exile); - this.cardid = cardid; + staticText = "If a card cast this way would be put into a graveyard this turn, exile it instead"; } public DiluvianPrimordialReplacementEffect(final DiluvianPrimordialReplacementEffect effect) { super(effect); - this.cardid = effect.cardid; } @Override @@ -162,14 +163,13 @@ class DiluvianPrimordialReplacementEffect extends ReplacementEffectImpl { @Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { - UUID eventObject = ((ZoneChangeEvent) event).getTargetId(); - StackObject card = game.getStack().getStackObject(eventObject); - if (card instanceof Spell) { - game.rememberLKI(card.getId(), Zone.STACK, (Spell) card); - } - if (card instanceof Card && card != null && eventObject == cardid) { - ((Card) card).moveToExile(id, "Diluvian Primordial", id, game); - return true; + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + Card card = game.getCard(getTargetPointer().getFirst(game, source)); + if (card != null) { + controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.STACK); + return true; + } } return false; } @@ -179,7 +179,7 @@ class DiluvianPrimordialReplacementEffect extends ReplacementEffectImpl { if (event.getType() == EventType.ZONE_CHANGE) { ZoneChangeEvent zEvent = (ZoneChangeEvent) event; if (zEvent.getToZone() == Zone.GRAVEYARD - && ((ZoneChangeEvent) event).getTargetId() == cardid) { + && ((ZoneChangeEvent) event).getTargetId().equals(getTargetPointer().getFirst(game, source))) { return true; } } diff --git a/Mage.Sets/src/mage/sets/khansoftarkir/HordelingOutburst.java b/Mage.Sets/src/mage/sets/khansoftarkir/HordelingOutburst.java index da50239661..f11b2a52c9 100644 --- a/Mage.Sets/src/mage/sets/khansoftarkir/HordelingOutburst.java +++ b/Mage.Sets/src/mage/sets/khansoftarkir/HordelingOutburst.java @@ -47,7 +47,7 @@ public class HordelingOutburst extends CardImpl { this.color.setRed(true); // Put 3 1/1 red Goblin creature tokens onto the battlefield. - this.getSpellAbility().addEffect(new CreateTokenEffect(new GoblinToken("KTK"), 3)); + this.getSpellAbility().addEffect(new CreateTokenEffect(new GoblinToken(expansionSetCode), 3)); } public HordelingOutburst(final HordelingOutburst card) { diff --git a/Mage.Sets/src/mage/sets/khansoftarkir/MarduAscendancy.java b/Mage.Sets/src/mage/sets/khansoftarkir/MarduAscendancy.java index 9b950073a1..4827d767d7 100644 --- a/Mage.Sets/src/mage/sets/khansoftarkir/MarduAscendancy.java +++ b/Mage.Sets/src/mage/sets/khansoftarkir/MarduAscendancy.java @@ -69,7 +69,7 @@ public class MarduAscendancy extends CardImpl { this.color.setWhite(true); // Whenever a nontoken creature you control attacks, put a 1/1 red Goblin creature token onto the battlefield tapped and attacking. - this.addAbility(new AttacksCreatureYourControlTriggeredAbility(new CreateTokenEffect(new GoblinToken("KTK"), 1, true, true), false, attackFilter)); + this.addAbility(new AttacksCreatureYourControlTriggeredAbility(new CreateTokenEffect(new GoblinToken(expansionSetCode), 1, true, true), false, attackFilter)); // Sacrifice Mardu Ascendancy: Creatures you control get +0/+3 until end of turn. this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new BoostAllEffect(0, 3, Duration.EndOfTurn, filter, false), diff --git a/Mage.Sets/src/mage/sets/khansoftarkir/PonybackBrigade.java b/Mage.Sets/src/mage/sets/khansoftarkir/PonybackBrigade.java index 6f98560e7a..e5ab12344e 100644 --- a/Mage.Sets/src/mage/sets/khansoftarkir/PonybackBrigade.java +++ b/Mage.Sets/src/mage/sets/khansoftarkir/PonybackBrigade.java @@ -42,6 +42,7 @@ import mage.game.events.GameEvent; import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.game.permanent.token.GoblinToken; +import mage.game.permanent.token.Token; /** * @@ -62,7 +63,7 @@ public class PonybackBrigade extends CardImpl { this.toughness = new MageInt(2); // When Ponyback Brigade enters the battlefield or is turned face up, put three 1/1 red Goblin creature tokens onto the battlefield. - this.addAbility(new PonybackBrigadeAbility()); + this.addAbility(new PonybackBrigadeAbility(new GoblinToken(expansionSetCode))); // Morph {2}{R}{W}{B} this.addAbility(new MorphAbility(this, new ManaCostsImpl("{2}{R}{W}{B}"))); @@ -80,8 +81,8 @@ public class PonybackBrigade extends CardImpl { class PonybackBrigadeAbility extends TriggeredAbilityImpl { - public PonybackBrigadeAbility() { - super(Zone.BATTLEFIELD, new CreateTokenEffect(new GoblinToken("KTK"), 3), false); + public PonybackBrigadeAbility(Token token) { + super(Zone.BATTLEFIELD, new CreateTokenEffect(token, 3), false); this.setWorksFaceDown(true); } diff --git a/Mage.Sets/src/mage/sets/mirrodinbesieged/ContestedWarZone.java b/Mage.Sets/src/mage/sets/mirrodinbesieged/ContestedWarZone.java index 74db20c8b7..f61d7dfae0 100644 --- a/Mage.Sets/src/mage/sets/mirrodinbesieged/ContestedWarZone.java +++ b/Mage.Sets/src/mage/sets/mirrodinbesieged/ContestedWarZone.java @@ -63,11 +63,17 @@ public class ContestedWarZone extends CardImpl { public ContestedWarZone(UUID ownerId) { super(ownerId, 144, "Contested War Zone", Rarity.RARE, new CardType[]{CardType.LAND}, null); this.expansionSetCode = "MBS"; + + // Whenever a creature deals combat damage to you, that creature's controller gains control of Contested War Zone. + this.addAbility(new ContestedWarZoneAbility()); + + // {T}: Add {1} to your mana pool. this.addAbility(new ColorlessManaAbility()); + + // {1}, {T}: Attacking creatures get +1/+0 until end of turn. Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BoostAllEffect(1, 0, Duration.EndOfTurn, filter, false), new ManaCostsImpl("{1}")); ability.addCost(new TapSourceCost()); this.addAbility(ability); - this.addAbility(new ContestedWarZoneAbility()); } public ContestedWarZone(final ContestedWarZone card) { diff --git a/Mage.Sets/src/mage/sets/planechase2012/BeetlebackChief.java b/Mage.Sets/src/mage/sets/planechase2012/BeetlebackChief.java index ec9d8de599..8721de7ff2 100644 --- a/Mage.Sets/src/mage/sets/planechase2012/BeetlebackChief.java +++ b/Mage.Sets/src/mage/sets/planechase2012/BeetlebackChief.java @@ -52,7 +52,7 @@ public class BeetlebackChief extends CardImpl { this.toughness = new MageInt(2); // When Beetleback Chief enters the battlefield, put two 1/1 red Goblin creature tokens onto the battlefield. - this.addAbility(new EntersBattlefieldTriggeredAbility(new CreateTokenEffect(new GoblinToken(), 2))); + this.addAbility(new EntersBattlefieldTriggeredAbility(new CreateTokenEffect(new GoblinToken(expansionSetCode), 2))); } diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/LiquimetalCoating.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/LiquimetalCoating.java index 47525b023f..7d0592a270 100644 --- a/Mage.Sets/src/mage/sets/scarsofmirrodin/LiquimetalCoating.java +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/LiquimetalCoating.java @@ -50,6 +50,8 @@ public class LiquimetalCoating extends CardImpl { public LiquimetalCoating (UUID ownerId) { super(ownerId, 171, "Liquimetal Coating", Rarity.UNCOMMON, new CardType[]{CardType.ARTIFACT}, "{2}"); this.expansionSetCode = "SOM"; + + // {T}: Target permanent becomes an artifact in addition to its other types until end of turn. Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new AddCardTypeTargetEffect(CardType.ARTIFACT, Duration.EndOfTurn), new TapSourceCost()); ability.addTarget(new TargetPermanent()); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/PanicSpellbomb.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/PanicSpellbomb.java index 5aec33ea8b..f373583bdb 100644 --- a/Mage.Sets/src/mage/sets/scarsofmirrodin/PanicSpellbomb.java +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/PanicSpellbomb.java @@ -34,6 +34,7 @@ import mage.constants.Rarity; import mage.constants.Zone; import mage.abilities.Ability; import mage.abilities.common.DiesTriggeredAbility; +import mage.abilities.common.PutIntoGraveFromBattlefieldTriggeredAbility; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.SacrificeSourceCost; import mage.abilities.costs.common.TapSourceCost; @@ -54,11 +55,14 @@ public class PanicSpellbomb extends CardImpl { super(ownerId, 191, "Panic Spellbomb", Rarity.COMMON, new CardType[]{CardType.ARTIFACT}, "{1}"); this.expansionSetCode = "SOM"; + // Tap, Sacrifice Panic Spellbomb: Target creature can't block this turn. Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new CantBlockTargetEffect(Duration.EndOfTurn), new TapSourceCost()); ability.addCost(new SacrificeSourceCost()); ability.addTarget(new TargetCreaturePermanent()); this.addAbility(ability); - this.addAbility(new DiesTriggeredAbility(new DoIfCostPaid(new DrawCardSourceControllerEffect(1), new ManaCostsImpl("{R}")), false)); + + // When Panic Spellbomb is put into a graveyard from the battlefield, you may pay Red. If you do, draw a card. + this.addAbility(new PutIntoGraveFromBattlefieldTriggeredAbility(new DoIfCostPaid(new DrawCardSourceControllerEffect(1), new ManaCostsImpl("{R}")), false)); } public PanicSpellbomb(final PanicSpellbomb card) { diff --git a/Mage/src/mage/game/permanent/token/GoblinToken.java b/Mage/src/mage/game/permanent/token/GoblinToken.java index aeec4f0f5d..36021d30df 100644 --- a/Mage/src/mage/game/permanent/token/GoblinToken.java +++ b/Mage/src/mage/game/permanent/token/GoblinToken.java @@ -27,8 +27,10 @@ */ package mage.game.permanent.token; +import java.util.Arrays; +import java.util.List; +import java.util.Random; import mage.MageInt; -import mage.ObjectColor; import mage.constants.CardType; /** @@ -37,12 +39,22 @@ import mage.constants.CardType; */ public class GoblinToken extends Token { + static List imageSetCodes = Arrays.asList( + "M10", "C14", "KTK", "EVG" + ); + public GoblinToken() { - this("M10"); + this(imageSetCodes.get(new Random().nextInt(imageSetCodes.size()))); } + public GoblinToken(String originalExpansionSetCode) { super("Goblin", "1/1 red Goblin creature token"); - this.setOriginalExpansionSetCode(originalExpansionSetCode); + if (!imageSetCodes.contains(originalExpansionSetCode)) { + this.setOriginalExpansionSetCode(imageSetCodes.get(new Random().nextInt(imageSetCodes.size()))); + } else { + this.setOriginalExpansionSetCode(originalExpansionSetCode); + } + cardType.add(CardType.CREATURE); subtype.add("Goblin"); @@ -50,4 +62,4 @@ public class GoblinToken extends Token { power = new MageInt(1); toughness = new MageInt(1); } -} \ No newline at end of file +}