示例#1
0
文件: game.py 项目: L0laapk3/Litama
def clone_board(board: Board) -> Board:
    new_board: Board = []
    for y in board:
        new_board.append([])
        for x in y:
            new_board[-1].append(Piece(x.is_master, x.color))

    return new_board
示例#2
0
def str_to_board(s: str) -> Board:
    board: Board = [[Piece(False, Player.NONE) for _ in range(5)] for _ in range(5)]
    for i, n in enumerate(s):
        if n == "0":
            continue
        x = 4 - (i % 5)
        y = i // 5
        if n == "1" or n == "2":
            board[y][x].color = Player.BLUE
        if n == "3" or n == "4":
            board[y][x].color = Player.RED
        if n == "2" or n == "4":
            board[y][x].is_master = True
    return board
示例#3
0
文件: game.py 项目: L0laapk3/Litama
def init_game() -> Tuple[Board, List[Card], List[Card], Card]:
    board: Board = [[Piece(False, Player.NONE) for _ in range(5)]
                    for _ in range(5)]

    for x, y in [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0)]:
        board[y][x].color = Player.BLUE
    board[0][2].is_master = True

    for x, y in [(0, 4), (1, 4), (2, 4), (3, 4), (4, 4)]:
        board[y][x].color = Player.RED
    board[4][2].is_master = True

    random_cards = random.sample(ALL_BASE_CARDS, 5)
    blue_cards = random_cards[:2]
    red_cards = random_cards[2:4]
    side_card = random_cards[4]

    return board, blue_cards, red_cards, side_card