Package horizons :: Package ai :: Module pirate :: Class Pirate
[hide private]
[frames] | no frames]

Class Pirate

source code

component.componentholder.ComponentHolder --+        
   util.changelistener.ChangeListener --+   |        
                                        |   |        
             util.worldobject.WorldObject --+        
                          world.player.Player --+    
                                generic.GenericAI --+

A pirate ship moving randomly around. If another ship comes into the reach of it, it will be followed for a short time.

Instance Methods [hide private]
__init__(self, session, id, name, color, **kwargs) source code
__init(self) source code
tick(self) source code
tick_long(self) source code
get_random_profile(self, token) source code
create_ship_at_random_position(self) source code
maintain_ship_count(self) source code
save(self, db) source code
_load(self, db, worldid)
This function makes it possible to load playerdata into an already allocated Player instance, which is used e.g.
source code
finish_loading(self, db) source code
remove_unit(self, unit)
Called when a ship which is owned by the pirate is removed or killed.
source code
end(self) source code
    Inherited from generic.GenericAI
send_ship(self, ship) source code
send_ship_random(self, ship)
Sends a ship to a random position on the map.
source code
ship_idle(self, ship)
Called if a ship is idle.
source code
    Inherited from world.player.Player
This takes a while to calculate, so only do it every 2 seconds at most
source code
get_latest_stats(self) source code
Returns a namedtuple containing player-wide statistics
source code
initialize(self, inventory)
Has to be called every time a componentholder is created.
source code
is_local_player(self) source code
notify_settler_reached_level(self, message)
Settler calls this to notify the player.
source code
Calculate settlements dynamically to save having a redundant list here
source code
    Inherited from component.componentholder.ComponentHolder
add_component(self, component)
Adds new component to holder and sets the instance attribute on the component
source code
get_component(self, component) source code
get_component_by_name(self, name) source code
has_component(self, component_class)
Check if holder has component with component name
source code
remove(self) source code
remove_component(self, component_class)
Removes component from holder.
source code
    Inherited from util.worldobject.WorldObject
__lt__(self, other) 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
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]
    Inherited from world.player.Player
load(cls, session, db, worldid) source code
    Inherited from component.componentholder.ComponentHolder
get_component_template(cls, component)
Returns the component template data given a component NAME
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
Static Methods [hide private]
get_nearest_player_ship(base_ship) source code
Class Variables [hide private]
  shipStates = Enum.get_extended(GenericAI.shipStates, 'on_a_mis...
  log = logging.getLogger("ai.pirate")
  regular_player = False
  caught_ship_radius = 5
  home_radius = 2
  ship_count = 1
  tick_interval = 32
  tick_long_interval = 128
    Inherited from world.player.Player
  component_templates = {'StorageComponent': {'PositiveStorage':...
    Inherited from component.componentholder.ComponentHolder
  class_mapping = {'AmbientSoundComponent': AmbientSoundComponen...
Method Details [hide private]

__init__(self, session, id, name, color, **kwargs)

source code 
  • session - Session instance
  • worldid - player's worldid
  • name - user-chosen name
  • color - color of player (as Color)
  • clientid - id of client
  • inventory - {res: value} that are put in the players inventory
Overrides: util.changelistener.ChangeListener.__init__

save(self, db)

source code 

_load(self, db, worldid)

source code 

This function makes it possible to load playerdata into an already allocated Player instance, which is used e.g. in Trader.load

Overrides: world.player.Player._load
(inherited documentation)


source code 
Overrides: util.changelistener.ChangeListener.end

Class Variable Details [hide private]


Enum.get_extended(GenericAI.shipStates, 'on_a_mission', 'chasing_ship'\
, 'going_home')