Package horizons :: Package world :: Package building :: Module building :: Class BasicBuilding
[hide private]
[frames] | no frames]

Class BasicBuilding

source code

 component.componentholder.ComponentHolder --+
                                             |
util.changelistener.ChangeListener --+       |
                                     |       |
          util.worldobject.WorldObject --+   |
                                         |   |
             concreteobject.ConcreteObject --+
                                             |
                                            BasicBuilding

Class that represents a building. The building class is mainly a super class for other buildings.

Instance Methods [hide private]
 
__init__(self, x, y, rotation, owner, island, level=None, **kwargs) source code
 
__pre_init(self, owner, rotation, origin, level=None)
Here we face the awkward situation of requiring a fourth init function.
source code
 
__init(self, remaining_ticks_of_month=None) source code
 
toggle_costs(self) source code
 
running_costs_active(self)
Returns whether the building currently pays the running costs for status 'active'
source code
 
get_payout(self)
Gets the payout from the settlement in form of its running costs
source code
 
remove(self)
Removes the building
source code
 
save(self, db) source code
 
load(self, db, worldid) source code
 
load_location(self, db, worldid)
Does not alter self, just gets island and settlement from a savegame.
source code
 
get_buildings_in_range(self) source code
 
update_action_set_level(self, level=0)
Updates this buildings action_set to a random actionset from the specified level (if an action set exists in that level).
source code
 
level_upgrade(self, lvl)
Upgrades building to another tier
source code
 
init(self)
init the building, called after the constructor is run and the building is positioned (the settlement variable is assigned etc)
source code
 
start(self)
This function is called when the building is built, to start production for example.
source code
 
__str__(self) 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
 
initialize(self, **kwargs)
Has to be called every time a componentholder is created.
source code
 
remove_component(self, component_class)
Removes component from holder.
source code
    Inherited from concreteobject.ConcreteObject
 
act(self, action, facing_loc=None, repeating=False, force_restart=True) source code
 
fife_instance(self) source code
 
has_action(self, action)
Checks if this unit has a certain action.
source code
 
name(self) source code
    Inherited from util.worldobject.WorldObject
 
__lt__(self, other) 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_change_listener(self, listener) source code
 
remove_remove_listener(self, listener) source code
Class Methods [hide private]
 
get_initial_level(cls, player) source code
 
getInstance(cls, session, x, y, action='idle', level=0, rotation=45, action_set_id=None, world_id="")
Get a Fife instance
source code
 
have_resources(cls, inventory_holders, owner) 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 concreteobject.ConcreteObject
 
get_random_action_set(cls, level=0, exact_level=False)
Returns an action set for an object of type object_id in a level <= the specified level.
source code
 
weighted_choice(cls, weighted_dict)
http://eli.thegreenplace.net/2010/01/22/weighted-random-generation-in-python/
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]
  walkable = False
  buildable_upon = False
  is_building = True
  tearable = True
  layer = 3
  log = logging.getLogger("world.building")
    Inherited from component.componentholder.ComponentHolder
  class_mapping = {'AmbientSoundComponent': AmbientSoundComponen...
    Inherited from concreteobject.ConcreteObject
  is_unit = False
  movable = False
Method Details [hide private]

__init__(self, x, y, rotation, owner, island, level=None, **kwargs)
(Constructor)

source code 
Parameters:
  • session - Session instance this obj belongs to
Overrides: util.changelistener.ChangeListener.__init__

__pre_init(self, owner, rotation, origin, level=None)

source code 

Here we face the awkward situation of requiring a fourth init function. It is called like __init, but before other parts are inited via super(). This is necessary since some attributes are used by these other parts.

remove(self)

source code 

Removes the building

Overrides: util.changelistener.ChangeListener.remove

save(self, db)

source code 
Overrides: util.worldobject.WorldObject.save

load(self, db, worldid)

source code 
Overrides: util.changelistener.ChangeListener.load

load_location(self, db, worldid)

source code 

Does not alter self, just gets island and settlement from a savegame.

Returns:
tuple: (island, settlement)

update_action_set_level(self, level=0)

source code 

Updates this buildings action_set to a random actionset from the specified level (if an action set exists in that level). Its difference to get_random_action_set is that it just checks one level, and doesn't search for an action set everywhere, which makes it a lot more effective if you're just updating.

Parameters:
  • level - int level number

getInstance(cls, session, x, y, action='idle', level=0, rotation=45, action_set_id=None, world_id="")
Class Method

source code 

Get a Fife instance

Parameters:
  • x, y - The coordinates
  • action - The action, defaults to 'idle'
  • level - object level. Relevant for choosing an action set
  • rotation - rotation of the object. Any of [ 45 + 90*i for i in xrange(0, 4) ]
  • action_set_id - can be set if the action set is already known. If set, level isn't considered.
Returns:
tuple (fife_instance, action_set_id)