Planechase: refactor planes;

This commit is contained in:
Oleg Agafonov 2020-04-13 21:50:40 +04:00
parent b6557201b4
commit 823d677068
25 changed files with 229 additions and 241 deletions

View file

@ -13,6 +13,7 @@ import mage.choices.Choice;
import mage.choices.ChoiceImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Planes;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.game.Game;
@ -538,12 +539,11 @@ public final class SystemUtil {
break;
}
}
Class<?> c = Class.forName("mage.game.command.planes." + command.cardName);
Constructor<?> cons = c.getConstructor();
Object plane = cons.newInstance();
if (plane instanceof mage.game.command.Plane) {
((mage.game.command.Plane) plane).setControllerId(player.getId());
game.addPlane((mage.game.command.Plane) plane, null, player.getId());
Planes planeType = Planes.fromClassName(command.cardName);
Plane plane = Plane.createPlane(planeType);
if (plane != null) {
plane.setControllerId(player.getId());
game.addPlane(plane, null, player.getId());
continue;
}
} else if ("loyalty".equalsIgnoreCase(command.zone)) {

View file

@ -1,7 +1,5 @@
package mage.abilities.effects.common;
import java.util.List;
import java.util.stream.Collectors;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.Mode;
@ -18,8 +16,10 @@ import mage.players.Player;
import mage.target.Target;
import mage.target.targetpointer.FixedTarget;
import java.util.List;
import java.util.stream.Collectors;
/**
*
* @author spjspj
*/
public class RollPlanarDieEffect extends OneShotEffect {
@ -98,8 +98,8 @@ public class RollPlanarDieEffect extends OneShotEffect {
// Steps: 1) Remove the last plane and set its effects to discarded
for (CommandObject cobject : game.getState().getCommand()) {
if (cobject instanceof Plane) {
if (((Plane) cobject).getAbilities() != null) {
for (Ability ability : ((Plane) cobject).getAbilities()) {
if (cobject.getAbilities() != null) {
for (Ability ability : cobject.getAbilities()) {
for (Effect effect : ability.getEffects()) {
if (effect instanceof ContinuousEffect) {
((ContinuousEffect) effect).discard();
@ -107,7 +107,7 @@ public class RollPlanarDieEffect extends OneShotEffect {
}
}
}
game.getState().removeTriggersOfSourceId(((Plane) cobject).getId());
game.getState().removeTriggersOfSourceId(cobject.getId());
game.getState().getCommand().remove(cobject);
break;
}
@ -123,7 +123,7 @@ public class RollPlanarDieEffect extends OneShotEffect {
boolean foundNextPlane = false;
while (!foundNextPlane) {
Plane plane = Plane.getRandomPlane();
Plane plane = Plane.createRandomPlane();
try {
if (plane != null && !planesVisited.contains(plane.getName())) {
foundNextPlane = true;

View file

@ -1,41 +1,69 @@
package mage.constants;
/**
*
* @author spjspj
*/
public enum Planes {
PLANE_ACADEMY_AT_TOLARIA_WEST("AcademyAtTolariaWestPlane"),
PLANE_AGYREM("AgyremPlane"),
PLANE_AKOUM("AkoumPlane"),
PLANE_ASTRAL_ARENA("AstralArenaPlane"),
PLANE_BANT("BantPlane"),
PLANE_EDGE_OF_MALACOL("EdgeOfMalacolPlane"),
PLANE_FEEDING_GROUNDS("FeedingGroundsPlane"),
PLANE_FIELDS_OF_SUMMER("FieldsOfSummerPlane"),
PLANE_HEDRON_FIELDS_OF_AGADEEM("HedronFieldsOfAgadeemPlane"),
PLANE_LETHE_LAKE("LetheLakePlane"),
PLANE_NAYA("NayaPlane"),
PLANE_PANOPTICON("PanopticonPlane"),
PLANE_TAZEEM("TazeemPlane"),
PLANE_THE_DARK_BARONY("TheDarkBaronyPlane"),
PLANE_THE_EON_FOG("TheEonFogPlane"),
PLANE_THE_GREAT_FOREST("TheGreatForestPlane"),
PLANE_THE_ZEPHYR_MAZE_FOG("TheZephyrMazePlane"),
PLANE_TRUGA_JUNGLE("TrugaJunglePlane"),
PLANE_TRAIL_OF_THE_MAGE_RINGS("TrailOfTheMageRingsPlane"),
PLANE_TURRI_ISLAND("TurriIslandPlane"),
PLANE_UNDERCITY_REACHES("UndercityReachesPlane");
private final String text;
PLANE_ACADEMY_AT_TOLARIA_WEST("AcademyAtTolariaWestPlane", "Plane - Academy at Tolaria West"),
PLANE_AGYREM("AgyremPlane", "Plane - Agyrem"),
PLANE_AKOUM("AkoumPlane", "Plane - Akoum"),
PLANE_ASTRAL_ARENA("AstralArenaPlane", "Plane - Astral Arena"),
PLANE_BANT("BantPlane", "Plane - Bant"),
PLANE_EDGE_OF_MALACOL("EdgeOfMalacolPlane", "Plane - Edge of Malacol"),
PLANE_FEEDING_GROUNDS("FeedingGroundsPlane", "Plane - Feeding Grounds"),
PLANE_FIELDS_OF_SUMMER("FieldsOfSummerPlane", "Plane - Fields of Summer"),
PLANE_HEDRON_FIELDS_OF_AGADEEM("HedronFieldsOfAgadeemPlane", "Plane - Hedron Fields of Agadeem"),
PLANE_LETHE_LAKE("LetheLakePlane", "Plane - Lethe Lake"),
PLANE_NAYA("NayaPlane", "Plane - Naya"),
PLANE_PANOPTICON("PanopticonPlane", "Plane - Panopticon"),
PLANE_TAZEEM("TazeemPlane", "Plane - Tazeem"),
PLANE_THE_DARK_BARONY("TheDarkBaronyPlane", "Plane - The Dark Barony"),
PLANE_THE_EON_FOG("TheEonFogPlane", "Plane - The Eon Fog"),
PLANE_THE_GREAT_FOREST("TheGreatForestPlane", "Plane - The Great Forest"),
PLANE_THE_ZEPHYR_MAZE_FOG("TheZephyrMazePlane", "Plane - The Zephyr Maze"),
PLANE_TRUGA_JUNGLE("TrugaJunglePlane", "Plane - Truga Jungle"),
PLANE_TRAIL_OF_THE_MAGE_RINGS("TrailOfTheMageRingsPlane", "Plane - Trail of the Mage-Rings"),
PLANE_TURRI_ISLAND("TurriIslandPlane", "Plane - Turri Island"),
PLANE_UNDERCITY_REACHES("UndercityReachesPlane", "Plane - Undercity Reaches");
Planes(String text) {
this.text = text;
private final String className;
private final String fullName;
Planes(String className, String fullName) {
this.className = className;
this.fullName = fullName;
}
@Override
public String toString() {
return text;
return className;
}
public String getClassName() {
return className;
}
public String getFullName() {
return fullName;
}
public static Planes fromFullName(String fullName) {
for (Planes p : Planes.values()) {
if (p.fullName.equals(fullName)) {
return p;
}
}
return null;
}
public static Planes fromClassName(String className) {
for (Planes p : Planes.values()) {
if (p.className.equals(className)) {
return p;
}
}
return null;
}
}

View file

@ -38,7 +38,7 @@ public class Plane implements CommandObject {
private static ObjectColor emptyColor = new ObjectColor();
private static ManaCosts emptyCost = new ManaCostsImpl();
private String name = "";
private Planes planeType = null;
private UUID id;
private UUID controllerId;
private MageObject sourceObject;
@ -55,7 +55,7 @@ public class Plane implements CommandObject {
public Plane(final Plane plane) {
this.id = plane.id;
this.name = plane.name;
this.planeType = plane.planeType;
this.frameStyle = plane.frameStyle;
this.controllerId = plane.controllerId;
this.sourceObject = plane.sourceObject;
@ -78,9 +78,6 @@ public class Plane implements CommandObject {
public void setSourceObject(MageObject sourceObject) {
this.sourceObject = sourceObject;
if (sourceObject instanceof Card) {
if (name.isEmpty()) {
name = sourceObject.getSubtype(null).toString();
}
if (expansionSetCodeForImage.isEmpty()) {
expansionSetCodeForImage = ((Card) sourceObject).getExpansionSetCode();
}
@ -128,7 +125,7 @@ public class Plane implements CommandObject {
@Override
public String getName() {
return name;
return planeType != null ? planeType.getFullName() : "";
}
@Override
@ -143,12 +140,20 @@ public class Plane implements CommandObject {
@Override
public String getImageName() {
return this.name;
return planeType != null ? planeType.getFullName() : "";
}
@Override
public void setName(String name) {
this.name = name;
throw new UnsupportedOperationException("Planes don't use setName, use setPlaneType instead");
}
public void setPlaneType(Planes planeType) {
this.planeType = planeType;
}
public Planes getPlaneType() {
return this.planeType;
}
@Override
@ -288,19 +293,30 @@ public class Plane implements CommandObject {
public void removePTCDA() {
}
public static Plane getRandomPlane() {
int pick = RandomUtil.nextInt(Planes.values().length);
String planeName = Planes.values()[pick].toString();
planeName = "mage.game.command.planes." + planeName;
try {
Class<?> c = Class.forName(planeName);
Constructor<?> cons = c.getConstructor();
Object plane = cons.newInstance();
if (plane instanceof Plane) {
return (Plane) plane;
public static Plane createPlane(Planes planeType) {
if (planeType != null) {
String planeFullClass = "mage.game.command.planes." + planeType.getClassName();
try {
Class<?> c = Class.forName(planeFullClass);
Constructor<?> cons = c.getConstructor();
Object plane = cons.newInstance();
if (plane instanceof Plane) {
return (Plane) plane;
}
} catch (Exception ex) {
}
} catch (Exception ex) {
}
return null;
}
public static Plane createPlaneByFullName(String fullName) {
Planes planeType = Planes.fromFullName(fullName);
return createPlane(planeType);
}
public static Plane createRandomPlane() {
int pick = RandomUtil.nextInt(Planes.values().length);
Planes planeType = Planes.values()[pick];
return createPlane(planeType);
}
}

View file

@ -1,8 +1,5 @@
package mage.game.command.planes;
import java.util.ArrayList;
import java.util.List;
import mage.abilities.Ability;
import mage.abilities.common.ActivateIfConditionActivatedAbility;
import mage.abilities.common.BeginningOfEndStepTriggeredAbility;
@ -17,6 +14,7 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.RollPlanarDieEffect;
import mage.abilities.effects.common.discard.DiscardHandControllerEffect;
import mage.constants.Outcome;
import mage.constants.Planes;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.game.Game;
@ -26,14 +24,16 @@ import mage.target.Target;
import mage.util.CardUtil;
import mage.watchers.common.PlanarRollWatcher;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author spjspj
*/
public class AcademyAtTolariaWestPlane extends Plane {
public AcademyAtTolariaWestPlane() {
this.setName("Plane - Academy at Tolaria West");
this.setPlaneType(Planes.PLANE_ACADEMY_AT_TOLARIA_WEST);
this.setExpansionSetCodeForImage("PCA");
// At the beginning of your end step, if you have 0 cards in hand, draw seven cards
@ -88,7 +88,7 @@ class DrawCardsActivePlayerEffect extends OneShotEffect {
if (cPlane == null) {
return false;
}
if (!cPlane.getName().equalsIgnoreCase("Plane - Academy at Tolaria West")) {
if (!cPlane.getPlaneType().equals(Planes.PLANE_ACADEMY_AT_TOLARIA_WEST)) {
return false;
}
Player player = game.getPlayer(game.getActivePlayerId());

View file

@ -15,10 +15,7 @@ import mage.abilities.effects.common.ReturnFromGraveyardToHandTargetEffect;
import mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlTargetEffect;
import mage.abilities.effects.common.RollPlanarDieEffect;
import mage.cards.Card;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.constants.*;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.ColorPredicate;
@ -47,7 +44,7 @@ public class AgyremPlane extends Plane {
}
public AgyremPlane() {
this.setName("Plane - Agyrem");
this.setPlaneType(Planes.PLANE_AGYREM);
this.setExpansionSetCodeForImage("PCA");
// Whenever a white creature dies, return it to the battlefield under its owner's control at the beginning of the next end step
@ -156,7 +153,7 @@ class AgyremRestrictionEffect extends RestrictionEffect {
}
Plane cPlane = game.getState().getCurrentPlane();
if (cPlane != null && cPlane.getName().equalsIgnoreCase("Plane - Agyrem")) {
if (cPlane != null && cPlane.getPlaneType().equals(Planes.PLANE_AGYREM)) {
return !defenderId.equals(source.getControllerId());
}
return true;

View file

@ -1,8 +1,5 @@
package mage.game.command.planes;
import java.util.ArrayList;
import java.util.List;
import mage.abilities.common.ActivateIfConditionActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.common.MainPhaseStackEmptyCondition;
@ -11,10 +8,7 @@ import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.abilities.effects.common.RollPlanarDieEffect;
import mage.abilities.effects.common.continuous.CastAsThoughItHadFlashAllEffect;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.constants.*;
import mage.filter.FilterCard;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.Predicates;
@ -24,8 +18,10 @@ import mage.target.Target;
import mage.target.common.TargetCreaturePermanent;
import mage.watchers.common.PlanarRollWatcher;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author spjspj
*/
public class AkoumPlane extends Plane {
@ -39,7 +35,7 @@ public class AkoumPlane extends Plane {
}
public AkoumPlane() {
this.setName("Plane - Akoum");
this.setPlaneType(Planes.PLANE_AKOUM);
this.setExpansionSetCodeForImage("PCA");
// Players may cast enchantment spells as if they had flash

View file

@ -10,6 +10,7 @@ import mage.abilities.effects.RestrictionEffect;
import mage.abilities.effects.common.DamageAllEffect;
import mage.abilities.effects.common.RollPlanarDieEffect;
import mage.constants.Duration;
import mage.constants.Planes;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
@ -30,7 +31,7 @@ import java.util.UUID;
public class AstralArenaPlane extends Plane {
public AstralArenaPlane() {
this.setName("Plane - Astral Arena");
this.setPlaneType(Planes.PLANE_ASTRAL_ARENA);
this.setExpansionSetCodeForImage("PCA");
// No more than one creature can attack each turn. No more than one creature can block each turn.
@ -80,7 +81,7 @@ class AstralArenaAttackRestrictionEffect extends RestrictionEffect {
if (cPlane == null) {
return false;
}
return cPlane.getName().equalsIgnoreCase("Plane - Astral Arena");
return cPlane.getPlaneType().equals(Planes.PLANE_ASTRAL_ARENA);
}
@Override
@ -111,7 +112,7 @@ class AstralArenaBlockRestrictionEffect extends RestrictionEffect {
if (cPlane == null) {
return false;
}
return cPlane.getName().equalsIgnoreCase("Plane - Astral Arena");
return cPlane.getPlaneType().equals(Planes.PLANE_ASTRAL_ARENA);
}
@Override

View file

@ -1,9 +1,5 @@
package mage.game.command.planes;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.common.ActivateIfConditionActivatedAbility;
@ -21,11 +17,7 @@ import mage.abilities.effects.common.cost.CostModificationEffectImpl;
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
import mage.abilities.keyword.ExaltedAbility;
import mage.abilities.keyword.IndestructibleAbility;
import mage.constants.CostModificationType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.constants.*;
import mage.counters.CounterType;
import mage.filter.StaticFilters;
import mage.filter.common.FilterCreaturePermanent;
@ -39,8 +31,11 @@ import mage.target.common.TargetCreaturePermanent;
import mage.util.CardUtil;
import mage.watchers.common.PlanarRollWatcher;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
*
* @author spjspj
*/
public class BantPlane extends Plane {
@ -56,15 +51,15 @@ public class BantPlane extends Plane {
private static final String exaltedRule = "All creatures have exalted";
public BantPlane() {
this.setName("Plane - Bant");
this.setPlaneType(Planes.PLANE_BANT);
this.setExpansionSetCodeForImage("PCA");
// All creatures have exalted
SimpleStaticAbility ability
= new SimpleStaticAbility(Zone.COMMAND, new ConditionalContinuousEffect(
new GainAbilityAllEffect(new ExaltedAbility(), Duration.Custom, StaticFilters.FILTER_PERMANENT_CREATURE),
new IsStillOnPlaneCondition(this.getName()),
exaltedRule));
new GainAbilityAllEffect(new ExaltedAbility(), Duration.Custom, StaticFilters.FILTER_PERMANENT_CREATURE),
new IsStillOnPlaneCondition(this.getName()),
exaltedRule));
this.getAbilities().add(ability);

View file

@ -1,27 +1,16 @@
package mage.game.command.planes;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.ActivateIfConditionActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.common.MainPhaseStackEmptyCondition;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.decorator.ConditionalContinuousEffect;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.RollPlanarDieEffect;
import mage.abilities.effects.common.SkipUntapStepEffect;
import mage.abilities.effects.common.UntapAllControllerEffect;
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.PhaseStep;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.constants.*;
import mage.counters.CounterType;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.common.FilterCreaturePermanent;
@ -34,14 +23,18 @@ import mage.target.Target;
import mage.target.targetpointer.FixedTarget;
import mage.watchers.common.PlanarRollWatcher;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
/**
*
* @author spjspj
*/
public class EdgeOfMalacolPlane extends Plane {
public EdgeOfMalacolPlane() {
this.setName("Plane - Edge Of Malacol");
this.setPlaneType(Planes.PLANE_EDGE_OF_MALACOL);
this.setExpansionSetCodeForImage("PCA");
// If a creature you control would untap during your untap step, put two +1/+1 counters on it instead.
@ -101,7 +94,7 @@ class EdgeOfMalacolEffect extends ContinuousRuleModifyingEffectImpl {
if (cPlane == null) {
return false;
}
if (!cPlane.getName().equalsIgnoreCase("Plane - Edge of Malacol")) {
if (!cPlane.getPlaneType().equals(Planes.PLANE_EDGE_OF_MALACOL)) {
return false;
}
Permanent permanent = game.getPermanent(event.getTargetId());

View file

@ -1,8 +1,5 @@
package mage.game.command.planes;
import java.util.ArrayList;
import java.util.List;
import mage.MageObject;
import mage.ObjectColor;
import mage.abilities.Ability;
@ -17,11 +14,7 @@ import mage.abilities.effects.common.RollPlanarDieEffect;
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
import mage.cards.Card;
import mage.constants.CostModificationType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.constants.*;
import mage.counters.CounterType;
import mage.filter.FilterCard;
import mage.filter.common.FilterCreaturePermanent;
@ -35,8 +28,10 @@ import mage.target.common.TargetCreaturePermanent;
import mage.util.CardUtil;
import mage.watchers.common.PlanarRollWatcher;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author spjspj
*/
public class FeedingGroundsPlane extends Plane {
@ -45,7 +40,7 @@ public class FeedingGroundsPlane extends Plane {
private static final String rule = "put X +1/+1 counters on target creature, where X is that creature's converted mana cost";
public FeedingGroundsPlane() {
this.setName("Plane - Feeding Grounds");
this.setPlaneType(Planes.PLANE_FEEDING_GROUNDS);
this.setExpansionSetCodeForImage("PCA");
// Red spells cost {1} less to cast. Green spells cost {1} less to cast
@ -133,7 +128,7 @@ class FeedingGroundsEffect extends CostModificationEffectImpl {
if (cPlane == null) {
return false;
}
if (!cPlane.getName().equalsIgnoreCase("Plane - Feeding Grounds")) {
if (!cPlane.getPlaneType().equals(Planes.PLANE_FEEDING_GROUNDS)) {
return false;
}

View file

@ -1,8 +1,5 @@
package mage.game.command.planes;
import java.util.ArrayList;
import java.util.List;
import mage.abilities.Ability;
import mage.abilities.common.ActivateIfConditionActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
@ -14,10 +11,7 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.effects.common.GainLifeTargetEffect;
import mage.abilities.effects.common.RollPlanarDieEffect;
import mage.constants.Outcome;
import mage.constants.SetTargetPointer;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.constants.*;
import mage.filter.FilterSpell;
import mage.game.Game;
import mage.game.command.Plane;
@ -26,8 +20,10 @@ import mage.target.Target;
import mage.target.targetpointer.FixedTarget;
import mage.watchers.common.PlanarRollWatcher;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author spjspj
*/
public class FieldsOfSummerPlane extends Plane {
@ -35,7 +31,7 @@ public class FieldsOfSummerPlane extends Plane {
private static final FilterSpell filter = new FilterSpell("a spell");
public FieldsOfSummerPlane() {
this.setName("Plane - Fields of Summer");
this.setPlaneType(Planes.PLANE_FIELDS_OF_SUMMER);
this.setExpansionSetCodeForImage("PCA");
// Whenever a player casts a spell, that player may gain 2 life
@ -78,7 +74,7 @@ class FieldsOfSummerEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Plane cPlane = game.getState().getCurrentPlane();
if (cPlane == null || !cPlane.getName().equalsIgnoreCase("Plane - Fields of Summer")) {
if (cPlane == null || !cPlane.getPlaneType().equals(Planes.PLANE_FIELDS_OF_SUMMER)) {
return false;
}
Player owner = game.getPlayer(this.getTargetPointer().getFirst(game, source));

View file

@ -9,10 +9,7 @@ import mage.abilities.effects.Effect;
import mage.abilities.effects.RestrictionEffect;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.RollPlanarDieEffect;
import mage.constants.ComparisonType;
import mage.constants.Duration;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.constants.*;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.PowerPredicate;
import mage.game.Game;
@ -31,7 +28,7 @@ import java.util.List;
public class HedronFieldsOfAgadeemPlane extends Plane {
public HedronFieldsOfAgadeemPlane() {
this.setName("Plane - Hedron Fields of Agadeem");
this.setPlaneType(Planes.PLANE_HEDRON_FIELDS_OF_AGADEEM);
this.setExpansionSetCodeForImage("PCA");
// Creatures with power 7 or greater can't attack or block
@ -94,7 +91,7 @@ class HedronFieldsOfAgadeemRestrictionEffect extends RestrictionEffect {
if (cPlane == null) {
return false;
}
if (!cPlane.getName().equalsIgnoreCase("Plane - Hedron Fields of Agadeem")) {
if (!cPlane.getPlaneType().equals(Planes.PLANE_HEDRON_FIELDS_OF_AGADEEM)) {
return false;
}
return filter.match(permanent, source.getSourceId(), source.getControllerId(), game);

View file

@ -1,8 +1,5 @@
package mage.game.command.planes;
import java.util.ArrayList;
import java.util.List;
import mage.abilities.Ability;
import mage.abilities.common.ActivateIfConditionActivatedAbility;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
@ -13,6 +10,7 @@ import mage.abilities.effects.Effect;
import mage.abilities.effects.common.PutLibraryIntoGraveTargetEffect;
import mage.abilities.effects.common.PutTopCardOfLibraryIntoGraveTargetEffect;
import mage.abilities.effects.common.RollPlanarDieEffect;
import mage.constants.Planes;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.game.command.Plane;
@ -20,14 +18,16 @@ import mage.target.Target;
import mage.target.TargetPlayer;
import mage.watchers.common.PlanarRollWatcher;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author spjspj
*/
public class LetheLakePlane extends Plane {
public LetheLakePlane() {
this.setName("Plane - Lethe Lake");
this.setPlaneType(Planes.PLANE_LETHE_LAKE);
this.setExpansionSetCodeForImage("PCA");
// At the beginning of your upkeep, put the top ten cards of your libary into your graveyard

View file

@ -1,8 +1,5 @@
package mage.game.command.planes;
import java.util.ArrayList;
import java.util.List;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.common.ActivateIfConditionActivatedAbility;
@ -16,6 +13,7 @@ import mage.abilities.effects.common.RollPlanarDieEffect;
import mage.abilities.effects.common.continuous.BoostTargetEffect;
import mage.abilities.effects.common.continuous.PlayAdditionalLandsAllEffect;
import mage.constants.Duration;
import mage.constants.Planes;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.StaticFilters;
@ -27,8 +25,10 @@ import mage.target.Target;
import mage.target.common.TargetControlledCreaturePermanent;
import mage.watchers.common.PlanarRollWatcher;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author spjspj
*/
public class NayaPlane extends Plane {
@ -40,7 +40,7 @@ public class NayaPlane extends Plane {
}
public NayaPlane() {
this.setName("Plane - Naya");
this.setPlaneType(Planes.PLANE_NAYA);
this.setExpansionSetCodeForImage("PCA");
// You may play any number of lands on each of your turns

View file

@ -1,7 +1,5 @@
package mage.game.command.planes;
import java.util.ArrayList;
import java.util.List;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.ActivateIfConditionActivatedAbility;
@ -13,6 +11,7 @@ import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.DrawCardTargetEffect;
import mage.abilities.effects.common.RollPlanarDieEffect;
import mage.constants.Planes;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.game.Game;
@ -24,8 +23,10 @@ import mage.target.Target;
import mage.target.targetpointer.FixedTarget;
import mage.watchers.common.PlanarRollWatcher;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author spjspj
*/
public class PanopticonPlane extends Plane {
@ -33,7 +34,7 @@ public class PanopticonPlane extends Plane {
private static final String rule = "At the beginning of your draw step, draw an additional card";
public PanopticonPlane() {
this.setName("Plane - Panopticon");
this.setPlaneType(Planes.PLANE_PANOPTICON);
this.setExpansionSetCodeForImage("PCA");
// When you planeswalk to Panopticon, draw a card
@ -80,7 +81,7 @@ class PanopticonTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Plane cPlane = game.getState().getCurrentPlane();
if (cPlane == null || !cPlane.getName().equalsIgnoreCase("Plane - Panopticon")) {
if (cPlane == null || !cPlane.getPlaneType().equals(Planes.PLANE_PANOPTICON)) {
return false;
}

View file

@ -12,6 +12,7 @@ import mage.abilities.effects.RestrictionEffect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.RollPlanarDieEffect;
import mage.constants.Duration;
import mage.constants.Planes;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.common.FilterControlledLandPermanent;
@ -33,7 +34,7 @@ public class TazeemPlane extends Plane {
private static final String rule = "Creatures can't block";
public TazeemPlane() {
this.setName("Plane - Tazeem");
this.setPlaneType(Planes.PLANE_TAZEEM);
this.setExpansionSetCodeForImage("PCA");
// Creatures can't block
@ -75,7 +76,7 @@ class TazeemCantBlockAllEffect extends RestrictionEffect {
public boolean applies(Permanent permanent, Ability source, Game game) {
Plane cPlane = game.getState().getCurrentPlane();
if (cPlane == null || !cPlane.getName().equalsIgnoreCase("Plane - Tazeem")) {
if (cPlane == null || !cPlane.getPlaneType().equals(Planes.PLANE_TAZEEM)) {
return false;
}
return filter.match(permanent, source.getSourceId(), source.getControllerId(), game);

View file

@ -1,8 +1,5 @@
package mage.game.command.planes;
import java.util.ArrayList;
import java.util.List;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.common.ActivateIfConditionActivatedAbility;
@ -14,6 +11,7 @@ import mage.abilities.effects.Effect;
import mage.abilities.effects.common.LoseLifeTargetEffect;
import mage.abilities.effects.common.RollPlanarDieEffect;
import mage.abilities.effects.common.discard.DiscardEachPlayerEffect;
import mage.constants.Planes;
import mage.constants.SetTargetPointer;
import mage.constants.TargetController;
import mage.constants.Zone;
@ -24,8 +22,10 @@ import mage.game.command.Plane;
import mage.target.Target;
import mage.watchers.common.PlanarRollWatcher;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author spjspj
*/
public class TheDarkBaronyPlane extends Plane {
@ -37,7 +37,7 @@ public class TheDarkBaronyPlane extends Plane {
}
public TheDarkBaronyPlane() {
this.setName("Plane - The Dark Barony");
this.setPlaneType(Planes.PLANE_THE_DARK_BARONY);
this.setExpansionSetCodeForImage("PCA");
// Whenever a nonblack card is put into a player's graveyard from anywhere, that player loses 1 life

View file

@ -1,8 +1,5 @@
package mage.game.command.planes;
import java.util.ArrayList;
import java.util.List;
import mage.abilities.Ability;
import mage.abilities.common.ActivateIfConditionActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
@ -12,10 +9,7 @@ import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.RollPlanarDieEffect;
import mage.abilities.effects.common.UntapAllControllerEffect;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.constants.*;
import mage.filter.common.FilterControlledPermanent;
import mage.game.Game;
import mage.game.command.Plane;
@ -23,14 +17,16 @@ import mage.game.events.GameEvent;
import mage.target.Target;
import mage.watchers.common.PlanarRollWatcher;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author spjspj
*/
public class TheEonFogPlane extends Plane {
public TheEonFogPlane() {
this.setName("Plane - The Eon Fog");
this.setPlaneType(Planes.PLANE_THE_EON_FOG);
this.setExpansionSetCodeForImage("PCA");
// All players miss their untap step
@ -87,7 +83,7 @@ class TheEonFogSkipUntapStepEffect extends ContinuousRuleModifyingEffectImpl {
if (cPlane == null) {
return false;
}
if (!cPlane.getName().equalsIgnoreCase("Plane - The Eon Fog")) {
if (!cPlane.getPlaneType().equals(Planes.PLANE_THE_EON_FOG)) {
return false;
}
return event.getType() == GameEvent.EventType.UNTAP_STEP;

View file

@ -1,8 +1,5 @@
package mage.game.command.planes;
import java.util.ArrayList;
import java.util.List;
import mage.abilities.Ability;
import mage.abilities.common.ActivateIfConditionActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
@ -13,22 +10,18 @@ import mage.abilities.effects.Effect;
import mage.abilities.effects.common.RollPlanarDieEffect;
import mage.abilities.effects.common.continuous.BoostControlledEffect;
import mage.abilities.effects.common.continuous.GainAbilityControlledEffect;
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
import mage.abilities.keyword.TrampleAbility;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.constants.*;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.command.Plane;
import mage.target.Target;
import mage.watchers.common.PlanarRollWatcher;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author spjspj
*/
public class TheGreatForestPlane extends Plane {
@ -36,7 +29,7 @@ public class TheGreatForestPlane extends Plane {
private static final String rule = "Each creature assigns combat damage equal to its toughness rather than its power";
public TheGreatForestPlane() {
this.setName("Plane - The Great Forest");
this.setPlaneType(Planes.PLANE_THE_GREAT_FOREST);
this.setExpansionSetCodeForImage("PCA");
// Each creature assigns combat damage equal to its toughness rather than its power
@ -82,11 +75,11 @@ class TheGreatForestCombatDamageRuleEffect extends ContinuousEffectImpl {
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
Plane cPlane = game.getState().getCurrentPlane();
Plane cPlane = game.getState().getCurrentPlane();
if (cPlane == null) {
return false;
}
if (!cPlane.getName().equalsIgnoreCase("Plane - The Great Forest")) {
if (!cPlane.getPlaneType().equals(Planes.PLANE_THE_GREAT_FOREST)) {
return false;
}

View file

@ -1,8 +1,5 @@
package mage.game.command.planes;
import java.util.ArrayList;
import java.util.List;
import mage.abilities.Ability;
import mage.abilities.common.ActivateIfConditionActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
@ -16,6 +13,7 @@ import mage.abilities.effects.common.continuous.BoostAllEffect;
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.constants.Duration;
import mage.constants.Planes;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
@ -26,8 +24,10 @@ import mage.target.Target;
import mage.target.common.TargetCreaturePermanent;
import mage.watchers.common.PlanarRollWatcher;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author spjspj
*/
public class TheZephyrMazePlane extends Plane {
@ -44,7 +44,7 @@ public class TheZephyrMazePlane extends Plane {
private static final String walkingRule = "Creatures without flying get -2/-0";
public TheZephyrMazePlane() {
this.setName("Plane - The Zephyr Maze");
this.setPlaneType(Planes.PLANE_THE_ZEPHYR_MAZE_FOG);
this.setExpansionSetCodeForImage("PCA");
// Creatures with flying get +2/+0
@ -61,7 +61,7 @@ public class TheZephyrMazePlane extends Plane {
this.getAbilities().add(ability2);
// Active player can roll the planar die: Whenever you roll {CHAOS}, target creature gains flying until end of turn
Effect chaosEffect = new GainAbilityTargetEffect(FlyingAbility.getInstance(), Duration.EndOfTurn);
Effect chaosEffect = new GainAbilityTargetEffect(FlyingAbility.getInstance(), Duration.EndOfTurn);
Target chaosTarget = new TargetCreaturePermanent(0, 1);
List<Effect> chaosEffects = new ArrayList<Effect>();

View file

@ -1,10 +1,5 @@
package mage.game.command.planes;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.ActivateIfConditionActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
@ -16,13 +11,7 @@ import mage.abilities.effects.common.RollPlanarDieEffect;
import mage.abilities.effects.common.search.SearchLibraryPutInHandEffect;
import mage.abilities.keyword.ReboundAbility;
import mage.cards.Card;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.constants.*;
import mage.filter.FilterCard;
import mage.filter.common.FilterInstantOrSorceryCard;
import mage.filter.predicate.Predicates;
@ -35,8 +24,12 @@ import mage.target.Target;
import mage.target.common.TargetCardInLibrary;
import mage.watchers.common.PlanarRollWatcher;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
/**
*
* @author spjspj
*/
public class TrailOfTheMageRingsPlane extends Plane {
@ -48,7 +41,7 @@ public class TrailOfTheMageRingsPlane extends Plane {
}
public TrailOfTheMageRingsPlane() {
this.setName("Plane - Trail of the Mage-Rings");
this.setPlaneType(Planes.PLANE_TRAIL_OF_THE_MAGE_RINGS);
this.setExpansionSetCodeForImage("PCA");
// Instant and sorcery spells have rebound
@ -100,7 +93,7 @@ class TrailOfTheMageRingsReboundEffect extends ContinuousEffectImpl {
if (cPlane == null) {
return false;
}
if (!cPlane.getName().equalsIgnoreCase("Plane - Trail of the Mage-Rings")) {
if (!cPlane.getPlaneType().equals(Planes.PLANE_TRAIL_OF_THE_MAGE_RINGS)) {
return false;
}
@ -110,7 +103,7 @@ class TrailOfTheMageRingsReboundEffect extends ContinuousEffectImpl {
for (Card card : player.getHand().getCards(filter, game)) {
addReboundAbility(card, source, game);
}
for (Iterator<StackObject> iterator = game.getStack().iterator(); iterator.hasNext();) {
for (Iterator<StackObject> iterator = game.getStack().iterator(); iterator.hasNext(); ) {
StackObject stackObject = iterator.next();
if (stackObject instanceof Spell && stackObject.isControlledBy(source.getControllerId())) {
Spell spell = (Spell) stackObject;

View file

@ -1,8 +1,5 @@
package mage.game.command.planes;
import java.util.ArrayList;
import java.util.List;
import mage.abilities.common.ActivateIfConditionActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.common.IsStillOnPlaneCondition;
@ -15,6 +12,7 @@ import mage.abilities.effects.common.RollPlanarDieEffect;
import mage.abilities.effects.common.continuous.GainAbilityAllEffect;
import mage.abilities.mana.AnyColorManaAbility;
import mage.constants.Duration;
import mage.constants.Planes;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.StaticFilters;
@ -23,8 +21,10 @@ import mage.game.command.Plane;
import mage.target.Target;
import mage.watchers.common.PlanarRollWatcher;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author spjspj
*/
public class TrugaJunglePlane extends Plane {
@ -32,14 +32,14 @@ public class TrugaJunglePlane extends Plane {
private static final String rule = "All lands have '{t}: Add one mana of any color";
public TrugaJunglePlane() {
this.setName("Plane - Truga Jungle");
this.setPlaneType(Planes.PLANE_TRUGA_JUNGLE);
this.setExpansionSetCodeForImage("PCA");
SimpleStaticAbility ability
= new SimpleStaticAbility(Zone.COMMAND, new ConditionalContinuousEffect(
new GainAbilityAllEffect(new AnyColorManaAbility(), Duration.Custom, StaticFilters.FILTER_LANDS),
new IsStillOnPlaneCondition(this.getName()),
rule));
new GainAbilityAllEffect(new AnyColorManaAbility(), Duration.Custom, StaticFilters.FILTER_LANDS),
new IsStillOnPlaneCondition(this.getName()),
rule));
this.getAbilities().add(ability);
// Active player can roll the planar die: Whenever you roll {CHAOS}, reveal the top three cards of your libary. Put all land cards revealed this way into your hand the rest on the bottom of your library in any order.

View file

@ -1,8 +1,5 @@
package mage.game.command.planes;
import java.util.ArrayList;
import java.util.List;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.common.ActivateIfConditionActivatedAbility;
@ -14,12 +11,7 @@ import mage.abilities.effects.common.RevealLibraryPutIntoHandEffect;
import mage.abilities.effects.common.RollPlanarDieEffect;
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
import mage.cards.Card;
import mage.constants.CardType;
import mage.constants.CostModificationType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.constants.*;
import mage.filter.FilterCard;
import mage.filter.common.FilterCreatureCard;
import mage.game.Game;
@ -29,14 +21,16 @@ import mage.target.Target;
import mage.util.CardUtil;
import mage.watchers.common.PlanarRollWatcher;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author spjspj
*/
public class TurriIslandPlane extends Plane {
public TurriIslandPlane() {
this.setName("Plane - Turri Island");
this.setPlaneType(Planes.PLANE_TURRI_ISLAND);
this.setExpansionSetCodeForImage("PCA");
// Creature spells cost {2} less to cast.
@ -76,11 +70,11 @@ class TurriIslandEffect extends CostModificationEffectImpl {
this.amount = 2;
this.staticText = rule;
}
protected TurriIslandEffect(TurriIslandEffect effect) {
super(effect);
this.amount = effect.amount;
}
this.amount = effect.amount;
}
@Override
public void init(Ability source, Game game) {
@ -112,7 +106,7 @@ class TurriIslandEffect extends CostModificationEffectImpl {
if (cPlane == null) {
return false;
}
if (!cPlane.getName().equalsIgnoreCase("Plane - Turri Island")) {
if (!cPlane.getPlaneType().equals(Planes.PLANE_TURRI_ISLAND)) {
return false;
}

View file

@ -1,8 +1,5 @@
package mage.game.command.planes;
import java.util.ArrayList;
import java.util.List;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.ActivateIfConditionActivatedAbility;
@ -15,10 +12,7 @@ import mage.abilities.effects.common.DrawCardTargetEffect;
import mage.abilities.effects.common.RollPlanarDieEffect;
import mage.abilities.effects.common.continuous.MaximumHandSizeControllerEffect;
import mage.abilities.effects.common.continuous.MaximumHandSizeControllerEffect.HandSizeModification;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.constants.*;
import mage.filter.FilterCard;
import mage.game.Game;
import mage.game.command.Plane;
@ -30,8 +24,10 @@ import mage.target.Target;
import mage.target.targetpointer.FixedTarget;
import mage.watchers.common.PlanarRollWatcher;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author spjspj
*/
public class UndercityReachesPlane extends Plane {
@ -43,7 +39,7 @@ public class UndercityReachesPlane extends Plane {
}
public UndercityReachesPlane() {
this.setName("Plane - Undercity Reaches");
this.setPlaneType(Planes.PLANE_UNDERCITY_REACHES);
this.setExpansionSetCodeForImage("PCA");
// Whenever a creature deals combat damage to a player, its controller may a draw a card
@ -94,7 +90,7 @@ class UndercityReachesTriggeredAbility extends TriggeredAbilityImpl {
if (cPlane == null) {
return false;
}
if (!cPlane.getName().equalsIgnoreCase("Plane - Undercity Reaches")) {
if (!cPlane.getPlaneType().equals(Planes.PLANE_UNDERCITY_REACHES)) {
return false;
}