From 3f1da815143628107fc1ee7fceb43a74193c2f8f Mon Sep 17 00:00:00 2001 From: Pesakitan22 Date: Mon, 9 Apr 2018 08:31:12 +0700 Subject: [PATCH 01/14] add last places --- actions.py | 1 + settings.py | 1 + simple_commands.py | 7 +++++++ user_setting.py | 1 + 4 files changed, 10 insertions(+) diff --git a/actions.py b/actions.py index c8c5f1e..d00c583 100644 --- a/actions.py +++ b/actions.py @@ -125,6 +125,7 @@ def do_play_card(bot, player, result_id): us2 = UserSetting.get(id=game.current_player.user.id) if us2 and us2.stats: us2.games_played += 1 + us2.last_places += 1 gm.end_game(chat, user) diff --git a/settings.py b/settings.py index 622d897..a1ed009 100644 --- a/settings.py +++ b/settings.py @@ -79,6 +79,7 @@ def kb_select(bot, update, groups): us.first_places = 0 us.games_played = 0 us.cards_played = 0 + us.last_places = 0 send_async(bot, chat.id, text=_("Deleted and disabled statistics!")) diff --git a/simple_commands.py b/simple_commands.py index 6cc0c23..b640141 100644 --- a/simple_commands.py +++ b/simple_commands.py @@ -134,6 +134,13 @@ def stats(bot, update): n).format(number=n) ) + n = us.last_places + stats_text.append( + _("{number} last place", + "{number} last places", + n).format(number=n) + ) + n = us.cards_played stats_text.append( _("{number} card played", diff --git a/user_setting.py b/user_setting.py index c4e2c50..1213a9f 100644 --- a/user_setting.py +++ b/user_setting.py @@ -28,6 +28,7 @@ class UserSetting(db.Entity): lang = Optional(str, default='') # The language setting for this user stats = Optional(bool, default=False) # Opt-in to keep game statistics first_places = Optional(int, default=0) # Nr. of games won in first place + last_places = Optional(int, default=0) # Nr. of games last place games_played = Optional(int, default=0) # Nr. of games completed cards_played = Optional(int, default=0) # Nr. of cards played total use_keyboards = Optional(bool, default=False) # Use keyboards (unused) From 9d2c1d0ce89daa6e767fe3531d90f3b92563802c Mon Sep 17 00:00:00 2001 From: Pesakitan22 Date: Wed, 11 Apr 2018 11:16:26 +0700 Subject: [PATCH 02/14] join +1 and wild percentage --- actions.py | 4 ++-- deck.py | 4 ++-- game_manager.py | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/actions.py b/actions.py index d00c583..2d5c374 100644 --- a/actions.py +++ b/actions.py @@ -109,7 +109,7 @@ def do_play_card(bot, player, result_id): .format(name=user.first_name)) if us.stats: - us.games_played += 1 + # us.games_played += 1 if game.players_won is 0: us.first_places += 1 @@ -124,7 +124,7 @@ def do_play_card(bot, player, result_id): us2 = UserSetting.get(id=game.current_player.user.id) if us2 and us2.stats: - us2.games_played += 1 + # us2.games_played += 1 us2.last_places += 1 gm.end_game(chat, user) diff --git a/deck.py b/deck.py index 4f1db83..f0507ea 100644 --- a/deck.py +++ b/deck.py @@ -78,9 +78,9 @@ class Deck(object): self.cards.clear() for color in c.COLORS: for value in c.WILD_VALUES: - for _ in range(4): + for _ in range(2): self.cards.append(Card(color, value)) for special in c.SPECIALS: - for _ in range(6): + for _ in range(8): self.cards.append(Card(None, None, special=special)) self.shuffle() diff --git a/game_manager.py b/game_manager.py index ec49bc4..18a3df8 100644 --- a/game_manager.py +++ b/game_manager.py @@ -62,6 +62,8 @@ class GameManager(object): self.logger.info("Joining game with id " + str(chat.id)) try: + us = UserSetting.get(id=user.id) + us.game_played += 1 game = self.chatid_games[chat.id][-1] except (KeyError, IndexError): raise NoGameInChatError() From 824ad89528e38e8b49ba47c38a97e73d4e152c8e Mon Sep 17 00:00:00 2001 From: Pesakitan22 Date: Wed, 11 Apr 2018 11:18:24 +0700 Subject: [PATCH 03/14] join +1 and wild percentage --- game_manager.py | 1 + 1 file changed, 1 insertion(+) diff --git a/game_manager.py b/game_manager.py index 18a3df8..d4e96f9 100644 --- a/game_manager.py +++ b/game_manager.py @@ -22,6 +22,7 @@ import logging from game import Game from player import Player +from user_setting import UserSetting from errors import (AlreadyJoinedError, LobbyClosedError, NoGameInChatError, NotEnoughPlayersError) From d2a52cf1efdefe7cc46bbe64fc85c531bc021b0a Mon Sep 17 00:00:00 2001 From: Pesakitan22 Date: Wed, 11 Apr 2018 11:20:31 +0700 Subject: [PATCH 04/14] typo --- game_manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/game_manager.py b/game_manager.py index d4e96f9..a3763e1 100644 --- a/game_manager.py +++ b/game_manager.py @@ -64,7 +64,7 @@ class GameManager(object): try: us = UserSetting.get(id=user.id) - us.game_played += 1 + us.games_played += 1 game = self.chatid_games[chat.id][-1] except (KeyError, IndexError): raise NoGameInChatError() From 27279b911433aec1d1a752cfd68b4f52079df9ce Mon Sep 17 00:00:00 2001 From: Pesakitan22 Date: Mon, 16 Apr 2018 15:11:42 +0700 Subject: [PATCH 05/14] new mode --- .vscode/settings.json | 3 +++ actions.py | 3 +++ bot.py | 1 + game.py | 2 +- results.py | 11 +++++++++++ simple_commands.py | 1 + 6 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..625247d --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.linting.enabled": false +} \ No newline at end of file diff --git a/actions.py b/actions.py index 2d5c374..111e633 100644 --- a/actions.py +++ b/actions.py @@ -113,6 +113,9 @@ def do_play_card(bot, player, result_id): if game.players_won is 0: us.first_places += 1 + if game.mode == 'one': + gm.end_game(chat, user) + game.players_won += 1 diff --git a/bot.py b/bot.py index cdd2ae4..70238a2 100644 --- a/bot.py +++ b/bot.py @@ -594,6 +594,7 @@ def reply_to_query(bot, update): add_mode_classic(results) add_mode_fast(results) add_mode_wild(results) + add_mode_one(results) else: add_not_started(results) diff --git a/game.py b/game.py index 3234f9b..5600f96 100644 --- a/game.py +++ b/game.py @@ -64,7 +64,7 @@ class Game(object): return players def start(self): - if self.mode == None or self.mode != "wild": + if self.mode == None or self.mode != "wild" or self.mode != "one": self.deck._fill_classic_() else: self.deck._fill_wild_() diff --git a/results.py b/results.py index 1203154..3f6aab2 100644 --- a/results.py +++ b/results.py @@ -129,6 +129,17 @@ def add_mode_wild(results): ) ) +def add_mode_one(results): + """Change mode to classic""" + results.append( + InlineQueryResultArticle( + "mode_one", + title=_("😐 Saitama mode"), + input_message_content= + InputTextMessageContent(_('One hit Kill? 😐')) + ) + ) + def add_draw(player, results): """Add option to draw""" diff --git a/simple_commands.py b/simple_commands.py index b640141..c81ceac 100644 --- a/simple_commands.py +++ b/simple_commands.py @@ -76,6 +76,7 @@ modes_explanation = ("This UNO bot has three game modes: Classic, Sanic and Wild " 🎻 The Classic mode uses the conventional UNO deck and there is no auto skip.\n" " πŸš€ The Sanic mode uses the conventional UNO deck and the bot automatically skips a player if he/she takes too long to play its turn\n" " πŸ‰ The Wild mode uses a deck with more special cards, less number variety and no auto skip.\n\n" + " 😐 The Saitama mode uses a deck with more special cards, less number variety and no auto skip. But ended with one win.\n\n" "To change the game mode, the GAME CREATOR has to type the bot nickname and a space, just like when playing a card, and all gamemode options should appear.") From 9682b9fbceb16732665b9696b3b01dc20f1c414b Mon Sep 17 00:00:00 2001 From: Pesakitan22 Date: Mon, 16 Apr 2018 16:35:25 +0700 Subject: [PATCH 06/14] new mode one --- bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot.py b/bot.py index 70238a2..046a465 100644 --- a/bot.py +++ b/bot.py @@ -36,7 +36,7 @@ from errors import (NoGameInChatError, LobbyClosedError, AlreadyJoinedError, from internationalization import _, __, user_locale, game_locales from results import (add_call_bluff, add_choose_color, add_draw, add_gameinfo, add_no_game, add_not_started, add_other_cards, add_pass, - add_card, add_mode_classic, add_mode_fast, add_mode_wild) + add_card, add_mode_classic, add_mode_fast, add_mode_wild, add_mode_one) from shared_vars import gm, updater, dispatcher from simple_commands import help_handler from start_bot import start_bot From 0b434636bc64a47facb58f5b4f1da1bd4d177be2 Mon Sep 17 00:00:00 2001 From: Pesakitan22 Date: Tue, 17 Apr 2018 11:15:16 +0700 Subject: [PATCH 07/14] templating --- actions.py | 2 ++ simple_commands.py | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/actions.py b/actions.py index 111e633..aeae24e 100644 --- a/actions.py +++ b/actions.py @@ -115,6 +115,8 @@ def do_play_card(bot, player, result_id): us.first_places += 1 if game.mode == 'one': gm.end_game(chat, user) + send_async(bot, chat.id, + text=__("Game ended!", multi=game.translate)) game.players_won += 1 diff --git a/simple_commands.py b/simple_commands.py index c81ceac..04deb29 100644 --- a/simple_commands.py +++ b/simple_commands.py @@ -31,8 +31,8 @@ help_text = ("Follow these steps:\n\n" " running game with /join\n" "3. After at least two players have joined, start the game with" " /start\n" - "4. Type @unobot into your chat box and hit " - "space, or click the via @unobot text " + "4. Type @xultanbot into your chat box and hit " + "space, or click the via @xultanbot text " "next to messages. You will see your cards (some greyed out), " "any extra options like drawing, and a ? to see the " "current game state. The greyed out cards are those you " @@ -75,8 +75,8 @@ attributions = ("Attributions:\n" modes_explanation = ("This UNO bot has three game modes: Classic, Sanic and Wild.\n\n" " 🎻 The Classic mode uses the conventional UNO deck and there is no auto skip.\n" " πŸš€ The Sanic mode uses the conventional UNO deck and the bot automatically skips a player if he/she takes too long to play its turn\n" - " πŸ‰ The Wild mode uses a deck with more special cards, less number variety and no auto skip.\n\n" - " 😐 The Saitama mode uses a deck with more special cards, less number variety and no auto skip. But ended with one win.\n\n" + " πŸ‰ The Wild mode uses a deck with more special cards, less number variety and no auto skip.\n" + " 😐 The Saitama mode uses a deck with more special cards, less number variety and no auto skip, but ended with one win.\n\n" "To change the game mode, the GAME CREATOR has to type the bot nickname and a space, just like when playing a card, and all gamemode options should appear.") From 89b01069c29514f73c9ca527fa772249d482ca8a Mon Sep 17 00:00:00 2001 From: Pesakitan22 Date: Tue, 17 Apr 2018 11:22:59 +0700 Subject: [PATCH 08/14] templating --- simple_commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simple_commands.py b/simple_commands.py index 04deb29..b864d8d 100644 --- a/simple_commands.py +++ b/simple_commands.py @@ -72,7 +72,7 @@ attributions = ("Attributions:\n" "Originals available on http://game-icons.net\n" "Icons edited by Ι³ick") -modes_explanation = ("This UNO bot has three game modes: Classic, Sanic and Wild.\n\n" +modes_explanation = ("This UNO bot has four game modes: One, Classic, Sanic and Wild.\n\n" " 🎻 The Classic mode uses the conventional UNO deck and there is no auto skip.\n" " πŸš€ The Sanic mode uses the conventional UNO deck and the bot automatically skips a player if he/she takes too long to play its turn\n" " πŸ‰ The Wild mode uses a deck with more special cards, less number variety and no auto skip.\n" From ecae8ab16e9ca7dfd536f8368dca9e7ed114324e Mon Sep 17 00:00:00 2001 From: Pesakitan22 Date: Tue, 17 Apr 2018 11:23:42 +0700 Subject: [PATCH 09/14] templating --- actions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions.py b/actions.py index aeae24e..f00b3ca 100644 --- a/actions.py +++ b/actions.py @@ -116,7 +116,7 @@ def do_play_card(bot, player, result_id): if game.mode == 'one': gm.end_game(chat, user) send_async(bot, chat.id, - text=__("Game ended!", multi=game.translate)) + text=__("Game ended! Flawless Victory!", multi=game.translate)) game.players_won += 1 From 6ad9107443fb8c62ba469e163c572363ffeb66b0 Mon Sep 17 00:00:00 2001 From: Pesakitan22 Date: Wed, 18 Apr 2018 09:44:05 +0700 Subject: [PATCH 10/14] fix stats --- actions.py | 12 ++++++------ game.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/actions.py b/actions.py index f00b3ca..36eee4a 100644 --- a/actions.py +++ b/actions.py @@ -107,19 +107,19 @@ def do_play_card(bot, player, result_id): send_async(bot, chat.id, text=__("{name} won!", multi=game.translate) .format(name=user.first_name)) + send_async(bot, chat.id, + text=__("Game ended! Flawless Victory!", multi=game.translate)) if us.stats: # us.games_played += 1 if game.players_won is 0: us.first_places += 1 - if game.mode == 'one': - gm.end_game(chat, user) - send_async(bot, chat.id, - text=__("Game ended! Flawless Victory!", multi=game.translate)) - - game.players_won += 1 + if game.mode == 'one': + gm.end_game(chat, user) + else: + game.players_won += 1 try: gm.leave_game(user, chat) diff --git a/game.py b/game.py index 5600f96..abf4d6a 100644 --- a/game.py +++ b/game.py @@ -64,7 +64,7 @@ class Game(object): return players def start(self): - if self.mode == None or self.mode != "wild" or self.mode != "one": + if self.mode == None or self.mode == "fast" self.deck._fill_classic_() else: self.deck._fill_wild_() From a464f366ebf7bea4f93b7d0315ba8fbcc841c3f9 Mon Sep 17 00:00:00 2001 From: Pesakitan22 Date: Wed, 18 Apr 2018 09:47:32 +0700 Subject: [PATCH 11/14] fix stats --- game.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/game.py b/game.py index abf4d6a..ca74d43 100644 --- a/game.py +++ b/game.py @@ -64,7 +64,7 @@ class Game(object): return players def start(self): - if self.mode == None or self.mode == "fast" + if self.mode == None or self.mode == 'fast' self.deck._fill_classic_() else: self.deck._fill_wild_() From 10c44d266d95a03a2926b3903d62ec8a28022895 Mon Sep 17 00:00:00 2001 From: Pesakitan22 Date: Wed, 18 Apr 2018 09:48:43 +0700 Subject: [PATCH 12/14] fix stats --- game.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/game.py b/game.py index ca74d43..c863943 100644 --- a/game.py +++ b/game.py @@ -64,7 +64,7 @@ class Game(object): return players def start(self): - if self.mode == None or self.mode == 'fast' + if self.mode == None or self.mode == "wild": self.deck._fill_classic_() else: self.deck._fill_wild_() From c55b4b81ed9d382484eecd8eb18e6489bbefc075 Mon Sep 17 00:00:00 2001 From: Pesakitan22 Date: Wed, 18 Apr 2018 09:59:10 +0700 Subject: [PATCH 13/14] fix stats --- actions.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/actions.py b/actions.py index 36eee4a..dfce4f5 100644 --- a/actions.py +++ b/actions.py @@ -108,7 +108,7 @@ def do_play_card(bot, player, result_id): text=__("{name} won!", multi=game.translate) .format(name=user.first_name)) send_async(bot, chat.id, - text=__("Game ended! Flawless Victory!", multi=game.translate)) + text=__("Game ended! Flawless Victory!")) if us.stats: # us.games_played += 1 @@ -122,7 +122,8 @@ def do_play_card(bot, player, result_id): game.players_won += 1 try: - gm.leave_game(user, chat) + if game.mode != 'one': + gm.leave_game(user, chat) except NotEnoughPlayersError: send_async(bot, chat.id, text=__("Game ended!", multi=game.translate)) From 32b9f4491f34fe7605c3cdcb95832bf830950f5d Mon Sep 17 00:00:00 2001 From: Deni Putra Perdana Date: Sun, 14 Oct 2018 20:52:35 +0700 Subject: [PATCH 14/14] register stat on join --- game_manager.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/game_manager.py b/game_manager.py index a3763e1..b1fa52c 100644 --- a/game_manager.py +++ b/game_manager.py @@ -64,6 +64,9 @@ class GameManager(object): try: us = UserSetting.get(id=user.id) + if not us: + us = UserSetting(id=user.id) + us.games_played += 1 game = self.chatid_games[chat.id][-1] except (KeyError, IndexError):