示例#1
0
def __changeflag (evt,b,g,i,j):
    """
    This function is called on right-click on a button.

    :param b: the board of buttons
    :type b: list of list of ``button``
    :param g: the minesweeper game
    :type g: game
    :param i: the x-coordinate of the cell
    :type i: int
    :param j: the y-coordinate of the cell
    :type j: int
    """
    cell = minesweeper.get_cell(g,i,j)
    if not minesweeper.is_hypothetic_bomb(cell):
        minesweeper.set_hypothetic(cell)
    else:
        minesweeper.unset_hypothetic(cell)
    __redraw(b,g,i,j)
    __test_end (b,g)
示例#2
0
def play(game):
    """
    require action to the player and execute it
    :param game: game
    :type game: a minesweeper game
    :return: None
    :rtype: NoneType
    :UC: none
    """
    action = keyboard_input(game)
    x = action[0]
    y = action[1]
    a = action[2]
    if a == 'R':
        ms.reveal_all_cells_from(game,x, y)
    elif a == 'S':
        cell = ms.get_cell(game, x, y)
        ms.set_hypothetic(cell)
    elif a == 'U':
        cell = ms.get_cell(game, x, y)
        ms.unset_hypothetic(cell)