Skip to content

Commit

Permalink
* Rename production.get_produced_res() to get_produced_resources()
Browse files Browse the repository at this point in the history
The resourcehandler used get_produced_resources already and
the counterparts were both called get_consumed_resources().
  • Loading branch information
ChrisOelmueller committed Apr 17, 2012
1 parent 48d869d commit ec0c408
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion horizons/ai/aiplayer/goal/improvecollectorcoverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def _get_problematic_collector_coverage_buildings(self):
amount_paused = history[PRODUCTION.STATES.inventory_full.index] + history[PRODUCTION.STATES.paused.index]
if amount_paused < self.personality.min_bad_collector_coverage:
continue
for resource_id in production.get_produced_res():
for resource_id in production.get_produced_resources():
if self.settlement.get_component(StorageComponent).inventory.get_free_space_for(resource_id) > self.personality.min_free_space:
# this is actually problematic
problematic_buildings[building.worldid] = building
Expand Down
4 changes: 2 additions & 2 deletions horizons/ai/aiplayer/productionbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,12 +483,12 @@ def manage_production(self):
for building in self.production_buildings:
producer = building.get_component(Producer)
for production in producer.get_productions():
if not production.get_produced_res():
if not production.get_produced_resources():
continue
all_full = True

# inventory full of the produced resources?
for resource_id, min_amount in production.get_produced_res().iteritems():
for resource_id, min_amount in production.get_produced_resources().iteritems():
if production.inventory.get_free_space_for(resource_id) >= min_amount:
all_full = False
break
Expand Down
2 changes: 1 addition & 1 deletion horizons/gui/tabs/productiontabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def refresh(self):
# fix pychans lack of dynamic container sizing
# the container in the xml must provide a height attribute, that is valid for
# one resource.
max_res_in_one_line = max(len(production.get_produced_res()), \
max_res_in_one_line = max(len(production.get_produced_resources()), \
len(production.get_consumed_resources()))
container.height = max_res_in_one_line * container.height

Expand Down
6 changes: 3 additions & 3 deletions horizons/world/playerstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ def _collect_info(self):
settler_buildings[building.level] += 1
for production in building.get_component(Producer).get_productions():
if production.get_state() is PRODUCTION.STATES.producing:
produced_res = production.get_produced_res()
if RES.HAPPINESS in produced_res:
happiness = produced_res[RES.HAPPINESS]
produced_resources = production.get_produced_resources()
if RES.HAPPINESS in produced_resources:
happiness = produced_resources[RES.HAPPINESS]
for resource_id in production.get_consumed_resources():
settler_resources_provided[resource_id] += happiness / production.get_production_time()

Expand Down
4 changes: 2 additions & 2 deletions horizons/world/production/producer.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ def add_production(self, production):
def _production_finished(self, production):
"""Gets called when a production finishes. Intercepts call, adds info
and forwards it"""
produced_res = production.get_produced_res()
self.on_production_finished(produced_res)
produced_resources = production.get_produced_resources()
self.on_production_finished(produced_resources)

def finish_production_now(self):
"""Cheat, makes current production finish right now (and produce the resources).
Expand Down
3 changes: 1 addition & 2 deletions horizons/world/production/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
# ###################################################

import logging
import copy

from collections import defaultdict, deque

Expand Down Expand Up @@ -158,7 +157,7 @@ def get_consumed_resources(self):
"""Res that are consumed here. Returns dict {res:amount}. Interface for _prod_line."""
return self._prod_line.consumed_res

def get_produced_res(self):
def get_produced_resources(self):
"""Res that are produced here. Returns dict {res:amount}. Interface for _prod_line."""
return self._prod_line.produced_res

Expand Down
16 changes: 8 additions & 8 deletions horizons/world/resourcehandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ def get_consumed_resources(self):

def get_produced_resources(self):
"""Returns the resources, that are produced by productions, that are currently active"""
produced_res = set()
produced_resources = set()
if self.has_component(Producer):
prod_comp = self.get_component(Producer)
for production in prod_comp._productions.itervalues():
produced_res.update(production.get_produced_res().iterkeys())
return list(produced_res)
produced_resources.update(production.get_produced_resources().iterkeys())
return list(produced_resources)

def get_stocked_provided_resources(self):
"""Returns provided resources, where at least 1 ton is available"""
Expand Down Expand Up @@ -160,15 +160,15 @@ def _load_provided_resources(self):
"""Returns a iterable obj containing all resources this building provides.
This is outsourced from initiation to a method for the possiblity of overwriting it.
Do not alter the returned list; if you need to do so, then copy it."""
produced_res = set()
produced_resources = set()
for prod in self.get_component(Producer).get_productions():
for res in prod.get_produced_res():
produced_res.add(res)
for res in prod.get_produced_resources():
produced_resources.add(res)

for res in self.additional_provided_resources:
produced_res.add(res)
produced_resources.add(res)

return produced_res
return produced_resources

def transfer_to_storageholder(self, amount, res_id, transfer_to):
"""Transfers amount of res_id to transfer_to.
Expand Down

0 comments on commit ec0c408

Please sign in to comment.