public class RecruitGraph
extends java.lang.Object
TerrainRecruitLoader
Modifier and Type | Class and Description |
---|---|
private static class |
RecruitGraph.RecruitEdge
The edge of the Recruit Graph
|
static class |
RecruitGraph.RecruitOption
Models a recruit option for a given creature.
|
private static class |
RecruitGraph.RecruitVertex
The vertex of the Recruit Graph
|
Modifier and Type | Field and Description |
---|---|
private java.util.List<RecruitGraph.RecruitEdge> |
allEdge |
private java.util.List<RecruitGraph.RecruitVertex> |
allVertex |
static int |
BIGNUM
99 creatures can muster one means: can not muster at all
|
private Caretaker |
caretaker |
private java.util.Map<java.lang.String,RecruitGraph.RecruitVertex> |
creatureToVertex |
private static java.util.logging.Logger |
LOGGER |
private IVariantKnower |
variantKnower |
Constructor and Description |
---|
RecruitGraph(IVariantKnower variantKnower) |
Modifier and Type | Method and Description |
---|---|
private RecruitGraph.RecruitEdge |
addEdge(RecruitGraph.RecruitVertex src,
RecruitGraph.RecruitVertex dst,
int number,
MasterBoardTerrain terrain) |
void |
addEdge(java.lang.String src,
java.lang.String dst,
int number,
MasterBoardTerrain terrain)
Add an edge is the graph from a Creature to another, in a given number,
in a given terrain.
|
private RecruitGraph.RecruitVertex |
addVertex(java.lang.String cre) |
void |
clear()
Clear the graph of all Vertex & Edge.
|
java.util.List<MasterBoardTerrain> |
getAllTerrainsWhereThisNumberOfCreatureRecruit(java.lang.String cre,
int number)
Return all the terrains (as String in a List) where the given
number of creature of the given name can recruit.
|
java.util.List<RecruitGraph.RecruitOption> |
getAllThatCanRecruitThisCreature(java.lang.String cre)
A list of what can recruit a creature.
|
java.util.List<RecruitGraph.RecruitOption> |
getAllThatThisCreatureCanRecruit(java.lang.String cre)
A list of what a creature can recruit.
|
CreatureType |
getBestPossibleRecruitEver(java.lang.String cre,
Legion legion)
Return the name of the best possible creature that is reachable
trough the given creature from the given LegionInfo (can be null).
|
(package private) Caretaker |
getCaretaker() |
private java.util.List<RecruitGraph.RecruitEdge> |
getIncomingEdges(java.lang.String cre)
Give the List of RecruitEdge where the given creature is the destination.
|
int |
getMaximumUsefulNumber(java.lang.String cre)
What is the maximum "useful" number of a given creature for
recruitment purpose (excluding "Any" or "AnyNonLord").
|
private java.util.List<RecruitGraph.RecruitEdge> |
getOutgoingEdges(java.lang.String cre)
Give the List of RecruitEdge where the given creature is the source.
|
CreatureType |
getRecruitFromRecruiterTerrainNumber(CreatureType cre,
MasterBoardTerrain t,
int number)
Return the name of the recruit for the given number of the given
recruiter in the given terrain, or null if there's none.
|
private Variant |
getVariant() |
private RecruitGraph.RecruitVertex |
getVertex(java.lang.String cre) |
boolean |
isRecruitDistanceLessThan(java.lang.String lesser,
java.lang.String greater,
int distance)
Determine if a creature given by 'lesser' could potentially
summon the higher valued creature given by 'greater' within N steps.
|
int |
numberOfRecruiterNeeded(java.lang.String recruiter,
java.lang.String recruit,
MasterBoardTerrain terrain,
MasterHex hex) |
void |
setCaretaker(Caretaker caretaker)
Set the Caretaker to use for availability of creatures.
|
private java.util.List<RecruitGraph.RecruitVertex> |
traverse(RecruitGraph.RecruitVertex s,
java.util.Set<RecruitGraph.RecruitVertex> visited,
Legion legion)
Traverse the graph (depth first), assuming that all vertex in visited
have been already visited, and using the given legion for availability
of creatures (along with the caretakerInfo).
|
private java.util.List<RecruitGraph.RecruitVertex> |
traverse(java.lang.String cre,
Legion legion)
Give the List of RecruitVertex still reachable through the given
creature from the given Legion.
|
private static final java.util.logging.Logger LOGGER
private Caretaker caretaker
private final IVariantKnower variantKnower
private final java.util.List<RecruitGraph.RecruitVertex> allVertex
private final java.util.List<RecruitGraph.RecruitEdge> allEdge
private final java.util.Map<java.lang.String,RecruitGraph.RecruitVertex> creatureToVertex
public static final int BIGNUM
public RecruitGraph(IVariantKnower variantKnower)
private RecruitGraph.RecruitVertex addVertex(java.lang.String cre)
private RecruitGraph.RecruitVertex getVertex(java.lang.String cre)
private RecruitGraph.RecruitEdge addEdge(RecruitGraph.RecruitVertex src, RecruitGraph.RecruitVertex dst, int number, MasterBoardTerrain terrain)
private java.util.List<RecruitGraph.RecruitVertex> traverse(RecruitGraph.RecruitVertex s, java.util.Set<RecruitGraph.RecruitVertex> visited, Legion legion)
s
- The base vertexvisited
- Already visited vertexeslegion
- The legion to use for availabilityCaretaker getCaretaker()
private Variant getVariant()
private java.util.List<RecruitGraph.RecruitEdge> getOutgoingEdges(java.lang.String cre)
cre
- Name of the recruiting creatureprivate java.util.List<RecruitGraph.RecruitEdge> getIncomingEdges(java.lang.String cre)
cre
- Name of the recruited creatureprivate java.util.List<RecruitGraph.RecruitVertex> traverse(java.lang.String cre, Legion legion)
cre
- Name of the base creaturepublic void addEdge(java.lang.String src, java.lang.String dst, int number, MasterBoardTerrain terrain)
src
- Name of the recruiting creaturedst
- Name of the recruited creaturenumber
- Number of recruitersterrain
- Terrain where the recruiting occurspublic int numberOfRecruiterNeeded(java.lang.String recruiter, java.lang.String recruit, MasterBoardTerrain terrain, MasterHex hex)
public void setCaretaker(Caretaker caretaker)
caretaker
- The caretaker to use subsequently.public void clear()
public int getMaximumUsefulNumber(java.lang.String cre)
cre
- Name of the creature considered.public java.util.List<MasterBoardTerrain> getAllTerrainsWhereThisNumberOfCreatureRecruit(java.lang.String cre, int number)
cre
- Name of the recruiting creature.number
- Number of creaturepublic java.util.List<RecruitGraph.RecruitOption> getAllThatThisCreatureCanRecruit(java.lang.String cre)
public java.util.List<RecruitGraph.RecruitOption> getAllThatCanRecruitThisCreature(java.lang.String cre)
public CreatureType getRecruitFromRecruiterTerrainNumber(CreatureType cre, MasterBoardTerrain t, int number)
cre
- The recruiting creature.number
- Number of creaturet
- Terrain in which the recruiting may occur.public CreatureType getBestPossibleRecruitEver(java.lang.String cre, Legion legion)
cre
- The recruiting creature.legion
- The recruiting legion or null.public boolean isRecruitDistanceLessThan(java.lang.String lesser, java.lang.String greater, int distance)
lesser
- Name of the recruiting creature.greater
- Name of the recruit we are trying to get todistance
- number of steps to consider