-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.rb
54 lines (45 loc) · 875 Bytes
/
game.rb
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
# frozen_string_literal: true
class GameBow
def initialize
@matrix = Array.new(2) { Array.new(10) { 0 } }
@tiro = 0
@bandera = true
@cont = 0
end
def llenar_game_random
(0...2).each do |i|
(0...10).each do |j|
# validation(i, j)
llenando_val(i, j)
end
end
end
def llenando_val(i, j)
if @cont == 2
@tiro = 0
@cont = 0
end
# entra
@tiro = rand(11 - @tiro)
@matrix[i][j] = @tiro
@cont += 1
end
def draw_game
@matrix.each do |column|
column.each do |card|
print card
print ' ' # print no imprime un salto de linea al final del output
end
puts ' ' # salto de linea
end
end
def llenado_manual(x, y)
@matrix[x][y] = 1
end
def play_game
llenar_game_random
draw_game
end
end
game = GameBow.new
game.play_game