mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
* Added log message.
This commit is contained in:
parent
40689fe1b9
commit
4d832326a3
1 changed files with 20 additions and 11 deletions
|
@ -25,13 +25,12 @@
|
||||||
* 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.abilities.effects.common.cost;
|
package mage.abilities.effects.common.cost;
|
||||||
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.constants.ComparisonType;
|
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
|
import mage.constants.ComparisonType;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.filter.common.FilterNonlandCard;
|
import mage.filter.common.FilterNonlandCard;
|
||||||
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
|
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
|
||||||
|
@ -39,12 +38,14 @@ import mage.game.Game;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.Target;
|
import mage.target.Target;
|
||||||
import mage.target.common.TargetCardInHand;
|
import mage.target.common.TargetCardInHand;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author fireshoes - Original Code
|
* @author fireshoes - Original Code
|
||||||
* @author JRHerlehy - Implement as seperate class
|
* @author JRHerlehy - Implement as seperate class
|
||||||
* <p>
|
* <p>
|
||||||
* Allows player to choose to cast as card from hand without paying its mana cost.
|
* Allows player to choose to cast as card from hand without paying its mana
|
||||||
|
* cost.
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public class CastWithoutPayingManaCostEffect extends OneShotEffect {
|
public class CastWithoutPayingManaCostEffect extends OneShotEffect {
|
||||||
|
@ -73,20 +74,28 @@ public class CastWithoutPayingManaCostEffect extends OneShotEffect {
|
||||||
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) return false;
|
if (controller == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Target target = new TargetCardInHand(filter);
|
Target target = new TargetCardInHand(filter);
|
||||||
if (target.canChoose(source.getSourceId(), controller.getId(), game) &&
|
if (target.canChoose(source.getSourceId(), controller.getId(), game)
|
||||||
controller.chooseUse(outcome, "Cast a card with converted mana cost " + manaCost +
|
&& controller.chooseUse(outcome, "Cast a card with converted mana cost " + manaCost
|
||||||
" or less from your hand without paying its mana cost?", source, game)) {
|
+ " or less from your hand without paying its mana cost?", source, game)) {
|
||||||
Card cardToCast = null;
|
Card cardToCast = null;
|
||||||
boolean cancel = false;
|
boolean cancel = false;
|
||||||
while (controller.canRespond() && !cancel) {
|
while (controller.canRespond() && !cancel) {
|
||||||
if (controller.chooseTarget(outcome, target, source, game)) {
|
if (controller.chooseTarget(outcome, target, source, game)) {
|
||||||
cardToCast = game.getCard(target.getFirstTarget());
|
cardToCast = game.getCard(target.getFirstTarget());
|
||||||
if (cardToCast != null && cardToCast.getSpellAbility().canChooseTarget(game)) {
|
if (cardToCast != null) {
|
||||||
|
if (cardToCast.getSpellAbility() == null) {
|
||||||
|
Logger.getLogger(CastWithoutPayingManaCostEffect.class).fatal("Card: " + cardToCast.getName() + " is no land and has no spell ability!");
|
||||||
cancel = true;
|
cancel = true;
|
||||||
}
|
}
|
||||||
|
if (cardToCast.getSpellAbility().canChooseTarget(game)) {
|
||||||
|
cancel = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
cancel = true;
|
cancel = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue