Sha256: 381cfb023bba51dabbc39fa36a9a0317540ce8c1fb67e867b33770964a5c7c09
Contents?: true
Size: 636 Bytes
Versions: 1
Compression:
Stored size: 636 Bytes
Contents
module TaTeTi class HumanPlayer < Player def move( board ) print board moves = board.moves print "Your move? (format: b3) " move = $stdin.gets until moves.include?(move.chomp.downcase) print "Invalid move. Try again. " move = $stdin.gets end move.chomp end def finish( final_board ) print final_board if final_board.won? == @mark print "Congratulations, you win.\n\n" elsif final_board.won? == " " print "Tie game.\n\n" else print "You lost tic-tac-toe?!\n\n" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ta-te-ti-0.0.2 | lib/ta_te_ti/human_player.rb |