fix 2 bugs: gen_statistics called multiple times, dist_cards accepts values too large

This commit is contained in:
JerryXiao 2019-10-21 16:57:09 +08:00
parent 5f0a45583f
commit bb66ce364f
Signed by: Jerry
GPG key ID: 9D9CE43650FF2BAA
2 changed files with 4 additions and 2 deletions

View file

@ -53,7 +53,8 @@ def getperm(update, context):
else: else:
tuser = from_user tuser = from_user
tplayer = get_player(int(tuser.id)) 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") parse_mode="Markdown")
@run_async @run_async
@ -235,6 +236,7 @@ def dist_cards(update, context):
(cards, damount) = [int(a) for a in context.args] (cards, damount) = [int(a) for a in context.args]
assert (cards > 0 and damount > 0) assert (cards > 0 and damount > 0)
fplayer = get_player(int(from_user.id)) fplayer = get_player(int(from_user.id))
assert fplayer.immunity_cards >= cards
fplayer.immunity_cards -= cards fplayer.immunity_cards -= cards
fplayer.save() fplayer.save()
red_packets = context.chat_data.setdefault('red_packets', dict()) red_packets = context.chat_data.setdefault('red_packets', dict())

View file

@ -152,7 +152,7 @@ class Board():
self.__open(row, col) self.__open(row, col)
def gen_statistics(self): def gen_statistics(self):
if self.__op != 0: if self.__3bv != 0:
return (self.__op, self.__is, self.__3bv) return (self.__op, self.__is, self.__3bv)
self.__visited = np.zeros((self.height, self.width), dtype=np.int8) self.__visited = np.zeros((self.height, self.width), dtype=np.int8)
def scan_open(row, col): def scan_open(row, col):