* Some minor clean ups.

This commit is contained in:
LevelX2 2018-04-24 11:38:25 +02:00
parent 5cd1999efd
commit 6ebd715e17
4 changed files with 26 additions and 25 deletions

View file

@ -1,5 +1,14 @@
package org.mage.test.serverside.base;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import mage.cards.Card;
import mage.cards.repository.CardInfo;
import mage.cards.repository.CardRepository;
@ -23,12 +32,6 @@ import org.apache.log4j.Logger;
import org.junit.BeforeClass;
import org.mage.test.player.TestPlayer;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Base class for all tests.
*
@ -158,7 +161,7 @@ public abstract class MageTestPlayerBase {
protected void parseScenario(String filename) throws FileNotFoundException {
parserState = ParserState.INIT;
File f = new File(filename);
try(Scanner scanner = new Scanner(f)) {
try (Scanner scanner = new Scanner(f)) {
while (scanner.hasNextLine()) {
String line = scanner.nextLine().trim();
if (line == null || line.isEmpty() || line.startsWith("#")) {

View file

@ -168,6 +168,12 @@ public final class StaticFilters {
FILTER_CONTROLLED_PERMANENT_LAND.setLockedFilter(true);
}
public static final FilterControlledPermanent FILTER_CONTROLLED_PERMANENT_LANDS = new FilterControlledLandPermanent("lands you control");
static {
FILTER_CONTROLLED_PERMANENT_LANDS.setLockedFilter(true);
}
public static final FilterPermanent FILTER_OPPONENTS_PERMANENT = new FilterPermanent("permanent an opponent controls");
static {

View file

@ -72,9 +72,9 @@ public class FieldsOfSummerPlane extends Plane {
Effect chaosEffect = new GainLifeEffect(10);
Target chaosTarget = null;
List<Effect> chaosEffects = new ArrayList<Effect>();
List<Effect> chaosEffects = new ArrayList<>();
chaosEffects.add(chaosEffect);
List<Target> chaosTargets = new ArrayList<Target>();
List<Target> chaosTargets = new ArrayList<>();
chaosTargets.add(chaosTarget);
ActivateIfConditionActivatedAbility chaosAbility = new ActivateIfConditionActivatedAbility(Zone.COMMAND, new RollPlanarDieEffect(chaosEffects, chaosTargets), new GenericManaCost(0), MainPhaseStackEmptyCondition.instance);
@ -104,15 +104,9 @@ class FieldsOfSummerEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Plane cPlane = game.getState().getCurrentPlane();
if (cPlane == null) {
if (cPlane == null || !cPlane.getName().equalsIgnoreCase("Plane - Fields of Summer")) {
return false;
}
if (cPlane != null) {
if (!cPlane.getName().equalsIgnoreCase("Plane - Fields of Summer")) {
return false;
}
}
Player controller = game.getPlayer(source.getControllerId());
Player owner = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if (owner != null && owner.canRespond() && owner.chooseUse(Outcome.Benefit, "Gain 2 life?", source, game)) {
Effect effect = new GainLifeTargetEffect(2);

View file

@ -35,6 +35,7 @@ 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.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.RollPlanarDieEffect;
@ -43,14 +44,13 @@ import mage.abilities.effects.common.continuous.PlayAdditionalLandsAllEffect;
import mage.constants.Duration;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.StaticFilters;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.common.FilterControlledLandPermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.ColorPredicate;
import mage.game.command.Plane;
import mage.target.Target;
import mage.target.common.TargetControlledCreaturePermanent;
import mage.target.common.TargetCreaturePermanent;
import mage.watchers.common.PlanarRollWatcher;
/**
@ -60,14 +60,11 @@ import mage.watchers.common.PlanarRollWatcher;
public class NayaPlane extends Plane {
private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("Red, Green or White creature");
private static final FilterControlledLandPermanent filter2 = new FilterControlledLandPermanent("lands you control");
static {
filter.add(Predicates.or(new ColorPredicate(ObjectColor.RED), new ColorPredicate(ObjectColor.GREEN), new ColorPredicate(ObjectColor.WHITE)));
}
private static final String rule = "{this} gets +1/+1 until end of of turn for each land you control";
public NayaPlane() {
this.setName("Plane - Naya");
this.setExpansionSetCodeForImage("PCA");
@ -76,13 +73,14 @@ public class NayaPlane extends Plane {
Ability ability = new SimpleStaticAbility(Zone.COMMAND, new PlayAdditionalLandsAllEffect(Integer.MAX_VALUE));
this.getAbilities().add(ability);
// Active player can roll the planar die: Whenever you roll {CHAOS}, target red, green or white creature you control gets +1/+1 until end of turn for each land you control
Effect chaosEffect = new BoostTargetEffect(new PermanentsOnBattlefieldCount(filter2), new PermanentsOnBattlefieldCount(filter2), Duration.EndOfTurn);
// Active player can roll the planar die: Whenever you roll {CHAOS}, target red, green or white creature you control gets +1/+1 until end of turn for each land you control
DynamicValue dynamicValue = new PermanentsOnBattlefieldCount(StaticFilters.FILTER_CONTROLLED_PERMANENT_LANDS);
Effect chaosEffect = new BoostTargetEffect(dynamicValue, dynamicValue, Duration.EndOfTurn);
Target chaosTarget = new TargetControlledCreaturePermanent(1, 1, filter, false);
List<Effect> chaosEffects = new ArrayList<Effect>();
List<Effect> chaosEffects = new ArrayList<>();
chaosEffects.add(chaosEffect);
List<Target> chaosTargets = new ArrayList<Target>();
List<Target> chaosTargets = new ArrayList<>();
chaosTargets.add(chaosTarget);
ActivateIfConditionActivatedAbility chaosAbility = new ActivateIfConditionActivatedAbility(Zone.COMMAND, new RollPlanarDieEffect(chaosEffects, chaosTargets), new GenericManaCost(0), MainPhaseStackEmptyCondition.instance);