Package horizons :: Package world :: Module settlement :: Class Settlement
[hide private]
[frames] | no frames]

Class Settlement

source code

  component.componentholder.ComponentHolder --+
                                              |
     util.changelistener.ChangeListener --+   |
                                          |   |
               util.worldobject.WorldObject --+
                                              |
         util.changelistener.ChangeListener --+
                                              |
resourcehandler.ResourceTransferHandler --+   |
                                          |   |
            resourcehandler.ResourceHandler --+
                                              |
                                             Settlement

The Settlement class describes a settlement and stores all the necessary information like name, current inhabitants, lists of tiles and houses, etc belonging to the village.

Instance Methods [hide private]
 
__init__(self, session, owner) source code
 
__init(self, session, owner, upgrade_permissions, tax_settings) source code
 
init_buildability_cache(self, terrain_cache) source code
 
set_tax_setting(self, level, tax) source code
 
set_upgrade_permissions(self, level, allowed) source code
 
inhabitants(self)
Returns number of inhabitants (sum of inhabitants of its buildings)
source code
 
cumulative_running_costs(self)
Return sum of running costs of all buildings
source code
 
cumulative_taxes(self)
Return sum of all taxes paid in this settlement in 1 tax round
source code
 
get_residentials_of_lvl_for_happiness(self, level, min_happiness=0, max_happiness=101) source code
 
balance(self)
Returns sum(income) - sum(expenses) for settlement
source code
 
island(self)
Returns the island this settlement is on
source code
 
level_upgrade(self, lvl)
Upgrades settlement to a new tier.
source code
 
save(self, db, islandid) source code
 
get_tiles_in_radius(self, location, radius, include_self)
Returns tiles in radius of location.
source code
 
add_building(self, building, load=False)
Adds a building to the settlement.
source code
 
remove_building(self, building)
Properly removes a building from the settlement
source code
 
count_buildings(self, id)
Returns the number of buildings in the settlement that are of the given type.
source code
 
settlement_building_production_finished(self, building, produced_res)
Callback function for registering the production of resources.
source code
 
__init_inventory_checker(self)
Check for changed inventories every 4 ticks.
source code
 
end(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(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
 
_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
    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
Class Methods [hide private]
 
make_default_upgrade_permissions(cls) source code
 
make_default_tax_settings(cls) source code
 
load(cls, db, worldid, session, island) 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
Class Variables [hide private]
  log = logging.getLogger("world.settlement")
  component_templates = {'StorageComponent': {'PositiveSizedSlot...
    Inherited from component.componentholder.ComponentHolder
  class_mapping = {'AmbientSoundComponent': AmbientSoundComponen...
    Inherited from resourcehandler.ResourceHandler
  tabs = ProductionOverviewTab, InventoryTab
Method Details [hide private]

__init__(self, session, owner)
(Constructor)

source code 
Parameters:
  • owner - Player object that owns the settlement
Overrides: resourcehandler.ResourceHandler.__init__

inhabitants(self)

source code 

Returns number of inhabitants (sum of inhabitants of its buildings)

Decorators:
  • @property

cumulative_running_costs(self)

source code 

Return sum of running costs of all buildings

Decorators:
  • @property

cumulative_taxes(self)

source code 

Return sum of all taxes paid in this settlement in 1 tax round

Decorators:
  • @property

balance(self)

source code 

Returns sum(income) - sum(expenses) for settlement

Decorators:
  • @property

island(self)

source code 

Returns the island this settlement is on

Decorators:
  • @property

level_upgrade(self, lvl)

source code 

Upgrades settlement to a new tier. It only delegates the upgrade to its buildings.

save(self, db, islandid)

source code 
Overrides: resourcehandler.ResourceHandler.save

load(cls, db, worldid, session, island)
Class Method

source code 
Overrides: resourcehandler.ResourceHandler.load

get_tiles_in_radius(self, location, radius, include_self)

source code 

Returns tiles in radius of location. This is a generator.

Parameters:
  • location - anything that supports get_radius_coordinates (usually Rect).
  • include_self - bool, whether to include the coordinates in location

add_building(self, building, load=False)

source code 

Adds a building to the settlement. This does not set building.settlement, it must be set beforehand. @see Island.add_building

end(self)

source code 
Overrides: util.changelistener.ChangeListener.end

Class Variable Details [hide private]

component_templates

Value:
{'StorageComponent': {'PositiveSizedSlotStorage': {'limit': 0}}}, 'Tra\
dePostComponent', 'SettlementNameComponent',