Add comprehensive web interface enhancements and encounter tracking

Major Features Added:
- Complete petdex page showing all available pets with stats, types, evolution info
- Encounter tracking system recording pet discoveries and catch statistics
- Gym badges display on player profiles with victory counts and dates
- Enhanced player profiles with discovery progress and completion percentages

Technical Implementation:
- New /petdex route with rarity-organized pet encyclopedia
- Database encounter tracking with automatic integration into exploration/catch
- Updated webserver.py with encounter data fetching and display
- Fixed battle_system.py syntax error in gym battle completion logic
- Organized project by moving unused bot files to backup_bots/ folder

Database Changes:
- Added player_encounters table for tracking discoveries
- Added methods: record_encounter, get_player_encounters, get_encounter_stats
- Enhanced player profile queries to include gym badges and encounters

Web Interface Updates:
- Petdex page with search stats, rarity grouping, and spawn location info
- Player profiles now show species seen, completion %, gym badges earned
- Encounter section displaying discovered pets with catch statistics
- Updated navigation to include petdex link on main game hub

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
megaproxy 2025-07-14 16:32:25 +01:00
parent bd455f1be5
commit 1ce7158200
7 changed files with 684 additions and 63 deletions

View file

@ -224,74 +224,74 @@ class BattleSystem(BaseModule):
return
defeated_pet = gym_team[current_pet_index]
self.send_message(channel, f"🎉 {nickname}: You defeated {defeated_pet['species_name']}!")
# Award experience for defeating gym pet
await self.award_battle_experience(channel, nickname, player, defeated_pet, "gym")
# Check if there are more pets
if await self.database.advance_gym_battle(player["id"]):
# More pets to fight
next_index = current_pet_index + 1
next_pet = gym_team[next_index]
self.send_message(channel,
f"🥊 {gym_battle['leader_name']} sends out {next_pet['species_name']} (Lv.{next_pet['level']})!")
self.send_message(channel, f"🎉 {nickname}: You defeated {defeated_pet['species_name']}!")
# Start battle with next gym pet
active_pets = await self.database.get_active_pets(player["id"])
player_pet = active_pets[0] # Use first active pet
# Award experience for defeating gym pet
await self.award_battle_experience(channel, nickname, player, defeated_pet, "gym")
# Create gym pet data for battle engine
next_gym_pet_data = {
"species_name": next_pet["species_name"],
"level": next_pet["level"],
"type1": next_pet["type1"],
"type2": next_pet["type2"],
"stats": {
"hp": next_pet["hp"],
"attack": next_pet["attack"],
"defense": next_pet["defense"],
"speed": next_pet["speed"]
# Check if there are more pets
if await self.database.advance_gym_battle(player["id"]):
# More pets to fight
next_index = current_pet_index + 1
next_pet = gym_team[next_index]
self.send_message(channel,
f"🥊 {gym_battle['leader_name']} sends out {next_pet['species_name']} (Lv.{next_pet['level']})!")
# Start battle with next gym pet
active_pets = await self.database.get_active_pets(player["id"])
player_pet = active_pets[0] # Use first active pet
# Create gym pet data for battle engine
next_gym_pet_data = {
"species_name": next_pet["species_name"],
"level": next_pet["level"],
"type1": next_pet["type1"],
"type2": next_pet["type2"],
"stats": {
"hp": next_pet["hp"],
"attack": next_pet["attack"],
"defense": next_pet["defense"],
"speed": next_pet["speed"]
}
}
}
# Start next battle
battle = await self.game_engine.battle_engine.start_battle(player["id"], player_pet, next_gym_pet_data)
self.send_message(channel,
f"⚔️ Your {player_pet['species_name']} (HP: {battle['player_hp']}/{player_pet['max_hp']}) vs {next_pet['species_name']} (HP: {battle['wild_hp']}/{next_pet['hp']})")
# Show available moves
moves_colored = " | ".join([
f"{self.get_move_color(move['type'])}{move['name']}\x0F"
for move in battle["available_moves"]
])
self.send_message(channel, f"🎯 Moves: {moves_colored} | Use !attack <move> or !use <item>")
# Start next battle
battle = await self.game_engine.battle_engine.start_battle(player["id"], player_pet, next_gym_pet_data)
self.send_message(channel,
f"⚔️ Your {player_pet['species_name']} (HP: {battle['player_hp']}/{player_pet['max_hp']}) vs {next_pet['species_name']} (HP: {battle['wild_hp']}/{next_pet['hp']})")
# Show available moves
moves_colored = " | ".join([
f"{self.get_move_color(move['type'])}{move['name']}\x0F"
for move in battle["available_moves"]
])
self.send_message(channel, f"🎯 Moves: {moves_colored} | Use !attack <move> or !use <item>")
else:
# All gym pets defeated - gym victory!
result = await self.database.end_gym_battle(player["id"], victory=True)
self.send_message(channel, f"🏆 {nickname}: You defeated all of {gym_battle['leader_name']}'s pets!")
self.send_message(channel,
f"{gym_battle['badge_icon']} {gym_battle['leader_name']}: \"Impressive! You've earned the {gym_battle['gym_name']} badge!\"")
self.send_message(channel, f"🎉 {nickname} earned the {gym_battle['gym_name']} badge {gym_battle['badge_icon']}!")
# Award rewards based on difficulty
money_reward = 500 + (result["difficulty_level"] * 100)
self.send_message(channel, f"💰 Rewards: ${money_reward} | 🌟 Gym mastery increased!")
else:
# All gym pets defeated - gym victory!
result = await self.database.end_gym_battle(player["id"], victory=True)
# Player lost gym battle
result = await self.database.end_gym_battle(player["id"], victory=False)
self.send_message(channel, f"🏆 {nickname}: You defeated all of {gym_battle['leader_name']}'s pets!")
self.send_message(channel, f"💀 {nickname}: Your pet fainted!")
self.send_message(channel,
f"{gym_battle['badge_icon']} {gym_battle['leader_name']}: \"Impressive! You've earned the {gym_battle['gym_name']} badge!\"")
self.send_message(channel, f"🎉 {nickname} earned the {gym_battle['gym_name']} badge {gym_battle['badge_icon']}!")
# Award rewards based on difficulty
money_reward = 500 + (result["difficulty_level"] * 100)
self.send_message(channel, f"💰 Rewards: ${money_reward} | 🌟 Gym mastery increased!")
else:
# Player lost gym battle
result = await self.database.end_gym_battle(player["id"], victory=False)
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!\"")
self.send_message(channel,
f"💡 {nickname}: Try leveling up your pets or bringing items to heal during battle!")
f"{gym_battle['badge_icon']} {gym_battle['leader_name']}: \"Good battle! Train more and come back stronger!\"")
self.send_message(channel,
f"💡 {nickname}: Try leveling up your pets or bringing items to heal during battle!")
except Exception as e:
self.send_message(channel, f"{nickname}: Gym battle error occurred - please !forfeit and try again")