mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
* Wild Evocation - Fixed handling to prevent errors in some cases.
This commit is contained in:
parent
ee890418c5
commit
c87e992e1d
1 changed files with 27 additions and 21 deletions
|
@ -25,10 +25,10 @@
|
|||
* 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;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -51,10 +52,9 @@ import mage.players.Player;
|
|||
public class WildEvocation extends CardImpl {
|
||||
|
||||
public WildEvocation(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{5}{R}");
|
||||
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.
|
||||
//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);
|
||||
Cards cards = new CardsImpl();
|
||||
cards.add(card);
|
||||
player.revealCards("Wild Evocation", cards, game);
|
||||
if (card.isLand()) {
|
||||
card.putOntoBattlefield(game, Zone.HAND, source.getSourceId(), player.getId());
|
||||
}
|
||||
else {
|
||||
player.cast(card.getSpellAbility(), game, true);
|
||||
if (card != null) {
|
||||
Cards cards = new CardsImpl();
|
||||
cards.add(card);
|
||||
player.revealCards(sourceObject.getIdName() + " Turn: " + game.getTurnNum(), cards, game);
|
||||
if (card.isLand()) {
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue