add '<n> or fewer cards in hand' condition

master
ShawnieBoy 2017-04-23 03:14:37 +01:00
parent d4920cc3d7
commit 670cc9cba1
2 changed files with 15 additions and 0 deletions

View File

@ -109,6 +109,15 @@ public class MagicConditionFactory {
};
}
public static MagicCondition HandAtMost(final int n) {
return new MagicCondition() {
@Override
public boolean accept(MagicSource source) {
return source.getController().getHandSize() <= n;
}
};
}
public static MagicCondition RNHandAtLeast(final int n) {
return new MagicCondition() {
@Override

View File

@ -132,6 +132,12 @@ public enum MagicConditionParser {
return MagicConditionFactory.HandAtLeast(amount);
}
},
HandFewer("you have " + ARG.AMOUNT +" or fewer cards in hand") {
public MagicCondition toCondition(final Matcher arg) {
final int amount = ARG.amount(arg);
return MagicConditionFactory.HandAtMost(amount);
}
},
Hellbent("(you )?have no cards in hand") {
public MagicCondition toCondition(final Matcher arg) {
return MagicCondition.HELLBENT;