-
Notifications
You must be signed in to change notification settings - Fork 0
/
play.rb
47 lines (32 loc) · 897 Bytes
/
play.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
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
require 'tic_tac_toe'
include TicTacToe
rows = ARGV[0].to_i
cols = ARGV[1].to_i
puts "You want to setup #{rows} X #{cols} board to play."
game = Game.new(rows,cols)
puts 'First player name >'
first_player_name = $stdin.gets.chomp
puts "Hi #{first_player_name}, Welcome to play."
puts '-' * 50
puts 'Second player name >'
second_player_name = $stdin.gets.chomp
puts "Hi #{second_player_name}, Welcome to play."
puts '-' * 50
first_player = Player.new(first_player_name, 'X')
second_player = Player.new(second_player_name, 'O')
end_game = false
game.set_players(first_player, second_player)
#game.start
while !end_game
game.start
puts 'Play again? Y/N'
answer = $stdin.gets.chomp
if answer.downcase == 'y'
first_player.reset_moves_count
second_player.reset_moves_count
game.reset_game
else
end_game = true
end
end