diff --git a/amazons-works/__pycache__/board.cpython-310.pyc b/amazons-works/__pycache__/board.cpython-310.pyc index 07bc5f3..8cc2666 100644 Binary files a/amazons-works/__pycache__/board.cpython-310.pyc and b/amazons-works/__pycache__/board.cpython-310.pyc differ diff --git a/amazons-works/__pycache__/view.cpython-310.pyc b/amazons-works/__pycache__/view.cpython-310.pyc index 658887b..16291d7 100644 Binary files a/amazons-works/__pycache__/view.cpython-310.pyc and b/amazons-works/__pycache__/view.cpython-310.pyc differ diff --git a/amazons-works/game.py b/amazons-works/game.py index 9a1e1cd..8b17db0 100644 --- a/amazons-works/game.py +++ b/amazons-works/game.py @@ -10,27 +10,41 @@ translator = { 'd4':[0,3], 'd3':[1,3], 'd2':[2,3], 'd1':[3,3] } +def good_square_checker(square): + square_names = ['a1', 'a2', 'a3', 'a4', 'b1', 'b2', 'b3', 'b4', 'c1', 'c2', 'c3', 'c4', 'd1', 'd2', 'd3', 'd4'] + if square not in square_names: + return False + else: + return True + def turn(): - global board move_chosen = False while move_chosen == False: tui(board) print("Valid coordinates look like: \'b2\' or \'c4\'") - amazon = translator[(input("The starting coordinates of the amazon of your choice: "))] - move = translator[(input("The coordinates of the square you'd like to move to: "))] - burn = translator[(input("The coordinates of the square you'd like to set aflame: "))] - choice = ((amazon[0],amazon[1]),move,burn) + amazon = 'none' + move = 'none' + burn = 'none' + while good_square_checker(amazon) == False: + amazon = input("Choose a square containing the amazon of your choice: ") + while good_square_checker(move) == False: + move = input("Choose a square she can move to: ") + while good_square_checker(burn) == False: + burn = input("Choose a square she can then shoot: ") + choice = ((translator[amazon][0],translator[amazon][1]),translator[move],translator[burn]) + print(choice) print(board.possible_moves()) if choice in board.possible_moves(): board.state = board.get_successor_state(choice) move_chosen = True else: - print(str(choice)+" is not a valid move.") + input("That is not a valid move. Press enter to continue.") def play(): while len(board.possible_moves())>0: turn() - return ("Player "+str(get_active_player_code()-1)+" loses!") + tui(board) + print("Player "+str(board.get_active_player_code()-1)+" loses!") play()