[MKC] Implement Watcher of Hours (#11808)

This commit is contained in:
PurpleCrowbar 2024-02-17 18:30:00 +00:00 committed by GitHub
parent c470598080
commit 4e648a29a9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 66 additions and 3 deletions

View file

@ -1,4 +1,3 @@
package mage.abilities.common;
import mage.abilities.TriggeredAbilityImpl;
@ -14,20 +13,29 @@ import mage.game.events.GameEvent;
public class CounterRemovedFromSourceWhileExiledTriggeredAbility extends TriggeredAbilityImpl {
private final CounterType counterType;
private final boolean onlyController;
public CounterRemovedFromSourceWhileExiledTriggeredAbility(CounterType counterType, Effect effect) {
this(counterType, effect, false);
}
public CounterRemovedFromSourceWhileExiledTriggeredAbility(CounterType counterType, Effect effect, boolean optional) {
this(counterType, effect, optional, false);
}
public CounterRemovedFromSourceWhileExiledTriggeredAbility(CounterType counterType, Effect effect, boolean optional, boolean onlyController) {
super(Zone.EXILED, effect, optional);
this.counterType = counterType;
setTriggerPhrase("Whenever a " + counterType.getName() + " counter is removed from {this} while it's exiled, ");
this.onlyController = onlyController;
setTriggerPhrase("Whenever " + (
onlyController ? ("you remove a " + counterType.getName() + " counter") : ("a " + counterType.getName() + " counter is removed")
) + " from {this} while it's exiled, ");
}
private CounterRemovedFromSourceWhileExiledTriggeredAbility(final CounterRemovedFromSourceWhileExiledTriggeredAbility ability) {
super(ability);
this.counterType = ability.counterType;
this.onlyController = ability.onlyController;
}
@Override
@ -42,6 +50,8 @@ public class CounterRemovedFromSourceWhileExiledTriggeredAbility extends Trigger
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return event.getData().equals(counterType.getName()) && event.getTargetId().equals(this.getSourceId());
return event.getData().equals(counterType.getName())
&& event.getTargetId().equals(this.getSourceId())
&& (!onlyController || event.getPlayerId().equals(getControllerId()));
}
}