evolution.constructions
Class ConstructionKnowledgeCatalog

evolution.KnowledgeCatalog
  |
  +--evolution.constructions.ConstructionKnowledgeCatalog

public class ConstructionKnowledgeCatalog
extends KnowledgeCatalog

KnowledgeCatalog for constructions.


Field Summary
 protected static ConstructionKnowledgeCataloginstance
          Instance of the singleton.

Constructor Summary
 protected ConstructionKnowledgeCatalog(String fileName)
          Create a new KnowledgeCatalog from the given file.

Method Summary
 voidbuild(String constructionName, String shape, List humans, SquareOfLand sq)
          Build a construction.
 booleancanBeBuildOn(String constructionName, String landType)
          Can this construction be build on the specified landtype?
 protected booleancanStandOn(String construction, SquareOfLand sq, List humans)
          Checks if the construction can stand on the given square of land.
 protected booleancanStandOn(String construction, List squares, List humans)
          Checks if the construction can stand on the given squares of land.
 booleancanStandOnLandType(String construction, String landType)
          Checks if the construction can stand on the given landtype.
 booleanconstructionExists(String constructionName)
          Does this construction exist in the current game?
 intcountSquares(String shape)
          Return the squares used for this shape.
 ListgetConstructionShapes(String constructionName)
          The shapes the given construction can be build in.
 InfoListgetConstructionsInfo()
          Return infolist for constructions.
 doublegetConstructionSpeed(String constructionName)
          Get the speed at which this construction will be build.
 ListgetConstructionTypes()
          Return the different types of constructions.
 static ConstructionKnowledgeCataloggetInst()
          Return the instance of this singleton.
 doublegetPriority(Construction construction)
          Get the priority of this construction.
 protected ListgetSquares(SquareOfLand sq, String shape)
          Get the squares marked in the shape string with the given square as upper left corner.
 static voidinitialize(String fileName)
          Initialize this singleton from the given file.
 protected voidinstantiate(String constructionName, List squares)
          Instantiate the given construction on the given squares.
 booleanisEnergyResource(String resourceName)
          Is the given resource in the produce energy chain?
 protected voidparseConstructions(String cstring)
          Parse the constructions-string.
 MapproducesLandResourcesConstructing(String construction)
          The landresources produced when constructing this construction.
 MapproducesResources(String constructionName)
          A map with as keys the resource and as value the amount the construction produces.
 MapproducesResourcesConstructing(String construction)
          The resources produced when constructing this construction.
 ListproducesResourcesNames(String constructionName)
          A list with the names of the resources produced by a given construction.
 MapusesLandResources(String constructionName)
          A map with as keys the landresource and as value the amount the construction uses.
 MapusesLandResourcesConstructing(String construction)
          The landresources used for constructing this construction.
 MapusesResources(String constructionName)
          A map with as keys the resource and as value the amount the construction uses.
 MapusesResourcesConstructing(String construction)
          The resources used for constructing this construction.
 ListusesResourcesNames(String constructionName)
          A list with the names of the resources used by a given construction.

Methods inherited from class evolution.KnowledgeCatalog
dlClassForName, extractArgument, extractName, extractValue, getFileName, getProperty, getProperty, getResourcePath, isInitialized, makeStringDoubleMap, setResourcePath, split, stripPathFromClassName, stripPathFromClassName, stripPathFromClassName

Field Detail

instance

protected static ConstructionKnowledgeCatalog instance
Instance of the singleton.
Constructor Detail

ConstructionKnowledgeCatalog

protected ConstructionKnowledgeCatalog(String fileName)
throws java.io.IOException,
java.io.FileNotFoundException
Create a new KnowledgeCatalog from the given file.
Method Detail

build

public void build(String constructionName, String shape, List humans, SquareOfLand sq)
throws evolution.lands.IllegalPlacementException
Build a construction.
Parameters:
constructionName - The name of the construction type to build.
shape - The shape of the construction to build, e.g. "1x1:1", "2x2:1101", "3x2:111111101", ...
humans - The humans who will build the construction.
sq - The square of land in the top left of the shape, to position the construction.
Throws:
IllegalPlacementException - If it is impossible to build the construction on the indicated place or you have assigned more humans to the job than there are build squares for this construction.

canBeBuildOn

public boolean canBeBuildOn(String constructionName, String landType)
Can this construction be build on the specified landtype?

canStandOn

protected boolean canStandOn(String construction, SquareOfLand sq, List humans)
Checks if the construction can stand on the given square of land.
Parameters:
construction - The name of the construction.
sq - The square of land to test.
humans - A List of Humans's who will construct the construction.
Returns: true if the construction can stand on this square, false otherwise. If there is a human on the square that is not in the given list, then the construction can not stand on this square.

canStandOn

protected boolean canStandOn(String construction, List squares, List humans)
Checks if the construction can stand on the given squares of land.
Parameters:
construction - The name of the construction.
squares - A List of SquareOfLand's were the construction will be build.
humans - A List of Humans's who will construct the construction.
Returns: true if the construction can stand on the squares, false otherwise. If there is a human on the squares that is not in the given list, then the construction can not stand on these squares.

canStandOnLandType

public boolean canStandOnLandType(String construction, String landType)
Checks if the construction can stand on the given landtype.

constructionExists

public boolean constructionExists(String constructionName)
Does this construction exist in the current game?

countSquares

public int countSquares(String shape)
Return the squares used for this shape.

getConstructionShapes

public List getConstructionShapes(String constructionName)
The shapes the given construction can be build in. Returns a List of Strings according to the shape spec. e.g. {"1x1:1", "2x2:1101", "3x2:111111101"}

getConstructionsInfo

public InfoList getConstructionsInfo()
Return infolist for constructions.

getConstructionSpeed

public double getConstructionSpeed(String constructionName)
Get the speed at which this construction will be build.

getConstructionTypes

public List getConstructionTypes()
Return the different types of constructions.

getInst

public static ConstructionKnowledgeCatalog getInst()
Return the instance of this singleton.

getPriority

public double getPriority(Construction construction)
Get the priority of this construction.

getSquares

protected List getSquares(SquareOfLand sq, String shape)
Get the squares marked in the shape string with the given square as upper left corner. Returns a list of SquareOfLands.
Throws:
IndexOutOfBoundsException - If the given shapes extends out of the game board.
IllegalArgumentException - If the shape string is malformed.

initialize

public static void initialize(String fileName)
throws java.io.FileNotFoundException,
java.io.IOException
Initialize this singleton from the given file.

instantiate

protected void instantiate(String constructionName, List squares)
Instantiate the given construction on the given squares.

isEnergyResource

public boolean isEnergyResource(String resourceName)
Is the given resource in the produce energy chain?

parseConstructions

protected void parseConstructions(String cstring)
Parse the constructions-string.

producesLandResourcesConstructing

public Map producesLandResourcesConstructing(String construction)
The landresources produced when constructing this construction.
Returns: A Map of (String, Double).

producesResources

public Map producesResources(String constructionName)
A map with as keys the resource and as value the amount the construction produces.

producesResourcesConstructing

public Map producesResourcesConstructing(String construction)
The resources produced when constructing this construction.
Returns: A Map of (String, Double).

producesResourcesNames

public List producesResourcesNames(String constructionName)
A list with the names of the resources produced by a given construction.

usesLandResources

public Map usesLandResources(String constructionName)
A map with as keys the landresource and as value the amount the construction uses.

usesLandResourcesConstructing

public Map usesLandResourcesConstructing(String construction)
The landresources used for constructing this construction.
Returns: A Map of (String, Double).

usesResources

public Map usesResources(String constructionName)
A map with as keys the resource and as value the amount the construction uses.

usesResourcesConstructing

public Map usesResourcesConstructing(String construction)
The resources used for constructing this construction.
Returns: A Map of (String, Double).

usesResourcesNames

public List usesResourcesNames(String constructionName)
A list with the names of the resources used by a given construction.

Association Links

to Class java.util.List

The different types of constructions.

to Class evolution.constructions.ConstructionKnowledgeCatalog

Instance of the singleton.

a gvijf production