Package net.sf.colossus.xmlparser
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 class
Helper class, associating a Creature and a number.static class
private class
Used internally to associate a creature name and the number of creatures needed to recruit it.private class
Used 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 int
private final AllCreatureType
The AllCreatureType object to use, needed to convert from String (name) to the actual CreatureType.private static RecruitGraph
Representation of the Recruiting Graph (for use) (sometimes called Recruiting Tree).static final String
static final String
static final String
static final String
static final String
private static final Logger
private 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 int
Base amount of points needed for Titan improvement.private int
Amount of points needed for Titan Teleport. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static void
Add an entire terrain recruiting list to the Recruiting Graph.static boolean
anonymousRecruitLegal
(CreatureType recruit, MasterBoardTerrain terrain, MasterHex hex) private RecruitingSubTree
buildRecruitingSubTree
(List<TerrainRecruitLoader.RecruitNumber> rl, boolean regularRecruit) static ICustomRecruitBase
getCustomRecruitBase
(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 RecruitGraph
to 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 MasterBoardTerrain
getTerrainById
(String id) 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.Return a collection of all possible terrains.int
To obtain the base amount of points needed for Titan improvement.int
To obtain the amount of points needed for Titan teleport.private void
handleAcquirable
(org.jdom.Element el) private void
handleAlias
(org.jdom.Element el) private void
handleTerrain
(org.jdom.Element el) private static boolean
isConcreteCreature
(String name) static boolean
isStartCreature
(CreatureType type) Tell whether given type is in the loaded variant a start creature, i.e.static int
numberOfRecruiterNeeded
(CreatureType recruiter, CreatureType recruit, MasterBoardTerrain terrain, MasterHex hex) Give the number of a given recruiters needed to recruit a given Creature.static void
setCaretaker
(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.JDOMException
ParseException
-
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 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:
getTitanImprovementValue
in 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:
getTitanTeleportValue
in interfaceIVariantInitializer
- Returns:
- The amount of points needed for Titan teleport.
-
getRecruitGraph
to obtain the recruit graph -
getAcquirablesList
- Specified by:
getAcquirablesList
in interfaceIVariantInitializer
-