Mercurial > sypikslang
comparison gamelib/lab.py @ 21:bdc6bfc34ef2
Serialise lab data.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Sun, 06 May 2012 18:34:28 +0200 |
parents | 718d1ec382f7 |
children | f6a3b213857b |
comparison
equal
deleted
inserted
replaced
20:718d1ec382f7 | 21:bdc6bfc34ef2 |
---|---|
29 elif module == 'research': | 29 elif module == 'research': |
30 science = getattr(research, cls) | 30 science = getattr(research, cls) |
31 else: | 31 else: |
32 raise ValueError("Unknown science type: %s" % (module,)) | 32 raise ValueError("Unknown science type: %s" % (module,)) |
33 self._gain_science(science(points)) | 33 self._gain_science(science(points)) |
34 | |
35 def save_data(self): | |
36 data = {'science': {}} | |
37 for science in self.science: | |
38 science_class = type(science) | |
39 name = "%s.%s" % (science_class.__module__.split('.')[-1], | |
40 science_class.__name__) | |
41 data['science'][name] = science.points | |
42 return data | |
34 | 43 |
35 def _choose_initial_science(self): | 44 def _choose_initial_science(self): |
36 # We always get all starting products. | 45 # We always get all starting products. |
37 for product in self.new_products[:]: | 46 for product in self.new_products[:]: |
38 if product.STARTING_PRODUCT: | 47 if product.STARTING_PRODUCT: |