修复冒险模式使用食物的相关错误

This commit is contained in:
2025-11-12 23:49:39 +08:00
parent 7332141a92
commit 90c2fa79cb
2 changed files with 50 additions and 8 deletions

View File

@@ -533,9 +533,9 @@ class CombatService:
recommended_food = math.ceil(stage_time / food_support_time)
# 如果没有提供食物,给出提示但允许继续
if len(food_items) == 0:
msg = f" 未使用食物。推荐使用 {recommended_food} 个果酒以获得buff加成"
return True, msg, recommended_food
#if len(food_items) == 0:
# msg = f" 未使用食物。推荐使用 {recommended_food} 个果酒以获得buff加成"
# return True, msg, recommended_food
return True, "", recommended_food
@@ -696,9 +696,9 @@ class CombatService:
# 验证拥有
user_items = backpack.get_user_items(user_id)
for food_id, count in food_count.items():
owned = sum(1 for item in user_items if item.item_id == food_id)
owned = sum(item.quantity for item in user_items if item.item_id == food_id)
if owned < count:
return False, f"{food_id} 数量不足,需要 {count} ", None
return False, f"{food_id} 数量不足,需要 {count - owned} 个, 当前只有{owned}", None
# 消耗食物
for food_id, count in food_count.items():