diff --git a/core/__pycache__/models.cpython-311.pyc b/core/__pycache__/models.cpython-311.pyc index 505bc48..d6f8f21 100644 Binary files a/core/__pycache__/models.cpython-311.pyc and b/core/__pycache__/models.cpython-311.pyc differ diff --git a/core/__pycache__/urls.cpython-311.pyc b/core/__pycache__/urls.cpython-311.pyc index e4054c9..e33ebf3 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 c371fb2..4de7585 100644 Binary files a/core/__pycache__/views.cpython-311.pyc and b/core/__pycache__/views.cpython-311.pyc differ diff --git a/core/management/__init__.py b/core/management/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/core/management/__pycache__/__init__.cpython-311.pyc b/core/management/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000..0b03314 Binary files /dev/null and b/core/management/__pycache__/__init__.cpython-311.pyc differ diff --git a/core/management/commands/__init__.py b/core/management/commands/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/core/management/commands/__pycache__/__init__.cpython-311.pyc b/core/management/commands/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000..e4b96de Binary files /dev/null and b/core/management/commands/__pycache__/__init__.cpython-311.pyc differ diff --git a/core/management/commands/__pycache__/populate_games.cpython-311.pyc b/core/management/commands/__pycache__/populate_games.cpython-311.pyc new file mode 100644 index 0000000..3f0b288 Binary files /dev/null and b/core/management/commands/__pycache__/populate_games.cpython-311.pyc differ diff --git a/core/management/commands/populate_games.py b/core/management/commands/populate_games.py new file mode 100644 index 0000000..c04b5f9 --- /dev/null +++ b/core/management/commands/populate_games.py @@ -0,0 +1,140 @@ +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
+ + + + +""" diff --git a/core/migrations/0004_gameproject_external_url_userpurchase_is_paid_and_more.py b/core/migrations/0004_gameproject_external_url_userpurchase_is_paid_and_more.py new file mode 100644 index 0000000..e1e7901 --- /dev/null +++ b/core/migrations/0004_gameproject_external_url_userpurchase_is_paid_and_more.py @@ -0,0 +1,38 @@ +# Generated by Django 5.2.7 on 2026-02-14 02:28 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0003_gameproject_script_code_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='gameproject', + name='external_url', + field=models.URLField(blank=True, help_text='URL for external online games', null=True), + ), + migrations.AddField( + model_name='userpurchase', + name='is_paid', + field=models.BooleanField(default=False, help_text='Anti-fraud: Payment detected by intelligent system'), + ), + migrations.AlterField( + model_name='gameproject', + name='genre', + field=models.CharField(choices=[('platformer', 'Platformer'), ('shooter', 'Top-Down Shooter'), ('runner', 'Endless Runner'), ('puzzle', 'Puzzle'), ('traditional', 'Traditional Script'), ('online', 'Online Link')], default='platformer', max_length=50), + ), + migrations.AlterField( + model_name='gameproject', + name='prompt', + field=models.TextField(blank=True), + ), + migrations.AlterField( + model_name='userpurchase', + name='is_confirmed', + field=models.BooleanField(default=False, help_text='User successfully validated the code'), + ), + ] diff --git a/core/migrations/__pycache__/0004_gameproject_external_url_userpurchase_is_paid_and_more.cpython-311.pyc b/core/migrations/__pycache__/0004_gameproject_external_url_userpurchase_is_paid_and_more.cpython-311.pyc new file mode 100644 index 0000000..4cc9413 Binary files /dev/null and b/core/migrations/__pycache__/0004_gameproject_external_url_userpurchase_is_paid_and_more.cpython-311.pyc differ diff --git a/core/models.py b/core/models.py index 60d6bbd..efed311 100644 --- a/core/models.py +++ b/core/models.py @@ -24,15 +24,17 @@ class GameProject(models.Model): ('runner', 'Endless Runner'), ('puzzle', 'Puzzle'), ('traditional', 'Traditional Script'), + ('online', 'Online Link'), ] title = models.CharField(max_length=255) description = models.TextField(blank=True) - prompt = models.TextField() + prompt = models.TextField(blank=True) genre = models.CharField(max_length=50, choices=GENRE_CHOICES, default='platformer') image_reference = models.ImageField(upload_to='game_references/', null=True, blank=True) config_json = models.JSONField(default=dict, blank=True) script_code = models.TextField(blank=True, help_text="HTML/JS/CSS code for the game") + external_url = models.URLField(blank=True, null=True, help_text="URL for external online games") created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) is_active = models.BooleanField(default=True) @@ -58,10 +60,11 @@ class UserPurchase(models.Model): confirmation_code = models.CharField(max_length=12, blank=True, null=True) purchased_at = models.DateTimeField(auto_now_add=True) expires_at = models.DateTimeField() - is_confirmed = models.BooleanField(default=False) + is_paid = models.BooleanField(default=False, help_text="Anti-fraud: Payment detected by intelligent system") + is_confirmed = models.BooleanField(default=False, help_text="User successfully validated the code") def is_valid(self): return self.is_confirmed and timezone.now() < self.expires_at def __str__(self): - return f"{self.user_session.access_code} - {self.game.title}" \ No newline at end of file + return f"{self.user_session.access_code} - {self.game.title}" diff --git a/core/templates/core/admin_game_form.html b/core/templates/core/admin_game_form.html index 9dde2b1..aeb5e12 100644 --- a/core/templates/core/admin_game_form.html +++ b/core/templates/core/admin_game_form.html @@ -20,10 +20,17 @@ + +
+ + + Se preenchido, o jogo será carregado via Iframe desta URL. +
+
@@ -59,4 +66,4 @@
-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/core/templates/core/play.html b/core/templates/core/play.html index d8bee65..5bbca7d 100644 --- a/core/templates/core/play.html +++ b/core/templates/core/play.html @@ -1,78 +1,74 @@ {% extends 'base.html' %} +{% load static %} {% block content %} -
-
-

{{ game.title }}

-

Sessão validada. Divirta-se!

-
- Sair do Jogo -
- -
- {% if game.script_code %} - - {% else %} -
- - -
-

Este jogo ainda não possui script. Exibindo simulador.

-
Aguardando IA
+
+
+ +
+
+ + Voltar + +
{{ game.title }}
+
+
+ {{ game.get_genre_display }}
- {% endif %} -
-
-
-

Sobre o Jogo

-

{{ game.prompt }}

-
-
-
-
Status da Sessão
-
Ativo ✅
-
Sua compra foi validada com sucesso.
+ +
+ {% if game.external_url %} + + {% elif game.script_code %} + + + {% else %} + +
+
+

Jogo Simulado

+

Este jogo está em desenvolvimento.

+ +
+
+ + {% endif %}
- -{% block extra_js %} -{% if not game.script_code %} - -{% endif %} {% endblock %} -{% endblock %} \ No newline at end of file diff --git a/core/templates/core/purchase.html b/core/templates/core/purchase.html index 4225c69..dec6b16 100644 --- a/core/templates/core/purchase.html +++ b/core/templates/core/purchase.html @@ -1,183 +1,265 @@ {% extends 'base.html' %} +{% load static %} {% block content %} -
-
-
-

{{ game.title }}

-

{{ game.prompt }}

-
-
💳
-
-
Instruções de Aluguel
-
Selecione um plano, clique em "CLICK NO QR", escaneie o código e aguarde 3 minutos para receber seu código de validação.
-
-
- -

Escolha o tempo de acesso:

-
+
+
+
+

{{ game.title }}

+

Selecione o tempo de jogo desejado para liberar o acesso.

+ + +
{% for option in options %} -
-
-
{{ option.title }}
-
R$ {{ option.price }}
+
+
+
+
+ +
+

{{ option.title }}

+

{{ option.description }}

+
R$ {{ option.price }}
+
{{ option.duration_days }} dia(s) de jogo
+
{% endfor %}
-
-
-
-
-
-
🛒
-

Selecione uma opção

-

Escolha um plano ao lado para começar.

-
- -
-

- -
- -

Clique para visualizar os códigos de pagamento

-
- -
-
-
-
- QR 1 -
-
QR CODE 1
+ +