This commit is contained in:
Lymia Aluysia 2016-09-25 14:09:42 -05:00
commit 207cb04dbc
No known key found for this signature in database
GPG key ID: DB2E204C989251F7
6 changed files with 59 additions and 20 deletions

View file

@ -41,9 +41,10 @@ import java.util.List;
*/
public class PermanentHasCounterCondition implements Condition {
public static enum CountType {MORE_THAN, FEWER_THAN, EQUAL_TO}
public static enum CountType {
MORE_THAN, FEWER_THAN, EQUAL_TO
};
;
private CounterType counterType;
private int amount;
private FilterPermanent filter;
@ -62,30 +63,26 @@ public class PermanentHasCounterCondition implements Condition {
@Override
public boolean apply(Game game, Ability source) {
boolean conditionApplies = false;
List<Permanent> permanents = game.getBattlefield().getAllActivePermanents(this.filter, source.getControllerId(), game);
List<Permanent> permanents = game.getBattlefield().getActivePermanents(this.filter, source.getControllerId(), game);
for (Permanent permanent : permanents) {
switch (this.type) {
case FEWER_THAN:
if (permanent.getCounters(game).getCount(this.counterType) < this.amount) {
conditionApplies = true;
break;
return true;
}
break;
case MORE_THAN:
if (permanent.getCounters(game).getCount(this.counterType) > this.amount) {
conditionApplies = true;
break;
return true;
}
break;
case EQUAL_TO:
if (permanent.getCounters(game).getCount(this.counterType) == this.amount) {
conditionApplies = true;
break;
return true;
}
break;
}
}
return conditionApplies;
return false;
}
}