def perform(self):
     if self.app.game:
         if self.app.game.state == "selection":
             self.player.tell("Character selection is already open.")
         elif self.app.game.state == "battle":
             self.player.tell("You can't open selection during battle.")
         else:
             self.app.game.open_selection()
     else:
         if 'gametype' in self.args:
             gtype = gametypes.get(self.args['gametype'])
             if gtype:
                 self.app.set_game(gtype)
             else:
                 self.player.tell("No such gametype exists.")
         else:
             gtype = gametypes.get('survivor')
             if gtype:
                 self.app.set_game(gtype)
             else:
                 self.player.tell("# Missing 'gametype' parameter. (1:str)")
Beispiel #2
0
def gametype(app, name, argsleft):
    """Validate argument to an existing gametype."""
    from urb import gametypes

    typename = argsleft.pop(0)
    gt = gametypes.get(typename)
    if gt:
        gt = GameSettings.get(selector=typename)
        if gt == None:
            gt = GameSettings.create(selector=typename)
        return gt, argsleft

    else:
        choices = [g.selector for g in GameSettings.all() if g.selector.startswith(typename)]
        raise ValidationError("'%s' is not a valid gametype." % typename, gametype, choices)