bec_widgets.widgets.games#

Submodules#

Classes#

Minesweeper

Mixin class for all BEC widgets, to handle cleanup

Package Contents#

class Minesweeper(parent=None, *args, **kwargs)#

Bases: bec_widgets.utils.bec_widget.BECWidget, 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)
Parameters:
  • client (BECClient, optional) – The BEC client.

  • config (ConnectionConfig, optional) – The connection configuration.

  • gui_id (str, optional) – The GUI ID.

  • theme_update (bool, optional) – 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.

_init_map()#

Redraw the grid of mines

_init_ui()#
_set_level_params(level: tuple[int, int])#
change_level(level: str)#
check_win()#

Check if the game is won.

cleanup()#

Cleanup the widget.

expand_reveal(x, y)#

Expand the reveal to the surrounding

Parameters:
  • x (int) – The x position.

  • y (int) – The y position.

game_over()#

Cause the game to end early

get_num_hidden() int#

Get the number of hidden positions.

get_num_remaining_flags() int#

Get the number of remaining flags.

get_surrounding(x, y)#
on_click()#

Handle the click event. If the game is not started, start the game.

reset_button_pressed()#
reset_map()#

Reset the map and add new mines.

reveal_map()#
update_available_flags()#

Update the number of available flags.

update_status(status: GameStatus)#

Update the status of the game.

Parameters:

status (GameStatus) – The status of the game.

update_timer()#

Update the timer.

ICON_NAME = 'videogame_asset'#
PLUGIN = True#
RPC = True#
USER_ACCESS = []#