From 581a516610b9d5b36b25b75b760c8ac48281aa3f Mon Sep 17 00:00:00 2001 From: ninemine <1371605831@qq.com> Date: Wed, 29 Oct 2025 12:56:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E4=BF=AE=E5=A4=8D=E7=A7=AF?= =?UTF-8?q?=E5=88=86=E7=B3=BB=E7=BB=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- games/alchemy.py | 21 +++++---------------- games/base.py | 5 ----- games/gift.py | 32 ++++++++++++++------------------ games/points.py | 6 +++--- 4 files changed, 22 insertions(+), 42 deletions(-) diff --git a/games/alchemy.py b/games/alchemy.py index 81eb145..8fffbcd 100644 --- a/games/alchemy.py +++ b/games/alchemy.py @@ -90,16 +90,9 @@ class AlchemyGame(BaseGame): _, args = CommandParser.extract_command_args(command) args = args.strip().lower() - # 炼金统计 - if args in ['stats', '统计', '记录']: - return self._get_alchemy_stats(user_id) - - # 炼金记录 - elif args in ['records', '历史', 'log']: - return self._get_alchemy_records(user_id) # 炼金说明 - elif args in ['help', '帮助', 'info']: + if args in ['help', '帮助', 'info']: return self._get_alchemy_help() # 默认:炼金抽奖 @@ -129,8 +122,8 @@ class AlchemyGame(BaseGame): """ # 检查用户积分是否足够 user_points = self.db.get_user_points(user_id) - if user_points['available_points'] < cost_points: - return f"❌ 积分不足!需要 {cost_points} 积分,当前可用 {user_points['available_points']} 积分" + if user_points['points'] < cost_points: + return f"❌ 积分不足!需要 {cost_points} 积分,当前可用 {user_points['points']} 积分" # 选择奖品池 if cost_points == 10: @@ -158,11 +151,7 @@ class AlchemyGame(BaseGame): penalty_points = abs(reward['value']) self.db.consume_points(user_id, penalty_points, "alchemy", f"炼金失败") - # 记录炼金抽奖 - self.db.add_alchemy_record( - user_id, cost_points, reward['type'], - reward['value'], reward['description'] - ) + # 炼金系统已简化,不再记录历史 # 获取更新后的积分信息 updated_points = self.db.get_user_points(user_id) @@ -190,7 +179,7 @@ class AlchemyGame(BaseGame): else: text += f"**获得奖励**:{reward['description']}\n\n" - text += f"**当前积分**:{updated_points['available_points']} 分\n\n" + text += f"**当前积分**:{updated_points['points']} 分\n\n" text += "---\n\n" text += "💡 提示:炼金有风险,投资需谨慎!" diff --git a/games/base.py b/games/base.py index fd3e4ad..52be0b8 100644 --- a/games/base.py +++ b/games/base.py @@ -95,16 +95,11 @@ def get_help_message() -> str: - `.炼金` - 消耗10积分进行炼金 - `.alchemy 20` - 消耗20积分进行炼金 - `.alchemy 50` - 消耗50积分进行炼金 -- `.alchemy stats` - 查看炼金统计 -- `.alchemy records` - 查看炼金记录 ### 🎁 积分赠送系统 - `.gift <用户ID> <积分数量> [消息]` - 赠送积分 - `.赠送 <用户ID> <积分数量> [消息]` - 赠送积分 - `.送 <用户ID> <积分数量> [消息]` - 赠送积分 -- `.gift stats` - 查看赠送统计 -- `.gift sent` - 查看发送记录 -- `.gift received` - 查看接收记录 ### 其他 - `.help` - 显示帮助 diff --git a/games/gift.py b/games/gift.py index f4d8578..9152864 100644 --- a/games/gift.py +++ b/games/gift.py @@ -32,20 +32,9 @@ class GiftGame(BaseGame): _, args = CommandParser.extract_command_args(command) args = args.strip() - # 赠送统计 - if args in ['stats', '统计']: - return self._get_gift_stats(user_id) - - # 发送记录 - elif args in ['sent', '发送', '送出']: - return self._get_gift_records_sent(user_id) - - # 接收记录 - elif args in ['received', '接收', '收到']: - return self._get_gift_records_received(user_id) # 赠送帮助 - elif args in ['help', '帮助']: + if args in ['help', '帮助']: return self._get_gift_help() # 默认:执行赠送 @@ -89,11 +78,18 @@ class GiftGame(BaseGame): if sender_id == receiver_id: return "❌ 不能赠送积分给自己!" - # 执行赠送 - if self.db.send_gift(sender_id, receiver_id, points, message): + # 检查赠送者积分是否足够 + sender_points = self.db.get_user_points(sender_id) + if sender_points['points'] < points: + return f"❌ 积分不足!需要 {points} 积分,当前可用 {sender_points['points']} 积分" + + # 执行赠送(消费赠送者积分,增加接收者积分) + if (self.db.consume_points(sender_id, points, "gift_send", f"赠送积分给用户{receiver_id}") and + self.db.add_points(receiver_id, points, "gift_receive", f"收到用户{sender_id}的积分赠送")): + # 获取更新后的积分信息 - sender_points = self.db.get_user_points(sender_id) - receiver_points = self.db.get_user_points(receiver_id) + sender_points_after = self.db.get_user_points(sender_id) + receiver_points_after = self.db.get_user_points(receiver_id) text = f"## 🎁 积分赠送成功!\n\n" text += f"**赠送者**:用户{sender_id}\n\n" @@ -103,8 +99,8 @@ class GiftGame(BaseGame): if message: text += f"**附赠消息**:{message}\n\n" - text += f"**赠送者剩余积分**:{sender_points['available_points']} 分\n\n" - text += f"**接收者当前积分**:{receiver_points['available_points']} 分\n\n" + text += f"**赠送者剩余积分**:{sender_points_after['points']} 分\n\n" + text += f"**接收者当前积分**:{receiver_points_after['points']} 分\n\n" text += "---\n\n" text += "💝 感谢您的慷慨赠送!" diff --git a/games/points.py b/games/points.py index e5dc958..8cc2d9d 100644 --- a/games/points.py +++ b/games/points.py @@ -60,7 +60,7 @@ class PointsGame(BaseGame): 签到结果消息 """ # 固定签到积分 - checkin_points = 10 + checkin_points = 100 # 检查是否已签到 today = datetime.now().strftime('%Y-%m-%d') @@ -150,8 +150,8 @@ class PointsGame(BaseGame): Returns: 获得的积分数量 """ - # 随机积分范围:1-20分 - points = random.randint(1, 20) + # 随机积分范围:50-200分 + points = random.randint(50, 200) if self.db.add_points(user_id, points, "fortune", "运势奖励"): logger.info(f"用户 {user_id} 通过运势获得 {points} 积分")