diff --git a/game/game.py b/game/game.py index ed5f5c2..4f65528 100644 --- a/game/game.py +++ b/game/game.py @@ -4,11 +4,14 @@ import random class Minesweeper: board = [] - def __init__(self, rows=10, cols=10, mines=5): + def __init__(self, rows=10, cols=10, mines=5, board=None): self.rows = rows self.cols = cols self.mines = mines + if board is not None: + self.board = board + def create_board(self): """ Creating the board cells with 0 as default value """ self.board = [[0 for col in range(self.cols)] for row in range(self.rows)] diff --git a/game/migrations/0004_auto_20201106_0453.py b/game/migrations/0004_auto_20201106_0453.py new file mode 100644 index 0000000..e391011 --- /dev/null +++ b/game/migrations/0004_auto_20201106_0453.py @@ -0,0 +1,41 @@ +# Generated by Django 3.1.3 on 2020-11-06 04:53 + +from django.db import migrations, models +import game.models + + +class Migration(migrations.Migration): + + dependencies = [ + ("game", "0003_gameevent"), + ] + + operations = [ + migrations.AlterModelOptions( + name="gameevent", + options={ + "ordering": ["created_at"], + "verbose_name": "Game event", + "verbose_name_plural": "Game events", + }, + ), + migrations.AlterField( + model_name="gameevent", + name="type", + field=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"), + (8, "CLICK_NAIVE"), + ], + default=game.models.EventTypes["START_GAME"], + help_text="The game event", + ), + ), + ] diff --git a/game/models.py b/game/models.py index 41b55a1..779ab12 100644 --- a/game/models.py +++ b/game/models.py @@ -80,6 +80,7 @@ class EventTypes(EnumChoicesBase): CLICK_EMPTY = 5 CLICK_FLAG = 6 GAME_OVER = 7 + CLICK_NAIVE = 8 class GameEvent(models.Model):