8000 working version of the test branch by xXUnique31Xx · Pull Request #8 · crnnr/Python-TicTacToe · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

working version of the test branch #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .coverage
Binary file not shown.
Binary file modified Docs/Documentation.pdf
Binary file not shown.
10 changes: 8 additions & 2 deletions controller.py
EE5F
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def start_menu(self):
else:
GameView.display_message("Loading game failed.")
self.load_game_state()
break
elif choice == '3':
GameView.display_message("Thank you for playing. Goodbye!")
sys.exit(0)
Expand Down Expand Up @@ -108,6 +109,9 @@ def post_game(self):
elif choice == '2':
GameView.display_message("Thank you for playing. Goodbye!")
sys.exit(0)
else: # Invalid choice
GameView.display_message("Invalid choice. Returning to main menu.")
self.start_menu()

def start_new_game(self):
"""
Expand All @@ -116,7 +120,7 @@ def start_new_game(self):
initializies the game board and players.
"""
self.board = GameBoard()
num_players = input('Enter number of players [1-2]: ')
num_players = GameView.input_prompt('Enter number of players [1-2]: ')
self.num_players = int(num_players)

if self.num_players not in [1, 2]:
Expand All @@ -143,12 +147,14 @@ def binary_rain(rows=1080, columns=1920):
start_row = random.randint(0, rows - 1)
for row in range(start_row, rows):
frame[row][col] = str(random.randint(0, 1))
# Print the frame
GameView.display_message(frame)

def save_game_state(self):
"""
Save the current game state to a file.
"""
save_name = input("Enter a name for your save"
save_name = GameView.input_prompt("Enter a name for your save"
"(leave blank to use the current datetime): ")
if not save_name:
# Ensure filename valid filename, regardless of OS
Expand Down
14 changes: 0 additions & 14 deletions tests/test_board.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,20 +189,6 @@ def test_check_terminal_state_incomplete(self):
GameBoard.BOARD_EMPTY]
self.assertIsNone(self.board.check_terminal_state())

@patch('builtins.input', side_effect=['save'])
def test_save_option(self, mocked_input):
"""Test the save option."""
action = self.player.make_move(self.board)
self.assertEqual(action, 'save')

# Invalid row, then valid
@patch('builtins.input', side_effect=['4', '2', '1'])
def test_invalid_row_input(self, mocked_input):
"""Test invalid row input."""
with patch('builtins.print') as mocked_print:
self.player.make_move(self.board)
mocked_print.assert_called_with(
"Invalid input. Please enter a number between 1 and 3.")

def test_evaluate_terminal_state_win(self):
"""Test the evaluate terminal state method when a player wins."""
Expand Down
Loading
Loading
0