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
|
@ -1,16 +1,16 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification, are
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
* permitted provided that the following conditions are met:
|
* permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
* conditions and the following disclaimer.
|
* conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
* provided with the distribution.
|
* provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||||
|
@ -20,15 +20,15 @@
|
||||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* The views and conclusions contained in the software and documentation are those of the
|
* The views and conclusions contained in the software and documentation are those of the
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.cards.w;
|
package mage.cards.w;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
@ -43,6 +43,7 @@ import mage.constants.TargetController;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
import mage.util.GameLog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -51,10 +52,9 @@ import mage.players.Player;
|
||||||
public class WildEvocation extends CardImpl {
|
public class WildEvocation extends CardImpl {
|
||||||
|
|
||||||
public WildEvocation(UUID ownerId, CardSetInfo setInfo) {
|
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));
|
this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new WildEvocationEffect(), TargetController.ANY, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,9 @@ class WildEvocationEffect extends OneShotEffect {
|
||||||
|
|
||||||
public WildEvocationEffect() {
|
public WildEvocationEffect() {
|
||||||
super(Outcome.PutCardInPlay);
|
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) {
|
public WildEvocationEffect(final WildEvocationEffect effect) {
|
||||||
|
@ -83,16 +85,21 @@ class WildEvocationEffect extends OneShotEffect {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player player = game.getPlayer(targetPointer.getFirst(game, 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);
|
Card card = player.getHand().getRandom(game);
|
||||||
Cards cards = new CardsImpl();
|
if (card != null) {
|
||||||
cards.add(card);
|
Cards cards = new CardsImpl();
|
||||||
player.revealCards("Wild Evocation", cards, game);
|
cards.add(card);
|
||||||
if (card.isLand()) {
|
player.revealCards(sourceObject.getIdName() + " Turn: " + game.getTurnNum(), cards, game);
|
||||||
card.putOntoBattlefield(game, Zone.HAND, source.getSourceId(), player.getId());
|
if (card.isLand()) {
|
||||||
}
|
player.moveCards(card, Zone.BATTLEFIELD, source, game);
|
||||||
else {
|
} else if (card.getSpellAbility() != null
|
||||||
player.cast(card.getSpellAbility(), game, true);
|
&& 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -103,5 +110,4 @@ class WildEvocationEffect extends OneShotEffect {
|
||||||
public WildEvocationEffect copy() {
|
public WildEvocationEffect copy() {
|
||||||
return new WildEvocationEffect(this);
|
return new WildEvocationEffect(this);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue