Package horizons :: Package ai :: Package aiplayer :: Module settlementmanager :: Class SettlementManager
[hide private]
[frames] | no frames]

Class SettlementManager

source code

util.changelistener.ChangeListener --+    
                                     |    
          util.worldobject.WorldObject --+
                                         |
                                        SettlementManager

This is the main settlement control class.

Important attributes: * feeder_island: boolean showing whether the island is a feeder island (feeder islands have no village area) * island: Island instance * settlement: Settlement instance * land_manager: LandManager instance * production_chain: dictionary where the key is a resource id and the value is the ProductionChain instance * production_builder: ProductionBuilder instance * village_builder: VillageBuilder instance * resource_manager: ResourceManager instance * trade_manager: TradeManager instance

Instance Methods [hide private]
 
__init__(self, owner, land_manager) source code
 
__init(self, land_manager) source code
 
__init_goals(self)
Initialize the list of all the goals the settlement can use.
source code
 
save(self, db) source code
 
_load(self, db, owner, worldid) source code
 
_set_taxes_and_permissions(self, sailor_taxes, pioneer_taxes, settler_taxes, citizen_taxes, sailor_upgrades, pioneer_upgrades, settler_upgrades)
Set new tax settings and building permissions.
source code
 
_set_taxes_and_permissions_prefix(self, prefix)
Set new tax settings and building permissions according to the prefix used in the personality file.
source code
 
can_provide_resources(self)
Return a boolean showing whether this settlement is complete enough to concentrate on building a new settlement.
source code
 
get_resource_production(self, resource_id)
Return the current production capacity (including import) per tick of the given resource.
source code
 
get_resource_production_requirement(self, resource_id)
Return the amount of resource per tick the settlement needs.
source code
 
_manual_upgrade(self, level, limit)
Manually allow settlers to upgrade.
source code
 
get_ideal_production_level(self, resource_id)
Return the amount of resource per tick the settlement should produce.
source code
 
_start_feeder_tick(self) source code
 
_end_feeder_tick(self) source code
 
_start_general_tick(self) source code
 
refresh_taxes_and_upgrade_permissions(self) source code
 
_end_general_tick(self) source code
 
_add_goals(self, goals)
Add the settlement's goals that can be activated to the goals list.
source code
 
tick(self, goals)
Refresh the settlement info and add its goals to the player's goal list.
source code
 
add_building(self, building)
Called when a new building is added to the settlement (the building already exists during the call).
source code
 
remove_building(self, building)
Called when a building is removed from the settlement (the building still exists during the call).
source code
 
handle_lost_area(self, coords_list)
Handle losing the potential land in the given coordinates list.
source code
 
handle_disaster(self, message) source code
 
__str__(self) source code
    Inherited from util.worldobject.WorldObject
 
__lt__(self, other) source code
 
remove(self) 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]
 
load(cls, db, owner, worldid) 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("ai.aiplayer")
Method Details [hide private]

__init__(self, owner, land_manager)
(Constructor)

source code 
Parameters:
  • worldid - worldid to assign. Use None to get an autogenerated one.
Overrides: util.changelistener.ChangeListener.__init__

save(self, db)

source code 
Overrides: util.worldobject.WorldObject.save

load(cls, db, owner, worldid)
Class Method

source code 
Overrides: util.changelistener.ChangeListener.load

_manual_upgrade(self, level, limit)

source code 

Manually allow settlers to upgrade. If more then the set limit are already upgrading then don't stop them.

Parameters:
  • level - the initial settler level from which to upgrade
  • limit - the maximum number of residences of the specified level upgrading at the same time
Returns:
boolean showing whether we gave any new residences the right to upgrade

get_ideal_production_level(self, resource_id)

source code 

Return the amount of resource per tick the settlement should produce.

This is the amount that should be produced to satisfy the people in this settlement, keep up the current export rate, and fix the player's global deficit. This means that different (feeder) islands will have different ideal production levels.

handle_lost_area(self, coords_list)

source code 

Handle losing the potential land in the given coordinates list.

Take the following actions: * remove the lost area from the village, production, and road areas * remove village sections with impossible main squares * remove all planned buildings that are now impossible from the village area * remove planned fields that are now impossible * remove fields that can no longer be serviced by a farm * TODO: if the village area takes too much of the total area then remove / reduce the remaining sections