Implement comprehensive pet healing system with revive items and database support

- Add Revive (50% HP) and Max Revive (100% HP) items to config/items.json
- Extend database schema with fainted_at timestamp for pets table
- Add last_heal_time column to players table for heal command cooldown
- Implement comprehensive pet healing database methods:
  - get_fainted_pets(): Retrieve all fainted pets for a player
  - revive_pet(): Restore fainted pet with specified HP
  - faint_pet(): Mark pet as fainted with timestamp
  - get_pets_for_auto_recovery(): Find pets eligible for 30-minute auto-recovery
  - auto_recover_pet(): Automatically restore pet to 1 HP
  - get_active_pets(): Get active pets excluding fainted ones
  - get_player_pets(): Enhanced to filter out fainted pets when active_only=True
- Update inventory module to handle revive and max_revive effects
- Add proper error handling for cases where no fainted pets exist
- Maintain case-insensitive item usage compatibility

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
megaproxy 2025-07-16 11:32:01 +00:00
parent fca0423c84
commit 72c1098a22
3 changed files with 440 additions and 3 deletions

View file

@ -99,6 +99,41 @@ class Inventory(BaseModule):
self.send_message(channel,
f"🍀 {nickname}: Used {item['name']}! Rare pet encounter rate increased by {effect_value}% for 1 hour!")
elif effect == "revive":
# Handle revive items for fainted pets
fainted_pets = await self.database.get_fainted_pets(player["id"])
if not fainted_pets:
self.send_message(channel, f"{nickname}: You don't have any fainted pets to revive!")
return
# Use the first fainted pet (can be expanded to choose specific pet)
pet = fainted_pets[0]
new_hp = int(pet["max_hp"] * (effect_value / 100.0)) # Convert percentage to HP
# Revive the pet and restore HP
await self.database.revive_pet(pet["id"], new_hp)
self.send_message(channel,
f"💫 {nickname}: Used {item['name']} on {pet['nickname'] or pet['species_name']}! "
f"Revived and restored {new_hp}/{pet['max_hp']} HP!")
elif effect == "max_revive":
# Handle max revive items for fainted pets
fainted_pets = await self.database.get_fainted_pets(player["id"])
if not fainted_pets:
self.send_message(channel, f"{nickname}: You don't have any fainted pets to revive!")
return
# Use the first fainted pet (can be expanded to choose specific pet)
pet = fainted_pets[0]
# Revive the pet and fully restore HP
await self.database.revive_pet(pet["id"], pet["max_hp"])
self.send_message(channel,
f"{nickname}: Used {item['name']} on {pet['nickname'] or pet['species_name']}! "
f"Revived and fully restored HP! ({pet['max_hp']}/{pet['max_hp']})")
elif effect == "money":
# Handle money items (like Coin Pouch)
import random