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