• R/O
  • SSH

Commit

Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Just a simple, and painful to use calculator for the game Factorio written in Python


Commit MetaInfo

Revision67b3fb9439f19b873bb5c0a2224d8911252948f6 (tree)
Time2017-08-07 23:53:24
AuthorEric Hopper <hopper@omni...>
CommiterEric Hopper

Log Message

Allow ingredient specification by name in constructor.

Change Summary

Incremental Difference

diff -r f3360cc79f32 -r 67b3fb9439f1 factorio_calc.py
--- a/factorio_calc.py Sun Aug 06 14:40:20 2017 -0700
+++ b/factorio_calc.py Mon Aug 07 07:53:24 2017 -0700
@@ -13,7 +13,17 @@
1313 self._produced = produced
1414 self._name = name
1515 self._time = time
16- self._ingredients = ingredients
16+ def lookup_ingredients(ingredients):
17+ for ct, item in ingredients:
18+ print(f"Lookup up ({ct}, {item!s})", file=sys.stderr)
19+ if not isinstance(item, ProductionItem):
20+ item = item_db[item]
21+ print(f"Wasn't already an item, found {item!s}",
22+ file=sys.stderr)
23+ yield (ct, item)
24+ oldlen = len(ingredients)
25+ self._ingredients = tuple(item for item in lookup_ingredients(ingredients))
26+ assert(len(self._ingredients) == oldlen)
1727
1828 def __hash__(self):
1929 return hash(self._name)