evolution.resources
Class Resource

Direct Known Subclasses:
Energy, SimpleResource

public abstract class Resource

A world resource.


Field Summary
 final static intLINEAR
          A linear transformation function.
 final static intSLOPE
          A saturation transformation function.

Constructor Summary
Resource(double value, double min, double max, int function)
          Create a new world resource.

Method Summary
 protected doubleautoHasOthers(double value)
          Try to convert from other resources.
 protected doubleautoModOthers(double amount)
          Try to transform another resource into this one.
 doublegetMin()
          Get the minimal value of this world resource.
 StringgetName()
          Get the name of this world resource.
 doublegetValue()
          Get the value of this world resource.
 booleanhas(double value)
          See if we have enough of this resource.
 doubleinfluence(double v)
          Influence a value by this resource.
 voidmodValue(double v)
          Modify the value of this worldresource.
 protected voidsetLimits(double min, double max, int function)
          Set the limits of this resource.
 voidsetValue(double value)
          Set the value of this resource.

Field Detail

LINEAR

public final static int LINEAR
A linear transformation function.

SLOPE

public final static int SLOPE
A saturation transformation function.
Constructor Detail

Resource

public Resource(double value, double min, double max, int function)
Create a new world resource.
Parameters:
value - The initial value.
min - The minimum value.
max - The maximum value.
function - The transform input/output function, one of LINEAR, SLOPE.
Method Detail

autoHasOthers

protected double autoHasOthers(double value)
Try to convert from other resources.

autoModOthers

protected double autoModOthers(double amount)
Try to transform another resource into this one.
Parameters:
amount - The amount needed from this resource.
Returns: The amount left.

getMin

public double getMin()
Get the minimal value of this world resource.

getName

public String getName()
Get the name of this world resource.

getValue

public double getValue()
Get the value of this world resource.

has

public boolean has(double value)
See if we have enough of this resource. Will try to use other resources to fullfill the need.

influence

public double influence(double v)
Influence a value by this resource.

modValue

public void modValue(double v)
throws NotEnoughResourcesException
Modify the value of this worldresource. This is done according to the input/output function. If this resource does not have enough it will try to transform some other resource to get enough.
Throws:
NotEnoughResourcesException - If we go below the minimum of this resource and no other resource could fill the need.

setLimits

protected void setLimits(double min, double max, int function)
Set the limits of this resource.

setValue

public void setValue(double value)
throws NotEnoughResourcesException
Set the value of this resource.
Throws:
NotEnoughResourcesException - If you try to set this resource below its minimal level.

a gvijf production