net.sf.colossus.variant
Class Variant

java.lang.Object
  extended by net.sf.colossus.variant.Variant

public class Variant
extends java.lang.Object

Hub for all variant-specific information. This class is meant to give access to all the information about a Colossus game in the static sense: the master board layout, the battle board layouts, available creatures, rules, etc. The information about a game in progress is in the Game class. Instances of this class are immutable. TODO add access to the markers by having a class for them TODO same thing for the colors/markersets


Nested Class Summary
static class Variant.AcquirableData
          Used internally to record the Acquirable name, points needed for recruiting, and the list of terrains in which the Acquirable dwells.
 
Field Summary
private  java.util.List<Variant.AcquirableData> acquirableList
           
private  java.util.Map<java.lang.String,CreatureType> creatureTypeByNameCache
          A map for fast lookup of creatures by their name.
private  AllCreatureType creatureTypes
           
private static java.util.logging.Logger LOGGER
           
private  MasterBoard masterBoard
           
private  javax.swing.text.Document readme
           
private  java.util.List<CreatureType> summonableCreatureTypes
           
private  java.util.Collection<MasterBoardTerrain> terrains
           
private  int titanImprove
           
private  int titanTeleport
           
private  java.lang.String variantName
           
 
Constructor Summary
Variant(IVariantInitializer variantInitializer, AllCreatureType creatureTypes, MasterBoard masterBoard, javax.swing.text.Document readme, java.lang.String name)
           
 
Method Summary
 java.util.List<java.lang.String> getAcquirableList()
          To obtain all the Creature that can be Acquired.
 int getAcquirableRecruitmentsValue()
          To obtain the base amount of points needed for Acquirement.
 CreatureType getCreatureByName(java.lang.String name)
          Look up a creature type by its name.
 java.util.SortedSet<CreatureType> getCreatureTypes()
           
 java.util.List<CreatureType> getCreatureTypesAsList()
           
 MasterBoard getMasterBoard()
           
 int getMaxBattleTurns()
           
 java.lang.String getName()
           
 java.lang.String getPrimaryAcquirable()
          To obtain the first Acquirable (aka 'primary') Creature name.
 javax.swing.text.Document getReadme()
           
 java.util.List<java.lang.String> getRecruitableAcquirableList(MasterBoardTerrain t, int value)
          To obtain all the Creature that can be acquired at the given amount of points in the given terrain.
 int[] getReinforcementTurns()
           
 java.util.List<CreatureType> getSummonableCreatureTypes()
           
 MasterBoardTerrain getTerrainById(java.lang.String id)
          Retrieves the terrain with the given identifier.
 java.util.Collection<MasterBoardTerrain> getTerrains()
           
 int getTitanImprovementValue()
          To obtain the base amount of points needed for Titan improvement.
 int getTitanTeleportValue()
          To obtain the amount of points needed for Titan teleport.
private  void initCreatureNameCache()
           
 boolean isAcquirable(CreatureType c)
          Check if the Creature in parameter is an Acquirable creature or not.
private  boolean isAcquirable(java.lang.String name)
          Check if the Creature whose name is in parameter is an Acquirable creature or not.
 boolean isCreature(java.lang.String name)
          Checks if a creature with the given name exists.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

private static final java.util.logging.Logger LOGGER

creatureTypes

private final AllCreatureType creatureTypes

summonableCreatureTypes

private final java.util.List<CreatureType> summonableCreatureTypes

terrains

private final java.util.Collection<MasterBoardTerrain> terrains

acquirableList

private final java.util.List<Variant.AcquirableData> acquirableList

masterBoard

private final MasterBoard masterBoard

readme

private final javax.swing.text.Document readme

variantName

private final java.lang.String variantName

titanImprove

private final int titanImprove

titanTeleport

private final int titanTeleport

creatureTypeByNameCache

private final java.util.Map<java.lang.String,CreatureType> creatureTypeByNameCache
A map for fast lookup of creatures by their name. This is a cache to find creatures by their case-insensitive name quickly.

Constructor Detail

Variant

public Variant(IVariantInitializer variantInitializer,
               AllCreatureType creatureTypes,
               MasterBoard masterBoard,
               javax.swing.text.Document readme,
               java.lang.String name)
Method Detail

getCreatureTypesAsList

public java.util.List<CreatureType> getCreatureTypesAsList()

getCreatureTypes

public java.util.SortedSet<CreatureType> getCreatureTypes()

getTerrains

public java.util.Collection<MasterBoardTerrain> getTerrains()

getTerrainById

public MasterBoardTerrain getTerrainById(java.lang.String id)
Retrieves the terrain with the given identifier.

Parameters:
id - The identifier for the terrain. Must be a valid for this variant.
Returns:
The matching terrain.
Throws:
java.lang.IllegalArgumentException - iff the identifier does not refer to an existing terrain in this variant.

getMasterBoard

public MasterBoard getMasterBoard()

getReadme

public javax.swing.text.Document getReadme()

getName

public java.lang.String getName()

getCreatureByName

public CreatureType getCreatureByName(java.lang.String name)
Look up a creature type by its name. The lookup is case-insensitive at the moment (TODO: check if that makes sense at all). TODO in the long run noone should really need this since the names shouldn't be passed around by themselves ... except for resolving name that came over network... (Clemens)

Parameters:
name - Name of a creature type. Not null.
Returns:
CreatureType with the given name, null no such creature type.

initCreatureNameCache

private void initCreatureNameCache()

isCreature

public boolean isCreature(java.lang.String name)
Checks if a creature with the given name exists.

Parameters:
name - (case insensitive) name of a creature, must not be null.
Returns:
true if this names represents a creature

getSummonableCreatureTypes

public java.util.List<CreatureType> getSummonableCreatureTypes()

getAcquirableList

public java.util.List<java.lang.String> getAcquirableList()
To obtain all the Creature that can be Acquired.

Returns:
The list of name (as String) that can be Acquired

getAcquirableRecruitmentsValue

public int getAcquirableRecruitmentsValue()
To obtain the base amount of points needed for Acquirement. All Acquirements must occur at integer multiple of this.

Returns:
The base amount of points needed for Acquirement.

getPrimaryAcquirable

public java.lang.String getPrimaryAcquirable()
To obtain the first Acquirable (aka 'primary') Creature name. This one is the starting Lord with the Titan.

Returns:
The name of the primary Acquirable Creature.

getRecruitableAcquirableList

public java.util.List<java.lang.String> getRecruitableAcquirableList(MasterBoardTerrain t,
                                                                     int value)
To obtain all the Creature that can be acquired at the given amount of points in the given terrain. TODO should return List

Parameters:
t - The Terrain in which the recruitment occurs.
value - The number of points at which the recruitment occurs. Valid values are constrained.
Returns:
The list of name (as String) that can be acquired in this terrain, for this amount of points.
See Also:
getAcquirableRecruitmentsValue()

isAcquirable

private boolean isAcquirable(java.lang.String name)
Check if the Creature whose name is in parameter is an Acquirable creature or not.

Parameters:
name - The name of the Creature inquired.
Returns:
If the creature is Acquirable.

isAcquirable

public boolean isAcquirable(CreatureType c)
Check if the Creature in parameter is an Acquirable creature or not.

Parameters:
c - The Creature inquired.
Returns:
If the creature is Acquirable.

getTitanImprovementValue

public int getTitanImprovementValue()
To obtain the base amount of points needed for Titan improvement.

Returns:
The base amount of points needed for Titan improvement.

getTitanTeleportValue

public int getTitanTeleportValue()
To obtain the amount of points needed for Titan teleport.

Returns:
The amount of points needed for Titan teleport.

getReinforcementTurns

public int[] getReinforcementTurns()

getMaxBattleTurns

public int getMaxBattleTurns()