diff --git a/core/__pycache__/urls.cpython-311.pyc b/core/__pycache__/urls.cpython-311.pyc index e33ebf3..1c76a4c 100644 Binary files a/core/__pycache__/urls.cpython-311.pyc and b/core/__pycache__/urls.cpython-311.pyc differ diff --git a/core/__pycache__/views.cpython-311.pyc b/core/__pycache__/views.cpython-311.pyc index e54558c..168dc43 100644 Binary files a/core/__pycache__/views.cpython-311.pyc and b/core/__pycache__/views.cpython-311.pyc differ diff --git a/core/management/commands/__pycache__/activate_all_games.cpython-311.pyc b/core/management/commands/__pycache__/activate_all_games.cpython-311.pyc index 37ae392..8781de6 100644 Binary files a/core/management/commands/__pycache__/activate_all_games.cpython-311.pyc and b/core/management/commands/__pycache__/activate_all_games.cpython-311.pyc differ diff --git a/core/management/commands/__pycache__/update_all_games_ai.cpython-311.pyc b/core/management/commands/__pycache__/update_all_games_ai.cpython-311.pyc new file mode 100644 index 0000000..3e8dfd5 Binary files /dev/null and b/core/management/commands/__pycache__/update_all_games_ai.cpython-311.pyc differ diff --git a/core/management/commands/activate_all_games.py b/core/management/commands/activate_all_games.py index d4ecec2..74de642 100644 --- a/core/management/commands/activate_all_games.py +++ b/core/management/commands/activate_all_games.py @@ -5,11 +5,19 @@ from core.pexels import fetch_first import time class Command(BaseCommand): - help = 'Ativa todos os jogos, gera scripts de IA e capas automaticamente para todo o catálogo.' + help = 'Ativa todos os jogos, gera scripts de IA (com história e correção) e capas automaticamente para todo o catálogo.' + + def add_arguments(self, parser): + parser.add_argument( + '--force', + action='store_true', + help='Força a re-geração de todos os scripts, mesmo que já existam.', + ) def handle(self, *args, **options): + force = options['force'] games = GameProject.objects.all() - self.stdout.write(f"Iniciando atualização de {games.count()} jogos...") + self.stdout.write(f"Iniciando processamento de {games.count()} jogos (Force={force})...") for game in games: self.stdout.write(f"Processando: {game.title}...") @@ -17,22 +25,28 @@ class Command(BaseCommand): # 1. Ativar o jogo game.is_active = True - # 2. Gerar script se estiver vazio ou for muito curto (indicativo de placeholder) - if not game.script_code or len(game.script_code) < 100: + # 2. Gerar script se estiver vazio, for placeholder ou se force for True + needs_script = force or not game.script_code or len(game.script_code) < 500 + + if needs_script: if not game.external_url: - self.stdout.write(f" -> Gerando script de IA para {game.title}...") + self.stdout.write(f" -> Gerando script de IA Autônomo para {game.title}...") script = generate_game_script(game.title, game.prompt, game.genre) if script: game.script_code = script + self.stdout.write(self.style.SUCCESS(f" -> Script gerado com sucesso.")) else: self.stdout.write(self.style.ERROR(f" -> Falha ao gerar script para {game.title}")) + else: + self.stdout.write(f" -> Jogo possui URL externa, pulando geração de script.") # 3. Gerar Capa se não tiver if not game.image_reference: self.stdout.write(f" -> Buscando capa no Pexels para {game.title}...") - pexels_data = fetch_first(f"{game.title} game {game.genre}") + pexels_data = fetch_first(f"{game.title} game background") if pexels_data: game.image_reference = pexels_data['local_path'].replace('media/', '') + self.stdout.write(self.style.SUCCESS(f" -> Capa encontrada e salva.")) else: self.stdout.write(self.style.WARNING(f" -> Capa não encontrada para {game.title}")) @@ -40,6 +54,6 @@ class Command(BaseCommand): self.stdout.write(self.style.SUCCESS(f" -> {game.title} ATUALIZADO E ATIVO!")) # Pequena pausa para evitar sobrecarga na API de IA/Pexels - time.sleep(1) + time.sleep(2) - self.stdout.write(self.style.SUCCESS("Processamento concluído com sucesso! Todos os jogos estão online.")) \ No newline at end of file + self.stdout.write(self.style.SUCCESS("Processamento concluído! Todos os jogos estão online e atualizados com IA Autônoma.")) diff --git a/core/management/commands/update_all_games_ai.py b/core/management/commands/update_all_games_ai.py new file mode 100644 index 0000000..388561a --- /dev/null +++ b/core/management/commands/update_all_games_ai.py @@ -0,0 +1,44 @@ +from django.core.management.base import BaseCommand +from core.models import GameProject +from core.views import generate_game_script +from core.pexels import fetch_first +import time + +class Command(BaseCommand): + help = 'Atualiza todos os jogos existentes usando IA para gerar script, história e banners.' + + def handle(self, *args, **options): + games = GameProject.objects.all() + total = games.count() + self.stdout.write(self.style.SUCCESS(f'Iniciando atualização de {total} jogos...')) + + for i, game in enumerate(games): + self.stdout.write(f'[{i+1}/{total}] Atualizando: {game.title}') + + # 1. Gerar Script e História via IA + # O prompt original do jogo é usado como base + new_script = generate_game_script(game.title, game.prompt, game.genre) + if new_script: + game.script_code = new_script + # Se o prompt estiver vazio, podemos pedir para a IA gerar uma descrição/história também + # Mas o generate_game_script já coloca a história no código HTML. + # Vamos garantir que o is_active esteja True + game.is_active = True + self.stdout.write(self.style.SUCCESS(f' - Script gerado com sucesso.')) + else: + self.stdout.write(self.style.ERROR(f' - Erro ao gerar script.')) + + # 2. Gerar Banner via Pexels (IA baseada no título) + if not game.image_reference or "pexels" not in str(game.image_reference): + pexels_data = fetch_first(f"{game.title} game wallpaper background") + if pexels_data: + game.image_reference = pexels_data['local_path'].replace('media/', '') + self.stdout.write(self.style.SUCCESS(f' - Banner gerado: {game.image_reference}')) + else: + self.stdout.write(self.style.WARNING(f' - Não foi possível gerar banner.')) + + game.save() + # Pequeno delay para evitar hitting limits se houver muitos + time.sleep(1) + + self.stdout.write(self.style.SUCCESS('Todos os jogos foram atualizados, ativados e integrados com IA!')) diff --git a/core/templates/base.html b/core/templates/base.html index 4ab3a6b..b104fba 100644 --- a/core/templates/base.html +++ b/core/templates/base.html @@ -43,6 +43,30 @@ border-radius: 16px; padding: 2rem; } + /* Google Translate customization */ + .goog-te-banner-frame.skiptranslate { display: none !important; } + body { top: 0px !important; } + #google_translate_element { + margin-right: 15px; + } + .goog-te-gadget-icon { display: none !important; } + .goog-te-gadget-simple { + background-color: rgba(255,255,255,0.1) !important; + border: 1px solid rgba(255,255,255,0.2) !important; + padding: 5px 10px !important; + border-radius: 20px !important; + color: white !important; + } + .goog-te-menu-value span { color: white !important; } + + /* Auto-translation notification */ + #translation-note { + display: none; + font-size: 0.7rem; + color: var(--cyan-accent); + text-align: right; + margin-right: 15px; + } {% block extra_css %}{% endblock %} @@ -52,11 +76,18 @@ AI GAME FORGE +