forked from External/mage
refactored IntCompareCondition
This commit is contained in:
parent
1f89b4eedf
commit
22c842dfec
12 changed files with 46 additions and 55 deletions
|
|
@ -28,6 +28,7 @@
|
|||
package mage.abilities.condition;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.CountType;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
|
|
@ -36,10 +37,10 @@ import mage.game.Game;
|
|||
*/
|
||||
public abstract class IntCompareCondition implements Condition {
|
||||
|
||||
protected final Condition.ComparisonType type;
|
||||
protected final CountType type;
|
||||
protected final int value;
|
||||
|
||||
public IntCompareCondition(Condition.ComparisonType type, int value) {
|
||||
public IntCompareCondition(CountType type, int value) {
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
}
|
||||
|
|
@ -49,24 +50,7 @@ public abstract class IntCompareCondition implements Condition {
|
|||
@Override
|
||||
public final boolean apply(Game game, Ability source) {
|
||||
int inputValue = getInputValue(game, source);
|
||||
switch (type) {
|
||||
case Equal:
|
||||
if (inputValue != value) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case GreaterThan:
|
||||
if (inputValue <= value) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case LessThan:
|
||||
if (inputValue >= value) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
return CountType.compare(inputValue , type, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue