-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
97 lines (79 loc) · 2.36 KB
/
main.py
File metadata and controls
97 lines (79 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# -*- coding: utf-8 -*-
# This is my first Project, form calculators to this, no tutorials. Fell free to fork
# Ps: Sorry for this monstrosity
# Ps: Ps: Will try to implement list containing themselfs.
import Generator
import Render
tam = 0
def wincheck(renderboard, mineboard):
i = 1
j = 1
win = True
while i < len(renderboard) - 1:
j = 1
while j < len(renderboard) - 1:
if mineboard[i][j] == 0:
if renderboard[i][j] != 1:
win = False
j = j+1
i = i+1
return win
def myinput():
ended = False
while ended == False:
valid = False
while valid == False:
try:
y, x = input("faça uma jogada: ").split()
y, x = int(y), int(x)
valid = True
return x, y
except:
valid = False
def game():
print("1 - Easy")
print("2 - Medium")
print("3 - Hard")
print("4 - Custom")
choice = int(input())
if choice == 1:
tam = 8
dif = 10
if choice == 2:
tam = 16
dif = 40
if choice == 3:
tam = 20
dif = 99
if choice == 4:
notValid = True
while(notValid):
try:
tam = int(input("Tamanho do tabuleiro: "))
dif = int(input("Numero de Minas: "))
print("Número de minas inválido")
if(dif < tam**2):
notValid = False
except:
print("Digite Apenas Numeros")
firstmove = True
mineboard = Generator.GerarMinas(tam, dif)
numboard = Generator.MineCounterBoard(mineboard, tam)
renderboard = Render.DefRenderBoard(tam)
Render.Numboard(numboard, renderboard, tam)
ended = False
while ended == False:
x, y = myinput()
Generator.firstmovecheck(mineboard, x, y, tam, firstmove)
firstmove = False
if mineboard[y][x] == -1:
ended == True
print("Você Perdeu")
return
renderboard = Render.updateRenderBoard(
numboard, renderboard, x, y, tam)
Render.Numboard(numboard, renderboard, tam)
if wincheck(renderboard, mineboard):
print("Você Ganhou")
return
game()