Add comprehensive startup script validation and enhanced pet system
- Enhanced start_petbot.sh with extensive validation and error checking - Added emoji support to pet species system with database migration - Expanded pet species from 9 to 33 unique pets with balanced spawn rates - Improved database integrity validation and orphaned pet detection - Added comprehensive pre-startup testing and configuration validation - Enhanced locations with diverse species spawning across all areas - Added dual-type pets and rarity-based spawn distribution - Improved startup information display with feature overview - Added background monitoring and validation systems 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
add7731d80
commit
fca0423c84
8 changed files with 640 additions and 81 deletions
|
|
@ -36,10 +36,19 @@ class Database:
|
|||
evolution_level INTEGER,
|
||||
evolution_species_id INTEGER,
|
||||
rarity INTEGER DEFAULT 1,
|
||||
emoji TEXT,
|
||||
FOREIGN KEY (evolution_species_id) REFERENCES pet_species (id)
|
||||
)
|
||||
""")
|
||||
|
||||
# Add emoji column if it doesn't exist (migration)
|
||||
try:
|
||||
await db.execute("ALTER TABLE pet_species ADD COLUMN emoji TEXT")
|
||||
await db.commit()
|
||||
except Exception:
|
||||
# Column already exists or other error, which is fine
|
||||
pass
|
||||
|
||||
await db.execute("""
|
||||
CREATE TABLE IF NOT EXISTS pets (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
|
|
@ -452,7 +461,7 @@ class Database:
|
|||
async with aiosqlite.connect(self.db_path) as db:
|
||||
db.row_factory = aiosqlite.Row
|
||||
query = """
|
||||
SELECT p.*, ps.name as species_name, ps.type1, ps.type2
|
||||
SELECT p.*, ps.name as species_name, ps.type1, ps.type2, ps.emoji
|
||||
FROM pets p
|
||||
JOIN pet_species ps ON p.species_id = ps.id
|
||||
WHERE p.player_id = ?
|
||||
|
|
|
|||
|
|
@ -35,19 +35,28 @@ class GameEngine:
|
|||
species_data = json.load(f)
|
||||
|
||||
async with aiosqlite.connect(self.database.db_path) as db:
|
||||
for species in species_data:
|
||||
await db.execute("""
|
||||
INSERT OR IGNORE INTO pet_species
|
||||
(name, type1, type2, base_hp, base_attack, base_defense,
|
||||
base_speed, evolution_level, rarity)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""", (
|
||||
species["name"], species["type1"], species.get("type2"),
|
||||
species["base_hp"], species["base_attack"], species["base_defense"],
|
||||
species["base_speed"], species.get("evolution_level"),
|
||||
species.get("rarity", 1)
|
||||
))
|
||||
await db.commit()
|
||||
# Check if species already exist to avoid re-inserting and changing IDs
|
||||
cursor = await db.execute("SELECT COUNT(*) FROM pet_species")
|
||||
existing_count = (await cursor.fetchone())[0]
|
||||
|
||||
if existing_count == 0:
|
||||
# Only insert if no species exist to avoid ID conflicts
|
||||
for species in species_data:
|
||||
await db.execute("""
|
||||
INSERT OR IGNORE INTO pet_species
|
||||
(name, type1, type2, base_hp, base_attack, base_defense,
|
||||
base_speed, evolution_level, rarity, emoji)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""", (
|
||||
species["name"], species["type1"], species.get("type2"),
|
||||
species["base_hp"], species["base_attack"], species["base_defense"],
|
||||
species["base_speed"], species.get("evolution_level"),
|
||||
species.get("rarity", 1), species.get("emoji", "🐾")
|
||||
))
|
||||
await db.commit()
|
||||
print(f"✅ Loaded {len(species_data)} pet species into database")
|
||||
else:
|
||||
print(f"✅ Found {existing_count} existing pet species - skipping reload to preserve IDs")
|
||||
|
||||
except FileNotFoundError:
|
||||
await self.create_default_species()
|
||||
|
|
@ -664,6 +673,38 @@ class GameEngine:
|
|||
except Exception as e:
|
||||
print(f"Error checking expired weather: {e}")
|
||||
|
||||
async def get_pet_emoji(self, species_name: str) -> str:
|
||||
"""Get emoji for a pet species"""
|
||||
try:
|
||||
async with aiosqlite.connect(self.database.db_path) as db:
|
||||
cursor = await db.execute(
|
||||
"SELECT emoji FROM pet_species WHERE name = ?",
|
||||
(species_name,)
|
||||
)
|
||||
row = await cursor.fetchone()
|
||||
return row[0] if row and row[0] else "🐾"
|
||||
except Exception:
|
||||
return "🐾" # Default emoji if something goes wrong
|
||||
|
||||
def format_pet_name_with_emoji(self, pet_name: str, emoji: str = None, species_name: str = None) -> str:
|
||||
"""Format pet name with emoji for display in IRC or web
|
||||
|
||||
Args:
|
||||
pet_name: The pet's nickname or species name
|
||||
emoji: Optional emoji to use (if None, will look up by species_name)
|
||||
species_name: Species name for emoji lookup if emoji not provided
|
||||
|
||||
Returns:
|
||||
Formatted string like "🔥 Flamey" or "🐉 Infernowyrm"
|
||||
"""
|
||||
if emoji:
|
||||
return f"{emoji} {pet_name}"
|
||||
elif species_name:
|
||||
# This would need to be async, but for IRC we can use sync fallback
|
||||
return f"🐾 {pet_name}" # Use default for now, can be enhanced later
|
||||
else:
|
||||
return f"🐾 {pet_name}"
|
||||
|
||||
async def shutdown(self):
|
||||
"""Gracefully shutdown the game engine"""
|
||||
print("🔄 Shutting down game engine...")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue