feat: add math engine and puzzle services
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
# Generated by Django 4.2.23 on 2026-08-08 17:26
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import uuid
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
('contest', '0002_realtimematch_matchmaking_lookup_idx'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='MathGameAttempt',
|
||||
fields=[
|
||||
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
||||
('kind', models.CharField(choices=[('sudoku', '数独'), ('twenty_four', '24 点')], max_length=20)),
|
||||
('difficulty', models.CharField(choices=[('easy', '入门'), ('standard', '标准'), ('hard', '进阶')], default='standard', max_length=16)),
|
||||
('puzzle', models.JSONField(default=dict)),
|
||||
('solution', models.JSONField(default=dict)),
|
||||
('submission', models.JSONField(blank=True, default=dict)),
|
||||
('status', models.CharField(choices=[('active', '进行中'), ('completed', '已完成'), ('failed', '未通过')], default='active', max_length=16)),
|
||||
('score', models.PositiveIntegerField(default=0)),
|
||||
('duration_ms', models.PositiveIntegerField(default=0)),
|
||||
('hints_used', models.PositiveSmallIntegerField(default=0)),
|
||||
('submission_key', models.CharField(blank=True, max_length=80, null=True)),
|
||||
('started_at', models.DateTimeField(auto_now_add=True)),
|
||||
('submitted_at', models.DateTimeField(blank=True, null=True)),
|
||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='math_game_attempts', to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
options={
|
||||
'ordering': ['-started_at'],
|
||||
'indexes': [models.Index(fields=['kind', 'status', '-score', 'duration_ms'], name='math_game_ranking_idx')],
|
||||
},
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='mathgameattempt',
|
||||
constraint=models.UniqueConstraint(fields=('user', 'submission_key'), name='unique_user_math_game_submission'),
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user