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

Class Settler

source code

                        buildable.Buildable --+    
                                              |    
                        buildable.BuildableRect --+
                                                  |
resourcehandler.ResourceTransferHandler --+       |
                                          |       |
            resourcehandler.ResourceHandler --+   |
                                              |   |
buildingresourcehandler.BuildingResourceHandler --+
                                                  |
  component.componentholder.ComponentHolder --+   |
                                              |   |
 util.changelistener.ChangeListener --+       |   |
                                      |       |   |
           util.worldobject.WorldObject --+   |   |
                                          |   |   |
              concreteobject.ConcreteObject --+   |
                                              |   |
                         building.BasicBuilding --+
                                                  |
                                                 Settler

Represents a settlers house, that uses resources and creates inhabitants.

Instance Methods [hide private]
 
__init__(self, x, y, owner, instance=None, **kwargs) source code
 
__init(self, loading=False, last_tax_payed=0) source code
 
initialize(self)
Has to be called every time a componentholder is created.
source code
 
save(self, db) source code
 
load(self, db, worldid) source code
 
_load_upgrade_data(self, db)
Load the upgrade production and relevant stored resources
source code
 
_add_upgrade_production_line(self)
Add a production line that gets the necessary upgrade material.
source code
 
remove(self)
Removes the building
source code
 
upgrade_allowed(self) source code
 
_on_change_upgrade_permissions(self, message) source code
 
happiness(self) source code
 
capacity_utilization(self) source code
 
_update_level_data(self, loading=False, initial=False)
Updates all settler-related data because of a level change or as initialization
source code
 
run(self, remaining_ticks=None)
Start regular tick calls
source code
 
_tick(self)
Here we collect the functions, that are called regularly (every "month").
source code
 
pay_tax(self)
Pays the tax for this settler
source code
 
inhabitant_check(self)
Checks whether or not the population of this settler should increase or decrease
source code
 
can_level_up(self) source code
 
level_check(self)
Checks whether we should level up or down.
source code
 
level_up(self, production=None)
Actually level up (usually called when the upgrade material has arrived)
source code
 
level_down(self) source code
 
make_ruin(self)
Replaces itself with a ruin.
source code
 
_has_disaster(self) source code
 
_check_main_square_in_range(self)
Notifies the user via a message in case there is no main square in range
source code
 
level_upgrade(self, lvl)
Settlers only level up by themselves
source code
 
_update_status_icon(self) source code
 
__str__(self) source code
 
__get_data(self, key)
Returns constant settler-related data from the db.
source code
    Inherited from buildingresourcehandler.BuildingResourceHandler
 
_set_running_costs_to_status(self, caller, activate) source code
 
is_valid_tradable_resource(self, resources)
Checks if the produced resource tradable (can be carried by collectors).
source code
 
on_production_finished(self, caller, resources) source code
    Inherited from resourcehandler.ResourceHandler
 
_get_owner_inventory(self)
Returns the inventory of the owner to be able to retrieve special resources such as gold.
source code
 
_load_provided_resources(self)
Returns a iterable obj containing all resources this building provides.
source code
 
add_incoming_collector(self, collector) source code
 
get_available_pickup_amount(self, res, collector)
Returns how much of res a collector may pick up.
source code
 
get_consumed_resources(self, include_inactive=False)
Returns the needed resources that are used by the productions currently active.
source code
 
get_currently_consumed_resources(self)
Returns a list of resources, that are currently consumed in a production.
source code
 
get_currently_not_consumed_resources(self)
Needed, but not currently consumed resources.
source code
 
get_needed_resources(self)
Returns list of resources, where free space in the inventory exists.
source code
 
get_produced_resources(self)
Returns the resources, that are produced by productions, that are currently active
source code
 
get_stocked_provided_resources(self)
Returns provided resources, where at least 1 ton is available
source code
 
pickup_resources(self, res, amount, collector)
Try to get amount number of resources of id res_id that are in stock and removes them from the stock.
source code
 
remove_incoming_collector(self, collector) source code
    Inherited from resourcehandler.ResourceTransferHandler
 
transfer_to_storageholder(self, amount, res_id, transfer_to, signal_errors=False)
Transfers amount of res_id to transfer_to.
source code
    Inherited from building.BasicBuilding
 
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
 
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
 
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.BuildableRect
 
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]
  log = logging.getLogger("world.building.settler")
  production_class = SettlerProduction
  tabs = SettlerOverviewTab,
  default_level_on_build = 0
    Inherited from buildable.Buildable
  CHECK_NEARBY_LOCATIONS_UP_TO_DISTANCE = 3
  irregular_conditions = False
  terrain_type = 1
    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, x, y, owner, instance=None, **kwargs)
(Constructor)

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

initialize(self)

source code 

Has to be called every time a componentholder is created. This is not in __init__() because we need to make sure that all other sub/parent classes have been inited, for example the ConcreteObject class. This is to ensure that all member variables of sub/parent classes are correctly set when we init the components. If someday all code is moved to components, this will not be necessary any more.

Overrides: component.componentholder.ComponentHolder.initialize
(inherited documentation)

save(self, db)

source code 
Overrides: util.worldobject.WorldObject.save

load(self, db, worldid)

source code 
Overrides: util.changelistener.ChangeListener.load

_add_upgrade_production_line(self)

source code 

Add a production line that gets the necessary upgrade material. When the production finishes, it calls upgrade_materials_collected.

remove(self)

source code 

Removes the building

Overrides: util.changelistener.ChangeListener.remove

upgrade_allowed(self)

source code 
Decorators:
  • @property

happiness(self)

source code 
Decorators:
  • @property

capacity_utilization(self)

source code 
Decorators:
  • @property

_update_level_data(self, loading=False, initial=False)

source code 

Updates all settler-related data because of a level change or as initialization

Parameters:
  • loading - whether called to set data after loading
  • initial - whether called to set data initially

level_check(self)

source code 

Checks whether we should level up or down.

Ignores buildings with a active disaster.

level_upgrade(self, lvl)

source code 

Settlers only level up by themselves

Overrides: building.BasicBuilding.level_upgrade

__str__(self)
(Informal representation operator)

source code 
Overrides: building.BasicBuilding.__str__

__get_data(self, key)

source code 

Returns constant settler-related data from the db. The values are cached by python, so the underlying data must not change.