Package net.sf.colossus.server
Class VariantSupport
java.lang.Object
net.sf.colossus.server.VariantSupport
Class VariantSupport hold the members and functions
required to support Variants in Colossus
TODO this should probably move into the variant package sooner or later, possibly
into the
Variant
class itself- Author:
- Romain Dolbeau
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
A helper class to store the exception that happened during VariantLoading together with the task during which that happened. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static IVariantHint
private static Variant
private static String
private static boolean
whether or not there is currently a valid variant loaded.private static final Logger
private static String
private static Properties
private static int
private static String
private static String
private static String
private static String
private static Document
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Variant
Retrieves the currently loaded variant.static String
getFullPathFileForVariantName
(String varName) static int
getHintedRecruitmentValueOffset
(CreatureType creature) static int
getHintedRecruitmentValueOffset
(CreatureType creature, List<IVariantHint.AIStyle> aiStyles) static List<CreatureType>
static List<CreatureType>
getInitialSplitHint
(MasterHex hex, List<IVariantHint.AIStyle> aiStyles) static String
static Properties
static int
get maximum number of players in that variantprivate static Document
static CreatureType
getRecruitHint
(MasterBoardTerrain terrain, IOracleLegion legion, List<CreatureType> recruits, IHintOracle oracle) static CreatureType
getRecruitHint
(MasterBoardTerrain terrain, IOracleLegion legion, List<CreatureType> recruits, IHintOracle oracle, List<IVariantHint.AIStyle> aiStyles) getVarDirectoriesList
(String suffixPath) static String
static String
static String
private static String
getVariantNameFromFilename
(String varFilename) static AllCreatureType
Call immediately after loading variant, before using creatures.private static void
private static Properties
static IVariantInitializer
loadTerrainsAndRecruits
(AllCreatureType creatureTypes) static Variant
loadVariant
(String tempVariantName, String tempVarFilename, String tempVarDirectory, boolean serverSide) Try to load a Colossus Variant from the specified filename in the specified path.static Variant
loadVariantByFile
(File varFile, boolean serverSide) Load a Colossus Variant from the specified Filestatic Variant
loadVariantByName
(String variantName, boolean serverSide) Load a Colossus Variant by name.static void
rememberFullPathFileForVariantName
(String varName, String varFullPathFilename) private static Variant
tryLoadVariant
(String tempVariantName, String tempVarFilename, String tempVarDirectory, boolean serverSide) This does the actual work forloadVariant(String, String, String, boolean)
This here is private and should be called only from the synchronized before-mentioned method.static void
Remove all variant data, so that next variant loading attempt is guaranteed to load it freshly (e.g.
-
Field Details
-
LOGGER
-
varDirectory
-
varFilename
-
variantName
-
mapName
-
recruitsFileName
-
hintName
-
lCreaturesName
-
varREADME
-
dependUpon
-
loadedVariant
private static boolean loadedVariantwhether or not there is currently a valid variant loaded. TODO: perhaps superfluous - check CURRENT_VARIANT for null instead? -
CURRENT_VARIANT
-
maxPlayers
private static int maxPlayers -
aihl
-
markerNames
-
rememberCustomDirs
-
-
Constructor Details
-
VariantSupport
public VariantSupport()
-
-
Method Details
-
unloadVariant
public static void unloadVariant()Remove all variant data, so that next variant loading attempt is guaranteed to load it freshly (e.g. to get XML data from remote server even if currently loaded was same name, but, well, from local files). -
rememberFullPathFileForVariantName
-
getFullPathFileForVariantName
-
loadVariantByName
Load a Colossus Variant by name.- Parameters:
variantName
- The name of the variant.serverSide
- We're loading on a server.- Returns:
- The loaded variant.
-
loadVariantByFile
Load a Colossus Variant from the specified File- Parameters:
varFile
- The File to load as a Variant, probably selected by user in a FileSelectionDialog, with full absolute path.serverSide
- We're loading on a server.- Returns:
- The loaded variant.
-
getVariantNameFromFilename
- Throws:
Exception
-
loadVariant
public static Variant loadVariant(String tempVariantName, String tempVarFilename, String tempVarDirectory, boolean serverSide) Try to load a Colossus Variant from the specified filename in the specified path. If loading fails, inform user with a message dialog and try to load Default variant instead. If that fails as well, do a system.exit after another message dialog. Synchronized to avoid concurrent threads running into it at same time (probably not possible so far, but if one day Public Server game can run with one local human and several AIs (on user's computer) this would become an issue.- Parameters:
tempVarFilename
- The name of the file holding the Variant definition.tempVarDirectory
- The path to the directory holding the Variant.tempVariantName
- The actual plain name of the variantserverSide
- We're loading on a server.- Returns:
- A variant object, perhaps newly created, perhaps re-used if same variant was used before. TODO right now variant name might sometimes be null, then we try a hack to retrieve the variant name from the variant file name.
-
tryLoadVariant
private static Variant tryLoadVariant(String tempVariantName, String tempVarFilename, String tempVarDirectory, boolean serverSide) throws VariantSupport.VariantLoadException This does the actual work forloadVariant(String, String, String, boolean)
This here is private and should be called only from the synchronized before-mentioned method.- Parameters:
tempVariantName
-tempVarFilename
-tempVarDirectory
-serverSide
-- Returns:
- A variant object, perhaps newly created, perhaps re-used if same variant was used before.
- Throws:
VariantSupport.VariantLoadException
-
loadCreatures
Call immediately after loading variant, before using creatures. -
getMissingReadmeNotification
-
getVarDirectory
-
getVarFilename
-
getVariantName
-
getMapName
-
getCreaturesNames
-
getVarDirectoriesList
-
getVarDirectoriesList
-
getImagesDirectoriesList
-
getBattlelandsDirectoriesList
-
loadTerrainsAndRecruits
-
loadMarkerNamesProperties
-
getMarkerNamesProperties
-
loadHints
-
getRecruitHint
public static CreatureType getRecruitHint(MasterBoardTerrain terrain, IOracleLegion legion, List<CreatureType> recruits, IHintOracle oracle) -
getRecruitHint
public static CreatureType getRecruitHint(MasterBoardTerrain terrain, IOracleLegion legion, List<CreatureType> recruits, IHintOracle oracle, List<IVariantHint.AIStyle> aiStyles) -
getInitialSplitHint
-
getInitialSplitHint
public static List<CreatureType> getInitialSplitHint(MasterHex hex, List<IVariantHint.AIStyle> aiStyles) -
getHintedRecruitmentValueOffset
-
getHintedRecruitmentValueOffset
public static int getHintedRecruitmentValueOffset(CreatureType creature, List<IVariantHint.AIStyle> aiStyles) -
getMaxPlayers
public static int getMaxPlayers()get maximum number of players in that variant -
getCurrentVariant
Retrieves the currently loaded variant. TODO this is a helper method to introduce the Variant objects into the code, in the long run they should be passed around instead of being in a static member here.
-