What a mess

This commit is contained in:
Joan
2025-11-07 15:27:13 +01:00
parent 0b79b3ae59
commit 33cc9586c2
130 changed files with 29819 additions and 1175 deletions

View File

@@ -17,12 +17,13 @@ async def move_keyboard(current_location_id: str, player_id: int) -> InlineKeybo
[ Other exits (inside, down, etc.) ]
[ Back ]
"""
from bot import database, logic
from bot import logic
from bot.api_client import api_client
keyboard = []
location = game_world.get_location(current_location_id)
player = await database.get_player(player_id)
inventory = await database.get_inventory(player_id)
player = await api_client.get_player(player_id)
inventory = await api_client.get_inventory(player_id)
if location and player:
# Dictionary to hold direction buttons
@@ -157,7 +158,7 @@ async def move_keyboard(current_location_id: str, player_id: int) -> InlineKeybo
return InlineKeyboardMarkup(keyboard)
async def inspect_keyboard(location_id: str, dropped_items: list, wandering_enemies: list = None) -> InlineKeyboardMarkup:
from bot import database
from bot.api_client import api_client
from data.npcs import NPCS
keyboard = []
@@ -191,7 +192,7 @@ async def inspect_keyboard(location_id: str, dropped_items: list, wandering_enem
has_available_action = False
for action_id in interactable.actions.keys():
cooldown_key = f"{instance_id}:{action_id}"
if await database.get_cooldown(cooldown_key) == 0:
if await api_client.get_cooldown(cooldown_key) == 0:
has_available_action = True
break
if not has_available_action and len(interactable.actions) > 0:
@@ -218,7 +219,7 @@ async def inspect_keyboard(location_id: str, dropped_items: list, wandering_enem
keyboard.append(row)
# Show player corpse bags
player_corpses = await database.get_player_corpses_in_location(location_id)
player_corpses = await api_client.get_player_corpses_in_location(location_id)
if player_corpses:
keyboard.append([InlineKeyboardButton("--- Fallen survivors ---", callback_data="no_op")])
row = []
@@ -235,7 +236,7 @@ async def inspect_keyboard(location_id: str, dropped_items: list, wandering_enem
keyboard.append(row)
# Show NPC corpses
npc_corpses = await database.get_npc_corpses_in_location(location_id)
npc_corpses = await api_client.get_npc_corpses_in_location(location_id)
if npc_corpses:
if not player_corpses: # Only add separator if not already added
keyboard.append([InlineKeyboardButton("--- Corpses ---", callback_data="no_op")])
@@ -308,7 +309,7 @@ def pickup_options_keyboard(item_id: int, item_name: str, quantity: int) -> Inli
return InlineKeyboardMarkup(keyboard)
async def actions_keyboard(location_id: str, instance_id: str) -> InlineKeyboardMarkup:
from bot import database
from bot.api_client import api_client
keyboard = []
location = game_world.get_location(location_id)
@@ -318,7 +319,7 @@ async def actions_keyboard(location_id: str, instance_id: str) -> InlineKeyboard
if interactable:
for action_id, action in interactable.actions.items():
cooldown_key = f"{instance_id}:{action_id}"
cooldown = await database.get_cooldown(cooldown_key)
cooldown = await api_client.get_cooldown(cooldown_key)
label = action.label
# Add stamina cost to the label
if action.stamina_cost > 0:
@@ -487,7 +488,7 @@ def inventory_item_actions_keyboard(item_db_id: int, item_def: dict, is_equipped
async def combat_keyboard(player_id: int) -> InlineKeyboardMarkup:
"""Create combat action keyboard."""
from bot import database
from bot.api_client import api_client
keyboard = []
# Attack option
@@ -497,20 +498,23 @@ async def combat_keyboard(player_id: int) -> InlineKeyboardMarkup:
keyboard.append([InlineKeyboardButton("🏃 Try to Flee", callback_data="combat_flee")])
# Use item option (show consumables)
inventory_items = await database.get_inventory(player_id)
inventory_items = await api_client.get_inventory(player_id)
consumables = [item for item in inventory_items if ITEMS.get(item['item_id'], {}).get('type') == 'consumable']
if consumables:
keyboard.append([InlineKeyboardButton("💊 Use Item", callback_data="combat_use_item_menu")])
# Profile button (no effect on turn, just info)
keyboard.append([InlineKeyboardButton("👤 Profile", callback_data="profile")])
return InlineKeyboardMarkup(keyboard)
async def combat_items_keyboard(player_id: int) -> InlineKeyboardMarkup:
"""Show consumable items during combat."""
from bot import database
from bot.api_client import api_client
keyboard = []
inventory_items = await database.get_inventory(player_id)
inventory_items = await api_client.get_inventory(player_id)
consumables = [item for item in inventory_items if ITEMS.get(item['item_id'], {}).get('type') == 'consumable']
if consumables: