-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtablemanager.py
91 lines (77 loc) · 2.31 KB
/
tablemanager.py
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
#
# Nesse modulo constam as funcoes responsaveis pelas operacoes nas tabelas dos jogadores
#
#
import tableinterface as ti
__all__ = ['beginTables', 'insertValue', 'calcTable','getUserTable','getSampleTable','loadTable','prepareTableToSave','canYahtbonus']
tables = []
#
# Inicializa a tabela de acordo com o numero de jogadores
#
def beginTables(nPlayers):
if tables != [] or not isinstance(nPlayers,int) or nPlayers < 1:
return False
for i in range(0,nPlayers):
tables[:] += [['0','0','0','0','0','0','0','0','0','0','0','0','0','0']]
return True
#
# Prepara a tabela de um usuario para string para ser salva no txt
#
def prepareTableToSave(nPlayer):
tableLst = ""
for i in tables[nPlayer]:
tableLst += str(i) + " "
return tableLst
#
# Atualiza a tabela com a de um jogo anterior
#
def loadTable(loadedTable):
tables[:] = loadedTable
#
# Insere valor na tabela
#
def insertValue(nPlayer,cel,value):
if not value:
return False
if cel == 13:
if(tables[nPlayer][11] == '0'):
return False
else:
tables[nPlayer][cel] = str(int(tables[nPlayer][cel]) + value)
return True
elif(tables[nPlayer][cel] != '0'):
return False
else:
tables[nPlayer][cel] = str(value)
print('Insercao concluida!')
return True
#
# Calcula valor total da tabela de um usuario
#
def calcTable(nPlayer):
totalUpper = 0
for cel in range(0,6):
totalUpper += int(tables[nPlayer][cel])
totalLower = 0
for cel in range(6,14):
totalLower += int(tables[nPlayer][cel])
totalUpper += int(tables[nPlayer][13])*int(tables[nPlayer][11])
if totalLower > 62:
totalLower += 35
return (totalUpper+totalLower)
def getSampleTable(dCelulas):
it.displayTable(dCelulas)
return
#
# Retorna a tabela de um usuario
#
def getUserTable(nPlayer):
t = tables[nPlayer]
ti.displayTable(t, nPlayer)
return
#
# Retorna se pode fazer bonus
#
def canYahtbonus(nPlayer):
if(tables[nPlayer][11] != '0'):
return True