mirror of
https://github.com/correl/mage.git
synced 2024-12-26 19:16:54 +00:00
Merge pull request #4437 from SpikesCafe-google/master
Fix Reyhan death trigger (fixes #4055)
This commit is contained in:
commit
a0b6c36512
1 changed files with 31 additions and 12 deletions
|
@ -47,6 +47,7 @@ import mage.game.events.GameEvent;
|
|||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
/**
|
||||
|
@ -108,19 +109,37 @@ class ReyhanLastOfTheAbzanTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if ((((ZoneChangeEvent) event).getToZone() == Zone.GRAVEYARD || ((ZoneChangeEvent) event).getToZone() == Zone.COMMAND)
|
||||
&& ((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD) {
|
||||
Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
|
||||
if (permanent.getControllerId().equals(this.getControllerId()) && permanent.isCreature()) {
|
||||
int countersOn = permanent.getCounters(game).getCount(CounterType.P1P1);
|
||||
if (countersOn > 0) {
|
||||
this.getEffects().clear();
|
||||
this.addEffect(new AddCountersTargetEffect(CounterType.P1P1.createInstance(countersOn)));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
ZoneChangeEvent zcEvent = (ZoneChangeEvent) event;
|
||||
// Dies or is put in the command zone
|
||||
if (zcEvent.getFromZone() != Zone.BATTLEFIELD) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
if (zcEvent.getToZone() != Zone.GRAVEYARD && zcEvent.getToZone() != Zone.COMMAND) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// A creature
|
||||
Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
|
||||
if (permanent == null || !permanent.isCreature()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// You control
|
||||
Player player = game.getPlayer(this.getControllerId());
|
||||
if (player == null || !player.getId().equals(this.getControllerId())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If it had one or more +1/+1 counters on it
|
||||
int countersOn = permanent.getCounters(game).getCount(CounterType.P1P1);
|
||||
if (countersOn == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// You may put that may +1/+1 counters on target creature
|
||||
this.getEffects().clear();
|
||||
this.addEffect(new AddCountersTargetEffect(CounterType.P1P1.createInstance(countersOn)));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue