multiplayer 2.4.0__tar.gz → 3.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {multiplayer-2.4.0 → multiplayer-3.0.1}/PKG-INFO +65 -7
- {multiplayer-2.4.0 → multiplayer-3.0.1}/README.md +64 -5
- {multiplayer-2.4.0 → multiplayer-3.0.1}/pyproject.toml +2 -3
- {multiplayer-2.4.0 → multiplayer-3.0.1}/pyproject.toml.orig +2 -3
- {multiplayer-2.4.0 → multiplayer-3.0.1}/src/multiplayer/__init__.py +13 -2
- {multiplayer-2.4.0 → multiplayer-3.0.1}/src/multiplayer/client.py +594 -32
- multiplayer-3.0.1/src/multiplayer/exceptions.py +191 -0
- multiplayer-3.0.1/src/multiplayer/game.py +3052 -0
- {multiplayer-2.4.0 → multiplayer-3.0.1}/src/multiplayer/save.py +202 -22
- {multiplayer-2.4.0 → multiplayer-3.0.1}/src/multiplayer/server.py +1258 -121
- multiplayer-2.4.0/src/multiplayer/exceptions.py +0 -83
- multiplayer-2.4.0/src/multiplayer/game.py +0 -615
- {multiplayer-2.4.0 → multiplayer-3.0.1}/src/multiplayer/data/cities.csv +0 -0
- {multiplayer-2.4.0 → multiplayer-3.0.1}/src/multiplayer/data/countries.csv +0 -0
- {multiplayer-2.4.0 → multiplayer-3.0.1}/src/multiplayer/data/egyptian_gods.csv +0 -0
- {multiplayer-2.4.0 → multiplayer-3.0.1}/src/multiplayer/data/european_kings.csv +0 -0
- {multiplayer-2.4.0 → multiplayer-3.0.1}/src/multiplayer/data/european_queens.csv +0 -0
- {multiplayer-2.4.0 → multiplayer-3.0.1}/src/multiplayer/data/greek_gods.csv +0 -0
- {multiplayer-2.4.0 → multiplayer-3.0.1}/src/multiplayer/data/planets_moons.csv +0 -0
- {multiplayer-2.4.0 → multiplayer-3.0.1}/src/multiplayer/data/rivers.csv +0 -0
- {multiplayer-2.4.0 → multiplayer-3.0.1}/src/multiplayer/data/roman_gods.csv +0 -0
- {multiplayer-2.4.0 → multiplayer-3.0.1}/src/multiplayer/data/seas_oceans.csv +0 -0
- {multiplayer-2.4.0 → multiplayer-3.0.1}/src/multiplayer/py.typed +0 -0
- {multiplayer-2.4.0 → multiplayer-3.0.1}/src/multiplayer/utils.py +0 -0
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: multiplayer
|
|
3
|
-
Version:
|
|
3
|
+
Version: 3.0.1
|
|
4
4
|
Summary: Library that allows you to manage multiple players, locally, on a network, or on the Internet.
|
|
5
5
|
Author: devfred78
|
|
6
6
|
Author-email: devfred78 <devfred78@gmail.com>
|
|
7
7
|
License-Expression: MIT
|
|
8
8
|
Classifier: Development Status :: 5 - Production/Stable
|
|
9
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
10
9
|
Classifier: Operating System :: OS Independent
|
|
11
10
|
Classifier: Programming Language :: Python :: 3
|
|
12
11
|
Classifier: Programming Language :: Python :: 3.10
|
|
@@ -21,7 +20,7 @@ Requires-Dist: msgpack>=1.2.1
|
|
|
21
20
|
Requires-Python: >=3.10
|
|
22
21
|
Description-Content-Type: text/markdown
|
|
23
22
|
|
|
24
|
-
# Multiplayer Library
|
|
23
|
+
# Multiplayer Library
|
|
25
24
|
|
|
26
25
|
A Python library for managing multiplayer game sessions, users, and groups.
|
|
27
26
|
|
|
@@ -30,7 +29,8 @@ A Python library for managing multiplayer game sessions, users, and groups.
|
|
|
30
29
|
- **Player Management**: Create players with static and dynamic attributes.
|
|
31
30
|
- **User Accounts**: Authentication and role-based permissions (Player, Group Admin, Server Admin).
|
|
32
31
|
- **Game Sessions**: Support for turn-based and simultaneous games, private games with passwords, and observers.
|
|
33
|
-
- **Game Groups**: Organize multiple games into manageable groups.
|
|
32
|
+
- **Game Groups**: Organize multiple games into manageable groups, optionally with a game factory that creates games and enforces unique option values.
|
|
33
|
+
- **Factories**: Define reusable player and game factory templates, with options, exclusions and proposed values exposed to clients.
|
|
34
34
|
- **Persistence**: Save and restore your game state using JSON or SQLite formats.
|
|
35
35
|
- **Networking**: Client-Server architecture using TCP with optional TLS 1.3 encryption, automatic server discovery, and real-time notifications.
|
|
36
36
|
- **Name Suggestions**: Built-in utility to suggest random names for players and games from various categories.
|
|
@@ -46,7 +46,7 @@ pip install multiplayer
|
|
|
46
46
|
Alternatively, you can install it by downloading the `.whl` file from the [Releases](https://github.com/devfred78/multiplayer/releases) section of the GitHub repository:
|
|
47
47
|
|
|
48
48
|
```bash
|
|
49
|
-
pip install multiplayer-
|
|
49
|
+
pip install multiplayer-3.0.0-py3-none-any.whl
|
|
50
50
|
```
|
|
51
51
|
|
|
52
52
|
## Quick Start
|
|
@@ -60,7 +60,7 @@ from multiplayer import ParameterFamily
|
|
|
60
60
|
# Create a player with attributes
|
|
61
61
|
player = Player("Alice", score=(ParameterFamily.DYNAMIC, 0), team=(ParameterFamily.STATIC, "Red"))
|
|
62
62
|
|
|
63
|
-
# Create a user account
|
|
63
|
+
# Create a user account (credentials and permissions, distinct from players)
|
|
64
64
|
user = User(username="alice_92", password="secret_password", email="alice@example.com")
|
|
65
65
|
```
|
|
66
66
|
|
|
@@ -86,7 +86,63 @@ from multiplayer.game import GameGroup
|
|
|
86
86
|
|
|
87
87
|
# Organize multiple games
|
|
88
88
|
group = GameGroup(name="Summer Tournament")
|
|
89
|
-
group.add_game(game)
|
|
89
|
+
group.add_game(game) # or group.add_game(game.ID)
|
|
90
|
+
print(group.games) # tuple of game IDs
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Using Game Factories
|
|
94
|
+
|
|
95
|
+
A `GameFactoryTemplate` defines how the games of a group are created. The group factory copies its options and computes the values already taken by the games of the group.
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
from multiplayer import OptionType
|
|
99
|
+
from multiplayer.game import GameFactoryTemplate, GameGroup, Option
|
|
100
|
+
|
|
101
|
+
template = GameFactoryTemplate("Tournament")
|
|
102
|
+
template.add_option(
|
|
103
|
+
Option("Game name", OptionType.TEXT, default="Game_%%RANDOM_NUMBER%%"),
|
|
104
|
+
"name",
|
|
105
|
+
unicity=True,
|
|
106
|
+
)
|
|
107
|
+
template.add_option(
|
|
108
|
+
Option("Max players", OptionType.RANGE, min_value=2, max_value=4, default=4),
|
|
109
|
+
"max_players",
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
group = GameGroup("Summer Tournament", password="secret")
|
|
113
|
+
group.create_game_factory(template)
|
|
114
|
+
|
|
115
|
+
factory = group.game_factory
|
|
116
|
+
name_option_id = factory.options[0][0]
|
|
117
|
+
info = factory.get_option(name_option_id) # entry, exclusions, proposed_value
|
|
118
|
+
print(info["exclusions"], info["proposed_value"])
|
|
119
|
+
|
|
120
|
+
game = group.create_and_add_game({name_option_id: "Final_1"}, password="secret")
|
|
121
|
+
print(game.name, group.games) # unique names are enforced when games join the group
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Over a network, the server can announce the `game_factory` feature. An administrator creates a game factory template, applies it to a group (`GROUP_FACTORY_SET` is also available), then clients build their creation form from `get_group_game_factory` and call `create_game(..., game_factory_values=...)`. They can subscribe to `GAME_CREATION_FACTORY_UPDATED` to refresh their form when other games take a value.
|
|
125
|
+
|
|
126
|
+
```python
|
|
127
|
+
# Administrator (client is a connected GameClient logged in as admin)
|
|
128
|
+
options = [
|
|
129
|
+
{"type": "TEXT", "name": "Game name", "default": "Game_%%RANDOM_NUMBER%%",
|
|
130
|
+
"unicity": True, "target": "ATTRIBUTE", "attribute": "name"},
|
|
131
|
+
{"type": "RANGE", "name": "Max players", "min": 2, "max": 4, "default": 4,
|
|
132
|
+
"target": "ATTRIBUTE", "attribute": "max_players"},
|
|
133
|
+
]
|
|
134
|
+
template_id = client.create_game_factory_template("Tournament", options)["template_id"]
|
|
135
|
+
group_id = client.send_request(
|
|
136
|
+
"GROUP_CREATE", name="Summer Tournament", game_factory_template_id=template_id
|
|
137
|
+
)["group_id"]
|
|
138
|
+
|
|
139
|
+
# Player preparing a game
|
|
140
|
+
client.on_notification("GAME_CREATION_FACTORY_UPDATED", lambda n: print(n["payload"]))
|
|
141
|
+
form = client.get_group_game_factory(group_id)
|
|
142
|
+
option_id = form["options"][0]["option_id"]
|
|
143
|
+
game_id = client.create_game(
|
|
144
|
+
"Tournament", group_id=group_id, game_factory_values={option_id: "Final_1"}
|
|
145
|
+
)
|
|
90
146
|
```
|
|
91
147
|
|
|
92
148
|
### Persistence
|
|
@@ -158,6 +214,8 @@ Press `CTRL+C` to stop it cleanly.
|
|
|
158
214
|
|
|
159
215
|
For more detailed information, please refer to:
|
|
160
216
|
- [REFERENCE.md](REFERENCE.md): Full API reference.
|
|
217
|
+
- [SPECIFICATIONS.md](SPECIFICATIONS.md): Detailed design of the library classes.
|
|
218
|
+
- [PROTOCOLE.md](PROTOCOLE.md): Client-server protocol, including the `game_factory` feature.
|
|
161
219
|
- [INSTALL_DOCKER_CONTAINER_SYNOLOGY_DSM71.md](INSTALL_DOCKER_CONTAINER_SYNOLOGY_DSM71.md): Install the Docker image on Synology DSM 7.1, including data and TLS certificate volume mappings.
|
|
162
220
|
|
|
163
221
|
## Development
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Multiplayer Library
|
|
1
|
+
# Multiplayer Library
|
|
2
2
|
|
|
3
3
|
A Python library for managing multiplayer game sessions, users, and groups.
|
|
4
4
|
|
|
@@ -7,7 +7,8 @@ A Python library for managing multiplayer game sessions, users, and groups.
|
|
|
7
7
|
- **Player Management**: Create players with static and dynamic attributes.
|
|
8
8
|
- **User Accounts**: Authentication and role-based permissions (Player, Group Admin, Server Admin).
|
|
9
9
|
- **Game Sessions**: Support for turn-based and simultaneous games, private games with passwords, and observers.
|
|
10
|
-
- **Game Groups**: Organize multiple games into manageable groups.
|
|
10
|
+
- **Game Groups**: Organize multiple games into manageable groups, optionally with a game factory that creates games and enforces unique option values.
|
|
11
|
+
- **Factories**: Define reusable player and game factory templates, with options, exclusions and proposed values exposed to clients.
|
|
11
12
|
- **Persistence**: Save and restore your game state using JSON or SQLite formats.
|
|
12
13
|
- **Networking**: Client-Server architecture using TCP with optional TLS 1.3 encryption, automatic server discovery, and real-time notifications.
|
|
13
14
|
- **Name Suggestions**: Built-in utility to suggest random names for players and games from various categories.
|
|
@@ -23,7 +24,7 @@ pip install multiplayer
|
|
|
23
24
|
Alternatively, you can install it by downloading the `.whl` file from the [Releases](https://github.com/devfred78/multiplayer/releases) section of the GitHub repository:
|
|
24
25
|
|
|
25
26
|
```bash
|
|
26
|
-
pip install multiplayer-
|
|
27
|
+
pip install multiplayer-3.0.0-py3-none-any.whl
|
|
27
28
|
```
|
|
28
29
|
|
|
29
30
|
## Quick Start
|
|
@@ -37,7 +38,7 @@ from multiplayer import ParameterFamily
|
|
|
37
38
|
# Create a player with attributes
|
|
38
39
|
player = Player("Alice", score=(ParameterFamily.DYNAMIC, 0), team=(ParameterFamily.STATIC, "Red"))
|
|
39
40
|
|
|
40
|
-
# Create a user account
|
|
41
|
+
# Create a user account (credentials and permissions, distinct from players)
|
|
41
42
|
user = User(username="alice_92", password="secret_password", email="alice@example.com")
|
|
42
43
|
```
|
|
43
44
|
|
|
@@ -63,7 +64,63 @@ from multiplayer.game import GameGroup
|
|
|
63
64
|
|
|
64
65
|
# Organize multiple games
|
|
65
66
|
group = GameGroup(name="Summer Tournament")
|
|
66
|
-
group.add_game(game)
|
|
67
|
+
group.add_game(game) # or group.add_game(game.ID)
|
|
68
|
+
print(group.games) # tuple of game IDs
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Using Game Factories
|
|
72
|
+
|
|
73
|
+
A `GameFactoryTemplate` defines how the games of a group are created. The group factory copies its options and computes the values already taken by the games of the group.
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
from multiplayer import OptionType
|
|
77
|
+
from multiplayer.game import GameFactoryTemplate, GameGroup, Option
|
|
78
|
+
|
|
79
|
+
template = GameFactoryTemplate("Tournament")
|
|
80
|
+
template.add_option(
|
|
81
|
+
Option("Game name", OptionType.TEXT, default="Game_%%RANDOM_NUMBER%%"),
|
|
82
|
+
"name",
|
|
83
|
+
unicity=True,
|
|
84
|
+
)
|
|
85
|
+
template.add_option(
|
|
86
|
+
Option("Max players", OptionType.RANGE, min_value=2, max_value=4, default=4),
|
|
87
|
+
"max_players",
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
group = GameGroup("Summer Tournament", password="secret")
|
|
91
|
+
group.create_game_factory(template)
|
|
92
|
+
|
|
93
|
+
factory = group.game_factory
|
|
94
|
+
name_option_id = factory.options[0][0]
|
|
95
|
+
info = factory.get_option(name_option_id) # entry, exclusions, proposed_value
|
|
96
|
+
print(info["exclusions"], info["proposed_value"])
|
|
97
|
+
|
|
98
|
+
game = group.create_and_add_game({name_option_id: "Final_1"}, password="secret")
|
|
99
|
+
print(game.name, group.games) # unique names are enforced when games join the group
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Over a network, the server can announce the `game_factory` feature. An administrator creates a game factory template, applies it to a group (`GROUP_FACTORY_SET` is also available), then clients build their creation form from `get_group_game_factory` and call `create_game(..., game_factory_values=...)`. They can subscribe to `GAME_CREATION_FACTORY_UPDATED` to refresh their form when other games take a value.
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
# Administrator (client is a connected GameClient logged in as admin)
|
|
106
|
+
options = [
|
|
107
|
+
{"type": "TEXT", "name": "Game name", "default": "Game_%%RANDOM_NUMBER%%",
|
|
108
|
+
"unicity": True, "target": "ATTRIBUTE", "attribute": "name"},
|
|
109
|
+
{"type": "RANGE", "name": "Max players", "min": 2, "max": 4, "default": 4,
|
|
110
|
+
"target": "ATTRIBUTE", "attribute": "max_players"},
|
|
111
|
+
]
|
|
112
|
+
template_id = client.create_game_factory_template("Tournament", options)["template_id"]
|
|
113
|
+
group_id = client.send_request(
|
|
114
|
+
"GROUP_CREATE", name="Summer Tournament", game_factory_template_id=template_id
|
|
115
|
+
)["group_id"]
|
|
116
|
+
|
|
117
|
+
# Player preparing a game
|
|
118
|
+
client.on_notification("GAME_CREATION_FACTORY_UPDATED", lambda n: print(n["payload"]))
|
|
119
|
+
form = client.get_group_game_factory(group_id)
|
|
120
|
+
option_id = form["options"][0]["option_id"]
|
|
121
|
+
game_id = client.create_game(
|
|
122
|
+
"Tournament", group_id=group_id, game_factory_values={option_id: "Final_1"}
|
|
123
|
+
)
|
|
67
124
|
```
|
|
68
125
|
|
|
69
126
|
### Persistence
|
|
@@ -135,6 +192,8 @@ Press `CTRL+C` to stop it cleanly.
|
|
|
135
192
|
|
|
136
193
|
For more detailed information, please refer to:
|
|
137
194
|
- [REFERENCE.md](REFERENCE.md): Full API reference.
|
|
195
|
+
- [SPECIFICATIONS.md](SPECIFICATIONS.md): Detailed design of the library classes.
|
|
196
|
+
- [PROTOCOLE.md](PROTOCOLE.md): Client-server protocol, including the `game_factory` feature.
|
|
138
197
|
- [INSTALL_DOCKER_CONTAINER_SYNOLOGY_DSM71.md](INSTALL_DOCKER_CONTAINER_SYNOLOGY_DSM71.md): Install the Docker image on Synology DSM 7.1, including data and TLS certificate volume mappings.
|
|
139
198
|
|
|
140
199
|
## Development
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "multiplayer"
|
|
3
|
-
version = "
|
|
3
|
+
version = "3.0.1"
|
|
4
4
|
description = "Library that allows you to manage multiple players, locally, on a network, or on the Internet."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "MIT"
|
|
7
7
|
requires-python = ">=3.10"
|
|
8
8
|
classifiers = [
|
|
9
9
|
"Development Status :: 5 - Production/Stable",
|
|
10
|
-
"License :: OSI Approved :: MIT License",
|
|
11
10
|
"Operating System :: OS Independent",
|
|
12
11
|
"Programming Language :: Python :: 3",
|
|
13
12
|
"Programming Language :: Python :: 3.10",
|
|
@@ -28,7 +27,7 @@ name = "devfred78"
|
|
|
28
27
|
email = "devfred78@gmail.com"
|
|
29
28
|
|
|
30
29
|
[build-system]
|
|
31
|
-
requires = ["uv_build>=0.11.7,<0.
|
|
30
|
+
requires = ["uv_build>=0.11.7,<0.14"]
|
|
32
31
|
build-backend = "uv_build"
|
|
33
32
|
|
|
34
33
|
[dependency-groups]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "multiplayer"
|
|
3
|
-
version = "
|
|
3
|
+
version = "3.0.1"
|
|
4
4
|
description = "Library that allows you to manage multiple players, locally, on a network, or on the Internet."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "MIT"
|
|
@@ -10,7 +10,6 @@ authors = [
|
|
|
10
10
|
requires-python = ">=3.10"
|
|
11
11
|
classifiers = [
|
|
12
12
|
"Development Status :: 5 - Production/Stable",
|
|
13
|
-
"License :: OSI Approved :: MIT License",
|
|
14
13
|
"Operating System :: OS Independent",
|
|
15
14
|
"Programming Language :: Python :: 3",
|
|
16
15
|
"Programming Language :: Python :: 3.10",
|
|
@@ -27,7 +26,7 @@ dependencies = [
|
|
|
27
26
|
]
|
|
28
27
|
|
|
29
28
|
[build-system]
|
|
30
|
-
requires = ["uv_build>=0.11.7,<0.
|
|
29
|
+
requires = ["uv_build>=0.11.7,<0.14"]
|
|
31
30
|
build-backend = "uv_build"
|
|
32
31
|
|
|
33
32
|
[dependency-groups]
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"""Multiplayer package initialization."""
|
|
2
2
|
from enum import Enum
|
|
3
3
|
|
|
4
|
-
class
|
|
5
|
-
"""Enumeration for
|
|
4
|
+
class UserRole(Enum):
|
|
5
|
+
"""Enumeration for user account roles."""
|
|
6
6
|
PLAYER = "player"
|
|
7
7
|
GROUP_ADMIN = "group_admin"
|
|
8
8
|
SERVER_ADMIN = "server_admin"
|
|
@@ -23,3 +23,14 @@ class SaveFormat(Enum):
|
|
|
23
23
|
"""Enumeration for the supported persistence formats of a save file."""
|
|
24
24
|
JSON = "json"
|
|
25
25
|
SQLITE = "sqlite"
|
|
26
|
+
|
|
27
|
+
class OptionType(Enum):
|
|
28
|
+
"""Enumeration for the types of the player customization options.
|
|
29
|
+
|
|
30
|
+
These types are typically used by a client process to build the widgets
|
|
31
|
+
of a player customization form.
|
|
32
|
+
"""
|
|
33
|
+
CHECK = "check"
|
|
34
|
+
RANGE = "range"
|
|
35
|
+
LIST = "list"
|
|
36
|
+
TEXT = "text"
|