From e773a7a1ef058db6b03dc15c78c145f7b1444480 Mon Sep 17 00:00:00 2001 From: "Mr.Xia" <1424473282@qq.com> Date: Sun, 5 Apr 2026 21:25:10 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=B5=9B=E9=A9=AC=E6=B8=B8=E6=88=8F?= =?UTF-8?q?=E8=B0=83=E6=95=B4=20-=20=E5=85=81=E8=AE=B8=E8=87=AA=E9=A9=AC?= =?UTF-8?q?=E4=B8=8B=E6=B3=A8=20&=20=E5=8F=96=E6=B6=88=E9=9D=9E=E5=86=A0?= =?UTF-8?q?=E5=86=9B=E5=8F=82=E8=B5=9B=E5=A5=96=E5=8A=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除下注时不能给自己马匹下注的限制 - 非冠军马主不再获得参赛奖励积分(PARTICIPANT_REWARD=0) - 同步更新帮助文本、README文档和config默认值 --- .../plugins/group_horse_racing/README.md | 9 +++++---- .../plugins/group_horse_racing/commands.py | 19 ++----------------- .../plugins/group_horse_racing/config.py | 2 +- 3 files changed, 8 insertions(+), 22 deletions(-) diff --git a/danding_bot/plugins/group_horse_racing/README.md b/danding_bot/plugins/group_horse_racing/README.md index 6baaaef..c09d2a7 100644 --- a/danding_bot/plugins/group_horse_racing/README.md +++ b/danding_bot/plugins/group_horse_racing/README.md @@ -7,7 +7,7 @@ 这是一个完整的群组赛马游戏系统,支持以下核心功能: - **马匹报名**:用户可以报名参加赛马比赛 -- **下注系统**:支持用户对参赛马匹进行下注 +- **下注系统**:支持用户对任意参赛马匹进行下注(含自己的马) - **自动比赛**:基于随机算法的赛马进程模拟 - **积分集成**:与 danding_points 积分系统无缝集成 - **自动撤回**:支持配置消息自动撤回时间 @@ -47,7 +47,7 @@ GROUP_HORSE_RACING_ALLOWED_GROUPS=[] | 配置项 | 默认值 | 说明 | |--------|--------|------| -| `PARTICIPANT_REWARD` | 50 | 参赛者奖励积分 | +| `PARTICIPANT_REWARD` | 0 | 参赛者奖励积分(已禁用) | | `CHAMPION_REWARD` | 200 | 冠军奖励积分 | | `MIN_BET` | 10 | 最小下注积分 | | `MIN_ODDS` | 1.2 | 最小赔率 | @@ -143,12 +143,13 @@ RACE_DB_FILE = "data/group_horse_racing/race.db" 1. **报名阶段** - 用户执行 `/赛马报名` 命令 - 系统检查权限和房间容量(最多8匹马) - - 成功报名后获得参赛奖励 + - 成功报名 2. **下注阶段** - 用户可对参赛马匹进行下注 - 下注金额需满足最小下注要求 - 下注积分从用户账户扣除 + - 可以给自己的马下注 3. **比赛阶段** - 房主执行 `/赛马开赛` 命令 @@ -158,7 +159,7 @@ RACE_DB_FILE = "data/group_horse_racing/race.db" 4. **结算阶段** - 冠军获得冠军奖励 - - 下注冠军的用户获得中奖积分 + - 中奖用户获得下注奖金(下注金额 × 赔率) - 比赛结果保存到数据库 ## 权限控制 diff --git a/danding_bot/plugins/group_horse_racing/commands.py b/danding_bot/plugins/group_horse_racing/commands.py index a04b1f5..67d57a1 100644 --- a/danding_bot/plugins/group_horse_racing/commands.py +++ b/danding_bot/plugins/group_horse_racing/commands.py @@ -153,10 +153,6 @@ def _build_point_changes(room: Room, odds: dict[str, float]) -> tuple[dict[str, if champion: point_changes[champion.owner_id] = point_changes.get(champion.owner_id, 0) + config.CHAMPION_REWARD - for horse in room.horses.values(): - if champion and horse.owner_id != champion.owner_id: - point_changes[horse.owner_id] = point_changes.get(horse.owner_id, 0) + config.PARTICIPANT_REWARD - for bet in room.bets: if bet.horse_name == room.champion_name: payout = int(bet.amount * odds.get(bet.horse_name, config.MIN_ODDS)) @@ -209,11 +205,6 @@ async def settle_race(room: Room) -> RaceResult | None: # Reward champion owner await points_service.reward_champion(champion.owner_id) - # Reward all participants - for horse in room.horses.values(): - if horse.owner_id != champion.owner_id: - await points_service.reward_participant(horse.owner_id) - # Settle bets odds = calculate_odds(room) for bet in room.bets: @@ -453,10 +444,6 @@ async def handle_bet(bot: Bot, event: Event): await bet_cmd.finish(f"马匹序号/名称 \"{horse_selector}\" 不存在") return - if horse.owner_id == user_id: - await bet_cmd.finish("不能给自己的马下注") - return - success, balance = await points_service.spend_bet_points(user_id, amount, f"下注 {_format_horse_label(horse)}") if not success: await bet_cmd.finish(f"积分不足(当前余额:{balance})") @@ -550,7 +537,7 @@ async def handle_help(bot: Bot, event: Event): /赛马报名 <马匹名> - 报名参赛(最多8匹马) /赛马报名 - 复用上一次绑定的马名报名 /赛马取消报名 - 取消报名并退还下注 -/赛马下注 <序号|马匹名> <金额> - 下注(不能给自己的马下注) +/赛马下注 <序号|马匹名> <金额> - 下注 /赛马赔率 - 查看当前赔率和下注池 /赛马开赛 - 开始比赛(至少2匹马) /赛马帮助 - 显示此帮助 @@ -559,11 +546,9 @@ async def handle_help(bot: Bot, event: Event): • 最低下注金额:{config.MIN_BET} 积分 • 参赛马匹上限:8匹 • 开赛要求:至少2匹马报名 -• 不能给自己的马下注 💰 奖励机制: • 冠军马主:获得 {config.CHAMPION_REWARD} 积分 -• 参赛马主:获得 {config.PARTICIPANT_REWARD} 积分 • 下注中奖:下注金额 × 赔率 📊 赔率说明: @@ -573,7 +558,7 @@ async def handle_help(bot: Bot, event: Event): 🎮 游戏流程: 1️⃣ 玩家报名并绑定马匹名 -2️⃣ 玩家可以给其他玩家的马下注 +2️⃣ 玩家可以给任意马匹下注 3️⃣ 满足开赛条件后,任意玩家可开赛 4️⃣ 比赛实时进行,定期播报进度 5️⃣ 比赛结束后结算积分和奖金""" diff --git a/danding_bot/plugins/group_horse_racing/config.py b/danding_bot/plugins/group_horse_racing/config.py index 580b05d..88fd903 100644 --- a/danding_bot/plugins/group_horse_racing/config.py +++ b/danding_bot/plugins/group_horse_racing/config.py @@ -16,7 +16,7 @@ class Config(BaseSettings): ALLOWED_GROUPS: set[int] = Field(default_factory=set) # 奖励配置 - PARTICIPANT_REWARD: int = 50 + PARTICIPANT_REWARD: int = 0 CHAMPION_REWARD: int = 200 MIN_BET: int = 10 MIN_ODDS: float = 1.2