from RockPaperScissors import *

def GotResult(value):
	if value == -1:
		print "Game drawn"
	else:
		print "Player", value, "won."
	print "Board:", rps.GetBoard()

rps = RockPaperScissors()
rps.AddNotifier(GotResult)

def Play(player, state):
	print "Playing: player", player, "state", rps.GetName(state)
	try:
		rps.Play((player, state))
	except RockPaperScissorsException, e:
		print "Exception:", e
	print

print "Testing exceptions"
print "------------------"
Play(1, 1)
Play(2, 3) # throw an exception (3 isn't a valid state)
Play(-1, 0) # throw an exception (-1 isn't a valid player)
Play(1, 0) # throw an exception (can't play the same position twice)
rps.Reset()

print
print "Draw game 1"
print "-----------"
Play(1, 2)
Play(2, 2)

print "Draw game 2"
print "-----------"
Play(2, 0)
Play(1, 0)

print "Winning game 1"
print "--------------"
Play(2, 1)
Play(1, 0)

print "Winning game 2"
print "--------------"
Play(1, 1)
Play(2, 0)

print "Winning game 3"
print "--------------"
Play(2, 2)
Play(1, 0)

print "Winning game 3"
print "--------------"
Play(1, 2)
Play(2, 0)

print "Winning game 4"
print "--------------"
Play(2, 2)
Play(1, 1)

print "Winning game 5"
print "--------------"
Play(2, 1)
Play(1, 2)


