diff --git a/danding_bot/plugins/group_horse_racing/commands.py b/danding_bot/plugins/group_horse_racing/commands.py index f4e3890..2a53571 100644 --- a/danding_bot/plugins/group_horse_racing/commands.py +++ b/danding_bot/plugins/group_horse_racing/commands.py @@ -146,6 +146,10 @@ def _describe_points_delta(delta: int) -> str: def _build_point_changes(room: Room, odds: dict[str, float]) -> tuple[dict[str, int], dict[str, str]]: point_changes: dict[str, int] = {} + # Participation reward for all horse owners + for horse in room.horses.values(): + point_changes[horse.owner_id] = point_changes.get(horse.owner_id, 0) + config.PARTICIPANT_REWARD + for bet in room.bets: point_changes[bet.user_id] = point_changes.get(bet.user_id, 0) - bet.amount @@ -202,6 +206,10 @@ async def settle_race(room: Room) -> RaceResult | None: if not champion: return None + # Reward all participants + for horse in room.horses.values(): + await points_service.reward_participant(horse.owner_id) + # Reward champion owner await points_service.reward_champion(champion.owner_id) diff --git a/danding_bot/plugins/group_horse_racing/config.py b/danding_bot/plugins/group_horse_racing/config.py index 580b05d..578cf7b 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 = 20 CHAMPION_REWARD: int = 200 MIN_BET: int = 10 MIN_ODDS: float = 1.2 diff --git a/danding_bot/plugins/group_horse_racing/race_engine.py b/danding_bot/plugins/group_horse_racing/race_engine.py index 8d57170..9b8f67d 100644 --- a/danding_bot/plugins/group_horse_racing/race_engine.py +++ b/danding_bot/plugins/group_horse_racing/race_engine.py @@ -58,10 +58,21 @@ class RaceEngine: lines = [f"【第{room.tick_count}回合】"] sorted_horses = sorted(room.horses.values(), key=lambda h: h.index) + # Calculate max display width for name alignment + # Each CJK/fullwidth char counts as 2, others as 1 + def _display_width(s: str) -> int: + w = 0 + for ch in s: + w += 2 if '\u4e00' <= ch <= '\u9fff' or '\u3000' <= ch <= '\u303f' or '\uff00' <= ch <= '\uffef' else 1 + return w + + max_name_width = max(_display_width(h.name) for h in sorted_horses) + for horse in sorted_horses: progress = min(horse.position / distance, 1.0) filled = int(progress * bar_width) bar = "█" * filled + "░" * (bar_width - filled) - lines.append(f" {horse.index:02d}号 {horse.name} |{bar}| {horse.position:.1f}m") + pad = " " * (max_name_width - _display_width(horse.name)) + lines.append(f" {horse.index:02d}号 {horse.name}{pad} |{bar}| {horse.position:.1f}m") return "\n".join(lines)