Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
jawwadzafar committed Jun 2, 2021
1 parent d43dc48 commit ae638ba
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions game.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@ def display_board(self):

def turn(self):
print(self.current_player + "'s turn.")
# TODO: improve to show only available turns
# TODO: handle exception for non int numbers
position = input("Choose a position from 1 to 9 ")
valid = False
while not valid:
# TODO: use range instead of list
while position not in ["1", "2", "3", "4", "5", "6", "7", "8", "9"]:
position = input("Incorrect. Choose a position from 1 to 9 again ")

Expand Down Expand Up @@ -118,7 +115,6 @@ def check_game_status(self):
return

def run(self):
print('Welcome to Terminal Tic Tac Toe')
self.display_board()

while self.game_still_going:
Expand All @@ -127,12 +123,11 @@ def run(self):
self.check_game_status()

#End of the game
if self.winner == "X" or self.winner == "O":
if self.winner != None:
print(self.winner + " won.")
elif self.winner == None:
else:
print("Tie. ")

if __name__ == "__main__":
print('Creating game object...')
game = Game()
game.run()

0 comments on commit ae638ba

Please sign in to comment.