bec_widgets.widgets.games.minesweeper ===================================== .. py:module:: bec_widgets.widgets.games.minesweeper Attributes ---------- .. autoapisummary:: bec_widgets.widgets.games.minesweeper.LEVELS bec_widgets.widgets.games.minesweeper.NUM_COLORS Classes ------- .. autoapisummary:: bec_widgets.widgets.games.minesweeper.GameStatus bec_widgets.widgets.games.minesweeper.Minesweeper bec_widgets.widgets.games.minesweeper.Pos Module Contents --------------- .. py:class:: GameStatus(*args, **kwds) Bases: :py:obj:`enum.Enum` Create a collection of name/value pairs. Example enumeration: >>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3 Access them by: - attribute access:: >>> Color.RED - value lookup: >>> Color(1) - name lookup: >>> Color['RED'] Enumerations can be iterated over, and know how many members they have: >>> len(Color) 3 >>> list(Color) [, , ] Methods can be added to enumerations, and members can have their own attributes -- see the documentation for details. .. py:attribute:: FAILED :value: 2 .. py:attribute:: PLAYING :value: 1 .. py:attribute:: READY :value: 0 .. py:attribute:: SUCCESS :value: 3 .. py:class:: Minesweeper(parent=None, *args, **kwargs) Bases: :py:obj:`bec_widgets.utils.bec_widget.BECWidget`, :py:obj:`qtpy.QtWidgets.QWidget` Mixin class for all BEC widgets, to handle cleanup Base class for all BEC widgets. This class should be used as a mixin class for all BEC widgets, e.g.: >>> class MyWidget(BECWidget, QWidget): >>> def __init__(self, parent=None, client=None, config=None, gui_id=None): >>> super().__init__(parent=parent, client=client, config=config, gui_id=gui_id) :param client: The BEC client. :type client: BECClient, optional :param config: The connection configuration. :type config: ConnectionConfig, optional :param gui_id: The GUI ID. :type gui_id: str, optional :param theme_update: Whether to subscribe to theme updates. Defaults to False. When set to True, the widget's apply_theme method will be called when the theme changes. :type theme_update: bool, optional .. py:method:: _init_map() Redraw the grid of mines .. py:method:: _init_ui() .. py:method:: _set_level_params(level: tuple[int, int]) .. py:method:: change_level(level: str) .. py:method:: check_win() Check if the game is won. .. py:method:: cleanup() Cleanup the widget. .. py:method:: expand_reveal(x, y) Expand the reveal to the surrounding :param x: The x position. :type x: int :param y: The y position. :type y: int .. py:method:: game_over() Cause the game to end early .. py:method:: get_num_hidden() -> int Get the number of hidden positions. .. py:method:: get_num_remaining_flags() -> int Get the number of remaining flags. .. py:method:: get_surrounding(x, y) .. py:method:: on_click() Handle the click event. If the game is not started, start the game. .. py:method:: reset_button_pressed() .. py:method:: reset_map() Reset the map and add new mines. .. py:method:: reveal_map() .. py:method:: update_available_flags() Update the number of available flags. .. py:method:: update_status(status: GameStatus) Update the status of the game. :param status: The status of the game. :type status: GameStatus .. py:method:: update_timer() Update the timer. .. py:attribute:: ICON_NAME :value: 'videogame_asset' .. py:attribute:: PLUGIN :value: True .. py:attribute:: RPC :value: True .. py:attribute:: USER_ACCESS :value: [] .. py:class:: Pos(x, y, *args, **kwargs) Bases: :py:obj:`qtpy.QtWidgets.QWidget` .. py:method:: click() .. py:method:: flag() .. py:method:: mouseReleaseEvent(event) .. py:method:: paintEvent(event) .. py:method:: reset() Restore the tile to its original state before mine status is assigned .. py:method:: reveal() .. py:attribute:: adjacent_n :value: 0 .. py:attribute:: clicked .. py:attribute:: expandable .. py:attribute:: is_flagged :value: False .. py:attribute:: is_mine :value: False .. py:attribute:: is_revealed :value: False .. py:attribute:: is_start :value: False .. py:attribute:: ohno .. py:attribute:: x .. py:attribute:: y .. py:data:: LEVELS :type: dict[str, tuple[int, int]] .. py:data:: NUM_COLORS