From bb66ce364f26495414a2db376e4ebd4ba1651fa9 Mon Sep 17 00:00:00 2001 From: Jerry Date: Mon, 21 Oct 2019 16:57:09 +0800 Subject: [PATCH] fix 2 bugs: gen_statistics called multiple times, dist_cards accepts values too large --- cards.py | 4 +++- mscore.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cards.py b/cards.py index d3bcc8b..73f8b8a 100644 --- a/cards.py +++ b/cards.py @@ -53,7 +53,8 @@ def getperm(update, context): else: tuser = from_user tplayer = get_player(int(tuser.id)) - update.message.reply_text(f"{display_username(tuser)} 等级为 {tplayer.permission}", + update.message.reply_text((f"{display_username(tuser)} 等级为 {tplayer.permission}\n" + f"口袋里有 {tplayer.immunity_cards} 张免疫卡"), parse_mode="Markdown") @run_async @@ -235,6 +236,7 @@ def dist_cards(update, context): (cards, damount) = [int(a) for a in context.args] assert (cards > 0 and damount > 0) fplayer = get_player(int(from_user.id)) + assert fplayer.immunity_cards >= cards fplayer.immunity_cards -= cards fplayer.save() red_packets = context.chat_data.setdefault('red_packets', dict()) diff --git a/mscore.py b/mscore.py index 4540b8e..035b90e 100644 --- a/mscore.py +++ b/mscore.py @@ -152,7 +152,7 @@ class Board(): self.__open(row, col) def gen_statistics(self): - if self.__op != 0: + if self.__3bv != 0: return (self.__op, self.__is, self.__3bv) self.__visited = np.zeros((self.height, self.width), dtype=np.int8) def scan_open(row, col):