* Some more changes for tework ENTERS_THE_BATTLEFIELD event for replacement effects.

This commit is contained in:
LevelX2 2015-10-18 11:11:48 +02:00
parent d145885d2d
commit 4216fbab8c
42 changed files with 119 additions and 91 deletions

View file

@ -38,6 +38,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.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -82,7 +83,7 @@ public class OrbOfDreams extends CardImpl {
@Override @Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent permanent = game.getPermanentEntering(event.getTargetId()); Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget();
if (permanent != null) { if (permanent != null) {
permanent.setTapped(true); permanent.setTapped(true);
} }

View file

@ -44,6 +44,7 @@ import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.game.ExileZone; import mage.game.ExileZone;
import mage.game.Game; import mage.game.Game;
import mage.game.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType; import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -185,7 +186,7 @@ class OtherworldlyJourneyEntersBattlefieldEffect extends ReplacementEffectImpl {
@Override @Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent permanent = game.getPermanentEntering(event.getTargetId()); Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget();
if (permanent != null) { if (permanent != null) {
permanent.addCounters(CounterType.P1P1.createInstance(), game); permanent.addCounters(CounterType.P1P1.createInstance(), game);
discard(); // use only once discard(); // use only once

View file

@ -41,6 +41,7 @@ import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.filter.common.FilterControlledPermanent; import mage.filter.common.FilterControlledPermanent;
import mage.game.Game; import mage.game.Game;
import mage.game.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
@ -105,7 +106,7 @@ class ShimatsuTheBloodcloakedEffect extends ReplacementEffectImpl {
@Override @Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent creature = game.getPermanentEntering(event.getTargetId()); Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (creature != null && controller != null) { if (creature != null && controller != null) {
Target target = new TargetControlledPermanent(0, Integer.MAX_VALUE, new FilterControlledPermanent(), true); Target target = new TargetControlledPermanent(0, Integer.MAX_VALUE, new FilterControlledPermanent(), true);

View file

@ -46,6 +46,7 @@ import mage.constants.Rarity;
import mage.constants.Zone; import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.game.Game; import mage.game.Game;
import mage.game.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
@ -193,7 +194,7 @@ class ChorusOfTheConclaveReplacementEffect2 extends ReplacementEffectImpl {
@Override @Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent creature = game.getPermanentEntering(event.getSourceId()); Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
Map<String, Integer> spellX = (Map<String, Integer>) game.getState().getValue("spellX" + source.getSourceId()); Map<String, Integer> spellX = (Map<String, Integer>) game.getState().getValue("spellX" + source.getSourceId());
MageObject sourceObject = source.getSourceObject(game); MageObject sourceObject = source.getSourceObject(game);
if (sourceObject != null && creature != null && spellX != null) { if (sourceObject != null && creature != null && spellX != null) {

View file

@ -47,6 +47,7 @@ import mage.constants.WatcherScope;
import mage.constants.Zone; import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.game.Game; import mage.game.Game;
import mage.game.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType; import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -163,7 +164,7 @@ class OpalPalaceEntersBattlefieldEffect extends ReplacementEffectImpl {
@Override @Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent permanent = game.getPermanentEntering(event.getTargetId()); Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget();
if (permanent != null) { if (permanent != null) {
Integer castCount = (Integer) game.getState().getValue(permanent.getId() + "_castCount"); Integer castCount = (Integer) game.getState().getValue(permanent.getId() + "_castCount");
if (castCount != null && castCount > 0) { if (castCount != null && castCount > 0) {

View file

@ -56,7 +56,6 @@ public class ScrapMastery extends CardImpl {
super(ownerId, 38, "Scrap Mastery", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{3}{R}{R}"); super(ownerId, 38, "Scrap Mastery", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{3}{R}{R}");
this.expansionSetCode = "C14"; this.expansionSetCode = "C14";
// Each player exiles all artifact cards from his or her graveyard, then sacrifices all artifacts he or she controls, then puts all cards he or she exiled this way onto the battlefield. // Each player exiles all artifact cards from his or her graveyard, then sacrifices all artifacts he or she controls, then puts all cards he or she exiled this way onto the battlefield.
this.getSpellAbility().addEffect(new ScrapMasteryEffect()); this.getSpellAbility().addEffect(new ScrapMasteryEffect());
} }
@ -93,11 +92,11 @@ class ScrapMasteryEffect extends OneShotEffect {
if (controller != null) { if (controller != null) {
Map<UUID, Set<UUID>> exiledCards = new HashMap<>(); Map<UUID, Set<UUID>> exiledCards = new HashMap<>();
// exile artifacts from graveyard // exile artifacts from graveyard
for (UUID playerId: controller.getInRange()) { for (UUID playerId : controller.getInRange()) {
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);
if (player != null) { if (player != null) {
Set<UUID> cards = new HashSet<>(); Set<UUID> cards = new HashSet<>();
for (Card card: player.getGraveyard().getCards(new FilterArtifactCard(), game)) { for (Card card : player.getGraveyard().getCards(new FilterArtifactCard(), game)) {
cards.add(card.getId()); cards.add(card.getId());
player.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.GRAVEYARD, true); player.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.GRAVEYARD, true);
} }
@ -105,22 +104,22 @@ class ScrapMasteryEffect extends OneShotEffect {
} }
} }
// sacrifice all artifacts // sacrifice all artifacts
for (UUID playerId: controller.getInRange()) { for (UUID playerId : controller.getInRange()) {
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);
if (player != null) { if (player != null) {
for (Permanent permanent: game.getBattlefield().getAllActivePermanents(new FilterArtifactPermanent(), playerId, game)) { for (Permanent permanent : game.getBattlefield().getAllActivePermanents(new FilterArtifactPermanent(), playerId, game)) {
permanent.sacrifice(source.getSourceId(), game); permanent.sacrifice(source.getSourceId(), game);
} }
} }
} }
// puts all cards he or she exiled this way onto the battlefield // puts all cards he or she exiled this way onto the battlefield
for (UUID playerId: controller.getInRange()) { for (UUID playerId : controller.getInRange()) {
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);
if (player != null) { if (player != null) {
for (UUID cardId: exiledCards.get(playerId)) { for (UUID cardId : exiledCards.get(playerId)) {
Card card = game.getCard(cardId); Card card = game.getCard(cardId);
if (card != null) { if (card != null) {
player.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, cardId); controller.moveCards(card, Zone.EXILED, source, game);
} }
} }
} }

View file

@ -38,6 +38,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.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType; import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -79,7 +80,7 @@ class KismetEffect extends ReplacementEffectImpl {
@Override @Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent target = game.getPermanentEntering(event.getTargetId()); Permanent target = ((EntersTheBattlefieldEvent) event).getTarget();
if (target != null) { if (target != null) {
target.setTapped(true); target.setTapped(true);
} }
@ -94,7 +95,7 @@ class KismetEffect extends ReplacementEffectImpl {
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) { if (game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
Permanent permanent = game.getPermanent(event.getTargetId()); Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget();
if (permanent != null && (permanent.getCardType().contains(CardType.ARTIFACT) if (permanent != null && (permanent.getCardType().contains(CardType.ARTIFACT)
|| permanent.getCardType().contains(CardType.CREATURE) || permanent.getCardType().contains(CardType.CREATURE)
|| permanent.getCardType().contains(CardType.LAND))) { || permanent.getCardType().contains(CardType.LAND))) {

View file

@ -45,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.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType; import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -101,7 +102,7 @@ class PrimalPlasmaReplacementEffect extends ReplacementEffectImpl {
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getTargetId().equals(source.getSourceId())) { if (event.getTargetId().equals(source.getSourceId())) {
Permanent sourcePermanent = game.getPermanentEntering(event.getTargetId()); Permanent sourcePermanent = ((EntersTheBattlefieldEvent) event).getTarget();
if (sourcePermanent != null && !sourcePermanent.isFaceDown(game)) { if (sourcePermanent != null && !sourcePermanent.isFaceDown(game)) {
return true; return true;
} }
@ -116,7 +117,7 @@ class PrimalPlasmaReplacementEffect extends ReplacementEffectImpl {
@Override @Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent permanent = game.getPermanentEntering(event.getTargetId()); Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget();
if (permanent != null) { if (permanent != null) {
Choice choice = new ChoiceImpl(true); Choice choice = new ChoiceImpl(true);
choice.setMessage("Choose what " + permanent.getIdName() + " becomes to"); choice.setMessage("Choose what " + permanent.getIdName() + " becomes to");

View file

@ -39,6 +39,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.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -83,7 +84,7 @@ class BlindObedienceTapEffect extends ReplacementEffectImpl {
@Override @Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent target = game.getPermanentEntering(event.getTargetId()); Permanent target = ((EntersTheBattlefieldEvent) event).getTarget();
if (target != null) { if (target != null) {
target.setTapped(true); target.setTapped(true);
} }
@ -98,7 +99,7 @@ class BlindObedienceTapEffect extends ReplacementEffectImpl {
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) { if (game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
Permanent permanent = game.getPermanentEntering(event.getTargetId()); Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget();
if (permanent != null && (permanent.getCardType().contains(CardType.CREATURE) || permanent.getCardType().contains(CardType.ARTIFACT))) { if (permanent != null && (permanent.getCardType().contains(CardType.CREATURE) || permanent.getCardType().contains(CardType.ARTIFACT))) {
return true; return true;
} }

View file

@ -111,7 +111,7 @@ class MasterBiomancerEntersBattlefieldEffect extends ReplacementEffectImpl {
creature.addCounters(CounterType.P1P1.createInstance(power), game); creature.addCounters(CounterType.P1P1.createInstance(power), game);
} }
ContinuousEffect effect = new AddCardSubTypeTargetEffect("Mutant", Duration.Custom); ContinuousEffect effect = new AddCardSubTypeTargetEffect("Mutant", Duration.Custom);
effect.setTargetPointer(new FixedTarget(creature.getId())); effect.setTargetPointer(new FixedTarget(creature.getId(), creature.getZoneChangeCounter(game) + 1));
game.addEffect(effect, source); game.addEffect(effect, source);
} }
return false; return false;

View file

@ -43,6 +43,7 @@ import mage.constants.Rarity;
import mage.constants.Zone; import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.game.Game; import mage.game.Game;
import mage.game.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetControlledCreaturePermanent;
@ -99,7 +100,7 @@ class ZameckGuildmageEntersBattlefieldEffect extends ReplacementEffectImpl {
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
Permanent permanent = game.getPermanentEntering(event.getTargetId()); Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget();
return permanent != null && permanent.getControllerId().equals(source.getControllerId()) && permanent.getCardType().contains(CardType.CREATURE); return permanent != null && permanent.getControllerId().equals(source.getControllerId()) && permanent.getCardType().contains(CardType.CREATURE);
} }
@ -110,7 +111,7 @@ class ZameckGuildmageEntersBattlefieldEffect extends ReplacementEffectImpl {
@Override @Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent target = game.getPermanentEntering(event.getTargetId()); Permanent target = ((EntersTheBattlefieldEvent) event).getTarget();
if (target != null) { if (target != null) {
target.addCounters(CounterType.P1P1.createInstance(), game); target.addCounters(CounterType.P1P1.createInstance(), game);
} }

View file

@ -41,6 +41,7 @@ import mage.constants.Rarity;
import mage.constants.Zone; import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.game.Game; import mage.game.Game;
import mage.game.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType; import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -92,7 +93,7 @@ class DearlyDepartedEntersBattlefieldEffect extends ReplacementEffectImpl {
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
Permanent permanent = game.getPermanentEntering(event.getTargetId()); Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget();
if (permanent != null && permanent.getControllerId().equals(source.getControllerId()) && permanent.hasSubtype("Human")) { if (permanent != null && permanent.getControllerId().equals(source.getControllerId()) && permanent.hasSubtype("Human")) {
return true; return true;
} }
@ -101,7 +102,7 @@ class DearlyDepartedEntersBattlefieldEffect extends ReplacementEffectImpl {
@Override @Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent target = game.getPermanentEntering(event.getTargetId()); Permanent target = ((EntersTheBattlefieldEvent) event).getTarget();
if (target != null) { if (target != null) {
target.addCounters(CounterType.P1P1.createInstance(), game); target.addCounters(CounterType.P1P1.createInstance(), game);
} }

View file

@ -40,6 +40,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.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType; import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -90,13 +91,13 @@ class EssenceOfTheWildEffect extends ReplacementEffectImpl {
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
Permanent perm = game.getPermanentEntering(event.getTargetId()); Permanent perm = ((EntersTheBattlefieldEvent) event).getTarget();
return perm != null && perm.getCardType().contains(CardType.CREATURE) && perm.getControllerId().equals(source.getControllerId()); return perm != null && perm.getCardType().contains(CardType.CREATURE) && perm.getControllerId().equals(source.getControllerId());
} }
@Override @Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent sourceObject = game.getPermanent(source.getSourceId()); Permanent sourceObject = ((EntersTheBattlefieldEvent) event).getTarget();
if (sourceObject != null) { if (sourceObject != null) {
game.addEffect(new CopyEffect(Duration.Custom, sourceObject, event.getTargetId()), source); game.addEffect(new CopyEffect(Duration.Custom, sourceObject, event.getTargetId()), source);
} }

View file

@ -152,7 +152,7 @@ class WorldgorgerDragonLeavesEffect extends OneShotEffect {
for (UUID cardId : exile) { for (UUID cardId : exile) {
Card card = game.getCard(cardId); Card card = game.getCard(cardId);
if (card != null) { if (card != null) {
controller.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId()); controller.moveCards(card, Zone.EXILED, source, game);
} }
} }
return true; return true;

View file

@ -39,6 +39,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.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -84,7 +85,7 @@ class ImposingSovereignEffect extends ReplacementEffectImpl {
@Override @Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent target = game.getPermanentEntering(event.getTargetId()); Permanent target = ((EntersTheBattlefieldEvent) event).getTarget();
if (target != null) { if (target != null) {
target.tap(game); target.tap(game);
} }
@ -99,7 +100,7 @@ class ImposingSovereignEffect extends ReplacementEffectImpl {
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) { if (game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
Permanent permanent = game.getPermanentEntering(event.getTargetId()); Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget();
if (permanent != null && permanent.getCardType().contains(CardType.CREATURE)) { if (permanent != null && permanent.getCardType().contains(CardType.CREATURE)) {
return true; return true;
} }

View file

@ -50,6 +50,7 @@ import mage.constants.WatcherScope;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.game.Game; import mage.game.Game;
import mage.game.command.Commander; import mage.game.command.Commander;
import mage.game.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType; import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -314,7 +315,7 @@ class SavageSummoningEntersBattlefieldEffect extends ReplacementEffectImpl {
@Override @Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent creature = game.getPermanentEntering(event.getTargetId()); Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
if (creature != null) { if (creature != null) {
creature.addCounters(CounterType.P1P1.createInstance(), game); creature.addCounters(CounterType.P1P1.createInstance(), game);
} }

View file

@ -43,6 +43,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.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -108,7 +109,7 @@ class HushwingGryffEffect extends ContinuousRuleModifyingEffectImpl {
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
Ability ability = (Ability) getValue("targetAbility"); Ability ability = (Ability) getValue("targetAbility");
if (ability != null && AbilityType.TRIGGERED.equals(ability.getAbilityType())) { if (ability != null && AbilityType.TRIGGERED.equals(ability.getAbilityType())) {
Permanent permanent = game.getPermanentEntering(event.getTargetId()); Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget();
if (permanent != null && permanent.getCardType().contains(CardType.CREATURE)) { if (permanent != null && permanent.getCardType().contains(CardType.CREATURE)) {
return true; return true;
} }

View file

@ -44,6 +44,7 @@ import mage.counters.CounterType;
import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.permanent.CounterPredicate; import mage.filter.predicate.permanent.CounterPredicate;
import mage.game.Game; import mage.game.Game;
import mage.game.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -108,7 +109,7 @@ class BramblewoodParagonReplacementEffect extends ReplacementEffectImpl {
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
Permanent creature = game.getPermanentEntering(event.getTargetId()); Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
return creature != null && creature.getControllerId().equals(source.getControllerId()) return creature != null && creature.getControllerId().equals(source.getControllerId())
&& creature.getCardType().contains(CardType.CREATURE) && creature.getCardType().contains(CardType.CREATURE)
&& creature.hasSubtype("Warrior") && creature.hasSubtype("Warrior")
@ -117,7 +118,7 @@ class BramblewoodParagonReplacementEffect extends ReplacementEffectImpl {
@Override @Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent creature = game.getPermanentEntering(event.getTargetId()); Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
if (creature != null) { if (creature != null) {
creature.addCounters(CounterType.P1P1.createInstance(), game); creature.addCounters(CounterType.P1P1.createInstance(), game);
} }

View file

@ -45,6 +45,7 @@ import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.game.Game; import mage.game.Game;
import mage.game.events.DamagedPlayerEvent; import mage.game.events.DamagedPlayerEvent;
import mage.game.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType; import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -102,7 +103,7 @@ class OonasBlackguardReplacementEffect extends ReplacementEffectImpl {
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
Permanent creature = game.getPermanentEntering(event.getTargetId()); Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
if (creature != null && creature.getControllerId().equals(source.getControllerId()) if (creature != null && creature.getControllerId().equals(source.getControllerId())
&& creature.getCardType().contains(CardType.CREATURE) && creature.getCardType().contains(CardType.CREATURE)
&& creature.hasSubtype("Rogue") && creature.hasSubtype("Rogue")
@ -119,7 +120,7 @@ class OonasBlackguardReplacementEffect extends ReplacementEffectImpl {
@Override @Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent creature = game.getPermanentEntering(event.getTargetId()); Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
if (creature != null) { if (creature != null) {
creature.addCounters(CounterType.P1P1.createInstance(), game); creature.addCounters(CounterType.P1P1.createInstance(), game);
} }

View file

@ -44,6 +44,7 @@ import mage.constants.Rarity;
import mage.constants.Zone; import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.game.Game; import mage.game.Game;
import mage.game.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetControlledCreaturePermanent;
@ -99,7 +100,7 @@ class SageOfFablesReplacementEffect extends ReplacementEffectImpl {
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
Permanent creature = game.getPermanentEntering(event.getTargetId()); Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
return creature != null && creature.getControllerId().equals(source.getControllerId()) return creature != null && creature.getControllerId().equals(source.getControllerId())
&& creature.getCardType().contains(CardType.CREATURE) && creature.getCardType().contains(CardType.CREATURE)
&& creature.getSubtype().contains("Wizard") && creature.getSubtype().contains("Wizard")
@ -113,7 +114,7 @@ class SageOfFablesReplacementEffect extends ReplacementEffectImpl {
@Override @Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent creature = game.getPermanentEntering(event.getTargetId()); Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
if (creature != null) { if (creature != null) {
creature.addCounters(CounterType.P1P1.createInstance(), game); creature.addCounters(CounterType.P1P1.createInstance(), game);
} }

View file

@ -37,6 +37,7 @@ 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.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -84,7 +85,7 @@ class DueRespectEffect extends ReplacementEffectImpl {
@Override @Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent permanent = game.getPermanentEntering(event.getTargetId()); Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget();
if (permanent != null) { if (permanent != null) {
permanent.setTapped(true); permanent.setTapped(true);
} }

View file

@ -42,6 +42,7 @@ import mage.constants.Rarity;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.common.FilterControlledCreaturePermanent;
import mage.game.Game; import mage.game.Game;
import mage.game.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType; import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -88,7 +89,7 @@ class UrabraskTheHiddenEffect extends ReplacementEffectImpl {
@Override @Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent target = game.getPermanentEntering(event.getTargetId()); Permanent target = ((EntersTheBattlefieldEvent) event).getTarget();
if (target != null) { if (target != null) {
target.setTapped(true); target.setTapped(true);
} }
@ -103,7 +104,7 @@ class UrabraskTheHiddenEffect extends ReplacementEffectImpl {
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) { if (game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
Permanent permanent = game.getPermanentEntering(event.getTargetId()); Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget();
if (permanent != null && permanent.getCardType().contains(CardType.CREATURE)) { if (permanent != null && permanent.getCardType().contains(CardType.CREATURE)) {
return true; return true;
} }

View file

@ -38,6 +38,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.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType; import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -79,7 +80,7 @@ class FrozenAEtherTapEffect extends ReplacementEffectImpl {
@Override @Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent target = game.getPermanentEntering(event.getTargetId()); Permanent target = ((EntersTheBattlefieldEvent) event).getTarget();
if (target != null) { if (target != null) {
target.setTapped(true); target.setTapped(true);
} }
@ -94,7 +95,7 @@ class FrozenAEtherTapEffect extends ReplacementEffectImpl {
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) { if (game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
Permanent permanent = game.getPermanentEntering(event.getTargetId()); Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget();
if (permanent != null if (permanent != null
&& (permanent.getCardType().contains(CardType.CREATURE) && (permanent.getCardType().contains(CardType.CREATURE)
|| permanent.getCardType().contains(CardType.LAND) || permanent.getCardType().contains(CardType.LAND)

View file

@ -45,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.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType; import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -102,7 +103,7 @@ class PrimalPlasmaReplacementEffect extends ReplacementEffectImpl {
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getTargetId().equals(source.getSourceId())) { if (event.getTargetId().equals(source.getSourceId())) {
Permanent sourcePermanent = game.getPermanentEntering(source.getSourceId()); Permanent sourcePermanent = ((EntersTheBattlefieldEvent) event).getTarget();
if (sourcePermanent != null && !sourcePermanent.isFaceDown(game)) { if (sourcePermanent != null && !sourcePermanent.isFaceDown(game)) {
return true; return true;
} }
@ -117,7 +118,7 @@ class PrimalPlasmaReplacementEffect extends ReplacementEffectImpl {
@Override @Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent permanent = game.getPermanentEntering(source.getSourceId()); Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget();
if (permanent != null) { if (permanent != null) {
Choice choice = new ChoiceImpl(true); Choice choice = new ChoiceImpl(true);
choice.setMessage("Choose what " + permanent.getIdName() + " becomes to"); choice.setMessage("Choose what " + permanent.getIdName() + " becomes to");

View file

@ -39,6 +39,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.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType; import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -86,7 +87,7 @@ class LoxodonGatekeeperTapEffect extends ReplacementEffectImpl {
@Override @Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent target = game.getPermanentEntering(event.getTargetId()); Permanent target = ((EntersTheBattlefieldEvent) event).getTarget();
if (target != null) { if (target != null) {
target.setTapped(true); target.setTapped(true);
} }
@ -101,7 +102,7 @@ class LoxodonGatekeeperTapEffect extends ReplacementEffectImpl {
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) { if (game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
Permanent permanent = game.getPermanentEntering(event.getTargetId()); Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget();
if (permanent != null if (permanent != null
&& (permanent.getCardType().contains(CardType.CREATURE) && (permanent.getCardType().contains(CardType.CREATURE)
|| permanent.getCardType().contains(CardType.LAND) || permanent.getCardType().contains(CardType.LAND)

View file

@ -118,18 +118,18 @@ class SistersOfStoneDeathEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
CardsImpl cardsInExile = new CardsImpl(); CardsImpl cardsInExile = new CardsImpl();
TargetCard target = new TargetCard(Zone.PICK, new FilterCard()); TargetCard target = new TargetCard(Zone.PICK, new FilterCard());
Player you = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (you != null) { if (controller != null) {
ExileZone exile = game.getExile().getExileZone(exileId); ExileZone exile = game.getExile().getExileZone(exileId);
if (exile != null) { if (exile != null) {
LinkedList<UUID> cards = new LinkedList<UUID>(exile); LinkedList<UUID> cards = new LinkedList<>(exile);
for (UUID cardId : cards) { for (UUID cardId : cards) {
Card card = game.getCard(cardId); Card card = game.getCard(cardId);
cardsInExile.add(card); cardsInExile.add(card);
} }
if (you.choose(Outcome.PutCreatureInPlay, cardsInExile, target, game)) { if (controller.choose(Outcome.PutCreatureInPlay, cardsInExile, target, game)) {
Card chosenCard = game.getCard(target.getFirstTarget()); Card chosenCard = game.getCard(target.getFirstTarget());
return you.putOntoBattlefieldWithInfo(chosenCard, game, Zone.EXILED, source.getSourceId()); return controller.moveCards(chosenCard, Zone.EXILED, source, game);
} }
} }
} }

View file

@ -40,6 +40,7 @@ import mage.constants.Rarity;
import mage.constants.Zone; import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.game.Game; import mage.game.Game;
import mage.game.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -95,7 +96,7 @@ class CorpsejackMenaceReplacementEffect extends ReplacementEffectImpl {
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent permanent = game.getPermanent(event.getTargetId()); Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent == null) { if (permanent == null) {
permanent = game.getPermanentEntering(event.getTargetId()); permanent = ((EntersTheBattlefieldEvent) event).getTarget();
} }
if (permanent != null) { if (permanent != null) {
permanent.addCounters(CounterType.P1P1.createInstance(event.getAmount() * 2), game, event.getAppliedEffects()); permanent.addCounters(CounterType.P1P1.createInstance(event.getAmount() * 2), game, event.getAppliedEffects());
@ -111,7 +112,7 @@ class CorpsejackMenaceReplacementEffect extends ReplacementEffectImpl {
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getData().equals(CounterType.P1P1.getName())) { if (event.getData().equals(CounterType.P1P1.getName())) {
Permanent permanent = game.getPermanent(event.getTargetId()); Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget();
if (permanent == null) { if (permanent == null) {
permanent = game.getPermanentEntering(event.getTargetId()); permanent = game.getPermanentEntering(event.getTargetId());
} }

View file

@ -25,7 +25,6 @@
* authors and should not be interpreted as representing official policies, either expressed * authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
*/ */
package mage.sets.scarsofmirrodin; package mage.sets.scarsofmirrodin;
import java.util.HashMap; import java.util.HashMap;
@ -76,7 +75,8 @@ public class TunnelIgnus extends CardImpl {
} }
class TunnelIgnusWatcher extends Watcher { class TunnelIgnusWatcher extends Watcher {
protected Map<UUID, Integer> counts = new HashMap<UUID, Integer>();
protected Map<UUID, Integer> counts = new HashMap<>();
public TunnelIgnusWatcher() { public TunnelIgnusWatcher() {
super("LandPlayedCount", WatcherScope.PLAYER); super("LandPlayedCount", WatcherScope.PLAYER);
@ -84,7 +84,7 @@ class TunnelIgnusWatcher extends Watcher {
public TunnelIgnusWatcher(final TunnelIgnusWatcher watcher) { public TunnelIgnusWatcher(final TunnelIgnusWatcher watcher) {
super(watcher); super(watcher);
for (Entry<UUID, Integer> entry: watcher.counts.entrySet()) { for (Entry<UUID, Integer> entry : watcher.counts.entrySet()) {
counts.put(entry.getKey(), entry.getValue()); counts.put(entry.getKey(), entry.getValue());
} }
} }
@ -116,6 +116,7 @@ class TunnelIgnusWatcher extends Watcher {
} }
class TunnelIgnusTriggeredAbility extends TriggeredAbilityImpl { class TunnelIgnusTriggeredAbility extends TriggeredAbilityImpl {
TunnelIgnusTriggeredAbility() { TunnelIgnusTriggeredAbility() {
super(Zone.BATTLEFIELD, new DamageTargetEffect(3)); super(Zone.BATTLEFIELD, new DamageTargetEffect(3));
} }
@ -153,4 +154,4 @@ class TunnelIgnusTriggeredAbility extends TriggeredAbilityImpl {
public String getRule() { public String getRule() {
return "Whenever a land enters the battlefield under an opponent's control, if that player had another land enter the battlefield under his or her control this turn, {this} deals 3 damage to that player."; return "Whenever a land enters the battlefield under an opponent's control, if that player had another land enter the battlefield under his or her control this turn, {this} deals 3 damage to that player.";
} }
} }

View file

@ -90,9 +90,6 @@ class FlourishingDefensesTriggeredAbility extends TriggeredAbilityImpl {
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
if (event.getData().equals(CounterType.M1M1.getName())) { if (event.getData().equals(CounterType.M1M1.getName())) {
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getTargetId()); Permanent permanent = game.getPermanentOrLKIBattlefield(event.getTargetId());
if (permanent == null) {
permanent = game.getPermanentEntering(event.getTargetId());
}
if (permanent != null && permanent.getCardType().contains(CardType.CREATURE)) { if (permanent != null && permanent.getCardType().contains(CardType.CREATURE)) {
return true; return true;
} }

View file

@ -44,6 +44,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.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType; import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -112,7 +113,7 @@ class AquamorphEntityReplacementEffect extends ReplacementEffectImpl {
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == EventType.ENTERS_THE_BATTLEFIELD) { if (event.getType() == EventType.ENTERS_THE_BATTLEFIELD) {
if (event.getTargetId().equals(source.getSourceId())) { if (event.getTargetId().equals(source.getSourceId())) {
Permanent sourcePermanent = game.getPermanentEntering(source.getSourceId()); Permanent sourcePermanent = ((EntersTheBattlefieldEvent) event).getTarget();;
if (sourcePermanent != null && !sourcePermanent.isFaceDown(game)) { if (sourcePermanent != null && !sourcePermanent.isFaceDown(game)) {
return true; return true;
} }
@ -133,7 +134,7 @@ class AquamorphEntityReplacementEffect extends ReplacementEffectImpl {
@Override @Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent permanent = game.getPermanentEntering(source.getSourceId()); Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget();
if (permanent != null) { if (permanent != null) {
Choice choice = new ChoiceImpl(true); Choice choice = new ChoiceImpl(true);
choice.setMessage("Choose what the creature becomes to"); choice.setMessage("Choose what the creature becomes to");

View file

@ -48,6 +48,7 @@ import mage.constants.Zone;
import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.permanent.AnotherPredicate; import mage.filter.predicate.permanent.AnotherPredicate;
import mage.game.Game; import mage.game.Game;
import mage.game.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
@ -122,7 +123,7 @@ class DracoplasmEffect extends ReplacementEffectImpl {
@Override @Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent creature = game.getPermanentEntering(event.getTargetId()); Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (creature != null && controller != null) { if (creature != null && controller != null) {
Target target = new TargetControlledPermanent(0, Integer.MAX_VALUE, filter, true); Target target = new TargetControlledPermanent(0, Integer.MAX_VALUE, filter, true);

View file

@ -43,6 +43,7 @@ import mage.game.ExileZone;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
/** /**
* *
* @author Plopman * @author Plopman
@ -53,7 +54,6 @@ public class LivingDeath extends CardImpl {
super(ownerId, 36, "Living Death", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{3}{B}{B}"); super(ownerId, 36, "Living Death", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{3}{B}{B}");
this.expansionSetCode = "TMP"; this.expansionSetCode = "TMP";
// Each player exiles all creature cards from his or her graveyard, then sacrifices all creatures he or she controls, then puts all cards he or she exiled this way onto the battlefield. // Each player exiles all creature cards from his or her graveyard, then sacrifices all creatures he or she controls, then puts all cards he or she exiled this way onto the battlefield.
this.getSpellAbility().addEffect(new LivingDeathEffect()); this.getSpellAbility().addEffect(new LivingDeathEffect());
} }
@ -67,6 +67,7 @@ public class LivingDeath extends CardImpl {
return new LivingDeath(this); return new LivingDeath(this);
} }
} }
class LivingDeathEffect extends OneShotEffect { class LivingDeathEffect extends OneShotEffect {
public LivingDeathEffect() { public LivingDeathEffect() {
@ -89,16 +90,16 @@ class LivingDeathEffect extends OneShotEffect {
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null) { if (controller != null && sourceObject != null) {
// move creature cards from graveyard to exile // move creature cards from graveyard to exile
for (UUID playerId: controller.getInRange()){ for (UUID playerId : controller.getInRange()) {
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);
if (player != null) { if (player != null) {
for (Card card :player.getGraveyard().getCards(new FilterCreatureCard(), game)) { for (Card card : player.getGraveyard().getCards(new FilterCreatureCard(), game)) {
controller.moveCardToExileWithInfo(card, source.getSourceId(), sourceObject.getIdName(), source.getSourceId(), game, Zone.GRAVEYARD, true); controller.moveCardToExileWithInfo(card, source.getSourceId(), sourceObject.getIdName(), source.getSourceId(), game, Zone.GRAVEYARD, true);
} }
} }
} }
// sacrifice all creatures // sacrifice all creatures
for (Permanent permanent :game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), game)) { for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), game)) {
permanent.sacrifice(source.getSourceId(), game); permanent.sacrifice(source.getSourceId(), game);
} }
// put exiled cards to battlefield // put exiled cards to battlefield
@ -107,6 +108,7 @@ class LivingDeathEffect extends OneShotEffect {
for (Card card : exileZone.getCards(game)) { for (Card card : exileZone.getCards(game)) {
Player player = game.getPlayer(card.getOwnerId()); Player player = game.getPlayer(card.getOwnerId());
if (player != null) { if (player != null) {
player.moveCards(card, Zone.EXILED, source, game);
player.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId()); player.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId());
} }
} }

View file

@ -38,6 +38,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.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType; import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -79,7 +80,7 @@ class RootMazeEffect extends ReplacementEffectImpl {
@Override @Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent target = game.getPermanentEntering(event.getTargetId()); Permanent target = ((EntersTheBattlefieldEvent) event).getTarget();
if (target != null) { if (target != null) {
target.setTapped(true); target.setTapped(true);
} }
@ -93,7 +94,7 @@ class RootMazeEffect extends ReplacementEffectImpl {
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
Permanent permanent = game.getPermanentEntering(event.getTargetId()); Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget();
return permanent != null && (permanent.getCardType().contains(CardType.LAND) || permanent.getCardType().contains(CardType.ARTIFACT)); return permanent != null && (permanent.getCardType().contains(CardType.LAND) || permanent.getCardType().contains(CardType.ARTIFACT));
} }

View file

@ -173,7 +173,7 @@ class PyxisOfPandemoniumPutOntoBattlefieldEffect extends OneShotEffect {
for (Card card : exileZone.getCards(game)) { for (Card card : exileZone.getCards(game)) {
card.setFaceDown(false, game); card.setFaceDown(false, game);
if (CardUtil.isPermanentCard(card)) { if (CardUtil.isPermanentCard(card)) {
player.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId()); player.moveCards(card, Zone.EXILED, source, game);
} }
} }
} }

View file

@ -198,7 +198,7 @@ class XenagosExileEffect extends OneShotEffect {
for (UUID targetId : target1.getTargets()) { for (UUID targetId : target1.getTargets()) {
Card card = cards.get(targetId, game); Card card = cards.get(targetId, game);
if (card != null) { if (card != null) {
player.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId()); player.moveCards(card, Zone.EXILED, source, game);
} }
} }
} }

View file

@ -63,7 +63,7 @@ public class LivingEnd extends CardImpl {
// Each player exiles all creature cards from his or her graveyard, then sacrifices all creatures // Each player exiles all creature cards from his or her graveyard, then sacrifices all creatures
// he or she controls, then puts all cards he or she exiled this way onto the battlefield. // he or she controls, then puts all cards he or she exiled this way onto the battlefield.
this.getSpellAbility().addEffect(new LivingEndEffect()); this.getSpellAbility().addEffect(new LivingEndEffect());
} }
public LivingEnd(final LivingEnd card) { public LivingEnd(final LivingEnd card) {
@ -98,16 +98,16 @@ class LivingEndEffect extends OneShotEffect {
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null) { if (controller != null && sourceObject != null) {
// move creature cards from graveyard to exile // move creature cards from graveyard to exile
for (UUID playerId: controller.getInRange()){ for (UUID playerId : controller.getInRange()) {
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);
if (player != null) { if (player != null) {
for (Card card :player.getGraveyard().getCards(new FilterCreatureCard(), game)) { for (Card card : player.getGraveyard().getCards(new FilterCreatureCard(), game)) {
controller.moveCardToExileWithInfo(card, source.getSourceId(), sourceObject.getIdName(), source.getSourceId(), game, Zone.GRAVEYARD, true); controller.moveCardToExileWithInfo(card, source.getSourceId(), sourceObject.getIdName(), source.getSourceId(), game, Zone.GRAVEYARD, true);
} }
} }
} }
// sacrifice all creatures // sacrifice all creatures
for (Permanent permanent :game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), game)) { for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), game)) {
permanent.sacrifice(source.getSourceId(), game); permanent.sacrifice(source.getSourceId(), game);
} }
// put exiled cards to battlefield // put exiled cards to battlefield
@ -116,7 +116,7 @@ class LivingEndEffect extends OneShotEffect {
for (Card card : exileZone.getCards(game)) { for (Card card : exileZone.getCards(game)) {
Player player = game.getPlayer(card.getOwnerId()); Player player = game.getPlayer(card.getOwnerId());
if (player != null) { if (player != null) {
player.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId()); player.moveCards(card, Zone.EXILED, source, game);
} }
} }
} }

View file

@ -60,7 +60,7 @@ public class FathomMageTest extends CardTestPlayerBase {
assertPowerToughness(playerA, "Fathom Mage", 3, 3); assertPowerToughness(playerA, "Fathom Mage", 3, 3);
Permanent fathomMage = getPermanent("Fathom Mage", playerA); Permanent fathomMage = getPermanent("Fathom Mage", playerA);
Assert.assertEquals("Fathom Mage has to be a Mutant", fathomMage.getSubtype().contains("Mutant"), true); Assert.assertEquals("Fathom Mage has to be a Mutant", true, fathomMage.getSubtype().contains("Mutant"));
assertHandCount(playerA, 2); assertHandCount(playerA, 2);
} }

View file

@ -116,7 +116,7 @@ public class AmplifyEffect extends ReplacementEffectImpl {
cards.addAll(target.getTargets()); cards.addAll(target.getTargets());
int amountCounters = cards.size() * amplifyFactor.getFactor(); int amountCounters = cards.size() * amplifyFactor.getFactor();
sourceCreature.addCounters(CounterType.P1P1.createInstance(amountCounters), game); sourceCreature.addCounters(CounterType.P1P1.createInstance(amountCounters), game);
controller.revealCards(sourceCreature.getName(), cards, game); controller.revealCards(sourceCreature.getIdName(), cards, game);
} }
} }
} }

View file

@ -39,6 +39,7 @@ import mage.counters.CounterType;
import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.permanent.AnotherPredicate; import mage.filter.predicate.permanent.AnotherPredicate;
import mage.game.Game; import mage.game.Game;
import mage.game.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
@ -116,7 +117,7 @@ public class DevourEffect extends ReplacementEffectImpl {
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getTargetId().equals(source.getSourceId())) { if (event.getTargetId().equals(source.getSourceId())) {
Permanent sourcePermanent = game.getPermanentEntering(source.getSourceId()); Permanent sourcePermanent = ((EntersTheBattlefieldEvent) event).getTarget();
game.getState().setValue(sourcePermanent.getId().toString() + "devoured", null); game.getState().setValue(sourcePermanent.getId().toString() + "devoured", null);
return true; return true;
} }
@ -130,7 +131,7 @@ public class DevourEffect extends ReplacementEffectImpl {
@Override @Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent creature = game.getPermanentEntering(event.getTargetId()); Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (creature != null && controller != null) { if (creature != null && controller != null) {
Target target = new TargetControlledCreaturePermanent(1, Integer.MAX_VALUE, filter, true); Target target = new TargetControlledCreaturePermanent(1, Integer.MAX_VALUE, filter, true);

View file

@ -25,7 +25,6 @@
* authors and should not be interpreted as representing official policies, either expressed * authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
*/ */
package mage.abilities.effects.common.continuous; package mage.abilities.effects.common.continuous;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -42,7 +41,7 @@ import mage.game.permanent.Permanent;
* @author nantuko * @author nantuko
*/ */
public class AddCardSubTypeTargetEffect extends ContinuousEffectImpl { public class AddCardSubTypeTargetEffect extends ContinuousEffectImpl {
private final String addedSubType; private final String addedSubType;
public AddCardSubTypeTargetEffect(String addedSubType, Duration duration) { public AddCardSubTypeTargetEffect(String addedSubType, Duration duration) {

View file

@ -1,16 +1,16 @@
/* /*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, are * Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met: * permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, this list of * 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. * conditions and the following disclaimer.
* *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list * 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 * of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution. * provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED * 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 * 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 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
@ -20,12 +20,11 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 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 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* The views and conclusions contained in the software and documentation are those of the * 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 * authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
*/ */
package mage.abilities.effects.common.continuous; package mage.abilities.effects.common.continuous;
import mage.MageObject; import mage.MageObject;
@ -76,7 +75,10 @@ public class SetPowerToughnessSourceEffect extends ContinuousEffectImpl {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
MageObject mageObject = game.getObject(source.getSourceId()); MageObject mageObject = game.getObject(source.getSourceId());
if (mageObject == null) {
game.getPermanentEntering(source.getSourceId());
}
if (mageObject == null) { if (mageObject == null) {
if (duration.equals(Duration.Custom)) { if (duration.equals(Duration.Custom)) {
discard(); discard();

View file

@ -37,6 +37,7 @@ import mage.constants.Outcome;
import mage.constants.Zone; import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.game.Game; import mage.game.Game;
import mage.game.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType; import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -97,10 +98,10 @@ class UnleashReplacementEffect extends ReplacementEffectImpl {
@Override @Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent creature = game.getPermanentEntering(source.getSourceId()); Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (creature != null && controller != null) { if (creature != null && controller != null) {
if (controller.chooseUse(outcome, "Unleash " + creature.getName() + "?", source, game)) { if (controller.chooseUse(outcome, "Unleash " + creature.getLogName() + "?", source, game)) {
if (!game.isSimulation()) { if (!game.isSimulation()) {
game.informPlayers(controller.getLogName() + " unleashes " + creature.getName()); game.informPlayers(controller.getLogName() + " unleashes " + creature.getName());
} }