mirror of
https://github.com/correl/mage.git
synced 2024-12-25 19:25:41 +00:00
Fix omniscience effect for colorless mana.
Also unified the tests for omniscience into a single file, and put the effect into a single class so that Tamiyo and Omniscience can share implementations.
This commit is contained in:
parent
be82f3bf33
commit
1d3ebb749d
6 changed files with 179 additions and 231 deletions
|
@ -36,6 +36,7 @@ import mage.abilities.condition.Condition;
|
||||||
import mage.abilities.condition.common.SourceIsSpellCondition;
|
import mage.abilities.condition.common.SourceIsSpellCondition;
|
||||||
import mage.abilities.costs.AlternativeCostSourceAbility;
|
import mage.abilities.costs.AlternativeCostSourceAbility;
|
||||||
import mage.abilities.effects.ContinuousEffectImpl;
|
import mage.abilities.effects.ContinuousEffectImpl;
|
||||||
|
import mage.abilities.effects.common.continuous.CastFromHandWithoutPayingManaCostEffect;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
|
@ -61,7 +62,7 @@ public class Omniscience extends CardImpl {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{7}{U}{U}{U}");
|
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{7}{U}{U}{U}");
|
||||||
|
|
||||||
// You may cast nonland cards from your hand without paying their mana costs.
|
// You may cast nonland cards from your hand without paying their mana costs.
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new OmniscienceCastingEffect()));
|
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CastFromHandWithoutPayingManaCostEffect()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Omniscience(final Omniscience card) {
|
public Omniscience(final Omniscience card) {
|
||||||
|
@ -74,62 +75,3 @@ public class Omniscience extends CardImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class OmniscienceCastingEffect extends ContinuousEffectImpl {
|
|
||||||
|
|
||||||
public OmniscienceCastingEffect() {
|
|
||||||
super(Duration.WhileOnBattlefield, Outcome.Detriment);
|
|
||||||
staticText = "You may cast nonland cards from your hand without paying their mana costs";
|
|
||||||
}
|
|
||||||
|
|
||||||
public OmniscienceCastingEffect(final OmniscienceCastingEffect effect) {
|
|
||||||
super(effect);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public OmniscienceCastingEffect copy() {
|
|
||||||
return new OmniscienceCastingEffect(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
|
||||||
if (controller != null) {
|
|
||||||
controller.getAlternativeSourceCosts().add(new AlternativeCostSourceAbility(
|
|
||||||
null, new CompoundCondition(SourceIsSpellCondition.getInstance(), new IsBeingCastFromHandCondition()), null, new FilterNonlandCard(), true));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean apply(Game game, Ability source) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasLayer(Layer layer) {
|
|
||||||
return layer == Layer.RulesEffects;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class IsBeingCastFromHandCondition implements Condition {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean apply(Game game, Ability source) {
|
|
||||||
MageObject object = game.getObject(source.getSourceId());
|
|
||||||
if (object instanceof SplitCardHalf) {
|
|
||||||
UUID splitCardId = ((Card) object).getMainCard().getId();
|
|
||||||
object = game.getObject(splitCardId);
|
|
||||||
}
|
|
||||||
if (object instanceof Spell) { // needed to check if it can be cast by alternate cost
|
|
||||||
Spell spell = (Spell) object;
|
|
||||||
return spell.getFromZone() == Zone.HAND;
|
|
||||||
}
|
|
||||||
if (object instanceof Card) { // needed for the check what's playable
|
|
||||||
Card card = (Card) object;
|
|
||||||
return game.getPlayer(card.getOwnerId()).getHand().get(card.getId(), game) != null;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ import mage.abilities.effects.common.DontUntapInControllersNextUntapStepTargetEf
|
||||||
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
||||||
import mage.abilities.effects.common.GetEmblemEffect;
|
import mage.abilities.effects.common.GetEmblemEffect;
|
||||||
import mage.abilities.effects.common.TapTargetEffect;
|
import mage.abilities.effects.common.TapTargetEffect;
|
||||||
|
import mage.abilities.effects.common.continuous.CastFromHandWithoutPayingManaCostEffect;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
|
@ -207,66 +208,7 @@ class TamiyoFieldResearcherEmblem extends Emblem {
|
||||||
|
|
||||||
this.setName("Emblem Tamiyo");
|
this.setName("Emblem Tamiyo");
|
||||||
|
|
||||||
this.getAbilities().add(new SimpleStaticAbility(Zone.COMMAND, new TamiyoFieldResearcherCastingEffect()));
|
this.getAbilities().add(new SimpleStaticAbility(Zone.COMMAND, new CastFromHandWithoutPayingManaCostEffect()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TamiyoFieldResearcherCastingEffect extends ContinuousEffectImpl {
|
|
||||||
|
|
||||||
public TamiyoFieldResearcherCastingEffect() {
|
|
||||||
super(Duration.WhileOnBattlefield, Outcome.Detriment);
|
|
||||||
staticText = "You may cast nonland cards from your hand without paying their mana costs";
|
|
||||||
}
|
|
||||||
|
|
||||||
public TamiyoFieldResearcherCastingEffect(final TamiyoFieldResearcherCastingEffect effect) {
|
|
||||||
super(effect);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TamiyoFieldResearcherCastingEffect copy() {
|
|
||||||
return new TamiyoFieldResearcherCastingEffect(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
|
||||||
if (controller != null) {
|
|
||||||
controller.getAlternativeSourceCosts().add(new AlternativeCostSourceAbility(
|
|
||||||
null, new CompoundCondition(SourceIsSpellCondition.getInstance(), new IsBeingCastFromHandCondition()), null, new FilterNonlandCard(), true));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean apply(Game game, Ability source) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasLayer(Layer layer) {
|
|
||||||
return layer == Layer.RulesEffects;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class IsBeingCastFromHandCondition implements Condition {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean apply(Game game, Ability source) {
|
|
||||||
MageObject object = game.getObject(source.getSourceId());
|
|
||||||
if (object instanceof SplitCardHalf) {
|
|
||||||
UUID splitCardId = ((Card) object).getMainCard().getId();
|
|
||||||
object = game.getObject(splitCardId);
|
|
||||||
}
|
|
||||||
if (object instanceof Spell) { // needed to check if it can be cast by alternate cost
|
|
||||||
Spell spell = (Spell) object;
|
|
||||||
return spell.getFromZone() == Zone.HAND;
|
|
||||||
}
|
|
||||||
if (object instanceof Card) { // needed for the check what's playable
|
|
||||||
Card card = (Card) object;
|
|
||||||
return game.getPlayer(card.getOwnerId()).getHand().get(card.getId(), game) != null;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,31 +1,4 @@
|
||||||
/*
|
package org.mage.test.cards.cost.alternate;
|
||||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without modification, are
|
|
||||||
* permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
|
||||||
* conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
* provided with the distribution.
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
||||||
* 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
|
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
|
||||||
*/
|
|
||||||
package org.mage.test.cards.single;
|
|
||||||
|
|
||||||
import mage.constants.PhaseStep;
|
import mage.constants.PhaseStep;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
|
@ -33,19 +6,82 @@ import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||||
|
|
||||||
/**
|
public class CastFromHandWithoutPayingManaCostTest extends CardTestPlayerBase {
|
||||||
*
|
|
||||||
* @author LevelX2
|
@Test
|
||||||
*/
|
public void testSpellNoCost() {
|
||||||
public class OmniscienceTest extends CardTestPlayerBase {
|
// You may cast nonland cards from your hand without paying their mana costs.
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Omniscience", 1);
|
||||||
|
|
||||||
|
addCard(Zone.HAND, playerA, "Gray Ogre", 1);
|
||||||
|
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Gray Ogre");
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.END_TURN);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
//Gray Ogre is cast because it is free
|
||||||
|
assertPermanentCount(playerA, "Gray Ogre", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSpellHasCostIfCastFromGraveyard() {
|
||||||
|
// You may cast nonland cards from your hand without paying their mana costs.
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Omniscience", 1);
|
||||||
|
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Haakon, Stromgald Scourge", 1);
|
||||||
|
|
||||||
|
addCard(Zone.GRAVEYARD, playerA, "Knight of the White Orchid", 1);
|
||||||
|
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Knight of the White Orchid");
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.END_TURN);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
//Knight of the White Orchid was not cast due to lack of mana
|
||||||
|
assertPermanentCount(playerA, "Knight of the White Orchid", 0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Omniscience {7}{U}{U}{U}
|
* If you cast a card with monocolored hybrid mana with Omniscience's
|
||||||
*
|
* alternate casting cost, you will be asked to pay 1 colorless mana per
|
||||||
* Enchantment You may cast nonland cards from your hand without paying
|
* monocolored hybrid mana in its cost. For example, while casting Beseech
|
||||||
* their mana costs.
|
* the Queen, you are asked to pay {1}{1}{1}.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
|
public void testMonocoloredHybridMana() {
|
||||||
|
// You may cast nonland cards from your hand without paying their mana costs.
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Omniscience", 1);
|
||||||
|
|
||||||
|
// ({2B} can be paid with any two mana or with {B}. This card's converted mana cost is 6.)
|
||||||
|
// Search your library for a card with converted mana cost less than or equal to the number of lands you control, reveal it, and put it into your hand. Then shuffle your library.
|
||||||
|
addCard(Zone.HAND, playerA, "Beseech the Queen", 1);
|
||||||
|
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Beseech the Queen");
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.END_TURN);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
// Beseech the Queen is cast because it is free
|
||||||
|
assertGraveyardCount(playerA, "Beseech the Queen", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testColorlessMana() {
|
||||||
|
// You may cast nonland cards from your hand without paying their mana costs.
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Omniscience", 1);
|
||||||
|
|
||||||
|
addCard(Zone.HAND, playerA, "Reality Smasher", 1);
|
||||||
|
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Reality Smasher");
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.END_TURN);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
// Relaity Smasher is cast because it is free
|
||||||
|
assertPermanentCount(playerA, "Reality Smasher", 1);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCastingCreature() {
|
public void testCastingCreature() {
|
||||||
addCard(Zone.BATTLEFIELD, playerA, "Omniscience");
|
addCard(Zone.BATTLEFIELD, playerA, "Omniscience");
|
|
@ -1,67 +0,0 @@
|
||||||
package org.mage.test.cards.cost.alternate;
|
|
||||||
|
|
||||||
import mage.constants.PhaseStep;
|
|
||||||
import mage.constants.Zone;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
|
||||||
|
|
||||||
public class OmniscienceTest extends CardTestPlayerBase {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSpellNoCost() {
|
|
||||||
// You may cast nonland cards from your hand without paying their mana costs.
|
|
||||||
addCard(Zone.BATTLEFIELD, playerA, "Omniscience", 1);
|
|
||||||
|
|
||||||
addCard(Zone.HAND, playerA, "Gray Ogre", 1);
|
|
||||||
|
|
||||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Gray Ogre");
|
|
||||||
|
|
||||||
setStopAt(1, PhaseStep.END_TURN);
|
|
||||||
execute();
|
|
||||||
|
|
||||||
//Gray Ogre is cast because it is free
|
|
||||||
assertPermanentCount(playerA, "Gray Ogre", 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSpellHasCostIfCastFromGraveyard() {
|
|
||||||
// You may cast nonland cards from your hand without paying their mana costs.
|
|
||||||
addCard(Zone.BATTLEFIELD, playerA, "Omniscience", 1);
|
|
||||||
|
|
||||||
addCard(Zone.BATTLEFIELD, playerA, "Haakon, Stromgald Scourge", 1);
|
|
||||||
|
|
||||||
addCard(Zone.GRAVEYARD, playerA, "Knight of the White Orchid", 1);
|
|
||||||
|
|
||||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Knight of the White Orchid");
|
|
||||||
|
|
||||||
setStopAt(1, PhaseStep.END_TURN);
|
|
||||||
execute();
|
|
||||||
|
|
||||||
//Knight of the White Orchid was not cast due to lack of mana
|
|
||||||
assertPermanentCount(playerA, "Knight of the White Orchid", 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If you cast a card with monocolored hybrid mana with Omniscience's
|
|
||||||
* alternate casting cost, you will be asked to pay 1 colorless mana per
|
|
||||||
* monocolored hybrid mana in its cost. For example, while casting Beseech
|
|
||||||
* the Queen, you are asked to pay {1}{1}{1}.
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testMonocoloredHybridMana() {
|
|
||||||
// You may cast nonland cards from your hand without paying their mana costs.
|
|
||||||
addCard(Zone.BATTLEFIELD, playerA, "Omniscience", 1);
|
|
||||||
|
|
||||||
// ({2B} can be paid with any two mana or with {B}. This card's converted mana cost is 6.)
|
|
||||||
// Search your library for a card with converted mana cost less than or equal to the number of lands you control, reveal it, and put it into your hand. Then shuffle your library.
|
|
||||||
addCard(Zone.HAND, playerA, "Beseech the Queen", 1);
|
|
||||||
|
|
||||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Beseech the Queen");
|
|
||||||
|
|
||||||
setStopAt(1, PhaseStep.END_TURN);
|
|
||||||
execute();
|
|
||||||
|
|
||||||
// Beseech the Queen is cast because it is free
|
|
||||||
assertGraveyardCount(playerA, "Beseech the Queen", 1);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
package mage.abilities.effects.common.continuous;
|
||||||
|
|
||||||
|
import mage.MageObject;
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.condition.CompoundCondition;
|
||||||
|
import mage.abilities.condition.Condition;
|
||||||
|
import mage.abilities.condition.common.SourceIsSpellCondition;
|
||||||
|
import mage.abilities.costs.AlternativeCostSourceAbility;
|
||||||
|
import mage.abilities.effects.ContinuousEffectImpl;
|
||||||
|
import mage.cards.Card;
|
||||||
|
import mage.cards.SplitCardHalf;
|
||||||
|
import mage.constants.*;
|
||||||
|
import mage.filter.common.FilterNonlandCard;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.game.stack.Spell;
|
||||||
|
import mage.players.Player;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class CastFromHandWithoutPayingManaCostEffect extends ContinuousEffectImpl {
|
||||||
|
|
||||||
|
public CastFromHandWithoutPayingManaCostEffect() {
|
||||||
|
super(Duration.WhileOnBattlefield, Outcome.Detriment);
|
||||||
|
staticText = "You may cast nonland cards from your hand without paying their mana costs";
|
||||||
|
}
|
||||||
|
|
||||||
|
public CastFromHandWithoutPayingManaCostEffect(final CastFromHandWithoutPayingManaCostEffect effect) {
|
||||||
|
super(effect);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CastFromHandWithoutPayingManaCostEffect copy() {
|
||||||
|
return new CastFromHandWithoutPayingManaCostEffect(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||||
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
|
if (controller != null) {
|
||||||
|
controller.getAlternativeSourceCosts().add(new AlternativeCostSourceAbility(
|
||||||
|
null, new CompoundCondition(SourceIsSpellCondition.getInstance(), new IsBeingCastFromHandCondition()), null, new FilterNonlandCard(), true));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Game game, Ability source) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasLayer(Layer layer) {
|
||||||
|
return layer == Layer.RulesEffects;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class IsBeingCastFromHandCondition implements Condition {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Game game, Ability source) {
|
||||||
|
MageObject object = game.getObject(source.getSourceId());
|
||||||
|
if (object instanceof SplitCardHalf) {
|
||||||
|
UUID splitCardId = ((Card) object).getMainCard().getId();
|
||||||
|
object = game.getObject(splitCardId);
|
||||||
|
}
|
||||||
|
if (object instanceof Spell) { // needed to check if it can be cast by alternate cost
|
||||||
|
Spell spell = (Spell) object;
|
||||||
|
return spell.getFromZone() == Zone.HAND;
|
||||||
|
}
|
||||||
|
if (object instanceof Card) { // needed for the check what's playable
|
||||||
|
Card card = (Card) object;
|
||||||
|
return game.getPlayer(card.getOwnerId()).getHand().get(card.getId(), game) != null;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -31,6 +31,9 @@ import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.Mana;
|
import mage.Mana;
|
||||||
import mage.ObjectColor;
|
import mage.ObjectColor;
|
||||||
|
@ -271,12 +274,12 @@ public final class CardUtil {
|
||||||
reduceMana.add(manaCost.getMana());
|
reduceMana.add(manaCost.getMana());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ManaCosts<ManaCost> manaCostToCheckForColorless = new ManaCostsImpl<>();
|
ManaCosts<ManaCost> manaCostToCheckForGeneric = new ManaCostsImpl<>();
|
||||||
// subtract colored mana
|
// subtract non-generic mana
|
||||||
for (ManaCost newManaCost : previousCost) {
|
for (ManaCost newManaCost : previousCost) {
|
||||||
Mana mana = newManaCost.getMana();
|
Mana mana = newManaCost.getMana();
|
||||||
if (!(newManaCost instanceof MonoHybridManaCost) && mana.getGeneric() > 0) {
|
if (!(newManaCost instanceof MonoHybridManaCost) && mana.getGeneric() > 0) {
|
||||||
manaCostToCheckForColorless.add(newManaCost);
|
manaCostToCheckForGeneric.add(newManaCost);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
boolean hybridMana = newManaCost instanceof HybridManaCost;
|
boolean hybridMana = newManaCost instanceof HybridManaCost;
|
||||||
|
@ -340,6 +343,17 @@ public final class CardUtil {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(mana.getColorless() > 0 && reduceMana.getColorless() > 0) {
|
||||||
|
if(reduceMana.getColorless() > mana.getColorless()) {
|
||||||
|
reduceMana.setColorless(reduceMana.getColorless() - mana.getColorless());
|
||||||
|
mana.setColorless(0);
|
||||||
|
} else {
|
||||||
|
mana.setColorless(mana.getColorless() - reduceMana.getColorless());
|
||||||
|
reduceMana.setColorless(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (mana.count() > 0) {
|
if (mana.count() > 0) {
|
||||||
if (newManaCost instanceof MonoHybridManaCost) {
|
if (newManaCost instanceof MonoHybridManaCost) {
|
||||||
if (mana.count() == 2) {
|
if (mana.count() == 2) {
|
||||||
|
@ -347,7 +361,7 @@ public final class CardUtil {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
manaCostToCheckForColorless.add(newManaCost);
|
manaCostToCheckForGeneric.add(newManaCost);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -360,7 +374,7 @@ public final class CardUtil {
|
||||||
reduceAmount = reduceMana.getGeneric();
|
reduceAmount = reduceMana.getGeneric();
|
||||||
}
|
}
|
||||||
if (reduceAmount > 0) {
|
if (reduceAmount > 0) {
|
||||||
for (ManaCost newManaCost : manaCostToCheckForColorless) {
|
for (ManaCost newManaCost : manaCostToCheckForGeneric) {
|
||||||
Mana mana = newManaCost.getMana();
|
Mana mana = newManaCost.getMana();
|
||||||
if (mana.getGeneric() == 0 || reduceAmount == 0) {
|
if (mana.getGeneric() == 0 || reduceAmount == 0) {
|
||||||
adjustedCost.add(newManaCost);
|
adjustedCost.add(newManaCost);
|
||||||
|
@ -387,7 +401,7 @@ public final class CardUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
adjustedCost.addAll(manaCostToCheckForColorless);
|
adjustedCost.addAll(manaCostToCheckForGeneric);
|
||||||
}
|
}
|
||||||
if (adjustedCost.isEmpty()) {
|
if (adjustedCost.isEmpty()) {
|
||||||
adjustedCost.add(new GenericManaCost(0)); // neede to check if cost was reduced to 0
|
adjustedCost.add(new GenericManaCost(0)); // neede to check if cost was reduced to 0
|
||||||
|
@ -397,6 +411,10 @@ public final class CardUtil {
|
||||||
spellAbility.getManaCostsToPay().addAll(adjustedCost);
|
spellAbility.getManaCostsToPay().addAll(adjustedCost);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void reduceMana(Mana mana, Mana reduceMana, Supplier<Integer> manaAmountSupplier, Consumer<Integer> manaAmountConsumer) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns function that copies params\abilities from one card to
|
* Returns function that copies params\abilities from one card to
|
||||||
* {@link Token}.
|
* {@link Token}.
|
||||||
|
|
Loading…
Reference in a new issue