Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#include.rb
def show_board
count = 0
@board.each { |key, value|
print "#{value}" + " | "
if count == 2 or count == 5 then print "\n______________\n" end
count += 1
}
print "\n"
end
def check_for_winner
#check for O's
if @board["ul"] == "O" and @board["um"] == "O" and @board["ur"] == "O" then
@active = false
puts "Player 1(O's) wins"
end
if @board["ml"] == "O" and @board["mm"] == "O" and @board["mr"] == "O" then
@active = false
puts "Player 1(O's) wins"
end
if @board["bl"] == "O" and @board["bm"] == "O" and @board["br"] == "O" then
@active = false
puts "Player 1(O's) wins"
end
if @board["ul"] == "O" and @board["mm"] == "O" and @board["br"] == "O" then
@active = false
puts "Player 1(O's) wins"
end
if @board["bl"] == "O" and @board["mm"] == "O" and @board["ur"] == "O" then
@active = false
puts "Player 1(O's) wins"
end
#check for X's
if @board["ul"] == "X" and @board["um"] == "X" and @board["ur"] == "X" then
@active = false
puts "Player 2(X's) wins"
end
if @board["ml"] == "X" and @board["mm"] == "X" and @board["mr"] == "X" then
@active = false
puts "Player 2(X's) wins"
end
if @board["bl"] == "X" and @board["bm"] == "X" and @board["br"] == "X" then
@active = false
puts "Player 2(X's) wins"
end
if @board["ul"] == "X" and @board["mm"] == "X" and @board["br"] == "X" then
@active = false
puts "Player 2(X's) wins"
end
if @board["bl"] == "X" and @board["mm"] == "X" and @board["ur"] == "X" then
@active = false
puts "Player 2(X's) wins"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment