Mercurial > sypikslang
comparison gamelib/gamestate.py @ 221:bf92c982996e
Don't crash when we run out of suggestions
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Sat, 12 May 2012 21:02:02 +0200 |
parents | ed25c335fd67 |
children | e4f9513c9dd0 |
comparison
equal
deleted
inserted
replaced
220:2f229b917959 | 221:bf92c982996e |
---|---|
45 self.cur_allocation = [] | 45 self.cur_allocation = [] |
46 # Suggest research | 46 # Suggest research |
47 basic_research, suggestions = self.lab.suggest_research() | 47 basic_research, suggestions = self.lab.suggest_research() |
48 if basic_research: | 48 if basic_research: |
49 suggestions.append(None) | 49 suggestions.append(None) |
50 self.advice = choice(suggestions) | 50 try: |
51 self.advice = choice(suggestions) | |
52 except IndexError: | |
53 # We have an empty list of suggestions | |
54 self.advice = None | |
51 if self.advice is None: | 55 if self.advice is None: |
52 self.advice = ("Leave some researchers unassigned." | 56 self.advice = ("Leave some researchers unassigned." |
53 " They might turn up something cool.") | 57 " They might turn up something cool.") |
54 else: | 58 else: |
55 self.advice = "Our work in %s is looking promising." % ( | 59 self.advice = "Our work in %s is looking promising." % ( |