🎮 Features implemented: - Pokemon-style pet collection and battles - Multi-location exploration system - Dynamic weather with background updates - Achievement system with location unlocks - Web dashboard for player stats - Modular command system - Async database with SQLite - PM flood prevention - Persistent player data 🌤️ Weather System: - 6 weather types with spawn modifiers - 30min-3hour dynamic durations - Background task for automatic updates - Location-specific weather patterns 🐛 Recent Bug Fixes: - Database persistence on restart - Player page SQLite row conversion - Achievement count calculations - Travel requirement messages - Battle move color coding - Locations page display 🔧 Generated with Claude Code 🤖 Co-Authored-By: Claude <noreply@anthropic.com>
85 lines
No EOL
2.8 KiB
Python
Executable file
85 lines
No EOL
2.8 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
"""
|
|
Reset Player Database Script
|
|
Clears all player data for a fresh start while preserving game data (species, locations, etc.)
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
import asyncio
|
|
|
|
# Add the project directory to the path
|
|
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
from src.database import Database
|
|
|
|
async def reset_player_data(force=False):
|
|
"""Reset all player-related data in the database"""
|
|
print("🔄 Initializing database connection...")
|
|
database = Database()
|
|
await database.init_database()
|
|
|
|
print("⚠️ WARNING: This will delete ALL player data!")
|
|
print(" - All player accounts")
|
|
print(" - All caught pets")
|
|
print(" - All player achievements")
|
|
print(" - All player progress")
|
|
print(" - All battle history")
|
|
print("")
|
|
print("Game data (species, locations, moves, etc.) will be preserved.")
|
|
print("")
|
|
|
|
if not force:
|
|
confirm = input("Are you sure you want to reset all player data? (type 'yes' to confirm): ")
|
|
if confirm.lower() != 'yes':
|
|
print("❌ Reset cancelled.")
|
|
return
|
|
else:
|
|
print("🚀 Force mode enabled - proceeding with reset...")
|
|
|
|
print("")
|
|
print("🗑️ Resetting player data...")
|
|
|
|
try:
|
|
# Get database connection using aiosqlite directly
|
|
import aiosqlite
|
|
async with aiosqlite.connect(database.db_path) as db:
|
|
# Clear player-related tables in correct order (foreign key constraints)
|
|
tables_to_clear = [
|
|
'active_battles', # Battle data
|
|
'player_achievements', # Player achievements
|
|
'pets', # Player pets
|
|
'players' # Player accounts
|
|
]
|
|
|
|
for table in tables_to_clear:
|
|
print(f" Clearing {table}...")
|
|
await db.execute(f"DELETE FROM {table}")
|
|
await db.commit()
|
|
|
|
# Reset auto-increment counters
|
|
print(" Resetting ID counters...")
|
|
for table in tables_to_clear:
|
|
await db.execute(f"DELETE FROM sqlite_sequence WHERE name='{table}'")
|
|
await db.commit()
|
|
|
|
print("✅ Player data reset complete!")
|
|
print("")
|
|
print("🎮 Players can now use !start to begin fresh journeys.")
|
|
|
|
except Exception as e:
|
|
print(f"❌ Error resetting player data: {e}")
|
|
import traceback
|
|
traceback.print_exc()
|
|
|
|
async def main():
|
|
"""Main function"""
|
|
print("🐾 PetBot Player Data Reset Tool")
|
|
print("=" * 40)
|
|
|
|
# Check for force flag
|
|
force = len(sys.argv) > 1 and sys.argv[1] == '--force'
|
|
await reset_player_data(force=force)
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main()) |