Update
This commit is contained in:
@@ -391,3 +391,36 @@ async def consume_tool_durability(user_id: int, tools: list, inventory: list, it
|
||||
await db.decrease_unique_item_durability(tool['unique_item_id'], durability_cost)
|
||||
|
||||
return True, "", consumed_tools
|
||||
|
||||
|
||||
async def enrich_character_data(char: Dict[str, Any], items_manager: ItemsManager) -> Dict[str, Any]:
|
||||
"""
|
||||
Add calculated stats (weight, volume) to character data.
|
||||
"""
|
||||
# Calculate weight and volume
|
||||
inventory = await db.get_inventory(char['id'])
|
||||
current_weight, max_weight, current_volume, max_volume = await calculate_player_capacity(inventory, items_manager)
|
||||
|
||||
return {
|
||||
"id": char["id"],
|
||||
"name": char["name"],
|
||||
"level": char["level"],
|
||||
"xp": char["xp"],
|
||||
"hp": char["hp"],
|
||||
"max_hp": char["max_hp"],
|
||||
"stamina": char["stamina"],
|
||||
"max_stamina": char["max_stamina"],
|
||||
"strength": char["strength"],
|
||||
"agility": char["agility"],
|
||||
"endurance": char["endurance"],
|
||||
"intellect": char["intellect"],
|
||||
"location_id": char["location_id"],
|
||||
"avatar_data": char.get("avatar_data"),
|
||||
"last_played_at": char.get("last_played_at"),
|
||||
"created_at": char.get("created_at"),
|
||||
# Add calculated capacity
|
||||
"weight": round(current_weight, 1),
|
||||
"max_weight": round(max_weight, 1),
|
||||
"volume": round(current_volume, 1),
|
||||
"max_volume": round(max_volume, 1),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user