Lots of code cleanup, including removing some useless null checks,

preventing some NPE's before they ever occur, and clean up some
of the inheritance hierarchy.
This commit is contained in:
elcnesh
2015-04-13 14:29:01 +00:00
parent 19ccab3d00
commit 6dacb83c37
19 changed files with 322 additions and 262 deletions

View File

@@ -66,7 +66,7 @@ public class DeckgenUtil {
}
gen.setSingleton(FModel.getPreferences().getPrefBoolean(FPref.DECKGEN_SINGLETONS));
gen.setUseArtifacts(!FModel.getPreferences().getPrefBoolean(FPref.DECKGEN_ARTIFACTS));
CardPool cards = gen == null ? null : gen.getDeck(60, forAi);
final CardPool cards = gen.getDeck(60, forAi);
if (null == deckName) {
deckName = Lang.joinHomogenous(Arrays.asList(selection));
@@ -312,7 +312,7 @@ public class DeckgenUtil {
gen = new DeckGenerator2Color(cardDb, format, comColors.get(0), comColors.get(1));
gen.setSingleton(true);
gen.setUseArtifacts(!FModel.getPreferences().getPrefBoolean(FPref.DECKGEN_ARTIFACTS));
CardPool cards = gen == null ? null : gen.getDeck(gameType.getDeckFormat().getMainRange().getMaximum(), forAi);
CardPool cards = gen.getDeck(gameType.getDeckFormat().getMainRange().getMaximum(), forAi);
// After generating card lists, build deck.
deck = new Deck("Generated " + gameType.toString() + " deck (" + commander.getName() + ")");

View File

@@ -385,13 +385,14 @@ public abstract class GameLobby {
deck = autoGenerateVariant.autoGenerateDeck(rp);
}
// Initialise variables for other variants
deck = deck == null ? rp.getDeck() : deck;
final CardPool avatarPool = deck.get(DeckSection.Avatar);
if (avatarPool != null) {
vanguardAvatar = avatarPool.get(0);
}
// Initialise variables for other variants
deck = deck == null ? rp.getDeck() : deck;
Iterable<PaperCard> schemes = null;
Iterable<PaperCard> planes = null;

View File

@@ -155,18 +155,19 @@ public class FGameClient implements IToServer {
replies.complete(event.getIndex(), event.getReply());
} else if (msg instanceof GuiGameEvent) {
final GuiGameEvent event = (GuiGameEvent) msg;
final String method = event.getMethod();
final Object[] args = event.getObjects();
Serializable reply = null;
boolean doReply = false;
final IButton btn;
if (args.length >= 2 && args[0] instanceof PlayerView && args[1] instanceof MatchButtonType) {
if (method.startsWith("btn_") && args.length >= 2 && args[0] instanceof PlayerView && args[1] instanceof MatchButtonType) {
btn = args[1] == MatchButtonType.OK ? clientGui.getBtnOK((PlayerView) args[0]) : clientGui.getBtnCancel((PlayerView) args[0]);
} else {
btn = null;
}
switch (event.getMethod()) {
switch (method) {
case "setGameView":
clientGui.setGameView((GameView) args[0]);
break;