ruff: Fix N802 Function name should be lowercase.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
2c4e7069ad
commit
d5ad3300c7
5 changed files with 48 additions and 48 deletions
|
@ -127,7 +127,7 @@ The first player to get 4 in a row wins!\n Good Luck!",
|
|||
]
|
||||
|
||||
def test_connect_four_logic(self) -> None:
|
||||
def confirmAvailableMoves(
|
||||
def confirm_available_moves(
|
||||
good_moves: List[int], bad_moves: List[int], board: List[List[int]]
|
||||
) -> None:
|
||||
connectFourModel.update_board(board)
|
||||
|
@ -138,7 +138,7 @@ The first player to get 4 in a row wins!\n Good Luck!",
|
|||
for move in bad_moves:
|
||||
self.assertFalse(connectFourModel.validate_move(move))
|
||||
|
||||
def confirmMove(
|
||||
def confirm_move(
|
||||
column_number: int,
|
||||
token_number: int,
|
||||
initial_board: List[List[int]],
|
||||
|
@ -149,18 +149,18 @@ The first player to get 4 in a row wins!\n Good Luck!",
|
|||
|
||||
self.assertEqual(test_board, final_board)
|
||||
|
||||
def confirmGameOver(board: List[List[int]], result: str) -> None:
|
||||
def confirm_game_over(board: List[List[int]], result: str) -> None:
|
||||
connectFourModel.update_board(board)
|
||||
game_over = connectFourModel.determine_game_over(["first_player", "second_player"])
|
||||
|
||||
self.assertEqual(game_over, result)
|
||||
|
||||
def confirmWinStates(array: List[List[List[List[int]]]]) -> None:
|
||||
def confirm_win_states(array: List[List[List[List[int]]]]) -> None:
|
||||
for board in array[0]:
|
||||
confirmGameOver(board, "first_player")
|
||||
confirm_game_over(board, "first_player")
|
||||
|
||||
for board in array[1]:
|
||||
confirmGameOver(board, "second_player")
|
||||
confirm_game_over(board, "second_player")
|
||||
|
||||
connectFourModel = ConnectFourModel()
|
||||
|
||||
|
@ -428,9 +428,9 @@ The first player to get 4 in a row wins!\n Good Luck!",
|
|||
]
|
||||
|
||||
# Test Move Validation Logic
|
||||
confirmAvailableMoves([0, 1, 2, 3, 4, 5, 6], [-1, 7], blank_board)
|
||||
confirmAvailableMoves([3], [0, 1, 2, 4, 5, 6], single_column_board)
|
||||
confirmAvailableMoves([0, 1, 2, 3, 4, 5], [6], diagonal_board)
|
||||
confirm_available_moves([0, 1, 2, 3, 4, 5, 6], [-1, 7], blank_board)
|
||||
confirm_available_moves([3], [0, 1, 2, 4, 5, 6], single_column_board)
|
||||
confirm_available_moves([0, 1, 2, 3, 4, 5], [6], diagonal_board)
|
||||
|
||||
# Test Available Move Logic
|
||||
connectFourModel.update_board(blank_board)
|
||||
|
@ -443,7 +443,7 @@ The first player to get 4 in a row wins!\n Good Luck!",
|
|||
self.assertEqual(connectFourModel.available_moves(), [])
|
||||
|
||||
# Test Move Logic
|
||||
confirmMove(
|
||||
confirm_move(
|
||||
1,
|
||||
0,
|
||||
blank_board,
|
||||
|
@ -457,7 +457,7 @@ The first player to get 4 in a row wins!\n Good Luck!",
|
|||
],
|
||||
)
|
||||
|
||||
confirmMove(
|
||||
confirm_move(
|
||||
1,
|
||||
1,
|
||||
blank_board,
|
||||
|
@ -471,7 +471,7 @@ The first player to get 4 in a row wins!\n Good Luck!",
|
|||
],
|
||||
)
|
||||
|
||||
confirmMove(
|
||||
confirm_move(
|
||||
1,
|
||||
0,
|
||||
diagonal_board,
|
||||
|
@ -485,7 +485,7 @@ The first player to get 4 in a row wins!\n Good Luck!",
|
|||
],
|
||||
)
|
||||
|
||||
confirmMove(
|
||||
confirm_move(
|
||||
2,
|
||||
0,
|
||||
diagonal_board,
|
||||
|
@ -499,7 +499,7 @@ The first player to get 4 in a row wins!\n Good Luck!",
|
|||
],
|
||||
)
|
||||
|
||||
confirmMove(
|
||||
confirm_move(
|
||||
3,
|
||||
0,
|
||||
diagonal_board,
|
||||
|
@ -513,7 +513,7 @@ The first player to get 4 in a row wins!\n Good Luck!",
|
|||
],
|
||||
)
|
||||
|
||||
confirmMove(
|
||||
confirm_move(
|
||||
4,
|
||||
0,
|
||||
diagonal_board,
|
||||
|
@ -527,7 +527,7 @@ The first player to get 4 in a row wins!\n Good Luck!",
|
|||
],
|
||||
)
|
||||
|
||||
confirmMove(
|
||||
confirm_move(
|
||||
5,
|
||||
0,
|
||||
diagonal_board,
|
||||
|
@ -541,7 +541,7 @@ The first player to get 4 in a row wins!\n Good Luck!",
|
|||
],
|
||||
)
|
||||
|
||||
confirmMove(
|
||||
confirm_move(
|
||||
6,
|
||||
0,
|
||||
diagonal_board,
|
||||
|
@ -556,14 +556,14 @@ The first player to get 4 in a row wins!\n Good Luck!",
|
|||
)
|
||||
|
||||
# Test Game Over Logic:
|
||||
confirmGameOver(blank_board, "")
|
||||
confirmGameOver(full_board, "draw")
|
||||
confirm_game_over(blank_board, "")
|
||||
confirm_game_over(full_board, "draw")
|
||||
|
||||
# Test Win States:
|
||||
confirmWinStates(horizontal_win_boards)
|
||||
confirmWinStates(vertical_win_boards)
|
||||
confirmWinStates(major_diagonal_win_boards)
|
||||
confirmWinStates(minor_diagonal_win_boards)
|
||||
confirm_win_states(horizontal_win_boards)
|
||||
confirm_win_states(vertical_win_boards)
|
||||
confirm_win_states(major_diagonal_win_boards)
|
||||
confirm_win_states(minor_diagonal_win_boards)
|
||||
|
||||
def test_more_logic(self) -> None:
|
||||
model = ConnectFourModel()
|
||||
|
|
|
@ -69,7 +69,7 @@ class TestGameOfFifteenBot(BotTestCase, DefaultTests):
|
|||
winning_board = [[0, 1, 2], [3, 4, 5], [6, 7, 8]]
|
||||
|
||||
def test_game_of_fifteen_logic(self) -> None:
|
||||
def confirmAvailableMoves(
|
||||
def confirm_available_moves(
|
||||
good_moves: List[int], bad_moves: List[int], board: List[List[int]]
|
||||
) -> None:
|
||||
gameOfFifteenModel.update_board(board)
|
||||
|
@ -79,7 +79,7 @@ class TestGameOfFifteenBot(BotTestCase, DefaultTests):
|
|||
for move in bad_moves:
|
||||
self.assertFalse(gameOfFifteenModel.validate_move(move))
|
||||
|
||||
def confirmMove(
|
||||
def confirm_move(
|
||||
tile: str,
|
||||
token_number: int,
|
||||
initial_board: List[List[int]],
|
||||
|
@ -90,7 +90,7 @@ class TestGameOfFifteenBot(BotTestCase, DefaultTests):
|
|||
|
||||
self.assertEqual(test_board, final_board)
|
||||
|
||||
def confirmGameOver(board: List[List[int]], result: str) -> None:
|
||||
def confirm_game_over(board: List[List[int]], result: str) -> None:
|
||||
gameOfFifteenModel.update_board(board)
|
||||
game_over = gameOfFifteenModel.determine_game_over(["first_player"])
|
||||
|
||||
|
@ -111,20 +111,20 @@ class TestGameOfFifteenBot(BotTestCase, DefaultTests):
|
|||
winning_board = [[0, 1, 2], [3, 4, 5], [6, 7, 8]]
|
||||
|
||||
# Test Move Validation Logic
|
||||
confirmAvailableMoves([1, 2, 3, 4, 5, 6, 7, 8], [0, 9, -1], initial_board)
|
||||
confirm_available_moves([1, 2, 3, 4, 5, 6, 7, 8], [0, 9, -1], initial_board)
|
||||
|
||||
# Test Move Logic
|
||||
confirmMove("1", 0, initial_board, [[8, 7, 6], [5, 4, 3], [2, 0, 1]])
|
||||
confirm_move("1", 0, initial_board, [[8, 7, 6], [5, 4, 3], [2, 0, 1]])
|
||||
|
||||
confirmMove("1 2", 0, initial_board, [[8, 7, 6], [5, 4, 3], [0, 2, 1]])
|
||||
confirm_move("1 2", 0, initial_board, [[8, 7, 6], [5, 4, 3], [0, 2, 1]])
|
||||
|
||||
confirmMove("1 2 5", 0, initial_board, [[8, 7, 6], [0, 4, 3], [5, 2, 1]])
|
||||
confirm_move("1 2 5", 0, initial_board, [[8, 7, 6], [0, 4, 3], [5, 2, 1]])
|
||||
|
||||
confirmMove("1 2 5 4", 0, initial_board, [[8, 7, 6], [4, 0, 3], [5, 2, 1]])
|
||||
confirm_move("1 2 5 4", 0, initial_board, [[8, 7, 6], [4, 0, 3], [5, 2, 1]])
|
||||
|
||||
confirmMove("3", 0, sample_board, [[7, 6, 8], [0, 3, 1], [2, 4, 5]])
|
||||
confirm_move("3", 0, sample_board, [[7, 6, 8], [0, 3, 1], [2, 4, 5]])
|
||||
|
||||
confirmMove("3 7", 0, sample_board, [[0, 6, 8], [7, 3, 1], [2, 4, 5]])
|
||||
confirm_move("3 7", 0, sample_board, [[0, 6, 8], [7, 3, 1], [2, 4, 5]])
|
||||
|
||||
# Test coordinates logic:
|
||||
confirm_coordinates(
|
||||
|
@ -143,8 +143,8 @@ class TestGameOfFifteenBot(BotTestCase, DefaultTests):
|
|||
)
|
||||
|
||||
# Test Game Over Logic:
|
||||
confirmGameOver(winning_board, "current turn")
|
||||
confirmGameOver(sample_board, "")
|
||||
confirm_game_over(winning_board, "current turn")
|
||||
confirm_game_over(sample_board, "")
|
||||
|
||||
def test_invalid_moves(self) -> None:
|
||||
model = GameOfFifteenModel()
|
||||
|
|
|
@ -30,7 +30,7 @@ class UnspecifiedProblemException(Exception):
|
|||
pass
|
||||
|
||||
|
||||
def make_API_request(
|
||||
def make_api_request(
|
||||
endpoint: str,
|
||||
method: str = "GET",
|
||||
body: Optional[Dict[str, str]] = None,
|
||||
|
@ -56,31 +56,31 @@ def make_API_request(
|
|||
|
||||
|
||||
def api_noop() -> None:
|
||||
make_API_request("/noop")
|
||||
make_api_request("/noop")
|
||||
|
||||
|
||||
def api_list_team() -> List[Dict[str, str]]:
|
||||
return make_API_request("/teams")
|
||||
return make_api_request("/teams")
|
||||
|
||||
|
||||
def api_show_team(hash_id: str) -> Dict[str, str]:
|
||||
return make_API_request(f"/teams/{hash_id}")
|
||||
return make_api_request(f"/teams/{hash_id}")
|
||||
|
||||
|
||||
# NOTE: This function is not currently used
|
||||
def api_show_users(hash_id: str) -> Any:
|
||||
return make_API_request(f"/teams/{hash_id}/members")
|
||||
return make_api_request(f"/teams/{hash_id}/members")
|
||||
|
||||
|
||||
def api_list_entries(team_id: Optional[str] = None) -> List[Dict[str, Any]]:
|
||||
if team_id:
|
||||
return make_API_request("/entries", params=dict(team_id=team_id))
|
||||
return make_api_request("/entries", params=dict(team_id=team_id))
|
||||
else:
|
||||
return make_API_request("/entries")
|
||||
return make_api_request("/entries")
|
||||
|
||||
|
||||
def api_create_entry(body: str, team_id: str) -> Dict[str, Any]:
|
||||
return make_API_request("/entries", "POST", {"body": body, "team_id": team_id})
|
||||
return make_api_request("/entries", "POST", {"body": body, "team_id": team_id})
|
||||
|
||||
|
||||
def list_teams() -> str:
|
||||
|
|
|
@ -14,7 +14,7 @@ from . import database, mechanics
|
|||
COMMAND_PATTERN = re.compile("^(\\w*).*(\\d,\\d).*(\\d,\\d)|^(\\w+).*(\\d,\\d)")
|
||||
|
||||
|
||||
def getInfo():
|
||||
def get_info():
|
||||
"""Gets the info on starting the game
|
||||
|
||||
:return: Info on how to start the game
|
||||
|
@ -22,7 +22,7 @@ def getInfo():
|
|||
return "To start a game, mention me and add `create`. A game will start in that topic. "
|
||||
|
||||
|
||||
def getHelp():
|
||||
def get_help():
|
||||
"""Gets the help message
|
||||
|
||||
:return: Help message
|
||||
|
|
|
@ -64,7 +64,7 @@ class MerelsMessageHandler:
|
|||
return original_player + " :" + move_info
|
||||
|
||||
def game_start_message(self) -> str:
|
||||
return game.getHelp()
|
||||
return game.get_help()
|
||||
|
||||
|
||||
class MerelsHandler(GameAdapter):
|
||||
|
@ -79,7 +79,7 @@ class MerelsHandler(GameAdapter):
|
|||
}
|
||||
|
||||
def usage(self) -> str:
|
||||
return game.getInfo()
|
||||
return game.get_info()
|
||||
|
||||
def __init__(self) -> None:
|
||||
game_name = "Merels"
|
||||
|
@ -87,7 +87,7 @@ class MerelsHandler(GameAdapter):
|
|||
move_help_message = ""
|
||||
move_regex = ".*"
|
||||
model = MerelsModel
|
||||
rules = game.getInfo()
|
||||
rules = game.get_info()
|
||||
gameMessageHandler = MerelsMessageHandler
|
||||
super().__init__(
|
||||
game_name,
|
||||
|
|
Loading…
Add table
Reference in a new issue