Adding CLICK_NAIVE event

This commit is contained in:
2020-11-06 02:01:11 -03:00
parent c80dc93447
commit e29a1a88e0
3 changed files with 46 additions and 1 deletions

View File

@@ -4,11 +4,14 @@ import random
class Minesweeper: class Minesweeper:
board = [] 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.rows = rows
self.cols = cols self.cols = cols
self.mines = mines self.mines = mines
if board is not None:
self.board = board
def create_board(self): def create_board(self):
""" Creating the board cells with 0 as default value """ """ Creating the board cells with 0 as default value """
self.board = [[0 for col in range(self.cols)] for row in range(self.rows)] self.board = [[0 for col in range(self.cols)] for row in range(self.rows)]

View File

@@ -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",
),
),
]

View File

@@ -80,6 +80,7 @@ class EventTypes(EnumChoicesBase):
CLICK_EMPTY = 5 CLICK_EMPTY = 5
CLICK_FLAG = 6 CLICK_FLAG = 6
GAME_OVER = 7 GAME_OVER = 7
CLICK_NAIVE = 8
class GameEvent(models.Model): class GameEvent(models.Model):