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

Class SizedSpecializedStorage

source code

util.changelistener.ChangeListener --+        
                                     |        
                        GenericStorage --+    
                                         |    
                        SpecializedStorage --+
                                             |
                                            SizedSpecializedStorage

Just like SpecializedStorage, but each res has an own limit. Can take a dict {res: size, res2: size2, ...} to init slots

Instance Methods [hide private]
 
__init__(self, slot_sizes=None) 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_limit(self, res)
Returns the current limit of the storage.
source code
 
add_resource_slot(self, res, size)
Add a resource slot for res that can hold at most *size* units.
source code
 
save(self, db, ownerid) source code
 
load(self, db, ownerid) source code
    Inherited from SpecializedStorage
 
has_resource_slot(self, res) 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, slot_sizes=None)
(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: GenericStorage.alter
(inherited documentation)

get_limit(self, res)

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)

add_resource_slot(self, res, size)

source code 

Add a resource slot for res that can hold at most *size* units. If the slot already exists, just update its size to *size*. NOTE: THIS IS NOT SAVE/LOADED HERE. It must be restored manually.

Overrides: SpecializedStorage.add_resource_slot

save(self, db, ownerid)

source code 
Overrides: GenericStorage.save

load(self, db, ownerid)

source code 
Overrides: util.changelistener.ChangeListener.load