@@ -176,6 +176,16 @@ def play_game(self, msg)-> tuple:
176176 :param msg:
177177 :return:
178178 """
179+ real_msg = msg .text .split ()
180+ if real_msg [len (real_msg ) - 1 ] == "石头" or real_msg [len (real_msg ) - 1 ] == "剪刀" \
181+ or real_msg [len (real_msg ) - 1 ] == "布" :
182+ game = RspGame (1 )
183+ game .start (msg .member .name )
184+ cancel , result , pic = game .play (msg )
185+ return 'both' , pic , result
186+ else :
187+ return empty_result
188+ """
179189 group_id = msg.member.group.puid
180190 user_id = msg.member.puid
181191 player_map = self.rsp_game_player_map
@@ -201,7 +211,7 @@ def play_game(self, msg)-> tuple:
201211 typ, content1, content2 = self.finger_guessing_game(msg) # 猜拳游戏
202212 if typ == 'text':
203213 return typ, content1, content2
204- return empty_result
214+ return empty_result"""
205215
206216 def draw_lots (self , msg )-> tuple :
207217 real_msg = msg .text .split ()
@@ -287,7 +297,7 @@ def extra(self, msg)-> tuple:
287297 "- 超越猜拳\n " + \
288298 "- 村头留言板\n " + \
289299 "- 超越抽签\n " + \
290- "- 成语接龙\n " + \
300+ "- 成语接龙\n "
291301
292302 return 'text' , payload , ''
293303 if real_msg [len (real_msg ) - 1 ] == "投票" :
@@ -339,17 +349,34 @@ def handle_group_msg(self, msg)-> tuple:
339349 typ , content1 , content2 = self .play_game (msg ) # 玩游戏,高优先级,内部存在拦截其他回复
340350 if typ :
341351 self .log .info (content1 )
342- if "游戏结束,恭喜你赢了" in content2 :
343- from_puid = self .bot .self .puid
344- print (from_puid )
345- to = msg .member
346- result = self .user .transfer (from_puid , to .puid , 5 , self .api_key )
347- if result ["status" ] == "success" :
348- payload = "奖励给 " + to .name + " 3 个超越积分!"
349- else :
350- payload = "但是我没钱啦~"
352+ user_puid = msg .member .puid
353+ bot_id = self .bot .self .puid
354+ user_balance = self .user .get_balance_by_puid (user_puid )
355+ bot_balance = self .user .get_balance_by_puid (bot_id )
356+ if user_balance < 3 :
357+ payload = " 由于你余额不足 3 积分,所以本次游戏没有奖惩哦~"
358+ elif bot_balance < 3 :
359+ payload = " 超越宝宝的钱包瘪了,所以本次游戏没有奖惩哦~"
351360 else :
352- payload = ""
361+ if "游戏结束,恭喜你赢了" in content2 :
362+ from_puid = bot_id
363+ print (from_puid )
364+ to_puid = user_puid
365+ result = self .user .transfer (from_puid , to_puid , 3 , self .api_key )
366+ if result ["status" ] == "success" :
367+ payload = " 奖励给 " + msg .member .name + " 3 个超越积分!"
368+ else :
369+ payload = " 但是我没钱啦~"
370+ elif "你输了" in content2 :
371+ from_puid = user_puid
372+ to_puid = bot_id
373+ result = self .user .transfer (from_puid , to_puid , 3 , self .api_key )
374+ if result ["status" ] == "success" :
375+ payload = " 扣除 " + msg .member .name + " 3 个超越积分!"
376+ else :
377+ payload = " 你钱不够,接下来的游戏会没有奖励哦~"
378+ else :
379+ payload = ""
353380 return typ , content1 , content2 + payload
354381 typ , content1 , content2 = self .draw_lots (msg ) # 抽签
355382 if typ :
0 commit comments