Class TerrainRecruitLoader
java.lang.Object
net.sf.colossus.xmlparser.TerrainRecruitLoader
- All Implemented Interfaces:
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classHelper class, associating a Creature and a number.static classprivate classUsed internally to associate a creature name and the number of creatures needed to recruit it.private classUsed internally to associate a creature name and the number received when starting a game. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static List<Variant.AcquirableData> The list of Acquirable Creature, as acquirableData.private intprivate final AllCreatureTypeThe AllCreatureType object to use, needed to convert from String (name) to the actual CreatureType.private static RecruitGraphRepresentation of the Recruiting Graph (for use) (sometimes called Recruiting Tree).static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprivate static final Loggerprivate static Map<String, CustomRecruitBase> support for the custom recruiting functions ; map the class name to an instance of the class.private static Map<MasterBoardTerrain, Boolean> Map a terrain to a boolean, telling if a Creature can recruit in the usual way or not.private static Map<MasterBoardTerrain, List<TerrainRecruitLoader.RecruitNumber>> Map a terrain to a list of recruits.private static Map<MasterBoardTerrain, String> Map a terrain to an optional BattlelandsRandomizer filename.private static Map<MasterBoardTerrain, List<TerrainRecruitLoader.StartingNumber>> Map a terrain to a list of recruits.private static Map<String, MasterBoardTerrain> A map from the terrain names to the terrains.private intBase amount of points needed for Titan improvement.private intAmount of points needed for Titan Teleport. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidAdd an entire terrain recruiting list to the Recruiting Graph.static booleananonymousRecruitLegal(CreatureType recruit, MasterBoardTerrain terrain, MasterHex hex) private RecruitingSubTreebuildRecruitingSubTree(List<TerrainRecruitLoader.RecruitNumber> rl, boolean regularRecruit) static ICustomRecruitBasegetCustomRecruitBase(String specialString) static List<CreatureType> getPossibleRecruiters(MasterBoardTerrain terrain, MasterHex hex) Give a modifiable list of the possible recruiters in a terrain.static List<CreatureType> getPossibleRecruits(MasterBoardTerrain terrain, MasterHex hex) Give a modifiable list of the possible recruits in a terrain.static RecruitGraphto obtain the recruit graphstatic CreatureType[]Give an array of the starting creatures, those available in the first turn and in a particular kind of Tower.protected static MasterBoardTerraingetTerrainById(String id) static StringgetTerrainRandomName(MasterBoardTerrain masterBoardTerrain) Give the name of the random filename to use to generate this terrain, or null if it's a static Battlelands.Return a collection of all possible terrains.intTo obtain the base amount of points needed for Titan improvement.intTo obtain the amount of points needed for Titan teleport.private voidhandleAcquirable(org.jdom.Element el) private voidhandleAlias(org.jdom.Element el) private voidhandleTerrain(org.jdom.Element el) private static booleanisConcreteCreature(String name) static booleanisStartCreature(CreatureType type) Tell whether given type is in the loaded variant a start creature, i.e.static intnumberOfRecruiterNeeded(CreatureType recruiter, CreatureType recruit, MasterBoardTerrain terrain, MasterHex hex) Give the number of a given recruiters needed to recruit a given Creature.static voidsetCaretaker(Caretaker caretaker) set the Caretaker used by the graph (needed to know what creatures are still available)
-
Field Details
-
LOGGER
-
Keyword_Anything
- See Also:
-
Keyword_AnyNonLord
- See Also:
-
Keyword_Lord
- See Also:
-
Keyword_DemiLord
- See Also:
-
Keyword_Special
- See Also:
-
aquirableRecruitmentsValue
private int aquirableRecruitmentsValue -
titanImprove
private int titanImproveBase amount of points needed for Titan improvement. -
titanTeleport
private int titanTeleportAmount of points needed for Titan Teleport. -
strToRecruits
Map a terrain to a list of recruits. TODO integrate intoMasterBoardTerrain -
strToStarters
Map a terrain to a list of recruits. TODO integrate intoMasterBoardTerrain -
strToBelow
Map a terrain to a boolean, telling if a Creature can recruit in the usual way or not. TODO integrate intoMasterBoardTerrain -
strToRnd
Map a terrain to an optional BattlelandsRandomizer filename. TODO integrate intoMasterBoardTerrain -
terrains
A map from the terrain names to the terrains. -
acquirableList
The list of Acquirable Creature, as acquirableData.- See Also:
-
nameToInstance
support for the custom recruiting functions ; map the class name to an instance of the class. -
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
The AllCreatureType object to use, needed to convert from String (name) to the actual CreatureType.
-
-
Constructor Details
-
TerrainRecruitLoader
-
-
Method Details
-
setCaretaker
set the Caretaker used by the graph (needed to know what creatures are still available) -
isConcreteCreature
-
addToGraph
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
- Throws:
ParseException
-
handleAcquirable
- Throws:
org.jdom.JDOMExceptionParseException
-
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:
getTerrainsin interfaceIVariantInitializer- Returns:
- A collection containing all instances of
MasterBoardTerrain.
-
getTerrainById
-
getCustomRecruitBase
-
getStartingCreatures
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
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
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
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
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:
getTitanImprovementValuein interfaceIVariantInitializer- 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:
getTitanTeleportValuein interfaceIVariantInitializer- Returns:
- The amount of points needed for Titan teleport.
-
getRecruitGraph
to obtain the recruit graph -
getAcquirablesList
- Specified by:
getAcquirablesListin interfaceIVariantInitializer
-