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
|
# File 'lib/TicTacToe_Col.rb', line 7
def start
loop do
puts " ------------- MENU ------------- ".cyan
puts "| [1] Play Tic Tac Toe |".cyan
puts "| [2] Exit |".cyan
puts " -------------------------------- ".cyan
= gets.chomp.to_i
case
when 1
default_player = 1
@@ttt.start_game(default_player)
player = @@ttt.turns
loop do
puts "-------------------------------------- ".cyan
puts "| Do you want to start a new game? |".cyan
puts "| [1] Continue |".cyan
puts "| [2] Show Scoreboard |".cyan
puts "| [3] Return to first menu |".cyan
puts "-------------------------------------- ".cyan
= gets.chomp.to_i
case
when 1
@@ttt.start_game(player)
player = @@ttt.turns
when 2
@@ttt.check_winners
when 3
break
else
puts "Choose a valid element".red
end
end
when 2
break
else
puts "Choose a valid element".red
end
end
end
|