Pre-menu-integration snapshot: combat, crafting, status effects, gamedata updates
This commit is contained in:
@@ -50,6 +50,14 @@ async def equip_item(
|
||||
player_id = current_user['id']
|
||||
locale = request.headers.get('Accept-Language', 'en')
|
||||
|
||||
# Check if in combat
|
||||
in_combat = await db.get_active_combat(player_id)
|
||||
if in_combat:
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
detail=get_game_message('cannot_equip_combat', locale)
|
||||
)
|
||||
|
||||
# Get the inventory item
|
||||
inv_item = await db.get_inventory_item_by_id(equip_req.inventory_id)
|
||||
if not inv_item or inv_item['character_id'] != player_id:
|
||||
@@ -156,6 +164,14 @@ async def unequip_item(
|
||||
player_id = current_user['id']
|
||||
locale = request.headers.get('Accept-Language', 'en')
|
||||
|
||||
# Check if in combat
|
||||
in_combat = await db.get_active_combat(player_id)
|
||||
if in_combat:
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
detail=get_game_message('cannot_equip_combat', locale)
|
||||
)
|
||||
|
||||
# Check if slot is valid
|
||||
valid_slots = ['head', 'torso', 'legs', 'feet', 'weapon', 'offhand', 'backpack']
|
||||
if unequip_req.slot not in valid_slots:
|
||||
@@ -412,7 +428,7 @@ async def repair_item(
|
||||
|
||||
|
||||
|
||||
async def reduce_armor_durability(player_id: int, damage_taken: int) -> tuple:
|
||||
async def reduce_armor_durability(player_id: int, damage_taken: int, is_defending: bool = False) -> tuple:
|
||||
"""
|
||||
Reduce durability of equipped armor pieces when taking damage.
|
||||
Formula: durability_loss = max(1, (damage_taken / armor_value) * base_reduction_rate)
|
||||
@@ -452,7 +468,7 @@ async def reduce_armor_durability(player_id: int, damage_taken: int) -> tuple:
|
||||
|
||||
# Calculate durability loss for each armor piece
|
||||
# Balanced formula: armor should last many combats (10-20+ hits for low tier)
|
||||
base_reduction_rate = 0.1 # Reduced from 0.5 to make armor more durable
|
||||
base_reduction_rate = 0.2 if is_defending else 0.1 # Reduced from 0.5 to make armor more durable
|
||||
broken_armor = []
|
||||
|
||||
for armor in equipped_armor:
|
||||
|
||||
Reference in New Issue
Block a user