# HG changeset patch # User Jeremy Thurgood # Date 1336515958 -7200 # Node ID b503ccb0a86e746d1b02c8b83e4259f9a6ffc509 # Parent 8b06b07a1477212d0bd59d84e2307c5840909863 Only one schematic per turn, please. diff -r 8b06b07a1477 -r b503ccb0a86e gamelib/game_base.py --- a/gamelib/game_base.py Wed May 09 00:11:51 2012 +0200 +++ b/gamelib/game_base.py Wed May 09 00:25:58 2012 +0200 @@ -26,6 +26,13 @@ return True @classmethod + def depends_on(self, sciences): + for science_class, _ in self.PREREQUISITES: + if any(isinstance(science, science_class) for science in sciences): + return True + return False + + @classmethod def save_name(cls): return "%s.%s" % (cls.SCIENCE_TYPE, cls.__name__) diff -r 8b06b07a1477 -r b503ccb0a86e gamelib/lab.py --- a/gamelib/lab.py Wed May 09 00:11:51 2012 +0200 +++ b/gamelib/lab.py Wed May 09 00:25:58 2012 +0200 @@ -70,9 +70,9 @@ thing.spend_point() # Next, check for schematic breakthroughs and upgrades - for thing in things: - if isinstance(thing, research.ResearchArea): - breakthroughs.extend(self.apply_area_research(thing)) + breakthroughs.extend(self.apply_area_research( + thing for thing in things + if isinstance(thing, research.ResearchArea))) # Finally, check for research breakthroughs. breakthroughs.extend(self.apply_basic_research(basic_research)) @@ -112,9 +112,9 @@ available_research.append(research_class) return available_research - def apply_area_research(self, research): + def apply_area_research(self, researches): options = [schema for schema in self.find_new_schematics() - if type(research) in [p[0] for p in schema.PREREQUISITES]] + if schema.depends_on(researches)] breakthroughs = [schematic for schematic in options if random() < schematic.ACQUISITION_CHANCE] if breakthroughs: