com.b3dgs.lionengine.game.strategy
Class Ressource

java.lang.Object
  extended by com.b3dgs.lionengine.game.strategy.Ressource

public class Ressource
extends java.lang.Object

Represent a ressource, such as gold, wood... It is possible to increase the ressource amount, or spend it. It is also possible to check if there are enough ressource before spending it.


Constructor Summary
Ressource()
          Create a new blank ressource.
Ressource(int amount)
          Create a new ressource.
 
Method Summary
 void add(int amount)
          Increase ressource stock with a specified amount.
 boolean canSpend(int amount)
          Check if the specified amount of ressource can be spent.
 int get()
          Get current amount of ressource.
 void spend(int amount)
          Decrease ressource stock with a specified amount.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Ressource

public Ressource()
Create a new blank ressource.


Ressource

public Ressource(int amount)
Create a new ressource.

Parameters:
amount - starting amount.
Method Detail

add

public void add(int amount)
Increase ressource stock with a specified amount.

Parameters:
amount - amount of new ressources.

spend

public void spend(int amount)
Decrease ressource stock with a specified amount.

Parameters:
amount - amout of ressource to spend.

canSpend

public boolean canSpend(int amount)
Check if the specified amount of ressource can be spent.

Parameters:
amount - amount to check.
Returns:
true if current stock - amount > 0.

get

public int get()
Get current amount of ressource.

Returns:
current stock.