Jarv ea881cf520 Added gamemodes. New mode: Fast. (#44)
* Changes for possible bug

* New sanic mode wip

* More changes for fast mode, WIP

* Fast mode is playable (code is ugly tho)

* Fixed skip error

* Fixed fast mode error

* Bug fixing

* Possible fix for the /leave bug before the game starts

* Update README to include Codacy badge

* Fixing error prone code

* Removing code smells

* Removing more code smells

* How long can this go on? (More smells according to Codacy)

* Compile locale fixed for Linux. Small es_ES fix.

* Major refactoring

* Wild mode finished. Changed emojis for text in log.

* Removing test prints, back to emojis

* Code cleaning and fix for player time in fast mode

* Changing help to not override builtin function

* Decreased's complexity

* Default gamemode is now Fast. Added a bot configuration file

* back to random

* Moved logger to shared_vars

* Added MIN_FAST_TURN_TIME to config and fixed 'skipped 4 times' message

* Pull review changes

* More review changes

* Removing codacy badge linked to my account for pull request

* Fixed first special card issue, logger back to how it was (with just one logging init)

* Renamed gameplay config file to
2017-11-27 17:59:19 +01:00

112 lines
3.5 KiB

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Telegram bot to play UNO in group chats
# Copyright (c) 2016 Jannes Höke <>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <>.
import unittest
from telegram import User, Chat
from game_manager import GameManager
from errors import AlreadyJoinedError, LobbyClosedError, NoGameInChatError, \
class Test(unittest.TestCase):
game = None
def setUp(self): = GameManager()
self.chat0 = Chat(0, 'group')
self.chat1 = Chat(1, 'group')
self.chat2 = Chat(2, 'group')
self.user0 = User(0, 'user0')
self.user1 = User(1, 'user1')
self.user2 = User(2, 'user2')
def test_new_game(self):
g0 =
g1 =
self.assertListEqual([0], [g0])
self.assertListEqual([1], [g1])
def test_join_game(self):
*(self.user0, self.chat0))
g0 =, self.chat0)
self.assertEqual(len(g0.players), 1), self.chat0)
self.assertEqual(len(g0.players), 2) = False
*(self.user2, self.chat0)) = True
*(self.user1, self.chat0))
def test_leave_game(self):, self.chat0), self.chat0)
*(self.user1, self.chat0)), self.chat0), self.chat0)
*(self.user0, self.chat0))
def test_end_game(self):, self.chat0), self.chat0)
self.assertEqual(len([0]), 1), self.chat0), self.user0)
self.assertEqual(len([0]), 1), self.user2)
self.assertFalse(0 in
self.assertFalse(0 in
self.assertFalse(1 in
self.assertFalse(2 in