more fixes

This commit is contained in:
Evan Kranzler 2019-01-05 17:18:49 -05:00
parent ef38ff10e9
commit 8c2a347f4d
6 changed files with 159 additions and 167 deletions

View file

@ -1,25 +1,12 @@
package mage.cards.a; package mage.cards.a;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneAllEffect; import mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneAllEffect;
import mage.abilities.keyword.CyclingAbility; import mage.abilities.keyword.CyclingAbility;
import mage.cards.Card; import mage.cards.*;
import mage.cards.CardImpl; import mage.constants.*;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.constants.WatcherScope;
import mage.constants.Zone;
import mage.filter.FilterCard; import mage.filter.FilterCard;
import mage.filter.predicate.Predicates; import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.AbilityPredicate; import mage.filter.predicate.mageobject.AbilityPredicate;
@ -31,8 +18,12 @@ import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.watchers.Watcher; import mage.watchers.Watcher;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
/** /**
*
* @author jeffwadsworth * @author jeffwadsworth
*/ */
public final class AbandonedSarcophagus extends CardImpl { public final class AbandonedSarcophagus extends CardImpl {
@ -55,7 +46,7 @@ public final class AbandonedSarcophagus extends CardImpl {
} }
public AbandonedSarcophagus(final AbandonedSarcophagus card) { private AbandonedSarcophagus(final AbandonedSarcophagus card) {
super(card); super(card);
} }
@ -67,15 +58,12 @@ public final class AbandonedSarcophagus extends CardImpl {
class AbandonedSarcophagusReplacementEffect extends ReplacementEffectImpl { class AbandonedSarcophagusReplacementEffect extends ReplacementEffectImpl {
boolean cardHasCycling; AbandonedSarcophagusReplacementEffect() {
boolean cardWasCycledThisTurn;
public AbandonedSarcophagusReplacementEffect() {
super(Duration.WhileOnBattlefield, Outcome.Exile); super(Duration.WhileOnBattlefield, Outcome.Exile);
staticText = "If a card with cycling would be put into your graveyard from anywhere and it wasn't cycled, exile it instead"; staticText = "If a card with cycling would be put into your graveyard from anywhere and it wasn't cycled, exile it instead";
} }
public AbandonedSarcophagusReplacementEffect(final AbandonedSarcophagusReplacementEffect effect) { private AbandonedSarcophagusReplacementEffect(final AbandonedSarcophagusReplacementEffect effect) {
super(effect); super(effect);
} }
@ -112,34 +100,33 @@ class AbandonedSarcophagusReplacementEffect extends ReplacementEffectImpl {
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
cardWasCycledThisTurn = false; boolean cardWasCycledThisTurn = false;
cardHasCycling = false; boolean cardHasCycling = false;
if (((ZoneChangeEvent) event).getToZone() == Zone.GRAVEYARD if (!(((ZoneChangeEvent) event).getToZone() == Zone.GRAVEYARD) || game.isSimulation()) {
&& !game.isSimulation()) { return false;
Player controller = game.getPlayer(source.getControllerId()); }
AbandonedSarcophagusWatcher watcher = (AbandonedSarcophagusWatcher) game.getState().getWatchers().get(AbandonedSarcophagusWatcher.class.getSimpleName()); Player controller = game.getPlayer(source.getControllerId());
Card card = game.getCard(event.getTargetId()); AbandonedSarcophagusWatcher watcher = (AbandonedSarcophagusWatcher) game.getState().getWatchers().get(AbandonedSarcophagusWatcher.class.getSimpleName());
if (card != null Card card = game.getCard(event.getTargetId());
&& controller != null if (card == null
&& watcher != null || controller == null
&& card.isOwnedBy(controller.getId())) { || watcher == null
for (Ability ability : card.getAbilities()) { || !card.isOwnedBy(controller.getId())) {
if (ability instanceof CyclingAbility) { return false;
cardHasCycling = true; }
} for (Ability ability : card.getAbilities()) {
} if (ability instanceof CyclingAbility) {
Cards cards = watcher.getCardsCycledThisTurn(controller.getId()); cardHasCycling = true;
for (Card c : cards.getCards(game)) {
if (c == card) {
cardWasCycledThisTurn = true;
watcher.getCardsCycledThisTurn(controller.getId()).remove(card); //remove reference to the card as it is no longer needed
}
}
return (!cardWasCycledThisTurn
&& cardHasCycling);
} }
} }
return false; Cards cards = watcher.getCardsCycledThisTurn(controller.getId());
for (Card c : cards.getCards(game)) {
if (c == card) {
cardWasCycledThisTurn = true;
watcher.getCardsCycledThisTurn(controller.getId()).remove(card); //remove reference to the card as it is no longer needed
}
}
return !cardWasCycledThisTurn && cardHasCycling;
} }
} }
@ -147,11 +134,11 @@ class AbandonedSarcophagusWatcher extends Watcher {
private final Map<UUID, Cards> cycledCardsThisTurn = new HashMap<>(); private final Map<UUID, Cards> cycledCardsThisTurn = new HashMap<>();
public AbandonedSarcophagusWatcher() { AbandonedSarcophagusWatcher() {
super(AbandonedSarcophagusWatcher.class.getSimpleName(), WatcherScope.GAME); super(AbandonedSarcophagusWatcher.class.getSimpleName(), WatcherScope.GAME);
} }
public AbandonedSarcophagusWatcher(final AbandonedSarcophagusWatcher watcher) { private AbandonedSarcophagusWatcher(final AbandonedSarcophagusWatcher watcher) {
super(watcher); super(watcher);
for (Entry<UUID, Cards> entry : watcher.cycledCardsThisTurn.entrySet()) { for (Entry<UUID, Cards> entry : watcher.cycledCardsThisTurn.entrySet()) {
cycledCardsThisTurn.put(entry.getKey(), entry.getValue().copy()); cycledCardsThisTurn.put(entry.getKey(), entry.getValue().copy());

View file

@ -1,8 +1,6 @@
package mage.cards.a; package mage.cards.a;
import java.util.Optional;
import java.util.UUID;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl; import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
@ -17,8 +15,10 @@ import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.target.TargetPlayer; import mage.target.TargetPlayer;
import java.util.Optional;
import java.util.UUID;
/** /**
*
* @author fireshoes * @author fireshoes
*/ */
public final class Abeyance extends CardImpl { public final class Abeyance extends CardImpl {
@ -46,12 +46,13 @@ public final class Abeyance extends CardImpl {
class AbeyanceEffect extends ContinuousRuleModifyingEffectImpl { class AbeyanceEffect extends ContinuousRuleModifyingEffectImpl {
public AbeyanceEffect() { AbeyanceEffect() {
super(Duration.EndOfTurn, Outcome.Detriment); super(Duration.EndOfTurn, Outcome.Detriment);
staticText = "Until end of turn, target player can't cast instant or sorcery spells, and that player can't activate abilities that aren't mana abilities"; staticText = "Until end of turn, target player can't cast instant or sorcery spells, " +
"and that player can't activate abilities that aren't mana abilities";
} }
public AbeyanceEffect(final AbeyanceEffect effect) { private AbeyanceEffect(final AbeyanceEffect effect) {
super(effect); super(effect);
} }
@ -69,29 +70,30 @@ class AbeyanceEffect extends ContinuousRuleModifyingEffectImpl {
public String getInfoMessage(Ability source, GameEvent event, Game game) { public String getInfoMessage(Ability source, GameEvent event, Game game) {
MageObject mageObject = game.getObject(source.getSourceId()); MageObject mageObject = game.getObject(source.getSourceId());
if (mageObject != null) { if (mageObject != null) {
return "You can't cast instant or sorcery spells or activate abilities that aren't mana abilities this turn (" + mageObject.getIdName() + ")."; return "You can't cast instant or sorcery spells or activate abilities " +
"that aren't mana abilities this turn (" + mageObject.getIdName() + ").";
} }
return null; return null;
} }
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (source.getFirstTarget() != null && source.getFirstTarget().equals(event.getPlayerId())) { if (source.getFirstTarget() != null
MageObject object = game.getObject(event.getSourceId()); && source.getFirstTarget().equals(event.getPlayerId())) {
if(object == null){ return false;
return false; }
} MageObject object = game.getObject(event.getSourceId());
if (event.getType() == GameEvent.EventType.CAST_SPELL) { if (object == null) {
if (object.isInstant() || object.isSorcery()) { return false;
return true; }
} if (event.getType() == GameEvent.EventType.CAST_SPELL
} && (object.isInstant() || object.isSorcery())) {
if (event.getType() == GameEvent.EventType.ACTIVATE_ABILITY) { return true;
Optional<Ability> ability = game.getAbility(event.getTargetId(), event.getSourceId()); }
if (ability.isPresent() && !(ability.get() instanceof ActivatedManaAbilityImpl)) { if (event.getType() == GameEvent.EventType.ACTIVATE_ABILITY) {
return true; Optional<Ability> ability = game.getAbility(event.getTargetId(), event.getSourceId());
} return ability != null && ability.isPresent()
} && !(ability.get() instanceof ActivatedManaAbilityImpl);
} }
return false; return false;
} }

View file

@ -1,7 +1,6 @@
package mage.cards.a; package mage.cards.a;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
@ -17,23 +16,23 @@ import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.filter.predicate.permanent.ControllerPredicate; import mage.filter.predicate.permanent.ControllerPredicate;
import mage.filter.predicate.permanent.CounterPredicate; import mage.filter.predicate.permanent.CounterPredicate;
import java.util.UUID;
/** /**
*
* @author LevelX2 * @author LevelX2
*/ */
public final class AbzanBattlePriest extends CardImpl { public final class AbzanBattlePriest extends CardImpl {
private static final FilterPermanent filter = new FilterPermanent(); private static final FilterPermanent filter = new FilterPermanent();
static { static {
filter.add(new CardTypePredicate(CardType.CREATURE)); filter.add(new CardTypePredicate(CardType.CREATURE));
filter.add(new ControllerPredicate(TargetController.YOU)); filter.add(new ControllerPredicate(TargetController.YOU));
filter.add(new CounterPredicate(CounterType.P1P1)); filter.add(new CounterPredicate(CounterType.P1P1));
} }
static final String rule = "Each creature you control with a +1/+1 counter on it has lifelink";
public AbzanBattlePriest(UUID ownerId, CardSetInfo setInfo) { public AbzanBattlePriest(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{W}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{W}");
this.subtype.add(SubType.HUMAN); this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.CLERIC); this.subtype.add(SubType.CLERIC);
@ -42,9 +41,15 @@ public final class AbzanBattlePriest extends CardImpl {
// Outlast {W} // Outlast {W}
this.addAbility(new OutlastAbility(new ManaCostsImpl<>("{W}"))); this.addAbility(new OutlastAbility(new ManaCostsImpl<>("{W}")));
// Each creature you control with a +1/+1 counter on it has lifelink. // Each creature you control with a +1/+1 counter on it has lifelink.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAllEffect(LifelinkAbility.getInstance(), Duration.WhileOnBattlefield, filter, rule))); this.addAbility(new SimpleStaticAbility(
Zone.BATTLEFIELD,
new GainAbilityAllEffect(
LifelinkAbility.getInstance(), Duration.WhileOnBattlefield,
filter, "Each creature you control with a +1/+1 counter on it has lifelink"
)
));
} }
public AbzanBattlePriest(final AbzanBattlePriest card) { public AbzanBattlePriest(final AbzanBattlePriest card) {

View file

@ -1,8 +1,6 @@
package mage.cards.a; package mage.cards.a;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.Mode; import mage.abilities.Mode;
@ -22,6 +20,8 @@ import mage.players.Player;
import mage.target.Target; import mage.target.Target;
import mage.util.CardUtil; import mage.util.CardUtil;
import java.util.UUID;
/** /**
* @author halljared * @author halljared
*/ */
@ -44,7 +44,7 @@ public final class AccursedWitch extends CardImpl {
this.addAbility(new DiesTriggeredAbility(new AccursedWitchReturnTransformedEffect())); this.addAbility(new DiesTriggeredAbility(new AccursedWitchReturnTransformedEffect()));
} }
public AccursedWitch(final AccursedWitch card) { private AccursedWitch(final AccursedWitch card) {
super(card); super(card);
} }
@ -56,12 +56,12 @@ public final class AccursedWitch extends CardImpl {
class AccursedWitchReturnTransformedEffect extends OneShotEffect { class AccursedWitchReturnTransformedEffect extends OneShotEffect {
public AccursedWitchReturnTransformedEffect() { AccursedWitchReturnTransformedEffect() {
super(Outcome.PutCardInPlay); super(Outcome.PutCardInPlay);
this.staticText = "Put {this} from your graveyard onto the battlefield transformed"; this.staticText = "Put {this} from your graveyard onto the battlefield transformed";
} }
public AccursedWitchReturnTransformedEffect(final AccursedWitchReturnTransformedEffect effect) { private AccursedWitchReturnTransformedEffect(final AccursedWitchReturnTransformedEffect effect) {
super(effect); super(effect);
} }
@ -73,29 +73,27 @@ class AccursedWitchReturnTransformedEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller == null || !(game.getState().getZone(source.getSourceId()) == Zone.GRAVEYARD)) {
if (game.getState().getZone(source.getSourceId()) == Zone.GRAVEYARD) { return false;
game.getState().setValue(TransformAbility.VALUE_KEY_ENTER_TRANSFORMED + source.getSourceId(), Boolean.TRUE);
//note: should check for null after game.getCard
Card card = game.getCard(source.getSourceId());
if (card != null) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
return true;
} }
return false; game.getState().setValue(TransformAbility.VALUE_KEY_ENTER_TRANSFORMED + source.getSourceId(), Boolean.TRUE);
//note: should check for null after game.getCard
Card card = game.getCard(source.getSourceId());
if (card != null) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
return true;
} }
} }
class AccursedWitchSpellsCostReductionEffect extends CostModificationEffectImpl { class AccursedWitchSpellsCostReductionEffect extends CostModificationEffectImpl {
public AccursedWitchSpellsCostReductionEffect() { AccursedWitchSpellsCostReductionEffect() {
super(Duration.WhileOnBattlefield, Outcome.Detriment, CostModificationType.REDUCE_COST); super(Duration.WhileOnBattlefield, Outcome.Detriment, CostModificationType.REDUCE_COST);
this.staticText = "Spells your opponents cast that target {this} cost {1} less to cast."; this.staticText = "Spells your opponents cast that target {this} cost {1} less to cast.";
} }
protected AccursedWitchSpellsCostReductionEffect(AccursedWitchSpellsCostReductionEffect effect) { private AccursedWitchSpellsCostReductionEffect(AccursedWitchSpellsCostReductionEffect effect) {
super(effect); super(effect);
} }
@ -107,17 +105,16 @@ class AccursedWitchSpellsCostReductionEffect extends CostModificationEffectImpl
@Override @Override
public boolean applies(Ability abilityToModify, Ability source, Game game) { public boolean applies(Ability abilityToModify, Ability source, Game game) {
if (abilityToModify instanceof SpellAbility) { if (!(abilityToModify instanceof SpellAbility) || !game.getOpponents(source.getControllerId()).contains(abilityToModify.getControllerId())) {
if (game.getOpponents(source.getControllerId()).contains(abilityToModify.getControllerId())) { return false;
for (UUID modeId : abilityToModify.getModes().getSelectedModes()) { }
Mode mode = abilityToModify.getModes().get(modeId); for (UUID modeId : abilityToModify.getModes().getSelectedModes()) {
for (Target target : mode.getTargets()) { Mode mode = abilityToModify.getModes().get(modeId);
for (UUID targetUUID : target.getTargets()) { for (Target target : mode.getTargets()) {
Permanent permanent = game.getPermanent(targetUUID); for (UUID targetUUID : target.getTargets()) {
if (permanent != null && permanent.getId().equals(source.getSourceId())) { Permanent permanent = game.getPermanent(targetUUID);
return true; if (permanent != null && permanent.getId().equals(source.getSourceId())) {
} return true;
}
} }
} }
} }

View file

@ -1,7 +1,6 @@
package mage.cards.a; package mage.cards.a;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility; import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
@ -25,8 +24,9 @@ import mage.players.Player;
import mage.target.common.TargetCardInLibrary; import mage.target.common.TargetCardInLibrary;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
/** /**
*
* @author L_J * @author L_J
*/ */
public final class AchHansRun extends CardImpl { public final class AchHansRun extends CardImpl {
@ -38,7 +38,7 @@ public final class AchHansRun extends CardImpl {
this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new AchHansRunEffect(), TargetController.YOU, true)); this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new AchHansRunEffect(), TargetController.YOU, true));
} }
public AchHansRun(final AchHansRun card) { private AchHansRun(final AchHansRun card) {
super(card); super(card);
} }
@ -50,12 +50,12 @@ public final class AchHansRun extends CardImpl {
class AchHansRunEffect extends OneShotEffect { class AchHansRunEffect extends OneShotEffect {
public AchHansRunEffect() { AchHansRunEffect() {
super(Outcome.PutCreatureInPlay); super(Outcome.PutCreatureInPlay);
this.staticText = "you may say \"Ach! Hans, run! Its the …\" and the name of a creature card. If you do, search your library for a card with that name, put it onto the battlefield, then shuffle your library. That creature gains haste. Exile it at the beginning of the next end step"; this.staticText = "you may say \"Ach! Hans, run! Its the …\" and the name of a creature card. If you do, search your library for a card with that name, put it onto the battlefield, then shuffle your library. That creature gains haste. Exile it at the beginning of the next end step";
} }
public AchHansRunEffect(final AchHansRunEffect effect) { private AchHansRunEffect(final AchHansRunEffect effect) {
super(effect); super(effect);
} }
@ -67,41 +67,41 @@ class AchHansRunEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller == null) {
ChoiceImpl cardChoice = new ChoiceImpl(true); return false;
cardChoice.setChoices(CardRepository.instance.getCreatureNames());
cardChoice.setMessage("Choose a creature card name");
if (controller.choose(Outcome.Detriment, cardChoice, game)) {
String cardName = cardChoice.getChoice();
if (!game.isSimulation()) {
game.informPlayers(controller.getLogName() + ": \"Ach! Hans, run! It's the " + cardName + "!\"");
}
FilterCard nameFilter = new FilterCard();
nameFilter.add(new NamePredicate(cardName));
TargetCardInLibrary target = new TargetCardInLibrary(1, 1, nameFilter);
if (controller.searchLibrary(target, game)) {
Card card = controller.getLibrary().remove(target.getFirstTarget(), game);
if (card != null) {
if (card != null && controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
Permanent creature = game.getPermanent(card.getId());
if (creature != null) {
// gains haste
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(creature, game));
game.addEffect(effect, source);
// Exile at begin of next end step
ExileTargetEffect exileEffect = new ExileTargetEffect(null, null, Zone.BATTLEFIELD);
exileEffect.setTargetPointer(new FixedTarget(creature, game));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect);
game.addDelayedTriggeredAbility(delayedAbility, source);
}
}
}
controller.shuffleLibrary(source, game);
}
return true;
}
} }
return false; ChoiceImpl cardChoice = new ChoiceImpl(true);
cardChoice.setChoices(CardRepository.instance.getCreatureNames());
cardChoice.setMessage("Choose a creature card name");
if (!controller.choose(Outcome.Detriment, cardChoice, game)) {
return false;
}
String cardName = cardChoice.getChoice();
game.informPlayers(controller.getLogName() + ": \"Ach! Hans, run! It's the " + cardName + "!\"");
FilterCard nameFilter = new FilterCard();
nameFilter.add(new NamePredicate(cardName));
TargetCardInLibrary target = new TargetCardInLibrary(1, 1, nameFilter);
if (!controller.searchLibrary(target, game)) {
return false;
}
Card card = controller.getLibrary().remove(target.getFirstTarget(), game);
if (card == null || !controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
return false;
}
Permanent creature = game.getPermanent(card.getId());
if (creature == null) {
return false;
}
// gains haste
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(creature, game));
game.addEffect(effect, source);
// Exile at begin of next end step
ExileTargetEffect exileEffect = new ExileTargetEffect(null, null, Zone.BATTLEFIELD);
exileEffect.setTargetPointer(new FixedTarget(creature, game));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect);
game.addDelayedTriggeredAbility(delayedAbility, source);
controller.shuffleLibrary(source, game);
return true;
} }
} }

View file

@ -1,7 +1,6 @@
package mage.cards.a; package mage.cards.a;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.SpellAbility; import mage.abilities.SpellAbility;
@ -23,14 +22,15 @@ import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.target.common.TargetAnyTarget; import mage.target.common.TargetAnyTarget;
import java.util.UUID;
/** /**
*
* @author Loki * @author Loki
*/ */
public final class ApocalypseHydra extends CardImpl { public final class ApocalypseHydra extends CardImpl {
public ApocalypseHydra(UUID ownerId, CardSetInfo setInfo) { public ApocalypseHydra(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{X}{R}{G}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{X}{R}{G}");
this.subtype.add(SubType.HYDRA); this.subtype.add(SubType.HYDRA);
this.power = new MageInt(0); this.power = new MageInt(0);
@ -46,7 +46,7 @@ public final class ApocalypseHydra extends CardImpl {
this.addAbility(ability); this.addAbility(ability);
} }
public ApocalypseHydra(final ApocalypseHydra card) { private ApocalypseHydra(final ApocalypseHydra card) {
super(card); super(card);
} }
@ -63,7 +63,7 @@ class ApocalypseHydraEffect extends OneShotEffect {
staticText = "with X +1/+1 counters on it. If X is 5 or more, it enters the battlefield with an additional X +1/+1 counters on it"; staticText = "with X +1/+1 counters on it. If X is 5 or more, it enters the battlefield with an additional X +1/+1 counters on it";
} }
ApocalypseHydraEffect(final ApocalypseHydraEffect effect) { private ApocalypseHydraEffect(final ApocalypseHydraEffect effect) {
super(effect); super(effect);
} }
@ -71,20 +71,21 @@ class ApocalypseHydraEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanentEntering(source.getSourceId()); Permanent permanent = game.getPermanentEntering(source.getSourceId());
if (permanent != null) { if (permanent != null) {
SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY); return false;
if (spellAbility != null }
&& spellAbility.getSourceId().equals(source.getSourceId()) SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
&& permanent.getZoneChangeCounter(game) == spellAbility.getSourceObjectZoneChangeCounter()) { if (spellAbility == null
int amount = spellAbility.getManaCostsToPay().getX(); || !spellAbility.getSourceId().equals(source.getSourceId())
if (amount > 0) { || permanent.getZoneChangeCounter(game) != spellAbility.getSourceObjectZoneChangeCounter()) {
if (amount < 5) { return false;
permanent.addCounters(CounterType.P1P1.createInstance(amount), source, game); }
} else { int amount = spellAbility.getManaCostsToPay().getX();
permanent.addCounters(CounterType.P1P1.createInstance(amount * 2), source, game); if (amount > 0) {
} if (amount < 5) {
} permanent.addCounters(CounterType.P1P1.createInstance(amount), source, game);
} else {
permanent.addCounters(CounterType.P1P1.createInstance(amount * 2), source, game);
} }
return true;
} }
return true; return true;
} }