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

Class QueueProducer

source code

component.Component --+    
                      |    
               Producer --+
                          |
                         QueueProducer

The QueueProducer stores all productions in a queue and runs them one by one.

Instance Methods [hide private]
 
__init__(self, **kwargs)
Used for initialization code that does not require any other components.
source code
 
__init(self) source code
 
save(self, db)
Will do nothing, but will be always called in componentholder code, even if not implemented.
source code
 
load(self, db, worldid)
This does on load what __init() and initalize() together do on constructions at runtime.
source code
 
add_production_by_id(self, production_line_id)
Convenience method.
source code
 
check_next_production_startable(self) source code
 
on_queue_element_finished(self, production)
Callback used for the SingleUseProduction
source code
 
start_next_production(self)
Starts the next production that is in the queue, if there is one.
source code
 
cancel_all_productions(self) source code
 
cancel_current_production(self)
Cancels the current production and proceeds to the next one, if there is one
source code
 
remove_from_queue(self, index)
Remove the index'th element from the queue.
source code
    Inherited from Producer
 
__str__(self) source code
 
_add_status_icon(self, icon) source code
 
_get_current_state(self)
Returns the current state of the producer.
source code
 
_get_production(self, prod_line_id)
Returns a production of this producer by a production line id.
source code
 
_on_production_change(self)
Makes the instance act according to the producers current state
source code
 
_production_finished(self, production)
Gets called when a production finishes.
source code
 
_update_decommissioned_icon(self)
Add or remove decommissioned icon.
source code
 
add_production(self, production) source code
 
alter_production_time(self, modifier, prod_line_id=None)
Multiplies the original production time of all production lines by modifier
source code
 
capacity_utilization(self) source code
 
capacity_utilization_below(self, limit) source code
 
create_production(self, id, load=False) source code
 
create_production_line(self, id)
Creates a production line instance, this is meant only for data transfer and READONLY use! If you want to use production lines for anything else, go the proper way of the production class.
source code
 
finish_production_now(self)
Cheat, makes current production finish right now (and produce the resources).
source code
 
get_production_lines(self)
Returns all production lines that have been added.
source code
 
get_production_lines_by_level(self, level) source code
 
get_production_progress(self)
Returns the current progress of the active production.
source code
 
get_productions(self)
Returns all productions, inactive and active ones, as list
source code
 
get_status_icons(self) source code
 
has_production_line(self, prod_line_id)
Checks if this instance has a production with a certain production line id
source code
 
initialize(self)
This is called by the ComponentHolder after it set the instance.
source code
 
is_active(self, production=None)
Checks if a production, or the at least one production if production is None, is active
source code
 
remove(self)
Removes component and reference to instance
source code
 
remove_production(self, production)
Removes a production instance.
source code
 
remove_production_by_id(self, prod_line_id)
Convenience method.
source code
 
set_active(self, production=None, active=True)
Pause or unpause a production (aka set it active/inactive).
source code
 
toggle_active(self, production=None) source code
 
update_capacity_utilization(self)
Called by the scheduler to update the utilization regularly
source code
    Inherited from component.Component
 
__gt__(self, other) source code
 
__lt__(self, other) source code
 
session(self) source code
Class Methods [hide private]
    Inherited from Producer
 
get_instance(cls, arguments=None)
This function is used to instantiate classes from yaml data.
source code
Class Variables [hide private]
  production_class = SingleUseProduction
    Inherited from Producer
  DEPENDENCIES = [StorageComponent]
  NAME = "producer"
hash(x)
  log = logging.getLogger("world.production")
  produces_resource = True
  utilization_mapping = {'FieldUtilization': FieldUtilization, '...
Method Details [hide private]

__init__(self, **kwargs)
(Constructor)

source code 

Used for initialization code that does not require any other components. This is always called first, on construction and on load.

Parameters:
  • productionline - yaml-dict for prod line data. Must not be changed since it is cached.
  • utilization_calculator - one of utilization_mapping
  • settler_upgrade_lines - data for settler upgrades. can one day be generalized to other upgrades
  • auto_init - bool. If True, the producer automatically adds one production for each production_line.
Overrides: component.Component.__init__
(inherited documentation)

save(self, db)

source code 

Will do nothing, but will be always called in componentholder code, even if not implemented.

Overrides: component.Component.save
(inherited documentation)

load(self, db, worldid)

source code 

This does on load what __init() and initalize() together do on constructions at runtime. Has to set up everything that is not setup in __init__(). Note that on loading __init__() is called with the data needed by the component through get_instance(), but initialize() is not, so any work needed for loading as well should be moved to a separate method and called here.

Overrides: component.Component.load
(inherited documentation)

add_production_by_id(self, production_line_id)

source code 

Convenience method.

Parameters:
  • production_line_id - Production line from db
Overrides: Producer.add_production_by_id

remove_from_queue(self, index)

source code 

Remove the index'th element from the queue. First element is 0