mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 11:32:00 -08:00
Little refactor of PermanentHasCounterCondition
This commit is contained in:
parent
e6a258dd63
commit
f18e4b66f1
2 changed files with 10 additions and 14 deletions
|
|
@ -36,12 +36,11 @@ import mage.abilities.condition.common.PermanentHasCounterCondition;
|
||||||
import mage.abilities.keyword.FlyingAbility;
|
import mage.abilities.keyword.FlyingAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.counters.CounterType;
|
import mage.counters.CounterType;
|
||||||
import mage.filter.common.FilterCreaturePermanent;
|
|
||||||
import mage.abilities.effects.common.continuous.BoostSourceEffect;
|
import mage.abilities.effects.common.continuous.BoostSourceEffect;
|
||||||
import mage.abilities.decorator.ConditionalContinuousEffect;
|
import mage.abilities.decorator.ConditionalContinuousEffect;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
|
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -64,7 +63,7 @@ public class ChampionsDrake extends CardImpl {
|
||||||
this.addAbility(FlyingAbility.getInstance());
|
this.addAbility(FlyingAbility.getInstance());
|
||||||
|
|
||||||
// Champion's Drake gets +3/+3 as long as you control a creature with three or more level counters on it.
|
// Champion's Drake gets +3/+3 as long as you control a creature with three or more level counters on it.
|
||||||
ConditionalContinuousEffect effect = new ConditionalContinuousEffect(new BoostSourceEffect(3, 3, Duration.WhileOnBattlefield), new PermanentHasCounterCondition(CounterType.LEVEL, 2, new FilterCreaturePermanent(), PermanentHasCounterCondition.CountType.MORE_THAN), rule);
|
ConditionalContinuousEffect effect = new ConditionalContinuousEffect(new BoostSourceEffect(3, 3, Duration.WhileOnBattlefield), new PermanentHasCounterCondition(CounterType.LEVEL, 2, new FilterControlledCreaturePermanent(), PermanentHasCounterCondition.CountType.MORE_THAN), rule);
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
|
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,9 +41,10 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public class PermanentHasCounterCondition implements Condition {
|
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 CounterType counterType;
|
||||||
private int amount;
|
private int amount;
|
||||||
private FilterPermanent filter;
|
private FilterPermanent filter;
|
||||||
|
|
@ -62,30 +63,26 @@ public class PermanentHasCounterCondition implements Condition {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
boolean conditionApplies = false;
|
List<Permanent> permanents = game.getBattlefield().getActivePermanents(this.filter, source.getControllerId(), game);
|
||||||
List<Permanent> permanents = game.getBattlefield().getAllActivePermanents(this.filter, source.getControllerId(), game);
|
|
||||||
for (Permanent permanent : permanents) {
|
for (Permanent permanent : permanents) {
|
||||||
switch (this.type) {
|
switch (this.type) {
|
||||||
case FEWER_THAN:
|
case FEWER_THAN:
|
||||||
if (permanent.getCounters(game).getCount(this.counterType) < this.amount) {
|
if (permanent.getCounters(game).getCount(this.counterType) < this.amount) {
|
||||||
conditionApplies = true;
|
return true;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MORE_THAN:
|
case MORE_THAN:
|
||||||
if (permanent.getCounters(game).getCount(this.counterType) > this.amount) {
|
if (permanent.getCounters(game).getCount(this.counterType) > this.amount) {
|
||||||
conditionApplies = true;
|
return true;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EQUAL_TO:
|
case EQUAL_TO:
|
||||||
if (permanent.getCounters(game).getCount(this.counterType) == this.amount) {
|
if (permanent.getCounters(game).getCount(this.counterType) == this.amount) {
|
||||||
conditionApplies = true;
|
return true;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return conditionApplies;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue