Class VariantSupport

java.lang.Object
net.sf.colossus.server.VariantSupport

public final class VariantSupport extends Object
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
  • Field Details

    • LOGGER

      private static final Logger LOGGER
    • varDirectory

      private static String varDirectory
    • varFilename

      private static String varFilename
    • variantName

      private static String variantName
    • mapName

      private static String mapName
    • recruitsFileName

      private static String recruitsFileName
    • hintName

      private static String hintName
    • lCreaturesName

      private static List<String> lCreaturesName
    • varREADME

      private static Document varREADME
    • dependUpon

      private static List<String> dependUpon
    • loadedVariant

      private static boolean loadedVariant
      whether or not there is currently a valid variant loaded. TODO: perhaps superfluous - check CURRENT_VARIANT for null instead?
    • CURRENT_VARIANT

      private static Variant CURRENT_VARIANT
    • maxPlayers

      private static int maxPlayers
    • aihl

      private static IVariantHint aihl
    • markerNames

      private static Properties markerNames
    • rememberCustomDirs

      private static Map<String,String> 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

      public static void rememberFullPathFileForVariantName(String varName, String varFullPathFilename)
    • getFullPathFileForVariantName

      public static String getFullPathFileForVariantName(String varName)
    • loadVariantByName

      public static Variant loadVariantByName(String variantName, boolean serverSide)
      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

      public static Variant loadVariantByFile(File varFile, boolean serverSide)
      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

      private static String getVariantNameFromFilename(String varFilename) throws Exception
      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:
      tempVariantName - The actual plain name of the variant
      tempVarFilename - 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 for loadVariant(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

      public static AllCreatureType loadCreatures()
      Call immediately after loading variant, before using creatures.
    • getMissingReadmeNotification

      private static Document getMissingReadmeNotification()
    • getVarDirectory

      public static String getVarDirectory()
    • getVarFilename

      public static String getVarFilename()
    • getVariantName

      public static String getVariantName()
    • getMapName

      public static String getMapName()
    • getCreaturesNames

      public static List<String> getCreaturesNames()
    • getVarDirectoriesList

      public static List<String> getVarDirectoriesList()
    • getVarDirectoriesList

      public static List<String> getVarDirectoriesList(String suffixPath)
    • getImagesDirectoriesList

      public static List<String> getImagesDirectoriesList()
    • getBattlelandsDirectoriesList

      public static List<String> getBattlelandsDirectoriesList()
    • loadTerrainsAndRecruits

      public static IVariantInitializer loadTerrainsAndRecruits(AllCreatureType creatureTypes)
    • loadMarkerNamesProperties

      private static Properties loadMarkerNamesProperties()
    • getMarkerNamesProperties

      public static Properties getMarkerNamesProperties()
    • loadHints

      private static void loadHints(Variant variant)
    • 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

      public static List<CreatureType> getInitialSplitHint(MasterHex hex)
    • getInitialSplitHint

      public static List<CreatureType> getInitialSplitHint(MasterHex hex, List<IVariantHint.AIStyle> aiStyles)
    • getHintedRecruitmentValueOffset

      public static int getHintedRecruitmentValueOffset(CreatureType creature)
    • 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

      public static 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.