mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 11:32:00 -08:00
put comparing logic in counttype, remove all switches
This commit is contained in:
parent
0adc715499
commit
3d029d6ad5
8 changed files with 66 additions and 145 deletions
|
|
@ -47,7 +47,7 @@ public class PermanentHasCounterCondition implements Condition {
|
|||
private CounterType counterType;
|
||||
private int amount;
|
||||
private FilterPermanent filter;
|
||||
private CountType type;
|
||||
private CountType counttype;
|
||||
private boolean anyPlayer;
|
||||
|
||||
public PermanentHasCounterCondition(CounterType counterType, int amount, FilterPermanent filter) {
|
||||
|
|
@ -59,7 +59,7 @@ public class PermanentHasCounterCondition implements Condition {
|
|||
this.counterType = counterType;
|
||||
this.amount = amount;
|
||||
this.filter = filter;
|
||||
this.type = type;
|
||||
this.counttype = type;
|
||||
this.anyPlayer = false;
|
||||
}
|
||||
|
||||
|
|
@ -67,32 +67,19 @@ public class PermanentHasCounterCondition implements Condition {
|
|||
this.counterType = counterType;
|
||||
this.amount = amount;
|
||||
this.filter = filter;
|
||||
this.type = type;
|
||||
this.counttype = type;
|
||||
this.anyPlayer = any;
|
||||
}
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
List<Permanent> permanents = game.getBattlefield().getActivePermanents(this.filter, source.getControllerId(), game);
|
||||
if(this.anyPlayer == true) {
|
||||
if(this.anyPlayer) {
|
||||
permanents = game.getBattlefield().getAllActivePermanents(this.filter, game);
|
||||
}
|
||||
for (Permanent permanent : permanents) {
|
||||
switch (this.type) {
|
||||
case FEWER_THAN:
|
||||
if (permanent.getCounters(game).getCount(this.counterType) < this.amount) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case MORE_THAN:
|
||||
if (permanent.getCounters(game).getCount(this.counterType) > this.amount) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case EQUAL_TO:
|
||||
if (permanent.getCounters(game).getCount(this.counterType) == this.amount) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
if(CountType.compare(permanent.getCounters(game).getCount(this.counterType), counttype, this.amount))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue