Class TerrainRecruitLoader

java.lang.Object
net.sf.colossus.xmlparser.TerrainRecruitLoader
All Implemented Interfaces:
IVariantInitializer

public class TerrainRecruitLoader extends Object implements IVariantInitializer
TerrainRecruitLoader load the terrains and recruits descriptions. TODO check if any of the methods still needs the "String terrain" parameter TODO we still use plenty of strings in here since the creatures are mixed with the special recruit requirements such as Anything/Lord/AnyNonLord or the custom recruits marked by the "Special:" keyword
Author:
Romain Dolbeau
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • setCaretaker

      public static void setCaretaker(Caretaker caretaker)
      set the Caretaker used by the graph (needed to know what creatures are still available)
    • isConcreteCreature

      private static boolean isConcreteCreature(String name)
    • addToGraph

      private static void addToGraph(List<TerrainRecruitLoader.RecruitNumber> rl, MasterBoardTerrain t)
      Add an entire terrain recruiting list to the Recruiting Graph.
      Parameters:
      rl - The list of RecruitNumber to add to the graph.
    • handleTerrain

      private void handleTerrain(org.jdom.Element el) throws org.jdom.JDOMException
      Throws:
      org.jdom.JDOMException
    • buildRecruitingSubTree

      private RecruitingSubTree buildRecruitingSubTree(List<TerrainRecruitLoader.RecruitNumber> rl, boolean regularRecruit)
    • handleAlias

      private void handleAlias(org.jdom.Element el) throws ParseException
      Throws:
      ParseException
    • handleAcquirable

      private void handleAcquirable(org.jdom.Element el) throws org.jdom.JDOMException, ParseException
      Throws:
      org.jdom.JDOMException
      ParseException
    • getTerrains

      public Collection<MasterBoardTerrain> getTerrains()
      Return a collection of all possible terrains. NOTE: Only meant to be used for Variant Initialization! In normal cases this list should be get from variant object.
      Specified by:
      getTerrains in interface IVariantInitializer
      Returns:
      A collection containing all instances of MasterBoardTerrain.
    • getTerrainById

      protected static MasterBoardTerrain getTerrainById(String id)
    • getCustomRecruitBase

      public static ICustomRecruitBase getCustomRecruitBase(String specialString)
    • getStartingCreatures

      public static CreatureType[] getStartingCreatures(MasterHex hex)
      Give an array of the starting creatures, those available in the first turn and in a particular kind of Tower. TODO this heuristic (first 3 creatures in the tower) should be replaced by a real entry in the Tower terrain (similar to startlist).
      Parameters:
      hex - The specific Tower considered.
      Returns:
      an array of Creature representing the starting creatures.
      See Also:
    • isStartCreature

      public static boolean isStartCreature(CreatureType type)
      Tell whether given type is in the loaded variant a start creature, i.e. one of those one gets in the initial legion in the tower (any tower). I plan to use this for e.g. HexRecruitTreePanel, to show there how one can get to have a certain creature: start creature -or- acquirable -or- recruitable by N of from prev. in tree, -or- recruitable by any/Lord/DemiLord/anyNonLord -or- recruitable by N of something else (e.g. Titan=>Warlock)
      Parameters:
      type -
      Returns:
      true if this is a start creature in the loaded variant
    • getTerrainRandomName

      public static String getTerrainRandomName(MasterBoardTerrain masterBoardTerrain)
      Give the name of the random filename to use to generate this terrain, or null if it's a static Battlelands.
      Parameters:
      masterBoardTerrain - A master board terrain.
      Returns:
      The name of the random source file as a String
    • getPossibleRecruits

      public static List<CreatureType> getPossibleRecruits(MasterBoardTerrain terrain, MasterHex hex)
      Give a modifiable list of the possible recruits in a terrain.
      Parameters:
      terrain - The terrain to consider.
      hex - The specific hex to consider. It shouldn't be null during the actual recruiting, but it can be null when doing evaluation (it's only used for special recruiting in custom variants).
      Returns:
      List of Creatures that can be recruited in the terrain.
      See Also:
    • getPossibleRecruiters

      public static List<CreatureType> getPossibleRecruiters(MasterBoardTerrain terrain, MasterHex hex)
      Give a modifiable list of the possible recruiters in a terrain. TODO if clients need to modify they should make copies themselves, it seems better if have this class return an unmodifiable list
      Parameters:
      terrain - String representing a terrain.
      Returns:
      List of Creatures that can recruit in the terrain.
      See Also:
    • numberOfRecruiterNeeded

      public static int numberOfRecruiterNeeded(CreatureType recruiter, CreatureType recruit, MasterBoardTerrain terrain, MasterHex hex)
      Give the number of a given recruiters needed to recruit a given Creature. TODO do we need the terrain parameter
      Parameters:
      recruiter - The Creature that wish to recruit.
      recruit - The Creature that is to be recruited.
      terrain - String representing a terrain, in which the recruiting occurs.
      Returns:
      Number of recruiter needed.
      See Also:
    • anonymousRecruitLegal

      public static boolean anonymousRecruitLegal(CreatureType recruit, MasterBoardTerrain terrain, MasterHex hex)
    • getTitanImprovementValue

      public int getTitanImprovementValue()
      To obtain the base amount of points needed for Titan improvement.
      Specified by:
      getTitanImprovementValue in interface IVariantInitializer
      Returns:
      The base amount of points needed for Titan improvement.
    • getTitanTeleportValue

      public int getTitanTeleportValue()
      To obtain the amount of points needed for Titan teleport.
      Specified by:
      getTitanTeleportValue in interface IVariantInitializer
      Returns:
      The amount of points needed for Titan teleport.
    • getRecruitGraph

      public static RecruitGraph getRecruitGraph()
      to obtain the recruit graph
    • getAcquirablesList

      public List<Variant.AcquirableData> getAcquirablesList()
      Specified by:
      getAcquirablesList in interface IVariantInitializer