evolution.lands
Class SquareOfLand


public class SquareOfLand
implements Evolver

Class of squares of land.


Constructor Summary
SquareOfLand(String landType, int x, int y, boolean explored)
          Create a new SquareOfLand of the given type.
SquareOfLand(int x, int y, boolean explored)
          Create a new SquareOfLand of a random type.

Method Summary
 void_place(Human human)
          Place a human on this square, without triggering an event.
 void_place(Construction construction)
          Place a construction on this square, without triggering an event.
 void_setHuman(Human human)
          Set the given human on this square of land.
 booleancontainsLandResource(String resourceName)
          Check wheter this square has the named landresource.
 voidevolve(double val)
          Evolve this square of land.
 ConstructiongetConstruction()
          Return the construction on this square of land.
 doublegetExplorationState()
          Return the state of exploration of this square of land.
 HumangetHuman()
          Return the human on this square of land.
 InfoListgetInfo()
          Return the infolist for this square of land.
 LandResourcegetLandResource(String resName)
          Return the named landresource.
 MapgetLandResources()
          Get all the landresources for this square.
 StringgetLandState()
          Return the state of the land on this square, "Unexplored" if the landtype is yet unknown.
 StringgetLandType()
          Return the land type of this square of land.
 doublegetPriority()
          Returns the priority of this evolver.
 intgetX()
          Return the x-coordinate of this square of land.
 intgetY()
          Return the y-coordinate of this square of land.
 booleanhasEnoughLandResources(Map neededLandResources)
          Checks whether this square has enough landresources to perform a particular action.
 booleanisExplored()
          Is this square explored?
 doublemaxEnergyProduction(Map m1, Map m2)
          Whats the max energy this evolver will produce in this step.
 voidmodResource(String resName, double value)
          Modify the named landresource by value.
 voidplace(Human human)
          Place a human on this square, and trigger a SquareChangedEvt.
 voidplace(Construction construction)
          Place a construction on this square, and trigger a SquareChangedEvt.
 voidprintInfo()
          Just for testing and debugging.
 booleanproducesEnergy()
          Does this evolver produce energy?
 protected voidsetConstruction(Construction construction)
          Set the given construction on this square of land.
 voidsetExplorationState(double s)
          Set the state of exploration of this square of land.
 protected voidsetLandResources(Map r)
          Install a map of landresources.
 voidsetLandType(String landType)
          Set the land type of this square of land.
 protected voidsetX(int x)
          Set the x-coordinate of this square of land.
 protected voidsetY(int y)
          Set the y-coordinate of this square of land.

Constructor Detail

SquareOfLand

public SquareOfLand(String landType, int x, int y, boolean explored)
Create a new SquareOfLand of the given type.

SquareOfLand

public SquareOfLand(int x, int y, boolean explored)
Create a new SquareOfLand of a random type.
Method Detail

_place

public void _place(Human human)
throws IllegalPlacementException
Place a human on this square, without triggering an event.
Parameters:
human - The human to place on this square.
Throws:
IllegalPlacementException - If this spot is already taken or the spot is unexplored.

_place

public void _place(Construction construction)
throws IllegalPlacementException
Place a construction on this square, without triggering an event.
Throws:
IllegalPlacementException - If this spot is already build on.

_setHuman

public void _setHuman(Human human)
Set the given human on this square of land. This is an internal method, made public to be accessible from out of this package.

containsLandResource

public boolean containsLandResource(String resourceName)
Check wheter this square has the named landresource.

evolve

public void evolve(double val)
Evolve this square of land.

getConstruction

public Construction getConstruction()
Return the construction on this square of land.

getExplorationState

public double getExplorationState()
Return the state of exploration of this square of land. Returns a percentage.

getHuman

public Human getHuman()
Return the human on this square of land.

getInfo

public InfoList getInfo()
Return the infolist for this square of land.

getLandResource

public LandResource getLandResource(String resName)
Return the named landresource. Returns null if the landresource is not here.

getLandResources

public Map getLandResources()
Get all the landresources for this square. Map of (String, LandResource).

getLandState

public String getLandState()
Return the state of the land on this square, "Unexplored" if the landtype is yet unknown.

getLandType

public String getLandType()
Return the land type of this square of land.

getPriority

public double getPriority()
Returns the priority of this evolver.

getX

public int getX()
Return the x-coordinate of this square of land.

getY

public int getY()
Return the y-coordinate of this square of land.

hasEnoughLandResources

public boolean hasEnoughLandResources(Map neededLandResources)
Checks whether this square has enough landresources to perform a particular action. The needs are in the map. This function results true if all the needed landresources are still there, but does not look at the needed values.

isExplored

public boolean isExplored()
Is this square explored?

maxEnergyProduction

public double maxEnergyProduction(Map m1, Map m2)
Whats the max energy this evolver will produce in this step.

modResource

public void modResource(String resName, double value)
Modify the named landresource by value. If the landresource did not exist, it is created and initialized at the given value.

place

public void place(Human human)
throws IllegalPlacementException
Place a human on this square, and trigger a SquareChangedEvt.
Parameters:
human - The human to place on this square.
Throws:
IllegalPlacementException - If this spot is already taken or the spot is unexplored.

place

public void place(Construction construction)
throws IllegalPlacementException
Place a construction on this square, and trigger a SquareChangedEvt.
Throws:
IllegalPlacementException - If this spot is already build on.

printInfo

public void printInfo()
Just for testing and debugging.

producesEnergy

public boolean producesEnergy()
Does this evolver produce energy?

setConstruction

protected void setConstruction(Construction construction)
Set the given construction on this square of land.

setExplorationState

public void setExplorationState(double s)
Set the state of exploration of this square of land.
Parameters:
s - A percentage.

setLandResources

protected void setLandResources(Map r)
Install a map of landresources. Map of (String, LandResource).

setLandType

public void setLandType(String landType)
Set the land type of this square of land. precondition: the landtype must be valid.

setX

protected void setX(int x)
Set the x-coordinate of this square of land.

setY

protected void setY(int y)
Set the y-coordinate of this square of land.

Association Links

to Class java.lang.String

The landtype of this square.

to Class evolution.Human

The human which is living on this square.

to Class evolution.constructions.Construction

The construction which is placed on this square.

to Class java.util.Map

A hash of resource names and a reference to the land resource for this square.

a gvijf production