basic play interface

This commit is contained in:
Dan Ballard 2011-09-13 21:54:01 -07:00
parent e383c27a8d
commit 5b1d69ebfe
1 changed files with 15 additions and 4 deletions

View File

@ -323,6 +323,7 @@ class Board
return [x,y]
end
# todo: deal with loss when no move avail
def play()
setup()
color = ''
@ -358,23 +359,33 @@ class Board
valid = false
while !valid
print "Move piece: "
from = gets
from = gets().strip!
print "to: "
to = gets
to = gets().strip!
from = parse_coords(from)
to = parse_coords(to)
puts to.to_s + " or " + from.to_s
if !to or !from
next
end
if team(to[0], to[y]) != team
if team(from[0], from[1]) != team
next
end
if !piece_valid_moves(from[0], from[1], team).include?(to)
next
end
valid = true
end
do_move(from[0], from[1], to, team)
else
puts "AI MOVE"
end
if @stats[TEAM_1]['count'] == 0
puts "Black wins!"
elsif @stats[TEAM_2]['count'] == 0
puts "White wins!"
end
team = opposite_team(team)
turn += 1
end