Mercurial > sypikslang
comparison gamelib/lab.py @ 45:1e8f7e694f0c
Refactor missions and sciences a bit to reduce duplication.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Mon, 07 May 2012 20:44:27 +0200 |
parents | efc4f90cfd63 |
children | d3d277a42ac6 |
comparison
equal
deleted
inserted
replaced
44:d35a3762edda | 45:1e8f7e694f0c |
---|---|
1 # -*- test-case-name: gamelib.tests.test_lab -*- | 1 # -*- test-case-name: gamelib.tests.test_lab -*- |
2 | 2 |
3 from random import random, choice | 3 from random import random, choice |
4 | 4 |
5 from gamelib import research, products | 5 from gamelib import research, products |
6 from gamelib.game_base import get_subclasses | |
6 | 7 |
7 | 8 |
8 class Lab(object): | 9 class Lab(object): |
9 BASIC_RESEARCH_SUCCESS_RATE = 0.05 | 10 BASIC_RESEARCH_SUCCESS_RATE = 0.05 |
10 BASIC_RESEARCH_SUCCESS_MULTIPLIER = 2 | 11 BASIC_RESEARCH_SUCCESS_MULTIPLIER = 2 |
11 | 12 |
12 def __init__(self, init_data=None): | 13 def __init__(self, init_data=None): |
13 self.science = [] | 14 self.science = [] |
14 self.new_research = research.ResearchArea.__subclasses__() | 15 self.new_research = get_subclasses(research.ResearchArea) |
15 self.new_products = products.Product.__subclasses__() | 16 self.new_products = get_subclasses(products.Product) |
16 | 17 |
17 if init_data is not None: | 18 if init_data is not None: |
18 # Load stored state. | 19 # Load stored state. |
19 self._load_data(init_data) | 20 self._load_data(init_data) |
20 else: | 21 else: |