Mercurial > sypikslang
comparison gamelib/gamestate.py @ 224:e4f9513c9dd0
Include mission name in the results
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Sat, 12 May 2012 22:33:05 +0200 |
parents | bf92c982996e |
children |
comparison
equal
deleted
inserted
replaced
223:19aae2b701d1 | 224:e4f9513c9dd0 |
---|---|
92 | 92 |
93 def end_turn(self): | 93 def end_turn(self): |
94 # Attempt the missions | 94 # Attempt the missions |
95 mission_results = [] | 95 mission_results = [] |
96 for mission, equipment in self.cur_missions: | 96 for mission, equipment in self.cur_missions: |
97 mission_results.append(mission.attempt_mission(equipment, self)) | 97 mission_results.append((mission.NAME, |
98 mission.attempt_mission(equipment, self))) | |
98 if not self.cur_missions and self.reputation > 0: | 99 if not self.cur_missions and self.reputation > 0: |
99 # If you're not doing stuff, you're not in the news | 100 # If you're not doing stuff, you're not in the news |
100 self.reputation -= M_VALS[self.milestone] | 101 self.reputation -= M_VALS[self.milestone] |
101 # Do the science | 102 # Do the science |
102 self.points -= len(self.cur_allocation) | 103 self.points -= len(self.cur_allocation) |
103 if self.points < 0: | 104 if self.points < 0: |
104 raise RuntimeError('Spent too many points') | 105 raise RuntimeError('Spent too many points') |
105 # Process mission results | 106 # Process mission results |
106 messages = [] | 107 messages = [] |
107 for result in mission_results: | 108 for miss, result in mission_results: |
108 result.apply(self) | 109 result.apply(self) |
109 messages.append((result.outcome, result.text, result.loot)) | 110 messages.append((miss, result.outcome, result.text, result.loot)) |
110 # Missions may give us science breakthroughs, so handle this after | 111 # Missions may give us science breakthroughs, so handle this after |
111 # mission results | 112 # mission results |
112 new_stuff = self.lab.spend_points(self.cur_allocation, self.points) | 113 new_stuff = self.lab.spend_points(self.cur_allocation, self.points) |
113 self.points = 0 | 114 self.points = 0 |
114 self.minions = 0 | 115 self.minions = 0 |
115 for science in new_stuff: | 116 for science in new_stuff: |
116 # FIXME: Update UI better. | 117 # FIXME: Update UI better. |
117 messages.append((INFO, "SCIENCE breakthrough!", { | 118 messages.append((None, INFO, "SCIENCE breakthrough!", { |
118 science.SCIENCE_TYPE: science})) | 119 science.SCIENCE_TYPE: science})) |
119 return messages | 120 return messages |
120 | 121 |
121 def save_data(self): | 122 def save_data(self): |
122 """Serialize the game state into a dict""" | 123 """Serialize the game state into a dict""" |