rename counttype to comparisontype

This commit is contained in:
ingmargoudt 2017-04-11 17:01:59 +02:00
parent 60a325c43f
commit 03643d53a3
489 changed files with 1062 additions and 1062 deletions

View file

@ -27,7 +27,7 @@
*/
package mage.abilities.common;
import mage.abilities.CountType;
import mage.constants.ComparisonType;
import mage.abilities.StateTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.constants.Zone;
@ -44,10 +44,10 @@ import mage.game.events.GameEvent;
public class ControlsPermanentsControllerTriggeredAbility extends StateTriggeredAbility {
protected final FilterPermanent filter;
protected final CountType type;
protected final ComparisonType type;
protected final int value;
public ControlsPermanentsControllerTriggeredAbility(FilterPermanent filter, CountType type, int value, Effect effect) {
public ControlsPermanentsControllerTriggeredAbility(FilterPermanent filter, ComparisonType type, int value, Effect effect) {
super(Zone.BATTLEFIELD, effect);
this.filter = filter;
this.value = value;
@ -69,7 +69,7 @@ public class ControlsPermanentsControllerTriggeredAbility extends StateTriggered
@Override
public boolean checkTrigger(GameEvent event, Game game) {
int inputValue = game.getBattlefield().countAll(filter, getControllerId(), game);
return CountType.compare(value, type, inputValue);
return ComparisonType.compare(value, type, inputValue);
}
@Override

View file

@ -28,7 +28,7 @@
package mage.abilities.condition;
import mage.abilities.Ability;
import mage.abilities.CountType;
import mage.constants.ComparisonType;
import mage.game.Game;
/**
@ -37,10 +37,10 @@ import mage.game.Game;
*/
public abstract class IntCompareCondition implements Condition {
protected final CountType type;
protected final ComparisonType type;
protected final int value;
public IntCompareCondition(CountType type, int value) {
public IntCompareCondition(ComparisonType type, int value) {
this.type = type;
this.value = value;
}
@ -50,7 +50,7 @@ public abstract class IntCompareCondition implements Condition {
@Override
public final boolean apply(Game game, Ability source) {
int inputValue = getInputValue(game, source);
return CountType.compare(inputValue , type, value);
return ComparisonType.compare(inputValue , type, value);
}
@Override

View file

@ -28,7 +28,7 @@
package mage.abilities.condition.common;
import mage.abilities.Ability;
import mage.abilities.CountType;
import mage.constants.ComparisonType;
import mage.abilities.condition.Condition;
import mage.game.Game;
import mage.players.Player;
@ -40,10 +40,10 @@ import java.util.UUID;
*/
public class CardsInAnyLibraryCondition implements Condition {
protected final CountType type;
protected final ComparisonType type;
protected final int value;
public CardsInAnyLibraryCondition(CountType type, int value) {
public CardsInAnyLibraryCondition(ComparisonType type, int value) {
this.type = type;
this.value = value;
}
@ -55,7 +55,7 @@ public class CardsInAnyLibraryCondition implements Condition {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
return CountType.compare(player.getLibrary().size(), type, value);
return ComparisonType.compare(player.getLibrary().size(), type, value);
}
}

View file

@ -30,7 +30,7 @@ package mage.abilities.condition.common;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.CountType;
import mage.constants.ComparisonType;
import mage.abilities.condition.Condition;
import mage.constants.TargetController;
import mage.game.Game;
@ -47,23 +47,23 @@ public class CardsInHandCondition implements Condition {
private Condition condition;
private CountType type;
private ComparisonType type;
private int count;
private TargetController targetController;
public CardsInHandCondition() {
this(CountType.EQUAL_TO, 0);
this(ComparisonType.EQUAL_TO, 0);
}
public CardsInHandCondition(CountType type, int count) {
public CardsInHandCondition(ComparisonType type, int count) {
this(type, count, null);
}
public CardsInHandCondition(CountType type, int count, Condition conditionToDecorate) {
public CardsInHandCondition(ComparisonType type, int count, Condition conditionToDecorate) {
this(type, count, conditionToDecorate, TargetController.YOU);
}
public CardsInHandCondition(CountType type, int count, Condition conditionToDecorate, TargetController targetController) {
public CardsInHandCondition(ComparisonType type, int count, Condition conditionToDecorate, TargetController targetController) {
this.type = type;
this.count = count;
this.condition = conditionToDecorate;
@ -77,12 +77,12 @@ public class CardsInHandCondition implements Condition {
if (controller != null) {
switch (targetController) {
case YOU:
conditionApplies = CountType.compare(game.getPlayer(source.getControllerId()).getHand().size(), type, count);
conditionApplies = ComparisonType.compare(game.getPlayer(source.getControllerId()).getHand().size(), type, count);
break;
case ACTIVE:
Player player = game.getPlayer(game.getActivePlayerId());
if (player != null) {
conditionApplies = CountType.compare(player.getHand().size(), type, count);
conditionApplies = ComparisonType.compare(player.getHand().size(), type, count);
}
break;
case ANY:
@ -90,7 +90,7 @@ public class CardsInHandCondition implements Condition {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
player = game.getPlayer(playerId);
if (player != null) {
if (!CountType.compare(player.getHand().size(), type, this.count)) {
if (!ComparisonType.compare(player.getHand().size(), type, this.count)) {
conflict = true;
break;
}

View file

@ -28,7 +28,7 @@
package mage.abilities.condition.common;
import mage.abilities.Ability;
import mage.abilities.CountType;
import mage.constants.ComparisonType;
import mage.abilities.condition.IntCompareCondition;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DevourEffect;
@ -43,7 +43,7 @@ import mage.game.permanent.Permanent;
*/
public class DevouredCreaturesCondition extends IntCompareCondition {
public DevouredCreaturesCondition(CountType type, int value) {
public DevouredCreaturesCondition(ComparisonType type, int value) {
super(type, value);
}

View file

@ -29,7 +29,7 @@
package mage.abilities.condition.common;
import mage.abilities.Ability;
import mage.abilities.CountType;
import mage.constants.ComparisonType;
import mage.abilities.condition.Condition;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.PowerPredicate;
@ -43,7 +43,7 @@ public enum FerociousCondition implements Condition {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent();
static {
filter.add(new PowerPredicate(CountType.MORE_THAN, 3));
filter.add(new PowerPredicate(ComparisonType.MORE_THAN, 3));
}

View file

@ -31,7 +31,7 @@ package mage.abilities.condition.common;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.CountType;
import mage.constants.ComparisonType;
import mage.abilities.condition.Condition;
import mage.filter.FilterPermanent;
import mage.filter.predicate.permanent.ControllerIdPredicate;
@ -48,18 +48,18 @@ public class OpponentControlsPermanentCondition implements Condition {
private FilterPermanent filter;
private CountType type;
private ComparisonType type;
private int count;
/**
* @param filter
*/
public OpponentControlsPermanentCondition(FilterPermanent filter) {
this(filter, CountType.MORE_THAN, 0);
this(filter, ComparisonType.MORE_THAN, 0);
}
/**
* Applies a filter, a {@link CountType}, and count to permanents on the
* Applies a filter, a {@link ComparisonType}, and count to permanents on the
* battlefield when checking the condition during the
* {@link #apply(mage.game.Game, mage.abilities.Ability) apply} method invocation.
*
@ -67,7 +67,7 @@ public class OpponentControlsPermanentCondition implements Condition {
* @param type
* @param count
*/
public OpponentControlsPermanentCondition(FilterPermanent filter, CountType type, int count) {
public OpponentControlsPermanentCondition(FilterPermanent filter, ComparisonType type, int count) {
this.filter = filter;
this.type = type;
this.count = count;
@ -79,7 +79,7 @@ public class OpponentControlsPermanentCondition implements Condition {
for (UUID opponentId : game.getOpponents(source.getControllerId())) {
FilterPermanent localFilter = filter.copy();
localFilter.add(new ControllerIdPredicate(opponentId));
if (CountType.compare(game.getBattlefield().count(localFilter, source.getSourceId(), source.getControllerId(), game), type, this.count)) {
if (ComparisonType.compare(game.getBattlefield().count(localFilter, source.getSourceId(), source.getControllerId(), game), type, this.count)) {
conditionApplies = true;
break;
}

View file

@ -28,7 +28,7 @@
package mage.abilities.condition.common;
import mage.abilities.Ability;
import mage.abilities.CountType;
import mage.constants.ComparisonType;
import mage.abilities.condition.IntCompareCondition;
import mage.game.Game;
import mage.watchers.common.PlayerLostLifeWatcher;
@ -42,7 +42,7 @@ import java.util.UUID;
*/
public class OpponentLostLifeCondition extends IntCompareCondition {
public OpponentLostLifeCondition(CountType type, int value) {
public OpponentLostLifeCondition(ComparisonType type, int value) {
super(type, value);
}

View file

@ -28,7 +28,7 @@
package mage.abilities.condition.common;
import mage.abilities.Ability;
import mage.abilities.CountType;
import mage.constants.ComparisonType;
import mage.abilities.condition.Condition;
import mage.counters.CounterType;
import mage.game.Game;
@ -47,15 +47,15 @@ public class PermanentHasCounterCondition implements Condition {
private CounterType counterType;
private int amount;
private FilterPermanent filter;
private CountType counttype;
private ComparisonType counttype;
private boolean anyPlayer;
public PermanentHasCounterCondition(CounterType counterType, int amount, FilterPermanent filter) {
this(counterType, amount, filter, CountType.EQUAL_TO);
this(counterType, amount, filter, ComparisonType.EQUAL_TO);
this.anyPlayer = false;
}
public PermanentHasCounterCondition(CounterType counterType, int amount, FilterPermanent filter, CountType type) {
public PermanentHasCounterCondition(CounterType counterType, int amount, FilterPermanent filter, ComparisonType type) {
this.counterType = counterType;
this.amount = amount;
this.filter = filter;
@ -63,7 +63,7 @@ public class PermanentHasCounterCondition implements Condition {
this.anyPlayer = false;
}
public PermanentHasCounterCondition(CounterType counterType, int amount, FilterPermanent filter, CountType type, boolean any) {
public PermanentHasCounterCondition(CounterType counterType, int amount, FilterPermanent filter, ComparisonType type, boolean any) {
this.counterType = counterType;
this.amount = amount;
this.filter = filter;
@ -77,7 +77,7 @@ public class PermanentHasCounterCondition implements Condition {
permanents = game.getBattlefield().getAllActivePermanents(this.filter, game);
}
for (Permanent permanent : permanents) {
if(CountType.compare(permanent.getCounters(game).getCount(this.counterType), counttype, this.amount))
if(ComparisonType.compare(permanent.getCounters(game).getCount(this.counterType), counttype, this.amount))
{
return true;
}

View file

@ -28,7 +28,7 @@
package mage.abilities.condition.common;
import mage.abilities.Ability;
import mage.abilities.CountType;
import mage.constants.ComparisonType;
import mage.abilities.condition.Condition;
import mage.filter.FilterPermanent;
import mage.filter.predicate.permanent.ControllerIdPredicate;
@ -47,23 +47,23 @@ public class PermanentsOnTheBattlefieldCondition implements Condition {
private FilterPermanent filter;
private Condition condition;
private CountType type;
private ComparisonType type;
private int count;
private boolean onlyControlled;
/**
* Applies a filter and delegates creation to
* {@link #ControlsPermanent(mage.filter.FilterPermanent, mage.abilities.condition.common.ControlsPermanent.CountType, int)}
* with {@link CountType#MORE_THAN}, and 0.
* with {@link ComparisonType#MORE_THAN}, and 0.
*
* @param filter
*/
public PermanentsOnTheBattlefieldCondition(FilterPermanent filter) {
this(filter, CountType.MORE_THAN, 0);
this(filter, ComparisonType.MORE_THAN, 0);
}
/**
* Applies a filter, a {@link CountType}, and count to permanents on the
* Applies a filter, a {@link ComparisonType}, and count to permanents on the
* battlefield when checking the condition during the
* {@link #apply(mage.game.Game, mage.abilities.Ability) apply} method invocation.
*
@ -71,11 +71,11 @@ public class PermanentsOnTheBattlefieldCondition implements Condition {
* @param type
* @param count
*/
public PermanentsOnTheBattlefieldCondition(FilterPermanent filter, CountType type, int count) {
public PermanentsOnTheBattlefieldCondition(FilterPermanent filter, ComparisonType type, int count) {
this(filter, type, count, true);
}
public PermanentsOnTheBattlefieldCondition(FilterPermanent filter, CountType type, int count, boolean onlyControlled) {
public PermanentsOnTheBattlefieldCondition(FilterPermanent filter, ComparisonType type, int count, boolean onlyControlled) {
this.filter = filter;
this.type = type;
this.count = count;
@ -83,7 +83,7 @@ public class PermanentsOnTheBattlefieldCondition implements Condition {
}
/**
* Applies a filter, a {@link CountType}, and count to permanents on the
* Applies a filter, a {@link ComparisonType}, and count to permanents on the
* battlefield and calls the decorated condition to see if it
* {@link #apply(mage.game.Game, mage.abilities.Ability) applies}
* as well. This will force both conditions to apply for this to be true.
@ -93,7 +93,7 @@ public class PermanentsOnTheBattlefieldCondition implements Condition {
* @param count
* @param conditionToDecorate
*/
public PermanentsOnTheBattlefieldCondition(FilterPermanent filter, CountType type, int count, Condition conditionToDecorate) {
public PermanentsOnTheBattlefieldCondition(FilterPermanent filter, ComparisonType type, int count, Condition conditionToDecorate) {
this(filter, type, count);
this.condition = conditionToDecorate;
}
@ -108,7 +108,7 @@ public class PermanentsOnTheBattlefieldCondition implements Condition {
}
int permanentsOnBattlefield = game.getBattlefield().count(localFilter, source.getSourceId(), source.getControllerId(), game);
conditionApplies = CountType.compare(permanentsOnBattlefield, type, count);
conditionApplies = ComparisonType.compare(permanentsOnBattlefield, type, count);
//If a decorated condition exists, check it as well and apply them together.
if (this.condition != null) {

View file

@ -1,7 +1,7 @@
package mage.abilities.condition.common;
import mage.abilities.Ability;
import mage.abilities.CountType;
import mage.constants.ComparisonType;
import mage.abilities.condition.IntCompareCondition;
import mage.game.Game;
import mage.watchers.common.PlayerGainedLifeWatcher;
@ -11,7 +11,7 @@ import mage.watchers.common.PlayerGainedLifeWatcher;
*/
public class YouGainedLifeCondition extends IntCompareCondition {
public YouGainedLifeCondition(CountType type, int value) {
public YouGainedLifeCondition(ComparisonType type, int value) {
super(type, value);
}

View file

@ -29,7 +29,7 @@
package mage.abilities.effects.common.cost;
import mage.abilities.Ability;
import mage.abilities.CountType;
import mage.constants.ComparisonType;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.constants.Outcome;
@ -58,7 +58,7 @@ public class CastWithoutPayingManaCostEffect extends OneShotEffect {
public CastWithoutPayingManaCostEffect(int maxCost) {
super(Outcome.PlayForFree);
filter = new FilterNonlandCard("card with converted mana cost " + maxCost + " or less from your hand");
filter.add(new ConvertedManaCostPredicate(CountType.FEWER_THAN, maxCost + 1));
filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, maxCost + 1));
this.manaCost = maxCost;
this.staticText = "you may cast a card with converted mana cost " + maxCost + " or less from your hand without paying its mana cost";
}

View file

@ -28,7 +28,7 @@
package mage.abilities.effects.common.search;
import mage.abilities.Ability;
import mage.abilities.CountType;
import mage.constants.ComparisonType;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.constants.Outcome;
@ -67,7 +67,7 @@ public class SearchLibraryWithLessCMCPutInPlayEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
FilterCard advancedFilter = filter.copy(); // never change static objects so copy the object here before
advancedFilter.add(new ConvertedManaCostPredicate(CountType.FEWER_THAN, source.getManaCostsToPay().getX() + 1));
advancedFilter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, source.getManaCostsToPay().getX() + 1));
TargetCardInLibrary target = new TargetCardInLibrary(advancedFilter);
if (controller.searchLibrary(target, game)) {
if (!target.getTargets().isEmpty()) {

View file

@ -28,7 +28,7 @@
package mage.abilities.effects.keyword;
import mage.abilities.Ability;
import mage.abilities.CountType;
import mage.constants.ComparisonType;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.Effect;
@ -96,7 +96,7 @@ public class BolsterEffect extends OneShotEffect {
if (leastToughness != Integer.MAX_VALUE) {
if (selectedCreature == null) {
FilterPermanent filter = new FilterControlledCreaturePermanent("creature you control with toughness " + leastToughness);
filter.add(new ToughnessPredicate(CountType.EQUAL_TO, leastToughness));
filter.add(new ToughnessPredicate(ComparisonType.EQUAL_TO, leastToughness));
Target target = new TargetPermanent(1,1, filter, true);
if (controller.chooseTarget(outcome, target, source, game)) {
selectedCreature = game.getPermanent(target.getFirstTarget());

View file

@ -28,7 +28,7 @@
package mage.abilities.keyword;
import mage.abilities.CountType;
import mage.constants.ComparisonType;
import mage.abilities.common.DiesTriggeredAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
@ -76,7 +76,7 @@ public class SoulshiftAbility extends DiesTriggeredAbility {
this.getTargets().clear();
int intValue = amount.calculate(game, this, null);
FilterCard filter = new FilterCard("Spirit card with converted mana cost " + intValue + " or less from your graveyard");
filter.add(new ConvertedManaCostPredicate(CountType.FEWER_THAN, intValue + 1));
filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, intValue + 1));
filter.add(new SubtypePredicate("Spirit"));
this.addTarget(new TargetCardInYourGraveyard(filter));
super.trigger(game, controllerId); //To change body of generated methods, choose Tools | Templates.

View file

@ -2,7 +2,7 @@ package mage.abilities.keyword;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.CountType;
import mage.constants.ComparisonType;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.DiscardSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
@ -78,7 +78,7 @@ class TransmuteEffect extends OneShotEffect {
MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject != null && controller != null) {
FilterCard filter = new FilterCard("card with converted mana cost " + sourceObject.getConvertedManaCost());
filter.add(new ConvertedManaCostPredicate(CountType.EQUAL_TO, sourceObject.getConvertedManaCost()));
filter.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, sourceObject.getConvertedManaCost()));
TargetCardInLibrary target = new TargetCardInLibrary(1, filter);
if (controller.searchLibrary(target, game)) {
if (!target.getTargets().isEmpty()) {

View file

@ -1,14 +1,14 @@
package mage.abilities;
package mage.constants;
/**
* Created by IGOUDT on 5-3-2017.
*/
public enum CountType {
public enum ComparisonType {
MORE_THAN(">"), FEWER_THAN("<"), EQUAL_TO("==");
String operator;
CountType(String op) {
ComparisonType(String op) {
operator = op;
}
@ -18,7 +18,7 @@ public enum CountType {
}
public static boolean compare(int source, CountType comparison, int target) {
public static boolean compare(int source, ComparisonType comparison, int target) {
switch (comparison) {
case MORE_THAN:
return source > target;

View file

@ -28,7 +28,7 @@
package mage.filter.predicate;
import mage.MageObject;
import mage.abilities.CountType;
import mage.constants.ComparisonType;
import mage.game.Game;
/**
@ -38,10 +38,10 @@ import mage.game.Game;
*/
public abstract class IntComparePredicate<T extends MageObject> implements Predicate<T> {
protected final CountType type;
protected final ComparisonType type;
protected final int value;
public IntComparePredicate(CountType type, int value) {
public IntComparePredicate(ComparisonType type, int value) {
this.type = type;
this.value = value;
}
@ -51,7 +51,7 @@ public abstract class IntComparePredicate<T extends MageObject> implements Predi
@Override
public final boolean apply(T input, Game game) {
int inputValue = getInputValue(input);
return CountType.compare(inputValue, type, value);
return ComparisonType.compare(inputValue, type, value);
}
@Override

View file

@ -28,7 +28,7 @@
package mage.filter.predicate.mageobject;
import mage.MageObject;
import mage.abilities.CountType;
import mage.constants.ComparisonType;
import mage.filter.predicate.IntComparePredicate;
/**
@ -37,7 +37,7 @@ import mage.filter.predicate.IntComparePredicate;
*/
public class ConvertedManaCostPredicate extends IntComparePredicate<MageObject> {
public ConvertedManaCostPredicate(CountType type, int value) {
public ConvertedManaCostPredicate(ComparisonType type, int value) {
super(type, value);
}

View file

@ -28,7 +28,7 @@
package mage.filter.predicate.mageobject;
import mage.MageObject;
import mage.abilities.CountType;
import mage.constants.ComparisonType;
import mage.filter.predicate.IntComparePredicate;
/**
@ -37,7 +37,7 @@ import mage.filter.predicate.IntComparePredicate;
*/
public class PowerPredicate extends IntComparePredicate<MageObject> {
public PowerPredicate(CountType type, int value) {
public PowerPredicate(ComparisonType type, int value) {
super(type, value);
}

View file

@ -28,7 +28,7 @@
package mage.filter.predicate.mageobject;
import mage.MageObject;
import mage.abilities.CountType;
import mage.constants.ComparisonType;
import mage.filter.predicate.IntComparePredicate;
/**
@ -37,7 +37,7 @@ import mage.filter.predicate.IntComparePredicate;
*/
public class ToughnessPredicate extends IntComparePredicate<MageObject> {
public ToughnessPredicate(CountType type, int value) {
public ToughnessPredicate(ComparisonType type, int value) {
super(type, value);
}