Class TerrainRecruitLoader

  • All Implemented Interfaces:
    IVariantInitializer

    public class TerrainRecruitLoader
    extends java.lang.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:
    CreatureType
    • Field Detail

      • LOGGER

        private static final java.util.logging.Logger LOGGER
      • Keyword_Anything

        public static final java.lang.String Keyword_Anything
        See Also:
        Constant Field Values
      • Keyword_AnyNonLord

        public static final java.lang.String Keyword_AnyNonLord
        See Also:
        Constant Field Values
      • Keyword_DemiLord

        public static final java.lang.String Keyword_DemiLord
        See Also:
        Constant Field Values
      • aquirableRecruitmentsValue

        private int aquirableRecruitmentsValue
      • titanImprove

        private int titanImprove
        Base amount of points needed for Titan improvement.
      • titanTeleport

        private int titanTeleport
        Amount of points needed for Titan Teleport.
      • strToBelow

        private static java.util.Map<MasterBoardTerrain,​java.lang.Boolean> strToBelow
        Map a terrain to a boolean, telling if a Creature can recruit in the usual way or not. TODO integrate into MasterBoardTerrain
      • strToRnd

        private static java.util.Map<MasterBoardTerrain,​java.lang.String> strToRnd
        Map a terrain to an optional BattlelandsRandomizer filename. TODO integrate into MasterBoardTerrain
      • terrains

        private static java.util.Map<java.lang.String,​MasterBoardTerrain> terrains
        A map from the terrain names to the terrains.
      • nameToInstance

        private static java.util.Map<java.lang.String,​CustomRecruitBase> nameToInstance
        support for the custom recruiting functions ; map the class name to an instance of the class.
      • graph

        private static RecruitGraph graph
        Representation of the Recruiting Graph (for use) (sometimes called Recruiting Tree). TODO the VariantKnower is meant only as temporary solution; when variant loading and all this stuff here is not static any more, variant should be passed in or set afterwards or something...
      • creatureTypes

        private final AllCreatureType creatureTypes
        The AllCreatureType object to use, needed to convert from String (name) to the actual CreatureType.
    • Constructor Detail

      • TerrainRecruitLoader

        public TerrainRecruitLoader​(java.io.InputStream terIS,
                                    AllCreatureType creatureTypes)
    • Method Detail

      • 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​(java.lang.String name)
      • handleTerrain

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

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

        public java.util.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​(java.lang.String id)
      • getCustomRecruitBase

        public static ICustomRecruitBase getCustomRecruitBase​(java.lang.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:
        CreatureType
      • 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 java.lang.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 java.util.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:
        CreatureType
      • getPossibleRecruiters

        public static java.util.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:
        CreatureType
      • 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:
        CreatureType
      • 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