Creating structure for the game events (#3)
* Adding the GameVent model and migration * Initializing the GameEvent endpoint * GameEvent listing endpoint * Adding CLICK_NAIVE event * Added signal for identify what is on the click location * Using row and col integer is better than metadata with jsonfield * Create event for the same position is not allowed * Better signals control * Adding a board progress to Game model * Identifying the win status * Hide generated board from client
This commit is contained in:
73
game/migrations/0003_gameevent.py
Normal file
73
game/migrations/0003_gameevent.py
Normal file
@@ -0,0 +1,73 @@
|
||||
# Generated by Django 3.1.3 on 2020-11-06 03:54
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import django_mysql.models
|
||||
import game.models
|
||||
import internal.utils
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("game", "0002_auto_20201106_0225"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="GameEvent",
|
||||
fields=[
|
||||
(
|
||||
"id",
|
||||
models.AutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name="ID",
|
||||
),
|
||||
),
|
||||
(
|
||||
"created_at",
|
||||
models.DateTimeField(
|
||||
auto_now_add=True, verbose_name="Creation date"
|
||||
),
|
||||
),
|
||||
(
|
||||
"type",
|
||||
models.IntegerField(
|
||||
choices=[
|
||||
(0, "START_GAME"),
|
||||
(1, "PAUSE"),
|
||||
(2, "RESUME"),
|
||||
(3, "CLICK_MINE"),
|
||||
(4, "CLICK_POINT"),
|
||||
(5, "CLICK_EMPTY"),
|
||||
(6, "CLICK_FLAG"),
|
||||
(7, "GAME_OVER"),
|
||||
],
|
||||
default=game.models.EventTypes["START_GAME"],
|
||||
help_text="The game event",
|
||||
),
|
||||
),
|
||||
(
|
||||
"metadata",
|
||||
django_mysql.models.JSONField(
|
||||
default=internal.utils.empty_object,
|
||||
help_text="Some usefull event metadata",
|
||||
verbose_name="Event metadata",
|
||||
),
|
||||
),
|
||||
(
|
||||
"game",
|
||||
models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE, to="game.game"
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"verbose_name": "Game event",
|
||||
"verbose_name_plural": "Game events",
|
||||
"db_table": "game_events",
|
||||
},
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user