Package horizons :: Package world :: Module storage :: Class GlobalLimitStorage
[hide private]
[frames] | no frames]

Class GlobalLimitStorage

source code

util.changelistener.ChangeListener --+    
                                     |    
                        GenericStorage --+
                                         |
                                        GlobalLimitStorage

Storage with some kind of global limit. This limit has to be interpreted in the subclass, it has no predefined meaning here. This class is used for infrastructure, such as save/load for the limit.

Instance Methods [hide private]
 
__init__(self, limit) source code
 
save(self, db, ownerid) source code
 
load(self, db, ownerid) source code
 
adjust_limit(self, amount)
Adjusts the limit of the storage by amount.
source code
 
get_limit(self, res=None)
Returns the current limit of the storage.
source code
    Inherited from GenericStorage
 
__getitem__(self, res) source code
 
__str__(self) source code
 
alter(self, res, amount)
alter() will return the amount of resources that did not fit into the storage or if altering in a negative way to remove resources, the amount of resources that was not available in the storage.
source code
 
get_dump(self)
Returns a dump of the inventory as dict
source code
 
get_free_space_for(self, res)
Returns how much of res we can still store here (limit - current amount).
source code
 
get_sum_of_stored_resources(self) source code
 
itercontents(self) source code
 
iterslots(self) source code
 
reset(self, res)
Resets a resource slot to zero, removing all its contents.
source code
 
reset_all(self)
Removes every resource from this inventory
source code
    Inherited from util.changelistener.ChangeListener
 
_changed(self)
Calls every listener when an object changed
source code
 
add_change_listener(self, listener, call_listener_now=False, no_duplicates=False) source code
 
add_remove_listener(self, listener, no_duplicates=False)
A listener that listens for removal of the object
source code
 
clear_change_listeners(self)
Removes all change listeners
source code
 
discard_change_listener(self, listener)
Remove listener if it's there
source code
 
discard_remove_listener(self, listener) source code
 
end(self) source code
 
has_change_listener(self, listener) source code
 
has_remove_listener(self, listener) source code
 
remove(self) source code
 
remove_change_listener(self, listener) source code
 
remove_remove_listener(self, listener) source code
Class Variables [hide private]
    Inherited from util.changelistener.ChangeListener
  log = <logging.Logger object>
Method Details [hide private]

__init__(self, limit)
(Constructor)

source code 
Overrides: util.changelistener.ChangeListener.__init__

save(self, db, ownerid)

source code 
Overrides: GenericStorage.save

load(self, db, ownerid)

source code 
Overrides: util.changelistener.ChangeListener.load

adjust_limit(self, amount)

source code 

Adjusts the limit of the storage by amount. If the limit is reduced, every resource that doesn't fit in the storage anymore is dropped!

Parameters:
  • amount - int, difference to current limit (positive or negative)

get_limit(self, res=None)

source code 

Returns the current limit of the storage. Please note that this value can have different meanings depending on the context. See the storage descriptions on what the value does in each case.

Parameters:
  • res - int res that the limit should be returned for.
Returns:
int
Overrides: GenericStorage.get_limit
(inherited documentation)