mirror of
https://github.com/magefree/mage.git
synced 2025-12-28 22:42:03 -08:00
Change CardsInExileCondition constructor and toString
change CardsInExileCondition to accept generic DynamicValue create a toString override to generate rule text
This commit is contained in:
parent
b9fa82f602
commit
121ab378e7
3 changed files with 37 additions and 7 deletions
|
|
@ -2,23 +2,30 @@ package mage.abilities.condition.common;
|
|||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.CardsInExileCount;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.constants.ComparisonType;
|
||||
import mage.game.Game;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
|
||||
/**
|
||||
* Cards in exile condition
|
||||
*
|
||||
* @author Jmlundeen
|
||||
*/
|
||||
public class CardsInExileCondition implements Condition
|
||||
{
|
||||
private final ComparisonType type;
|
||||
private final int count;
|
||||
private CardsInExileCount cardsInExileCount;
|
||||
private final DynamicValue cardsInExileCount;
|
||||
|
||||
public CardsInExileCondition(ComparisonType type, int count)
|
||||
{
|
||||
this(type, count, CardsInExileCount.YOU);
|
||||
this(type, count, CardsInExileCount.ALL);
|
||||
}
|
||||
|
||||
public CardsInExileCondition(ComparisonType type, int count, CardsInExileCount cardsInExileCount)
|
||||
public CardsInExileCondition(ComparisonType type, int count, DynamicValue cardsInExileCount)
|
||||
{
|
||||
this.type = type;
|
||||
this.count = count;
|
||||
|
|
@ -31,4 +38,28 @@ public class CardsInExileCondition implements Condition
|
|||
int exileCards = cardsInExileCount.calculate(game, source, null);
|
||||
return ComparisonType.compare(exileCards, type, count);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("there are ");
|
||||
String countString = CardUtil.numberToText(count);
|
||||
switch (type) {
|
||||
case MORE_THAN:
|
||||
sb.append("more than ").append(countString).append(" ");
|
||||
break;
|
||||
case FEWER_THAN:
|
||||
sb.append("fewer than ").append(countString).append(" ");
|
||||
break;
|
||||
case OR_LESS:
|
||||
sb.append(countString).append(" or less ");
|
||||
break;
|
||||
case OR_GREATER:
|
||||
sb.append(countString).append(" or more ");
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("comparison rules for " + type + " missing");
|
||||
}
|
||||
sb.append("cards in exile");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import java.util.UUID;
|
|||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @author JayDi85
|
||||
* @author Jmlundeen
|
||||
*/
|
||||
public enum CardsInExileCount implements DynamicValue {
|
||||
YOU("you"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue