Mercurial > sypikslang
comparison gamelib/lab.py @ 177:4bbd4a1879f8
Plagiarism! (Only be sure, please, to always call it research)
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Sat, 12 May 2012 11:23:22 +0200 |
parents | a644f6b64a6d |
children | 52cc28b429b7 |
comparison
equal
deleted
inserted
replaced
176:32ef26f410b8 | 177:4bbd4a1879f8 |
---|---|
141 def __init__(self, init_data=None): | 141 def __init__(self, init_data=None): |
142 self.science = [] | 142 self.science = [] |
143 self.new_research = get_subclasses(research.ResearchArea) | 143 self.new_research = get_subclasses(research.ResearchArea) |
144 self.new_schematics = get_subclasses(schematics.Schematic) | 144 self.new_schematics = get_subclasses(schematics.Schematic) |
145 self.all_science = [s for s in self.new_research + self.new_schematics] | 145 self.all_science = [s for s in self.new_research + self.new_schematics] |
146 self._stolen = [] # Track stuff we learnt by theft this turn | |
146 | 147 |
147 if init_data is not None: | 148 if init_data is not None: |
148 # Load stored state. | 149 # Load stored state. |
149 self._load_data(init_data) | 150 self._load_data(init_data) |
150 else: | 151 else: |
191 if isinstance(science, research.ResearchArea): | 192 if isinstance(science, research.ResearchArea): |
192 self.new_research.remove(type(science)) | 193 self.new_research.remove(type(science)) |
193 elif isinstance(science, schematics.Schematic): | 194 elif isinstance(science, schematics.Schematic): |
194 self.new_schematics.remove(type(science)) | 195 self.new_schematics.remove(type(science)) |
195 | 196 |
197 def steal_science(self, science): | |
198 self._gain_science(science) | |
199 self._stolen.append(science) | |
200 | |
196 def spend_points(self, things, basic_research): | 201 def spend_points(self, things, basic_research): |
197 breakthroughs = [] | 202 breakthroughs = [] |
198 | 203 |
199 # First, allocate the points. | 204 # First, allocate the points. |
200 for thing in things: | 205 for thing in things: |
201 assert thing in self.science | 206 assert thing in self.science |
202 assert thing.can_spend(self, 1) | 207 assert thing.can_spend(self, 1) |
203 thing.spend_point() | 208 thing.spend_point() |
209 | |
210 # Then, gain any stolen science | |
211 breakthroughs.extend(self._stolen) | |
212 self._stolen = [] | |
204 | 213 |
205 # Next, check for schematic breakthroughs and upgrades | 214 # Next, check for schematic breakthroughs and upgrades |
206 breakthroughs.extend(self.apply_area_research([ | 215 breakthroughs.extend(self.apply_area_research([ |
207 thing for thing in things | 216 thing for thing in things |
208 if isinstance(thing, research.ResearchArea)])) | 217 if isinstance(thing, research.ResearchArea)])) |