# lineemup.py
# Program that plays a Line 'Em Up game

from graphics import *

def main():
	filename = raw_input("Input name of data file: ")
	window = GraphWin("Line 'Em Up", 350, 200)

	colorarray = initialize_array(filename)
	draw_lines(window)
	display_circles(window,colorarray)
	game_over = False
	while game_over == False:
		p = window.getMouse()
		column = p.getX()/50  # compute column where player clicked
		row = p.getY()/50     # compute row where player clicked
		update_array(colorarray, row, column)
		display_circles(window,colorarray)
		game_over = check_for_winner(colorarray)
	print "GAME OVER"
	raw_input("Press <ENTER> to quit.")
	window.close()

def initialize_array(filename):
	infile = open(filename, "r")
	colorarray = []
	for i in range(3):
		colorarray.append([])
	for row in range(3):
		for column in range(6):
			colorvalue = eval(infile.readline())
			colorarray[row].append(colorvalue)
	return colorarray

def draw_lines(window):
	for i in range(6):
		line = Line(Point(50*(i+1),0),Point(50*(i+1),200))
		line.draw(window)
	for j in range(3):
		line = Line(Point(0,50*(j+1)),Point(350,50*(j+1)))
		line.draw(window)

def display_circles(window,colorarray):
	colors = ["blue","green","cyan","red","magenta","yellow"]
	for row in range(3):
		for column in range(6):
			center = Point(column*50+25,row*50+25)
			circ = Circle(center,20)
			circ.setFill(colors[colorarray[row][column]])
			circ.draw(window)

def update_array(colorarray,row,column):
	# to be completed by you
	return	# remove this line when you complete this function

def check_for_winner(colorarray):
	# to be completed by you
	return False   # remove this line when you complete this function

main()		

		 
