Package horizons :: Package ai :: Package aiplayer :: Module trademanager :: Class SingleResourceTradeManager
[hide private]
[frames] | no frames]

Class SingleResourceTradeManager

source code

util.changelistener.ChangeListener --+    
          util.worldobject.WorldObject --+

An object of this class keeps track of both parties of the resource import/export deal for one resource.

Instance Methods [hide private]
__init__(self, settlement_manager, resource_id) source code
__init(self, settlement_manager, resource_id) source code
save(self, db, trade_manager_id) source code
_load(self, db, settlement_manager, worldid) source code
Return the total spare production including the import rate of this settlement (also reserves that amount).
source code
Reserve the total remaining production in every other settlement and adjust quotas if necessary.
source code
Release the unnecessarily reserved production capacity and decide which settlements will be providing the resources.
source code
get_quota(self, quota_holder)
Return the current quota in units per tick.
source code
Return the total amount of resource imported per tick.
source code
request_quota_change(self, quota_holder, amount)
Request that the quota of quota_holder be changed to the given amount.
source code
__str__(self) source code
    Inherited from util.worldobject.WorldObject
__lt__(self, other) source code
remove(self) source code
    Inherited from util.changelistener.ChangeListener
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
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_change_listener(self, listener) source code
remove_remove_listener(self, listener) source code
Class Methods [hide private]
load(cls, db, settlement_manager, worldid) source code
    Inherited from util.worldobject.WorldObject
get_object_by_id(cls, id)
Returns the worldobject with id id Throws WorldObjectNotFound with the worldid as arg.
source code
get_objs(cls) source code
reset(cls) source code
Class Variables [hide private]
    Inherited from util.worldobject.WorldObject
  log = logging.getLogger("util.worldobject")
Method Details [hide private]

__init__(self, settlement_manager, resource_id)

source code 
  • worldid - worldid to assign. Use None to get an autogenerated one.
Overrides: util.changelistener.ChangeListener.__init__

save(self, db, trade_manager_id)

source code 

load(cls, db, settlement_manager, worldid)
Class Method

source code 
Overrides: util.changelistener.ChangeListener.load