mirror of
https://github.com/correl/mage.git
synced 2025-04-13 01:01:11 -09:00
Some fixes to put token onto battlefield handling of cards. Some minor reworks.
This commit is contained in:
parent
7bb5d1bb43
commit
ec7c888044
26 changed files with 356 additions and 271 deletions
Mage.Sets/src/mage/sets
avacynrestored
battleforzendikar
commander2014
commander2015
dissension
gatecrash
guildpact
innistrad
journeyintonyx
magic2014
mirage
phyrexiavsthecoalition
planechase2012
prophecy
scourge
shadowmoor
worldwake
zendikar
Mage.Tests/src/test/java/org/mage/test/cards/triggers
Mage/src/mage
|
@ -31,7 +31,6 @@ import java.util.UUID;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.ObjectColor;
|
import mage.ObjectColor;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.DelayedTriggeredAbility;
|
|
||||||
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
|
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.abilities.effects.common.SacrificeTargetEffect;
|
import mage.abilities.effects.common.SacrificeTargetEffect;
|
||||||
|
@ -87,18 +86,14 @@ class ThatcherRevoltEffect extends OneShotEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
for (int i = 0; i < 3; i++) {
|
|
||||||
RedHumanToken token = new RedHumanToken();
|
RedHumanToken token = new RedHumanToken();
|
||||||
token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId());
|
token.putOntoBattlefield(3, game, source.getSourceId(), source.getControllerId());
|
||||||
Permanent permanent = game.getPermanent(token.getLastAddedToken());
|
for (UUID tokenId : token.getLastAddedTokenIds()) {
|
||||||
if (permanent != null) {
|
Permanent tokenPermanent = game.getPermanent(tokenId);
|
||||||
SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect("sacrifice this token", source.getControllerId());
|
if (tokenPermanent != null) {
|
||||||
sacrificeEffect.setTargetPointer(new FixedTarget(permanent, game));
|
SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect();
|
||||||
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect);
|
sacrificeEffect.setTargetPointer(new FixedTarget(tokenPermanent, game));
|
||||||
delayedAbility.setSourceId(source.getSourceId());
|
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect), source);
|
||||||
delayedAbility.setControllerId(source.getControllerId());
|
|
||||||
delayedAbility.setSourceObject(source.getSourceObject(game), game);
|
|
||||||
game.addDelayedTriggeredAbility(delayedAbility);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -30,7 +30,6 @@ package mage.sets.battleforzendikar;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.DelayedTriggeredAbility;
|
|
||||||
import mage.abilities.common.LandfallAbility;
|
import mage.abilities.common.LandfallAbility;
|
||||||
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
|
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
|
||||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||||
|
@ -44,6 +43,7 @@ import mage.constants.CardType;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.Rarity;
|
import mage.constants.Rarity;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
import mage.game.permanent.token.Token;
|
import mage.game.permanent.token.Token;
|
||||||
import mage.target.targetpointer.FixedTarget;
|
import mage.target.targetpointer.FixedTarget;
|
||||||
|
|
||||||
|
@ -97,13 +97,14 @@ class AkoumStonewakerEffect extends OneShotEffect {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Token token = new AkoumStonewakerElementalToken();
|
Token token = new AkoumStonewakerElementalToken();
|
||||||
if (token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId())) {
|
if (token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId())) {
|
||||||
|
for (UUID tokenId : token.getLastAddedTokenIds()) {
|
||||||
|
Permanent tokenPermanent = game.getPermanent(tokenId);
|
||||||
|
if (tokenPermanent != null) {
|
||||||
ExileTargetEffect exileEffect = new ExileTargetEffect();
|
ExileTargetEffect exileEffect = new ExileTargetEffect();
|
||||||
exileEffect.setTargetPointer(new FixedTarget(token.getLastAddedToken()));
|
exileEffect.setTargetPointer(new FixedTarget(tokenPermanent, game));
|
||||||
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect);
|
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect), source);
|
||||||
delayedAbility.setSourceId(source.getSourceId());
|
}
|
||||||
delayedAbility.setControllerId(source.getControllerId());
|
}
|
||||||
delayedAbility.setSourceObject(source.getSourceObject(game), game);
|
|
||||||
game.addDelayedTriggeredAbility(delayedAbility);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -129,12 +129,13 @@ class NahiriTheLithomancerFirstAbilityEffect extends OneShotEffect {
|
||||||
if (controller != null) {
|
if (controller != null) {
|
||||||
Token token = new KorSoldierToken();
|
Token token = new KorSoldierToken();
|
||||||
if (token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId())) {
|
if (token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId())) {
|
||||||
Permanent tokenPermanent = game.getPermanent(token.getLastAddedToken());
|
for (UUID tokenId : token.getLastAddedTokenIds()) {
|
||||||
|
Permanent tokenPermanent = game.getPermanent(tokenId);
|
||||||
if (tokenPermanent != null) {
|
if (tokenPermanent != null) {
|
||||||
//TODO: Make sure the Equipment can legally enchant the token, preferably on targetting.
|
//TODO: Make sure the Equipment can legally enchant the token, preferably on targetting.
|
||||||
Target target = new TargetControlledPermanent(0, 1, filter, true);
|
Target target = new TargetControlledPermanent(0, 1, filter, true);
|
||||||
if (target.canChoose(source.getSourceId(), controller.getId(), game)
|
if (target.canChoose(source.getSourceId(), controller.getId(), game)
|
||||||
&& controller.chooseUse(outcome, "Attach an Equipment you control to the created Token?", source, game)) {
|
&& controller.chooseUse(outcome, "Attach an Equipment you control to the created " + tokenPermanent.getIdName() + "?", source, game)) {
|
||||||
if (target.choose(Outcome.Neutral, source.getControllerId(), source.getSourceId(), game)) {
|
if (target.choose(Outcome.Neutral, source.getControllerId(), source.getSourceId(), game)) {
|
||||||
Permanent equipmentPermanent = game.getPermanent(target.getFirstTarget());
|
Permanent equipmentPermanent = game.getPermanent(target.getFirstTarget());
|
||||||
if (equipmentPermanent != null) {
|
if (equipmentPermanent != null) {
|
||||||
|
@ -148,6 +149,7 @@ class NahiriTheLithomancerFirstAbilityEffect extends OneShotEffect {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,6 @@ package mage.sets.commander2015;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.DelayedTriggeredAbility;
|
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility;
|
import mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility;
|
||||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||||
|
@ -137,25 +136,25 @@ class MirrorMatchEffect extends OneShotEffect {
|
||||||
if (controller != null) {
|
if (controller != null) {
|
||||||
for (UUID attackerId : game.getCombat().getAttackers()) {
|
for (UUID attackerId : game.getCombat().getAttackers()) {
|
||||||
Permanent attacker = game.getPermanent(attackerId);
|
Permanent attacker = game.getPermanent(attackerId);
|
||||||
if (attacker != null) {
|
if (attacker != null
|
||||||
if (source.getControllerId().equals(game.getCombat().getDefendingPlayerId(attackerId, game))) {
|
&& source.getControllerId().equals(game.getCombat().getDefendingPlayerId(attackerId, game))) {
|
||||||
PutTokenOntoBattlefieldCopyTargetEffect effect = new PutTokenOntoBattlefieldCopyTargetEffect(source.getControllerId(), null, false);
|
PutTokenOntoBattlefieldCopyTargetEffect effect = new PutTokenOntoBattlefieldCopyTargetEffect(source.getControllerId(), null, false);
|
||||||
effect.setTargetPointer(new FixedTarget(attacker, game));
|
effect.setTargetPointer(new FixedTarget(attacker, game));
|
||||||
effect.apply(game, source);
|
effect.apply(game, source);
|
||||||
|
CombatGroup group = game.getCombat().findGroup(attacker.getId());
|
||||||
|
boolean isCreature = false;
|
||||||
|
if (group != null) {
|
||||||
for (Permanent addedToken : effect.getAddedPermanent()) {
|
for (Permanent addedToken : effect.getAddedPermanent()) {
|
||||||
if (addedToken.getCardType().contains(CardType.CREATURE)) {
|
if (addedToken.getCardType().contains(CardType.CREATURE)) {
|
||||||
CombatGroup group = game.getCombat().findGroup(attacker.getId());
|
|
||||||
if (group != null) {
|
|
||||||
group.addBlockerToGroup(addedToken.getId(), attackerId, game);
|
group.addBlockerToGroup(addedToken.getId(), attackerId, game);
|
||||||
|
isCreature = true;
|
||||||
}
|
}
|
||||||
|
ExileTargetEffect exileEffect = new ExileTargetEffect("Exile the token at end of combat");
|
||||||
|
exileEffect.setTargetPointer(new FixedTarget(addedToken, game));
|
||||||
|
game.addDelayedTriggeredAbility(new AtTheEndOfCombatDelayedTriggeredAbility(exileEffect), source);
|
||||||
}
|
}
|
||||||
ExileTargetEffect sacrificeEffect = new ExileTargetEffect("Exile the token at end of combat");
|
if (isCreature) {
|
||||||
sacrificeEffect.setTargetPointer(new FixedTarget(addedToken, game));
|
group.pickBlockerOrder(attacker.getControllerId(), game);
|
||||||
DelayedTriggeredAbility delayedAbility = new AtTheEndOfCombatDelayedTriggeredAbility(sacrificeEffect);
|
|
||||||
delayedAbility.setSourceId(source.getSourceId());
|
|
||||||
delayedAbility.setControllerId(source.getControllerId());
|
|
||||||
delayedAbility.setSourceObject(source.getSourceObject(game), game);
|
|
||||||
game.addDelayedTriggeredAbility(delayedAbility);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,6 @@ package mage.sets.dissension;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.DelayedTriggeredAbility;
|
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
|
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
|
||||||
import mage.abilities.costs.common.DiscardCardCost;
|
import mage.abilities.costs.common.DiscardCardCost;
|
||||||
|
@ -46,6 +45,7 @@ import mage.constants.Outcome;
|
||||||
import mage.constants.Rarity;
|
import mage.constants.Rarity;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
import mage.game.permanent.token.Token;
|
import mage.game.permanent.token.Token;
|
||||||
import mage.target.common.TargetCreaturePermanent;
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
import mage.target.targetpointer.FixedTarget;
|
import mage.target.targetpointer.FixedTarget;
|
||||||
|
@ -66,7 +66,7 @@ public class RakdosGuildmage extends CardImpl {
|
||||||
|
|
||||||
// <i>({BR} can be paid with either {B} or {R}.)</i>
|
// <i>({BR} can be paid with either {B} or {R}.)</i>
|
||||||
// {3}{B}, Discard a card: Target creature gets -2/-2 until end of turn.
|
// {3}{B}, Discard a card: Target creature gets -2/-2 until end of turn.
|
||||||
SimpleActivatedAbility ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BoostTargetEffect(-2,-2, Duration.EndOfTurn), new ManaCostsImpl("{3}{B}"));
|
SimpleActivatedAbility ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BoostTargetEffect(-2, -2, Duration.EndOfTurn), new ManaCostsImpl("{3}{B}"));
|
||||||
ability.addTarget(new TargetCreaturePermanent());
|
ability.addTarget(new TargetCreaturePermanent());
|
||||||
ability.addCost(new DiscardCardCost());
|
ability.addCost(new DiscardCardCost());
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
|
@ -86,7 +86,6 @@ public class RakdosGuildmage extends CardImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class RakdosGuildmageEffect extends OneShotEffect {
|
class RakdosGuildmageEffect extends OneShotEffect {
|
||||||
|
|
||||||
public RakdosGuildmageEffect() {
|
public RakdosGuildmageEffect() {
|
||||||
|
@ -107,13 +106,14 @@ class RakdosGuildmageEffect extends OneShotEffect {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Token token = new RakdosGuildmageGoblinToken();
|
Token token = new RakdosGuildmageGoblinToken();
|
||||||
if (token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId())) {
|
if (token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId())) {
|
||||||
|
for (UUID tokenId : token.getLastAddedTokenIds()) {
|
||||||
|
Permanent tokenPermanent = game.getPermanent(tokenId);
|
||||||
|
if (tokenPermanent != null) {
|
||||||
ExileTargetEffect exileEffect = new ExileTargetEffect();
|
ExileTargetEffect exileEffect = new ExileTargetEffect();
|
||||||
exileEffect.setTargetPointer(new FixedTarget(token.getLastAddedToken()));
|
exileEffect.setTargetPointer(new FixedTarget(tokenPermanent, game));
|
||||||
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect);
|
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect), source);
|
||||||
delayedAbility.setSourceId(source.getSourceId());
|
}
|
||||||
delayedAbility.setControllerId(source.getControllerId());
|
}
|
||||||
delayedAbility.setSourceObject(source.getSourceObject(game), game);
|
|
||||||
game.addDelayedTriggeredAbility(delayedAbility);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -29,7 +29,6 @@ package mage.sets.gatecrash;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.ObjectColor;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.abilities.effects.common.DestroyTargetEffect;
|
import mage.abilities.effects.common.DestroyTargetEffect;
|
||||||
|
@ -52,7 +51,6 @@ public class RapidHybridization extends CardImpl {
|
||||||
super(ownerId, 44, "Rapid Hybridization", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{U}");
|
super(ownerId, 44, "Rapid Hybridization", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{U}");
|
||||||
this.expansionSetCode = "GTC";
|
this.expansionSetCode = "GTC";
|
||||||
|
|
||||||
|
|
||||||
// Destroy target creature. It can't be regenerated. That creature's controller puts a 3/3 green Frog Lizard creature token onto the battlefield.
|
// Destroy target creature. It can't be regenerated. That creature's controller puts a 3/3 green Frog Lizard creature token onto the battlefield.
|
||||||
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
|
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
|
||||||
this.getSpellAbility().addEffect(new DestroyTargetEffect(true));
|
this.getSpellAbility().addEffect(new DestroyTargetEffect(true));
|
||||||
|
@ -87,7 +85,7 @@ class RapidHybridizationEffect extends OneShotEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Permanent permanent = (Permanent) game.getPermanentOrLKIBattlefield(targetPointer.getFirst(game, source));
|
Permanent permanent = game.getPermanentOrLKIBattlefield(targetPointer.getFirst(game, source));
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
RapidHybridizationToken token = new RapidHybridizationToken();
|
RapidHybridizationToken token = new RapidHybridizationToken();
|
||||||
token.putOntoBattlefield(1, game, source.getSourceId(), permanent.getControllerId());
|
token.putOntoBattlefield(1, game, source.getSourceId(), permanent.getControllerId());
|
||||||
|
|
|
@ -28,12 +28,9 @@
|
||||||
package mage.sets.guildpact;
|
package mage.sets.guildpact;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.DelayedTriggeredAbility;
|
|
||||||
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
|
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
|
||||||
import mage.abilities.effects.Effect;
|
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.abilities.effects.common.ExileTargetEffect;
|
import mage.abilities.effects.common.ExileTargetEffect;
|
||||||
import mage.abilities.keyword.DefenderAbility;
|
import mage.abilities.keyword.DefenderAbility;
|
||||||
|
@ -44,6 +41,7 @@ import mage.constants.CardType;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.Rarity;
|
import mage.constants.Rarity;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
import mage.game.permanent.token.Token;
|
import mage.game.permanent.token.Token;
|
||||||
import mage.target.targetpointer.FixedTarget;
|
import mage.target.targetpointer.FixedTarget;
|
||||||
|
|
||||||
|
@ -93,13 +91,14 @@ class ThunderheadsEffect extends OneShotEffect {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Token token = new WeirdToken();
|
Token token = new WeirdToken();
|
||||||
if (token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId())) {
|
if (token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId())) {
|
||||||
|
for (UUID tokenId : token.getLastAddedTokenIds()) {
|
||||||
|
Permanent tokenPermanent = game.getPermanent(tokenId);
|
||||||
|
if (tokenPermanent != null) {
|
||||||
ExileTargetEffect exileEffect = new ExileTargetEffect();
|
ExileTargetEffect exileEffect = new ExileTargetEffect();
|
||||||
exileEffect.setTargetPointer(new FixedTarget(token.getLastAddedToken()));
|
exileEffect.setTargetPointer(new FixedTarget(tokenPermanent, game));
|
||||||
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect);
|
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect), source);
|
||||||
delayedAbility.setSourceId(source.getSourceId());
|
}
|
||||||
delayedAbility.setControllerId(source.getControllerId());
|
}
|
||||||
delayedAbility.setSourceObject(source.getSourceObject(game), game);
|
|
||||||
game.addDelayedTriggeredAbility(delayedAbility);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -107,6 +106,7 @@ class ThunderheadsEffect extends OneShotEffect {
|
||||||
}
|
}
|
||||||
|
|
||||||
class WeirdToken extends Token {
|
class WeirdToken extends Token {
|
||||||
|
|
||||||
WeirdToken() {
|
WeirdToken() {
|
||||||
super("Weird", "3/3 blue Weird create token with defender and flying");
|
super("Weird", "3/3 blue Weird create token with defender and flying");
|
||||||
cardType.add(CardType.CREATURE);
|
cardType.add(CardType.CREATURE);
|
||||||
|
|
|
@ -35,14 +35,13 @@ import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.AttacksTriggeredAbility;
|
import mage.abilities.common.AttacksTriggeredAbility;
|
||||||
import mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility;
|
import mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility;
|
||||||
import mage.abilities.effects.Effect;
|
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
|
|
||||||
import mage.abilities.effects.common.ExileTargetEffect;
|
import mage.abilities.effects.common.ExileTargetEffect;
|
||||||
import mage.abilities.keyword.HexproofAbility;
|
import mage.abilities.keyword.HexproofAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
import mage.game.permanent.token.AngelToken;
|
import mage.game.permanent.token.AngelToken;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.targetpointer.FixedTarget;
|
import mage.target.targetpointer.FixedTarget;
|
||||||
|
@ -79,6 +78,7 @@ public class GeistOfSaintTraft extends CardImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
class GeistOfSaintTraftEffect extends OneShotEffect {
|
class GeistOfSaintTraftEffect extends OneShotEffect {
|
||||||
|
|
||||||
GeistOfSaintTraftEffect() {
|
GeistOfSaintTraftEffect() {
|
||||||
super(Outcome.PutCreatureInPlay);
|
super(Outcome.PutCreatureInPlay);
|
||||||
staticText = "put a 4/4 white Angel creature token with flying onto the battlefield tapped and attacking. Exile that token at end of combat";
|
staticText = "put a 4/4 white Angel creature token with flying onto the battlefield tapped and attacking. Exile that token at end of combat";
|
||||||
|
@ -93,10 +93,14 @@ class GeistOfSaintTraftEffect extends OneShotEffect {
|
||||||
AngelToken token = new AngelToken();
|
AngelToken token = new AngelToken();
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
if (controller != null && token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId(), true, true)) {
|
if (controller != null && token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId(), true, true)) {
|
||||||
Effect effect = new ExileTargetEffect();
|
for (UUID tokenId : token.getLastAddedTokenIds()) {
|
||||||
effect.setTargetPointer(new FixedTarget(token.getLastAddedToken()));
|
Permanent tokenPermanent = game.getPermanent(tokenId);
|
||||||
CreateDelayedTriggeredAbilityEffect createEffect = new CreateDelayedTriggeredAbilityEffect(new AtTheEndOfCombatDelayedTriggeredAbility(effect), false);
|
if (tokenPermanent != null) {
|
||||||
createEffect.apply(game, source);
|
ExileTargetEffect exileEffect = new ExileTargetEffect();
|
||||||
|
exileEffect.setTargetPointer(new FixedTarget(tokenPermanent, game));
|
||||||
|
game.addDelayedTriggeredAbility(new AtTheEndOfCombatDelayedTriggeredAbility(exileEffect), source);
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -192,7 +192,7 @@ class BrainMaggotReturnExiledCardEffect extends OneShotEffect {
|
||||||
ExileZone exile = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), zoneChangeCounter));
|
ExileZone exile = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), zoneChangeCounter));
|
||||||
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||||
if (exile != null && sourcePermanent != null) {
|
if (exile != null && sourcePermanent != null) {
|
||||||
controller.moveCards(exile, null, Zone.HAND, source, game);
|
controller.moveCards(exile, Zone.HAND, source, game);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,6 @@ package mage.sets.magic2014;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.ObjectColor;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.EntersBattlefieldAllTriggeredAbility;
|
import mage.abilities.common.EntersBattlefieldAllTriggeredAbility;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
@ -39,8 +38,7 @@ import mage.constants.Outcome;
|
||||||
import mage.constants.Rarity;
|
import mage.constants.Rarity;
|
||||||
import mage.constants.SetTargetPointer;
|
import mage.constants.SetTargetPointer;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.filter.common.FilterControlledPermanent;
|
import mage.filter.common.FilterControlledEnchantmentPermanent;
|
||||||
import mage.filter.predicate.mageobject.CardTypePredicate;
|
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.game.permanent.token.CatToken;
|
import mage.game.permanent.token.CatToken;
|
||||||
|
@ -53,11 +51,6 @@ import mage.players.Player;
|
||||||
*/
|
*/
|
||||||
public class AjanisChosen extends CardImpl {
|
public class AjanisChosen extends CardImpl {
|
||||||
|
|
||||||
private static final FilterControlledPermanent filter = new FilterControlledPermanent();
|
|
||||||
static {
|
|
||||||
filter.add(new CardTypePredicate(CardType.ENCHANTMENT));
|
|
||||||
}
|
|
||||||
|
|
||||||
public AjanisChosen(UUID ownerId) {
|
public AjanisChosen(UUID ownerId) {
|
||||||
super(ownerId, 2, "Ajani's Chosen", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{2}{W}{W}");
|
super(ownerId, 2, "Ajani's Chosen", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{2}{W}{W}");
|
||||||
this.expansionSetCode = "M14";
|
this.expansionSetCode = "M14";
|
||||||
|
@ -69,7 +62,7 @@ public class AjanisChosen extends CardImpl {
|
||||||
|
|
||||||
// Whenever an enchantment enters the battlefield under your control, put a 2/2 white Cat creature token onto the battlefield. If that enchantment is an Aura, you may attach it to the token.
|
// Whenever an enchantment enters the battlefield under your control, put a 2/2 white Cat creature token onto the battlefield. If that enchantment is an Aura, you may attach it to the token.
|
||||||
this.addAbility(new EntersBattlefieldAllTriggeredAbility(
|
this.addAbility(new EntersBattlefieldAllTriggeredAbility(
|
||||||
Zone.BATTLEFIELD, new AjanisChosenEffect(), filter, false, SetTargetPointer.PERMANENT,
|
Zone.BATTLEFIELD, new AjanisChosenEffect(), new FilterControlledEnchantmentPermanent(), false, SetTargetPointer.PERMANENT,
|
||||||
"Whenever an enchantment enters the battlefield under your control, put a 2/2 white Cat creature token onto the battlefield. If that enchantment is an Aura, you may attach it to the token"));
|
"Whenever an enchantment enters the battlefield under your control, put a 2/2 white Cat creature token onto the battlefield. If that enchantment is an Aura, you may attach it to the token"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +78,6 @@ public class AjanisChosen extends CardImpl {
|
||||||
|
|
||||||
class AjanisChosenEffect extends OneShotEffect {
|
class AjanisChosenEffect extends OneShotEffect {
|
||||||
|
|
||||||
|
|
||||||
public AjanisChosenEffect() {
|
public AjanisChosenEffect() {
|
||||||
super(Outcome.PutCreatureInPlay);
|
super(Outcome.PutCreatureInPlay);
|
||||||
staticText = "put a 2/2 white Cat creature token onto the battlefield. If that enchantment is an Aura, you may attach it to the token";
|
staticText = "put a 2/2 white Cat creature token onto the battlefield. If that enchantment is an Aura, you may attach it to the token";
|
||||||
|
@ -102,19 +94,22 @@ class AjanisChosenEffect extends OneShotEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
|
if (controller != null) {
|
||||||
Token token = new CatToken();
|
Token token = new CatToken();
|
||||||
if(token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId())){
|
if (token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId())) {
|
||||||
Player player = game.getPlayer(source.getControllerId());
|
Permanent enchantment = game.getPermanent(this.getTargetPointer().getFirst(game, source));
|
||||||
Permanent enchantement = game.getPermanent(this.getTargetPointer().getFirst(game, source));
|
if (enchantment != null && enchantment.getSubtype().contains("Aura")) {
|
||||||
Permanent tokenPermanent = game.getPermanent(token.getLastAddedToken());
|
for (UUID tokenId : token.getLastAddedTokenIds()) {
|
||||||
if(player != null && enchantement != null && tokenPermanent != null && enchantement.getSubtype().contains("Aura"))
|
Permanent tokenPermanent = game.getPermanent(tokenId);
|
||||||
{
|
if (tokenPermanent != null) {
|
||||||
Permanent oldCreature = game.getPermanent(enchantement.getAttachedTo());
|
Permanent oldCreature = game.getPermanent(enchantment.getAttachedTo());
|
||||||
|
if (oldCreature != null && enchantment.getSpellAbility().getTargets().get(0).canTarget(tokenPermanent.getId(), game) && controller.chooseUse(Outcome.Neutral, "Attach " + enchantment.getName() + " to the token ?", source, game)) {
|
||||||
if(oldCreature != null && enchantement.getSpellAbility().getTargets().get(0).canTarget(tokenPermanent.getId(), game) && player.chooseUse(Outcome.Neutral, "Attach " + enchantement.getName() + " to the token ?", source, game))
|
if (oldCreature.removeAttachment(enchantment.getId(), game)) {
|
||||||
{
|
tokenPermanent.addAttachment(enchantment.getId(), game);
|
||||||
if(oldCreature.removeAttachment(enchantement.getId(), game)){
|
}
|
||||||
tokenPermanent.addAttachment(enchantement.getId(), game);
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,6 @@ public class DevoutInvocation extends CardImpl {
|
||||||
super(ownerId, 16, "Devout Invocation", Rarity.MYTHIC, new CardType[]{CardType.SORCERY}, "{6}{W}");
|
super(ownerId, 16, "Devout Invocation", Rarity.MYTHIC, new CardType[]{CardType.SORCERY}, "{6}{W}");
|
||||||
this.expansionSetCode = "M14";
|
this.expansionSetCode = "M14";
|
||||||
|
|
||||||
|
|
||||||
// Tap any number of untapped creatures you control. Put a 4/4 white Angel creature token with flying onto the battlefield for each creature tapped this way.
|
// Tap any number of untapped creatures you control. Put a 4/4 white Angel creature token with flying onto the battlefield for each creature tapped this way.
|
||||||
this.getSpellAbility().addEffect(new DevoutInvocationEffect());
|
this.getSpellAbility().addEffect(new DevoutInvocationEffect());
|
||||||
|
|
||||||
|
@ -93,7 +92,7 @@ class DevoutInvocationEffect extends OneShotEffect {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
if (controller != null) {
|
if (controller != null) {
|
||||||
int tappedAmount = 0;
|
int tappedAmount = 0;
|
||||||
TargetPermanent target = new TargetPermanent(0,1,filter, false);
|
TargetPermanent target = new TargetPermanent(0, 1, filter, false);
|
||||||
while (true && controller.canRespond()) {
|
while (true && controller.canRespond()) {
|
||||||
target.clearChosen();
|
target.clearChosen();
|
||||||
if (target.canChoose(source.getControllerId(), game)) {
|
if (target.canChoose(source.getControllerId(), game)) {
|
||||||
|
@ -109,15 +108,13 @@ class DevoutInvocationEffect extends OneShotEffect {
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tappedAmount > 0) {
|
if (tappedAmount > 0) {
|
||||||
AngelToken angelToken = new AngelToken();
|
AngelToken angelToken = new AngelToken();
|
||||||
angelToken.putOntoBattlefield(tappedAmount, game, source.getSourceId(), source.getControllerId());
|
angelToken.putOntoBattlefield(tappedAmount, game, source.getSourceId(), source.getControllerId());
|
||||||
game.informPlayers(new StringBuilder(controller.getLogName()).append(" puts ").append(tappedAmount).append(" token").append(tappedAmount != 1 ?"s":"").append(" onto the battlefield").toString());
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,13 +28,10 @@
|
||||||
package mage.sets.mirage;
|
package mage.sets.mirage;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.DelayedTriggeredAbility;
|
|
||||||
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
|
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.abilities.effects.common.ExileTargetEffect;
|
|
||||||
import mage.abilities.effects.common.SacrificeTargetEffect;
|
import mage.abilities.effects.common.SacrificeTargetEffect;
|
||||||
import mage.abilities.keyword.DefenderAbility;
|
import mage.abilities.keyword.DefenderAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
|
@ -42,6 +39,7 @@ import mage.constants.CardType;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.Rarity;
|
import mage.constants.Rarity;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
import mage.game.permanent.token.Token;
|
import mage.game.permanent.token.Token;
|
||||||
import mage.target.targetpointer.FixedTarget;
|
import mage.target.targetpointer.FixedTarget;
|
||||||
|
|
||||||
|
@ -89,13 +87,14 @@ class TidalWaveEffect extends OneShotEffect {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Token token = new WallToken();
|
Token token = new WallToken();
|
||||||
if (token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId())) {
|
if (token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId())) {
|
||||||
|
for (UUID tokenId : token.getLastAddedTokenIds()) {
|
||||||
|
Permanent tokenPermanent = game.getPermanent(tokenId);
|
||||||
|
if (tokenPermanent != null) {
|
||||||
SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect();
|
SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect();
|
||||||
sacrificeEffect.setTargetPointer(new FixedTarget(token.getLastAddedToken()));
|
sacrificeEffect.setTargetPointer(new FixedTarget(tokenPermanent, game));
|
||||||
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect);
|
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect), source);
|
||||||
delayedAbility.setSourceId(source.getSourceId());
|
}
|
||||||
delayedAbility.setControllerId(source.getControllerId());
|
}
|
||||||
delayedAbility.setSourceObject(source.getSourceObject(game), game);
|
|
||||||
game.addDelayedTriggeredAbility(delayedAbility);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -103,6 +102,7 @@ class TidalWaveEffect extends OneShotEffect {
|
||||||
}
|
}
|
||||||
|
|
||||||
class WallToken extends Token {
|
class WallToken extends Token {
|
||||||
|
|
||||||
WallToken() {
|
WallToken() {
|
||||||
super("Wall", "5/5 blue Wall creature token with defender");
|
super("Wall", "5/5 blue Wall creature token with defender");
|
||||||
cardType.add(CardType.CREATURE);
|
cardType.add(CardType.CREATURE);
|
||||||
|
|
|
@ -29,7 +29,6 @@ package mage.sets.phyrexiavsthecoalition;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.DelayedTriggeredAbility;
|
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
|
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
|
||||||
import mage.abilities.costs.common.TapSourceCost;
|
import mage.abilities.costs.common.TapSourceCost;
|
||||||
|
@ -42,6 +41,7 @@ import mage.constants.Outcome;
|
||||||
import mage.constants.Rarity;
|
import mage.constants.Rarity;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
import mage.game.permanent.token.HornetToken;
|
import mage.game.permanent.token.HornetToken;
|
||||||
import mage.game.permanent.token.Token;
|
import mage.game.permanent.token.Token;
|
||||||
import mage.target.targetpointer.FixedTarget;
|
import mage.target.targetpointer.FixedTarget;
|
||||||
|
@ -92,14 +92,14 @@ class HornetCannonEffect extends OneShotEffect {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Token hornetToken = new HornetToken();
|
Token hornetToken = new HornetToken();
|
||||||
hornetToken.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId());
|
hornetToken.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId());
|
||||||
|
for (UUID tokenId : hornetToken.getLastAddedTokenIds()) {
|
||||||
DestroyTargetEffect destroyEffect = new DestroyTargetEffect("destroy the token.");
|
Permanent tokenPermanent = game.getPermanent(tokenId);
|
||||||
destroyEffect.setTargetPointer(new FixedTarget(hornetToken.getLastAddedToken()));
|
if (tokenPermanent != null) {
|
||||||
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(destroyEffect);
|
DestroyTargetEffect destroyEffect = new DestroyTargetEffect(false);
|
||||||
delayedAbility.setSourceId(source.getSourceId());
|
destroyEffect.setTargetPointer(new FixedTarget(tokenPermanent, game));
|
||||||
delayedAbility.setControllerId(source.getControllerId());
|
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(destroyEffect), source);
|
||||||
delayedAbility.setSourceObject(source.getSourceObject(game), game);
|
}
|
||||||
game.addDelayedTriggeredAbility(delayedAbility);
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -28,26 +28,19 @@
|
||||||
package mage.sets.planechase2012;
|
package mage.sets.planechase2012;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.effects.ContinuousEffect;
|
|
||||||
import mage.abilities.effects.Effect;
|
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.abilities.effects.common.continuous.BoostTargetEffect;
|
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardsImpl;
|
import mage.cards.CardsImpl;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Duration;
|
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.Rarity;
|
import mage.constants.Rarity;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.players.Library;
|
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.common.TargetCreatureOrPlayer;
|
import mage.target.common.TargetCreatureOrPlayer;
|
||||||
import mage.target.common.TargetCreaturePermanent;
|
|
||||||
import mage.target.targetpointer.FixedTarget;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -78,7 +71,7 @@ class ErraticExplosionEffect extends OneShotEffect {
|
||||||
|
|
||||||
public ErraticExplosionEffect() {
|
public ErraticExplosionEffect() {
|
||||||
super(Outcome.Damage);
|
super(Outcome.Damage);
|
||||||
this.staticText = "Choose target creature or player. Reveal cards from the top of your library until you reveal a nonland card. Erratic Explosion deals damage equal to that card's converted mana cost to that creature or player. Put the revealed cards on the bottom of your library in any order.";
|
this.staticText = "Choose target creature or player. Reveal cards from the top of your library until you reveal a nonland card. {this} deals damage equal to that card's converted mana cost to that creature or player. Put the revealed cards on the bottom of your library in any order";
|
||||||
}
|
}
|
||||||
|
|
||||||
public ErraticExplosionEffect(ErraticExplosionEffect effect) {
|
public ErraticExplosionEffect(ErraticExplosionEffect effect) {
|
||||||
|
@ -92,32 +85,36 @@ class ErraticExplosionEffect extends OneShotEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player player = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
if (player != null && player.getLibrary().size() > 0) {
|
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||||
CardsImpl cards = new CardsImpl();
|
if (controller != null && sourceObject != null) {
|
||||||
Library library = player.getLibrary();
|
CardsImpl toReveal = new CardsImpl();
|
||||||
Card card = null;
|
boolean nonLandFound = false;
|
||||||
do {
|
Card nonLandCard = null;
|
||||||
card = library.removeFromTop(game);
|
|
||||||
if (card != null) {
|
while (nonLandFound && controller.getLibrary().size() > 0) {
|
||||||
cards.add(card);
|
nonLandCard = controller.getLibrary().removeFromTop(game);
|
||||||
|
toReveal.add(nonLandCard);
|
||||||
|
nonLandFound = nonLandCard.getCardType().contains(CardType.LAND);
|
||||||
}
|
}
|
||||||
} while (library.size() > 0 && card != null && card.getCardType().contains(CardType.LAND));
|
|
||||||
// reveal cards
|
// reveal cards
|
||||||
if (!cards.isEmpty()) {
|
if (!toReveal.isEmpty()) {
|
||||||
player.revealCards("Erratic Explosion", cards, game);
|
controller.revealCards(sourceObject.getIdName(), toReveal, game);
|
||||||
}
|
}
|
||||||
// the nonland card
|
// the nonland card
|
||||||
|
if (nonLandCard != null) {
|
||||||
Permanent targetCreature = game.getPermanent(this.getTargetPointer().getFirst(game, source));
|
Permanent targetCreature = game.getPermanent(this.getTargetPointer().getFirst(game, source));
|
||||||
if (targetCreature != null) {
|
if (targetCreature != null) {
|
||||||
targetCreature.damage(card.getManaCost().convertedManaCost(), source.getSourceId(), game, false, true);
|
targetCreature.damage(nonLandCard.getManaCost().convertedManaCost(), source.getSourceId(), game, false, true);
|
||||||
}
|
} else {
|
||||||
Player targetPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
|
Player targetPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
|
||||||
if (targetPlayer != null) {
|
if (targetPlayer != null) {
|
||||||
targetPlayer.damage(card.getManaCost().convertedManaCost(), source.getSourceId(), game, false, true);
|
targetPlayer.damage(nonLandCard.getManaCost().convertedManaCost(), source.getSourceId(), game, false, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// put the cards on the bottom of the library in any order
|
// put the cards on the bottom of the library in any order
|
||||||
return player.putCardsOnBottomOfLibrary(cards, game, source, true);
|
return controller.putCardsOnBottomOfLibrary(toReveal, game, source, true);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,6 @@ import java.util.UUID;
|
||||||
|
|
||||||
import mage.constants.*;
|
import mage.constants.*;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.ObjectColor;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
@ -51,7 +50,6 @@ public class InfernalGenesis extends CardImpl {
|
||||||
super(ownerId, 68, "Infernal Genesis", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{4}{B}{B}");
|
super(ownerId, 68, "Infernal Genesis", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{4}{B}{B}");
|
||||||
this.expansionSetCode = "PCY";
|
this.expansionSetCode = "PCY";
|
||||||
|
|
||||||
|
|
||||||
// At the beginning of each player's upkeep, that player puts the top card of his or her library into his or her graveyard. Then he or she puts X 1/1 black Minion creature tokens onto the battlefield, where X is that card's converted mana cost.
|
// At the beginning of each player's upkeep, that player puts the top card of his or her library into his or her graveyard. Then he or she puts X 1/1 black Minion creature tokens onto the battlefield, where X is that card's converted mana cost.
|
||||||
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new InfernalGenesisEffect(), TargetController.ANY, false));
|
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new InfernalGenesisEffect(), TargetController.ANY, false));
|
||||||
}
|
}
|
||||||
|
@ -81,9 +79,9 @@ class InfernalGenesisEffect extends OneShotEffect {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
|
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
Card card = player.getLibrary().removeFromTop(game);
|
Card card = player.getLibrary().getFromTop(game);
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
if (player.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game)) {
|
if (player.moveCards(card, Zone.GRAVEYARD, source, game)) {
|
||||||
int cmc = card.getManaCost().convertedManaCost();
|
int cmc = card.getManaCost().convertedManaCost();
|
||||||
MinionToken token = new MinionToken();
|
MinionToken token = new MinionToken();
|
||||||
token.putOntoBattlefield(cmc, game, source.getSourceId(), player.getId());
|
token.putOntoBattlefield(cmc, game, source.getSourceId(), player.getId());
|
||||||
|
|
|
@ -27,9 +27,10 @@
|
||||||
*/
|
*/
|
||||||
package mage.sets.scourge;
|
package mage.sets.scourge;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.MageInt;
|
import mage.MageObject;
|
||||||
import mage.ObjectColor;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||||
import mage.abilities.common.LeavesBattlefieldTriggeredAbility;
|
import mage.abilities.common.LeavesBattlefieldTriggeredAbility;
|
||||||
|
@ -48,7 +49,10 @@ import mage.filter.predicate.permanent.ControllerPredicate;
|
||||||
import mage.game.ExileZone;
|
import mage.game.ExileZone;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
import mage.game.permanent.PermanentToken;
|
||||||
import mage.game.permanent.token.DragonToken2;
|
import mage.game.permanent.token.DragonToken2;
|
||||||
|
import mage.players.Player;
|
||||||
|
import mage.util.CardUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -60,7 +64,6 @@ public class DayOfTheDragons extends CardImpl {
|
||||||
super(ownerId, 31, "Day of the Dragons", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{4}{U}{U}{U}");
|
super(ownerId, 31, "Day of the Dragons", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{4}{U}{U}{U}");
|
||||||
this.expansionSetCode = "SCG";
|
this.expansionSetCode = "SCG";
|
||||||
|
|
||||||
|
|
||||||
// When Day of the Dragons enters the battlefield, exile all creatures you control. Then put that many 5/5 red Dragon creature tokens with flying onto the battlefield.
|
// When Day of the Dragons enters the battlefield, exile all creatures you control. Then put that many 5/5 red Dragon creature tokens with flying onto the battlefield.
|
||||||
this.addAbility(new EntersBattlefieldTriggeredAbility(new DayOfTheDragonsEntersEffect(), false));
|
this.addAbility(new EntersBattlefieldTriggeredAbility(new DayOfTheDragonsEntersEffect(), false));
|
||||||
|
|
||||||
|
@ -98,18 +101,17 @@ class DayOfTheDragonsEntersEffect extends OneShotEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
UUID exileId = source.getSourceId();
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
int creaturesExiled = 0;
|
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||||
if (exileId != null) {
|
if (controller != null && sourceObject != null) {
|
||||||
for (Permanent creature : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
|
Set<Card> toExile = new HashSet<>();
|
||||||
if (creature != null) {
|
toExile.addAll(game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game));
|
||||||
if (creature.moveToExile(exileId, "Day of the Dragons", source.getSourceId(), game)) {
|
if (!toExile.isEmpty()) {
|
||||||
creaturesExiled++;
|
UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
|
||||||
}
|
controller.moveCardsToExile(toExile, source, game, true, exileId, sourceObject.getIdName());
|
||||||
}
|
|
||||||
}
|
|
||||||
DragonToken2 token = new DragonToken2();
|
DragonToken2 token = new DragonToken2();
|
||||||
token.putOntoBattlefield(creaturesExiled, game, source.getSourceId(), source.getControllerId());
|
token.putOntoBattlefield(toExile.size(), game, source.getSourceId(), source.getControllerId());
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -141,20 +143,22 @@ class DayOfTheDragonsLeavesEffect extends OneShotEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
UUID exileId = source.getSourceId();
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
|
MageObject sourceObject = source.getSourceObject(game);
|
||||||
|
if (controller != null) {
|
||||||
for (Permanent dragon : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
|
for (Permanent dragon : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
|
||||||
if (dragon != null) {
|
if (dragon != null) {
|
||||||
dragon.sacrifice(source.getSourceId(), game);
|
dragon.sacrifice(source.getSourceId(), game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ExileZone exile = game.getExile().getExileZone(exileId);
|
int zoneChangeCounter = source.getSourceObjectZoneChangeCounter();
|
||||||
if (exile != null) {
|
if (zoneChangeCounter > 0 && !(sourceObject instanceof PermanentToken)) {
|
||||||
exile = exile.copy();
|
zoneChangeCounter--;
|
||||||
for (UUID cardId : exile) {
|
}
|
||||||
Card card = game.getCard(cardId);
|
ExileZone exile = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), zoneChangeCounter));
|
||||||
card.putOntoBattlefield(game, Zone.EXILED, source.getSourceId(), source.getControllerId());
|
if (exile != null) {
|
||||||
|
controller.moveCards(exile, Zone.BATTLEFIELD, source, game);
|
||||||
}
|
}
|
||||||
game.getExile().getExileZone(exileId).clear();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -30,7 +30,6 @@ package mage.sets.shadowmoor;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.DelayedTriggeredAbility;
|
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
|
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
|
||||||
|
@ -65,7 +64,6 @@ public class ElementalMastery extends CardImpl {
|
||||||
this.expansionSetCode = "SHM";
|
this.expansionSetCode = "SHM";
|
||||||
this.subtype.add("Aura");
|
this.subtype.add("Aura");
|
||||||
|
|
||||||
|
|
||||||
// Enchant creature
|
// Enchant creature
|
||||||
TargetPermanent auraTarget = new TargetCreaturePermanent();
|
TargetPermanent auraTarget = new TargetCreaturePermanent();
|
||||||
this.getSpellAbility().addTarget(auraTarget);
|
this.getSpellAbility().addTarget(auraTarget);
|
||||||
|
@ -110,16 +108,17 @@ class ElementalMasteryEffect extends OneShotEffect {
|
||||||
Permanent creatureAttached = game.getPermanent(source.getSourceId());
|
Permanent creatureAttached = game.getPermanent(source.getSourceId());
|
||||||
if (creatureAttached != null) {
|
if (creatureAttached != null) {
|
||||||
int power = creatureAttached.getPower().getValue();
|
int power = creatureAttached.getPower().getValue();
|
||||||
for (int i = 0; i < power; i++) {
|
if (power > 0) {
|
||||||
ElementalToken token = new ElementalToken();
|
ElementalToken token = new ElementalToken();
|
||||||
token.putOntoBattlefield(1, game, creatureAttached.getId(), creatureAttached.getControllerId());
|
token.putOntoBattlefield(power, game, creatureAttached.getId(), creatureAttached.getControllerId());
|
||||||
ExileTargetEffect exileEffect = new ExileTargetEffect("exile the token");
|
for (UUID tokenId : token.getLastAddedTokenIds()) {
|
||||||
exileEffect.setTargetPointer(new FixedTarget(token.getLastAddedToken()));
|
Permanent tokenPermanent = game.getPermanent(tokenId);
|
||||||
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect);
|
if (tokenPermanent != null) {
|
||||||
delayedAbility.setSourceId(source.getId());
|
ExileTargetEffect exileEffect = new ExileTargetEffect();
|
||||||
delayedAbility.setControllerId(source.getControllerId());
|
exileEffect.setTargetPointer(new FixedTarget(tokenPermanent, game));
|
||||||
delayedAbility.setSourceObject(source.getSourceObject(game), game);
|
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect), source);
|
||||||
game.addDelayedTriggeredAbility(delayedAbility);
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,6 @@ package mage.sets.shadowmoor;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.DelayedTriggeredAbility;
|
|
||||||
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
|
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.abilities.effects.common.ExileTargetEffect;
|
import mage.abilities.effects.common.ExileTargetEffect;
|
||||||
|
@ -41,6 +40,7 @@ import mage.constants.CardType;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.Rarity;
|
import mage.constants.Rarity;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
import mage.game.permanent.token.Token;
|
import mage.game.permanent.token.Token;
|
||||||
import mage.target.targetpointer.FixedTarget;
|
import mage.target.targetpointer.FixedTarget;
|
||||||
|
|
||||||
|
@ -92,13 +92,14 @@ class GiantbaitingEffect extends OneShotEffect {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Token token = new GiantWarriorToken();
|
Token token = new GiantWarriorToken();
|
||||||
if (token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId())) {
|
if (token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId())) {
|
||||||
|
for (UUID tokenId : token.getLastAddedTokenIds()) {
|
||||||
|
Permanent tokenPermanent = game.getPermanent(tokenId);
|
||||||
|
if (tokenPermanent != null) {
|
||||||
ExileTargetEffect exileEffect = new ExileTargetEffect();
|
ExileTargetEffect exileEffect = new ExileTargetEffect();
|
||||||
exileEffect.setTargetPointer(new FixedTarget(token.getLastAddedToken()));
|
exileEffect.setTargetPointer(new FixedTarget(tokenPermanent, game));
|
||||||
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect);
|
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect), source);
|
||||||
delayedAbility.setSourceId(source.getSourceId());
|
}
|
||||||
delayedAbility.setControllerId(source.getControllerId());
|
}
|
||||||
delayedAbility.setSourceObject(source.getSourceObject(game), game);
|
|
||||||
game.addDelayedTriggeredAbility(delayedAbility);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -30,7 +30,6 @@ package mage.sets.worldwake;
|
||||||
import mage.constants.*;
|
import mage.constants.*;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.DelayedTriggeredAbility;
|
|
||||||
import mage.abilities.SpellAbility;
|
import mage.abilities.SpellAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
|
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
|
||||||
|
@ -47,6 +46,7 @@ import mage.target.targetpointer.FixedTarget;
|
||||||
import mage.util.CardUtil;
|
import mage.util.CardUtil;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -54,7 +54,6 @@ import java.util.UUID;
|
||||||
*/
|
*/
|
||||||
public class StoneIdolTrap extends CardImpl {
|
public class StoneIdolTrap extends CardImpl {
|
||||||
|
|
||||||
|
|
||||||
public StoneIdolTrap(UUID ownerId) {
|
public StoneIdolTrap(UUID ownerId) {
|
||||||
super(ownerId, 93, "Stone Idol Trap", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{5}{R}");
|
super(ownerId, 93, "Stone Idol Trap", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{5}{R}");
|
||||||
this.expansionSetCode = "WWK";
|
this.expansionSetCode = "WWK";
|
||||||
|
@ -86,6 +85,7 @@ class StoneIdolTrapCostReductionEffect extends CostModificationEffectImpl {
|
||||||
static {
|
static {
|
||||||
filter.add(new AttackingPredicate());
|
filter.add(new AttackingPredicate());
|
||||||
}
|
}
|
||||||
|
|
||||||
public StoneIdolTrapCostReductionEffect() {
|
public StoneIdolTrapCostReductionEffect() {
|
||||||
super(Duration.WhileOnStack, Outcome.Benefit, CostModificationType.REDUCE_COST);
|
super(Duration.WhileOnStack, Outcome.Benefit, CostModificationType.REDUCE_COST);
|
||||||
staticText = "{this} costs {1} less to cast for each attacking creature";
|
staticText = "{this} costs {1} less to cast for each attacking creature";
|
||||||
|
@ -97,7 +97,7 @@ class StoneIdolTrapCostReductionEffect extends CostModificationEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
||||||
int reductionAmount = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(),game);
|
int reductionAmount = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game);
|
||||||
CardUtil.reduceCost(abilityToModify, reductionAmount);
|
CardUtil.reduceCost(abilityToModify, reductionAmount);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -136,14 +136,14 @@ class StoneIdolTrapEffect extends OneShotEffect {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
StoneTrapIdolToken token = new StoneTrapIdolToken();
|
StoneTrapIdolToken token = new StoneTrapIdolToken();
|
||||||
token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId());
|
token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId());
|
||||||
ExileTargetEffect exileEffect = new ExileTargetEffect("exile the token");
|
for (UUID tokenId : token.getLastAddedTokenIds()) {
|
||||||
exileEffect.setTargetPointer(new FixedTarget(token.getLastAddedToken()));
|
Permanent tokenPermanent = game.getPermanent(tokenId);
|
||||||
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect, TargetController.YOU);
|
if (tokenPermanent != null) {
|
||||||
delayedAbility.setSourceId(source.getSourceId());
|
ExileTargetEffect exileEffect = new ExileTargetEffect();
|
||||||
delayedAbility.setControllerId(source.getControllerId());
|
exileEffect.setTargetPointer(new FixedTarget(tokenPermanent, game));
|
||||||
delayedAbility.setSourceObject(source.getSourceObject(game), game);
|
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect), source);
|
||||||
game.addDelayedTriggeredAbility(delayedAbility);
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,6 @@ import mage.constants.Duration;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.Rarity;
|
import mage.constants.Rarity;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.DelayedTriggeredAbility;
|
|
||||||
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
|
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
|
||||||
import mage.abilities.condition.LockedInCondition;
|
import mage.abilities.condition.LockedInCondition;
|
||||||
import mage.abilities.condition.common.KickedCondition;
|
import mage.abilities.condition.common.KickedCondition;
|
||||||
|
@ -44,6 +43,7 @@ import mage.abilities.effects.common.continuous.BoostTargetEffect;
|
||||||
import mage.abilities.keyword.KickerAbility;
|
import mage.abilities.keyword.KickerAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
import mage.target.targetpointer.FixedTarget;
|
import mage.target.targetpointer.FixedTarget;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,7 +56,6 @@ public class ElementalAppeal extends CardImpl {
|
||||||
super(ownerId, 123, "Elemental Appeal", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{R}{R}{R}{R}");
|
super(ownerId, 123, "Elemental Appeal", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{R}{R}{R}{R}");
|
||||||
this.expansionSetCode = "ZEN";
|
this.expansionSetCode = "ZEN";
|
||||||
|
|
||||||
|
|
||||||
// Kicker {5}
|
// Kicker {5}
|
||||||
this.addAbility(new KickerAbility("{5}"));
|
this.addAbility(new KickerAbility("{5}"));
|
||||||
|
|
||||||
|
@ -100,17 +99,14 @@ class ElementalAppealEffect extends OneShotEffect {
|
||||||
ElementalToken token = new ElementalToken();
|
ElementalToken token = new ElementalToken();
|
||||||
token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId());
|
token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId());
|
||||||
|
|
||||||
FixedTarget fixedTarget = new FixedTarget(token.getLastAddedToken());
|
for (UUID tokenId : token.getLastAddedTokenIds()) {
|
||||||
source.getEffects().get(1).setTargetPointer(fixedTarget);
|
Permanent tokenPermanent = game.getPermanent(tokenId);
|
||||||
|
if (tokenPermanent != null) {
|
||||||
ExileTargetEffect exileEffect = new ExileTargetEffect();
|
ExileTargetEffect exileEffect = new ExileTargetEffect();
|
||||||
exileEffect.setTargetPointer(fixedTarget);
|
exileEffect.setTargetPointer(new FixedTarget(tokenPermanent, game));
|
||||||
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect);
|
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect), source);
|
||||||
delayedAbility.setSourceId(source.getSourceId());
|
}
|
||||||
delayedAbility.setControllerId(source.getControllerId());
|
}
|
||||||
delayedAbility.setSourceObject(source.getSourceObject(game), game);
|
|
||||||
game.addDelayedTriggeredAbility(delayedAbility);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,14 +28,8 @@
|
||||||
package mage.sets.zendikar;
|
package mage.sets.zendikar;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.constants.CardType;
|
|
||||||
import mage.constants.Outcome;
|
|
||||||
import mage.constants.Rarity;
|
|
||||||
import mage.constants.Zone;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.ObjectColor;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.DelayedTriggeredAbility;
|
|
||||||
import mage.abilities.common.LandfallAbility;
|
import mage.abilities.common.LandfallAbility;
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
|
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
|
||||||
|
@ -47,8 +41,13 @@ import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||||
import mage.abilities.keyword.HasteAbility;
|
import mage.abilities.keyword.HasteAbility;
|
||||||
import mage.abilities.keyword.TrampleAbility;
|
import mage.abilities.keyword.TrampleAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
|
import mage.constants.CardType;
|
||||||
|
import mage.constants.Outcome;
|
||||||
|
import mage.constants.Rarity;
|
||||||
|
import mage.constants.Zone;
|
||||||
import mage.counters.CounterType;
|
import mage.counters.CounterType;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
import mage.game.permanent.token.Token;
|
import mage.game.permanent.token.Token;
|
||||||
import mage.target.targetpointer.FixedTarget;
|
import mage.target.targetpointer.FixedTarget;
|
||||||
|
|
||||||
|
@ -62,7 +61,6 @@ public class ZektarShrineExpedition extends CardImpl {
|
||||||
super(ownerId, 155, "Zektar Shrine Expedition", Rarity.COMMON, new CardType[]{CardType.ENCHANTMENT}, "{1}{R}");
|
super(ownerId, 155, "Zektar Shrine Expedition", Rarity.COMMON, new CardType[]{CardType.ENCHANTMENT}, "{1}{R}");
|
||||||
this.expansionSetCode = "ZEN";
|
this.expansionSetCode = "ZEN";
|
||||||
|
|
||||||
|
|
||||||
// Landfall - Whenever a land enters the battlefield under your control, you may put a quest counter on Zektar Shrine Expedition.
|
// Landfall - Whenever a land enters the battlefield under your control, you may put a quest counter on Zektar Shrine Expedition.
|
||||||
this.addAbility(new LandfallAbility(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.QUEST.createInstance()), true));
|
this.addAbility(new LandfallAbility(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.QUEST.createInstance()), true));
|
||||||
// Remove three quest counters from Zektar Shrine Expedition and sacrifice it: Put a 7/1 red Elemental creature token with trample and haste onto the battlefield. Exile it at the beginning of the next end step.
|
// Remove three quest counters from Zektar Shrine Expedition and sacrifice it: Put a 7/1 red Elemental creature token with trample and haste onto the battlefield. Exile it at the beginning of the next end step.
|
||||||
|
@ -101,15 +99,14 @@ class ZektarShrineExpeditionEffect extends OneShotEffect {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
ElementalToken token = new ElementalToken();
|
ElementalToken token = new ElementalToken();
|
||||||
token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId());
|
token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId());
|
||||||
|
for (UUID tokenId : token.getLastAddedTokenIds()) {
|
||||||
|
Permanent tokenPermanent = game.getPermanent(tokenId);
|
||||||
|
if (tokenPermanent != null) {
|
||||||
ExileTargetEffect exileEffect = new ExileTargetEffect();
|
ExileTargetEffect exileEffect = new ExileTargetEffect();
|
||||||
exileEffect.setTargetPointer(new FixedTarget(token.getLastAddedToken()));
|
exileEffect.setTargetPointer(new FixedTarget(tokenPermanent, game));
|
||||||
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect);
|
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect), source);
|
||||||
delayedAbility.setSourceId(source.getSourceId());
|
}
|
||||||
delayedAbility.setControllerId(source.getControllerId());
|
}
|
||||||
delayedAbility.setSourceObject(source.getSourceObject(game), game);
|
|
||||||
game.addDelayedTriggeredAbility(delayedAbility);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,96 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
* permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The views and conclusions contained in the software and documentation are those of the
|
||||||
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
|
*/
|
||||||
|
package org.mage.test.cards.triggers;
|
||||||
|
|
||||||
|
import mage.constants.PhaseStep;
|
||||||
|
import mage.constants.Zone;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author LevelX2
|
||||||
|
*/
|
||||||
|
public class DayOfTheDragonsTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void TestTokensAreCreated() {
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion", 1);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Pillarfield Ox", 1);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Island", 7);
|
||||||
|
// When Day of the Dragons enters the battlefield, exile all creatures you control. Then put that many 5/5 red Dragon creature tokens with flying onto the battlefield.
|
||||||
|
// When Day of the Dragons leaves the battlefield, sacrifice all Dragons you control. Then return the exiled cards to the battlefield under your control.
|
||||||
|
addCard(Zone.HAND, playerA, "Day of the Dragons"); // Enchantment - {4}{U}{U}{U}
|
||||||
|
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion");
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, "Shivan Dragon");
|
||||||
|
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Day of the Dragons");
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
assertExileCount("Silvercoat Lion", 1);
|
||||||
|
assertExileCount("Pillarfield Ox", 1);
|
||||||
|
assertPermanentCount(playerA, "Dragon", 2);
|
||||||
|
|
||||||
|
assertPermanentCount(playerB, "Silvercoat Lion", 1);
|
||||||
|
assertPermanentCount(playerB, "Shivan Dragon", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void TestTokensAreCreatedAndExiled() {
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion", 1);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Pillarfield Ox", 1);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Island", 7);
|
||||||
|
// When Day of the Dragons enters the battlefield, exile all creatures you control. Then put that many 5/5 red Dragon creature tokens with flying onto the battlefield.
|
||||||
|
// When Day of the Dragons leaves the battlefield, sacrifice all Dragons you control. Then return the exiled cards to the battlefield under your control.
|
||||||
|
addCard(Zone.HAND, playerA, "Day of the Dragons"); // Enchantment - {4}{U}{U}{U}
|
||||||
|
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion");
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, "Shivan Dragon");
|
||||||
|
addCard(Zone.BATTLEFIELD, playerB, "Plains", 2);
|
||||||
|
addCard(Zone.HAND, playerB, "Disenchant");
|
||||||
|
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Day of the Dragons");
|
||||||
|
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Disenchant", "Day of the Dragons");
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.END_TURN);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
assertGraveyardCount(playerA, "Day of the Dragons", 1);
|
||||||
|
assertGraveyardCount(playerB, "Disenchant", 1);
|
||||||
|
|
||||||
|
assertPermanentCount(playerA, "Silvercoat Lion", 1);
|
||||||
|
assertPermanentCount(playerA, "Pillarfield Ox", 1);
|
||||||
|
assertPermanentCount(playerA, "Dragon", 0);
|
||||||
|
|
||||||
|
assertPermanentCount(playerB, "Silvercoat Lion", 1);
|
||||||
|
assertPermanentCount(playerB, "Shivan Dragon", 1);
|
||||||
|
}
|
||||||
|
}
|
|
@ -37,20 +37,16 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||||
*
|
*
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class GoldnightCommanderTest extends CardTestPlayerBase {
|
public class GoldnightCommanderTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Goldnight Commander {3}{W}
|
* Goldnight Commander {3}{W} Human Cleric Soldier
|
||||||
* Human Cleric Soldier
|
* Whenever another creature enters the battlefield under your control, creatures you control get
|
||||||
* Whenever another creature enters the battlefield under your control, creatures you control get +1/+1 until end of turn.
|
* +1/+1 until end of turn.
|
||||||
*
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testThreeCreaturesEnterAtTheSameTime() {
|
public void testThreeCreaturesEnterAtTheSameTime() {
|
||||||
// The ability of the Commander triggers three times and each trigger sees all three creatures
|
// The ability of the Commander triggers three times and each trigger sees all three creatures
|
||||||
|
|
||||||
addCard(Zone.HAND, playerA, "Thatcher Revolt");
|
addCard(Zone.HAND, playerA, "Thatcher Revolt");
|
||||||
addCard(Zone.BATTLEFIELD, playerA, "Goldnight Commander", 1);
|
addCard(Zone.BATTLEFIELD, playerA, "Goldnight Commander", 1);
|
||||||
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3);
|
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3);
|
||||||
|
|
|
@ -104,7 +104,7 @@ public class ReturnFromExileForSourceEffect extends OneShotEffect {
|
||||||
if (returnToZone.equals(Zone.BATTLEFIELD)) {
|
if (returnToZone.equals(Zone.BATTLEFIELD)) {
|
||||||
controller.moveCards(exile.getCards(game), returnToZone, source, game, false, false, true, null);
|
controller.moveCards(exile.getCards(game), returnToZone, source, game, false, false, true, null);
|
||||||
} else {
|
} else {
|
||||||
controller.moveCards(exile, null, returnToZone, source, game);
|
controller.moveCards(exile, returnToZone, source, game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -385,6 +385,8 @@ public interface Game extends MageItem, Serializable {
|
||||||
|
|
||||||
UUID addDelayedTriggeredAbility(DelayedTriggeredAbility delayedAbility);
|
UUID addDelayedTriggeredAbility(DelayedTriggeredAbility delayedAbility);
|
||||||
|
|
||||||
|
UUID addDelayedTriggeredAbility(DelayedTriggeredAbility delayedAbility, Ability source);
|
||||||
|
|
||||||
void applyEffects();
|
void applyEffects();
|
||||||
|
|
||||||
boolean checkStateAndTriggered();
|
boolean checkStateAndTriggered();
|
||||||
|
|
|
@ -1490,6 +1490,14 @@ public abstract class GameImpl implements Game, Serializable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UUID addDelayedTriggeredAbility(DelayedTriggeredAbility delayedAbility, Ability source) {
|
||||||
|
delayedAbility.setSourceId(source.getSourceId());
|
||||||
|
delayedAbility.setControllerId(source.getControllerId());
|
||||||
|
delayedAbility.setSourceObject(source.getSourceObject(this), this);
|
||||||
|
return addDelayedTriggeredAbility(delayedAbility);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UUID addDelayedTriggeredAbility(DelayedTriggeredAbility delayedAbility) {
|
public UUID addDelayedTriggeredAbility(DelayedTriggeredAbility delayedAbility) {
|
||||||
DelayedTriggeredAbility newAbility = delayedAbility.copy();
|
DelayedTriggeredAbility newAbility = delayedAbility.copy();
|
||||||
|
|
Loading…
Add table
Reference in a new issue