diff gamelib/lab.py @ 49:373c57ab4140

Product -> Schematic.
author Jeremy Thurgood <firxen@gmail.com>
date Mon, 07 May 2012 21:24:23 +0200
parents 3e3bed2ce248
children 52913ba12988
line wrap: on
line diff
--- a/gamelib/lab.py	Mon May 07 21:23:54 2012 +0200
+++ b/gamelib/lab.py	Mon May 07 21:24:23 2012 +0200
@@ -2,7 +2,7 @@
 
 from random import random, choice
 
-from gamelib import research, products
+from gamelib import research, schematics
 from gamelib.game_base import get_subclasses
 
 
@@ -13,7 +13,7 @@
     def __init__(self, init_data=None):
         self.science = []
         self.new_research = get_subclasses(research.ResearchArea)
-        self.new_products = get_subclasses(products.Product)
+        self.new_schematics = get_subclasses(schematics.Schematic)
 
         if init_data is not None:
             # Load stored state.
@@ -24,7 +24,7 @@
 
     def _load_data(self, init_data):
         sciences = init_data['science'].copy()
-        for science in self.new_products + self.new_research:
+        for science in self.new_schematics + self.new_research:
             # Check if this science is one we should know.
             points = sciences.pop(science.save_name(), None)
             if points is not None:
@@ -38,10 +38,10 @@
         return {'science': dict(s.save_data() for s in self.science)}
 
     def _choose_initial_science(self):
-        # We always get all starting products.
-        for product in self.new_products[:]:
-            if product.STARTING_PRODUCT:
-                self._gain_science(product())
+        # We always get all starting schematics.
+        for schematic in self.new_schematics[:]:
+            if schematic.STARTING_PRODUCT:
+                self._gain_science(schematic())
 
         # We get three random sciences with no prerequisites.
         new_science = []
@@ -50,15 +50,15 @@
             self._gain_science(science)
             new_science.append(science)
 
-        # Add a point to each of our sciences, and see if we get products.
+        # Add a point to each of our sciences, and see if we get schematics.
         self.spend_points(new_science, 0)
 
     def _gain_science(self, science):
         self.science.append(science)
         if isinstance(science, research.ResearchArea):
             self.new_research.remove(type(science))
-        elif isinstance(science, products.Product):
-            self.new_products.remove(type(science))
+        elif isinstance(science, schematics.Schematic):
+            self.new_schematics.remove(type(science))
 
     def spend_points(self, things, basic_research):
         breakthroughs = []
@@ -69,7 +69,7 @@
             assert thing.can_spend(self)
             thing.spend_point()
 
-        # Next, check for product breakthroughs and upgrades
+        # Next, check for schematic breakthroughs and upgrades
         for thing in things:
             if isinstance(thing, research.ResearchArea):
                 breakthroughs.extend(self.apply_area_research(thing))
@@ -98,12 +98,12 @@
             total_points += my_science.points
         return total_points - base_points >= extra
 
-    def find_new_products(self):
-        available_products = []
-        for product_class in self.new_products:
-            if self.meet_requirements(product_class):
-                available_products.append(product_class)
-        return available_products
+    def find_new_schematics(self):
+        available_schematics = []
+        for schematic_class in self.new_schematics:
+            if self.meet_requirements(schematic_class):
+                available_schematics.append(schematic_class)
+        return available_schematics
 
     def find_new_research(self):
         available_research = []
@@ -113,10 +113,10 @@
         return available_research
 
     def apply_area_research(self, research):
-        options = [product for product in self.find_new_products()
-                   if type(research) in [p[0] for p in product.PREREQUISITES]]
-        breakthroughs = [product for product in options
-                         if random() < product.ACQUISITION_CHANCE]
+        options = [schema for schema in self.find_new_schematics()
+                   if type(research) in [p[0] for p in schema.PREREQUISITES]]
+        breakthroughs = [schematic for schematic in options
+                         if random() < schematic.ACQUISITION_CHANCE]
         if breakthroughs:
             breakthrough = choice(breakthroughs)()
             self._gain_science(breakthrough)