mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
- CheckStyle.
This commit is contained in:
@@ -205,7 +205,7 @@ public class Deck extends DeckBase {
|
||||
d.getMain().set(Deck.readCardList(sections.get("main")));
|
||||
d.getSideboard().set(Deck.readCardList(sections.get("sideboard")));
|
||||
List<String> cmd = Deck.readCardList(sections.get("commander"));
|
||||
String cmdName = cmd.isEmpty() ? null : cmd.get(0);
|
||||
String cmdName = cmd.isEmpty() ? null : cmd.get(0);
|
||||
d.commander = CardDb.instance().isCardSupported(cmdName) ? CardDb.instance().getCard(cmdName) : null;
|
||||
d.getPlanes().set(Deck.readCardList(sections.get("planes")));
|
||||
d.getSchemes().set(Deck.readCardList(sections.get("schemes")));
|
||||
@@ -251,7 +251,7 @@ public class Deck extends DeckBase {
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
private static String serializeSingleCard(CardPrinted card, Integer n) {
|
||||
|
||||
final boolean hasBadSetInfo = "???".equals(card.getEdition()) || StringUtils.isBlank(card.getEdition());
|
||||
@@ -259,7 +259,7 @@ public class Deck extends DeckBase {
|
||||
return String.format("%d %s", n, card.getName());
|
||||
} else {
|
||||
return String.format("%d %s|%s", n, card.getName(), card.getEdition());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -285,15 +285,15 @@ public class Deck extends DeckBase {
|
||||
|
||||
out.add(String.format("%s", "[sideboard]"));
|
||||
out.addAll(Deck.writeCardPool(this.getSideboard()));
|
||||
|
||||
if ( getCommander() != null ) {
|
||||
|
||||
if (getCommander() != null) {
|
||||
out.add(String.format("%s", "[commander]"));
|
||||
out.add(Deck.serializeSingleCard(getCommander(), 1));
|
||||
}
|
||||
|
||||
|
||||
out.add(String.format("%s", "[planes]"));
|
||||
out.addAll(Deck.writeCardPool(this.getPlanes()));
|
||||
|
||||
|
||||
out.add(String.format("%s", "[schemes]"));
|
||||
out.addAll(Deck.writeCardPool(this.getSchemes()));
|
||||
return out;
|
||||
@@ -352,46 +352,54 @@ public class Deck extends DeckBase {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(type == GameType.Commander)
|
||||
{//Must contain exactly 1 legendary Commander and no sideboard.
|
||||
if (type == GameType.Commander) { //Must contain exactly 1 legendary Commander and no sideboard.
|
||||
|
||||
//TODO:Enforce color identity
|
||||
if ( null == getCommander())
|
||||
if (null == getCommander()) {
|
||||
return false;
|
||||
|
||||
if(!getCommander().getCard().getType().isLegendary())
|
||||
}
|
||||
if (!getCommander().getCard().getType().isLegendary()) {
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
//No sideboarding in Commander
|
||||
if(!getSideboard().isEmpty())
|
||||
if (!getSideboard().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(type == GameType.Planechase)
|
||||
{//Must contain at least 10 planes/phenomenons, but max 2 phenomenons. Singleton.
|
||||
if(getPlanes().countAll() < 10)
|
||||
else if (type == GameType.Planechase) { //Must contain at least 10 planes/phenomenons, but max 2 phenomenons. Singleton.
|
||||
|
||||
if (getPlanes().countAll() < 10) {
|
||||
return false;
|
||||
}
|
||||
int phenoms = 0;
|
||||
for(CardPrinted cp : getPlanes().toFlatList())
|
||||
{
|
||||
if(cp.getType().contains("Phenomenon"))
|
||||
for (CardPrinted cp : getPlanes().toFlatList()) {
|
||||
|
||||
if (cp.getType().contains("Phenomenon")) {
|
||||
phenoms++;
|
||||
if(getPlanes().count(cp) > 1)
|
||||
}
|
||||
if (getPlanes().count(cp) > 1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(phenoms > 2)
|
||||
if (phenoms > 2) {
|
||||
return false;
|
||||
}
|
||||
else if(type == GameType.Archenemy)
|
||||
{//Must contain at least 20 schemes, max 2 of each.
|
||||
if(getSchemes().countAll() < 20)
|
||||
return false;
|
||||
|
||||
for(CardPrinted cp : getSchemes().toFlatList())
|
||||
{
|
||||
if(getSchemes().count(cp) > 2)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
else if (type == GameType.Archenemy) { //Must contain at least 20 schemes, max 2 of each.
|
||||
|
||||
if (getSchemes().countAll() < 20) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (CardPrinted cp : getSchemes().toFlatList()) {
|
||||
|
||||
if (getSchemes().count(cp) > 2) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,9 +53,9 @@ public class GameNew {
|
||||
for (int i = 0; i < stackOfCards.getValue(); i++) {
|
||||
|
||||
final Card card = cardPrinted.toForgeCard(player);
|
||||
|
||||
|
||||
// apply random pictures for cards
|
||||
if ( player.isComputer() ) {
|
||||
if (player.isComputer()) {
|
||||
final int cntVariants = cardPrinted.getCard().getEditionInfo(cardPrinted.getEdition()).getCopiesCount();
|
||||
if (cntVariants > 1) {
|
||||
card.setRandomPicture(generator.nextInt(cntVariants - 1) + 1);
|
||||
@@ -70,41 +70,43 @@ public class GameNew {
|
||||
}
|
||||
|
||||
if (!useAnte && card.hasKeyword("Remove CARDNAME from your deck before playing if you're not playing for ante.")) {
|
||||
if(!removedAnteCards.containsKey(player))
|
||||
if (!removedAnteCards.containsKey(player)) {
|
||||
removedAnteCards.put(player, new ArrayList<String>());
|
||||
}
|
||||
removedAnteCards.get(player).add(card.getName());
|
||||
} else {
|
||||
library.add(card);
|
||||
}
|
||||
|
||||
|
||||
// mark card as difficult for AI to play
|
||||
if ( player.isComputer() && card.getSVar("RemAIDeck").equals("True") && !rAICards.contains(card.getName())) {
|
||||
if (player.isComputer() && card.getSVar("RemAIDeck").equals("True") && !rAICards.contains(card.getName())) {
|
||||
rAICards.add(card.getName());
|
||||
// get card picture so that it is in the image cache
|
||||
// ImageCache.getImage(card);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Shuffling
|
||||
// Ai may cheat
|
||||
if ( player.isComputer() && Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_SMOOTH_LAND) ) {
|
||||
// Ai may cheat
|
||||
if (player.isComputer() && Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_SMOOTH_LAND)) {
|
||||
// do this instead of shuffling Computer's deck
|
||||
final Iterable<Card> c1 = GameNew.smoothComputerManaCurve(player.getCardsIn(ZoneType.Library));
|
||||
player.getZone(ZoneType.Library).setCards(c1);
|
||||
} else
|
||||
} else {
|
||||
player.shuffle();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for new game allowing card lists to be put into play
|
||||
* immediately, and life totals to be adjusted, for computer and human.
|
||||
*
|
||||
* TODO: Accept something like match state as parameter. Match should be aware of players,
|
||||
* their decks and other special starting conditions.
|
||||
* TODO: Accept something like match state as parameter. Match should be aware of players,
|
||||
* their decks and other special starting conditions.
|
||||
*/
|
||||
public static void newGame(final Map<Player, PlayerStartConditions> playersConditions, final GameState game, final boolean canRandomFoil ) {
|
||||
public static void newGame(final Map<Player, PlayerStartConditions> playersConditions, final GameState game, final boolean canRandomFoil) {
|
||||
Singletons.getModel().getMatch().getInput().clearInput();
|
||||
|
||||
Card.resetUniqueNumber();
|
||||
@@ -118,7 +120,7 @@ public class GameNew {
|
||||
final Map<Player, List<String>> removedAnteCards = new HashMap<Player, List<String>>();
|
||||
final List<String> rAICards = new ArrayList<String>();
|
||||
|
||||
for( Entry<Player, PlayerStartConditions> p : playersConditions.entrySet() ) {
|
||||
for (Entry<Player, PlayerStartConditions> p : playersConditions.entrySet()) {
|
||||
final Player player = p.getKey();
|
||||
player.setStartingLife(p.getValue().getStartingLife());
|
||||
int hand = p.getValue().getStartingHand();
|
||||
@@ -126,7 +128,7 @@ public class GameNew {
|
||||
player.setStartingHandSize(hand);
|
||||
// what if I call it for AI player?
|
||||
PlayerZone bf = player.getZone(ZoneType.Battlefield);
|
||||
Iterable<Card> onTable = p.getValue().getCardsOnBattlefield();
|
||||
Iterable<Card> onTable = p.getValue().getCardsOnBattlefield();
|
||||
if (onTable != null) {
|
||||
for (final Card c : onTable) {
|
||||
c.setOwner(player);
|
||||
@@ -136,7 +138,7 @@ public class GameNew {
|
||||
c.refreshUniqueNumber();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PlayerZone com = player.getZone(ZoneType.Command);
|
||||
Iterable<Card> inCommand = p.getValue().getCardsInCommand();
|
||||
if (inCommand != null) {
|
||||
@@ -146,7 +148,7 @@ public class GameNew {
|
||||
c.refreshUniqueNumber();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
prepareSingleLibrary(player, p.getValue().getDeck(), removedAnteCards, rAICards, canRandomFoil);
|
||||
player.updateObservers();
|
||||
bf.updateObservers();
|
||||
@@ -154,18 +156,18 @@ public class GameNew {
|
||||
player.getZone(ZoneType.Command).updateObservers();
|
||||
player.getZone(ZoneType.Battlefield).updateObservers();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (rAICards.size() > 0) {
|
||||
String message = buildFourColumnList("AI deck contains the following cards that it can't play or may be buggy:", rAICards);
|
||||
JOptionPane.showMessageDialog(null, message, "", JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
|
||||
|
||||
if (!removedAnteCards.isEmpty()) {
|
||||
StringBuilder ante = new StringBuilder("The following ante cards were removed:\n\n");
|
||||
for(Entry<Player, List<String>> ants : removedAnteCards.entrySet() ) {
|
||||
ante.append(buildFourColumnList( "From the " + ants.getKey().getName() + "'s deck:", ants.getValue()));
|
||||
for (Entry<Player, List<String>> ants : removedAnteCards.entrySet()) {
|
||||
ante.append(buildFourColumnList("From the " + ants.getKey().getName() + "'s deck:", ants.getValue()));
|
||||
}
|
||||
JOptionPane.showMessageDialog(null, ante.toString(), "", JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
@@ -175,14 +177,14 @@ public class GameNew {
|
||||
|
||||
public static void restartGame(final GameState game, final Player startingTurn, Map<Player, List<Card>> playerLibraries) {
|
||||
MatchController match = Singletons.getModel().getMatch();
|
||||
|
||||
|
||||
Map<LobbyPlayer, PlayerStartConditions> players = match.getPlayers();
|
||||
Map<Player, PlayerStartConditions> playersConditions = new HashMap<Player, PlayerStartConditions>();
|
||||
|
||||
|
||||
for (Player p : game.getPlayers()) {
|
||||
playersConditions.put(p, players.get(p.getLobbyPlayer()));
|
||||
}
|
||||
|
||||
|
||||
match.getInput().clearInput();
|
||||
|
||||
//Card.resetUniqueNumber();
|
||||
@@ -193,18 +195,18 @@ public class GameNew {
|
||||
trigHandler.clearDelayedTrigger();
|
||||
trigHandler.cleanUpTemporaryTriggers();
|
||||
trigHandler.suppressMode(TriggerType.ChangesZone);
|
||||
|
||||
|
||||
game.getStack().reset();
|
||||
GameAction action = game.getAction();
|
||||
|
||||
|
||||
for( Entry<Player, PlayerStartConditions> p : playersConditions.entrySet() ) {
|
||||
|
||||
for (Entry<Player, PlayerStartConditions> p : playersConditions.entrySet()) {
|
||||
final Player player = p.getKey();
|
||||
player.setStartingLife(p.getValue().getStartingLife());
|
||||
player.setNumLandsPlayed(0);
|
||||
// what if I call it for AI player?
|
||||
PlayerZone bf = player.getZone(ZoneType.Battlefield);
|
||||
Iterable<Card> onTable = p.getValue().getCardsOnBattlefield();
|
||||
Iterable<Card> onTable = p.getValue().getCardsOnBattlefield();
|
||||
if (onTable != null) {
|
||||
for (final Card c : onTable) {
|
||||
c.addController(player);
|
||||
@@ -218,7 +220,7 @@ public class GameNew {
|
||||
|
||||
PlayerZone library = player.getZone(ZoneType.Library);
|
||||
List<Card> newLibrary = playerLibraries.get(player);
|
||||
for(Card c : newLibrary) {
|
||||
for (Card c : newLibrary) {
|
||||
action.moveTo(library, c);
|
||||
}
|
||||
|
||||
@@ -229,7 +231,7 @@ public class GameNew {
|
||||
}
|
||||
|
||||
trigHandler.clearSuppression(TriggerType.ChangesZone);
|
||||
|
||||
|
||||
PhaseHandler phaseHandler = game.getPhaseHandler();
|
||||
phaseHandler.setPlayerTurn(startingTurn);
|
||||
|
||||
@@ -246,17 +248,17 @@ public class GameNew {
|
||||
*/
|
||||
private static void actuateGame(final GameState game, boolean isRestartedGame) {
|
||||
if (!isRestartedGame) {
|
||||
// Deciding which cards go to ante
|
||||
// Deciding which cards go to ante
|
||||
if (Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_ANTE)) {
|
||||
final String nl = System.getProperty("line.separator");
|
||||
final StringBuilder msg = new StringBuilder();
|
||||
for (final Player p : game.getPlayers()) {
|
||||
|
||||
|
||||
final List<Card> lib = p.getCardsIn(ZoneType.Library);
|
||||
Predicate<Card> goodForAnte = Predicates.not(CardPredicates.Presets.BASIC_LANDS);
|
||||
Card ante = Aggregates.random(Iterables.filter(lib, goodForAnte));
|
||||
if (ante == null) {
|
||||
throw new RuntimeException(p + " library is empty.");
|
||||
throw new RuntimeException(p + " library is empty.");
|
||||
}
|
||||
game.getGameLog().add("Ante", p + " anted " + ante, 0);
|
||||
VAntes.SINGLETON_INSTANCE.addAnteCard(p, ante);
|
||||
@@ -266,7 +268,7 @@ public class GameNew {
|
||||
JOptionPane.showMessageDialog(null, msg, "Ante", JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
|
||||
GameOutcome lastGameOutcome = Singletons.getModel().getMatch().getLastGameOutcome();
|
||||
GameOutcome lastGameOutcome = Singletons.getModel().getMatch().getLastGameOutcome();
|
||||
// Only cut/coin toss if it's the first game of the match
|
||||
if (lastGameOutcome == null) {
|
||||
GameNew.seeWhoPlaysFirstDice();
|
||||
@@ -277,17 +279,17 @@ public class GameNew {
|
||||
}
|
||||
}
|
||||
|
||||
// Draw <handsize> cards
|
||||
// Draw <handsize> cards
|
||||
for (final Player p : game.getPlayers()) {
|
||||
p.drawCards(p.getMaxHandSize());
|
||||
}
|
||||
|
||||
|
||||
game.getPhaseHandler().setPhaseState(PhaseType.MULLIGAN);
|
||||
InputControl control = Singletons.getModel().getMatch().getInput();
|
||||
control.setInput(new InputMulligan());
|
||||
} // newGame()
|
||||
|
||||
private static String buildFourColumnList(String firstLine, List<String> cAnteRemoved ) {
|
||||
|
||||
private static String buildFourColumnList(String firstLine, List<String> cAnteRemoved) {
|
||||
StringBuilder sb = new StringBuilder(firstLine);
|
||||
sb.append("\n");
|
||||
for (int i = 0; i < cAnteRemoved.size(); i++) {
|
||||
@@ -366,33 +368,34 @@ public class GameNew {
|
||||
private static void seeWhoPlaysFirstDice() {
|
||||
int playerDie = 0;
|
||||
int computerDie = 0;
|
||||
|
||||
|
||||
while (playerDie == computerDie) {
|
||||
playerDie = MyRandom.getRandom().nextInt(20);
|
||||
computerDie = MyRandom.getRandom().nextInt(20);
|
||||
}
|
||||
|
||||
|
||||
// Play the Flip Coin sound
|
||||
Singletons.getModel().getGame().getEvents().post(new FlipCoinEvent());
|
||||
|
||||
|
||||
List<Player> allPlayers = Singletons.getModel().getGame().getPlayers();
|
||||
setPlayersFirstTurn(allPlayers.get(MyRandom.getRandom().nextInt(allPlayers.size())), true);
|
||||
}
|
||||
|
||||
|
||||
private static void setPlayersFirstTurn(Player goesFirst, boolean firstGame) {
|
||||
StringBuilder sb = new StringBuilder(goesFirst.toString());
|
||||
if (firstGame) {
|
||||
sb.append(" has won the coin toss.");
|
||||
}
|
||||
else {
|
||||
sb.append(" lost the last game.");
|
||||
sb.append(" lost the last game.");
|
||||
}
|
||||
if ( goesFirst.isHuman() ) {
|
||||
if( !humanPlayOrDraw(sb.toString()) )
|
||||
if (goesFirst.isHuman()) {
|
||||
if (!humanPlayOrDraw(sb.toString())) {
|
||||
goesFirst = goesFirst.getOpponent();
|
||||
}
|
||||
} else {
|
||||
sb.append("\nComputer Going First");
|
||||
JOptionPane.showMessageDialog(null, sb.toString(),
|
||||
JOptionPane.showMessageDialog(null, sb.toString(),
|
||||
"Play or Draw?", JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
Singletons.getModel().getGame().getPhaseHandler().setPlayerTurn(goesFirst);
|
||||
@@ -400,11 +403,11 @@ public class GameNew {
|
||||
|
||||
private static boolean humanPlayOrDraw(String message) {
|
||||
final String[] possibleValues = { "Play", "Draw" };
|
||||
|
||||
final Object playDraw = JOptionPane.showOptionDialog(null, message + "\n\nWould you like to play or draw?",
|
||||
"Play or Draw?", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null,
|
||||
|
||||
final Object playDraw = JOptionPane.showOptionDialog(null, message + "\n\nWould you like to play or draw?",
|
||||
"Play or Draw?", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null,
|
||||
possibleValues, possibleValues[0]);
|
||||
|
||||
|
||||
return !playDraw.equals(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public enum GameType {
|
||||
/** The Planechase. */
|
||||
Planechase(false, 60),
|
||||
/** The Archenemy. */
|
||||
Archenemy(false, 60),
|
||||
Archenemy(false, 60),
|
||||
/** */
|
||||
Gauntlet(true, 40);
|
||||
|
||||
|
||||
@@ -21,21 +21,21 @@ public class MatchStartHelper {
|
||||
private final Map<LobbyPlayer, PlayerStartConditions> players = new HashMap<LobbyPlayer, PlayerStartConditions>();
|
||||
|
||||
public void addPlayer(final LobbyPlayer player, final PlayerStartConditions c) {
|
||||
players.put(player,c);
|
||||
players.put(player, c);
|
||||
}
|
||||
|
||||
|
||||
public void addPlayer(final LobbyPlayer player, final Deck deck) {
|
||||
PlayerStartConditions start = new PlayerStartConditions(deck);
|
||||
players.put(player, start);
|
||||
}
|
||||
|
||||
public void addVanguardPlayer(final LobbyPlayer player, final Deck deck, final CardPrinted avatar)
|
||||
{
|
||||
|
||||
public void addVanguardPlayer(final LobbyPlayer player, final Deck deck, final CardPrinted avatar) {
|
||||
|
||||
PlayerStartConditions start = new PlayerStartConditions(deck);
|
||||
|
||||
|
||||
start.setStartingLife(start.getStartingLife() + avatar.getCard().getLife());
|
||||
start.setStartingHand(start.getStartingHand() + avatar.getCard().getHand());
|
||||
|
||||
|
||||
start.setCardsInCommand(new Supplier<Iterable<Card>>() {
|
||||
|
||||
@Override
|
||||
@@ -44,14 +44,14 @@ public class MatchStartHelper {
|
||||
res.add(avatar.toForgeCard());
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
players.put(player, start);
|
||||
}
|
||||
|
||||
public Map<LobbyPlayer, PlayerStartConditions> getPlayerMap()
|
||||
{
|
||||
|
||||
public Map<LobbyPlayer, PlayerStartConditions> getPlayerMap() {
|
||||
|
||||
return players;
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ interface IZone {
|
||||
* a {@link java.lang.Object} object.
|
||||
*/
|
||||
void add(Object o);
|
||||
|
||||
|
||||
void add(Object o, boolean b);
|
||||
|
||||
/**
|
||||
|
||||
@@ -488,8 +488,9 @@ public class MagicStack extends MyObservable {
|
||||
//GuiDisplayUtil.updateGUI();
|
||||
} else {
|
||||
if (sp.getOptionalAdditionalCosts() != null) {
|
||||
for (String s : sp.getOptionalAdditionalCosts())
|
||||
for (String s : sp.getOptionalAdditionalCosts()) {
|
||||
sp.getSourceCard().addOptionalAdditionalCostsPaid(s);
|
||||
}
|
||||
}
|
||||
if (sp.getSourceCard().isCopiedSpell()) {
|
||||
this.push(sp);
|
||||
@@ -609,7 +610,7 @@ public class MagicStack extends MyObservable {
|
||||
}
|
||||
}
|
||||
};
|
||||
Player activating = sp.getActivatingPlayer();
|
||||
Player activating = sp.getActivatingPlayer();
|
||||
|
||||
if (activating.isHuman()) {
|
||||
final ManaCost manaCost = this.getMultiKickerSpellCostChange(ability);
|
||||
@@ -716,7 +717,7 @@ public class MagicStack extends MyObservable {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Copied spells aren't cast
|
||||
// per se so triggers shouldn't
|
||||
// run for them.
|
||||
@@ -864,7 +865,7 @@ public class MagicStack extends MyObservable {
|
||||
// when something is added we need to setPriority
|
||||
game.getPhaseHandler().setPriority(sp.getActivatingPlayer());
|
||||
}
|
||||
|
||||
|
||||
SDisplayUtil.showTab(EDocID.REPORT_STACK.getDoc());
|
||||
this.updateObservers();
|
||||
|
||||
@@ -1004,18 +1005,18 @@ public class MagicStack extends MyObservable {
|
||||
&& game.getZoneOf(source).is(ZoneType.Stack)
|
||||
&& source.getOwner().equals(source.getController())) //"If you cast this spell from your hand"
|
||||
{
|
||||
|
||||
|
||||
//Move rebounding card to exile
|
||||
source = game.getAction().exile(source);
|
||||
|
||||
source.setSVar("ReboundAbilityTrigger", "DB$ Play | Defined$ Self " +
|
||||
"| WithoutManaCost$ True | Optional$ True");
|
||||
source.setSVar("ReboundAbilityTrigger", "DB$ Play | Defined$ Self "
|
||||
+ "| WithoutManaCost$ True | Optional$ True");
|
||||
|
||||
//Setup a Rebound-trigger
|
||||
final Trigger reboundTrigger = forge.card.trigger.TriggerHandler.parseTrigger("Mode$ Phase " +
|
||||
"| Phase$ Upkeep | ValidPlayer$ You | OptionalDecider$ You | Execute$ ReboundAbilityTrigger " +
|
||||
"| TriggerDescription$ At the beginning of your next upkeep, you may cast " + source.toString()
|
||||
+ " without paying it's manacost.", source, true);
|
||||
final Trigger reboundTrigger = forge.card.trigger.TriggerHandler.parseTrigger("Mode$ Phase "
|
||||
+ "| Phase$ Upkeep | ValidPlayer$ You | OptionalDecider$ You | Execute$ ReboundAbilityTrigger "
|
||||
+ "| TriggerDescription$ At the beginning of your next upkeep, you may cast " + source.toString()
|
||||
+ " without paying it's manacost.", source, true);
|
||||
|
||||
game.getTriggerHandler().registerDelayedTrigger(reboundTrigger);
|
||||
}
|
||||
@@ -1086,13 +1087,13 @@ public class MagicStack extends MyObservable {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean hasFizzled(final SpellAbility sa, final Card source, final boolean parentFizzled) {
|
||||
// Can't fizzle unless there are some targets
|
||||
// Can't fizzle unless there are some targets
|
||||
boolean fizzle = false;
|
||||
|
||||
|
||||
Target tgt = sa.getTarget();
|
||||
if (tgt != null) {
|
||||
if (tgt.getMinTargets(source, sa) == 0 && tgt.getNumTargeted() == 0) {
|
||||
// Nothing targeted, and nothing needs to be targeted.
|
||||
// Nothing targeted, and nothing needs to be targeted.
|
||||
}
|
||||
else {
|
||||
// Some targets were chosen, fizzling for this subability is now possible
|
||||
@@ -1114,11 +1115,11 @@ public class MagicStack extends MyObservable {
|
||||
else if (o instanceof Card) {
|
||||
final Card card = (Card) o;
|
||||
Card current = game.getCardState(card);
|
||||
|
||||
|
||||
invalidTarget = current.getTimestamp() != card.getTimestamp();
|
||||
|
||||
|
||||
invalidTarget |= !(CardFactoryUtil.isTargetStillValid(sa, card));
|
||||
|
||||
|
||||
if (invalidTarget) {
|
||||
choices.removeTarget(card);
|
||||
}
|
||||
@@ -1133,12 +1134,12 @@ public class MagicStack extends MyObservable {
|
||||
}
|
||||
}
|
||||
fizzle &= invalidTarget;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (sa.getTargetCard() != null) {
|
||||
fizzle = !CardFactoryUtil.isTargetStillValid(sa, sa.getTargetCard());
|
||||
}
|
||||
}
|
||||
else if (sa.getTargetPlayer() != null) {
|
||||
fizzle = !sa.getTargetPlayer().canBeTargetedBy(sa);
|
||||
}
|
||||
@@ -1146,11 +1147,11 @@ public class MagicStack extends MyObservable {
|
||||
// Set fizzle to the same as the parent if there's no target info
|
||||
fizzle = parentFizzled;
|
||||
}
|
||||
|
||||
|
||||
if (sa.getSubAbility() == null) {
|
||||
return fizzle;
|
||||
}
|
||||
|
||||
|
||||
return hasFizzled(sa.getSubAbility(), source, fizzle) && fizzle;
|
||||
}
|
||||
|
||||
@@ -1370,12 +1371,11 @@ public class MagicStack extends MyObservable {
|
||||
} else {
|
||||
this.add(next);
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
// Otherwise, gave a dual list form to create instead of needing to do it one at a time
|
||||
List<SpellAbility> orderedSAs = GuiChoose.getOrderChoices("Select order for Simultaneous Spell Abilities", "Resolve first", 0, activePlayerSAs, null, null);
|
||||
int size = orderedSAs.size();
|
||||
for(int i = size-1; i >= 0; i--){
|
||||
for (int i = size - 1; i >= 0; i--) {
|
||||
SpellAbility next = orderedSAs.get(i);
|
||||
if (next.isTrigger()) {
|
||||
game.getAction().playSpellAbility(next);
|
||||
@@ -1385,7 +1385,7 @@ public class MagicStack extends MyObservable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -37,7 +37,7 @@ public class PlayerZone extends Zone {
|
||||
|
||||
private final Player player;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -97,12 +97,12 @@ public class PlayerZone extends Zone {
|
||||
}
|
||||
|
||||
this.cardList.add(c);
|
||||
|
||||
|
||||
if (update) {
|
||||
this.update();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Checks if is.
|
||||
@@ -116,7 +116,7 @@ public class PlayerZone extends Zone {
|
||||
public final boolean is(final ZoneType zone, final Player player) {
|
||||
return (zone == this.zoneName && this.player.equals(player));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Getter for the field <code>player</code>.
|
||||
@@ -148,6 +148,6 @@ public class PlayerZone extends Zone {
|
||||
public void updateLabelObservers() {
|
||||
getPlayer().updateLabelObservers();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ public class PlayerZoneBattlefield extends PlayerZone {
|
||||
if (c.isLand()) {
|
||||
|
||||
// Tectonic Instability
|
||||
final List<Card> tis =
|
||||
final List<Card> tis =
|
||||
CardLists.filter(Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield), CardPredicates.nameEquals("Tectonic Instability"));
|
||||
final Card tisLand = c;
|
||||
for (final Card ti : tis) {
|
||||
@@ -280,14 +280,14 @@ public class PlayerZoneBattlefield extends PlayerZone {
|
||||
this.leavesTrigger = b;
|
||||
}
|
||||
|
||||
private static Predicate<Card> isNotPhased = new Predicate<Card>(){
|
||||
private static Predicate<Card> isNotPhased = new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card crd) {
|
||||
return !crd.isPhasedOut();
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
||||
@@ -44,14 +44,14 @@ public class Zone extends MyObservable implements IZone, Observer, java.io.Seria
|
||||
|
||||
/** The cards. */
|
||||
protected final List<Card> cardList = new ArrayList<Card>();
|
||||
protected final List<Card> roCardList;
|
||||
protected final List<Card> roCardList;
|
||||
protected final ZoneType zoneName;
|
||||
protected boolean update = true;
|
||||
|
||||
protected final List<Card> cardsAddedThisTurn = new ArrayList<Card>();
|
||||
protected final ArrayList<ZoneType> cardsAddedThisTurnSource = new ArrayList<ZoneType>();
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -91,13 +91,13 @@ public class Zone extends MyObservable implements IZone, Observer, java.io.Seria
|
||||
c.setTapped(false);
|
||||
|
||||
this.cardList.add(c);
|
||||
|
||||
|
||||
if (update) {
|
||||
this.update();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Adds the.
|
||||
*
|
||||
@@ -207,8 +207,9 @@ public class Zone extends MyObservable implements IZone, Observer, java.io.Seria
|
||||
@Override
|
||||
public final void setCards(final Iterable<Card> cards) {
|
||||
cardList.clear();
|
||||
for(Card c : cards)
|
||||
for (Card c : cards) {
|
||||
cardList.add(c);
|
||||
}
|
||||
this.update();
|
||||
}
|
||||
|
||||
@@ -226,11 +227,11 @@ public class Zone extends MyObservable implements IZone, Observer, java.io.Seria
|
||||
return zone == this.zoneName;
|
||||
}
|
||||
|
||||
// PlayerZone should override it with a correct implementation
|
||||
// PlayerZone should override it with a correct implementation
|
||||
public boolean is(final ZoneType zone, final Player player) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
||||
@@ -76,15 +76,15 @@ public enum ZoneType {
|
||||
public boolean isKnown() {
|
||||
return !holdsHiddenInfo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static boolean isHidden(final String origin, final boolean hiddenOverride) {
|
||||
List<ZoneType> zone = ZoneType.listValueOf(origin);
|
||||
|
||||
|
||||
if (hiddenOverride || zone.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
for (ZoneType z : zone) {
|
||||
if (z.isHidden()) {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user