Apply visual HP bars to all combat displays
- Update combat_handlers.py to show visual enemy and player HP bars - Update action_handlers.py combat encounters with progress bars - Update combat.py attack results with visual HP displays - Add UI_EXAMPLES.md with before/after comparisons - All combat displays now use format_stat_bar() for consistency
This commit is contained in:
@@ -8,6 +8,7 @@ import random
|
||||
from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup
|
||||
from telegram.ext import ContextTypes
|
||||
from . import database, keyboards, logic
|
||||
from .utils import format_stat_bar
|
||||
from data.world_loader import game_world
|
||||
from data.items import ITEMS
|
||||
|
||||
@@ -20,8 +21,6 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
async def get_player_status_text(telegram_id: int) -> str:
|
||||
"""Generate player status text with location and stats."""
|
||||
from .utils import format_stat_bar
|
||||
|
||||
player = await database.get_player(telegram_id)
|
||||
if not player:
|
||||
return "Could not find player data."
|
||||
@@ -124,8 +123,8 @@ async def handle_attack_wandering(query, user_id: int, player: dict, data: list)
|
||||
npc_def = NPCS.get(npc_id)
|
||||
message = f"⚔️ You engage the {npc_def.emoji} {npc_def.name}!\n\n"
|
||||
message += f"{npc_def.description}\n\n"
|
||||
message += f"{npc_def.emoji} Enemy HP: {combat_data['npc_hp']}/{combat_data['npc_max_hp']}\n"
|
||||
message += f"❤️ Your HP: {player['hp']}/{player['max_hp']}\n\n"
|
||||
message += format_stat_bar(f"{npc_def.emoji} Enemy HP", "", combat_data['npc_hp'], combat_data['npc_max_hp']) + "\n"
|
||||
message += format_stat_bar("Your HP", "❤️", player['hp'], player['max_hp']) + "\n\n"
|
||||
message += "🎯 Your turn! What will you do?"
|
||||
|
||||
keyboard = await keyboards.combat_keyboard(user_id)
|
||||
@@ -343,8 +342,8 @@ async def handle_move(query, user_id: int, player: dict, data: list):
|
||||
npc_def = NPCS.get(npc_id)
|
||||
message = f"⚠️ A {npc_def.emoji} {npc_def.name} appears!\n\n"
|
||||
message += f"{npc_def.description}\n\n"
|
||||
message += f"{npc_def.emoji} Enemy HP: {combat_data['npc_hp']}/{combat_data['npc_max_hp']}\n"
|
||||
message += f"❤️ Your HP: {player['hp']}/{player['max_hp']}\n\n"
|
||||
message += format_stat_bar(f"{npc_def.emoji} Enemy HP", "", combat_data['npc_hp'], combat_data['npc_max_hp']) + "\n"
|
||||
message += format_stat_bar("Your HP", "❤️", player['hp'], player['max_hp']) + "\n\n"
|
||||
message += "🎯 Your turn! What will you do?"
|
||||
|
||||
keyboard = await keyboards.combat_keyboard(user_id)
|
||||
|
||||
Reference in New Issue
Block a user