Reworked Rakshasa Vizier triggered ability to only trigger once (fixes #5475)

This commit is contained in:
Evan Kranzler 2018-12-25 16:11:20 -05:00
parent e45dda28a9
commit ce10d20517

View file

@ -1,7 +1,6 @@
package mage.cards.r; package mage.cards.r;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect;
@ -14,29 +13,28 @@ import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent; import mage.game.events.ZoneChangeGroupEvent;
import java.util.UUID;
/** /**
*
* @author LevelX2 * @author LevelX2
*/ */
public final class RakshasaVizier extends CardImpl { public final class RakshasaVizier extends CardImpl {
public RakshasaVizier(UUID ownerId, CardSetInfo setInfo) { public RakshasaVizier(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{B}{G}{U}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{B}{G}{U}");
this.subtype.add(SubType.CAT); this.subtype.add(SubType.CAT);
this.subtype.add(SubType.DEMON); this.subtype.add(SubType.DEMON);
this.power = new MageInt(4); this.power = new MageInt(4);
this.toughness = new MageInt(4); this.toughness = new MageInt(4);
// Whenever one or more cards are put into exile from your graveyard, put that many +1/+1 counters on Rakshasa Vizier. // Whenever one or more cards are put into exile from your graveyard, put that many +1/+1 counters on Rakshasa Vizier.
// TODO: Handle effects that move more than one card with one trigger (e.g. if opponent want to counter a trigger, he has now to counter multiple instead of one).
this.addAbility(new RakshasaVizierTriggeredAbility()); this.addAbility(new RakshasaVizierTriggeredAbility());
} }
public RakshasaVizier(final RakshasaVizier card) { private RakshasaVizier(final RakshasaVizier card) {
super(card); super(card);
} }
@ -48,29 +46,35 @@ public final class RakshasaVizier extends CardImpl {
class RakshasaVizierTriggeredAbility extends TriggeredAbilityImpl { class RakshasaVizierTriggeredAbility extends TriggeredAbilityImpl {
public RakshasaVizierTriggeredAbility() { RakshasaVizierTriggeredAbility() {
super(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.P1P1.createInstance()), false); super(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.P1P1.createInstance()), false);
} }
public RakshasaVizierTriggeredAbility(final RakshasaVizierTriggeredAbility ability) { private RakshasaVizierTriggeredAbility(final RakshasaVizierTriggeredAbility ability) {
super(ability); super(ability);
} }
@Override @Override
public boolean checkEventType(GameEvent event, Game game) { public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.ZONE_CHANGE; return event.getType() == GameEvent.EventType.ZONE_CHANGE_GROUP;
} }
@Override @Override
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event; ZoneChangeGroupEvent zEvent = (ZoneChangeGroupEvent) event;
if (zEvent.getFromZone() == Zone.GRAVEYARD if (zEvent != null
&& zEvent.getToZone() == Zone.EXILED) { && Zone.GRAVEYARD == zEvent.getFromZone()
Card card = game.getCard(event.getTargetId()); && Zone.EXILED != zEvent.getToZone()
if (card != null && card.isOwnedBy(getControllerId())) { && zEvent.getCards() != null) {
return true; int cardCount = 0;
for (Card card : zEvent.getCards()) {
if (card != null && card.isOwnedBy(getControllerId())) {
cardCount++;
}
} }
this.getEffects().clear();
this.getEffects().add(new AddCountersSourceEffect(CounterType.P1P1.createInstance(cardCount)));
return true;
} }
return false; return false;
} }