* Wild Evocation - Fixed handling to prevent errors in some cases.
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
-
package mage.cards.w;
import java.util.UUID;
+import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
@@ -43,6 +43,7 @@ import mage.constants.TargetController;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
+import mage.util.GameLog;
/**
*
@@ -53,7 +54,6 @@ public class WildEvocation extends CardImpl {
public WildEvocation(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{5}{R}");
-
//At the beginning of each player's upkeep, that player reveals a card at random from his or her hand. If it's a land card, the player puts it onto the battlefield. Otherwise, the player casts it without paying its mana cost if able.
this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new WildEvocationEffect(), TargetController.ANY, false));
}
@@ -73,7 +73,9 @@ class WildEvocationEffect extends OneShotEffect {
public WildEvocationEffect() {
super(Outcome.PutCardInPlay);
- staticText = "that player reveals a card at random from his or her hand. If it's a land card, that player puts it onto the battlefield. Otherwise, the player casts it without paying its mana cost if able";
+ staticText = "that player reveals a card at random from his or her hand. "
+ + "If it's a land card, that player puts it onto the battlefield. "
+ + "Otherwise, the player casts it without paying its mana cost if able";
}
public WildEvocationEffect(final WildEvocationEffect effect) {
@@ -83,16 +85,21 @@ class WildEvocationEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source));
- if (player != null && !player.getHand().isEmpty()) {
+ MageObject sourceObject = source.getSourceObject(game);
+ if (player != null && sourceObject != null) {
Card card = player.getHand().getRandom(game);
+ if (card != null) {
Cards cards = new CardsImpl();
cards.add(card);
- player.revealCards("Wild Evocation", cards, game);
+ player.revealCards(sourceObject.getIdName() + " Turn: " + game.getTurnNum(), cards, game);
if (card.isLand()) {
- card.putOntoBattlefield(game, Zone.HAND, source.getSourceId(), player.getId());
- }
- else {
+ player.moveCards(card, Zone.BATTLEFIELD, source, game);
+ } else if (card.getSpellAbility() != null
+ && card.getSpellAbility().getTargets().canChoose(player.getId(), game)) {
player.cast(card.getSpellAbility(), game, true);
+ } else {
+ game.informPlayers(GameLog.getColoredObjectName(card) + " can't be cast now by " + player.getLogName());
+ }
}
return true;
}
@@ -103,5 +110,4 @@ class WildEvocationEffect extends OneShotEffect {
public WildEvocationEffect copy() {
return new WildEvocationEffect(this);
}
-
}
