Package horizons :: Package ai :: Package aiplayer :: Package mission :: Module internationaltrade :: Class InternationalTrade
[hide private]
[frames] | no frames]

Class InternationalTrade

source code

util.changelistener.ChangeListener --+            
                                     |            
          util.worldobject.WorldObject --+        
                                         |        
                                   Mission --+    
                                             |    
                                   ShipMission --+
                                                 |
                                                InternationalTrade

Given a ship, a settlement_manager of our settlement, a settlement of another player, and either a resource to be bought or sold (or both) the ship will load/unload the required resources at our settlement and do the necessary trading at the other player's one.

Instance Methods [hide private]
 
__init__(self, settlement_manager, settlement, ship, bought_resource, sold_resource, success_callback, failure_callback) source code
 
save(self, db) source code
 
_load(self, db, worldid, success_callback, failure_callback) source code
 
start(self) source code
 
_move_to_my_settlement(self) source code
 
_get_max_sellable_amount(self, available_amount) source code
 
_reached_my_settlement(self) source code
 
_move_to_other_settlement(self) source code
 
_get_max_buyable_amount(self) source code
 
_reached_other_settlement(self) source code
 
_return_to_my_settlement(self) source code
 
_returned_to_my_settlement(self) source code
    Inherited from ShipMission
 
__str__(self) source code
 
_move_to_warehouse_area(self, position, success_callback, blocked_callback, failure_msg) source code
 
_unload_all_resources(self, settlement) source code
 
cancel(self) source code
 
report_failure(self, msg) source code
 
report_success(self, msg) source code
    Inherited from Mission
 
end(self) source code
    Inherited from util.worldobject.WorldObject
 
__lt__(self, other) source code
 
remove(self) 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
 
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, worldid, success_callback, failure_callback) source code
    Inherited from ShipMission
 
move_resource(cls, ship, settlement, resource_id, amount)
Move up to amount tons of resource_id from the ship to the settlement.
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]
  missionStates = Enum('created', 'moving_to_my_settlement', 'mo...
    Inherited from Mission
  log = logging.getLogger("ai.aiplayer.mission")
Method Details [hide private]

__init__(self, settlement_manager, settlement, ship, bought_resource, sold_resource, success_callback, failure_callback)
(Constructor)

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

save(self, db)

source code 
Overrides: util.worldobject.WorldObject.save

load(cls, db, worldid, success_callback, failure_callback)
Class Method

source code 
Overrides: util.changelistener.ChangeListener.load

Class Variable Details [hide private]

missionStates

Value:
Enum('created', 'moving_to_my_settlement', 'moving_to_other_settlement\
', 'returning_to_my_settlement')