- CheckStyle.

This commit is contained in:
Chris
2012-11-24 14:15:12 +00:00
parent a0e1eaf1d7
commit fce84984db
10 changed files with 95 additions and 88 deletions

View File

@@ -293,7 +293,7 @@ public class Deck extends DeckBase {
double best = 1.0; double best = 1.0;
for( Entry<CardPrinted, Integer> kv : this.getMain()) { for (Entry<CardPrinted, Integer> kv : this.getMain()) {
CardPrinted evalCard = kv.getKey(); CardPrinted evalCard = kv.getKey();
int count = kv.getValue(); int count = kv.getValue();
if (ranker.getRanking(evalCard.getName(), evalCard.getEdition()) != null) { if (ranker.getRanking(evalCard.getName(), evalCard.getEdition()) != null) {
@@ -320,12 +320,12 @@ public class Deck extends DeckBase {
int deckSize = main.countAll(); int deckSize = main.countAll();
int deckDistinct = main.countDistinct(); int deckDistinct = main.countDistinct();
Integer max = type.getDeckMaximum(); Integer max = type.getDeckMaximum();
if (deckSize < type.getDeckMinimum() || (max != null && deckSize > max) || if (deckSize < type.getDeckMinimum() || (max != null && deckSize > max)
(type.isSingleton() && deckDistinct != deckSize)) { || (type.isSingleton() && deckDistinct != deckSize)) {
return false; return false;
} }
return true; return true;
} }

View File

@@ -106,7 +106,7 @@ public class DeckSection extends ItemPool<CardPrinted> {
} }
/** /**
* Add all from a List of CardPrinted * Add all from a List of CardPrinted.
* *
* @param list * @param list
* CardPrinteds to add * CardPrinteds to add

View File

@@ -78,7 +78,7 @@ public class Generate2ColorDeck extends GenerateColoredDeckBase {
public final ItemPoolView<CardPrinted> get2ColorDeck(final int size, final PlayerType pt) { public final ItemPoolView<CardPrinted> get2ColorDeck(final int size, final PlayerType pt) {
addCreaturesAndSpells(size, cmcLevels, cmcAmounts, pt); addCreaturesAndSpells(size, cmcLevels, cmcAmounts, pt);
// Add lands // Add lands
int numLands = (int) (getLandsPercentage() * size); int numLands = (int) (getLandsPercentage() * size);

View File

@@ -63,7 +63,7 @@ public abstract class GenerateColoredDeckBase {
protected float getLandsPercentage() { return 0.44f; } protected float getLandsPercentage() { return 0.44f; }
protected float getCreatPercentage() { return 0.34f; } protected float getCreatPercentage() { return 0.34f; }
protected float getSpellPercentage() { return 0.22f; } protected float getSpellPercentage() { return 0.22f; }
StringBuilder tmpDeck = new StringBuilder(); StringBuilder tmpDeck = new StringBuilder();
// protected final float landsPercentage = 0.42f; // protected final float landsPercentage = 0.42f;
@@ -87,7 +87,7 @@ public abstract class GenerateColoredDeckBase {
protected void addCreaturesAndSpells(int size, List<FilterCMC> cmcLevels, int[] cmcAmounts, PlayerType pt) { protected void addCreaturesAndSpells(int size, List<FilterCMC> cmcLevels, int[] cmcAmounts, PlayerType pt) {
final Iterable<CardPrinted> cards = selectCardsOfMatchingColorForPlayer(pt); final Iterable<CardPrinted> cards = selectCardsOfMatchingColorForPlayer(pt);
// build subsets based on type // build subsets based on type
final Iterable<CardPrinted> creatures = Iterables.filter(cards, Predicates.compose(CardRulesPredicates.Presets.IS_CREATURE, CardPrinted.FN_GET_RULES)); final Iterable<CardPrinted> creatures = Iterables.filter(cards, Predicates.compose(CardRulesPredicates.Presets.IS_CREATURE, CardPrinted.FN_GET_RULES));
final int creatCnt = (int) (getCreatPercentage() * size); final int creatCnt = (int) (getCreatPercentage() * size);
tmpDeck.append("Creature Count:").append(creatCnt).append("\n"); tmpDeck.append("Creature Count:").append(creatCnt).append("\n");
@@ -200,7 +200,7 @@ public abstract class GenerateColoredDeckBase {
for (int i = 0; i < cmcAmounts.length; i++) { for (int i = 0; i < cmcAmounts.length; i++) {
Iterable<CardPrinted> matchingCards = Iterables.filter(source, Predicates.compose(cmcLevels.get(i), CardPrinted.FN_GET_RULES)); Iterable<CardPrinted> matchingCards = Iterables.filter(source, Predicates.compose(cmcLevels.get(i), CardPrinted.FN_GET_RULES));
curved.addAll( Aggregates.random(matchingCards, cmcAmounts[i])); curved.addAll(Aggregates.random(matchingCards, cmcAmounts[i]));
} }
for (CardPrinted c : curved) { for (CardPrinted c : curved) {
@@ -249,7 +249,7 @@ public abstract class GenerateColoredDeckBase {
} }
return res; return res;
} }
protected static void increment(Map<String, Integer> map, String key, int delta) protected static void increment(Map<String, Integer> map, String key, int delta)
{ {
final Integer boxed = map.get(key); final Integer boxed = map.get(key);

View File

@@ -70,7 +70,7 @@ public class GenerateDeckUtil {
@Override @Override
public boolean apply(CardRules subject) { public boolean apply(CardRules subject) {
CardManaCost mc = subject.getManaCost(); CardManaCost mc = subject.getManaCost();
return !mc.isPureGeneric() && mc.canBePaidWithManaOfColor(allowedColor); return !mc.isPureGeneric() && mc.canBePaidWithManaOfColor(allowedColor);
// return allowedColor.containsAllColorsFrom(mc.getColorProfile()); // return allowedColor.containsAllColorsFrom(mc.getColorProfile());
} }

View File

@@ -32,7 +32,7 @@ public enum GameEndReason {
/** The Wins game spell effect. */ /** The Wins game spell effect. */
WinsGameSpellEffect, // ones that could be both hardcoded (felidar) and WinsGameSpellEffect, // ones that could be both hardcoded (felidar) and
// scripted ( such as Mayael's Aria ) // scripted ( such as Mayael's Aria )
/** Used to end multiplayer games where the all humans have lost or conceded while AIs cannot end match by themselves*/ /** Used to end multiplayer games where the all humans have lost or conceded while AIs cannot end match by themselves.*/
AllHumansLost, AllHumansLost,
} }

View File

@@ -43,7 +43,7 @@ public class GameFormat {
protected final transient List<String> allowedSetCodes_ro; protected final transient List<String> allowedSetCodes_ro;
protected final transient List<String> bannedCardNames_ro; protected final transient List<String> bannedCardNames_ro;
protected final transient Predicate<CardPrinted> filterRules; protected final transient Predicate<CardPrinted> filterRules;
protected final transient Predicate<CardPrinted> filterPrinted; protected final transient Predicate<CardPrinted> filterPrinted;
@@ -61,25 +61,27 @@ public class GameFormat {
this.name = fName; this.name = fName;
this.allowedSetCodes = Lists.newArrayList(sets); this.allowedSetCodes = Lists.newArrayList(sets);
this.bannedCardNames = bannedCards == null ? new ArrayList<String>() : Lists.newArrayList(bannedCards); this.bannedCardNames = bannedCards == null ? new ArrayList<String>() : Lists.newArrayList(bannedCards);
this.allowedSetCodes_ro = Collections.unmodifiableList(allowedSetCodes); this.allowedSetCodes_ro = Collections.unmodifiableList(allowedSetCodes);
this.bannedCardNames_ro = Collections.unmodifiableList(bannedCardNames); this.bannedCardNames_ro = Collections.unmodifiableList(bannedCardNames);
this.filterRules = this.buildFilterRules(); this.filterRules = this.buildFilterRules();
this.filterPrinted = this.buildFilterPritned(); this.filterPrinted = this.buildFilterPritned();
} }
private Predicate<CardPrinted> buildFilterPritned() { private Predicate<CardPrinted> buildFilterPritned() {
final Predicate<CardPrinted> banNames = CardPrinted.Predicates.namesExcept(this.bannedCardNames); final Predicate<CardPrinted> banNames = CardPrinted.Predicates.namesExcept(this.bannedCardNames);
if (this.allowedSetCodes == null || this.allowedSetCodes.isEmpty() ) if (this.allowedSetCodes == null || this.allowedSetCodes.isEmpty()) {
return banNames; return banNames;
}
return Predicates.and(banNames, CardPrinted.Predicates.printedInSets(this.allowedSetCodes, true)); return Predicates.and(banNames, CardPrinted.Predicates.printedInSets(this.allowedSetCodes, true));
} }
private Predicate<CardPrinted> buildFilterRules() { private Predicate<CardPrinted> buildFilterRules() {
final Predicate<CardPrinted> banNames = CardPrinted.Predicates.namesExcept(this.bannedCardNames); final Predicate<CardPrinted> banNames = CardPrinted.Predicates.namesExcept(this.bannedCardNames);
if ( this.allowedSetCodes == null || this.allowedSetCodes.isEmpty() ) if (this.allowedSetCodes == null || this.allowedSetCodes.isEmpty()) {
return banNames; return banNames;
}
return Predicates.and(banNames, Predicates.compose(CardRulesPredicates.wasPrintedInSets(this.allowedSetCodes), CardPrinted.FN_GET_RULES)); return Predicates.and(banNames, Predicates.compose(CardRulesPredicates.wasPrintedInSets(this.allowedSetCodes), CardPrinted.FN_GET_RULES));
} }

View File

@@ -32,8 +32,8 @@ public enum GameLossReason {
// 104.3e and others // 104.3e and others
/** The Spell effect. */ /** The Spell effect. */
SpellEffect, SpellEffect,
OpponentWon OpponentWon
/* /*

View File

@@ -53,9 +53,9 @@ public class GameNew {
for (int i = 0; i < stackOfCards.getValue(); i++) { for (int i = 0; i < stackOfCards.getValue(); i++) {
final Card card = cardPrinted.toForgeCard(player); final Card card = cardPrinted.toForgeCard(player);
// apply random pictures for cards // apply random pictures for cards
if ( player.isComputer() ) { if (player.isComputer()) {
final int cntVariants = cardPrinted.getCard().getEditionInfo(cardPrinted.getEdition()).getCopiesCount(); final int cntVariants = cardPrinted.getCard().getEditionInfo(cardPrinted.getEdition()).getCopiesCount();
if (cntVariants > 1) { if (cntVariants > 1) {
card.setRandomPicture(generator.nextInt(cntVariants - 1) + 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 (!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.put(player, new ArrayList<String>());
}
removedAnteCards.get(player).add(card.getName()); removedAnteCards.get(player).add(card.getName());
} else { } else {
library.add(card); library.add(card);
} }
// mark card as difficult for AI to play // 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()); rAICards.add(card.getName());
// get card picture so that it is in the image cache // get card picture so that it is in the image cache
// ImageCache.getImage(card); // ImageCache.getImage(card);
} }
} }
} }
// Shuffling // Shuffling
// Ai may cheat // Ai may cheat
if ( player.isComputer() && Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_SMOOTH_LAND) ) { if (player.isComputer() && Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_SMOOTH_LAND)) {
// do this instead of shuffling Computer's deck // do this instead of shuffling Computer's deck
final Iterable<Card> c1 = GameNew.smoothComputerManaCurve(player.getCardsIn(ZoneType.Library)); final Iterable<Card> c1 = GameNew.smoothComputerManaCurve(player.getCardsIn(ZoneType.Library));
player.getZone(ZoneType.Library).setCards(c1); player.getZone(ZoneType.Library).setCards(c1);
} else } else {
player.shuffle(); player.shuffle();
}
} }
/** /**
* Constructor for new game allowing card lists to be put into play * Constructor for new game allowing card lists to be put into play
* immediately, and life totals to be adjusted, for computer and human. * 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, * TODO: Accept something like match state as parameter. Match should be aware of players,
* their decks and other special starting conditions. * 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(); Singletons.getModel().getMatch().getInput().clearInput();
Card.resetUniqueNumber(); Card.resetUniqueNumber();
@@ -118,12 +120,12 @@ public class GameNew {
final Map<Player, List<String>> removedAnteCards = new HashMap<Player, List<String>>(); final Map<Player, List<String>> removedAnteCards = new HashMap<Player, List<String>>();
final List<String> rAICards = new ArrayList<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(); final Player player = p.getKey();
player.setStartingLife(p.getValue().getStartingLife()); player.setStartingLife(p.getValue().getStartingLife());
// what if I call it for AI player? // what if I call it for AI player?
PlayerZone bf = player.getZone(ZoneType.Battlefield); PlayerZone bf = player.getZone(ZoneType.Battlefield);
Iterable<Card> onTable = p.getValue().getCardsOnTable(); Iterable<Card> onTable = p.getValue().getCardsOnTable();
if (onTable != null) { if (onTable != null) {
for (final Card c : onTable) { for (final Card c : onTable) {
c.addController(player); c.addController(player);
@@ -134,24 +136,23 @@ public class GameNew {
c.refreshUniqueNumber(); c.refreshUniqueNumber();
} }
} }
prepareSingleLibrary(player, p.getValue().getDeck(), removedAnteCards, rAICards, canRandomFoil); prepareSingleLibrary(player, p.getValue().getDeck(), removedAnteCards, rAICards, canRandomFoil);
player.updateObservers(); player.updateObservers();
bf.updateObservers(); bf.updateObservers();
player.getZone(ZoneType.Hand).updateObservers(); player.getZone(ZoneType.Hand).updateObservers();
} }
if (rAICards.size() > 0) { if (rAICards.size() > 0) {
String message = buildFourColumnList("AI deck contains the following cards that it can't play or may be buggy:", rAICards); 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); JOptionPane.showMessageDialog(null, message, "", JOptionPane.INFORMATION_MESSAGE);
} }
if (!removedAnteCards.isEmpty()) { if (!removedAnteCards.isEmpty()) {
StringBuilder ante = new StringBuilder("The following ante cards were removed:\n\n"); StringBuilder ante = new StringBuilder("The following ante cards were removed:\n\n");
for(Entry<Player, List<String>> ants : removedAnteCards.entrySet() ) { for (Entry<Player, List<String>> ants : removedAnteCards.entrySet()) {
ante.append(buildFourColumnList( "From the " + ants.getKey().getName() + "'s deck:", ants.getValue())); ante.append(buildFourColumnList("From the " + ants.getKey().getName() + "'s deck:", ants.getValue()));
} }
JOptionPane.showMessageDialog(null, ante.toString(), "", JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(null, ante.toString(), "", JOptionPane.INFORMATION_MESSAGE);
} }
@@ -161,14 +162,14 @@ public class GameNew {
public static void restartGame(final GameState game, final Player startingTurn, Map<Player, List<Card>> playerLibraries) { public static void restartGame(final GameState game, final Player startingTurn, Map<Player, List<Card>> playerLibraries) {
MatchController match = Singletons.getModel().getMatch(); MatchController match = Singletons.getModel().getMatch();
Map<LobbyPlayer, PlayerStartConditions> players = match.getPlayers(); Map<LobbyPlayer, PlayerStartConditions> players = match.getPlayers();
Map<Player, PlayerStartConditions> playersConditions = new HashMap<Player, PlayerStartConditions>(); Map<Player, PlayerStartConditions> playersConditions = new HashMap<Player, PlayerStartConditions>();
for (Player p : game.getPlayers()) { for (Player p : game.getPlayers()) {
playersConditions.put(p, players.get(p.getLobbyPlayer())); playersConditions.put(p, players.get(p.getLobbyPlayer()));
} }
match.getInput().clearInput(); match.getInput().clearInput();
//Card.resetUniqueNumber(); //Card.resetUniqueNumber();
@@ -179,18 +180,18 @@ public class GameNew {
trigHandler.clearDelayedTrigger(); trigHandler.clearDelayedTrigger();
trigHandler.cleanUpTemporaryTriggers(); trigHandler.cleanUpTemporaryTriggers();
trigHandler.suppressMode(TriggerType.ChangesZone); trigHandler.suppressMode(TriggerType.ChangesZone);
game.getStack().reset(); game.getStack().reset();
GameAction action = game.getAction(); GameAction action = game.getAction();
for( Entry<Player, PlayerStartConditions> p : playersConditions.entrySet() ) {
for (Entry<Player, PlayerStartConditions> p : playersConditions.entrySet()) {
final Player player = p.getKey(); final Player player = p.getKey();
player.setStartingLife(p.getValue().getStartingLife()); player.setStartingLife(p.getValue().getStartingLife());
player.setNumLandsPlayed(0); player.setNumLandsPlayed(0);
// what if I call it for AI player? // what if I call it for AI player?
PlayerZone bf = player.getZone(ZoneType.Battlefield); PlayerZone bf = player.getZone(ZoneType.Battlefield);
Iterable<Card> onTable = p.getValue().getCardsOnTable(); Iterable<Card> onTable = p.getValue().getCardsOnTable();
if (onTable != null) { if (onTable != null) {
for (final Card c : onTable) { for (final Card c : onTable) {
c.addController(player); c.addController(player);
@@ -204,7 +205,7 @@ public class GameNew {
PlayerZone library = player.getZone(ZoneType.Library); PlayerZone library = player.getZone(ZoneType.Library);
List<Card> newLibrary = playerLibraries.get(player); List<Card> newLibrary = playerLibraries.get(player);
for(Card c : newLibrary) { for (Card c : newLibrary) {
action.moveTo(library, c); action.moveTo(library, c);
} }
@@ -215,7 +216,7 @@ public class GameNew {
} }
trigHandler.clearSuppression(TriggerType.ChangesZone); trigHandler.clearSuppression(TriggerType.ChangesZone);
PhaseHandler phaseHandler = game.getPhaseHandler(); PhaseHandler phaseHandler = game.getPhaseHandler();
phaseHandler.setPlayerTurn(startingTurn); phaseHandler.setPlayerTurn(startingTurn);
@@ -232,7 +233,7 @@ public class GameNew {
*/ */
private static void actuateGame(final GameState game, boolean isRestartedGame) { private static void actuateGame(final GameState game, boolean isRestartedGame) {
if (!isRestartedGame) { if (!isRestartedGame) {
// Deciding which cards go to ante // Deciding which cards go to ante
if (Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_ANTE)) { if (Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_ANTE)) {
final String nl = System.getProperty("line.separator"); final String nl = System.getProperty("line.separator");
final StringBuilder msg = new StringBuilder(); final StringBuilder msg = new StringBuilder();
@@ -241,7 +242,7 @@ public class GameNew {
Predicate<Card> goodForAnte = Predicates.not(CardPredicates.Presets.BASIC_LANDS); Predicate<Card> goodForAnte = Predicates.not(CardPredicates.Presets.BASIC_LANDS);
Card ante = Aggregates.random(Iterables.filter(lib, goodForAnte)); Card ante = Aggregates.random(Iterables.filter(lib, goodForAnte));
if (ante == null) { 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); game.getGameLog().add("Ante", p + " anted " + ante, 0);
VAntes.SINGLETON_INSTANCE.addAnteCard(p, ante); VAntes.SINGLETON_INSTANCE.addAnteCard(p, ante);
@@ -251,7 +252,7 @@ public class GameNew {
JOptionPane.showMessageDialog(null, msg, "Ante", JOptionPane.INFORMATION_MESSAGE); 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 // Only cut/coin toss if it's the first game of the match
if (lastGameOutcome == null) { if (lastGameOutcome == null) {
GameNew.seeWhoPlaysFirstDice(); GameNew.seeWhoPlaysFirstDice();
@@ -262,18 +263,18 @@ public class GameNew {
} }
} }
// Draw 7 cards // Draw 7 cards
for (final Player p : game.getPlayers()) { for (final Player p : game.getPlayers()) {
// Should this be p.getMaxHandSize() for Vanguard compatibility? // Should this be p.getMaxHandSize() for Vanguard compatibility?
p.drawCards(7); p.drawCards(7);
} }
game.getPhaseHandler().setPhaseState(PhaseType.MULLIGAN); game.getPhaseHandler().setPhaseState(PhaseType.MULLIGAN);
InputControl control = Singletons.getModel().getMatch().getInput(); InputControl control = Singletons.getModel().getMatch().getInput();
control.setInput(new InputMulligan()); control.setInput(new InputMulligan());
} // newGame() } // newGame()
private static String buildFourColumnList(String firstLine, List<String> cAnteRemoved ) { private static String buildFourColumnList(String firstLine, List<String> cAnteRemoved) {
StringBuilder sb = new StringBuilder(firstLine); StringBuilder sb = new StringBuilder(firstLine);
sb.append("\n"); sb.append("\n");
for (int i = 0; i < cAnteRemoved.size(); i++) { for (int i = 0; i < cAnteRemoved.size(); i++) {
@@ -352,33 +353,34 @@ public class GameNew {
private static void seeWhoPlaysFirstDice() { private static void seeWhoPlaysFirstDice() {
int playerDie = 0; int playerDie = 0;
int computerDie = 0; int computerDie = 0;
while (playerDie == computerDie) { while (playerDie == computerDie) {
playerDie = MyRandom.getRandom().nextInt(20); playerDie = MyRandom.getRandom().nextInt(20);
computerDie = MyRandom.getRandom().nextInt(20); computerDie = MyRandom.getRandom().nextInt(20);
} }
// Play the Flip Coin sound // Play the Flip Coin sound
Singletons.getModel().getGame().getEvents().post(new FlipCoinEvent()); Singletons.getModel().getGame().getEvents().post(new FlipCoinEvent());
List<Player> allPlayers = Singletons.getModel().getGame().getPlayers(); List<Player> allPlayers = Singletons.getModel().getGame().getPlayers();
setPlayersFirstTurn(allPlayers.get(MyRandom.getRandom().nextInt(allPlayers.size())), true); setPlayersFirstTurn(allPlayers.get(MyRandom.getRandom().nextInt(allPlayers.size())), true);
} }
private static void setPlayersFirstTurn(Player goesFirst, boolean firstGame) { private static void setPlayersFirstTurn(Player goesFirst, boolean firstGame) {
StringBuilder sb = new StringBuilder(goesFirst.toString()); StringBuilder sb = new StringBuilder(goesFirst.toString());
if (firstGame) { if (firstGame) {
sb.append(" has won the coin toss."); sb.append(" has won the coin toss.");
} }
else { else {
sb.append(" lost the last game."); sb.append(" lost the last game.");
} }
if ( goesFirst.isHuman() ) { if (goesFirst.isHuman()) {
if( !humanPlayOrDraw(sb.toString()) ) if (!humanPlayOrDraw(sb.toString())) {
goesFirst = goesFirst.getOpponent(); goesFirst = goesFirst.getOpponent();
}
} else { } else {
sb.append("\nComputer Going First"); sb.append("\nComputer Going First");
JOptionPane.showMessageDialog(null, sb.toString(), JOptionPane.showMessageDialog(null, sb.toString(),
"Play or Draw?", JOptionPane.INFORMATION_MESSAGE); "Play or Draw?", JOptionPane.INFORMATION_MESSAGE);
} }
Singletons.getModel().getGame().getPhaseHandler().setPlayerTurn(goesFirst); Singletons.getModel().getGame().getPhaseHandler().setPlayerTurn(goesFirst);
@@ -386,11 +388,11 @@ public class GameNew {
private static boolean humanPlayOrDraw(String message) { private static boolean humanPlayOrDraw(String message) {
final String[] possibleValues = { "Play", "Draw" }; final String[] possibleValues = { "Play", "Draw" };
final Object playDraw = JOptionPane.showOptionDialog(null, message + "\n\nWould you like to play or 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, "Play or Draw?", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null,
possibleValues, possibleValues[0]); possibleValues, possibleValues[0]);
return !playDraw.equals(1); return !playDraw.equals(1);
} }
} }

View File

@@ -68,8 +68,8 @@ public final class GameOutcome implements Iterable<Entry<LobbyPlayer, PlayerStat
for (final Player n : list) { for (final Player n : list) {
this.playerRating.put(n.getLobbyPlayer(), n.getStats()); this.playerRating.put(n.getLobbyPlayer(), n.getStats());
} }
} }
/** /**
* Checks if is draw. * Checks if is draw.
@@ -77,10 +77,11 @@ public final class GameOutcome implements Iterable<Entry<LobbyPlayer, PlayerStat
* @return true, if is draw * @return true, if is draw
*/ */
public boolean isDraw() { public boolean isDraw() {
for( PlayerStatistics pv : playerRating.values()) for (PlayerStatistics pv : playerRating.values()) {
{
if ( pv.getOutcome().hasWon() ) if (pv.getOutcome().hasWon()) {
return false; return false;
}
} }
return true; return true;
} }
@@ -103,10 +104,11 @@ public final class GameOutcome implements Iterable<Entry<LobbyPlayer, PlayerStat
* @return the winner * @return the winner
*/ */
public LobbyPlayer getWinner() { public LobbyPlayer getWinner() {
for( Entry<LobbyPlayer, PlayerStatistics> ps : playerRating.entrySet()) for (Entry<LobbyPlayer, PlayerStatistics> ps : playerRating.entrySet()) {
{
if ( ps.getValue().getOutcome().hasWon() ) if (ps.getValue().getOutcome().hasWon()) {
return ps.getKey(); return ps.getKey();
}
} }
return null; return null;
} }
@@ -155,10 +157,11 @@ public final class GameOutcome implements Iterable<Entry<LobbyPlayer, PlayerStat
* @return the win spell effect * @return the win spell effect
*/ */
public String getWinSpellEffect() { public String getWinSpellEffect() {
for( PlayerStatistics pv : playerRating.values()) for (PlayerStatistics pv : playerRating.values()) {
{
if ( pv.getOutcome().hasWon() ) if (pv.getOutcome().hasWon()) {
return pv.getOutcome().altWinSourceName; return pv.getOutcome().altWinSourceName;
}
} }
return null; return null;
} }