Integrate pet fainting tracking into battle system

- Update wild battle defeat handling to mark pets as fainted
- Update gym battle defeat handling to mark pets as fainted
- Add database faint_pet() calls when pets lose battles
- Ensure fainted pets are properly tracked with timestamps
- Both wild and gym battles now consistently handle pet fainting
- Defeated pets are immediately marked as fainted in database
- Maintains existing battle flow while adding fainting mechanics

🤖 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:38 +00:00
parent d758d6b924
commit a333306ad3

View file

@ -148,6 +148,12 @@ class BattleSystem(BaseModule):
del self.bot.active_encounters[player["id"]]
else:
self.send_message(channel, f"💀 {nickname}: Your pet fainted! You lost the battle...")
# Mark pet as fainted in database
pets = await self.database.get_player_pets(player["id"], active_only=True)
if pets:
await self.database.faint_pet(pets[0]["id"])
# Remove encounter
if player["id"] in self.bot.active_encounters:
del self.bot.active_encounters[player["id"]]
@ -293,6 +299,11 @@ class BattleSystem(BaseModule):
# Player lost gym battle
result = await self.database.end_gym_battle(player["id"], victory=False)
# Mark pet as fainted in database
pets = await self.database.get_player_pets(player["id"], active_only=True)
if pets:
await self.database.faint_pet(pets[0]["id"])
self.send_message(channel, f"💀 {nickname}: Your pet fainted!")
self.send_message(channel,
f"{gym_battle['badge_icon']} {gym_battle['leader_name']}: \"Good battle! Train more and come back stronger!\"")