bec_widgets.widgets.games.minesweeper#
Attributes#
Classes#
Create a collection of name/value pairs. |
|
Mixin class for all BEC widgets, to handle cleanup |
|
Module Contents#
- class GameStatus(*args, **kwds)#
Bases:
enum.EnumCreate a collection of name/value pairs.
Example enumeration:
>>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3
Access them by:
attribute access:
>>> Color.RED <Color.RED: 1>
value lookup:
>>> Color(1) <Color.RED: 1>
name lookup:
>>> Color['RED'] <Color.RED: 1>
Enumerations can be iterated over, and know how many members they have:
>>> len(Color) 3
>>> list(Color) [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.
- FAILED = 2#
- PLAYING = 1#
- READY = 0#
- SUCCESS = 3#
- class Minesweeper(parent=None, *args, **kwargs)#
Bases:
bec_widgets.utils.bec_widget.BECWidget,qtpy.QtWidgets.QWidgetMixin 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 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 = []#
- class Pos(x, y, *args, **kwargs)#
Bases:
qtpy.QtWidgets.QWidget- click()#
- flag()#
- mouseReleaseEvent(event)#
- paintEvent(event)#
- reset()#
Restore the tile to its original state before mine status is assigned
- reveal()#
- adjacent_n = 0#
- clicked#
- expandable#
- is_flagged = False#
- is_mine = False#
- is_revealed = False#
- is_start = False#
- ohno#
- x#
- y#
- LEVELS: dict[str, tuple[int, int]]#
- NUM_COLORS#