# HG changeset patch # User Neil Muller # Date 1336849322 -7200 # Node ID bf92c982996eb808cdb5356c8f8e827d0f97b35a # Parent 2f229b917959d913d2e4a2fb87de100aaae97933 Don't crash when we run out of suggestions diff -r 2f229b917959 -r bf92c982996e gamelib/gamestate.py --- 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.")