17
17
18
18
function ForcaGame :Start (mode )
19
19
ForcaGame :Reiniciar () -- Reinicia Variaveis
20
- os.execute ( " clear " ) -- Limpa tela
20
+ ForcaGame : Clear ()
21
21
str = " "
22
22
if mode == 1 then
23
23
io.read ()
@@ -37,7 +37,7 @@ function ForcaGame:Start(mode)
37
37
38
38
io.read ()
39
39
40
- os.execute ( " clear " ) -- Limpa tela
40
+ ForcaGame : Clear ()
41
41
ForcaGame .dica = string.upper ( ForcaGame .dica ) -- Coloca dica em caixa alta
42
42
ForcaGame :InicializaPalavra (str ) -- Remove espacos e inicializa WORD
43
43
@@ -66,7 +66,7 @@ function ForcaGame:Start(mode)
66
66
io.write (" Digite uma Letra: " )
67
67
ForcaGame .letra = string.upper ( io.read () ) -- Coloca letra maiuscula
68
68
ForcaGame :VerificaLetra (ForcaGame .letra ) -- Verifica se a letra esta na palavra
69
- os.execute ( " clear " ) -- Limpa tela
69
+ ForcaGame : Clear ()
70
70
else
71
71
print (" Voce Perdeu!!! Palavra Correta: " .. str )
72
72
break
@@ -90,7 +90,9 @@ function ForcaGame:Reiniciar() -- Reinicia variaveis do objeto
90
90
end
91
91
92
92
function ForcaGame :SorteiaDica () -- Raffle the dica number
93
- dicas = io.open (" dicas.words" , r ) -- Open file dicas
93
+ file = " dicas.words"
94
+ dicas = io.open (file ) -- Open file dicas
95
+
94
96
q_dica = dicas :read () -- Read dica number
95
97
dicas :close () -- Close the file
96
98
math.randomseed (os.time ()) -- Create seed for random
@@ -100,7 +102,8 @@ function ForcaGame:SorteiaDica() -- Raffle the dica number
100
102
end
101
103
102
104
function ForcaGame :RetornaDica (ndica ) -- Return the name file dica
103
- dicas = io.open (" dicas.words" , r ) -- Open file dicas
105
+ file = " dicas.words"
106
+ dicas = io.open (file ) -- Open file dicas
104
107
for i = 1 , ndica + 1 , 1 do
105
108
dica = dicas :read () -- Read dicas
106
109
end
@@ -109,7 +112,8 @@ function ForcaGame:RetornaDica(ndica) -- Return the name file dica
109
112
end
110
113
111
114
function ForcaGame :SorteiaPalavra (banco_sorteado ) -- Sorteia Palavra
112
- banco = io.open (banco_sorteado .. " .words" , r )
115
+ file = banco_sorteado .. " .words"
116
+ banco = io.open (file )
113
117
num_palavras = banco :read () -- Read number the words
114
118
math.randomseed (os.time ()) -- Create seed for random
115
119
math.random () -- Adicionar mais Random ajudam na melhor aleatoriedade
@@ -341,5 +345,12 @@ function ForcaGame:Boneco(fase) -- Imprime boneco corespondente com os erros
341
345
print (" ------------------------------------- " )
342
346
end
343
347
end
348
+
349
+ function ForcaGame :Clear () -- Limpa a tela de acordo com o sistema operacional
350
+ r = os.execute (" clear" )
351
+ if (r == false ) then
352
+ os.execute (" cls" )
353
+ end
354
+ end
344
355
345
356
return ForcaGame -- Retorna Instancia do Objeto
0 commit comments