Mercurial > sypikslang
comparison gamelib/gamestate.py @ 41:e285b1e31a08
Add can_attempt method for future flexibility
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Mon, 07 May 2012 13:59:50 +0200 |
parents | 12c33aac7684 |
children | 47c7e96cf9c8 |
comparison
equal
deleted
inserted
replaced
40:0e178b20e3ff | 41:e285b1e31a08 |
---|---|
39 if isinstance(x, products.Product) and x.COST <= self.money] | 39 if isinstance(x, products.Product) and x.COST <= self.money] |
40 return available | 40 return available |
41 | 41 |
42 def get_available_missions(self): | 42 def get_available_missions(self): |
43 """Return a list of missions we can feasibly attempt""" | 43 """Return a list of missions we can feasibly attempt""" |
44 available = [x for x in self.missions | 44 available = [x for x in self.missions if x.can_attempt(self)] |
45 if (x.MINIMUM_REPUTATION is None | |
46 or x.MINIMUM_REPUTATION <= self.reputation)] | |
47 return available | 45 return available |
48 | 46 |
49 def end_turn(self): | 47 def end_turn(self): |
50 # Attempt the missions | 48 # Attempt the missions |
51 mission_results = [] | 49 mission_results = [] |
52 for mission, equipment in self.cur_missions: | 50 for mission, equipment in self.cur_missions: |
53 mission_results.append(mission.attempt(equipment, self)) | 51 mission_results.append(mission.attempt(equipment, self)) |
54 if not mission.available: | |
55 # Mission no longer available, so we clean up | |
56 self.missions.remove(mission) | |
57 # Do the science | 52 # Do the science |
58 self.points -= len(self.cur_allocation) | 53 self.points -= len(self.cur_allocation) |
59 if self.points < 0: | 54 if self.points < 0: |
60 raise RuntimeError('Spent too many points') | 55 raise RuntimeError('Spent too many points') |
61 new_stuff = self.lab.spend_points(self.cur_allocation, self.points) | 56 new_stuff = self.lab.spend_points(self.cur_allocation, self.points) |