Refactor/Code Cleanup

This commit is contained in:
Anthony Calosa
2019-09-02 18:08:56 +08:00
parent 83b6b9faeb
commit c38bae910a
411 changed files with 1354 additions and 3010 deletions

View File

@@ -81,7 +81,7 @@ public abstract class AchievementCollection implements Iterable<Achievement> {
}
protected AchievementCollection(String name0, String filename0, boolean isLimitedFormat0) {
this(name0, filename0, isLimitedFormat0, (String) null);
this(name0, filename0, isLimitedFormat0, null);
}
protected AchievementCollection(String name0, String filename0, boolean isLimitedFormat0, String path0) {
@@ -125,7 +125,7 @@ public abstract class AchievementCollection implements Iterable<Achievement> {
final List<String> achievementListFile = FileUtil.readFile(path);
for (final String s : achievementListFile) {
if (!s.isEmpty()) {
String k[] = StringUtils.split(s, "|");
String[] k = StringUtils.split(s, "|");
add(k[0],k[1],k[2]);
}
}

View File

@@ -72,11 +72,8 @@ public class ChallengeAchievements extends AchievementCollection {
}
public static boolean checkValidGameMode(final Game game) {
if (game.getRules().hasAppliedVariant(GameType.MomirBasic) || game.getRules().hasAppliedVariant(GameType.MoJhoSto)
|| game.getRules().hasAppliedVariant(GameType.Puzzle)) {
// these modes use a fixed pre-defined deck format, so challenge achievements don't apply in them
return false;
}
return true;
// these modes use a fixed pre-defined deck format, so challenge achievements don't apply in them
return !game.getRules().hasAppliedVariant(GameType.MomirBasic) && !game.getRules().hasAppliedVariant(GameType.MoJhoSto)
&& !game.getRules().hasAppliedVariant(GameType.Puzzle);
}
}

View File

@@ -15,10 +15,7 @@ public class MatchWinStreak extends StreakAchievement {
@Override
protected Boolean eval(Player player, Game game) {
if (game.getMatch().isMatchOver()) {
if (game.getMatch().isWonBy(player.getLobbyPlayer())) {
return true;
}
return false;
return game.getMatch().isWonBy(player.getLobbyPlayer());
}
return null;
}

View File

@@ -23,9 +23,7 @@ public class VariantWins extends ProgressiveAchievement {
if (game.getRules().hasAppliedVariant(variant)) {
return true;
}
if (variant == GameType.Archenemy && game.getRules().hasAppliedVariant(GameType.ArchenemyRumble)) {
return true; //lump Archenemy Rumble into same achievement as Archenemy
}
return variant == GameType.Archenemy && game.getRules().hasAppliedVariant(GameType.ArchenemyRumble); //lump Archenemy Rumble into same achievement as Archenemy
}
return false;
}

View File

@@ -297,7 +297,7 @@ public enum FSkinProp {
private int[] coords;
private PropType type;
private FSkinProp(final int[] coords0, final PropType type0) {
FSkinProp(final int[] coords0, final PropType type0) {
coords = coords0;
type = type0;
}

View File

@@ -46,7 +46,7 @@ public class CardDetailUtil {
public final int r, g, b;
private DetailColors(final int r0, final int g0, final int b0) {
DetailColors(final int r0, final int g0, final int b0) {
r = r0;
g = g0;
b = b0;

View File

@@ -162,7 +162,7 @@ public class CardReaderExperiments {
Matcher m = p.matcher(line);
if (m.matches()) {
StringBuilder newLineBuilder = new StringBuilder();
newLineBuilder.append(line.substring(0, m.start(1)));
newLineBuilder.append(line, 0, m.start(1));
for (String sym : m.group(1).split(" ")) {
newLineBuilder.append("{" + sym + "}");
}

View File

@@ -119,10 +119,7 @@ public final class CardScriptParser {
if (!(part.startsWith("P") || part.startsWith("2") || isManaSymbol(part.charAt(0)))) {
return false;
}
if ((!isManaSymbol(part.charAt(1))) || part.charAt(0) == part.charAt(1)) {
return false;
}
return true;
return (isManaSymbol(part.charAt(1))) && part.charAt(0) != part.charAt(1);
}
return false;
}
@@ -344,10 +341,7 @@ public final class CardScriptParser {
if (DEFINED_CARDS.contains(defined)) {
return true;
}
if (Iterables.any(DEFINED_CARDS_STARTSWITH, startsWith(defined))) {
return true;
}
return false;
return Iterables.any(DEFINED_CARDS_STARTSWITH, startsWith(defined));
}
private static boolean isDefinedPlayerLegal(final String defined) {
final boolean non = defined.startsWith("Non"), flipped = defined.startsWith("Flipped");
@@ -363,10 +357,7 @@ public final class CardScriptParser {
if (DEFINED_PLAYERS.contains(defined)) {
return true;
}
if (Iterables.any(DEFINED_PLAYERS_STARTSWITH, startsWith(defined))) {
return true;
}
return false;
return Iterables.any(DEFINED_PLAYERS_STARTSWITH, startsWith(defined));
}
private static final Set<String> VALID_INCLUSIVE = ImmutableSortedSet.of(
@@ -472,10 +463,7 @@ public final class CardScriptParser {
if (VALID_EXCLUSIVE.contains(valid)) {
return true;
}
if (Iterables.any(VALID_EXCLUSIVE_STARTSWITH, startsWith(valid))) {
return true;
}
return false;
return Iterables.any(VALID_EXCLUSIVE_STARTSWITH, startsWith(valid));
}
private static final class KeyValuePair {

View File

@@ -80,7 +80,7 @@ public final class CardArchetypeLDAGenerator {
System.out.print("t" + t + ": ");
int i = 0;
while (topic.size()<=40&&i<highRankVocabs.size()) {
String cardName = highRankVocabs.get(i).getLeft();;
String cardName = highRankVocabs.get(i).getLeft();
if(!StaticData.instance().getCommonCards().getUniqueByName(cardName).getRules().getType().isBasicLand()){
if(highRankVocabs.get(i).getRight()>=0.005d) {
topicCards.add(cardName);

View File

@@ -100,7 +100,7 @@ public final class CardRelationMatrixGenerator {
for (PaperCard card:cardList){
int col=cardIntegerMap.get(card.getName());
int[] distances = matrix[col];
int max = (Integer) Collections.max(Arrays.asList(ArrayUtils.toObject(distances)));
int max = Collections.max(Arrays.asList(ArrayUtils.toObject(distances)));
if (max>0) {
ArrayIndexComparator comparator = new ArrayIndexComparator(ArrayUtils.toObject(distances));
Integer[] indices = comparator.createIndexArray();
@@ -118,7 +118,7 @@ public final class CardRelationMatrixGenerator {
++j;
}
deckPool.add(new AbstractMap.SimpleEntry<PaperCard, Integer>(cardToAdd,distances[indices[cardList.size()-1-k]]));
};
}
if(excludeThisCard){
continue;
}
@@ -181,7 +181,7 @@ public final class CardRelationMatrixGenerator {
for (PaperCard card:legends){
int col=legendIntegerMap.get(card.getName());
int[] distances = matrix[col];
int max = (Integer) Collections.max(Arrays.asList(ArrayUtils.toObject(distances)));
int max = Collections.max(Arrays.asList(ArrayUtils.toObject(distances)));
if (max>0) {
List<Map.Entry<PaperCard,Integer>> deckPool=new ArrayList<>();
for(int k=0;k<cardList.size(); k++){

View File

@@ -85,7 +85,7 @@ public enum DeckType {
}
private String value;
private DeckType(final String value) {
DeckType(final String value) {
final Localizer localizer = Localizer.getInstance();
this.value = localizer.getMessage(value);
}

View File

@@ -181,7 +181,7 @@ public class GuiDownloadZipService extends GuiDownloadService {
int count;
long total = 0;
final byte data[] = new byte[1024];
final byte[] data = new byte[1024];
while ((count = input.read(data)) != -1) {
if (cancel) { break; }

View File

@@ -61,7 +61,7 @@ public class ExceptionHandler implements UncaughtExceptionHandler {
int i = 0;
while (logFile.exists() && !logFile.delete()) {
String pathname = logFile.getPath().replaceAll("[0-9]{0,2}.log$", String.valueOf(i++) + ".log");
String pathname = logFile.getPath().replaceAll("[0-9]{0,2}.log$", i++ + ".log");
logFile = new File(pathname);
}

View File

@@ -64,7 +64,7 @@ public final class GauntletData {
public void stamp() {
final DateFormat dateFormat = new SimpleDateFormat("MM-dd-yy, H:m");
timestamp = dateFormat.format(new Date()).toString();
timestamp = dateFormat.format(new Date());
}
/** Resets a gauntlet data to an unplayed state, then stamps and saves. */

View File

@@ -61,7 +61,7 @@ public interface IDevModeCheats {
* Implementation of {@link IDevModeCheats} that disallows cheating by
* performing no action whatsoever when any of its methods is called.
*/
public static final IDevModeCheats NO_CHEAT = new IDevModeCheats() {
IDevModeCheats NO_CHEAT = new IDevModeCheats() {
@Override
public void winGame() {
}

View File

@@ -22,7 +22,7 @@ public interface IMayViewCards {
boolean mayFlip(CardView c);
/** {@link IMayViewCards} that lets you view all cards unconditionally. */
public static final IMayViewCards ALL = new IMayViewCards() {
IMayViewCards ALL = new IMayViewCards() {
@Override
public boolean mayView(final CardView c) {
return true;

View File

@@ -363,7 +363,7 @@ public class AdvancedSearch {
private final FilterOperator[] operatorOptions;
private final FilterEvaluator<? extends InventoryItem, ?> evaluator;
private FilterOption(String name0, Class<? extends InventoryItem> type0, FilterOperator[] operatorOptions0, FilterEvaluator<? extends InventoryItem, ?> evaluator0) {
FilterOption(String name0, Class<? extends InventoryItem> type0, FilterOperator[] operatorOptions0, FilterEvaluator<? extends InventoryItem, ?> evaluator0) {
name = name0;
type = type0;
operatorOptions = operatorOptions0;
@@ -680,7 +680,7 @@ public class AdvancedSearch {
private final FilterValueCount valueCount;
private final OperatorEvaluator<?> evaluator;
private FilterOperator(String caption0, String formatStr0, FilterValueCount valueCount0, OperatorEvaluator<?> evaluator0) {
FilterOperator(String caption0, String formatStr0, FilterValueCount valueCount0, OperatorEvaluator<?> evaluator0) {
caption = caption0;
formatStr = formatStr0;
valueCount = valueCount0;
@@ -1302,7 +1302,7 @@ public class AdvancedSearch {
private final String token;
private Operator(String token0) {
Operator(String token0) {
token = token0;
}

View File

@@ -7,7 +7,7 @@ import com.google.common.base.Function;
import forge.item.InventoryItem;
public class ItemColumnConfig {
public static enum SortState {
public enum SortState {
NONE,
ASC,
DESC

View File

@@ -114,7 +114,7 @@ public enum ItemManagerConfig {
private Prop<Integer> imageColumnCount;
private Prop<Integer> viewIndex;
private ItemManagerConfig(final Map<ColumnDef, ItemColumnConfig> cols0, boolean showUniqueCardsOption0, boolean uniqueCardsOnly0, boolean hideFilters0, GroupDef groupBy0, ColumnDef pileBy0, int imageColumnCount0, int viewIndex0) {
ItemManagerConfig(final Map<ColumnDef, ItemColumnConfig> cols0, boolean showUniqueCardsOption0, boolean uniqueCardsOnly0, boolean hideFilters0, GroupDef groupBy0, ColumnDef pileBy0, int imageColumnCount0, int viewIndex0) {
cols = cols0;
for (ItemColumnConfig colConfig : cols.values()) {
colConfig.establishDefaults();

View File

@@ -190,7 +190,7 @@ public final class ItemManagerModel<T extends InventoryItem> {
for (final ItemColumn col : colsToSort) {
oneColSorters.add(new ItemPoolSorter<InventoryItem>(
col.getFnSort(),
col.getConfig().getSortState().equals(SortState.ASC) ? true : false));
col.getConfig().getSortState().equals(SortState.ASC)));
}
return new Sorter(oneColSorters);

View File

@@ -28,7 +28,7 @@ import java.util.Map.Entry;
*/
public final class SItemManagerUtil {
/** An enum to encapsulate metadata for the stats/filter objects. */
public static enum StatTypes implements IHasSkinProp {
public enum StatTypes implements IHasSkinProp {
WHITE (FSkinProp.IMG_MANA_W, CardRulesPredicates.Presets.IS_WHITE, "lblWhitecards"),
BLUE (FSkinProp.IMG_MANA_U, CardRulesPredicates.Presets.IS_BLUE, "lblBluecards"),
BLACK (FSkinProp.IMG_MANA_B, CardRulesPredicates.Presets.IS_BLACK, "lblBlackcards"),
@@ -78,7 +78,7 @@ public final class SItemManagerUtil {
public final Predicate<CardRules> predicate;
public final String label;
private StatTypes(final FSkinProp skinProp0, final Predicate<CardRules> predicate0, final String label0) {
StatTypes(final FSkinProp skinProp0, final Predicate<CardRules> predicate0, final String label0) {
skinProp = skinProp0;
predicate = predicate0;
final Localizer localizer = Localizer.getInstance();

View File

@@ -346,7 +346,7 @@ public class BoosterDraft implements IBoosterDraft {
@Override
public Deck[] getDecks() {
Deck decks[] = new Deck[7];
Deck[] decks = new Deck[7];
for (int i = 1; i < N_PLAYERS; i++) {
decks[i - 1] = ((LimitedPlayerAI) this.players.get(i)).buildDeck();
}

View File

@@ -44,7 +44,7 @@ public class CardThemedConquestDeckBuilder extends CardThemedDeckBuilder {
}
numSpellsNeeded = ((Double)Math.floor(targetSize*(getCreaturePercentage()+getSpellPercentage()))).intValue();
numCreaturesToStart = ((Double)Math.ceil(targetSize*(getCreaturePercentage()))).intValue();
landsNeeded = ((Double)Math.ceil(targetSize*(getLandPercentage()))).intValue();;
landsNeeded = ((Double)Math.ceil(targetSize*(getLandPercentage()))).intValue();
if (logColorsToConsole) {
System.out.println(keyCard.getName());
System.out.println("Pre Colors: " + colors.toEnumSet().toString());

View File

@@ -132,7 +132,7 @@ public class CardThemedDeckBuilder extends DeckGeneratorBase {
}
numSpellsNeeded = ((Double)Math.floor(targetSize*(getCreaturePercentage()+getSpellPercentage()))).intValue();
numCreaturesToStart = ((Double)Math.ceil(targetSize*(getCreaturePercentage()))).intValue();
landsNeeded = ((Double)Math.ceil(targetSize*(getLandPercentage()))).intValue();;
landsNeeded = ((Double)Math.ceil(targetSize*(getLandPercentage()))).intValue();
if (logColorsToConsole) {
System.out.println(keyCard.getName());
System.out.println("Pre Colors: " + colors.toEnumSet().toString());

View File

@@ -8,7 +8,7 @@ public enum LimitedPoolType {
Chaos("Chaos Draft");
private final String displayName;
private LimitedPoolType(String name) {
LimitedPoolType(String name) {
displayName = name;
}

View File

@@ -158,7 +158,7 @@ public abstract class GameLobby implements IHasGameType {
public void addSlot() {
final int newIndex = getNumberOfSlots();
final LobbySlotType type = allowNetworking ? LobbySlotType.OPEN : LobbySlotType.AI;
addSlot(new LobbySlot(type, null, newIndex, newIndex, false, !allowNetworking, Collections.<AIOption>emptySet()));
addSlot(new LobbySlot(type, null, newIndex, newIndex, false, !allowNetworking, Collections.emptySet()));
}
protected final void addSlot(final LobbySlot slot) {
if (slot == null) {
@@ -485,7 +485,7 @@ public abstract class GameLobby implements IHasGameType {
return null;
}
}
schemes = schemePool == null ? Collections.<PaperCard>emptyList() : schemePool.toFlatList();
schemes = schemePool == null ? Collections.emptyList() : schemePool.toFlatList();
}
//Planechase
@@ -498,7 +498,7 @@ public abstract class GameLobby implements IHasGameType {
return null;
}
}
planes = planePool == null ? Collections.<PaperCard>emptyList() : planePool.toFlatList();
planes = planePool == null ? Collections.emptyList() : planePool.toFlatList();
}
//Vanguard

View File

@@ -98,7 +98,7 @@ public class HostedMatch {
throw new IllegalArgumentException();
}
this.guis = guis == null ? ImmutableMap.<RegisteredPlayer, IGuiGame>of() : guis;
this.guis = guis == null ? ImmutableMap.of() : guis;
final boolean useRandomFoil = FModel.getPreferences().getPrefBoolean(FPref.UI_RANDOM_FOIL);
for (final RegisteredPlayer rp : players) {
rp.setRandomFoil(useRandomFoil);
@@ -160,7 +160,7 @@ public class HostedMatch {
final GameView gameView = getGameView();
humanCount = 0;
final MapOfLists<IGuiGame, PlayerView> playersPerGui = new HashMapOfLists<IGuiGame, PlayerView>(CollectionSuppliers.<PlayerView>arrayLists());
final MapOfLists<IGuiGame, PlayerView> playersPerGui = new HashMapOfLists<IGuiGame, PlayerView>(CollectionSuppliers.arrayLists());
for (int iPlayer = 0; iPlayer < players.size(); iPlayer++) {
final RegisteredPlayer rp = match.getPlayers().get(iPlayer);
final Player p = players.get(iPlayer);

View File

@@ -137,7 +137,7 @@ public final class LobbySlot implements Serializable {
}
public void setAiOptions(final Set<AIOption> aiOptions) {
this.aiOptions = aiOptions == null ? ImmutableSet.<AIOption>of() : ImmutableSet.copyOf(aiOptions);
this.aiOptions = aiOptions == null ? ImmutableSet.of() : ImmutableSet.copyOf(aiOptions);
}
}

View File

@@ -4,5 +4,5 @@ public enum LobbySlotType {
LOCAL,
AI,
OPEN,
REMOTE;
REMOTE
}

View File

@@ -3,7 +3,6 @@ package forge.match;
import java.util.Collections;
import forge.GuiBase;
import forge.ai.AIOption;
import forge.interfaces.IGuiGame;
public final class LocalLobby extends GameLobby {
@@ -15,10 +14,10 @@ public final class LocalLobby extends GameLobby {
final String humanName = localName();
final int[] avatarIndices = localAvatarIndices();
final LobbySlot slot0 = new LobbySlot(LobbySlotType.LOCAL, humanName, avatarIndices[0], 0, true, true, Collections.<AIOption>emptySet());
final LobbySlot slot0 = new LobbySlot(LobbySlotType.LOCAL, humanName, avatarIndices[0], 0, true, true, Collections.emptySet());
addSlot(slot0);
final LobbySlot slot1 = new LobbySlot(LobbySlotType.AI, null, avatarIndices[1], 1, false, true, Collections.<AIOption>emptySet());
final LobbySlot slot1 = new LobbySlot(LobbySlotType.AI, null, avatarIndices[1], 1, false, true, Collections.emptySet());
addSlot(slot1);
}

View File

@@ -3,5 +3,5 @@ package forge.match;
public enum NextGameDecision {
NEW,
CONTINUE,
QUIT;
QUIT
}

View File

@@ -55,7 +55,7 @@ public class InputLockUI implements Input {
}
FThreads.invokeInEdtLater(showMessageFromEdt);
}
};
}
private final Runnable showMessageFromEdt = new Runnable() {
@Override

View File

@@ -181,10 +181,7 @@ public final class CardBlock implements Comparable<CardBlock> {
if (!this.landSet.equals(other.landSet)) {
return false;
}
if (!this.name.equals(other.name)) {
return false;
}
return true;
return this.name.equals(other.name);
}
/*

View File

@@ -276,7 +276,7 @@ public final class FModel {
} else if (s.length() > 1) {
if (tList != null) {
if (s.contains(":")) {
String k[] = s.split(":");
String[] k = s.split(":");
tList.add(k[0]);
CardType.Constant.pluralTypes.put(k[0], k[1]);
} else {

View File

@@ -108,7 +108,7 @@ public class MetaSet {
private final String shortHand;
public final String descriptiveName;
private MetaSetType(String shortname, String descName) {
MetaSetType(String shortname, String descName) {
shortHand = shortname;
descriptiveName = descName;
}

View File

@@ -2,7 +2,6 @@ package forge.net;
import java.util.Collections;
import forge.ai.AIOption;
import forge.interfaces.IGuiGame;
import forge.match.GameLobby;
import forge.match.LobbySlot;
@@ -16,10 +15,10 @@ public final class OfflineLobby extends GameLobby {
final String humanName = localName();
final int[] avatarIndices = localAvatarIndices();
final LobbySlot slot0 = new LobbySlot(LobbySlotType.LOCAL, humanName, avatarIndices[0], 0, true, false, Collections.<AIOption>emptySet());
final LobbySlot slot0 = new LobbySlot(LobbySlotType.LOCAL, humanName, avatarIndices[0], 0, true, false, Collections.emptySet());
addSlot(slot0);
final LobbySlot slot1 = new LobbySlot(LobbySlotType.OPEN, null, -1, -1, false, false, Collections.<AIOption>emptySet());
final LobbySlot slot1 = new LobbySlot(LobbySlotType.OPEN, null, -1, -1, false, false, Collections.emptySet());
addSlot(slot1);
}

View File

@@ -101,23 +101,23 @@ public enum ProtocolMethod {
CLIENT(IGameController.class);
private final Class<?> toInvoke;
private Mode(final Class<?> toInvoke) {
Mode(final Class<?> toInvoke) {
this.toInvoke = toInvoke;
}
};
}
private final ProtocolMethod.Mode mode;
private final Class<?> returnType;
private final Class<?>[] args;
private ProtocolMethod(final ProtocolMethod.Mode mode) {
ProtocolMethod(final ProtocolMethod.Mode mode) {
this(mode, Void.TYPE);
}
private ProtocolMethod(final ProtocolMethod.Mode mode, final Class<?> returnType) {
ProtocolMethod(final ProtocolMethod.Mode mode, final Class<?> returnType) {
this(mode, returnType, (Class<?>[]) null);
}
@SafeVarargs
private ProtocolMethod(final ProtocolMethod.Mode mode, final Class<?> returnType, final Class<?> ... args) {
ProtocolMethod(final ProtocolMethod.Mode mode, final Class<?> returnType, final Class<?>... args) {
this.mode = mode;
this.returnType = returnType;
this.args = args == null ? new Class<?>[] {} : args;

View File

@@ -231,7 +231,7 @@ final class GameClientHandler extends GameProtocolHandler<IGuiGame> {
if (trackableObject.getTracker() == null) {
trackableObject.setTracker(this.tracker);
// walk the props
EnumMap props = (EnumMap) trackableObject.getProps();
EnumMap props = trackableObject.getProps();
if (!(props == null)) {
for (Object propObj : props.values()) {
updateTrackers(new Object[]{propObj});

View File

@@ -223,7 +223,7 @@ public final class FServerManager {
NetworkInterface n = NetworkInterface.getByInetAddress(s.getLocalAddress());
Enumeration<InetAddress> en = n.getInetAddresses();
while (en.hasMoreElements()) {
InetAddress addr = (InetAddress) en.nextElement();
InetAddress addr = en.nextElement();
if (addr instanceof Inet4Address) {
if (preferIPv6) {
continue;

View File

@@ -4,7 +4,6 @@ import java.util.Collections;
import org.apache.commons.lang3.StringUtils;
import forge.ai.AIOption;
import forge.interfaces.IGuiGame;
import forge.match.GameLobby;
import forge.match.LobbySlot;
@@ -14,8 +13,8 @@ public final class ServerGameLobby extends GameLobby {
public ServerGameLobby() {
super(true);
addSlot(new LobbySlot(LobbySlotType.LOCAL, localName(), localAvatarIndices()[0], 0, true, false, Collections.<AIOption>emptySet()));
addSlot(new LobbySlot(LobbySlotType.OPEN, null, -1, 1, false, false, Collections.<AIOption>emptySet()));
addSlot(new LobbySlot(LobbySlotType.LOCAL, localName(), localAvatarIndices()[0], 0, true, false, Collections.emptySet()));
addSlot(new LobbySlot(LobbySlotType.OPEN, null, -1, 1, false, false, Collections.emptySet()));
}
public int connectPlayer(final String name, final int avatarIndex) {

View File

@@ -29,10 +29,7 @@ public class ConquestCommander implements InventoryItem, IXmlWritable {
@Override
public boolean apply(PaperCard pc) {
CardRules rules = pc.getRules();
if (rules.canBeCommander() || rules.getType().isPlaneswalker()) {
return false; //prevent including additional commanders or planeswalkers in starting deck
}
return true;
return !rules.canBeCommander() && !rules.getType().isPlaneswalker(); //prevent including additional commanders or planeswalkers in starting deck
}
})), false), null);
}

View File

@@ -27,7 +27,7 @@ public class ConquestPreferences extends PreferencesStore<ConquestPreferences.CQ
/**
* Preference identifiers, and their default values.
*/
public static enum CQPref {
public enum CQPref {
CURRENT_CONQUEST("DEFAULT"),
AETHER_BASE_DUPLICATE_VALUE("100"),

View File

@@ -206,7 +206,7 @@ public class ConquestUtil {
}
}
public static enum AEtherFilter implements IHasSkinProp {
public enum AEtherFilter implements IHasSkinProp {
C (null, new ColorFilter(MagicColor.COLORLESS), "Playable in {C}"),
W (null, new ColorFilter(MagicColor.WHITE), "Playable in {W}"),
U (null, new ColorFilter(MagicColor.BLUE), "Playable in {U}"),
@@ -262,7 +262,7 @@ public class ConquestUtil {
private final Predicate<PaperCard> predicate;
private String caption;
private AEtherFilter(final FSkinProp skinProp0, final Predicate<PaperCard> predicate0, final String caption0) {
AEtherFilter(final FSkinProp skinProp0, final Predicate<PaperCard> predicate0, final String caption0) {
skinProp = skinProp0;
predicate = predicate0;
caption = caption0;
@@ -509,8 +509,7 @@ public class ConquestUtil {
public boolean apply(PaperCard card) {
int cardCmc = card.getRules().getManaCost().getCMC();
if (cardCmc < cmcMin) { return false; }
if (cmcMax != -1 && cardCmc > cmcMax) { return false; }
return true;
return cmcMax == -1 || cardCmc <= cmcMax;
}
}
}

View File

@@ -17,7 +17,7 @@ import forge.util.MyRandom;
import forge.util.gui.SOptionPane;
public final class GamePlayerUtil {
private GamePlayerUtil() { };
private GamePlayerUtil() { }
private static final LobbyPlayer guiPlayer = new LobbyPlayerHuman("Human");
public static final LobbyPlayer getGuiPlayer() {

View File

@@ -159,7 +159,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
return PaymentDecision.card(discarded);
}
final String type = new String(discardType);
final String type = discardType;
final String[] validType = type.split(";");
hand = CardLists.getValidCards(hand, validType, player, source, ability);
@@ -860,7 +860,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
}
if (num == 0) {
return PaymentDecision.number(0);
};
}
inp = new InputSelectCardsFromList(controller, num, num, hand, ability);
inp.setMessage("Select %d more " + cost.getDescriptiveType() + " card(s) to reveal.");

View File

@@ -514,7 +514,7 @@ public class HumanPlay {
}
}
else if (part instanceof CostPutCardToLib) {
int amount = Integer.parseInt(((CostPutCardToLib) part).getAmount());
int amount = Integer.parseInt(part.getAmount());
final ZoneType from = ((CostPutCardToLib) part).getFrom();
final boolean sameZone = ((CostPutCardToLib) part).isSameZone();
CardCollectionView listView;
@@ -562,9 +562,7 @@ public class HumanPlay {
}
else { // Tainted Specter, Gurzigost, etc.
boolean hasPaid = payCostPart(controller, sourceAbility, (CostPartWithList)part, amount, list, "put into library." + orString);
if (!hasPaid) {
return false;
}
return hasPaid;
}
return true;
}
@@ -576,7 +574,7 @@ public class HumanPlay {
part.payAsDecided(p, pd, sourceAbility);
}
else if (part instanceof CostGainControl) {
int amount = Integer.parseInt(((CostGainControl)part).getAmount());
int amount = Integer.parseInt(part.getAmount());
CardCollectionView list = CardLists.getValidCards(p.getGame().getCardsIn(ZoneType.Battlefield), part.getType(), p, source);
boolean hasPaid = payCostPart(controller, sourceAbility, (CostPartWithList)part, amount, list, "gain control." + orString);
if (!hasPaid) { return false; }

View File

@@ -335,7 +335,7 @@ public class HumanPlaySpellAbility {
for (final String aVar : announce.split(",")) {
final String varName = aVar.trim();
if ("CreatureType".equals(varName)) {
final String choice = pc.chooseSomeType("Creature", ability, CardType.Constant.CREATURE_TYPES, Collections.<String>emptyList());
final String choice = pc.chooseSomeType("Creature", ability, CardType.Constant.CREATURE_TYPES, Collections.emptyList());
ability.getHostCard().setChosenType(choice);
}
if ("ChooseNumber".equals(varName)) {

View File

@@ -776,7 +776,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
} else {
toBottom = game.getCardList(getGui().many("Select cards to be put on the bottom of your library",
"Cards to put on the bottom", -1, CardView.getCollection(topN), null));
topN.removeAll((Collection<?>) toBottom);
topN.removeAll(toBottom);
if (topN.isEmpty()) {
toTop = null;
} else if (topN.size() == 1) {
@@ -814,7 +814,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
} else {
toGrave = game.getCardList(getGui().many("Select cards to be put into the graveyard",
"Cards to put in the graveyard", -1, CardView.getCollection(topN), null));
topN.removeAll((Collection<?>) toGrave);
topN.removeAll(toGrave);
if (topN.isEmpty()) {
toTop = null;
} else if (topN.size() == 1) {
@@ -1404,7 +1404,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
final boolean call) {
final String[] labelsSrc = call ? new String[] { "heads", "tails" }
: new String[] { "win the flip", "lose the flip" };
final ImmutableList.Builder<String> strResults = ImmutableList.<String>builder();
final ImmutableList.Builder<String> strResults = ImmutableList.builder();
for (int i = 0; i < results.length; i++) {
strResults.add(labelsSrc[results[i] ? 0 : 1]);
}
@@ -1665,8 +1665,8 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
boolean preselect = FModel.getPreferences()
.getPrefBoolean(FPref.UI_PRESELECT_PREVIOUS_ABILITY_ORDER);
orderedSAVs = getGui().order("Reorder simultaneous abilities", "Resolve first", 0, 0,
preselect ? Lists.<SpellAbilityView>newArrayList() : orderedSAVs,
preselect ? orderedSAVs : Lists.<SpellAbilityView>newArrayList(), null, false);
preselect ? Lists.newArrayList() : orderedSAVs,
preselect ? orderedSAVs : Lists.newArrayList(), null, false);
} else {
orderedSAVs = getGui().order("Select order for simultaneous abilities", "Resolve first", orderedSAVs,
null);
@@ -1829,10 +1829,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
return false;
}
final Player priorityPlayer = game.getPhaseHandler().getPriorityPlayer();
if (priorityPlayer == null || priorityPlayer != player) {
return false;
}
return true;
return priorityPlayer != null && priorityPlayer == player;
}
@Override
@@ -2741,7 +2738,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
for (final Player player : game.getPlayers()) {
if (player.getId() == entity.getKey()) {
found = true;
rememberedActions.add(Pair.of((GameEntityView) player.getView(), true));
rememberedActions.add(Pair.of(player.getView(), true));
break;
}
}
@@ -2749,7 +2746,7 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
for (final Card card : cards) {
if (card.getId() == entity.getKey()) {
found = true;
rememberedActions.add(Pair.of((GameEntityView) card.getView(), false));
rememberedActions.add(Pair.of(card.getView(), false));
break;
}
}

View File

@@ -12,7 +12,7 @@ import forge.game.player.PlayerView;
public class PlayerZoneUpdates implements Iterable<PlayerZoneUpdate>, Serializable {
private static final long serialVersionUID = 7023549243041119023L;
private final Map<PlayerView, PlayerZoneUpdate> updates = Collections.synchronizedMap(Maps.<PlayerView, PlayerZoneUpdate>newHashMap());
private final Map<PlayerView, PlayerZoneUpdate> updates = Collections.synchronizedMap(Maps.newHashMap());
public PlayerZoneUpdates() {
}

View File

@@ -306,7 +306,7 @@ public final class ForgeConstants {
public static final String GRAVEYARD_ORDERING_ALWAYS = "Always";
// Set boolean constant for landscape mode for gdx port
public static final boolean isGdxPortLandscape = FileUtil.doesFileExist(ASSETS_DIR + "switch_orientation.ini") ? true : false;
public static final boolean isGdxPortLandscape = FileUtil.doesFileExist(ASSETS_DIR + "switch_orientation.ini");
public enum CounterDisplayLocation {

View File

@@ -240,7 +240,7 @@ public class ForgePreferences extends PreferencesStore<ForgePreferences.FPref> {
private final String strDefaultVal;
private FPref(final String s0) {
FPref(final String s0) {
this.strDefaultVal = s0;
}

View File

@@ -74,7 +74,7 @@ public class ForgeProfileProperties {
cardPicsDir = getDir(props, CARD_PICS_DIR_KEY, cacheDir + "pics" + File.separator + "cards" + File.separator);
cardPicsSubDirs = getMap(props, CARD_PICS_SUB_DIRS_KEY);
decksDir = getDir(props, DECKS_DIR_KEY, userDir + "decks" + File.separator);
decksConstructedDir = getDir(props, DECKS_CONSTRUCTED_DIR_KEY, decksDir + "constructed" + File.separator);;
decksConstructedDir = getDir(props, DECKS_CONSTRUCTED_DIR_KEY, decksDir + "constructed" + File.separator);
serverPort = getInt(props, SERVER_PORT_KEY, 36743); // "Forge" using phone keypad
//ensure directories exist

View File

@@ -222,6 +222,6 @@ public class Puzzle extends GameState implements InventoryItem, Comparable<Puzzl
throw new ClassCastException("Tried to compare a Puzzle object to a non-Puzzle object.");
}
return getName().compareTo(((Puzzle)pzl).getName());
return getName().compareTo(pzl.getName());
}
}

View File

@@ -214,7 +214,7 @@ public class QuestController {
PreconDeck result = super.getPreconDeckFromSections(sections);
preconDeals.put(result.getName(), new SellRules(sections.get("shop")));
return result;
};
}
});
}
return QuestController.preconManager;

View File

@@ -427,11 +427,7 @@ public class QuestDraftUtils {
String sid1 = qd.getStandings()[offset];
String sid2 = qd.getStandings()[offset + 1];
if (sid1.equals(QuestEventDraft.HUMAN) || sid2.equals(QuestEventDraft.HUMAN)) {
return false;
}
return true;
return !sid1.equals(QuestEventDraft.HUMAN) && !sid2.equals(QuestEventDraft.HUMAN);
}
public static boolean injectRandomMatchOutcome(boolean simHumanMatches) {

View File

@@ -15,7 +15,7 @@ public enum QuestEventDifficulty {
private final String inFile;
private final double multiplier;
private QuestEventDifficulty(final String storedInFile, final double multiplier) {
QuestEventDifficulty(final String storedInFile, final double multiplier) {
inFile = storedInFile;
this.multiplier = multiplier;
}

View File

@@ -1022,7 +1022,6 @@ public class QuestEventDraft implements IQuestEvent {
if (allowedSets.size() == 2) {
final boolean draftOrder2016 = set0.getDate().after(FModel.getMagicDb().getEditions().get("BFZ").getDate()) ||
set1.getDate().after(FModel.getMagicDb().getEditions().get("BFZ").getDate());
;
if (draftOrder2016) {
if (set0.isLargeSet()) {
possibleCombinations.add(TextUtil.concatNoSpace(set1.getCode(), "/", set1.getCode(), "/", set0.getCode()));

View File

@@ -40,7 +40,7 @@ import java.util.*;
*/
public class QuestEventDuelManager implements QuestEventDuelManagerInterface {
private final MapOfLists<QuestEventDifficulty, QuestEventDuel> sortedDuels = new EnumMapOfLists<>(QuestEventDifficulty.class, CollectionSuppliers.<QuestEventDuel>arrayLists());
private final MapOfLists<QuestEventDifficulty, QuestEventDuel> sortedDuels = new EnumMapOfLists<>(QuestEventDifficulty.class, CollectionSuppliers.arrayLists());
private final IStorage<QuestEventDuel> allDuels;
/**

View File

@@ -42,7 +42,7 @@ import java.util.List;
public class QuestEventLDADuelManager implements QuestEventDuelManagerInterface {
private List<Archetype> archetypes;
private final MapOfLists<QuestEventDifficulty, QuestEventDuel> sortedDuels = new EnumMapOfLists<>(QuestEventDifficulty.class, CollectionSuppliers.<QuestEventDuel>arrayLists());
private final MapOfLists<QuestEventDifficulty, QuestEventDuel> sortedDuels = new EnumMapOfLists<>(QuestEventDifficulty.class, CollectionSuppliers.arrayLists());
private GameFormat baseFormat;
public QuestEventLDADuelManager(GameFormat baseFormat){

View File

@@ -25,9 +25,9 @@ public abstract class QuestRewardCard implements IQuestRewardCard {
if (s.startsWith("desc:") || s.startsWith("Desc:")) {
final String[] tmp = s.split(":");
if (tmp.length > 1) {
buildDesc = new String(tmp[1]);
buildDesc = tmp[1];
} else {
buildDesc = new String();
buildDesc = "";
}
} else if (buildDesc != null) {
if (s.contains(":")) {

View File

@@ -677,7 +677,7 @@ public class QuestUtil {
}
public static String getDeckConformanceProblems(Deck deck){
String errorMessage = GameType.Quest.getDeckFormat().getDeckConformanceProblem(deck);;
String errorMessage = GameType.Quest.getDeckFormat().getDeckConformanceProblem(deck);
if(errorMessage != null) return errorMessage; //return immediately if the deck does not conform to quest requirements

View File

@@ -130,7 +130,7 @@ public class QuestUtilUnlockSets {
*
* @return unmodifiable list, assorted sets that are not currently in the format.
*/
private static final List<CardEdition> emptyEditions = ImmutableList.<CardEdition>of();
private static final List<CardEdition> emptyEditions = ImmutableList.of();
private static final EnumSet<CardEdition.Type> unlockableSetTypes =
EnumSet.of(CardEdition.Type.CORE, CardEdition.Type.EXPANSION, CardEdition.Type.REPRINT, CardEdition.Type.STARTER);

View File

@@ -60,11 +60,7 @@ public class SellRules {
if (quest.getWin() < minWins) {
return false;
}
if (quest.getDifficulty() < minDifficulty || quest.getDifficulty() > maxDifficulty) {
return false;
}
return true;
return quest.getDifficulty() >= minDifficulty && quest.getDifficulty() <= maxDifficulty;
}
/**

View File

@@ -12,7 +12,7 @@ public enum StartingPoolType {
private final String caption;
private StartingPoolType(String caption0) {
StartingPoolType(String caption0) {
caption = caption0;
}

View File

@@ -53,8 +53,8 @@ public enum QuestItemType {
private final Class<? extends QuestItemBasic> bazaarControllerClass;
private final Class<? extends QuestItemCondition> modelClass;
private QuestItemType(final String key, final Class<? extends QuestItemBasic> controllerClass0,
final Class<? extends QuestItemCondition> modelClass0) {
QuestItemType(final String key, final Class<? extends QuestItemBasic> controllerClass0,
final Class<? extends QuestItemCondition> modelClass0) {
this.saveFileKey = key;
this.bazaarControllerClass = controllerClass0;
this.modelClass = modelClass0;

View File

@@ -44,10 +44,6 @@ public class StarRating {
return false;
}
if (rating != other.rating) {
return false;
}
return true;
return rating == other.rating;
}
}

View File

@@ -301,7 +301,7 @@ public class EventVisualizer extends IGameEventVisitor.Base<SoundEffectType> imp
if (null != c) {
effect = c.getSVar("SoundEffect");
}
return effect.isEmpty() ? false : true;
return !effect.isEmpty();
}

View File

@@ -1,8 +1,8 @@
package forge.sound;
public interface IAudioClip {
public void play();
public boolean isDone();
public void stop();
public void loop();
void play();
boolean isDone();
void stop();
void loop();
}

View File

@@ -14,7 +14,7 @@ public enum MusicPlaylist {
private int mostRecentTrackIdx = -1;
private String[] filenames;
private MusicPlaylist(String subDir0) {
MusicPlaylist(String subDir0) {
subDir = subDir0;
}

View File

@@ -57,7 +57,7 @@ public class TournamentData {
public void stamp() {
final DateFormat dateFormat = new SimpleDateFormat("MM-dd-yy, H:m");
timestamp = dateFormat.format(new Date()).toString();
timestamp = dateFormat.format(new Date());
}
/** Resets a Tournament data to an unplayed state, then stamps and saves. */

View File

@@ -57,7 +57,7 @@ public class TournamentSwiss extends AbstractTournament {
if (byePlayer != null) {
groupPlayers.remove(byePlayer);
TournamentPairing byePair = new TournamentPairing(activeRound, Lists.<TournamentPlayer>newArrayList(byePlayer));
TournamentPairing byePair = new TournamentPairing(activeRound, Lists.newArrayList(byePlayer));
byePair.setBye(true);
activePairings.add(byePair);
}

View File

@@ -118,7 +118,7 @@ public abstract class ImageFetcher {
protected abstract Runnable getDownloadTask(String[] toArray, String destPath, Runnable notifyObservers);
public static interface Callback {
public void onImageFetched();
public interface Callback {
void onImageFetched();
}
}