Mercurial > sypikslang
changeset 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 | 2f229b917959 |
children | 69941f04f1c0 |
files | gamelib/gamestate.py |
diffstat | 1 files changed, 5 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/gamelib/gamestate.py Sat May 12 21:25:50 2012 +0200 +++ b/gamelib/gamestate.py Sat May 12 21:02:02 2012 +0200 @@ -47,7 +47,11 @@ basic_research, suggestions = self.lab.suggest_research() if basic_research: suggestions.append(None) - self.advice = choice(suggestions) + try: + self.advice = choice(suggestions) + except IndexError: + # We have an empty list of suggestions + self.advice = None if self.advice is None: self.advice = ("Leave some researchers unassigned." " They might turn up something cool.")