Refactor variant descriptions into GameType enum

This commit is contained in:
drdev
2014-09-07 17:35:54 +00:00
parent cd69a0f4e2
commit be826672f2
4 changed files with 22 additions and 40 deletions

View File

@@ -13,19 +13,19 @@ import forge.game.player.RegisteredPlayer;
public enum GameType { public enum GameType {
// deck composition rules, isPoolRestricted, can sideboard between matches // deck composition rules, isPoolRestricted, can sideboard between matches
Sealed (DeckFormat.Limited, true, true, true, "Sealed", null), Sealed (DeckFormat.Limited, true, true, true, "Sealed", "", null),
Draft (DeckFormat.Limited, true, true, true, "Draft", null), Draft (DeckFormat.Limited, true, true, true, "Draft", "", null),
Winston (DeckFormat.Limited, true, true, true, "Winston", null), Winston (DeckFormat.Limited, true, true, true, "Winston", "", null),
Gauntlet (DeckFormat.Limited, true, true, true, "Gauntlet", null), Gauntlet (DeckFormat.Limited, true, true, true, "Gauntlet", "", null),
Quest (DeckFormat.QuestDeck, true, true, false, "Quest", null), Quest (DeckFormat.QuestDeck, true, true, false, "Quest", "", null),
QuestDraft (DeckFormat.Limited, true, true, true, "Quest Draft", null), QuestDraft (DeckFormat.Limited, true, true, true, "Quest Draft", "", null),
Constructed (DeckFormat.Constructed, false, true, true, "Constructed", null), Constructed (DeckFormat.Constructed, false, true, true, "Constructed", "", null),
Vanguard (DeckFormat.Vanguard, true, true, true, "Vanguard", null), Vanguard (DeckFormat.Vanguard, true, true, true, "Vanguard", "Each player has a special \"Avatar\" card that affects the game.", null),
Commander (DeckFormat.Commander, false, false, false, "Commander", null), Commander (DeckFormat.Commander, false, false, false, "Commander", "Each player has a legendary \"General\" card which can be cast at any time and determines deck colors.", null),
Planechase (DeckFormat.Planechase, false, false, true, "Planechase", null), Planechase (DeckFormat.Planechase, false, false, true, "Planechase", "Plane cards apply global effects. Plane card changed when a player rolls \"Chaos\" on the planar die.", null),
Archenemy (DeckFormat.Archenemy, false, false, true, "Archenemy", null), Archenemy (DeckFormat.Archenemy, false, false, true, "Archenemy", "One player is the Archenemy and can play scheme cards.", null),
ArchenemyRumble (DeckFormat.Archenemy, false, false, true, "Archenemy Rumble", null), ArchenemyRumble (DeckFormat.Archenemy, false, false, true, "Archenemy Rumble", "All players are Archenemies and can play scheme cards.", null),
MomirBasic (DeckFormat.Constructed, false, false, false, "Momir Basic", new Function<RegisteredPlayer, Deck>() { MomirBasic (DeckFormat.Constructed, false, false, false, "Momir Basic", "Each player has a deck containing 60 basic lands and the Momir Vig avatar.", new Function<RegisteredPlayer, Deck>() {
@Override @Override
public Deck apply(RegisteredPlayer player) { public Deck apply(RegisteredPlayer player) {
Deck deck = new Deck(); Deck deck = new Deck();
@@ -43,15 +43,16 @@ public enum GameType {
private final DeckFormat deckFormat; private final DeckFormat deckFormat;
private final boolean isCardPoolLimited, canSideboard, addWonCardsMidGame; private final boolean isCardPoolLimited, canSideboard, addWonCardsMidGame;
private final String name; private final String name, description;
private final Function<RegisteredPlayer, Deck> deckAutoGenerator; private final Function<RegisteredPlayer, Deck> deckAutoGenerator;
GameType(DeckFormat deckFormat0, boolean isCardPoolLimited0, boolean canSideboard0, boolean addWonCardsMidgame0, String name0, Function<RegisteredPlayer, Deck> deckAutoGenerator0) { GameType(DeckFormat deckFormat0, boolean isCardPoolLimited0, boolean canSideboard0, boolean addWonCardsMidgame0, String name0, String description0, Function<RegisteredPlayer, Deck> deckAutoGenerator0) {
deckFormat = deckFormat0; deckFormat = deckFormat0;
isCardPoolLimited = isCardPoolLimited0; isCardPoolLimited = isCardPoolLimited0;
canSideboard = canSideboard0; canSideboard = canSideboard0;
addWonCardsMidGame = addWonCardsMidgame0; addWonCardsMidGame = addWonCardsMidgame0;
name = name0; name = name0;
description = description0;
deckAutoGenerator = deckAutoGenerator0; deckAutoGenerator = deckAutoGenerator0;
} }
@@ -104,4 +105,8 @@ public enum GameType {
public String toString() { public String toString() {
return name; return name;
} }
public String getDescription() {
return description;
}
} }

View File

@@ -29,7 +29,6 @@ import forge.screens.home.*;
import forge.toolbox.*; import forge.toolbox.*;
import forge.toolbox.FSkin.SkinColor; import forge.toolbox.FSkin.SkinColor;
import forge.toolbox.FSkin.SkinImage; import forge.toolbox.FSkin.SkinImage;
import forge.util.GuiDisplayUtil;
import forge.util.Lang; import forge.util.Lang;
import forge.util.MyRandom; import forge.util.MyRandom;
import forge.util.NameGenerator; import forge.util.NameGenerator;
@@ -1144,7 +1143,7 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
variantType = variantType0; variantType = variantType0;
setToolTipText(GuiDisplayUtil.getVariantDescription(variantType0)); setToolTipText(variantType.getDescription());
addItemListener(new ItemListener() { addItemListener(new ItemListener() {
@Override @Override

View File

@@ -46,7 +46,6 @@ import forge.toolbox.FOptionPane;
import forge.toolbox.FScrollPane; import forge.toolbox.FScrollPane;
import forge.toolbox.FTextField; import forge.toolbox.FTextField;
import forge.util.Callback; import forge.util.Callback;
import forge.util.GuiDisplayUtil;
import forge.util.Lang; import forge.util.Lang;
import forge.util.NameGenerator; import forge.util.NameGenerator;
import forge.util.Utils; import forge.util.Utils;
@@ -951,11 +950,9 @@ public class ConstructedScreen extends LaunchScreen {
private class Variant { private class Variant {
private final GameType gameType; private final GameType gameType;
private final String description;
private Variant(GameType gameType0) { private Variant(GameType gameType0) {
gameType = gameType0; gameType = gameType0;
description = GuiDisplayUtil.getVariantDescription(gameType0);
} }
private void draw(Graphics g, FSkinFont font, FSkinColor color, float x, float y, float w, float h) { private void draw(Graphics g, FSkinFont font, FSkinColor color, float x, float y, float w, float h) {
@@ -1026,7 +1023,7 @@ public class ConstructedScreen extends LaunchScreen {
g.drawText(text, font, foreColor, x, y, w, h, false, HAlignment.LEFT, false); g.drawText(text, font, foreColor, x, y, w, h, false, HAlignment.LEFT, false);
value.draw(g, font, foreColor, x, y, w, h); value.draw(g, font, foreColor, x, y, w, h);
h += SettingsScreen.SETTING_PADDING; h += SettingsScreen.SETTING_PADDING;
g.drawText(value.description, SettingsScreen.DESC_FONT, SettingsScreen.DESC_COLOR, x, y + h, w, totalHeight - h + w * SettingsScreen.INSETS_FACTOR, true, HAlignment.LEFT, false); g.drawText(value.gameType.getDescription(), SettingsScreen.DESC_FONT, SettingsScreen.DESC_COLOR, x, y + h, w, totalHeight - h + w * SettingsScreen.INSETS_FACTOR, true, HAlignment.LEFT, false);
} }
} }
} }

View File

@@ -519,23 +519,4 @@ public final class GuiDisplayUtil {
String playerName = FModel.getPreferences().getPref(FPref.PLAYER_NAME); String playerName = FModel.getPreferences().getPref(FPref.PLAYER_NAME);
return text.replaceAll("(?i)human", playerName); return text.replaceAll("(?i)human", playerName);
} }
public static String getVariantDescription(GameType variant) {
switch (variant) {
case Archenemy:
return "One player is the Archenemy and can play scheme cards.";
case ArchenemyRumble:
return "All players are Archenemies and can play scheme cards.";
case Commander:
return "Each player has a legendary \"General\" card which can be cast at any time and determines deck colors.";
case MomirBasic:
return "Each player has a deck containing 60 basic lands and the Momir Vig avatar.";
case Planechase:
return "Plane cards apply global effects. Plane card changed when a player rolls \"Chaos\" on the planar die.";
case Vanguard:
return "Each player has a special \"Avatar\" card that affects the game.";
default:
return ""; //other game types don't need descriptions
}
}
} // end class GuiDisplayUtil } // end class GuiDisplayUtil