| resource_manager {villager} | R Documentation |
Resource Manager
Description
This object manages all of the resources in a village.
Methods
initialize()Creates a new manager
get_resources()Gets all of the resources that the manager has
get_resource()Retrieves a resource from the manager
add_resource()Adds a resource to the manager
remove_resource()Removes a resource from the manager
get_resource_index()Retrieves the index of the resource
get_states()Returns a list of states
load()Loads a csv file of resources and adds them to the manager.
Public fields
resourcesA list of resource objects
resource_classThe class used to represent resources Creates a new , empty, resource manager for a village.
Methods
Public methods
Method new()
Get a new instance of a resource_manager
Usage
resource_manager$new(resource_class = villager::resource)
Arguments
resource_classThe class being used to describe the resources being managed Gets all of the managed resources
Method get_resources()
Usage
resource_manager$get_resources()
Returns
A list of resources Gets a resource given a resource name
Method get_resource()
Usage
resource_manager$get_resource(name)
Arguments
nameThe name of the requested resource
Returns
A resource object Adds a resource to the manager.
Method add_resource()
Usage
resource_manager$add_resource(...)
Arguments
...The resources to add
Returns
None Removes a resource from the manager
Method remove_resource()
Usage
resource_manager$remove_resource(name)
Arguments
nameThe name of the resource being removed
Returns
None Returns the index of a resource in the internal resource list
Method get_resource_index()
Usage
resource_manager$get_resource_index(name)
Arguments
nameThe name of the resource being located
Returns
The index in the list, or R's default return value Returns a data.frame where each row is a resource.
Method get_states()
Usage
resource_manager$get_states()
Details
Subclasses should not have to override this method because it takes all member variables into account
Returns
A single data.frame Loads a csv file of resources into the manager
Method load()
Usage
resource_manager$load(file_name)
Arguments
file_nameThe path to the csv file
Returns
None
Method clone()
The objects of this class are cloneable with this method.
Usage
resource_manager$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.