Allow to create games with no character sheet
This commit is contained in:
parent
772e398e6a
commit
7ad1ab246a
|
@ -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))
|
||||
|
||||
|
||||
|
|
16
db.py
16
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))
|
||||
|
|
Loading…
Reference in New Issue