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

Class PositiveSizedSlotStorage

source code

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

A storage consisting of a slot for each resource, all slots have the same size 'limit' Used by the warehouse for example. So with a limit of 30 you could have a max of 30 from each resource.

Instance Methods [hide private]
 
__init__(self, limit=0) 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
    Inherited from GlobalLimitStorage
 
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
 
load(self, db, ownerid) source code
 
save(self, db, ownerid) source code
    Inherited from GenericStorage
 
__getitem__(self, res) source code
 
__str__(self) 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=0)
(Constructor)

source code 
Overrides: util.changelistener.ChangeListener.__init__

alter(self, res, amount)

source code 

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. The totalstorage always returns 0 as there are not limits as to what can be in the storage.

Parameters:
  • res - int res id that is to be altered
  • amount - int amount that is to be changed. Can be negative to remove resources.
Returns:
int - amount that did not fit or was not available, depending on context.
Overrides: PositiveStorage.alter