added game over condition
This commit is contained in:
parent
5b09ea5b56
commit
4cc483caee
11
tik.rb
11
tik.rb
@ -22,21 +22,28 @@ def checkWin(board, x, o)
|
||||
if board[line[0]] == "X" and board[line[1]] == "X" and board[line[2]] == "X"
|
||||
puts "X WINS!!!!!!"
|
||||
exit
|
||||
elsif board[line[0]] == "X" and board[line[1]] == "X" and board[line[2]] == "X"
|
||||
elsif board[line[0]] == "O" and board[line[1]] == "O" and board[line[2]] == "O"
|
||||
puts "O WINS!!!!!!"
|
||||
exit
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def isBoardFull(board)
|
||||
if not board.any?(0..9)
|
||||
puts "GAME OVER"
|
||||
exit
|
||||
end
|
||||
end
|
||||
|
||||
player = "X"
|
||||
x = Array.new
|
||||
o = Array.new
|
||||
def play(board, player, x, o)
|
||||
isBoardFull(board)
|
||||
printBoard(board)
|
||||
print "Place an #{player} "
|
||||
input = gets.to_i
|
||||
p input
|
||||
if board.include?(input)
|
||||
else
|
||||
puts "Bad input, pick a valid position"
|
||||
|
Loading…
x
Reference in New Issue
Block a user