diff --git a/commands.py b/commands.py index dc24e98..9c9b4b2 100644 --- a/commands.py +++ b/commands.py @@ -71,6 +71,10 @@ def choose_container(string, argname, allownew, adding): kwargs['containercallback'] = func kwargs['argname'] = argname handler.read_answer(new_container_callback, 'newcontainer', kwargs) + elif len(options) == 0: + # no options to show + handler.send('You don\'t seem to have anything with you.') + return False else: handler.send(string, options=options, allowedit=True) handler.read_answer(func, argname, kwargs) @@ -193,12 +197,14 @@ def need_role(role, errormessage): @read_args('How are we going to call the game?', 'name') @choose_template('Please choose a game template. This will only affect the default character sheets and dices.', 'template') def newgame(handler, name, template): + template, skip_sheet = db.convert_template(template) gameid = db.new_game(handler.dbc, handler.sender_id, handler.username, name, handler.chat_id, handler.groupname, template) if gameid is None: handler.send(newgame_already_started_usage()) return False - db.add_default_items(handler.dbc, handler.sender_id, gameid, template) + if not skip_sheet: + db.add_default_items(handler.dbc, handler.sender_id, gameid, template) handler.send('New game created: {}.'.format(name)) diff --git a/db.py b/db.py index b9bab86..2798b23 100644 --- a/db.py +++ b/db.py @@ -7,7 +7,9 @@ db_version = 1 ROLE_PLAYER = 10 ROLE_MASTER = 20 game_templates = OrderedDict([('fae', 'Fate Accelerated RPG'), - ('dnd', 'Dungeons & Dragons')]) + ('fae-blank', 'Fate Accelerated RPG (empty character sheet)'), + ('dnd', 'Dungeons & Dragons'), + ('dnd-blank', 'Dungeons & Dragons (empty character sheet)')]) room_container = 'room' rolls_container = 'rolls' @@ -61,6 +63,17 @@ def init(): db.commit() close_connection(db) +def convert_template(template): + """ + The blank versions of the character sheets use the same templates (same dices) + but treat treat the sheet creation differently (...by skipping it) + """ + if template == 'fae-blank': + return 'fae', True + if template == 'dnd-blank': + return 'dnd', True + return template, False + def new_game(db, admin, playername, gamename, groupid, groupname, template): """ Creates a new game. @@ -71,6 +84,7 @@ def new_game(db, admin, playername, gamename, groupid, groupname, template): """ if template not in game_templates: raise + c = db.cursor() try: query = c.execute('''INSERT INTO Games(version, lastactivity, gamename, template) VALUES (?, datetime('now'), ?, ?)''', (db_version, gamename, template))