evolution.resources
Class ResourceKnowledgeCatalog

evolution.KnowledgeCatalog
  |
  +--evolution.resources.ResourceKnowledgeCatalog

public class ResourceKnowledgeCatalog
extends KnowledgeCatalog

The Resource KnowledgeCatalog.

Stereotype singleton

Field Summary
 protected static ResourceKnowledgeCataloginstance
          Instance of the singleton.

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

Method Summary
 voidaddResources(Map resMap, double percentage)
          Add a percentage of a maximum to the world resources.
 static ResourceKnowledgeCataloggetInst()
          Return the instance of this singleton.
 ResourcegetResource(String resName)
          Return the resource with the given name.
 MapgetResourceInstances()
          An map of all resources which are connected to the current world.
 InfoListgetResourcesInfo()
          Generate an info list of all available resources.
 ListgetResourcesNames()
          The names of the worldresources.
 MapgetResourcesStringDoubleMap()
          Get the current world resources as a (String, Double) Map.
 doubleinfluencedByResources(String actionName, double v)
          Influence a value by all resources that influence the given action.
 static voidinitialize(String fileName)
          Initialize this singleton from the given file.
 booleanisTemporary(String resourceName)
          Is the named resource a temporary one?
 voidmodResource(String resourceName, double v)
          Increase or decrease the named resource with the given value.
 voidmodResource(String resourceName, String actionName, double v)
          Increase or decrease the named resource with the given value.
 protected voidparseResources(String resourcesString)
          Parse the resources string.
 voidresetTemporaries()
          Reset all temporary resources to their minimum.
 voidsetResources(Map resMap)
          Set the worldresources.
 voidsetTemporaries(Map max, double percentage)
          Set all the temporary resources.
 ListtransformsFrom(String resourceName)
          See from which resources we can fullfill the need for this one.

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 ResourceKnowledgeCatalog instance
Instance of the singleton.
Constructor Detail

ResourceKnowledgeCatalog

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

addResources

public void addResources(Map resMap, double percentage)
Add a percentage of a maximum to the world resources.
Parameters:
resMap - A Map of (String, Double).
percentage - The percentage to add.

getInst

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

getResource

public Resource getResource(String resName)
Return the resource with the given name.

getResourceInstances

public Map getResourceInstances()
An map of all resources which are connected to the current world.
Returns: A Map of (String, Resource).

getResourcesInfo

public InfoList getResourcesInfo()
Generate an info list of all available resources.

getResourcesNames

public List getResourcesNames()
The names of the worldresources. A List of Strings.

getResourcesStringDoubleMap

public Map getResourcesStringDoubleMap()
Get the current world resources as a (String, Double) Map.

influencedByResources

public double influencedByResources(String actionName, double v)
Influence a value by all resources that influence the given action.

initialize

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

isTemporary

public boolean isTemporary(String resourceName)
Is the named resource a temporary one?

modResource

public void modResource(String resourceName, double v)
throws NotEnoughResourcesException
Increase or decrease the named resource with the given value.

modResource

public void modResource(String resourceName, String actionName, double v)
throws NotEnoughResourcesException
Increase or decrease the named resource with the given value. The amount of increase or decrease will also depend on the resources that influence the named action.

parseResources

protected void parseResources(String resourcesString)
Parse the resources string.

resetTemporaries

public void resetTemporaries()
Reset all temporary resources to their minimum.

setResources

public void setResources(Map resMap)
Set the worldresources.
Parameters:
resMap - A Map of (String, Double).

setTemporaries

public void setTemporaries(Map max, double percentage)
Set all the temporary resources.
Parameters:
max - A (String, Double) Map, where the String is the name of the resource and the Double is the maximum producable.
percentage - The percentage we have to set of the maximum for each temporary resource.

transformsFrom

public List transformsFrom(String resourceName)
See from which resources we can fullfill the need for this one. Returns a List of Object[]{Resource, Double}.

Association Links

to Class java.util.List

The names of the worldresources. This is kept separate to keep the order of the worldresources. A List of Strings.

to Class java.util.Map

The worldresources. A Map of (String, Resource).

to Class evolution.resources.ResourceKnowledgeCatalog

Instance of the singleton.

a gvijf production