[KHC] updated Hero of Bretagard and Ranar, the Ever-Watchful abilities to match errata

This commit is contained in:
Evan Kranzler 2021-06-12 13:45:58 -04:00
parent 7373009c94
commit c3f4e3cc1b
2 changed files with 71 additions and 64 deletions

View file

@ -13,17 +13,22 @@ import mage.abilities.effects.common.continuous.GainAbilitySourceEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.IndestructibleAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.events.GameEvent;
import java.util.UUID;
import mage.game.events.ZoneChangeGroupEvent;
import java.util.Objects;
import java.util.UUID;
/**
* @author jeffwadsworth
*/
@ -105,43 +110,47 @@ class HeroOfBretagardTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeGroupEvent zEvent = (ZoneChangeGroupEvent) event;
if (zEvent != null
&& Zone.HAND == zEvent.getFromZone()
&& Zone.EXILED == zEvent.getToZone()
&& zEvent.getCards() != null) {
int cardCount = 0;
cardCount = zEvent.getCards().stream().filter((card)
-> (card != null && card.isOwnedBy(getControllerId()))).map((_item)
-> 1).reduce(cardCount, Integer::sum);
if (cardCount == 0) {
return false;
}
this.getEffects().clear();
this.getEffects().add(new AddCountersSourceEffect(CounterType.P1P1.createInstance(cardCount)));
return true;
if (zEvent.getToZone() != Zone.EXILED || zEvent.getCards() == null) {
return false;
}
// the permanent exiled does not have to be controlled/owned by anyone in particular
if (zEvent != null
&& Zone.BATTLEFIELD == zEvent.getFromZone()
&& Zone.EXILED == zEvent.getToZone()
&& zEvent.getCards() != null) {
int cardCount = 0;
cardCount = zEvent.getCards().stream().filter((card)
-> (card != null)).map((_item)
-> 1).reduce(cardCount, Integer::sum);
if (cardCount == 0) {
int cardCount;
switch (zEvent.getFromZone()) {
case BATTLEFIELD:
if (!isControlledBy(game.getControllerId(zEvent.getSourceId()))) {
return false;
}
cardCount = zEvent
.getCards()
.stream()
.filter(Objects::nonNull)
.mapToInt(x -> 1)
.sum();
break;
case HAND:
cardCount = zEvent
.getCards()
.stream()
.filter(Objects::nonNull)
.map(Card::getOwnerId)
.filter(this::isControlledBy)
.mapToInt(x -> 1)
.sum();
break;
default:
return false;
}
this.getEffects().clear();
this.getEffects().add(new AddCountersSourceEffect(CounterType.P1P1.createInstance(cardCount)));
return true;
}
return false;
if (cardCount < 1) {
return false;
}
this.getEffects().clear();
this.getEffects().add(new AddCountersSourceEffect(CounterType.P1P1.createInstance(cardCount)));
return true;
}
@Override
public String getRule() {
return "Whenever you exile one or more cards from your hand and/or permanents from the battlefield, put that many +1/+1 counters on {this}.";
return "Whenever one or more cards are put into exile from your hand " +
"or a spell or ability you control exiles one or more permanents from the battlefield, " +
"put that many +1/+1 counters on {this}.";
}
}

View file

@ -2,27 +2,28 @@ package mage.cards.r;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.ForetellAbility;
import mage.abilities.keyword.VigilanceAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.game.Game;
import java.util.UUID;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.keyword.VigilanceAbility;
import mage.cards.Card;
import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeGroupEvent;
import mage.game.permanent.token.SpiritWhiteToken;
import mage.watchers.common.ForetoldWatcher;
import java.util.Objects;
import java.util.UUID;
/**
* @author jeffwadsworth
*/
@ -118,34 +119,31 @@ class RanarTheEverWatchfulTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeGroupEvent zEvent = (ZoneChangeGroupEvent) event;
if (zEvent != null
&& Zone.HAND == zEvent.getFromZone()
&& Zone.EXILED == zEvent.getToZone()
&& zEvent.getPlayerId() == controllerId
&& zEvent.getCards() != null) {
for (Card card : zEvent.getCards()) {
if (card != null) {
UUID cardOwnerId = card.getOwnerId();
if (cardOwnerId != null
&& card.isOwnedBy(getControllerId())) {
return true;
}
}
}
if (zEvent.getToZone() != Zone.EXILED || zEvent.getCards() == null) {
return false;
}
if (zEvent != null
&& Zone.BATTLEFIELD == zEvent.getFromZone()
&& Zone.EXILED == zEvent.getToZone()
&& zEvent.getPlayerId() == controllerId
&& zEvent.getCards() != null) {
return true;
switch (zEvent.getFromZone()) {
case BATTLEFIELD:
return isControlledBy(game.getControllerId(zEvent.getSourceId()))
&& zEvent
.getCards()
.stream()
.anyMatch(Objects::nonNull);
case HAND:
return zEvent
.getCards()
.stream()
.filter(Objects::nonNull)
.map(Card::getOwnerId)
.anyMatch(this::isControlledBy);
}
return false;
}
@Override
public String getRule() {
return "Whenever you exile one or more cards from your hand and/or permanents from the battlefield, " + super.getRule();
return "Whenever one or more cards are put into exile from your hand " +
"or a spell or ability you control exiles one or more permanents from the battlefield, " +
"create a 1/1 white Spirit creature token with flying.";
}
}