Beispiel #1
0
def generate_board(maze_size):
    board = factories.create_board(maze_size=maze_size)
    location = BoardLocation(randint(0, maze_size-1), randint(0, maze_size-1))
    while board.objective_maze_card is board.maze[location]:
        location = BoardLocation(randint(0, maze_size-1), randint(0, maze_size-1))
    piece = Piece(0, board.maze[location])
    board.pieces.append(piece)
    return board
Beispiel #2
0
def given_game_and_player__when_set_game_on_player__creates_piece_for_player_on_board(
):
    board = create_board()
    game = Game(0, board=board)
    player = Player(0)

    player.set_game(game)

    assert player.piece in board.pieces
Beispiel #3
0
def change_game(game_id, game_request_dto):
    """ Changes game setup.

    Currently, the only option is to change the maze size.
    This will restart the game.
    :param game_id: specifies the game. Has to exist.
    :param game_request_dto: contains the new maze size."""
    new_size = mapper.dto_to_maze_size(game_request_dto)
    _ = interactors.OverduePlayerInteractor(game_repository())
    game = _load_game_or_throw(game_id)
    new_board = _try(lambda: factory.create_board(maze_size=new_size))
    _try(lambda: game.replace_board(new_board))
    DatabaseGateway.get_instance().update_game(game_id, game)
    DatabaseGateway.get_instance().commit()
Beispiel #4
0
def restart(game, maze_size=9):
    board = factory.create_board(maze_size=maze_size)
    game.restart(board)
Beispiel #5
0
def generate_board(maze_size):
    board = factories.create_board(maze_size=maze_size)
    board.pieces.append(generate_piece(board, 0))
    board.pieces.append(generate_piece(board, 1))
    return board