mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 03:51:58 -08:00
combined "one more more counters added" triggers into a single class
This commit is contained in:
parent
563028043c
commit
0608d2cf3d
3 changed files with 67 additions and 89 deletions
|
|
@ -0,0 +1,53 @@
|
|||
package mage.abilities.common;
|
||||
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
public class OneOrMoreCountersAddedTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
private final CounterType counterType;
|
||||
|
||||
public OneOrMoreCountersAddedTriggeredAbility(Effect effect) {
|
||||
this(effect, false);
|
||||
}
|
||||
|
||||
public OneOrMoreCountersAddedTriggeredAbility(Effect effect, boolean optional) {
|
||||
this(effect, optional, CounterType.P1P1);
|
||||
}
|
||||
|
||||
public OneOrMoreCountersAddedTriggeredAbility(Effect effect, boolean optional, CounterType counterType) {
|
||||
super(Zone.BATTLEFIELD, effect, true);
|
||||
this.counterType = counterType;
|
||||
}
|
||||
|
||||
private OneOrMoreCountersAddedTriggeredAbility(final OneOrMoreCountersAddedTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.counterType = ability.counterType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OneOrMoreCountersAddedTriggeredAbility copy() {
|
||||
return new OneOrMoreCountersAddedTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.COUNTERS_ADDED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
return event.getData().equals(counterType.getName())
|
||||
&& event.getAmount() > 0
|
||||
&& event.getTargetId().equals(this.getSourceId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever one or more " + counterType + " counters are put on {this}, " + super.getRule();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue