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

Class Tower

source code

                       buildable.Buildable --+    
                                             |    
                     buildable.BuildableSingle --+
                                                 |
           units.weaponholder.WeaponHolder --+   |
                                             |   |
     units.weaponholder.StationaryWeaponHolder --+
                                                 |
 component.componentholder.ComponentHolder --+   |
                                             |   |
util.changelistener.ChangeListener --+       |   |
                                     |       |   |
          util.worldobject.WorldObject --+   |   |
                                         |   |   |
             concreteobject.ConcreteObject --+   |
                                             |   |
                        building.BasicBuilding --+
                                                 |
                                                Tower

Instance Methods [hide private]
 
__init__(self, *args, **kwargs) source code
 
fire_all_weapons(self, dest, rotate=True)
Fires all weapons in storage at a given position
source code
 
update_range(self, caller=None) source code
 
_fix_weapon_range(self)
Set all min weapon ranges to 0.
source code
    Inherited from units.weaponholder.StationaryWeaponHolder
 
load(self, db, worldid) source code
    Inherited from units.weaponholder.WeaponHolder
 
_add_to_fireable(self, weapon)
Callback executed when weapon attack is ready
source code
 
_increase_fired_weapons_number(self, caller=None)
Callback that helps keeping tack of successful weapon fire number
source code
 
_remove_from_fireable(self, weapon)
Callback executed when weapon is fired
source code
 
_stance_tick(self)
Executes every few seconds, doing movement depending on the stance.
source code
 
act_attack(self, dest)
Override in subclasses for action code
source code
 
add_weapon_to_storage(self, weapon_id)
adds weapon to storage
source code
 
attack(self, target)
Triggers attack on target
source code
 
attack_in_range(self)
Returns True if the target is in range, False otherwise
source code
 
can_attack_position(self, position)
Returns True if the holder can attack position at call time
source code
 
create_weapon_storage(self) source code
 
equip_from_inventory(self, weapon_id, number)
Equips weapon if present in inventory
source code
 
get_attack_target(self) source code
 
get_status(self)
Return the current status of the ship.
source code
 
get_weapon_storage(self)
Returns storage object for self._weapon_storage
source code
 
is_attacking(self)
Returns True if the WeaponHolder is trying to attack a target
source code
 
load_target(self, db)
Loads target from database
source code
 
remove(self) source code
 
remove_target(self)
Removes reference from target, this happens when the attack is stopped or the target is dead either way the refs are checked using gc module this is used because after unit death it's possbile that it still has refs
source code
 
remove_weapon_from_storage(self, weapon_id)
removes weapon to storage
source code
 
save(self, db) source code
 
stop_attack(self) source code
 
try_attack_target(self)
Attacking loop
source code
 
unequip_to_inventory(self, weapon_id, number)
Unequips weapon and adds it to inventory
source code
 
user_attack(self, targetid)
Called when the user triggeres the attack, executes the user_attack_issued callbacks
source code
    Inherited from building.BasicBuilding
 
__str__(self) source code
 
get_buildings_in_range(self) source code
 
get_payout(self)
Gets the payout from the settlement in form of its running costs
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
 
level_upgrade(self, lvl)
Upgrades building to another tier
source code
 
load_location(self, db, worldid)
Does not alter self, just gets island and settlement from a savegame.
source code
 
running_costs_active(self)
Returns whether the building currently pays the running costs for status 'active'
source code
 
start(self)
This function is called when the building is built, to start production for example.
source code
 
toggle_costs(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
    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]
    Inherited from buildable.BuildableSingle
 
check_build_line(cls, session, point1, point2, rotation=45, ship=None)
Checks out a line on the map for build possibilities.
source code
    Inherited from buildable.Buildable
 
_check_buildings(cls, session, position, island=None)
Check if there are buildings blocking the build.
source code
 
_check_island(cls, session, position, island=None)
Check if there is an island and enough tiles.
source code
 
_check_rotation(cls, session, position, rotation)
Returns a possible rotation for this building.
source code
 
_check_settlement(cls, session, position, ship=None, issuer=None)
Check that there is a settlement that belongs to the player.
source code
 
_check_units(cls, session, position) source code
 
check_build(cls, session, point, rotation=45, check_settlement=True, ship=None, issuer=None)
Check if a building is buildable here.
source code
 
check_build_fuzzy(cls, session, point, *args, **kwargs)
Same as check_build, but consider point to be a vague suggestions and search nearby area for buildable position.
source code
 
is_tile_buildable(cls, session, tile, ship, island=None, check_settlement=True)
Checks a tile for buildability.
source code
    Inherited from building.BasicBuilding
 
getInstance(cls, session, x, y, action='idle', level=0, rotation=45, action_set_id=None, world_id="")
Get a Fife instance
source code
 
get_initial_level(cls, player) 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]
  POSSIBLE_WEAPONS = [WEAPONS.CANNON]
    Inherited from buildable.Buildable
  CHECK_NEARBY_LOCATIONS_UP_TO_DISTANCE = 3
  irregular_conditions = False
  terrain_type = 1
    Inherited from units.weaponholder.WeaponHolder
  log = logging.getLogger("world.combat")
    Inherited from building.BasicBuilding
  buildable_upon = False
  is_building = True
  layer = 3
  tearable = True
  walkable = False
    Inherited from component.componentholder.ComponentHolder
  class_mapping = {'AmbientSoundComponent': AmbientSoundComponen...
    Inherited from concreteobject.ConcreteObject
  is_unit = False
  movable = False
Method Details [hide private]

__init__(self, *args, **kwargs)
(Constructor)

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

fire_all_weapons(self, dest, rotate=True)

source code 

Fires all weapons in storage at a given position

Parameters:
  • dest - Point with the given position
  • rotated - If True weapons will be fired at different locations, rotated around dest override to True for units that need to fire at rotated coords
Overrides: units.weaponholder.WeaponHolder.fire_all_weapons
(inherited documentation)

update_range(self, caller=None)

source code 
Overrides: units.weaponholder.WeaponHolder.update_range

_fix_weapon_range(self)

source code 

Set all min weapon ranges to 0. Since the tower can't move, melee units could just approach it and destroy the tower