From c3ef05382ffa9c842d7c3a1d71b9d9dc72becb75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juhani=20Krekel=C3=A4?= Date: Fri, 10 May 2019 22:01:22 +0300 Subject: [PATCH] Start game with !join --- gameloop.py | 64 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 25 deletions(-) diff --git a/gameloop.py b/gameloop.py index 4f71b00..77bf280 100644 --- a/gameloop.py +++ b/gameloop.py @@ -360,6 +360,38 @@ def game(send, notice, voice, devoice, get_event): else: error('Unknown event type: %s' % event) + def start_game(rest): + expert = False + if len(rest) == 0 or rest[0] == 'default': + send('Adding the default CAH deck (A5DCM)') + + deck_add_handler('A5DCM') + + elif rest[0] == 'offtopia': + send('Adding the default CAH deck (A5DCM), offtopia injoke deck (PXWKC), :Deck (colondeck) and three random decks') + + deck_add_handler('A5DCM') + deck_add_handler('PXWKC') + deck_add_handler('colondeck') + + deck_add_random_handler() + deck_add_random_handler() + deck_add_random_handler() + + elif rest[0] == 'empty': + pass + + elif rest[0] == 'expert': + expert = True + + else: + send('Unknown preset %s' % rest[0]) + + if not expert: + limit_type = {limit_types.rounds: 'rounds', limit_types.points: 'points'}[limit.type] + send('Limit is %i %s, change with !limit' % (limit.number, limit_type)) + send('Once you are ready to start the game, everyone send !ready') + def no_game(): nonlocal players, bots, decks, limit, round_number, round_call_card, czar, card_choices if players is not None: @@ -388,36 +420,18 @@ def game(send, notice, voice, devoice, get_event): send('%s started a game, !join to join!' % nick) - expert = False - if len(rest) == 0 or rest[0] == 'default': - send('Adding the default CAH deck (A5DCM)') + start_game(rest) - deck_add_handler('A5DCM') + return game_setup - elif rest[0] == 'offtopia': - send('Adding the default CAH deck (A5DCM), offtopia injoke deck (PXWKC), :Deck (colondeck) and three random decks') + elif event == events.join: + nick = args[0] - deck_add_handler('A5DCM') - deck_add_handler('PXWKC') - deck_add_handler('colondeck') + send('Started game, !join to join!') - deck_add_random_handler() - deck_add_random_handler() - deck_add_random_handler() + common_handler(event, args) - elif rest[0] == 'empty': - pass - - elif rest[0] == 'expert': - expert = True - - else: - send('Unknown preset %s' % rest[0]) - - if not expert: - limit_type = {limit_types.rounds: 'rounds', limit_types.points: 'points'}[limit.type] - send('Limit is %i %s, change with !limit' % (limit.number, limit_type)) - send('Once you are ready to start the game, everyone send !ready') + start_game([]) return game_setup