mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 20:11:59 -08:00
* refactor all instances of getRule in triggered abilities using new getTriggerPrefix method * updated triggered ability rules generation * renamed method * fixed a test failure * some more refactoring * simplified some instances of ability word usage
57 lines
1.8 KiB
Java
57 lines
1.8 KiB
Java
|
|
package mage.abilities.common;
|
|
|
|
import mage.constants.ComparisonType;
|
|
import mage.abilities.StateTriggeredAbility;
|
|
import mage.abilities.effects.Effect;
|
|
import mage.constants.Zone;
|
|
import mage.filter.FilterPermanent;
|
|
import mage.game.Game;
|
|
import mage.game.events.GameEvent;
|
|
|
|
/**
|
|
* State triggered ability that triggers if the ability controller controlls the
|
|
* defined number of permanents.
|
|
*
|
|
* @author LevelX2
|
|
*/
|
|
public class ControlsPermanentsControllerTriggeredAbility extends StateTriggeredAbility {
|
|
|
|
protected final FilterPermanent filter;
|
|
protected final ComparisonType type;
|
|
protected final int value;
|
|
|
|
public ControlsPermanentsControllerTriggeredAbility(FilterPermanent filter, Effect effect){
|
|
this(filter, ComparisonType.MORE_THAN, 0, effect);
|
|
}
|
|
|
|
public ControlsPermanentsControllerTriggeredAbility(FilterPermanent filter, ComparisonType type, int value, Effect effect) {
|
|
super(Zone.BATTLEFIELD, effect);
|
|
this.filter = filter;
|
|
this.value = value;
|
|
this.type = type;
|
|
}
|
|
|
|
public ControlsPermanentsControllerTriggeredAbility(final ControlsPermanentsControllerTriggeredAbility ability) {
|
|
super(ability);
|
|
this.filter = ability.filter;
|
|
this.type = ability.type;
|
|
this.value = ability.value;
|
|
}
|
|
|
|
@Override
|
|
public ControlsPermanentsControllerTriggeredAbility copy() {
|
|
return new ControlsPermanentsControllerTriggeredAbility(this);
|
|
}
|
|
|
|
@Override
|
|
public boolean checkTrigger(GameEvent event, Game game) {
|
|
int inputValue = game.getBattlefield().countAll(filter, getControllerId(), game);
|
|
return ComparisonType.compare(inputValue, type, value);
|
|
}
|
|
|
|
@Override
|
|
public String getTriggerPhrase() {
|
|
return "When you control " + filter.getMessage() + ", " ;
|
|
}
|
|
}
|