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

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
* CardPrinteds to add

View File

@@ -200,7 +200,7 @@ public abstract class GenerateColoredDeckBase {
for (int i = 0; i < cmcAmounts.length; i++) {
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) {

View File

@@ -33,6 +33,6 @@ public enum GameEndReason {
WinsGameSpellEffect, // ones that could be both hardcoded (felidar) and
// 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,
}

View File

@@ -71,15 +71,17 @@ public class GameFormat {
private Predicate<CardPrinted> buildFilterPritned() {
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 Predicates.and(banNames, CardPrinted.Predicates.printedInSets(this.allowedSetCodes, true));
}
private Predicate<CardPrinted> buildFilterRules() {
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 Predicates.and(banNames, Predicates.compose(CardRulesPredicates.wasPrintedInSets(this.allowedSetCodes), CardPrinted.FN_GET_RULES));
}

View File

@@ -55,7 +55,7 @@ public class GameNew {
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,15 +70,16 @@ 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);
@@ -88,13 +89,14 @@ public class GameNew {
// Shuffling
// 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
final Iterable<Card> c1 = GameNew.smoothComputerManaCurve(player.getCardsIn(ZoneType.Library));
player.getZone(ZoneType.Library).setCards(c1);
} else
} else {
player.shuffle();
}
}
/**
@@ -104,7 +106,7 @@ public class GameNew {
* 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());
// what if I call it for AI player?
@@ -142,7 +144,6 @@ public class GameNew {
}
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);
@@ -150,8 +151,8 @@ public class GameNew {
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);
}
@@ -184,7 +185,7 @@ public class GameNew {
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);
@@ -204,7 +205,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);
}
@@ -273,7 +274,7 @@ public class GameNew {
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++) {
@@ -373,9 +374,10 @@ public class GameNew {
else {
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(),

View File

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