tic_tac_toe_vj 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tic_tac_toe_vj.rb +13 -7
- data/lib/tic_tac_toe_vj/board.rb +2 -2
- data/lib/tic_tac_toe_vj/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2bf7524f8d18e01bcd910204ce5b4e2adf4d8566f9ebf9fe98b8e046a1688d4c
|
4
|
+
data.tar.gz: 2ee010ab5568b000171a7ccdfded67154cb00639a7dfd08aefea4cd8f4832563
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbd1d9a3ff0fc41acea6888765d52eda5ae1f669e83aedb16ee4316d30594755a6a25f3c7deffee541c5811a0e2b73409508b204cfb91666131e17215027a42d
|
7
|
+
data.tar.gz: 839edcdbd0bc95ea4addc45f0e4be8ba6134574e1bba6a344e86ead4022bf9b9303e0c206ca9389e95cfb1051f7cd22f7cf2479b73a36efda277671a92048974
|
data/lib/tic_tac_toe_vj.rb
CHANGED
@@ -5,11 +5,11 @@ require 'tic_tac_toe_vj/player'
|
|
5
5
|
require 'tic_tac_toe_vj/location'
|
6
6
|
require 'tic_tac_toe_vj/game_status'
|
7
7
|
|
8
|
-
class
|
8
|
+
class TicTakToe
|
9
9
|
include TicTacToeVj
|
10
10
|
include GameStatus
|
11
11
|
|
12
|
-
def initialize(player1_name="
|
12
|
+
def initialize(player1_name="player1", player2_name="player2")
|
13
13
|
@board = Board.new
|
14
14
|
@tile_location = Location.new(0,0)
|
15
15
|
@player1 = Player.new(player1_name, :O)
|
@@ -20,7 +20,7 @@ class TicTakToeController
|
|
20
20
|
def start
|
21
21
|
puts "Tic tak toe is starting -------------"
|
22
22
|
sleep(1)
|
23
|
-
puts "
|
23
|
+
puts "turns should be write as row coma column ex 1,1 this will Enter your Symbol in the middle"
|
24
24
|
sleep(0.5)
|
25
25
|
user_play_move
|
26
26
|
end
|
@@ -50,7 +50,7 @@ class TicTakToeController
|
|
50
50
|
def update_game_after_move(gamestatus)
|
51
51
|
case gamestatus
|
52
52
|
when GameStatus::NEXT_MOVE
|
53
|
-
puts "your
|
53
|
+
puts "your turn #{@game.current_player.name}"
|
54
54
|
user_play_move
|
55
55
|
when GameStatus::DRAW
|
56
56
|
puts "its a draw"
|
@@ -68,8 +68,14 @@ class TicTakToeController
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def user_play_move
|
71
|
-
|
72
|
-
|
71
|
+
@board.tile.each do |row|
|
72
|
+
row.each do |column|
|
73
|
+
print " #{column} "
|
74
|
+
end
|
75
|
+
puts " "
|
76
|
+
end
|
77
|
+
|
78
|
+
puts "Enter your turn #{@game.current_player.name}"
|
73
79
|
location = gets.chomp
|
74
80
|
if validate_input?(location)
|
75
81
|
move_locations = location.split(",")
|
@@ -78,7 +84,7 @@ class TicTakToeController
|
|
78
84
|
@board.mark_tile(@tile_location, @game.current_player.symbol)
|
79
85
|
@game.play_move(@tile_location)
|
80
86
|
else
|
81
|
-
puts "location is already marked please do
|
87
|
+
puts "location is already marked please do turns again"
|
82
88
|
user_play_move
|
83
89
|
end
|
84
90
|
else
|
data/lib/tic_tac_toe_vj/board.rb
CHANGED
@@ -7,7 +7,7 @@ class Board
|
|
7
7
|
|
8
8
|
def initialize()
|
9
9
|
@number_of_tiles_marked = 0
|
10
|
-
@tile = Array.new(BOARD_SIZE) {Array.new(BOARD_SIZE)}
|
10
|
+
@tile = Array.new(BOARD_SIZE) {Array.new(BOARD_SIZE, '_')}
|
11
11
|
end
|
12
12
|
|
13
13
|
def mark_tile(location, mark)
|
@@ -18,7 +18,7 @@ class Board
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def is_tile_not_marked?(location)
|
21
|
-
return @tile[location.row][location.column]
|
21
|
+
return @tile[location.row][location.column] == "_"
|
22
22
|
end
|
23
23
|
|
24
24
|
def number_of_terns
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tic_tac_toe_vj
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vijay Pratap Singh
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|