def make_new_poll_command(instance, player, arguments): """ Make a new poll. Args: instance: The game instance to add the poll to. player: The email of the player creating the poll. arguments: A two item list containing the question and a second list of 2-5 options. Returns: Returns a list with information about the poll just created. See get_poll_return_list for its format. Raises: ValueError if the player is not in the instance. """ instance.check_player(player) if not arguments[0]: raise ValueError('Question cannot be empty') size = len(arguments[1]) if size < 2 or size > 5: raise ValueError('Incorrect number of options for poll. ' + 'Must be between two and five.') poll = Message(parent = instance, sender = player, msg_type = 'poll', recipient = '') poll.put() arguments.append(poll.key().id()) poll.content = simplejson.dumps(arguments) poll.votes = [0] * size poll.open = True poll.voters = [''] poll.put() return get_poll_return_list(poll)