Class VariantSupport
java.lang.Object
net.sf.colossus.server.VariantSupport
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classA helper class to store the exception that happened during VariantLoading together with the task during which that happened. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static IVariantHintprivate static Variantprivate static Stringprivate static booleanwhether or not there is currently a valid variant loaded.private static final Loggerprivate static Stringprivate static Propertiesprivate static intprivate static Stringprivate static Stringprivate static Stringprivate static Stringprivate static Document -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic VariantRetrieves the currently loaded variant.static StringgetFullPathFileForVariantName(String varName) static intgetHintedRecruitmentValueOffset(CreatureType creature) static intgetHintedRecruitmentValueOffset(CreatureType creature, List<IVariantHint.AIStyle> aiStyles) static List<CreatureType> static List<CreatureType> getInitialSplitHint(MasterHex hex, List<IVariantHint.AIStyle> aiStyles) static Stringstatic Propertiesstatic intget maximum number of players in that variantprivate static Documentstatic CreatureTypegetRecruitHint(MasterBoardTerrain terrain, IOracleLegion legion, List<CreatureType> recruits, IHintOracle oracle) static CreatureTypegetRecruitHint(MasterBoardTerrain terrain, IOracleLegion legion, List<CreatureType> recruits, IHintOracle oracle, List<IVariantHint.AIStyle> aiStyles) getVarDirectoriesList(String suffixPath) static Stringstatic Stringstatic Stringprivate static StringgetVariantNameFromFilename(String varFilename) static AllCreatureTypeCall immediately after loading variant, before using creatures.private static voidprivate static Propertiesstatic IVariantInitializerloadTerrainsAndRecruits(AllCreatureType creatureTypes) static VariantloadVariant(String tempVariantName, String tempVarFilename, String tempVarDirectory, boolean serverSide) Try to load a Colossus Variant from the specified filename in the specified path.static VariantloadVariantByFile(File varFile, boolean serverSide) Load a Colossus Variant from the specified Filestatic VariantloadVariantByName(String variantName, boolean serverSide) Load a Colossus Variant by name.static voidrememberFullPathFileForVariantName(String varName, String varFullPathFilename) private static VarianttryLoadVariant(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 voidRemove 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
-
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
-
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:
tempVariantName- The actual plain name of the varianttempVarFilename- The name of the file holding the Variant definition.tempVarDirectory- The path to the directory holding the Variant.serverSide- 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.
-