Package horizons :: Package world :: Package production :: Module production :: Class SingleUseProduction
[hide private]
[frames] | no frames]

Class SingleUseProduction

source code

util.changelistener.ChangeListener --+    
                            Production --+

This Production just produces one time, and then finishes. Notification of the finishing is done via production_finished listeners. Use case: Settler getting upgrade material

Instance Methods [hide private]
__init__(self, inventory, owner_inventory, prod_id, prod_data, **kwargs) source code
_finished_producing(self, **kwargs)
Called when the production finishes.
source code
    Inherited from Production
__str__(self) source code
_add_listeners(self, check_now=False)
Listen for changes in the inventory from now on.
source code
Calls every listener when an object changed
source code
Checks if all required resources are there.
source code
Checks if there is enough space in the inventory for the res, we want to produce.
source code
Called when assigned building's inventory changed in some way
source code
remove the part of the state history that is too old to matter
source code
_get_first_relevant_tick(self, ignore_pause)
Returns the first tick that is relevant for production utilization calculation
source code
Returns the callback used during the process of producing (state: producing)
source code
Put produces goods to the inventory
source code
Called when there are enough res in the inventory for starting production
source code
_remove_listeners(self) source code
Removes the resources from the inventory, that production takes.
source code
Actually start production.
source code
alter_production_time(self, modifier)
@see ProductionLine.alter_production_time
source code
Returns whether the production should change the animation
source code
Makes the production finish now
source code
get_age(self) source code
Returns the production's current state, but only if it effects the animation, else None
source code
Res that are consumed here.
source code
Res that are produced here.
source code
@return dict of produced units {unit_id: amount}
source code
Returns id of production line
source code
get_production_time(self) source code
Returns the Production's current state
source code
get_state_history_times(self, ignore_pause)
Returns the part of time 0 <= x <= 1 the production has been in a state during the last history_length ticks.
source code
Returns all produced res for whose there is no space
source code
is_paused(self) source code
load(self, db, worldid) source code
pause(self, pause=True) source code
remove(self) source code
save(self, db, owner_id)
owner_id: worldid of the owner of the producer object that owns this production
source code
toggle_pause(self) source code
    Inherited from util.changelistener.ChangeListener
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
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 Variables [hide private]
    Inherited from Production
  keep_original_prod_line = False
  log = logging.getLogger('world.production')
  uses_gold = False
Method Details [hide private]

__init__(self, inventory, owner_inventory, prod_id, prod_data, **kwargs)

source code 
  • inventory - interface to the world, take res from here and put output back there
  • owner_inventory - same as inventory, but for gold. Usually the players'.
  • prod_id - int id of the production line
  • prod_data - ?
  • start_finished - Whether to start at the final state of a production
  • load - set to True if this production is supposed to load a saved production
Overrides: util.changelistener.ChangeListener.__init__

_finished_producing(self, **kwargs)

source code 

Called when the production finishes.

Overrides: Production._finished_producing
(inherited documentation)