mirror of
https://github.com/correl/mage.git
synced 2024-12-24 03:00:14 +00:00
* Non basic mana abilities - fixed rollback errors in AI games (#6300);
This commit is contained in:
parent
28169b5271
commit
169d9bf761
62 changed files with 692 additions and 509 deletions
|
@ -4,11 +4,11 @@ import mage.Mana;
|
|||
import mage.cards.Card;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.constants.ColoredManaSymbol;
|
||||
import mage.constants.SubType;
|
||||
import mage.interfaces.rate.RateCallback;
|
||||
import mage.util.RandomUtil;
|
||||
|
||||
import java.util.*;
|
||||
import mage.constants.SubType;
|
||||
|
||||
/**
|
||||
* Builds deck from provided card pool.
|
||||
|
@ -17,14 +17,14 @@ import mage.constants.SubType;
|
|||
*/
|
||||
public final class DeckBuilder {
|
||||
|
||||
private static final int DECK_COUNT40[] = {3, 6, 6, 4, 3, 2};
|
||||
private static final int DECK_COUNT60[] = {4, 9, 9, 5, 5, 3};
|
||||
private static final int DECK_COST[] = {1, 2, 3, 4, 6, 10};
|
||||
private static final int[] DECK_COUNT40 = {3, 6, 6, 4, 3, 2};
|
||||
private static final int[] DECK_COUNT60 = {4, 9, 9, 5, 5, 3};
|
||||
private static final int[] DECK_COST = {1, 2, 3, 4, 6, 10};
|
||||
private static final int MIN_CARD_SCORE = 25;
|
||||
private static final int MIN_SOURCE = 3; // minmal number of sources for a mana color, will be taken also if ratio would give a lower number
|
||||
private static Deck deck;
|
||||
|
||||
private static int deckCount[];
|
||||
private static int[] deckCount;
|
||||
private static int deckSize;
|
||||
private static int deckSpells;
|
||||
private static int deckLands;
|
||||
|
@ -86,26 +86,6 @@ public final class DeckBuilder {
|
|||
return returnedDeck;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that chosen card can produce mana of specific color.
|
||||
*
|
||||
* @param card
|
||||
* @param allowedColors
|
||||
* @return
|
||||
*/
|
||||
private static boolean cardCardProduceChosenColors(Card card, List<ColoredManaSymbol> allowedColors) {
|
||||
int score = 0;
|
||||
for (Mana mana : card.getMana()) {
|
||||
for (ColoredManaSymbol color : allowedColors) {
|
||||
score = score + mana.getColor(color);
|
||||
}
|
||||
}
|
||||
if (score > 1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Chosed best scored card and adds it to the deck.
|
||||
*
|
||||
|
@ -115,7 +95,7 @@ public final class DeckBuilder {
|
|||
* @param count
|
||||
*/
|
||||
private static void addCardsToDeck(final Collection<MageScoredCard> remainingCards, final int minCost, final int maxCost,
|
||||
final int count) {
|
||||
final int count) {
|
||||
|
||||
for (int c = count; c > 0; c--) {
|
||||
|
||||
|
@ -231,7 +211,7 @@ public final class DeckBuilder {
|
|||
private Card card;
|
||||
private final int score;
|
||||
|
||||
private static final int SINGLE_PENALTY[] = {0, 1, 1, 3, 6, 9};
|
||||
private static final int[] SINGLE_PENALTY = {0, 1, 1, 3, 6, 9};
|
||||
//private static final int DOUBLE_PENALTY[] = { 0, 0, 1, 2, 4, 6 };
|
||||
|
||||
public MageScoredCard(Card card, List<ColoredManaSymbol> allowedColors, RateCallback cardRater) {
|
||||
|
@ -253,8 +233,8 @@ public final class DeckBuilder {
|
|||
this.score
|
||||
= // 5*card.getValue() + // not possible now
|
||||
3 * cardRater.rateCard(card)
|
||||
+ // 3*card.getRemoval() + // not possible now
|
||||
type + getManaCostScore(card, allowedColors);
|
||||
+ // 3*card.getRemoval() + // not possible now
|
||||
type + getManaCostScore(card, allowedColors);
|
||||
}
|
||||
|
||||
private int getManaCostScore(Card card, List<ColoredManaSymbol> allowedColors) {
|
||||
|
|
|
@ -69,11 +69,13 @@ class AstralCornucopiaManaEffect extends ManaEffect {
|
|||
@Override
|
||||
public List<Mana> getNetMana(Game game, Ability source) {
|
||||
List<Mana> netMana = new ArrayList<>();
|
||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||
if (sourcePermanent != null) {
|
||||
int counters = sourcePermanent.getCounters(game).getCount(CounterType.CHARGE.getName());
|
||||
if (counters > 0) {
|
||||
netMana.add(Mana.AnyMana(counters));
|
||||
if (game != null) {
|
||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||
if (sourcePermanent != null) {
|
||||
int counters = sourcePermanent.getCounters(game).getCount(CounterType.CHARGE.getName());
|
||||
if (counters > 0) {
|
||||
netMana.add(Mana.AnyMana(counters));
|
||||
}
|
||||
}
|
||||
}
|
||||
return netMana;
|
||||
|
@ -82,6 +84,9 @@ class AstralCornucopiaManaEffect extends ManaEffect {
|
|||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Mana mana = new Mana();
|
||||
if (game == null) {
|
||||
return mana;
|
||||
}
|
||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||
if (sourcePermanent != null) {
|
||||
int counters = sourcePermanent.getCounters(game).getCount(CounterType.CHARGE.getName());
|
||||
|
|
|
@ -148,6 +148,9 @@ class BenthicExplorersManaEffect extends ManaEffect {
|
|||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Mana mana = new Mana();
|
||||
if (game == null) {
|
||||
return mana;
|
||||
}
|
||||
Mana types = getManaTypes(game, source);
|
||||
Choice choice = new ChoiceColor(true);
|
||||
choice.getChoices().clear();
|
||||
|
@ -186,7 +189,7 @@ class BenthicExplorersManaEffect extends ManaEffect {
|
|||
} else {
|
||||
if (player == null
|
||||
|| !player.choose(Outcome.Neutral, choice, game)) {
|
||||
return null;
|
||||
return mana;
|
||||
}
|
||||
}
|
||||
if (choice.getChoice() != null) {
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
|
||||
package mage.cards.b;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
|
@ -15,10 +13,10 @@ import mage.constants.SubType;
|
|||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jeffwadsworth
|
||||
*/
|
||||
public final class BloomTender extends CardImpl {
|
||||
|
@ -64,6 +62,9 @@ class BloomTenderEffect extends ManaEffect {
|
|||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Mana mana = new Mana();
|
||||
if (game == null) {
|
||||
return mana;
|
||||
}
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(source.getControllerId())) {
|
||||
if (mana.getBlack() == 0 && permanent.getColor(game).isBlack()) {
|
||||
mana.increaseBlack();
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
|
||||
package mage.cards.c;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.Mana;
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Ability;
|
||||
|
@ -19,10 +17,10 @@ import mage.game.Game;
|
|||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward
|
||||
*/
|
||||
public final class CagedSun extends CardImpl {
|
||||
|
@ -110,9 +108,7 @@ class CagedSunTriggeredAbility extends TriggeredManaAbility {
|
|||
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
|
||||
if (permanent != null && permanent.isLand()) {
|
||||
ObjectColor color = (ObjectColor) game.getState().getValue(this.sourceId + "_color");
|
||||
if (color != null && event.getData().contains(color.toString())) {
|
||||
return true;
|
||||
}
|
||||
return color != null && event.getData().contains(color.toString());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -141,12 +137,13 @@ class CagedSunEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
ObjectColor color = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color");
|
||||
if (color != null) {
|
||||
return new Mana(ColoredManaSymbol.lookup(color.toString().charAt(0)));
|
||||
} else {
|
||||
return null;
|
||||
if (game != null) {
|
||||
ObjectColor color = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color");
|
||||
if (color != null) {
|
||||
return new Mana(ColoredManaSymbol.lookup(color.toString().charAt(0)));
|
||||
}
|
||||
}
|
||||
return new Mana();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -130,19 +130,24 @@ class CarpetOfFlowersEffect extends ManaEffect {
|
|||
@Override
|
||||
public List<Mana> getNetMana(Game game, Ability source) {
|
||||
List<Mana> netMana = new ArrayList<>();
|
||||
int count = game.getBattlefield().count(filter, source.getSourceId(), source.getTargets().getFirstTarget(), game);
|
||||
if (count > 0) {
|
||||
netMana.add(Mana.AnyMana(count));
|
||||
if (game != null) {
|
||||
int count = game.getBattlefield().count(filter, source.getSourceId(), source.getTargets().getFirstTarget(), game);
|
||||
if (count > 0) {
|
||||
netMana.add(Mana.AnyMana(count));
|
||||
}
|
||||
}
|
||||
return netMana;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Mana mana = new Mana();
|
||||
if (game == null) {
|
||||
return mana;
|
||||
}
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
ChoiceColor choice = new ChoiceColor();
|
||||
if (controller != null && controller.choose(Outcome.Benefit, choice, game)) {
|
||||
Mana mana = new Mana();
|
||||
int count = game.getBattlefield().count(filter, source.getSourceId(), source.getTargets().getFirstTarget(), game);
|
||||
if (count > 0) {
|
||||
switch (choice.getChoice()) {
|
||||
|
@ -165,9 +170,8 @@ class CarpetOfFlowersEffect extends ManaEffect {
|
|||
break;
|
||||
}
|
||||
}
|
||||
return mana;
|
||||
}
|
||||
return null;
|
||||
return mana;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,6 +20,7 @@ import mage.constants.Zone;
|
|||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
@ -101,6 +102,9 @@ class CharmedPendantManaEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public List<Mana> getNetMana(Game game, Ability source) {
|
||||
if (game == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
if (controller.isTopCardRevealed()) {
|
||||
|
@ -115,14 +119,17 @@ class CharmedPendantManaEffect extends ManaEffect {
|
|||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Mana mana = new Mana();
|
||||
if (game == null) {
|
||||
return mana;
|
||||
}
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
Mana mana = new Mana();
|
||||
for (Cost cost : source.getCosts()) {
|
||||
if (cost instanceof PutTopCardOfYourLibraryToGraveyardCost) {
|
||||
Set<Card> cards = ((PutTopCardOfYourLibraryToGraveyardCost) cost).getCardsMovedToGraveyard();
|
||||
|
@ -161,11 +168,8 @@ class CharmedPendantManaEffect extends ManaEffect {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return mana;
|
||||
}
|
||||
|
||||
return null;
|
||||
return mana;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,27 +124,29 @@ class ChromeMoxManaEffect extends ManaEffect {
|
|||
@Override
|
||||
public List<Mana> getNetMana(Game game, Ability source) {
|
||||
List<Mana> netMana = new ArrayList<>();
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
List<UUID> imprinted = permanent.getImprinted();
|
||||
if (imprinted != null && !imprinted.isEmpty()) {
|
||||
Card imprintedCard = game.getCard(imprinted.get(0));
|
||||
if (imprintedCard != null) {
|
||||
ObjectColor color = imprintedCard.getColor(game);
|
||||
if (color.isBlack()) {
|
||||
netMana.add(Mana.BlackMana(1));
|
||||
}
|
||||
if (color.isRed()) {
|
||||
netMana.add(Mana.RedMana(1));
|
||||
}
|
||||
if (color.isBlue()) {
|
||||
netMana.add(Mana.BlueMana(1));
|
||||
}
|
||||
if (color.isGreen()) {
|
||||
netMana.add(Mana.GreenMana(1));
|
||||
}
|
||||
if (color.isWhite()) {
|
||||
netMana.add(Mana.WhiteMana(1));
|
||||
if (game != null) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
List<UUID> imprinted = permanent.getImprinted();
|
||||
if (imprinted != null && !imprinted.isEmpty()) {
|
||||
Card imprintedCard = game.getCard(imprinted.get(0));
|
||||
if (imprintedCard != null) {
|
||||
ObjectColor color = imprintedCard.getColor(game);
|
||||
if (color.isBlack()) {
|
||||
netMana.add(Mana.BlackMana(1));
|
||||
}
|
||||
if (color.isRed()) {
|
||||
netMana.add(Mana.RedMana(1));
|
||||
}
|
||||
if (color.isBlue()) {
|
||||
netMana.add(Mana.BlueMana(1));
|
||||
}
|
||||
if (color.isGreen()) {
|
||||
netMana.add(Mana.GreenMana(1));
|
||||
}
|
||||
if (color.isWhite()) {
|
||||
netMana.add(Mana.WhiteMana(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -154,6 +156,10 @@ class ChromeMoxManaEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Mana mana = new Mana();
|
||||
if (game == null) {
|
||||
return mana;
|
||||
}
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (permanent != null && player != null) {
|
||||
|
@ -180,14 +186,13 @@ class ChromeMoxManaEffect extends ManaEffect {
|
|||
if (color.isWhite()) {
|
||||
choice.getChoices().add("White");
|
||||
}
|
||||
Mana mana = new Mana();
|
||||
if (!choice.getChoices().isEmpty()) {
|
||||
|
||||
if (choice.getChoices().size() == 1) {
|
||||
choice.setChoice(choice.getChoices().iterator().next());
|
||||
} else {
|
||||
if (!player.choose(outcome, choice, game)) {
|
||||
return null;
|
||||
return mana;
|
||||
}
|
||||
}
|
||||
switch (choice.getChoice()) {
|
||||
|
@ -215,11 +220,10 @@ class ChromeMoxManaEffect extends ManaEffect {
|
|||
break;
|
||||
}
|
||||
}
|
||||
return mana;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return mana;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -64,7 +64,11 @@ class CorruptedGrafstoneManaAbility extends ActivatedManaAbilityImpl {
|
|||
|
||||
@Override
|
||||
public List<Mana> getNetMana(Game game) {
|
||||
return ((CorruptedGrafstoneManaEffect) getEffects().get(0)).getNetMana(game, this);
|
||||
List<Mana> netMana = new ArrayList<>();
|
||||
if (game != null) {
|
||||
return ((CorruptedGrafstoneManaEffect) getEffects().get(0)).getNetMana(game, this);
|
||||
}
|
||||
return netMana;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,6 +119,10 @@ class CorruptedGrafstoneManaEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Mana mana = new Mana();
|
||||
if (game == null) {
|
||||
return mana;
|
||||
}
|
||||
Mana types = getManaTypesInGraveyard(game, source);
|
||||
Choice choice = new ChoiceColor(true);
|
||||
choice.getChoices().clear();
|
||||
|
@ -141,39 +149,35 @@ class CorruptedGrafstoneManaEffect extends ManaEffect {
|
|||
choice.setChoice(choice.getChoices().iterator().next());
|
||||
} else {
|
||||
if (!player.choose(outcome, choice, game)) {
|
||||
return null;
|
||||
return mana;
|
||||
}
|
||||
}
|
||||
Mana computedManaHere = new Mana();
|
||||
switch (choice.getChoice()) {
|
||||
case "Black":
|
||||
computedManaHere.setBlack(1);
|
||||
mana.setBlack(1);
|
||||
break;
|
||||
case "Blue":
|
||||
computedManaHere.setBlue(1);
|
||||
mana.setBlue(1);
|
||||
break;
|
||||
case "Red":
|
||||
computedManaHere.setRed(1);
|
||||
mana.setRed(1);
|
||||
break;
|
||||
case "Green":
|
||||
computedManaHere.setGreen(1);
|
||||
mana.setGreen(1);
|
||||
break;
|
||||
case "White":
|
||||
computedManaHere.setWhite(1);
|
||||
mana.setWhite(1);
|
||||
break;
|
||||
}
|
||||
return computedManaHere;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return mana;
|
||||
}
|
||||
|
||||
private Mana getManaTypesInGraveyard(Game game, Ability source) {
|
||||
|
||||
if (source != null && source.getControllerId() != null) {
|
||||
if (game != null && source != null && source.getControllerId() != null) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Mana types = new Mana();
|
||||
|
||||
if (controller != null) {
|
||||
for (Card card : controller.getGraveyard().getCards(game)) {
|
||||
if (card != null) {
|
||||
|
|
|
@ -123,7 +123,10 @@ class DawnsReflectionManaEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Player player = getPlayer(game, source);
|
||||
return ManaChoice.chooseAnyColor(player, game, 2);
|
||||
if (game != null) {
|
||||
Player player = getPlayer(game, source);
|
||||
return ManaChoice.chooseAnyColor(player, game, 2);
|
||||
}
|
||||
return new Mana();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
|
||||
package mage.cards.d;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.ConditionalMana;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
|
@ -17,8 +15,9 @@ import mage.game.Game;
|
|||
import mage.players.ManaPool;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jeffwadsworth
|
||||
*/
|
||||
public final class DoublingCube extends CardImpl {
|
||||
|
@ -56,27 +55,28 @@ class DoublingCubeEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller == null) {
|
||||
return null;
|
||||
if (game != null) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
ManaPool pool = controller.getManaPool();
|
||||
int blackMana = pool.getBlack();
|
||||
int whiteMana = pool.getWhite();
|
||||
int blueMana = pool.getBlue();
|
||||
int greenMana = pool.getGreen();
|
||||
int redMana = pool.getRed();
|
||||
int colorlessMana = pool.getColorless();
|
||||
for (ConditionalMana conditionalMana : pool.getConditionalMana()) {
|
||||
blackMana += conditionalMana.getBlack();
|
||||
whiteMana += conditionalMana.getWhite();
|
||||
blueMana += conditionalMana.getBlue();
|
||||
greenMana += conditionalMana.getGreen();
|
||||
redMana += conditionalMana.getRed();
|
||||
colorlessMana += conditionalMana.getColorless();
|
||||
}
|
||||
return new Mana(redMana, greenMana, blueMana, whiteMana, blackMana, 0, 0, colorlessMana);
|
||||
}
|
||||
}
|
||||
ManaPool pool = controller.getManaPool();
|
||||
int blackMana = pool.getBlack();
|
||||
int whiteMana = pool.getWhite();
|
||||
int blueMana = pool.getBlue();
|
||||
int greenMana = pool.getGreen();
|
||||
int redMana = pool.getRed();
|
||||
int colorlessMana = pool.getColorless();
|
||||
|
||||
for (ConditionalMana conditionalMana : pool.getConditionalMana()) {
|
||||
blackMana += conditionalMana.getBlack();
|
||||
whiteMana += conditionalMana.getWhite();
|
||||
blueMana += conditionalMana.getBlue();
|
||||
greenMana += conditionalMana.getGreen();
|
||||
redMana += conditionalMana.getRed();
|
||||
colorlessMana += conditionalMana.getColorless();
|
||||
}
|
||||
return new Mana(redMana, greenMana, blueMana, whiteMana, blackMana, 0, 0, colorlessMana);
|
||||
return new Mana();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -70,21 +70,24 @@ class EmpoweredAutogeneratorManaEffect extends ManaEffect {
|
|||
@Override
|
||||
public List<Mana> getNetMana(Game game, Ability source) {
|
||||
List<Mana> netMana = new ArrayList<>();
|
||||
|
||||
Permanent sourcePermanent = game.getState().getPermanent(source.getSourceId());
|
||||
if (sourcePermanent != null) {
|
||||
int counters = sourcePermanent.getCounters(game).getCount(CounterType.CHARGE) + 1; // one counter will be added on real mana call
|
||||
if (counters > 0) {
|
||||
netMana.add(Mana.AnyMana(counters));
|
||||
if (game != null) {
|
||||
Permanent sourcePermanent = game.getState().getPermanent(source.getSourceId());
|
||||
if (sourcePermanent != null) {
|
||||
int counters = sourcePermanent.getCounters(game).getCount(CounterType.CHARGE) + 1; // one counter will be added on real mana call
|
||||
if (counters > 0) {
|
||||
netMana.add(Mana.AnyMana(counters));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return netMana;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Mana mana = new Mana();
|
||||
if (game == null) {
|
||||
return mana;
|
||||
}
|
||||
game.applyEffects();
|
||||
Permanent sourcePermanent = game.getState().getPermanent(source.getSourceId());
|
||||
if (sourcePermanent == null) {
|
||||
|
@ -126,7 +129,6 @@ class EmpoweredAutogeneratorManaEffect extends ManaEffect {
|
|||
mana.setGreen(counters);
|
||||
break;
|
||||
}
|
||||
|
||||
return mana;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import mage.game.permanent.Permanent;
|
|||
import mage.players.Player;
|
||||
import mage.target.TargetPlayer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -107,17 +108,18 @@ class ManaScrewEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public List<Mana> getNetMana(Game game, Ability source) {
|
||||
return null;
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Player player = getPlayer(game, source);
|
||||
if (player != null && player.flipCoin(source, game, true)) {
|
||||
return Mana.ColorlessMana(2);
|
||||
} else {
|
||||
return new Mana();
|
||||
if (game != null) {
|
||||
Player player = getPlayer(game, source);
|
||||
if (player != null && player.flipCoin(source, game, true)) {
|
||||
return Mana.ColorlessMana(2);
|
||||
}
|
||||
}
|
||||
return new Mana();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -107,6 +107,9 @@ class FaeburrowElderManaEffect extends ManaEffect {
|
|||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Mana mana = new Mana();
|
||||
if (game == null) {
|
||||
return mana;
|
||||
}
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(source.getControllerId())) {
|
||||
if (mana.getBlack() == 0 && permanent.getColor(game).isBlack()) {
|
||||
mana.increaseBlack();
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
package mage.cards.f;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.ConditionalMana;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
|
@ -25,8 +22,11 @@ import mage.game.permanent.Permanent;
|
|||
import mage.players.Player;
|
||||
import mage.target.common.TargetControlledCreaturePermanent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author emerald000
|
||||
*/
|
||||
public final class FoodChain extends CardImpl {
|
||||
|
@ -83,24 +83,30 @@ class FoodChainManaEffect extends ManaEffect {
|
|||
@Override
|
||||
public List<Mana> getNetMana(Game game, Ability source) {
|
||||
List<Mana> netMana = new ArrayList<>();
|
||||
int cmc = -1;
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(source.getControllerId())) {
|
||||
if (permanent.isCreature()) {
|
||||
cmc = Math.max(cmc, permanent.getManaCost().convertedManaCost());
|
||||
if (game != null) {
|
||||
int cmc = -1;
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(source.getControllerId())) {
|
||||
if (permanent.isCreature()) {
|
||||
cmc = Math.max(cmc, permanent.getManaCost().convertedManaCost());
|
||||
}
|
||||
}
|
||||
if (cmc != -1) {
|
||||
netMana.add(manaBuilder.setMana(Mana.BlackMana(cmc + 1), source, game).build());
|
||||
netMana.add(manaBuilder.setMana(Mana.BlueMana(cmc + 1), source, game).build());
|
||||
netMana.add(manaBuilder.setMana(Mana.RedMana(cmc + 1), source, game).build());
|
||||
netMana.add(manaBuilder.setMana(Mana.GreenMana(cmc + 1), source, game).build());
|
||||
netMana.add(manaBuilder.setMana(Mana.WhiteMana(cmc + 1), source, game).build());
|
||||
}
|
||||
}
|
||||
if (cmc != -1) {
|
||||
netMana.add(manaBuilder.setMana(Mana.BlackMana(cmc + 1), source, game).build());
|
||||
netMana.add(manaBuilder.setMana(Mana.BlueMana(cmc + 1), source, game).build());
|
||||
netMana.add(manaBuilder.setMana(Mana.RedMana(cmc + 1), source, game).build());
|
||||
netMana.add(manaBuilder.setMana(Mana.GreenMana(cmc + 1), source, game).build());
|
||||
netMana.add(manaBuilder.setMana(Mana.WhiteMana(cmc + 1), source, game).build());
|
||||
}
|
||||
return netMana;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Mana mana = new Mana();
|
||||
if (game == null) {
|
||||
return mana;
|
||||
}
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
int manaCostExiled = 0;
|
||||
|
@ -113,13 +119,12 @@ class FoodChainManaEffect extends ManaEffect {
|
|||
}
|
||||
ChoiceColor choice = new ChoiceColor();
|
||||
if (!controller.choose(Outcome.PutManaInPool, choice, game)) {
|
||||
return null;
|
||||
return mana;
|
||||
}
|
||||
Mana chosen = choice.getMana(manaCostExiled + 1);
|
||||
return manaBuilder.setMana(chosen, source, game).build();
|
||||
}
|
||||
|
||||
return null;
|
||||
return mana;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package mage.cards.g;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.Mana;
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Ability;
|
||||
|
@ -25,8 +24,9 @@ import mage.game.permanent.Permanent;
|
|||
import mage.players.Player;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public final class GauntletOfPower extends CardImpl {
|
||||
|
@ -189,14 +189,16 @@ class GauntletOfPowerEffectEffect2 extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Permanent land = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source));
|
||||
if (land != null) {
|
||||
Mana mana = (Mana) getValue("mana");
|
||||
if (mana != null) {
|
||||
return mana.copy();
|
||||
if (game != null) {
|
||||
Permanent land = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source));
|
||||
if (land != null) {
|
||||
Mana mana = (Mana) getValue("mana");
|
||||
if (mana != null) {
|
||||
return mana.copy();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return new Mana();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -82,11 +82,15 @@ class GoblinClearCutterManaEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public List<Mana> getNetMana(Game game, Ability source) {
|
||||
return netMana;
|
||||
return new ArrayList<>(netMana);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Mana mana = new Mana();
|
||||
if (game == null) {
|
||||
return mana;
|
||||
}
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
Choice manaChoice = new ChoiceImpl();
|
||||
|
@ -95,11 +99,9 @@ class GoblinClearCutterManaEffect extends ManaEffect {
|
|||
choices.add("Green");
|
||||
manaChoice.setChoices(choices);
|
||||
manaChoice.setMessage("Select color of mana to add");
|
||||
|
||||
Mana mana = new Mana();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (!player.choose(Outcome.Benefit, manaChoice, game)) {
|
||||
return null;
|
||||
return mana;
|
||||
}
|
||||
switch (manaChoice.getChoice()) {
|
||||
case "Green":
|
||||
|
@ -110,8 +112,7 @@ class GoblinClearCutterManaEffect extends ManaEffect {
|
|||
break;
|
||||
}
|
||||
}
|
||||
return mana;
|
||||
}
|
||||
return null;
|
||||
return mana;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -204,6 +204,10 @@ class IceCauldronAddManaEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Mana mana = new Mana();
|
||||
if (game == null) {
|
||||
return mana;
|
||||
}
|
||||
Permanent iceCauldron = game.getPermanent(source.getSourceId());
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (iceCauldron != null && controller != null) {
|
||||
|
@ -222,7 +226,7 @@ class IceCauldronAddManaEffect extends ManaEffect {
|
|||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return mana;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -103,8 +103,11 @@ class AnyColorLandsProduceManaEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
int manaAmount = getManaAmount(game, source);
|
||||
Mana mana = new Mana();
|
||||
if (game == null) {
|
||||
return mana;
|
||||
}
|
||||
int manaAmount = getManaAmount(game, source);
|
||||
Mana types = getManaTypes(game, source);
|
||||
Choice choice = new ChoiceColor(true);
|
||||
choice.getChoices().clear();
|
||||
|
@ -140,7 +143,7 @@ class AnyColorLandsProduceManaEffect extends ManaEffect {
|
|||
if (choice.getChoices().size() == 1) {
|
||||
choice.setChoice(choice.getChoices().iterator().next());
|
||||
} else if (player == null || !player.choose(outcome, choice, game)) {
|
||||
return null;
|
||||
return mana;
|
||||
}
|
||||
if (choice.getChoice() != null) {
|
||||
switch (choice.getChoice()) {
|
||||
|
@ -174,9 +177,11 @@ class AnyColorLandsProduceManaEffect extends ManaEffect {
|
|||
}
|
||||
|
||||
private int getManaAmount(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null && permanent.getCounters(game).getCount(CounterType.P1P1) > 0) {
|
||||
return 3;
|
||||
if (game != null) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null && permanent.getCounters(game).getCount(CounterType.P1P1) > 0) {
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import mage.game.Game;
|
|||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -64,16 +65,19 @@ class JackInTheMoxManaEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public List<Mana> getNetMana(Game game, Ability source) {
|
||||
return null;
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Mana mana = new Mana();
|
||||
if (game == null) {
|
||||
return mana;
|
||||
}
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (controller != null && permanent != null) {
|
||||
int amount = controller.rollDice(game, 6);
|
||||
Mana mana = new Mana();
|
||||
switch (amount) {
|
||||
case 1:
|
||||
permanent.sacrifice(source.getSourceId(), game);
|
||||
|
@ -97,9 +101,8 @@ class JackInTheMoxManaEffect extends ManaEffect {
|
|||
default:
|
||||
break;
|
||||
}
|
||||
return mana;
|
||||
}
|
||||
return null;
|
||||
return mana;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
|
||||
package mage.cards.j;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.common.SourceHasCounterCondition;
|
||||
|
@ -24,8 +22,9 @@ import mage.game.permanent.Permanent;
|
|||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jeffwadsworth
|
||||
*/
|
||||
public final class JeweledAmulet extends CardImpl {
|
||||
|
@ -113,6 +112,10 @@ class JeweledAmuletAddManaEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Mana mana = new Mana();
|
||||
if (game == null) {
|
||||
return mana;
|
||||
}
|
||||
Permanent jeweledAmulet = game.getPermanent(source.getSourceId());
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (jeweledAmulet != null && controller != null) {
|
||||
|
@ -121,7 +124,7 @@ class JeweledAmuletAddManaEffect extends ManaEffect {
|
|||
return storedMana.copy();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return mana;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -80,17 +80,23 @@ public final class KyrenToy extends CardImpl {
|
|||
|
||||
@Override
|
||||
public List<Mana> getNetMana(Game game, Ability source) {
|
||||
Permanent sourceObject = game.getPermanent(source.getSourceId());
|
||||
if (sourceObject != null) {
|
||||
List<Mana> netMana = new ArrayList<>();
|
||||
netMana.add(Mana.ColorlessMana(sourceObject.getCounters(game).getCount(CounterType.CHARGE) + 1));
|
||||
return netMana;
|
||||
List<Mana> netMana = new ArrayList<>();
|
||||
if (game != null) {
|
||||
Permanent sourceObject = game.getPermanent(source.getSourceId());
|
||||
if (sourceObject != null) {
|
||||
netMana.add(Mana.ColorlessMana(sourceObject.getCounters(game).getCount(CounterType.CHARGE) + 1));
|
||||
return netMana;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return netMana;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Mana mana = new Mana();
|
||||
if (game == null) {
|
||||
return mana;
|
||||
}
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
int numberOfMana = 0;
|
||||
|
@ -101,7 +107,7 @@ public final class KyrenToy extends CardImpl {
|
|||
}
|
||||
return new Mana(Mana.ColorlessMana(numberOfMana + 1));
|
||||
}
|
||||
return null;
|
||||
return mana;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -13,6 +13,7 @@ import mage.constants.Zone;
|
|||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -56,20 +57,22 @@ class MadScienceFairManaEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public List<Mana> getNetMana(Game game, Ability source) {
|
||||
return null;
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
int amount = controller.rollDice(game, 6);
|
||||
if (amount <= 3) {
|
||||
return Mana.ColorlessMana(1);
|
||||
} else {
|
||||
return ManaChoice.chooseAnyColor(controller, game, 1);
|
||||
if (game != null) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
int amount = controller.rollDice(game, 6);
|
||||
if (amount <= 3) {
|
||||
return Mana.ColorlessMana(1);
|
||||
} else {
|
||||
return ManaChoice.chooseAnyColor(controller, game, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return new Mana();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import mage.constants.Zone;
|
|||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -87,16 +88,17 @@ class ManaScrewEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public List<Mana> getNetMana(Game game, Ability source) {
|
||||
return null;
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Player player = getPlayer(game, source);
|
||||
if (player != null && player.flipCoin(source, game, true)) {
|
||||
return Mana.ColorlessMana(2);
|
||||
} else {
|
||||
return new Mana();
|
||||
if (game != null) {
|
||||
Player player = getPlayer(game, source);
|
||||
if (player != null && player.flipCoin(source, game, true)) {
|
||||
return Mana.ColorlessMana(2);
|
||||
}
|
||||
}
|
||||
return new Mana();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,8 +120,11 @@ class MarketFestivalManaEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Player controller = getPlayer(game, source);
|
||||
return ManaChoice.chooseAnyColor(controller, game, 2);
|
||||
if (game != null) {
|
||||
Player controller = getPlayer(game, source);
|
||||
return ManaChoice.chooseAnyColor(controller, game, 2);
|
||||
}
|
||||
return new Mana();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -67,23 +67,28 @@ class MetalworkerManaEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public List<Mana> getNetMana(Game game, Ability source) {
|
||||
Player controller = getPlayer(game, source);
|
||||
if (controller == null) {
|
||||
return null;
|
||||
}
|
||||
List<Mana> netMana = new ArrayList<>();
|
||||
int artifacts = controller.getHand().count(StaticFilters.FILTER_CARD_ARTIFACT, game);
|
||||
if (artifacts > 0) {
|
||||
netMana.add(Mana.ColorlessMana(artifacts * 2));
|
||||
if (game != null) {
|
||||
Player controller = getPlayer(game, source);
|
||||
if (controller != null) {
|
||||
int artifacts = controller.getHand().count(StaticFilters.FILTER_CARD_ARTIFACT, game);
|
||||
if (artifacts > 0) {
|
||||
netMana.add(Mana.ColorlessMana(artifacts * 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
return netMana;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Mana mana = new Mana();
|
||||
if (game == null) {
|
||||
return mana;
|
||||
}
|
||||
Player controller = getPlayer(game, source);
|
||||
if (controller == null) {
|
||||
return null;
|
||||
return mana;
|
||||
}
|
||||
int artifacts = controller.getHand().count(StaticFilters.FILTER_CARD_ARTIFACT, game);
|
||||
if (artifacts > 0) {
|
||||
|
@ -94,6 +99,6 @@ class MetalworkerManaEffect extends ManaEffect {
|
|||
return Mana.ColorlessMana(target.getTargets().size() * 2);
|
||||
}
|
||||
}
|
||||
return new Mana();
|
||||
return mana;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,6 +86,10 @@ class MeteorCraterEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Mana mana = new Mana();
|
||||
if (game == null) {
|
||||
return mana;
|
||||
}
|
||||
Mana types = getManaTypes(game, source);
|
||||
Choice choice = new ChoiceColor(true);
|
||||
choice.getChoices().clear();
|
||||
|
@ -121,7 +125,6 @@ class MeteorCraterEffect extends ManaEffect {
|
|||
player.choose(outcome, choice, game);
|
||||
}
|
||||
if (choice.getChoice() != null) {
|
||||
Mana mana = new Mana();
|
||||
switch (choice.getChoice()) {
|
||||
case "Black":
|
||||
mana.setBlack(1);
|
||||
|
@ -139,31 +142,32 @@ class MeteorCraterEffect extends ManaEffect {
|
|||
mana.setWhite(1);
|
||||
break;
|
||||
}
|
||||
return mana;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return mana;
|
||||
}
|
||||
|
||||
private Mana getManaTypes(Game game, Ability source) {
|
||||
List<Permanent> controlledPermanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game);
|
||||
Mana types = new Mana();
|
||||
for (Permanent permanent : controlledPermanents) {
|
||||
ObjectColor color = permanent.getColor(game);
|
||||
if (color.isBlack()) {
|
||||
types.add(Mana.BlackMana(1));
|
||||
}
|
||||
if (color.isBlue()) {
|
||||
types.add(Mana.BlueMana(1));
|
||||
}
|
||||
if (color.isGreen()) {
|
||||
types.add(Mana.GreenMana(1));
|
||||
}
|
||||
if (color.isRed()) {
|
||||
types.add(Mana.RedMana(1));
|
||||
}
|
||||
if (color.isWhite()) {
|
||||
types.add(Mana.WhiteMana(1));
|
||||
if (game != null) {
|
||||
List<Permanent> controlledPermanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game);
|
||||
for (Permanent permanent : controlledPermanents) {
|
||||
ObjectColor color = permanent.getColor(game);
|
||||
if (color.isBlack()) {
|
||||
types.add(Mana.BlackMana(1));
|
||||
}
|
||||
if (color.isBlue()) {
|
||||
types.add(Mana.BlueMana(1));
|
||||
}
|
||||
if (color.isGreen()) {
|
||||
types.add(Mana.GreenMana(1));
|
||||
}
|
||||
if (color.isRed()) {
|
||||
types.add(Mana.RedMana(1));
|
||||
}
|
||||
if (color.isWhite()) {
|
||||
types.add(Mana.WhiteMana(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
return types;
|
||||
|
|
|
@ -71,12 +71,11 @@ class NykthosShrineToNyxManaAbility extends ActivatedManaAbilityImpl {
|
|||
|
||||
@Override
|
||||
public List<Mana> getNetMana(Game game) {
|
||||
List<Mana> netManaCopy = new ArrayList<>();
|
||||
if (game == null) {
|
||||
return netManaCopy;
|
||||
List<Mana> netMana = new ArrayList<>();
|
||||
if (game != null) {
|
||||
netMana.addAll(((ManaEffect) this.getEffects().get(0)).getNetMana(game, this));
|
||||
}
|
||||
netManaCopy.addAll(((ManaEffect) this.getEffects().get(0)).getNetMana(game, this));
|
||||
return netManaCopy;
|
||||
return netMana;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,30 +97,38 @@ class NykthosDynamicManaEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public List<Mana> getNetMana(Game game, Ability source) {
|
||||
return ChoiceColor.getBaseColors()
|
||||
.stream()
|
||||
.map(s -> computeMana(s, game, source))
|
||||
.filter(mana -> mana.count() > 0)
|
||||
.collect(Collectors.toList());
|
||||
if (game != null) {
|
||||
return ChoiceColor.getBaseColors()
|
||||
.stream()
|
||||
.map(s -> computeMana(s, game, source))
|
||||
.filter(mana -> mana.count() > 0)
|
||||
.collect(Collectors.toList());
|
||||
} else {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Mana mana = new Mana();
|
||||
if (game == null) {
|
||||
return mana;
|
||||
}
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller == null) {
|
||||
return null;
|
||||
return mana;
|
||||
}
|
||||
ChoiceColor choice = new ChoiceColor();
|
||||
choice.setMessage("Choose a color for devotion of Nykthos");
|
||||
if (!controller.choose(outcome, choice, game)) {
|
||||
return null;
|
||||
return mana;
|
||||
}
|
||||
return computeMana(choice.getChoice(), game, source);
|
||||
}
|
||||
|
||||
private Mana computeMana(String color, Game game, Ability source) {
|
||||
Mana mana = new Mana();
|
||||
if (color == null || color.isEmpty()) {
|
||||
if (game == null || color == null || color.isEmpty()) {
|
||||
return mana;
|
||||
}
|
||||
switch (color) {
|
||||
|
|
|
@ -70,12 +70,11 @@ class NyxLotusManaAbility extends ActivatedManaAbilityImpl {
|
|||
|
||||
@Override
|
||||
public List<Mana> getNetMana(Game game) {
|
||||
List<Mana> netManaCopy = new ArrayList<>();
|
||||
if (game == null) {
|
||||
return netManaCopy;
|
||||
List<Mana> netMana = new ArrayList<>();
|
||||
if (game != null) {
|
||||
netMana.addAll(((ManaEffect) this.getEffects().get(0)).getNetMana(game, this));
|
||||
}
|
||||
netManaCopy.addAll(((ManaEffect) this.getEffects().get(0)).getNetMana(game, this));
|
||||
return netManaCopy;
|
||||
return netMana;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,30 +96,38 @@ class NyxLotusDynamicManaEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public List<Mana> getNetMana(Game game, Ability source) {
|
||||
return ChoiceColor.getBaseColors()
|
||||
.stream()
|
||||
.map(s -> computeMana(s, game, source))
|
||||
.filter(mana -> mana.count() > 0)
|
||||
.collect(Collectors.toList());
|
||||
if (game != null) {
|
||||
return ChoiceColor.getBaseColors()
|
||||
.stream()
|
||||
.map(s -> computeMana(s, game, source))
|
||||
.filter(mana -> mana.count() > 0)
|
||||
.collect(Collectors.toList());
|
||||
} else {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Mana mana = new Mana();
|
||||
if (game == null) {
|
||||
return mana;
|
||||
}
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller == null) {
|
||||
return null;
|
||||
return mana;
|
||||
}
|
||||
ChoiceColor choice = new ChoiceColor();
|
||||
choice.setMessage("Choose a color for devotion of Nyx Lotus");
|
||||
if (!controller.choose(outcome, choice, game)) {
|
||||
return null;
|
||||
return mana;
|
||||
}
|
||||
return computeMana(choice.getChoice(), game, source);
|
||||
}
|
||||
|
||||
private Mana computeMana(String color, Game game, Ability source) {
|
||||
Mana mana = new Mana();
|
||||
if (color == null || color.isEmpty()) {
|
||||
if (game == null || color == null || color.isEmpty()) {
|
||||
return mana;
|
||||
}
|
||||
switch (color) {
|
||||
|
|
|
@ -87,6 +87,10 @@ class OrcishLumberjackManaEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Mana mana = new Mana();
|
||||
if (game == null) {
|
||||
return mana;
|
||||
}
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
Choice manaChoice = new ChoiceImpl();
|
||||
|
@ -95,11 +99,9 @@ class OrcishLumberjackManaEffect extends ManaEffect {
|
|||
choices.add("Green");
|
||||
manaChoice.setChoices(choices);
|
||||
manaChoice.setMessage("Select color of mana to add");
|
||||
|
||||
Mana mana = new Mana();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (!player.choose(Outcome.Benefit, manaChoice, game)) {
|
||||
return null;
|
||||
return mana;
|
||||
}
|
||||
switch (manaChoice.getChoice()) {
|
||||
case "Green":
|
||||
|
@ -110,9 +112,8 @@ class OrcishLumberjackManaEffect extends ManaEffect {
|
|||
break;
|
||||
}
|
||||
}
|
||||
return mana;
|
||||
}
|
||||
return null;
|
||||
return mana;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -101,8 +101,11 @@ class RhysticCaveManaEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Player controller = getPlayer(game, source);
|
||||
return ManaChoice.chooseAnyColor(controller, game, 1);
|
||||
if (game != null) {
|
||||
Player controller = getPlayer(game, source);
|
||||
return ManaChoice.chooseAnyColor(controller, game, 1);
|
||||
}
|
||||
return new Mana();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
|
||||
package mage.cards.r;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.common.ManaEffect;
|
||||
|
@ -13,8 +11,9 @@ import mage.filter.predicate.mageobject.NamePredicate;
|
|||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Plopman
|
||||
*/
|
||||
public final class RiteOfFlame extends CardImpl {
|
||||
|
@ -55,14 +54,17 @@ class RiteOfFlameManaEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
int count = 0;
|
||||
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
count += player.getGraveyard().count(filter, game);
|
||||
if (game != null) {
|
||||
int count = 0;
|
||||
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
count += player.getGraveyard().count(filter, game);
|
||||
}
|
||||
}
|
||||
return Mana.RedMana(count + 2);
|
||||
}
|
||||
return Mana.RedMana(count + 2);
|
||||
return new Mana();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -70,25 +70,28 @@ class SacellumGodspeakerEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public List<Mana> getNetMana(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
List<Mana> netMana = new ArrayList<>();
|
||||
int count = controller.getHand().count(filter, game);
|
||||
if (count > 0) {
|
||||
netMana.add(Mana.GreenMana(count));
|
||||
List<Mana> netMana = new ArrayList<>();
|
||||
if (game != null) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
int count = controller.getHand().count(filter, game);
|
||||
if (count > 0) {
|
||||
netMana.add(Mana.GreenMana(count));
|
||||
}
|
||||
}
|
||||
return netMana;
|
||||
}
|
||||
return null;
|
||||
return netMana;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
TargetCardInHand target = new TargetCardInHand(0, Integer.MAX_VALUE, filter);
|
||||
if (target.choose(Outcome.Benefit, source.getControllerId(), source.getSourceId(), game)) {
|
||||
return Mana.GreenMana(target.getTargets().size());
|
||||
if (game != null) {
|
||||
TargetCardInHand target = new TargetCardInHand(0, Integer.MAX_VALUE, filter);
|
||||
if (target.choose(Outcome.Benefit, source.getControllerId(), source.getSourceId(), game)) {
|
||||
return Mana.GreenMana(target.getTargets().size());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return new Mana();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import mage.game.permanent.Permanent;
|
|||
import mage.game.permanent.token.TokenImpl;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -132,16 +133,19 @@ class SasayasEssenceManaEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public List<Mana> getNetMana(Game game, Ability source) {
|
||||
return null;
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Mana newMana = new Mana();
|
||||
if (game == null) {
|
||||
return newMana;
|
||||
}
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Mana mana = (Mana) this.getValue("mana");
|
||||
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||
if (controller != null && mana != null && permanent != null) {
|
||||
Mana newMana = new Mana();
|
||||
FilterPermanent filter = new FilterLandPermanent();
|
||||
filter.add(Predicates.not(new PermanentIdPredicate(permanent.getId())));
|
||||
filter.add(new NamePredicate(permanent.getName()));
|
||||
|
@ -177,7 +181,7 @@ class SasayasEssenceManaEffect extends ManaEffect {
|
|||
choice.setChoice(choice.getChoices().iterator().next());
|
||||
} else {
|
||||
if (!controller.choose(outcome, choice, game)) {
|
||||
return null;
|
||||
return newMana;
|
||||
}
|
||||
}
|
||||
switch (choice.getChoice()) {
|
||||
|
@ -204,8 +208,7 @@ class SasayasEssenceManaEffect extends ManaEffect {
|
|||
|
||||
}
|
||||
}
|
||||
return newMana;
|
||||
}
|
||||
return null;
|
||||
return newMana;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import mage.constants.*;
|
|||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -69,16 +70,19 @@ class SelvalaExplorerReturnedEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public List<Mana> getNetMana(Game game, Ability source) {
|
||||
return null;
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
int parleyCount = ParleyCount.getInstance().calculate(game, source, this);
|
||||
Player player = getPlayer(game, source);
|
||||
if (player != null) {
|
||||
player.gainLife(parleyCount, game, source);
|
||||
if (game != null) {
|
||||
int parleyCount = ParleyCount.getInstance().calculate(game, source, this);
|
||||
Player player = getPlayer(game, source);
|
||||
if (player != null) {
|
||||
player.gainLife(parleyCount, game, source);
|
||||
}
|
||||
return Mana.GreenMana(parleyCount);
|
||||
}
|
||||
return Mana.GreenMana(parleyCount);
|
||||
return new Mana();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,8 +70,11 @@ class SpectralSearchlightManaEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Player player = getPlayer(game, source);
|
||||
return ManaChoice.chooseAnyColor(player, game, 1);
|
||||
if (game != null) {
|
||||
Player player = getPlayer(game, source);
|
||||
return ManaChoice.chooseAnyColor(player, game, 1);
|
||||
}
|
||||
return new Mana();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -88,6 +88,10 @@ class SquanderedResourcesEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Mana mana = new Mana();
|
||||
if (game == null) {
|
||||
return mana;
|
||||
}
|
||||
Mana types = getManaTypes(game, source);
|
||||
Choice choice = new ChoiceColor(true);
|
||||
choice.getChoices().clear();
|
||||
|
@ -118,7 +122,6 @@ class SquanderedResourcesEffect extends ManaEffect {
|
|||
choice.getChoices().add("White");
|
||||
choice.getChoices().add("Colorless");
|
||||
}
|
||||
Mana mana = new Mana();
|
||||
if (!choice.getChoices().isEmpty()) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player == null) {
|
||||
|
@ -128,7 +131,7 @@ class SquanderedResourcesEffect extends ManaEffect {
|
|||
choice.setChoice(choice.getChoices().iterator().next());
|
||||
} else {
|
||||
if (!player.choose(outcome, choice, game)) {
|
||||
return null;
|
||||
return mana;
|
||||
}
|
||||
}
|
||||
switch (choice.getChoice()) {
|
||||
|
@ -151,7 +154,6 @@ class SquanderedResourcesEffect extends ManaEffect {
|
|||
mana.setColorless(1);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
return mana;
|
||||
}
|
||||
|
|
|
@ -94,6 +94,10 @@ class StarCompassManaEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Mana mana = new Mana();
|
||||
if (game == null) {
|
||||
return mana;
|
||||
}
|
||||
Mana types = getManaTypes(game, source);
|
||||
Choice choice = new ChoiceColor(true);
|
||||
choice.getChoices().clear();
|
||||
|
@ -133,11 +137,10 @@ class StarCompassManaEffect extends ManaEffect {
|
|||
choice.setChoice(choice.getChoices().iterator().next());
|
||||
} else {
|
||||
if (!player.choose(outcome, choice, game)) {
|
||||
return null;
|
||||
return mana;
|
||||
}
|
||||
}
|
||||
if (choice.getChoice() != null) {
|
||||
Mana mana = new Mana();
|
||||
switch (choice.getChoice()) {
|
||||
case "Black":
|
||||
mana.setBlack(1);
|
||||
|
@ -158,21 +161,22 @@ class StarCompassManaEffect extends ManaEffect {
|
|||
mana.setColorless(1);
|
||||
break;
|
||||
}
|
||||
return mana;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return mana;
|
||||
}
|
||||
|
||||
private Mana getManaTypes(Game game, Ability source) {
|
||||
List<Permanent> lands = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game);
|
||||
Mana types = new Mana();
|
||||
for (Permanent land : lands) {
|
||||
Abilities<ActivatedManaAbilityImpl> manaAbilities = land.getAbilities().getActivatedManaAbilities(Zone.BATTLEFIELD);
|
||||
for (ActivatedManaAbilityImpl ability : manaAbilities) {
|
||||
if (!ability.equals(source) && ability.definesMana(game)) {
|
||||
for (Mana netMana : ability.getNetMana(game)) {
|
||||
types.add(netMana);
|
||||
if (game != null) {
|
||||
List<Permanent> lands = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game);
|
||||
for (Permanent land : lands) {
|
||||
Abilities<ActivatedManaAbilityImpl> manaAbilities = land.getAbilities().getActivatedManaAbilities(Zone.BATTLEFIELD);
|
||||
for (ActivatedManaAbilityImpl ability : manaAbilities) {
|
||||
if (!ability.equals(source) && ability.definesMana(game)) {
|
||||
for (Mana netMana : ability.getNetMana(game)) {
|
||||
types.add(netMana);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
|
||||
package mage.cards.u;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.Mana;
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Ability;
|
||||
|
@ -23,8 +21,9 @@ import mage.players.Player;
|
|||
import mage.target.TargetPermanent;
|
||||
import mage.target.common.TargetLandPermanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Plopman
|
||||
*/
|
||||
public final class UtopiaSprawl extends CardImpl {
|
||||
|
@ -114,12 +113,13 @@ class UtopiaSprawlEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
ObjectColor color = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color");
|
||||
if (color != null) {
|
||||
return new Mana(ColoredManaSymbol.lookup(color.toString().charAt(0)));
|
||||
} else {
|
||||
return null;
|
||||
if (game != null) {
|
||||
ObjectColor color = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color");
|
||||
if (color != null) {
|
||||
return new Mana(ColoredManaSymbol.lookup(color.toString().charAt(0)));
|
||||
}
|
||||
}
|
||||
return new Mana();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -113,12 +113,14 @@ class VedalkenEngineerEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
ChoiceColor choiceColor = new ChoiceColor(true);
|
||||
if (controller != null && controller.choose(Outcome.Benefit, choiceColor, game)) {
|
||||
return manaBuilder.setMana(choiceColor.getMana(amount), source, game).build();
|
||||
if (game != null) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
ChoiceColor choiceColor = new ChoiceColor(true);
|
||||
if (controller != null && controller.choose(Outcome.Benefit, choiceColor, game)) {
|
||||
return manaBuilder.setMana(choiceColor.getMana(amount), source, game).build();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return new Mana();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package org.mage.test.AI.basic;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBaseWithAIHelps;
|
||||
|
||||
/**
|
||||
* @author JayDi85
|
||||
*/
|
||||
public class CommanderCardScore extends CardTestPlayerBaseWithAIHelps {
|
||||
|
||||
@Test
|
||||
public void test_CommanderColorIdentityManaAbility() {
|
||||
// NPE error: https://www.reddit.com/r/XMage/comments/f8yzgg/game_error_with_any_mana_lands/
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Command Tower", 1);
|
||||
|
||||
// AI must play one time to run score calc
|
||||
// Verify tests checking all cards with broken getMana()
|
||||
aiPlayPriority(1, PhaseStep.PRECOMBAT_MAIN, playerA);
|
||||
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
setStrictChooseMode(true);
|
||||
execute();
|
||||
assertAllCommandsUsed();
|
||||
}
|
||||
}
|
|
@ -507,16 +507,19 @@ public class VerifyCardDataTest {
|
|||
}
|
||||
}
|
||||
|
||||
// 2. all planeswalkers must be legendary
|
||||
for (ExpansionSet set : sets) {
|
||||
for (ExpansionSet.SetCardInfo cardInfo : set.getSetCardInfo()) {
|
||||
Card card = CardImpl.createCard(cardInfo.getCardClass(), new CardSetInfo(cardInfo.getName(), set.getCode(),
|
||||
cardInfo.getCardNumber(), cardInfo.getRarity(), cardInfo.getGraphicInfo()));
|
||||
Assert.assertNotNull(card);
|
||||
|
||||
// 2. all planeswalkers must be legendary
|
||||
if (card.getCardType().contains(CardType.PLANESWALKER) && !card.getSuperType().contains(SuperType.LEGENDARY)) {
|
||||
errorsList.add("error, planeswalker must have legendary type: " + set.getCode() + " - " + set.getName() + " - " + card.getName() + " - " + card.getCardNumber());
|
||||
}
|
||||
|
||||
// 3. check that getMana works without NPE errors (it uses getNetMana with empty game param for AI score calcs)
|
||||
card.getMana();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,10 +11,7 @@ import mage.constants.*;
|
|||
import mage.game.Game;
|
||||
import org.junit.Assert;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Adds condition to {@link ContinuousEffect}. Acts as decorator.
|
||||
|
@ -34,7 +31,7 @@ public class ConditionalContinuousEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
|
||||
/**
|
||||
* Only use this if both effects have the same layers
|
||||
* Only use this if both effects have the same layers (TODO: add tests to search it?)
|
||||
*
|
||||
* @param effect
|
||||
* @param otherwiseEffect
|
||||
|
@ -178,4 +175,13 @@ public class ConditionalContinuousEffect extends ContinuousEffectImpl {
|
|||
return super.isDependentTo(allEffectsInLayer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all effects list, for tests only
|
||||
*/
|
||||
public List<ContinuousEffect> getAllEffects() {
|
||||
List<ContinuousEffect> res = new ArrayList<>();
|
||||
if (this.effect != null) res.add(this.effect);
|
||||
if (this.otherwiseEffect != null) res.add(this.otherwiseEffect);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package mage.abilities.decorator;
|
||||
|
||||
import java.util.List;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
|
@ -10,8 +9,10 @@ import mage.choices.ChoiceColor;
|
|||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class ConditionalManaEffect extends ManaEffect {
|
||||
|
@ -48,17 +49,23 @@ public class ConditionalManaEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public List<Mana> getNetMana(Game game, Ability source) {
|
||||
if (condition.apply(game, source)) {
|
||||
return effect.getNetMana(game, source);
|
||||
} else if (otherwiseEffect != null) {
|
||||
return otherwiseEffect.getNetMana(game, source);
|
||||
List<Mana> netMana = new ArrayList<>();
|
||||
if (game != null) {
|
||||
if (condition.apply(game, source)) {
|
||||
return effect.getNetMana(game, source);
|
||||
} else if (otherwiseEffect != null) {
|
||||
return otherwiseEffect.getNetMana(game, source);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return netMana;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Mana mana = new Mana();
|
||||
if (game == null) {
|
||||
return mana;
|
||||
}
|
||||
if (condition.apply(game, source)) {
|
||||
mana = effect.getManaTemplate().copy();
|
||||
} else if (otherwiseEffect != null) {
|
||||
|
|
|
@ -58,7 +58,7 @@ public abstract class ManaEffect extends OneShotEffect {
|
|||
* Returns the currently available max mana variations the effect can
|
||||
* produce
|
||||
*
|
||||
* @param game
|
||||
* @param game warning, can be NULL for card score calcs (AI games)
|
||||
* @param source
|
||||
* @return
|
||||
*/
|
||||
|
@ -78,7 +78,7 @@ public abstract class ManaEffect extends OneShotEffect {
|
|||
* if you don't want it then overide getNetMana to return max possible mana values
|
||||
* (if you have choose dialogs or extra effects like new counters in produceMana)
|
||||
*
|
||||
* @param game
|
||||
* @param game warning, can be NULL for AI score calcs (game == null)
|
||||
* @param source
|
||||
* @return can return null or empty mana
|
||||
*/
|
||||
|
|
|
@ -39,7 +39,11 @@ public class AddConditionalManaEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
return manaBuilder.setMana(mana, source, game).build();
|
||||
if (game != null) {
|
||||
return manaBuilder.setMana(mana, source, game).build();
|
||||
} else {
|
||||
return new Mana();
|
||||
}
|
||||
}
|
||||
|
||||
public Mana getMana() {
|
||||
|
|
|
@ -65,45 +65,45 @@ public class AddConditionalManaOfAnyColorEffect extends ManaEffect {
|
|||
@Override
|
||||
public List<Mana> getNetMana(Game game, Ability source) {
|
||||
List<Mana> netMana = new ArrayList<>();
|
||||
|
||||
int value = amount.calculate(game, source, this);
|
||||
if (value > 0) {
|
||||
netMana.add(Mana.AnyMana(value));
|
||||
if (game != null) {
|
||||
int value = amount.calculate(game, source, this);
|
||||
if (value > 0) {
|
||||
netMana.add(Mana.AnyMana(value));
|
||||
}
|
||||
}
|
||||
|
||||
return netMana;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller == null) {
|
||||
return null;
|
||||
}
|
||||
ConditionalMana mana = null;
|
||||
int value = amount.calculate(game, source, this);
|
||||
ChoiceColor choice = new ChoiceColor(true);
|
||||
for (int i = 0; i < value; i++) {
|
||||
if (choice.getChoice() == null) {
|
||||
controller.choose(outcome, choice, game);
|
||||
}
|
||||
if (choice.getChoice() == null) {
|
||||
return null;
|
||||
}
|
||||
if (oneChoice) {
|
||||
mana = new ConditionalMana(manaBuilder.setMana(choice.getMana(value), source, game).build());
|
||||
break;
|
||||
} else {
|
||||
if (mana == null) {
|
||||
mana = new ConditionalMana(manaBuilder.setMana(choice.getMana(1), source, game).build());
|
||||
} else {
|
||||
mana.add(choice.getMana(1));
|
||||
if (game != null) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
ConditionalMana mana = null;
|
||||
int value = amount.calculate(game, source, this);
|
||||
ChoiceColor choice = new ChoiceColor(true);
|
||||
for (int i = 0; i < value; i++) {
|
||||
if (choice.getChoice() == null) {
|
||||
controller.choose(outcome, choice, game);
|
||||
}
|
||||
if (choice.getChoice() == null) {
|
||||
return null;
|
||||
}
|
||||
if (oneChoice) {
|
||||
mana = new ConditionalMana(manaBuilder.setMana(choice.getMana(value), source, game).build());
|
||||
break;
|
||||
} else {
|
||||
if (mana == null) {
|
||||
mana = new ConditionalMana(manaBuilder.setMana(choice.getMana(1), source, game).build());
|
||||
} else {
|
||||
mana.add(choice.getMana(1));
|
||||
}
|
||||
choice.clearChoice();
|
||||
}
|
||||
}
|
||||
choice.clearChoice();
|
||||
return mana;
|
||||
}
|
||||
}
|
||||
|
||||
return mana;
|
||||
|
||||
return new Mana();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
*/
|
||||
package mage.abilities.effects.mana;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import mage.ConditionalMana;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
|
@ -16,14 +14,16 @@ import mage.choices.ManaChoice;
|
|||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jeffwadsworth
|
||||
*/
|
||||
public class AddConditionalManaOfTwoDifferentColorsEffect extends ManaEffect {
|
||||
|
||||
|
||||
private final ConditionalManaBuilder manaBuilder;
|
||||
|
||||
|
||||
public AddConditionalManaOfTwoDifferentColorsEffect(ConditionalManaBuilder manaBuilder) {
|
||||
super();
|
||||
this.manaBuilder = manaBuilder;
|
||||
|
@ -44,11 +44,14 @@ public class AddConditionalManaOfTwoDifferentColorsEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Player player = getPlayer(game, source);
|
||||
Mana mana = new ConditionalMana(manaBuilder.setMana(
|
||||
ManaChoice.chooseTwoDifferentColors(
|
||||
player, game), source, game).build());
|
||||
return mana;
|
||||
if (game != null) {
|
||||
Player player = getPlayer(game, source);
|
||||
Mana mana = new ConditionalMana(manaBuilder.setMana(
|
||||
ManaChoice.chooseTwoDifferentColors(
|
||||
player, game), source, game).build());
|
||||
return mana;
|
||||
}
|
||||
return new Mana();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -51,14 +51,16 @@ public class AddManaAnyColorAttachedControllerEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Permanent enchantment = game.getPermanent(source.getSourceId());
|
||||
if (enchantment != null) {
|
||||
Permanent land = game.getPermanent(enchantment.getAttachedTo());
|
||||
if (land != null) {
|
||||
Player player = game.getPlayer(land.getControllerId());
|
||||
ChoiceColor choice = new ChoiceColor();
|
||||
if (player != null && player.choose(outcome, choice, game)) {
|
||||
return choice.getMana(1);
|
||||
if (game != null) {
|
||||
Permanent enchantment = game.getPermanent(source.getSourceId());
|
||||
if (enchantment != null) {
|
||||
Permanent land = game.getPermanent(enchantment.getAttachedTo());
|
||||
if (land != null) {
|
||||
Player player = game.getPlayer(land.getControllerId());
|
||||
ChoiceColor choice = new ChoiceColor();
|
||||
if (player != null && player.choose(outcome, choice, game)) {
|
||||
return choice.getMana(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,12 +28,13 @@ public class AddManaChosenColorEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
ObjectColor color = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color");
|
||||
if (color != null) {
|
||||
return new Mana(ColoredManaSymbol.lookup(color.toString().charAt(0)));
|
||||
} else {
|
||||
return null;
|
||||
if (game != null) {
|
||||
ObjectColor color = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color");
|
||||
if (color != null) {
|
||||
return new Mana(ColoredManaSymbol.lookup(color.toString().charAt(0)));
|
||||
}
|
||||
}
|
||||
return new Mana();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -66,9 +66,11 @@ public class AddManaInAnyCombinationEffect extends ManaEffect {
|
|||
@Override
|
||||
public List<Mana> getNetMana(Game game, Ability source) {
|
||||
List<Mana> netMana = new ArrayList<>();
|
||||
int amountOfManaLeft = amount.calculate(game, source, this);
|
||||
if (amountOfManaLeft > 0) {
|
||||
netMana.add(Mana.AnyMana(amountOfManaLeft));
|
||||
if (game != null) {
|
||||
int amountOfManaLeft = amount.calculate(game, source, this);
|
||||
if (amountOfManaLeft > 0) {
|
||||
netMana.add(Mana.AnyMana(amountOfManaLeft));
|
||||
}
|
||||
}
|
||||
return netMana;
|
||||
}
|
||||
|
|
|
@ -54,21 +54,23 @@ public class AddManaOfAnyColorEffect extends BasicManaEffect {
|
|||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
String mes = String.format("Select color of %d mana to add it", this.amount);
|
||||
if (mes != null) {
|
||||
ChoiceColor choice = new ChoiceColor(true, mes, game.getObject(source.getSourceId()));
|
||||
if (controller.choose(outcome, choice, game)) {
|
||||
if (choice.getColor() != null) {
|
||||
Mana mana = choice.getMana(amount);
|
||||
mana.setFlag(setFlag);
|
||||
return mana;
|
||||
if (game != null) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
String mes = String.format("Select color of %d mana to add it", this.amount);
|
||||
if (mes != null) {
|
||||
ChoiceColor choice = new ChoiceColor(true, mes, game.getObject(source.getSourceId()));
|
||||
if (controller.choose(outcome, choice, game)) {
|
||||
if (choice.getColor() != null) {
|
||||
Mana mana = choice.getMana(amount);
|
||||
mana.setFlag(setFlag);
|
||||
return mana;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return new Mana();
|
||||
}
|
||||
|
||||
public int getAmount() {
|
||||
|
|
|
@ -47,71 +47,71 @@ public class AddManaOfAnyTypeProducedEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||
if (permanent != null) {
|
||||
Player targetController = game.getPlayer(permanent.getControllerId());
|
||||
if (targetController == null) {
|
||||
return null;
|
||||
}
|
||||
Mana types = (Mana) this.getValue("mana");
|
||||
if (types == null) {
|
||||
return null;
|
||||
}
|
||||
Choice choice = new ChoiceColor(true);
|
||||
choice.getChoices().clear();
|
||||
choice.setMessage("Pick the type of mana to produce");
|
||||
if (types.getBlack() > 0) {
|
||||
choice.getChoices().add("Black");
|
||||
}
|
||||
if (types.getRed() > 0) {
|
||||
choice.getChoices().add("Red");
|
||||
}
|
||||
if (types.getBlue() > 0) {
|
||||
choice.getChoices().add("Blue");
|
||||
}
|
||||
if (types.getGreen() > 0) {
|
||||
choice.getChoices().add("Green");
|
||||
}
|
||||
if (types.getWhite() > 0) {
|
||||
choice.getChoices().add("White");
|
||||
}
|
||||
if (types.getColorless() > 0) {
|
||||
choice.getChoices().add("Colorless");
|
||||
}
|
||||
Mana newMana = new Mana();
|
||||
if (!choice.getChoices().isEmpty()) {
|
||||
if (choice.getChoices().size() == 1) {
|
||||
choice.setChoice(choice.getChoices().iterator().next());
|
||||
} else {
|
||||
if (!targetController.choose(outcome, choice, game)) {
|
||||
return null;
|
||||
}
|
||||
Mana newMana = new Mana();
|
||||
if (game != null) {
|
||||
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||
if (permanent != null) {
|
||||
Player targetController = game.getPlayer(permanent.getControllerId());
|
||||
Mana types = (Mana) this.getValue("mana");
|
||||
if (targetController == null || types == null) {
|
||||
return newMana;
|
||||
}
|
||||
|
||||
switch (choice.getChoice()) {
|
||||
case "Black":
|
||||
newMana.setBlack(1);
|
||||
break;
|
||||
case "Blue":
|
||||
newMana.setBlue(1);
|
||||
break;
|
||||
case "Red":
|
||||
newMana.setRed(1);
|
||||
break;
|
||||
case "Green":
|
||||
newMana.setGreen(1);
|
||||
break;
|
||||
case "White":
|
||||
newMana.setWhite(1);
|
||||
break;
|
||||
case "Colorless":
|
||||
newMana.setColorless(1);
|
||||
break;
|
||||
Choice choice = new ChoiceColor(true);
|
||||
choice.getChoices().clear();
|
||||
choice.setMessage("Pick the type of mana to produce");
|
||||
if (types.getBlack() > 0) {
|
||||
choice.getChoices().add("Black");
|
||||
}
|
||||
if (types.getRed() > 0) {
|
||||
choice.getChoices().add("Red");
|
||||
}
|
||||
if (types.getBlue() > 0) {
|
||||
choice.getChoices().add("Blue");
|
||||
}
|
||||
if (types.getGreen() > 0) {
|
||||
choice.getChoices().add("Green");
|
||||
}
|
||||
if (types.getWhite() > 0) {
|
||||
choice.getChoices().add("White");
|
||||
}
|
||||
if (types.getColorless() > 0) {
|
||||
choice.getChoices().add("Colorless");
|
||||
}
|
||||
|
||||
if (!choice.getChoices().isEmpty()) {
|
||||
if (choice.getChoices().size() == 1) {
|
||||
choice.setChoice(choice.getChoices().iterator().next());
|
||||
} else {
|
||||
if (!targetController.choose(outcome, choice, game)) {
|
||||
return newMana;
|
||||
}
|
||||
}
|
||||
|
||||
switch (choice.getChoice()) {
|
||||
case "Black":
|
||||
newMana.setBlack(1);
|
||||
break;
|
||||
case "Blue":
|
||||
newMana.setBlue(1);
|
||||
break;
|
||||
case "Red":
|
||||
newMana.setRed(1);
|
||||
break;
|
||||
case "Green":
|
||||
newMana.setGreen(1);
|
||||
break;
|
||||
case "White":
|
||||
newMana.setWhite(1);
|
||||
break;
|
||||
case "Colorless":
|
||||
newMana.setColorless(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return newMana;
|
||||
}
|
||||
return null;
|
||||
return newMana;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -31,8 +31,12 @@ public class AddManaOfTwoDifferentColorsEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Player player = getPlayer(game, source);
|
||||
return ManaChoice.chooseTwoDifferentColors(player, game);
|
||||
if (game != null) {
|
||||
Player player = getPlayer(game, source);
|
||||
return ManaChoice.chooseTwoDifferentColors(player, game);
|
||||
} else {
|
||||
return new Mana();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,7 +16,6 @@ import mage.game.Game;
|
|||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -49,20 +48,23 @@ public class DoUnlessAnyPlayerPaysManaEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Player controller = getPlayer(game, source);
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
String message = CardUtil.replaceSourceName(chooseUseText, sourceObject.getName());
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && player.canRespond()
|
||||
&& cost.canPay(source, source.getSourceId(), player.getId(), game)
|
||||
&& player.chooseUse(Outcome.Detriment, message, source, game)) {
|
||||
cost.clearPaid();
|
||||
if (cost.pay(source, game, source.getSourceId(), player.getId(), false, null)) {
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(player.getLogName() + " pays the cost to prevent the effect");
|
||||
Mana mana = new Mana();
|
||||
if (game != null) {
|
||||
Player controller = getPlayer(game, source);
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
String message = CardUtil.replaceSourceName(chooseUseText, sourceObject.getName());
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && player.canRespond()
|
||||
&& cost.canPay(source, source.getSourceId(), player.getId(), game)
|
||||
&& player.chooseUse(Outcome.Detriment, message, source, game)) {
|
||||
cost.clearPaid();
|
||||
if (cost.pay(source, game, source.getSourceId(), player.getId(), false, null)) {
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(player.getLogName() + " pays the cost to prevent the effect");
|
||||
}
|
||||
return mana;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,6 +82,10 @@ public class DynamicManaEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public List<Mana> getNetMana(Game game, Ability source) {
|
||||
List<Mana> netMana = new ArrayList<>();
|
||||
if (game == null) {
|
||||
return netMana;
|
||||
}
|
||||
Mana computedMana = new Mana();
|
||||
int count;
|
||||
if (netAmount != null) {
|
||||
|
@ -108,7 +112,6 @@ public class DynamicManaEffect extends ManaEffect {
|
|||
} else {
|
||||
computedMana.setGeneric(count);
|
||||
}
|
||||
List<Mana> netMana = new ArrayList<>();
|
||||
netMana.add(computedMana);
|
||||
return netMana;
|
||||
}
|
||||
|
@ -116,8 +119,10 @@ public class DynamicManaEffect extends ManaEffect {
|
|||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Mana computedMana = new Mana();
|
||||
if (game == null) {
|
||||
return computedMana;
|
||||
}
|
||||
int count = amount.calculate(game, source, this);
|
||||
|
||||
if (baseMana.getBlack() > 0) {
|
||||
computedMana.setBlack(count);
|
||||
} else if (baseMana.getBlue() > 0) {
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
package mage.abilities.mana;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.Mana;
|
||||
import mage.abilities.ActivatedAbilityImpl;
|
||||
import mage.abilities.costs.Cost;
|
||||
|
@ -14,8 +11,11 @@ import mage.constants.TimingRule;
|
|||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public abstract class ActivatedManaAbilityImpl extends ActivatedAbilityImpl implements ManaAbility {
|
||||
|
@ -63,6 +63,8 @@ public abstract class ActivatedManaAbilityImpl extends ActivatedAbilityImpl impl
|
|||
/**
|
||||
* Used to check the possible mana production to determine which spells
|
||||
* and/or abilities can be used. (player.getPlayable()).
|
||||
* <p>
|
||||
* Also used for deck's card mana cycle with game = null (score system, etc)
|
||||
*
|
||||
* @param game
|
||||
* @return
|
||||
|
|
|
@ -115,6 +115,9 @@ class AnyColorLandsProduceManaEffect extends ManaEffect {
|
|||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Mana mana = new Mana();
|
||||
if (game == null) {
|
||||
return mana;
|
||||
}
|
||||
Mana types = getManaTypes(game, source);
|
||||
Choice choice = new ChoiceColor(true);
|
||||
choice.getChoices().clear();
|
||||
|
|
|
@ -110,6 +110,9 @@ class AnyColorPermanentTypesManaEffect extends ManaEffect {
|
|||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Mana mana = new Mana();
|
||||
if (game == null) {
|
||||
return mana;
|
||||
}
|
||||
Mana types = getManaTypes(game, source);
|
||||
Choice choice = new ChoiceColor(true);
|
||||
choice.getChoices().clear();
|
||||
|
|
|
@ -66,6 +66,9 @@ class CommanderIdentityManaEffect extends ManaEffect {
|
|||
@Override
|
||||
public List<Mana> getNetMana(Game game, Ability source) {
|
||||
List<Mana> netMana = new ArrayList<>();
|
||||
if (game == null) {
|
||||
return netMana;
|
||||
}
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
for (UUID commanderId : game.getCommandersIds(controller)) {
|
||||
|
@ -96,6 +99,9 @@ class CommanderIdentityManaEffect extends ManaEffect {
|
|||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
Mana mana = new Mana();
|
||||
if (game == null) {
|
||||
return mana;
|
||||
}
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
Choice choice = new ChoiceImpl();
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package mage.abilities.mana;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import mage.Mana;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
|
@ -10,6 +8,9 @@ import mage.constants.AbilityType;
|
|||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* see 20110715 - 605.1b
|
||||
*
|
||||
|
@ -53,7 +54,7 @@ public abstract class TriggeredManaAbility extends TriggeredAbilityImpl implemen
|
|||
}
|
||||
return newNetMana;
|
||||
}
|
||||
return new ArrayList<Mana>(netMana);
|
||||
return new ArrayList<>(netMana);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,7 +14,7 @@ public class ManaChoice {
|
|||
for (int i = 0; i < amount; i++) {
|
||||
ChoiceColor choiceColor = new ChoiceColor();
|
||||
if (amount > 1) {
|
||||
choiceColor.setMessage("Choose color " + (i+1));
|
||||
choiceColor.setMessage("Choose color " + (i + 1));
|
||||
}
|
||||
if (!player.choose(Outcome.Benefit, choiceColor, game)) {
|
||||
return null;
|
||||
|
@ -25,27 +25,28 @@ public class ManaChoice {
|
|||
}
|
||||
|
||||
public static Mana chooseTwoDifferentColors(Player player, Game game) {
|
||||
if (player == null) {
|
||||
return null;
|
||||
Mana mana = new Mana();
|
||||
|
||||
if (game == null || player == null) {
|
||||
return mana;
|
||||
}
|
||||
|
||||
ChoiceColor color1 = new ChoiceColor(true, "Choose color 1");
|
||||
if (!player.choose(Outcome.PutManaInPool, color1, game) || color1.getColor() == null) {
|
||||
return null;
|
||||
return mana;
|
||||
}
|
||||
|
||||
ChoiceColor color2 = new ChoiceColor(true, "Choose color 2");
|
||||
color2.removeColorFromChoices(color1.getChoice());
|
||||
if (!player.choose(Outcome.PutManaInPool, color2, game) || color2.getColor() == null) {
|
||||
return null;
|
||||
return mana;
|
||||
}
|
||||
|
||||
if (color1.getColor().equals(color2.getColor())) {
|
||||
game.informPlayers("Player " + player.getName() + " is cheating with mana choices.");
|
||||
return null;
|
||||
return mana;
|
||||
}
|
||||
|
||||
Mana mana = new Mana();
|
||||
mana.add(color1.getMana(1));
|
||||
mana.add(color2.getMana(1));
|
||||
return mana;
|
||||
|
|
Loading…
Reference in a new issue