changeset 78:e3143d711e26

merge
author Rizmari Versfeld <rizziepit@gmail.com>
date Wed, 09 May 2012 00:28:46 +0200
parents 9ebce976a683 (current diff) b503ccb0a86e (diff)
children 8d1cf0cbe5e1
files
diffstat 3 files changed, 12 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
Binary file data/images/mission_selected.png has changed
--- a/gamelib/game_base.py	Wed May 09 00:27:08 2012 +0200
+++ b/gamelib/game_base.py	Wed May 09 00:28:46 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__)
 
--- a/gamelib/lab.py	Wed May 09 00:27:08 2012 +0200
+++ b/gamelib/lab.py	Wed May 09 00:28:46 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: