import random from django.core.management.base import BaseCommand from core.models import GameProject class Command(BaseCommand): help = 'Populates the database with a variety of online and traditional games' def handle(self, *args, **options): game_data = [ { "title": "Space Invaders Pro", "genre": "shooter", "description": "Defenda a terra contra invasores espaciais nesta versão clássica.", "type": "script" }, { "title": "Neon Runner", "genre": "runner", "description": "Corra por uma cidade futurista desviando de obstáculos neon.", "type": "script" }, { "title": "Sudoku Online", "genre": "puzzle", "description": "Desafie sua mente com milhares de níveis de Sudoku.", "type": "online", "url": "https://www.247sudoku.com/" }, { "title": "Classic Solitaire", "genre": "puzzle", "description": "O jogo de cartas mais popular de todos os tempos.", "type": "online", "url": "https://www.247solitaire.com/" }, { "title": "Snake Classic", "genre": "arcade", "description": "O jogo da cobrinha original em versão moderna.", "type": "script" }, { "title": "Tower Building", "genre": "puzzle", "description": "Construa a torre mais alta que puder!", "type": "online", "url": "https://www.crazygames.com/embed/tower-building" }, { "title": "2048", "genre": "puzzle", "description": "Combine os blocos para chegar ao número 2048.", "type": "online", "url": "https://play2048.co/" } ] # Categories for variety categories = ['Ação', 'Aventura', 'Puzzle', 'Esportes', 'Estratégia', 'Arcade', 'Luta', 'Corrida'] count = 0 # Create base games for data in game_data: if not GameProject.objects.filter(title=data['title']).exists(): GameProject.objects.create( title=data['title'], genre=data['genre'], description=data['description'], external_url=data.get('url', ''), script_code=self.get_placeholder_script(data['title']) if data['type'] == 'script' else '', is_active=True ) count += 1 # Generate 50 more "simulated" games to show scale for i in range(1, 51): title = f"Jogo Online {i} - {random.choice(categories)}" if not GameProject.objects.filter(title=title).exists(): GameProject.objects.create( title=title, genre='online', description=f"Um emocionante jogo de {title.split(' - ')[1]} para jogar online.", external_url="https://www.crazygames.com/embed/shell-shockers" if i % 2 == 0 else "https://www.crazygames.com/embed/moto-x3m", is_active=True ) count += 1 self.stdout.write(self.style.SUCCESS(f'Sucesso! {count} novos jogos adicionados ao catálogo.')) def get_placeholder_script(self, title): return f"""
Score: 0
"""