API Reference
init.py: notty_game package.
main
Main entrypoint for the project.
get_screen()
Create the game window.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_width
|
Width of the window. |
required | |
app_height
|
Height of the window. |
required |
Source code in notty/main.py
75 76 77 78 79 80 81 82 83 84 85 | |
main()
Start the notty game.
Source code in notty/main.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |
run()
Run the game.
Returns:
| Type | Description |
|---|---|
str
|
"new_game" if user wants to restart, "quit" if user wants to exit. |
Source code in notty/main.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
run_event_loop(game)
Run the main event loop.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
game
|
VisualGame
|
The game instance. |
required |
Returns:
| Type | Description |
|---|---|
str
|
"new_game" if user wants to start a new game, "quit" if user wants to quit. |
Source code in notty/main.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
show_winner(game)
Show the winner display and get user choice.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
game
|
VisualGame
|
The game instance. |
required |
Returns:
| Type | Description |
|---|---|
str
|
"new_game" if user wants to start a new game, "quit" if user wants to quit. |
Source code in notty/main.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
start_background_music()
Start looping background music if possible.
Source code in notty/main.py
48 49 50 51 52 53 54 55 | |
rig
init module.
builders
init module.
builder
Build script.
All subclasses of Builder in the builds package are automatically called.
NottyBuilder
Bases: PyInstallerBuilder
Builder for notty.
Source code in notty/rig/builders/builder.py
13 14 15 16 17 18 | |
entry_point_module()
Get the entry point module.
Source code in notty/rig/builders/builder.py
16 17 18 | |
cli
init module.
shared_subcommands
Shared commands for the CLI.
This module provides shared CLI commands that can be used by multiple packages in a multi-package architecture. These commands are automatically discovered and added to the CLI by pyrig. Example is version command that is available in all packages. uv run my-awesome-project version will return my-awesome-project version 0.1.0
version()
Print the version of notty.
Source code in notty/rig/cli/shared_subcommands.py
13 14 15 | |
subcommands
Project-specific CLI commands.
Add custom CLI commands here as public functions. All public functions are automatically discovered and registered as CLI commands.
run()
Run the notty game.
Source code in notty/rig/cli/subcommands.py
8 9 10 11 12 | |
configs
init module.
configs
Configs for pyrig.
All subclasses of ConfigFile in the configs package are automatically called.
BuildWorkflowConfigFile
Bases: WorkflowConfigFileMixin, BuildWorkflowConfigFile
Build workflow.
Extends winipedia_utils build workflow to add additional steps. This is necessary to make pyside6 work on github actions which is a headless linux environment.
Source code in notty/rig/configs/configs.py
81 82 83 84 85 86 87 | |
step_pre_install_pygame_from_binary()
Get the step to install PySide6 dependencies.
Source code in notty/rig/configs/configs.py
53 54 55 56 57 58 | |
steps_core_installed_setup(*args, **kwargs)
Get the setup steps.
We need to install additional system dependencies for pyside6.
Source code in notty/rig/configs/configs.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
HealthCheckWorkflowConfigFile
Bases: WorkflowConfigFileMixin, HealthCheckWorkflowConfigFile
Health check workflow.
Extends winipedia_utils health check workflow to add additional steps. This is necessary to make pyside6 work on github actions which is a headless linux environment.
Source code in notty/rig/configs/configs.py
61 62 63 64 65 66 67 68 69 | |
step_pre_install_pygame_from_binary()
Get the step to install PySide6 dependencies.
Source code in notty/rig/configs/configs.py
53 54 55 56 57 58 | |
steps_core_installed_setup(*args, **kwargs)
Get the setup steps.
We need to install additional system dependencies for pyside6.
Source code in notty/rig/configs/configs.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
PyprojectConfigFile
Bases: PyprojectConfigFile
Pyproject config file.
Extends winipedia_utils pyproject config file to add additional config.
Source code in notty/rig/configs/configs.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
_configs()
Get the configs.
Source code in notty/rig/configs/configs.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | |
dependencies()
Get the dependencies.
Source code in notty/rig/configs/configs.py
116 117 118 119 120 | |
ReleaseWorkflowConfigFile
Bases: WorkflowConfigFileMixin, ReleaseWorkflowConfigFile
Release workflow.
Extends winipedia_utils release workflow to add additional steps. This is necessary to make pyside6 work on github actions which is a headless linux environment.
Source code in notty/rig/configs/configs.py
72 73 74 75 76 77 78 | |
step_pre_install_pygame_from_binary()
Get the step to install PySide6 dependencies.
Source code in notty/rig/configs/configs.py
53 54 55 56 57 58 | |
steps_core_installed_setup(*args, **kwargs)
Get the setup steps.
We need to install additional system dependencies for pyside6.
Source code in notty/rig/configs/configs.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
WorkflowConfigFileMixin
Bases: WorkflowConfigFile
Mixin to add PySide6-specific workflow steps.
This mixin provides common overrides for PySide6 workflows to work on GitHub Actions headless Linux environments.
Source code in notty/rig/configs/configs.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |
step_pre_install_pygame_from_binary()
Get the step to install PySide6 dependencies.
Source code in notty/rig/configs/configs.py
53 54 55 56 57 58 | |
steps_core_installed_setup(*args, **kwargs)
Get the setup steps.
We need to install additional system dependencies for pyside6.
Source code in notty/rig/configs/configs.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
resources
init module.
music
init module.
visuals
init module.
cards
init module.
black
init module.
blue
init module.
green
init module.
red
init module.
yellow
init module.
deck
init module.
hand
init module.
players
init module.
tests
init module.
fixtures
init module.
fixtures
Defines pytest fixtures.
assert_override_works(assert_package_manager_is_up_to_date)
Checks that the previous fixture override worked as expected.
Source code in notty/rig/tests/fixtures/fixtures.py
16 17 18 19 20 21 22 | |
assert_package_manager_is_up_to_date()
Overrides pyrigs fixture of the same name to check overriding works correctly.
Source code in notty/rig/tests/fixtures/fixtures.py
8 9 10 11 12 13 | |
mirror_test
Subclassing MirrorTest to test the notty game.
MirrorTestConfigFile
Bases: MirrorTestConfigFile
Subclassing MirrorTest to test the notty game.
Source code in notty/rig/tests/mirror_test.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | |
test_func_skeleton(test_func_name)
Get the test function skeleton.
Source code in notty/rig/tests/mirror_test.py
9 10 11 12 13 14 15 | |
test_method_skeleton(test_method_name)
Get the test method skeleton.
Source code in notty/rig/tests/mirror_test.py
17 18 19 20 21 22 | |
tools
Tool wrappers for CLI tools used in development workflows.
Tools are subclasses of Tool providing methods that return Args objects
for type-safe command construction and execution.
type_checker
Overriding the type checker to get from ty to mypy.
MypyTypeChecker
Bases: TypeChecker
Mypy type checker.
Source code in notty/rig/tools/type_checker.py
7 8 9 10 11 12 13 14 15 16 | |
check_args(*args)
Get the args for checking types.
Source code in notty/rig/tools/type_checker.py
14 15 16 | |
name()
Get the name of the type checker.
Source code in notty/rig/tools/type_checker.py
10 11 12 | |
src
src package.
computer_action_selection
Computer action selection.
choose_card_to_discard(game)
Choose which card to discard in draw-discard-discard action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
game
|
VisualGame
|
The game instance. |
required |
Returns:
| Type | Description |
|---|---|
VisualCard
|
The card to discard. |
Source code in notty/src/computer_action_selection.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
choose_draw_count(game)
Choose how many cards to draw (1-3) using strategic analysis.
Strategy: - Draw fewer cards if hand is nearly full (approaching 20 card limit) - Draw more cards if we have potential to form groups - Draw fewer cards if opponents are close to winning - Consider deck size to avoid running out
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
game
|
VisualGame
|
The game instance. |
required |
Returns:
| Type | Description |
|---|---|
int
|
Number of cards to draw (1-3). |
Source code in notty/src/computer_action_selection.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
choose_target_player(game)
Choose which player to steal from.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
game
|
VisualGame
|
The game instance. |
required |
Returns:
| Type | Description |
|---|---|
VisualPlayer
|
The target player to steal from. |
Source code in notty/src/computer_action_selection.py
123 124 125 126 127 128 129 130 131 132 133 134 135 | |
computer_chooses_action(game)
Computer chooses an action using Q-Learning.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
game
|
VisualGame
|
The game instance. |
required |
Source code in notty/src/computer_action_selection.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | |
find_best_discard_group(game)
Find the best group of cards to discard.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
game
|
VisualGame
|
The game instance. |
required |
Returns:
| Type | Description |
|---|---|
list[VisualCard] | None
|
List of cards to discard, or None if no valid group found. |
Source code in notty/src/computer_action_selection.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | |
get_qlearning_agent()
Get or create the Q-Learning agent.
Returns:
| Type | Description |
|---|---|
QLearningAgent
|
The Q-Learning agent instance. |
Source code in notty/src/computer_action_selection.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | |
reset_qlearning_episode()
Reset the Q-Learning agent for a new episode/game.
Source code in notty/src/computer_action_selection.py
270 271 272 273 | |
save_qlearning_agent()
Save the Q-Learning agent's Q-table.
Source code in notty/src/computer_action_selection.py
263 264 265 266 267 | |
consts
Constants for the game.
player_selection
Player selection screen and player setup.
get_players(screen)
Get the players with a selection screen to choose who you are.
Source code in notty/src/player_selection.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |
show_opponent_selection_screen(screen, human_player)
Show a screen to select 1-2 opponents.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
screen
|
Surface
|
The pygame display surface. |
required |
human_player
|
str
|
The name of the human player to exclude. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
List of selected opponent names. |
Source code in notty/src/player_selection.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
show_player_selection_screen(screen)
Show a screen to select which player you want to be.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
screen
|
Surface
|
The pygame display surface. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The name of the selected player. |
Source code in notty/src/player_selection.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
qlearning_agent
Q-Learning agent for Notty card game.
QLearningAgent
Q-Learning agent that learns to play Notty through reinforcement learning.
Source code in notty/src/qlearning_agent.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | |
__init__(alpha=0.1, gamma=0.9, epsilon=0.2, epsilon_decay=0.9995, epsilon_min=0.05)
Initialize Q-Learning agent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alpha
|
float
|
Learning rate (how much to update Q-values). |
0.1
|
gamma
|
float
|
Discount factor (how much to value future rewards). |
0.9
|
epsilon
|
float
|
Exploration rate (probability of random action). |
0.2
|
epsilon_decay
|
float
|
Rate at which epsilon decreases. |
0.9995
|
epsilon_min
|
float
|
Minimum epsilon value. |
0.05
|
Source code in notty/src/qlearning_agent.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
choose_action(game)
Choose an action using epsilon-greedy policy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
game
|
VisualGame
|
The game instance. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The chosen action name. |
Source code in notty/src/qlearning_agent.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
get_state(game)
Extract state features from the game.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
game
|
VisualGame
|
The game instance. |
required |
Returns:
| Type | Description |
|---|---|
tuple[int, int, bool, int]
|
Tuple representing the current state. |
Source code in notty/src/qlearning_agent.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
get_stats()
Get learning statistics.
Returns:
| Type | Description |
|---|---|
dict[str, int | float]
|
Dictionary with learning statistics. |
Source code in notty/src/qlearning_agent.py
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | |
learn(game, reward)
Update Q-values based on the reward received.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
game
|
VisualGame
|
The game instance. |
required |
reward
|
float
|
The reward received for the last action. |
required |
Source code in notty/src/qlearning_agent.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | |
load(filepath='notty_qtable.pkl')
Load Q-table from file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath
|
str
|
Path to load the Q-table from. |
'notty_qtable.pkl'
|
Returns:
| Type | Description |
|---|---|
bool
|
True if loaded successfully, False otherwise. |
Source code in notty/src/qlearning_agent.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 | |
reset_episode()
Reset episode-specific tracking.
Source code in notty/src/qlearning_agent.py
151 152 153 154 | |
save(filepath='notty_qtable.pkl')
Save Q-table to file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath
|
str
|
Path to save the Q-table. |
'notty_qtable.pkl'
|
Source code in notty/src/qlearning_agent.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
utils
utils.
get_qlearning_save_path()
Get the path for saving Q-Learning agent data.
Returns:
| Type | Description |
|---|---|
Path
|
Path to the Q-table save file. |
Source code in notty/src/utils.py
52 53 54 55 56 57 58 | |
get_user_data_dir()
Get the user data directory for saving game data.
This works correctly both in development and when packaged with PyInstaller.
Returns:
| Type | Description |
|---|---|
Path
|
Path to the user data directory. |
Source code in notty/src/utils.py
38 39 40 41 42 43 44 45 46 47 48 49 | |
get_window_size()
Get the window size based on screen dimensions.
Returns:
| Type | Description |
|---|---|
tuple[int, int]
|
Tuple of (width, height) for the window. |
Source code in notty/src/utils.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | |
visual
init module.
action_board
Action board for displaying available actions to the human player.
Action
Represents an action in the Notty game.
Source code in notty/src/visual/action_board.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
get_all_actions()
classmethod
Get all actions.
Source code in notty/src/visual/action_board.py
30 31 32 33 34 35 36 37 38 39 40 | |
ActionBoard
Action board that displays available actions for the human player.
Source code in notty/src/visual/action_board.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | |
__init__(screen, human_player_index, game)
Initialize the action board.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
screen
|
Surface
|
The pygame display surface. |
required |
human_player_index
|
int
|
Index of the human player (0-2). |
required |
game
|
VisualGame
|
The game instance for checking action availability. |
required |
Source code in notty/src/visual/action_board.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
_setup_buttons()
Set up the action buttons.
Source code in notty/src/visual/action_board.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
draw()
Draw the action board and all buttons.
Automatically updates button states before drawing.
Source code in notty/src/visual/action_board.py
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | |
handle_click(mouse_x, mouse_y)
Handle click on action board.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mouse_x
|
int
|
Mouse x coordinate. |
required |
mouse_y
|
int
|
Mouse y coordinate. |
required |
Returns:
| Type | Description |
|---|---|
None
|
The action name if a button was clicked, None otherwise. |
Source code in notty/src/visual/action_board.py
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | |
update_button_states(game)
Update button enabled states based on current game state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
game
|
VisualGame
|
The game instance to check action availability. |
required |
Source code in notty/src/visual/action_board.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | |
update_hover(mouse_x, mouse_y)
Update hover state for all buttons.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mouse_x
|
int
|
Mouse x coordinate. |
required |
mouse_y
|
int
|
Mouse y coordinate. |
required |
Source code in notty/src/visual/action_board.py
240 241 242 243 244 245 246 247 248 | |
ActionButton
Represents a clickable action button.
Source code in notty/src/visual/action_board.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | |
__init__(x, y, width, height, text, action_name, *, enabled=True)
Initialize an action button.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
int
|
X coordinate of the button. |
required |
y
|
int
|
Y coordinate of the button. |
required |
width
|
int
|
Width of the button. |
required |
height
|
int
|
Height of the button. |
required |
text
|
str
|
Text to display on the button. |
required |
action_name
|
str
|
Name of the action this button represents. |
required |
enabled
|
bool
|
Whether the button is enabled. |
True
|
Source code in notty/src/visual/action_board.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
draw(screen)
Draw the button.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
screen
|
Surface
|
The pygame display surface. |
required |
Source code in notty/src/visual/action_board.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | |
is_clicked(mouse_x, mouse_y)
Check if the button was clicked.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mouse_x
|
int
|
Mouse x coordinate. |
required |
mouse_y
|
int
|
Mouse y coordinate. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the button was clicked and is enabled. |
Source code in notty/src/visual/action_board.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
update_hover(mouse_x, mouse_y)
Update hover state based on mouse position.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mouse_x
|
int
|
Mouse x coordinate. |
required |
mouse_y
|
int
|
Mouse y coordinate. |
required |
Source code in notty/src/visual/action_board.py
94 95 96 97 98 99 100 101 102 103 104 | |
base
Contains a base clöass Visual to represent a visual element.
Visual
Bases: ABC
Base class for all visual elements.
Source code in notty/src/visual/base.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | |
__init__(x, y, height, width, screen)
Initialize a visual element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
int
|
X coordinate. Always represents the top-left corner. |
required |
y
|
int
|
Y coordinate. Always represents the top-left corner. |
required |
height
|
int
|
Height of the visual element. |
required |
width
|
int
|
Width of the visual element. |
required |
screen
|
Surface
|
The pygame display surface. |
required |
Source code in notty/src/visual/base.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |
draw()
Draw the visual element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
screen
|
The pygame display surface. |
required |
Source code in notty/src/visual/base.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |
get_center()
Get the center of the visual element.
Source code in notty/src/visual/base.py
44 45 46 | |
get_png_name()
abstractmethod
Get the png for the visual element.
Source code in notty/src/visual/base.py
97 98 99 | |
get_png_path()
Get the png for the visual element.
Source code in notty/src/visual/base.py
93 94 95 | |
get_png_pkg()
abstractmethod
Get the png for the visual element.
Source code in notty/src/visual/base.py
101 102 103 | |
move(x, y)
Move the visual element.
Animates the movement in a straight line to that given location.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
int
|
X coordinate. |
required |
y
|
int
|
Y coordinate. |
required |
Source code in notty/src/visual/base.py
48 49 50 51 52 53 54 55 56 57 58 | |
set_position(x, y)
Set the position of the visual element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
int
|
X coordinate. |
required |
y
|
int
|
Y coordinate. |
required |
Source code in notty/src/visual/base.py
60 61 62 63 64 65 66 67 68 | |
base_selector
Base selector dialog for choosing items with images.
BaseSelector
Bases: ABC
Base class for selector dialogs.
Source code in notty/src/visual/base_selector.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | |
__init__(screen, title, items, *, max_selections=1, validation_func=None)
Initialize the base selector.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
screen
|
Surface
|
The pygame display surface. |
required |
title
|
str
|
Title to display in the dialog. |
required |
items
|
list[T]
|
List of items that can be selected. |
required |
max_selections
|
int
|
Maximum number of items that can be selected (1 for single select). |
1
|
validation_func
|
Callable[[list[T]], bool] | None
|
Optional function to validate if selection is valid. |
None
|
Source code in notty/src/visual/base_selector.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
_draw()
Draw the selector dialog.
Source code in notty/src/visual/base_selector.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | |
_get_button_dimensions()
abstractmethod
Get button dimensions (width, height, spacing).
Returns:
| Type | Description |
|---|---|
tuple[int, int, int]
|
Tuple of (button_width, button_height, button_spacing). |
Source code in notty/src/visual/base_selector.py
144 145 146 147 148 149 150 | |
_get_dialog_dimensions()
abstractmethod
Get dialog dimensions.
Returns:
| Type | Description |
|---|---|
tuple[int, int]
|
Tuple of (dialog_width, dialog_height). |
Source code in notty/src/visual/base_selector.py
152 153 154 155 156 157 158 | |
_get_selected_items()
Get the list of currently selected items.
Returns:
| Type | Description |
|---|---|
list[T]
|
List of selected items. |
Source code in notty/src/visual/base_selector.py
160 161 162 163 164 165 166 | |
_is_valid_selection()
Check if the current selection is valid.
Returns:
| Type | Description |
|---|---|
bool
|
True if the selection is valid. |
Source code in notty/src/visual/base_selector.py
168 169 170 171 172 173 174 175 176 177 178 179 | |
_setup_buttons()
abstractmethod
Set up the selectable buttons. Must be implemented by subclasses.
Source code in notty/src/visual/base_selector.py
140 141 142 | |
show()
Show the selector and wait for user input.
Returns:
| Type | Description |
|---|---|
list[T] | T | None
|
The selected item(s). Returns single item if max_selections=1, list otherwise. |
list[T] | T | None
|
Returns None if no selection was made. |
Source code in notty/src/visual/base_selector.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | |
SelectableButton
Bases: ABC
Base class for selectable buttons with images.
Source code in notty/src/visual/base_selector.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |
__init__(x, y, width, height, item, image=None, *, enabled=True, selectable=False)
Initialize a selectable button.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
int
|
X coordinate of the button. |
required |
y
|
int
|
Y coordinate of the button. |
required |
width
|
int
|
Width of the button. |
required |
height
|
int
|
Height of the button. |
required |
item
|
T
|
The item this button represents. |
required |
image
|
Surface | None
|
The image to display. |
None
|
enabled
|
bool
|
Whether the button is enabled (clickable). |
True
|
selectable
|
bool
|
Whether the button can be selected (for multi-select). |
False
|
Source code in notty/src/visual/base_selector.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | |
draw(screen)
abstractmethod
Draw the button.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
screen
|
Surface
|
The pygame display surface. |
required |
Source code in notty/src/visual/base_selector.py
101 102 103 104 105 106 107 | |
is_clicked(mouse_x, mouse_y)
Check if the button was clicked.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mouse_x
|
int
|
Mouse x coordinate. |
required |
mouse_y
|
int
|
Mouse y coordinate. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the button was clicked and is enabled. |
Source code in notty/src/visual/base_selector.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
toggle_selection(current_selected_count, max_selections)
Toggle the selection state of this button.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current_selected_count
|
int
|
Number of currently selected items. |
required |
max_selections
|
int
|
Maximum number of selections allowed. |
required |
Source code in notty/src/visual/base_selector.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
update_hover(mouse_x, mouse_y)
Update hover state based on mouse position.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mouse_x
|
int
|
Mouse x coordinate. |
required |
mouse_y
|
int
|
Mouse y coordinate. |
required |
Source code in notty/src/visual/base_selector.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
card
visual card.
Color
Color class for the Notty game.
Source code in notty/src/visual/card.py
13 14 15 16 17 18 19 20 21 22 23 24 25 | |
get_all_colors()
classmethod
Get all colors.
Source code in notty/src/visual/card.py
22 23 24 25 | |
Number
Number class for the Notty game.
Source code in notty/src/visual/card.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | |
get_all_numbers()
classmethod
Get all numbers.
Source code in notty/src/visual/card.py
41 42 43 44 | |
VisualCard
Bases: Visual
Visual card.
Source code in notty/src/visual/card.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
__init__(color, number, x, y, screen)
Initialize a visual card.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
color
|
str
|
The color of the card. |
required |
number
|
int
|
The number of the card. |
required |
x
|
int
|
X coordinate. Always represents the top-left corner. |
required |
y
|
int
|
Y coordinate. Always represents the top-left corner. |
required |
height
|
Height of the visual element. |
required | |
width
|
Width of the visual element. |
required | |
screen
|
Surface
|
The pygame display surface. |
required |
Source code in notty/src/visual/card.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
draw()
Draw the visual element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
screen
|
The pygame display surface. |
required |
Source code in notty/src/visual/base.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |
get_center()
Get the center of the visual element.
Source code in notty/src/visual/base.py
44 45 46 | |
get_png_name()
Get the png for the visual element.
Source code in notty/src/visual/card.py
73 74 75 | |
get_png_path()
Get the png for the visual element.
Source code in notty/src/visual/base.py
93 94 95 | |
get_png_pkg()
Get the png for the visual element.
Source code in notty/src/visual/card.py
77 78 79 80 | |
move(x, y)
Move the visual element.
Animates the movement in a straight line to that given location.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
int
|
X coordinate. |
required |
y
|
int
|
Y coordinate. |
required |
Source code in notty/src/visual/base.py
48 49 50 51 52 53 54 55 56 57 58 | |
set_position(x, y)
Set the position of the visual element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
int
|
X coordinate. |
required |
y
|
int
|
Y coordinate. |
required |
Source code in notty/src/visual/base.py
60 61 62 63 64 65 66 67 68 | |
card_selector
Card selector dialog for choosing which card to discard.
CardButton
Bases: SelectableButton['VisualCard']
Represents a clickable card button.
Source code in notty/src/visual/card_selector.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
__init__(x, y, width, height, card, card_image)
Initialize a card button.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
int
|
X coordinate of the button. |
required |
y
|
int
|
Y coordinate of the button. |
required |
width
|
int
|
Width of the button. |
required |
height
|
int
|
Height of the button. |
required |
card
|
VisualCard
|
The card this button represents. |
required |
card_image
|
Surface
|
The image of the card. |
required |
Source code in notty/src/visual/card_selector.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
draw(screen)
Draw the button.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
screen
|
Surface
|
The pygame display surface. |
required |
Source code in notty/src/visual/card_selector.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
is_clicked(mouse_x, mouse_y)
Check if the button was clicked.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mouse_x
|
int
|
Mouse x coordinate. |
required |
mouse_y
|
int
|
Mouse y coordinate. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the button was clicked and is enabled. |
Source code in notty/src/visual/base_selector.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
toggle_selection(current_selected_count, max_selections)
Toggle the selection state of this button.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current_selected_count
|
int
|
Number of currently selected items. |
required |
max_selections
|
int
|
Maximum number of selections allowed. |
required |
Source code in notty/src/visual/base_selector.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
update_hover(mouse_x, mouse_y)
Update hover state based on mouse position.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mouse_x
|
int
|
Mouse x coordinate. |
required |
mouse_y
|
int
|
Mouse y coordinate. |
required |
Source code in notty/src/visual/base_selector.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
CardSelector
Bases: BaseSelector['VisualCard']
Dialog for selecting a card to discard.
Source code in notty/src/visual/card_selector.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
__init__(screen, available_cards)
Initialize the card selector.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
screen
|
Surface
|
The pygame display surface. |
required |
available_cards
|
list[VisualCard]
|
List of cards that can be selected. |
required |
Source code in notty/src/visual/card_selector.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |
_draw()
Draw the selector dialog.
Source code in notty/src/visual/base_selector.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | |
_get_button_dimensions()
Get button dimensions (width, height, spacing).
Returns:
| Type | Description |
|---|---|
tuple[int, int, int]
|
Tuple of (button_width, button_height, button_spacing). |
Source code in notty/src/visual/card_selector.py
93 94 95 96 97 98 99 100 101 102 | |
_get_dialog_dimensions()
Get dialog dimensions.
Returns:
| Type | Description |
|---|---|
tuple[int, int]
|
Tuple of (dialog_width, dialog_height). |
Source code in notty/src/visual/card_selector.py
104 105 106 107 108 109 110 111 112 | |
_get_selected_items()
Get the list of currently selected items.
Returns:
| Type | Description |
|---|---|
list[T]
|
List of selected items. |
Source code in notty/src/visual/base_selector.py
160 161 162 163 164 165 166 | |
_is_valid_selection()
Check if the current selection is valid.
Returns:
| Type | Description |
|---|---|
bool
|
True if the selection is valid. |
Source code in notty/src/visual/base_selector.py
168 169 170 171 172 173 174 175 176 177 178 179 | |
_setup_buttons()
Set up the card buttons.
Source code in notty/src/visual/card_selector.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
show()
Show the selector and wait for user input.
Returns:
| Type | Description |
|---|---|
list[T] | T | None
|
The selected item(s). Returns single item if max_selections=1, list otherwise. |
list[T] | T | None
|
Returns None if no selection was made. |
Source code in notty/src/visual/base_selector.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | |
cards_selector
Cards selector dialog for choosing multiple cards to discard as a group.
CardsSelector
Bases: BaseSelector['VisualCard']
Dialog for selecting multiple cards to discard as a group.
Source code in notty/src/visual/cards_selector.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 | |
__init__(screen, available_cards, validation_func)
Initialize the cards selector.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
screen
|
Surface
|
The pygame display surface. |
required |
available_cards
|
list[VisualCard]
|
List of cards that can be selected. |
required |
validation_func
|
Callable[[list[VisualCard]], bool]
|
Function to validate if selected cards form a valid group. |
required |
Source code in notty/src/visual/cards_selector.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
_draw()
Draw the cards selector dialog.
Source code in notty/src/visual/cards_selector.py
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 | |
_get_button_dimensions()
Get button dimensions (width, height, spacing).
Returns:
| Type | Description |
|---|---|
tuple[int, int, int]
|
Tuple of (button_width, button_height, button_spacing). |
Source code in notty/src/visual/cards_selector.py
205 206 207 208 209 210 211 212 213 214 | |
_get_dialog_dimensions()
Get dialog dimensions.
Returns:
| Type | Description |
|---|---|
tuple[int, int]
|
Tuple of (dialog_width, dialog_height). |
Source code in notty/src/visual/cards_selector.py
216 217 218 219 220 221 222 223 224 | |
_get_selected_items()
Get the list of currently selected items.
Returns:
| Type | Description |
|---|---|
list[T]
|
List of selected items. |
Source code in notty/src/visual/base_selector.py
160 161 162 163 164 165 166 | |
_is_valid_selection()
Check if the current selection is valid.
Returns:
| Type | Description |
|---|---|
bool
|
True if the selection is valid. |
Source code in notty/src/visual/base_selector.py
168 169 170 171 172 173 174 175 176 177 178 179 | |
_setup_buttons()
Set up the card and submit buttons.
Source code in notty/src/visual/cards_selector.py
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | |
_update_submit_button_state()
Update the submit button enabled state based on selected cards.
Source code in notty/src/visual/cards_selector.py
268 269 270 271 | |
show()
Show the cards selector and wait for user input.
Returns:
| Type | Description |
|---|---|
list[VisualCard]
|
The list of selected cards. |
Source code in notty/src/visual/cards_selector.py
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | |
MultiCardButton
Bases: SelectableButton['VisualCard']
Represents a clickable card button that can be selected/deselected.
Source code in notty/src/visual/cards_selector.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |
__init__(x, y, width, height, card, card_image)
Initialize a multi-card button.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
int
|
X coordinate of the button. |
required |
y
|
int
|
Y coordinate of the button. |
required |
width
|
int
|
Width of the button. |
required |
height
|
int
|
Height of the button. |
required |
card
|
VisualCard
|
The card this button represents. |
required |
card_image
|
Surface
|
The image of the card. |
required |
Source code in notty/src/visual/cards_selector.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
draw(screen)
Draw the button.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
screen
|
Surface
|
The pygame display surface. |
required |
Source code in notty/src/visual/cards_selector.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |
is_clicked(mouse_x, mouse_y)
Check if the button was clicked.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mouse_x
|
int
|
Mouse x coordinate. |
required |
mouse_y
|
int
|
Mouse y coordinate. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the button was clicked and is enabled. |
Source code in notty/src/visual/base_selector.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
toggle_selection(current_selected_count, max_selections)
Toggle the selection state of this button.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current_selected_count
|
int
|
Number of currently selected items. |
required |
max_selections
|
int
|
Maximum number of selections allowed. |
required |
Source code in notty/src/visual/base_selector.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
update_hover(mouse_x, mouse_y)
Update hover state based on mouse position.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mouse_x
|
int
|
Mouse x coordinate. |
required |
mouse_y
|
int
|
Mouse y coordinate. |
required |
Source code in notty/src/visual/base_selector.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
SubmitButton
Represents a submit button.
Source code in notty/src/visual/cards_selector.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | |
__init__(x, y, width, height)
Initialize a submit button.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
int
|
X coordinate of the button. |
required |
y
|
int
|
Y coordinate of the button. |
required |
width
|
int
|
Width of the button. |
required |
height
|
int
|
Height of the button. |
required |
Source code in notty/src/visual/cards_selector.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
draw(screen)
Draw the button.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
screen
|
Surface
|
The pygame display surface. |
required |
Source code in notty/src/visual/cards_selector.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | |
is_clicked(mouse_x, mouse_y)
Check if the button was clicked.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mouse_x
|
int
|
Mouse x coordinate. |
required |
mouse_y
|
int
|
Mouse y coordinate. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the button was clicked and is enabled. |
Source code in notty/src/visual/cards_selector.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
update_hover(mouse_x, mouse_y)
Update hover state based on mouse position.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mouse_x
|
int
|
Mouse x coordinate. |
required |
mouse_y
|
int
|
Mouse y coordinate. |
required |
Source code in notty/src/visual/cards_selector.py
130 131 132 133 134 135 136 137 138 139 140 | |
deck
visual deck.
VisualDeck
Bases: Visual
Visual deck.
Source code in notty/src/visual/deck.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
__init__(screen)
Initialize a visual deck.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
X coordinate. Always represents the top-left corner. |
required | |
y
|
Y coordinate. Always represents the top-left corner. |
required | |
height
|
Height of the visual element. |
required | |
width
|
Width of the visual element. |
required | |
screen
|
Surface
|
The pygame display surface. |
required |
deck
|
The deck to visualize. |
required |
Source code in notty/src/visual/deck.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
__len__()
Return the number of cards in the deck.
Source code in notty/src/visual/deck.py
148 149 150 | |
_initialize_deck()
Create all 90 cards (2 of each color-number combination).
Source code in notty/src/visual/deck.py
61 62 63 64 65 66 67 68 69 | |
add_card(card)
Add a single card back to the deck (used when discarding).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
card
|
VisualCard
|
VisualCard to add back to the deck. |
required |
Source code in notty/src/visual/deck.py
120 121 122 123 124 125 126 127 128 129 130 | |
add_cards(cards)
Add cards back to the deck (used when discarding).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cards
|
list[VisualCard]
|
List of cards to add back to the deck. |
required |
Source code in notty/src/visual/deck.py
111 112 113 114 115 116 117 118 | |
draw()
Draw the visual element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
screen
|
The pygame display surface. |
required |
Source code in notty/src/visual/deck.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
draw_card()
Draw the top card from the deck.
Returns:
| Type | Description |
|---|---|
VisualCard
|
The top card, or raises ValueError if deck is empty. |
Source code in notty/src/visual/deck.py
83 84 85 86 87 88 89 90 91 92 | |
draw_cards(count)
Draw multiple cards from the deck.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
count
|
int
|
Number of cards to draw. |
required |
Returns:
| Type | Description |
|---|---|
list[VisualCard]
|
List of drawn cards (may be fewer than requested if deck runs out). |
Source code in notty/src/visual/deck.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
get_center()
Get the center of the visual element.
Source code in notty/src/visual/base.py
44 45 46 | |
get_png_name()
Get the png for the visual element.
Source code in notty/src/visual/deck.py
71 72 73 | |
get_png_path()
Get the png for the visual element.
Source code in notty/src/visual/base.py
93 94 95 | |
get_png_pkg()
Get the png for the visual element.
Source code in notty/src/visual/deck.py
75 76 77 | |
is_empty()
Check if the deck is empty.
Returns:
| Type | Description |
|---|---|
bool
|
True if the deck has no cards, False otherwise. |
Source code in notty/src/visual/deck.py
132 133 134 135 136 137 138 | |
move(x, y)
Move the visual element.
Animates the movement in a straight line to that given location.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
int
|
X coordinate. |
required |
y
|
int
|
Y coordinate. |
required |
Source code in notty/src/visual/base.py
48 49 50 51 52 53 54 55 56 57 58 | |
set_position(x, y)
Set the position of the visual element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
int
|
X coordinate. |
required |
y
|
int
|
Y coordinate. |
required |
Source code in notty/src/visual/base.py
60 61 62 63 64 65 66 67 68 | |
shuffle()
Shuffle the deck.
Source code in notty/src/visual/deck.py
79 80 81 | |
size()
Get the number of cards in the deck.
Returns:
| Type | Description |
|---|---|
int
|
Number of cards currently in the deck. |
Source code in notty/src/visual/deck.py
140 141 142 143 144 145 146 | |
game
visual game.
VisualGame
Bases: Visual
visual game class.
Source code in notty/src/visual/game.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 | |
__init__(screen, players)
Initialize a visual game.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
players
|
list[VisualPlayer]
|
List of players. |
required |
screen
|
Surface
|
The pygame display surface. |
required |
Source code in notty/src/visual/game.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
_create_action_board()
Create action board for the human player.
Returns:
| Type | Description |
|---|---|
ActionBoard
|
ActionBoard instance if there's a human player, None otherwise. |
Source code in notty/src/visual/game.py
114 115 116 117 118 119 120 121 122 123 124 125 126 | |
action_is_possible(action)
Check if an action is possible.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action
|
str
|
The action to check. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if action is possible. |
Source code in notty/src/visual/game.py
574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 | |
all_players_have_no_cards()
Check if all players have no cards.
Source code in notty/src/visual/game.py
570 571 572 | |
calculate_reward(player_index, action)
Calculate reward for Q-learning agent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
player_index
|
int
|
Index of the player who took the action. |
required |
action
|
str
|
The action that was taken. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Reward value for the action. |
Source code in notty/src/visual/game.py
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | |
can_computer_act()
Check if enough time has passed for computer to take an action.
Returns:
| Type | Description |
|---|---|
bool
|
True if computer can act (1 second has passed since last action). |
Source code in notty/src/visual/game.py
136 137 138 139 140 141 142 143 144 145 | |
can_discard_group()
Check if current player can discard a group of cards.
Returns:
| Type | Description |
|---|---|
bool
|
True if action is available. |
Source code in notty/src/visual/game.py
493 494 495 496 497 498 499 500 501 502 503 504 505 506 | |
card_group_is_valid(cards)
Check if a group of cards is valid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cards
|
list[VisualCard]
|
List of cards to check. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if group is valid. |
Source code in notty/src/visual/game.py
456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 | |
check_win_condition()
Check if any player has won (empty hand).
Returns:
| Type | Description |
|---|---|
bool
|
True if game is over, False otherwise. |
Source code in notty/src/visual/game.py
195 196 197 198 199 200 201 202 203 204 205 | |
distribute_starting_cards(game)
classmethod
Distribute starting cards to players.
Source code in notty/src/visual/game.py
563 564 565 566 567 568 | |
do_action(action, count=None, card=None, cards=None, target_player=None)
Do an action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action
|
str
|
The action to do. |
required |
count
|
int | None
|
Number of cards to draw (for draw multiple action). |
None
|
card
|
VisualCard | None
|
Card to discard (for draw discard discard action). |
None
|
cards
|
list[VisualCard] | None
|
Cards to discard (for discard group action). |
None
|
target_player
|
VisualPlayer | None
|
Player to steal from (for steal action). |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if action was successful. |
Source code in notty/src/visual/game.py
620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 | |
draw()
Draw the game.
Source code in notty/src/visual/game.py
71 72 73 74 75 76 77 78 | |
draw_current_player_border()
Draw a black rectangle around the current player's hand.
Source code in notty/src/visual/game.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
get_all_possible_actions()
Get all possible actions.
Returns:
| Type | Description |
|---|---|
list[str]
|
List of possible actions. |
Source code in notty/src/visual/game.py
608 609 610 611 612 613 614 615 616 617 618 | |
get_center()
Get the center of the visual element.
Source code in notty/src/visual/base.py
44 45 46 | |
get_current_player()
Get the current player whose turn it is.
Returns:
| Type | Description |
|---|---|
VisualPlayer
|
The current player. |
Source code in notty/src/visual/game.py
128 129 130 131 132 133 134 | |
get_discardable_groups()
Get all discardable groups.
Returns:
| Type | Description |
|---|---|
list[list[VisualCard]]
|
List of discardable groups. |
Source code in notty/src/visual/game.py
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 | |
get_next_player()
Get the next player.
Returns:
| Type | Description |
|---|---|
VisualPlayer
|
The next player. |
Source code in notty/src/visual/game.py
159 160 161 162 163 164 165 | |
get_next_player_index()
Get the index of the next player.
Returns:
| Type | Description |
|---|---|
int
|
The index of the next player. |
Source code in notty/src/visual/game.py
167 168 169 170 171 172 173 | |
get_other_players()
Get all players except the current player.
Returns:
| Type | Description |
|---|---|
list[VisualPlayer]
|
List of other players. |
Source code in notty/src/visual/game.py
151 152 153 154 155 156 157 | |
get_png_name()
Get the png for the visual element.
Source code in notty/src/visual/game.py
101 102 103 | |
get_png_path()
Get the png for the visual element.
Source code in notty/src/visual/base.py
93 94 95 | |
get_png_pkg()
Get the png for the visual element.
Source code in notty/src/visual/game.py
105 106 107 | |
mark_computer_action()
Mark that the computer has taken an action.
Source code in notty/src/visual/game.py
147 148 149 | |
move(x, y)
Move the visual element.
Animates the movement in a straight line to that given location.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
int
|
X coordinate. |
required |
y
|
int
|
Y coordinate. |
required |
Source code in notty/src/visual/base.py
48 49 50 51 52 53 54 55 56 57 58 | |
next_turn()
Move to the next player's turn.
Source code in notty/src/visual/game.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | |
play_for_me()
Let the computer play for the human player.
Returns:
| Type | Description |
|---|---|
bool
|
True if action was successful. |
Source code in notty/src/visual/game.py
264 265 266 267 268 269 270 271 272 273 274 275 276 277 | |
player_can_draw_discard_discard()
Check if current player can draw and discard two cards.
Returns:
| Type | Description |
|---|---|
bool
|
True if action is available. |
Source code in notty/src/visual/game.py
410 411 412 413 414 415 416 417 418 419 | |
player_can_draw_discard_draw()
Check if current player can draw and discard a card.
Returns:
| Type | Description |
|---|---|
bool
|
True if action is available. |
Source code in notty/src/visual/game.py
383 384 385 386 387 388 389 390 391 392 | |
player_can_draw_multiple()
Check if current player can draw cards.
Returns:
| Type | Description |
|---|---|
bool
|
True if action is available. |
Source code in notty/src/visual/game.py
279 280 281 282 283 284 285 286 287 288 289 | |
player_can_pass()
Check if current player can pass.
Returns:
| Type | Description |
|---|---|
bool
|
True if action is available. |
Source code in notty/src/visual/game.py
242 243 244 245 246 247 248 249 | |
player_can_steal()
Check if current player can steal a card.
Returns:
| Type | Description |
|---|---|
bool
|
True if action is available. |
Source code in notty/src/visual/game.py
331 332 333 334 335 336 337 338 339 340 341 | |
player_discards_group(cards=None)
VisualPlayer discards a group of cards.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cards
|
list[VisualCard] | None
|
List of cards to discard. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if action was successful. |
Source code in notty/src/visual/game.py
524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 | |
player_draw_discard_discards(card=None)
VisualPlayer discards two cards.
Returns:
| Type | Description |
|---|---|
bool
|
True if action was successful. |
Source code in notty/src/visual/game.py
421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 | |
player_draw_discard_draws()
VisualPlayer draws one card and discards another.
Returns:
| Type | Description |
|---|---|
bool
|
True if action was successful. |
Source code in notty/src/visual/game.py
394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 | |
player_draws_multiple(count=None)
VisualPlayer draws cards.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
count
|
int | None
|
Number of cards to draw. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if action was successful. |
Source code in notty/src/visual/game.py
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | |
player_passes()
VisualPlayer passes.
Returns:
| Type | Description |
|---|---|
bool
|
True if action was successful. |
Source code in notty/src/visual/game.py
251 252 253 254 255 256 257 258 259 260 261 262 | |
player_steals(target_player=None)
VisualPlayer steals a card from another player.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_player
|
VisualPlayer | None
|
VisualPlayer to steal from. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if action was successful. |
Source code in notty/src/visual/game.py
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 | |
request_card_from_player()
Request a card from the player.
Returns:
| Type | Description |
|---|---|
VisualCard
|
The card requested. |
Source code in notty/src/visual/game.py
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 | |
request_cards_from_player()
Request cards from the player.
Returns:
| Type | Description |
|---|---|
list[VisualCard]
|
The cards requested. |
Source code in notty/src/visual/game.py
544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 | |
request_number_from_player()
Request a number from the player.
Returns:
| Type | Description |
|---|---|
int
|
The number requested. |
Source code in notty/src/visual/game.py
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | |
request_player_from_player()
Request a player from the player.
Returns:
| Type | Description |
|---|---|
VisualPlayer
|
The player requested. |
Source code in notty/src/visual/game.py
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 | |
set_position(x, y)
Set the position of the visual element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
int
|
X coordinate. |
required |
y
|
int
|
Y coordinate. |
required |
Source code in notty/src/visual/base.py
60 61 62 63 64 65 66 67 68 | |
setup()
Set up the game by shuffling deck and dealing initial cards.
Source code in notty/src/visual/game.py
109 110 111 112 | |
number_selector
Number selector dialog for choosing how many cards to draw.
NumberButton
Bases: SelectableButton[int]
Represents a clickable number button.
Source code in notty/src/visual/number_selector.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
__init__(x, y, width, height, number, *, enabled=True)
Initialize a number button.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
int
|
X coordinate of the button. |
required |
y
|
int
|
Y coordinate of the button. |
required |
width
|
int
|
Width of the button. |
required |
height
|
int
|
Height of the button. |
required |
number
|
int
|
The number this button represents. |
required |
enabled
|
bool
|
Whether the button is enabled (clickable). |
True
|
Source code in notty/src/visual/number_selector.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | |
draw(screen)
Draw the button.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
screen
|
Surface
|
The pygame display surface. |
required |
Source code in notty/src/visual/number_selector.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
is_clicked(mouse_x, mouse_y)
Check if the button was clicked.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mouse_x
|
int
|
Mouse x coordinate. |
required |
mouse_y
|
int
|
Mouse y coordinate. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the button was clicked and is enabled. |
Source code in notty/src/visual/base_selector.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
toggle_selection(current_selected_count, max_selections)
Toggle the selection state of this button.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current_selected_count
|
int
|
Number of currently selected items. |
required |
max_selections
|
int
|
Maximum number of selections allowed. |
required |
Source code in notty/src/visual/base_selector.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
update_hover(mouse_x, mouse_y)
Update hover state based on mouse position.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mouse_x
|
int
|
Mouse x coordinate. |
required |
mouse_y
|
int
|
Mouse y coordinate. |
required |
Source code in notty/src/visual/base_selector.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
NumberSelector
Bases: BaseSelector[int]
Dialog for selecting a number (1, 2, or 3).
Source code in notty/src/visual/number_selector.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
__init__(screen, max_number=3)
Initialize the number selector.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
screen
|
Surface
|
The pygame display surface. |
required |
max_number
|
int
|
Maximum number that can be selected (1-3). |
3
|
Source code in notty/src/visual/number_selector.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
_draw()
Draw the selector dialog.
Source code in notty/src/visual/base_selector.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | |
_get_button_dimensions()
Get button dimensions (width, height, spacing).
Returns:
| Type | Description |
|---|---|
tuple[int, int, int]
|
Tuple of (button_width, button_height, button_spacing). |
Source code in notty/src/visual/number_selector.py
96 97 98 99 100 101 102 103 104 105 | |
_get_dialog_dimensions()
Get dialog dimensions.
Returns:
| Type | Description |
|---|---|
tuple[int, int]
|
Tuple of (dialog_width, dialog_height). |
Source code in notty/src/visual/number_selector.py
107 108 109 110 111 112 113 114 115 | |
_get_selected_items()
Get the list of currently selected items.
Returns:
| Type | Description |
|---|---|
list[T]
|
List of selected items. |
Source code in notty/src/visual/base_selector.py
160 161 162 163 164 165 166 | |
_is_valid_selection()
Check if the current selection is valid.
Returns:
| Type | Description |
|---|---|
bool
|
True if the selection is valid. |
Source code in notty/src/visual/base_selector.py
168 169 170 171 172 173 174 175 176 177 178 179 | |
_setup_buttons()
Set up the number buttons.
Source code in notty/src/visual/number_selector.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
show()
Show the selector and wait for user input.
Returns:
| Type | Description |
|---|---|
list[T] | T | None
|
The selected item(s). Returns single item if max_selections=1, list otherwise. |
list[T] | T | None
|
Returns None if no selection was made. |
Source code in notty/src/visual/base_selector.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | |
player
visual player.
VisualHand
Bases: Visual
Represents a player's hand of cards.
Manages the collection of cards and enforces the 20-card limit.
Source code in notty/src/visual/player.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
__init__(player)
Initialize an empty hand.
Source code in notty/src/visual/player.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
add_card(card, *, draw_discard_draw=False)
Add a card to the hand.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
card
|
VisualCard
|
The card to add. |
required |
draw_discard_draw
|
bool
|
True if this is a draw and discard action. This is needed because in the draw and discard action, the player can draw even if hand is full. |
False
|
Returns:
| Type | Description |
|---|---|
bool
|
True if the card was added, False if hand is full. |
Source code in notty/src/visual/player.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
add_cards(cards)
Add multiple cards to the hand.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cards
|
list[VisualCard]
|
List of cards to add. |
required |
Returns:
| Type | Description |
|---|---|
dict[VisualCard, bool]
|
A dictionary mapping each card to a boolean indicating whether it was added. |
Source code in notty/src/visual/player.py
92 93 94 95 96 97 98 99 100 101 102 103 104 | |
draw()
Draw the hand.
Source code in notty/src/visual/player.py
51 52 53 54 55 | |
get_center()
Get the center of the visual element.
Source code in notty/src/visual/base.py
44 45 46 | |
get_png_name()
Get the png for the visual element.
Source code in notty/src/visual/player.py
57 58 59 | |
get_png_path()
Get the png for the visual element.
Source code in notty/src/visual/base.py
93 94 95 | |
get_png_pkg()
Get the png for the visual element.
Source code in notty/src/visual/player.py
61 62 63 | |
hand_is_full()
Check if the hand is full.
Returns:
| Type | Description |
|---|---|
bool
|
True if hand has reached the maximum number of cards. |
Source code in notty/src/visual/player.py
65 66 67 68 69 70 71 | |
is_empty()
Check if the hand is empty.
Returns:
| Type | Description |
|---|---|
bool
|
True if hand has no cards. |
Source code in notty/src/visual/player.py
146 147 148 149 150 151 152 | |
move(x, y)
Move the visual element.
Animates the movement in a straight line to that given location.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
int
|
X coordinate. |
required |
y
|
int
|
Y coordinate. |
required |
Source code in notty/src/visual/base.py
48 49 50 51 52 53 54 55 56 57 58 | |
order_cards()
Order the cards in the hand.
Source code in notty/src/visual/player.py
122 123 124 125 126 127 128 129 130 | |
remove_card(card)
Remove a specific card from the hand.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
card
|
VisualCard
|
The card to remove. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the card was removed, False if card not in hand. |
Source code in notty/src/visual/player.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
remove_cards(cards)
Remove multiple cards from the hand.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cards
|
list[VisualCard]
|
List of cards to remove. |
required |
Returns:
| Type | Description |
|---|---|
dict[VisualCard, bool]
|
A dictionary mapping each card to a boolean showing whether it was removed. |
Source code in notty/src/visual/player.py
132 133 134 135 136 137 138 139 140 141 142 143 144 | |
set_position(x, y)
Set the position of the visual element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
int
|
X coordinate. |
required |
y
|
int
|
Y coordinate. |
required |
Source code in notty/src/visual/base.py
60 61 62 63 64 65 66 67 68 | |
shuffle()
Shuffle the cards in the hand.
Source code in notty/src/visual/player.py
162 163 164 | |
size()
Get the number of cards in the hand.
Returns:
| Type | Description |
|---|---|
int
|
Number of cards in hand. |
Source code in notty/src/visual/player.py
154 155 156 157 158 159 160 | |
VisualPlayer
Bases: Visual
Visual player.
Source code in notty/src/visual/player.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | |
__init__(name, *, is_human=False, screen)
Initialize a visual player.
Source code in notty/src/visual/player.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 | |
draw()
Draw the player.
Source code in notty/src/visual/player.py
190 191 192 193 | |
get_all_player_names()
classmethod
Get all player names.
Source code in notty/src/visual/player.py
221 222 223 224 225 226 227 228 229 230 231 | |
get_center()
Get the center of the visual element.
Source code in notty/src/visual/base.py
44 45 46 | |
get_coordinates()
Get the coordinates for the player.
Source code in notty/src/visual/player.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |
get_png_name()
Get the png for the visual element.
Source code in notty/src/visual/player.py
195 196 197 | |
get_png_path()
Get the png for the visual element.
Source code in notty/src/visual/base.py
93 94 95 | |
get_png_pkg()
Get the png for the visual element.
Source code in notty/src/visual/player.py
199 200 201 | |
move(x, y)
Move the visual element.
Animates the movement in a straight line to that given location.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
int
|
X coordinate. |
required |
y
|
int
|
Y coordinate. |
required |
Source code in notty/src/visual/base.py
48 49 50 51 52 53 54 55 56 57 58 | |
set_position(x, y)
Set the position of the visual element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
int
|
X coordinate. |
required |
y
|
int
|
Y coordinate. |
required |
Source code in notty/src/visual/base.py
60 61 62 63 64 65 66 67 68 | |
player_name_selector
Player name selector for initial player selection.
PlayerNameButton
Bases: SelectableButton[str]
Represents a clickable player name button with image.
Source code in notty/src/visual/player_name_selector.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
__init__(x, y, width, height, player_name, player_image, *, enabled=True, selectable=False)
Initialize a player name button.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
int
|
X coordinate of the button. |
required |
y
|
int
|
Y coordinate of the button. |
required |
width
|
int
|
Width of the button. |
required |
height
|
int
|
Height of the button. |
required |
player_name
|
str
|
The name of the player. |
required |
player_image
|
Surface
|
The image of the player. |
required |
enabled
|
bool
|
Whether the button is enabled. |
True
|
selectable
|
bool
|
Whether the button can be selected/deselected. |
False
|
Source code in notty/src/visual/player_name_selector.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
draw(screen)
Draw the button.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
screen
|
Surface
|
The pygame display surface. |
required |
Source code in notty/src/visual/player_name_selector.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
is_clicked(mouse_x, mouse_y)
Check if the button was clicked.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mouse_x
|
int
|
Mouse x coordinate. |
required |
mouse_y
|
int
|
Mouse y coordinate. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the button was clicked and is enabled. |
Source code in notty/src/visual/base_selector.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
toggle_selection(current_selected_count, max_selections)
Toggle the selection state of this button.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current_selected_count
|
int
|
Number of currently selected items. |
required |
max_selections
|
int
|
Maximum number of selections allowed. |
required |
Source code in notty/src/visual/base_selector.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
update_hover(mouse_x, mouse_y)
Update hover state based on mouse position.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mouse_x
|
int
|
Mouse x coordinate. |
required |
mouse_y
|
int
|
Mouse y coordinate. |
required |
Source code in notty/src/visual/base_selector.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
PlayerNameSelector
Bases: BaseSelector[str]
Dialog for selecting player name(s) at game start.
Source code in notty/src/visual/player_name_selector.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | |
__init__(screen, available_names, title, *, max_selections=1, min_selections=1)
Initialize the player name selector.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
screen
|
Surface
|
The pygame display surface. |
required |
available_names
|
list[str]
|
List of available player names. |
required |
title
|
str
|
Title to display. |
required |
max_selections
|
int
|
Maximum number of selections allowed. |
1
|
min_selections
|
int
|
Minimum number of selections required. |
1
|
Source code in notty/src/visual/player_name_selector.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
_draw()
Draw the player name selector.
Source code in notty/src/visual/player_name_selector.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | |
_get_button_dimensions()
Get button dimensions (width, height, spacing).
Returns:
| Type | Description |
|---|---|
tuple[int, int, int]
|
Tuple of (button_width, button_height, button_spacing). |
Source code in notty/src/visual/player_name_selector.py
135 136 137 138 139 140 141 142 143 | |
_get_dialog_dimensions()
Get dialog dimensions.
Returns:
| Type | Description |
|---|---|
tuple[int, int]
|
Tuple of (dialog_width, dialog_height). |
Source code in notty/src/visual/player_name_selector.py
145 146 147 148 149 150 151 152 | |
_get_selected_items()
Get the list of currently selected items.
Returns:
| Type | Description |
|---|---|
list[T]
|
List of selected items. |
Source code in notty/src/visual/base_selector.py
160 161 162 163 164 165 166 | |
_is_valid_selection()
Check if the current selection is valid.
Returns:
| Type | Description |
|---|---|
bool
|
True if the selection is valid. |
Source code in notty/src/visual/base_selector.py
168 169 170 171 172 173 174 175 176 177 178 179 | |
_setup_buttons()
Set up the player name buttons.
Source code in notty/src/visual/player_name_selector.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |
show()
Show the player name selector and wait for user input.
Returns:
| Type | Description |
|---|---|
str | list[str]
|
Selected player name (single) or list of names (multiple). |
Source code in notty/src/visual/player_name_selector.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | |
player_selector
Player selector dialog for choosing which player to steal from.
PlayerButton
Bases: SelectableButton['VisualPlayer']
Represents a clickable player button.
Source code in notty/src/visual/player_selector.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
__init__(x, y, width, height, player, player_image)
Initialize a player button.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
int
|
X coordinate of the button. |
required |
y
|
int
|
Y coordinate of the button. |
required |
width
|
int
|
Width of the button. |
required |
height
|
int
|
Height of the button. |
required |
player
|
VisualPlayer
|
The player this button represents. |
required |
player_image
|
Surface
|
The image of the player. |
required |
Source code in notty/src/visual/player_selector.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
draw(screen)
Draw the button.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
screen
|
Surface
|
The pygame display surface. |
required |
Source code in notty/src/visual/player_selector.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
is_clicked(mouse_x, mouse_y)
Check if the button was clicked.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mouse_x
|
int
|
Mouse x coordinate. |
required |
mouse_y
|
int
|
Mouse y coordinate. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the button was clicked and is enabled. |
Source code in notty/src/visual/base_selector.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
toggle_selection(current_selected_count, max_selections)
Toggle the selection state of this button.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current_selected_count
|
int
|
Number of currently selected items. |
required |
max_selections
|
int
|
Maximum number of selections allowed. |
required |
Source code in notty/src/visual/base_selector.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
update_hover(mouse_x, mouse_y)
Update hover state based on mouse position.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mouse_x
|
int
|
Mouse x coordinate. |
required |
mouse_y
|
int
|
Mouse y coordinate. |
required |
Source code in notty/src/visual/base_selector.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
PlayerSelector
Bases: BaseSelector['VisualPlayer']
Dialog for selecting a player to steal from.
Source code in notty/src/visual/player_selector.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
__init__(screen, available_players)
Initialize the player selector.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
screen
|
Surface
|
The pygame display surface. |
required |
available_players
|
list[VisualPlayer]
|
List of players that can be selected. |
required |
Source code in notty/src/visual/player_selector.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
_draw()
Draw the selector dialog.
Source code in notty/src/visual/base_selector.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | |
_get_button_dimensions()
Get button dimensions (width, height, spacing).
Returns:
| Type | Description |
|---|---|
tuple[int, int, int]
|
Tuple of (button_width, button_height, button_spacing). |
Source code in notty/src/visual/player_selector.py
106 107 108 109 110 111 112 113 114 | |
_get_dialog_dimensions()
Get dialog dimensions.
Returns:
| Type | Description |
|---|---|
tuple[int, int]
|
Tuple of (dialog_width, dialog_height). |
Source code in notty/src/visual/player_selector.py
116 117 118 119 120 121 122 123 124 | |
_get_selected_items()
Get the list of currently selected items.
Returns:
| Type | Description |
|---|---|
list[T]
|
List of selected items. |
Source code in notty/src/visual/base_selector.py
160 161 162 163 164 165 166 | |
_is_valid_selection()
Check if the current selection is valid.
Returns:
| Type | Description |
|---|---|
bool
|
True if the selection is valid. |
Source code in notty/src/visual/base_selector.py
168 169 170 171 172 173 174 175 176 177 178 179 | |
_setup_buttons()
Set up the player buttons.
Source code in notty/src/visual/player_selector.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
show()
Show the selector and wait for user input.
Returns:
| Type | Description |
|---|---|
list[T] | T | None
|
The selected item(s). Returns single item if max_selections=1, list otherwise. |
list[T] | T | None
|
Returns None if no selection was made. |
Source code in notty/src/visual/base_selector.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | |
winner_display
Winner display dialog for showing the game winner.
WinnerDisplay
Dialog for displaying the winner of the game.
Source code in notty/src/visual/winner_display.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | |
__init__(screen, winner)
Initialize the winner display.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
screen
|
Surface
|
The pygame display surface. |
required |
winner
|
VisualPlayer
|
The winning player object. |
required |
Source code in notty/src/visual/winner_display.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
_draw()
Draw the winner display dialog.
Source code in notty/src/visual/winner_display.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 | |
_draw_button(rect, text, *, hovered, normal_color, hover_color)
Draw a button with hover effect.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rect
|
Rect
|
The button rectangle. |
required |
text
|
str
|
The button text. |
required |
hovered
|
bool
|
Whether the button is hovered. |
required |
normal_color
|
tuple[int, int, int]
|
The normal button color. |
required |
hover_color
|
tuple[int, int, int]
|
The hover button color. |
required |
Source code in notty/src/visual/winner_display.py
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | |
show()
Show the winner display and wait for user to click a button.
This displays a congratulations message and waits for the user to click either "Start New Game" or "Quit".
Returns:
| Type | Description |
|---|---|
str
|
"new_game" if user clicked Start New Game, "quit" if user clicked Quit. |
Source code in notty/src/visual/winner_display.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |