Package horizons :: Package world :: Module resourcehandler :: Class ResourceHandler
[hide private]
[frames] | no frames]

Class ResourceHandler

source code

ResourceTransferHandler --+
                          |
                         ResourceHandler

The ResourceHandler class acts as a basic class for describing objects that handle resources. This means the objects can provide resources for Collectors and have multiple productions. This is a base class, meaning you have to override a lot of functions in subclasses before you can actually use it. You can maybe understand our idea about the ResourceHandler if you look at the uml digramm: development/uml/production_classes.png

A ResourceHandler must not have more than 1 production with the same prod line id.

Instance Methods [hide private]
 
__init__(self, **kwargs) source code
 
__init(self) source code
 
initialize(self) source code
 
save(self, db) source code
 
load(self, db, worldid) source code
 
remove(self) source code
 
get_consumed_resources(self, include_inactive=False)
Returns the needed resources that are used by the productions currently active.
source code
 
get_produced_resources(self)
Returns the resources, that are produced by productions, that are currently active
source code
 
get_stocked_provided_resources(self)
Returns provided resources, where at least 1 ton is available
source code
 
get_currently_consumed_resources(self)
Returns a list of resources, that are currently consumed in a production.
source code
 
get_currently_not_consumed_resources(self)
Needed, but not currently consumed resources.
source code
 
get_needed_resources(self)
Returns list of resources, where free space in the inventory exists.
source code
 
add_incoming_collector(self, collector) source code
 
remove_incoming_collector(self, collector) source code
 
_get_owner_inventory(self)
Returns the inventory of the owner to be able to retrieve special resources such as gold.
source code
 
pickup_resources(self, res, amount, collector)
Try to get amount number of resources of id res_id that are in stock and removes them from the stock.
source code
 
get_available_pickup_amount(self, res, collector)
Returns how much of res a collector may pick up.
source code
 
_load_provided_resources(self)
Returns a iterable obj containing all resources this building provides.
source code
    Inherited from ResourceTransferHandler
 
transfer_to_storageholder(self, amount, res_id, transfer_to, signal_errors=False)
Transfers amount of res_id to transfer_to.
source code
Class Variables [hide private]
  tabs = ProductionOverviewTab, InventoryTab
Method Details [hide private]

get_consumed_resources(self, include_inactive=False)

source code 

Returns the needed resources that are used by the productions currently active. *include_inactive* will also include resources used in a production line that is currently inactive.

get_currently_not_consumed_resources(self)

source code 

Needed, but not currently consumed resources. Opposite of get_currently_consumed_resources.

_get_owner_inventory(self)

source code 

Returns the inventory of the owner to be able to retrieve special resources such as gold. The production system should be as decoupled as possible from actual world objects, so only use when there are no other possibilities

pickup_resources(self, res, amount, collector)

source code 

Try to get amount number of resources of id res_id that are in stock and removes them from the stock. Will return smaller amount if not enough resources are available.

Parameters:
  • res - int resource id
  • amount - int amount that is to be picked up
  • collector - the collector instance, that picks it up
Returns:
int number of resources that can actually be picked up

get_available_pickup_amount(self, res, collector)

source code 

Returns how much of res a collector may pick up. It's the stored amount minus the amount that other collectors are getting

_load_provided_resources(self)

source code 

Returns a iterable obj containing all resources this building provides. This is outsourced from initialization to a method for the possibility of overwriting it. Do not alter the returned list; if you need to do so, then copy it.