From ce10d2051782551f8756ffc1efd3c8dd64c8a1ce Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Tue, 25 Dec 2018 16:11:20 -0500 Subject: [PATCH] Reworked Rakshasa Vizier triggered ability to only trigger once (fixes #5475) --- .../src/mage/cards/r/RakshasaVizier.java | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/Mage.Sets/src/mage/cards/r/RakshasaVizier.java b/Mage.Sets/src/mage/cards/r/RakshasaVizier.java index 955fc76258..a182dab12a 100644 --- a/Mage.Sets/src/mage/cards/r/RakshasaVizier.java +++ b/Mage.Sets/src/mage/cards/r/RakshasaVizier.java @@ -1,7 +1,6 @@ package mage.cards.r; -import java.util.UUID; import mage.MageInt; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.effects.common.counter.AddCountersSourceEffect; @@ -14,29 +13,28 @@ import mage.constants.Zone; import mage.counters.CounterType; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.ZoneChangeEvent; +import mage.game.events.ZoneChangeGroupEvent; + +import java.util.UUID; /** - * * @author LevelX2 */ public final class RakshasaVizier extends CardImpl { 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.DEMON); - - this.power = 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. - // 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()); } - public RakshasaVizier(final RakshasaVizier card) { + private RakshasaVizier(final RakshasaVizier card) { super(card); } @@ -48,29 +46,35 @@ public final class RakshasaVizier extends CardImpl { class RakshasaVizierTriggeredAbility extends TriggeredAbilityImpl { - public RakshasaVizierTriggeredAbility() { + RakshasaVizierTriggeredAbility() { super(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.P1P1.createInstance()), false); } - public RakshasaVizierTriggeredAbility(final RakshasaVizierTriggeredAbility ability) { + private RakshasaVizierTriggeredAbility(final RakshasaVizierTriggeredAbility ability) { super(ability); } @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.ZONE_CHANGE; + return event.getType() == GameEvent.EventType.ZONE_CHANGE_GROUP; } @Override public boolean checkTrigger(GameEvent event, Game game) { - ZoneChangeEvent zEvent = (ZoneChangeEvent) event; - if (zEvent.getFromZone() == Zone.GRAVEYARD - && zEvent.getToZone() == Zone.EXILED) { - Card card = game.getCard(event.getTargetId()); - if (card != null && card.isOwnedBy(getControllerId())) { - return true; + ZoneChangeGroupEvent zEvent = (ZoneChangeGroupEvent) event; + if (zEvent != null + && Zone.GRAVEYARD == zEvent.getFromZone() + && Zone.EXILED != zEvent.getToZone() + && zEvent.getCards() != null) { + 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; }