multiplayer 1.1.1__tar.gz → 2.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.0.1/PKG-INFO +166 -0
- multiplayer-2.0.1/README.md +155 -0
- multiplayer-2.0.1/pyproject.toml +36 -0
- multiplayer-2.0.1/pyproject.toml.orig +29 -0
- multiplayer-2.0.1/src/multiplayer/__init__.py +25 -0
- multiplayer-2.0.1/src/multiplayer/client.py +686 -0
- multiplayer-2.0.1/src/multiplayer/exceptions.py +83 -0
- multiplayer-2.0.1/src/multiplayer/game.py +585 -0
- multiplayer-2.0.1/src/multiplayer/save.py +430 -0
- multiplayer-2.0.1/src/multiplayer/server.py +2713 -0
- multiplayer-2.0.1/src/multiplayer/utils.py +101 -0
- multiplayer-1.1.1/LICENSE.md +0 -23
- multiplayer-1.1.1/PKG-INFO +0 -322
- multiplayer-1.1.1/README.md +0 -299
- multiplayer-1.1.1/pyproject.toml +0 -48
- multiplayer-1.1.1/src/multiplayer/IPClogging/__init__.py +0 -42
- multiplayer-1.1.1/src/multiplayer/IPClogging/echoing.py +0 -34
- multiplayer-1.1.1/src/multiplayer/IPClogging/server.py +0 -338
- multiplayer-1.1.1/src/multiplayer/IPClogging/test.py +0 -71
- multiplayer-1.1.1/src/multiplayer/__init__.py +0 -54
- multiplayer-1.1.1/src/multiplayer/client.py +0 -781
- multiplayer-1.1.1/src/multiplayer/data/__init__.py +0 -1
- multiplayer-1.1.1/src/multiplayer/data/persistence.py +0 -517
- multiplayer-1.1.1/src/multiplayer/exceptions.py +0 -51
- multiplayer-1.1.1/src/multiplayer/game.py +0 -404
- multiplayer-1.1.1/src/multiplayer/language/__init__.py +0 -23
- multiplayer-1.1.1/src/multiplayer/language/language.py +0 -445
- multiplayer-1.1.1/src/multiplayer/run_log_server.py +0 -33
- multiplayer-1.1.1/src/multiplayer/run_server.py +0 -123
- multiplayer-1.1.1/src/multiplayer/server.py +0 -1355
- multiplayer-1.1.1/src/multiplayer/utils.py +0 -248
- {multiplayer-1.1.1 → multiplayer-2.0.1}/src/multiplayer/data/cities.csv +0 -0
- {multiplayer-1.1.1 → multiplayer-2.0.1}/src/multiplayer/data/countries.csv +0 -0
- {multiplayer-1.1.1 → multiplayer-2.0.1}/src/multiplayer/data/egyptian_gods.csv +0 -0
- {multiplayer-1.1.1 → multiplayer-2.0.1}/src/multiplayer/data/european_kings.csv +0 -0
- {multiplayer-1.1.1 → multiplayer-2.0.1}/src/multiplayer/data/european_queens.csv +0 -0
- {multiplayer-1.1.1 → multiplayer-2.0.1}/src/multiplayer/data/greek_gods.csv +0 -0
- {multiplayer-1.1.1 → multiplayer-2.0.1}/src/multiplayer/data/planets_moons.csv +0 -0
- {multiplayer-1.1.1 → multiplayer-2.0.1}/src/multiplayer/data/rivers.csv +0 -0
- {multiplayer-1.1.1 → multiplayer-2.0.1}/src/multiplayer/data/roman_gods.csv +0 -0
- {multiplayer-1.1.1 → multiplayer-2.0.1}/src/multiplayer/data/seas_oceans.csv +0 -0
- {multiplayer-1.1.1 → multiplayer-2.0.1}/src/multiplayer/py.typed +0 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: multiplayer
|
|
3
|
+
Version: 2.0.1
|
|
4
|
+
Summary: Library that allows you to manage multiple players, locally, on a network, or on the Internet.
|
|
5
|
+
Author: devfred78
|
|
6
|
+
Author-email: devfred78 <devfred78@gmail.com>
|
|
7
|
+
Requires-Dist: bcrypt>=5.0.0
|
|
8
|
+
Requires-Dist: msgpack>=1.2.1
|
|
9
|
+
Requires-Python: >=3.14
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
|
|
12
|
+
# Multiplayer Library V2
|
|
13
|
+
|
|
14
|
+
A Python library for managing multiplayer game sessions, users, and groups.
|
|
15
|
+
|
|
16
|
+
## Features
|
|
17
|
+
|
|
18
|
+
- **Player Management**: Create players with static and dynamic attributes.
|
|
19
|
+
- **User Accounts**: Authentication and role-based permissions (Player, Group Admin, Server Admin).
|
|
20
|
+
- **Game Sessions**: Support for turn-based and simultaneous games, private games with passwords, and observers.
|
|
21
|
+
- **Game Groups**: Organize multiple games into manageable groups.
|
|
22
|
+
- **Persistence**: Save and restore your game state using JSON or SQLite formats.
|
|
23
|
+
- **Networking**: Client-Server architecture using TCP with optional TLS 1.3 encryption, automatic server discovery, and real-time notifications.
|
|
24
|
+
- **Name Suggestions**: Built-in utility to suggest random names for players and games from various categories.
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
Install the library using `pip`:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install multiplayer
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Alternatively, you can install it by downloading the `.whl` file from the [Releases](https://github.com/devfred78/multiplayer/releases) section of the GitHub repository:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pip install multiplayer-2.0.0-py3-none-any.whl
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Quick Start
|
|
41
|
+
|
|
42
|
+
### Creating a Player and User
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
from multiplayer.game import Player, User
|
|
46
|
+
from multiplayer import ParameterFamily
|
|
47
|
+
|
|
48
|
+
# Create a player with attributes
|
|
49
|
+
player = Player("Alice", score=(ParameterFamily.DYNAMIC, 0), team=(ParameterFamily.STATIC, "Red"))
|
|
50
|
+
|
|
51
|
+
# Create a user account associated with its own player profile
|
|
52
|
+
user = User(username="alice_92", password="secret_password", email="alice@example.com")
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Managing Games
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
from multiplayer.game import Game
|
|
59
|
+
from multiplayer.utils import suggest_game_name
|
|
60
|
+
|
|
61
|
+
# Create a turn-based game with a suggested name
|
|
62
|
+
game_name = suggest_game_name("cities")
|
|
63
|
+
game = Game(name=game_name, turn_based=True)
|
|
64
|
+
|
|
65
|
+
# Join and start the game
|
|
66
|
+
game.join_game_as_player(player)
|
|
67
|
+
game.start()
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Using Game Groups
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
from multiplayer.game import GameGroup
|
|
74
|
+
|
|
75
|
+
# Organize multiple games
|
|
76
|
+
group = GameGroup(name="Summer Tournament")
|
|
77
|
+
group.add_game(game)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Persistence
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
from pathlib import Path
|
|
84
|
+
from multiplayer.save import Save
|
|
85
|
+
from multiplayer import SaveFormat
|
|
86
|
+
|
|
87
|
+
# Initialize a save file (JSON or SQLite)
|
|
88
|
+
save_handler = Save(file_path=Path("savegame.json"), save_format=SaveFormat.JSON)
|
|
89
|
+
|
|
90
|
+
# Save an object
|
|
91
|
+
save_handler.save(game)
|
|
92
|
+
save_handler.flush() # Effective write to disk
|
|
93
|
+
|
|
94
|
+
# Load objects
|
|
95
|
+
loaded_games = save_handler.load("Game")
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Networking
|
|
99
|
+
|
|
100
|
+
#### Starting a Server
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
import asyncio
|
|
104
|
+
from multiplayer.server import GameServer
|
|
105
|
+
|
|
106
|
+
async def main():
|
|
107
|
+
# Create and start a discoverable server
|
|
108
|
+
server = GameServer(name="Battle Server", discoverable=True)
|
|
109
|
+
await server.start()
|
|
110
|
+
try:
|
|
111
|
+
await asyncio.Event().wait()
|
|
112
|
+
finally:
|
|
113
|
+
await server.stop()
|
|
114
|
+
|
|
115
|
+
if __name__ == "__main__":
|
|
116
|
+
try:
|
|
117
|
+
asyncio.run(main())
|
|
118
|
+
except KeyboardInterrupt:
|
|
119
|
+
pass
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
#### Connecting a Client
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
from multiplayer.client import GameClient
|
|
126
|
+
|
|
127
|
+
# Connect to a server
|
|
128
|
+
client = GameClient(host="127.0.0.1")
|
|
129
|
+
try:
|
|
130
|
+
client.connect()
|
|
131
|
+
|
|
132
|
+
# Register a notification handler
|
|
133
|
+
client.on_notification("GAME_EVENT", lambda p: print(f"Received event: {p}"))
|
|
134
|
+
|
|
135
|
+
# Create a player for this client session
|
|
136
|
+
player = client.create_player("Alice")
|
|
137
|
+
print(f"Connected as {player.name}")
|
|
138
|
+
finally:
|
|
139
|
+
client.disconnect()
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
For a command-line server, run `uv run python scripts/run_server.py --help`.
|
|
143
|
+
Press `CTRL+C` to stop it cleanly.
|
|
144
|
+
|
|
145
|
+
## Documentation
|
|
146
|
+
|
|
147
|
+
For more detailed information, please refer to:
|
|
148
|
+
- [REFERENCE.md](REFERENCE.md): Full API reference.
|
|
149
|
+
- [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.
|
|
150
|
+
|
|
151
|
+
## Development
|
|
152
|
+
|
|
153
|
+
The project uses [uv](https://github.com/astral-sh/uv) for dependency management.
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
# Install development dependencies
|
|
157
|
+
uv sync
|
|
158
|
+
|
|
159
|
+
# Run quality checks and tests
|
|
160
|
+
uv run python scripts/check_project.py
|
|
161
|
+
uv run pytest
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## License
|
|
165
|
+
|
|
166
|
+
See `LICENSE.md` for details.
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# Multiplayer Library V2
|
|
2
|
+
|
|
3
|
+
A Python library for managing multiplayer game sessions, users, and groups.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Player Management**: Create players with static and dynamic attributes.
|
|
8
|
+
- **User Accounts**: Authentication and role-based permissions (Player, Group Admin, Server Admin).
|
|
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.
|
|
11
|
+
- **Persistence**: Save and restore your game state using JSON or SQLite formats.
|
|
12
|
+
- **Networking**: Client-Server architecture using TCP with optional TLS 1.3 encryption, automatic server discovery, and real-time notifications.
|
|
13
|
+
- **Name Suggestions**: Built-in utility to suggest random names for players and games from various categories.
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
Install the library using `pip`:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install multiplayer
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
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
|
+
```bash
|
|
26
|
+
pip install multiplayer-2.0.0-py3-none-any.whl
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Quick Start
|
|
30
|
+
|
|
31
|
+
### Creating a Player and User
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
from multiplayer.game import Player, User
|
|
35
|
+
from multiplayer import ParameterFamily
|
|
36
|
+
|
|
37
|
+
# Create a player with attributes
|
|
38
|
+
player = Player("Alice", score=(ParameterFamily.DYNAMIC, 0), team=(ParameterFamily.STATIC, "Red"))
|
|
39
|
+
|
|
40
|
+
# Create a user account associated with its own player profile
|
|
41
|
+
user = User(username="alice_92", password="secret_password", email="alice@example.com")
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Managing Games
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from multiplayer.game import Game
|
|
48
|
+
from multiplayer.utils import suggest_game_name
|
|
49
|
+
|
|
50
|
+
# Create a turn-based game with a suggested name
|
|
51
|
+
game_name = suggest_game_name("cities")
|
|
52
|
+
game = Game(name=game_name, turn_based=True)
|
|
53
|
+
|
|
54
|
+
# Join and start the game
|
|
55
|
+
game.join_game_as_player(player)
|
|
56
|
+
game.start()
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Using Game Groups
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
from multiplayer.game import GameGroup
|
|
63
|
+
|
|
64
|
+
# Organize multiple games
|
|
65
|
+
group = GameGroup(name="Summer Tournament")
|
|
66
|
+
group.add_game(game)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Persistence
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
from pathlib import Path
|
|
73
|
+
from multiplayer.save import Save
|
|
74
|
+
from multiplayer import SaveFormat
|
|
75
|
+
|
|
76
|
+
# Initialize a save file (JSON or SQLite)
|
|
77
|
+
save_handler = Save(file_path=Path("savegame.json"), save_format=SaveFormat.JSON)
|
|
78
|
+
|
|
79
|
+
# Save an object
|
|
80
|
+
save_handler.save(game)
|
|
81
|
+
save_handler.flush() # Effective write to disk
|
|
82
|
+
|
|
83
|
+
# Load objects
|
|
84
|
+
loaded_games = save_handler.load("Game")
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Networking
|
|
88
|
+
|
|
89
|
+
#### Starting a Server
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
import asyncio
|
|
93
|
+
from multiplayer.server import GameServer
|
|
94
|
+
|
|
95
|
+
async def main():
|
|
96
|
+
# Create and start a discoverable server
|
|
97
|
+
server = GameServer(name="Battle Server", discoverable=True)
|
|
98
|
+
await server.start()
|
|
99
|
+
try:
|
|
100
|
+
await asyncio.Event().wait()
|
|
101
|
+
finally:
|
|
102
|
+
await server.stop()
|
|
103
|
+
|
|
104
|
+
if __name__ == "__main__":
|
|
105
|
+
try:
|
|
106
|
+
asyncio.run(main())
|
|
107
|
+
except KeyboardInterrupt:
|
|
108
|
+
pass
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
#### Connecting a Client
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
from multiplayer.client import GameClient
|
|
115
|
+
|
|
116
|
+
# Connect to a server
|
|
117
|
+
client = GameClient(host="127.0.0.1")
|
|
118
|
+
try:
|
|
119
|
+
client.connect()
|
|
120
|
+
|
|
121
|
+
# Register a notification handler
|
|
122
|
+
client.on_notification("GAME_EVENT", lambda p: print(f"Received event: {p}"))
|
|
123
|
+
|
|
124
|
+
# Create a player for this client session
|
|
125
|
+
player = client.create_player("Alice")
|
|
126
|
+
print(f"Connected as {player.name}")
|
|
127
|
+
finally:
|
|
128
|
+
client.disconnect()
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
For a command-line server, run `uv run python scripts/run_server.py --help`.
|
|
132
|
+
Press `CTRL+C` to stop it cleanly.
|
|
133
|
+
|
|
134
|
+
## Documentation
|
|
135
|
+
|
|
136
|
+
For more detailed information, please refer to:
|
|
137
|
+
- [REFERENCE.md](REFERENCE.md): Full API reference.
|
|
138
|
+
- [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
|
+
|
|
140
|
+
## Development
|
|
141
|
+
|
|
142
|
+
The project uses [uv](https://github.com/astral-sh/uv) for dependency management.
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
# Install development dependencies
|
|
146
|
+
uv sync
|
|
147
|
+
|
|
148
|
+
# Run quality checks and tests
|
|
149
|
+
uv run python scripts/check_project.py
|
|
150
|
+
uv run pytest
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## License
|
|
154
|
+
|
|
155
|
+
See `LICENSE.md` for details.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "multiplayer"
|
|
3
|
+
version = "2.0.1"
|
|
4
|
+
description = "Library that allows you to manage multiple players, locally, on a network, or on the Internet."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.14"
|
|
7
|
+
dependencies = [
|
|
8
|
+
"bcrypt>=5.0.0",
|
|
9
|
+
"msgpack>=1.2.1",
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
[[project.authors]]
|
|
13
|
+
name = "devfred78"
|
|
14
|
+
email = "devfred78@gmail.com"
|
|
15
|
+
|
|
16
|
+
[build-system]
|
|
17
|
+
requires = ["uv_build>=0.11.7,<0.12.0"]
|
|
18
|
+
build-backend = "uv_build"
|
|
19
|
+
|
|
20
|
+
[dependency-groups]
|
|
21
|
+
dev = [
|
|
22
|
+
"mypy>=2.1.0",
|
|
23
|
+
"pytest>=9.0.3",
|
|
24
|
+
"ruff>=0.15.16",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[tool.mypy]
|
|
28
|
+
exclude = "^private-doc/"
|
|
29
|
+
ignore_missing_imports = true
|
|
30
|
+
disable_error_code = [
|
|
31
|
+
"arg-type",
|
|
32
|
+
"assignment",
|
|
33
|
+
"misc",
|
|
34
|
+
"operator",
|
|
35
|
+
"union-attr",
|
|
36
|
+
]
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "multiplayer"
|
|
3
|
+
version = "2.0.1"
|
|
4
|
+
description = "Library that allows you to manage multiple players, locally, on a network, or on the Internet."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
authors = [
|
|
7
|
+
{ name = "devfred78", email = "devfred78@gmail.com" }
|
|
8
|
+
]
|
|
9
|
+
requires-python = ">=3.14"
|
|
10
|
+
dependencies = [
|
|
11
|
+
"bcrypt>=5.0.0",
|
|
12
|
+
"msgpack>=1.2.1",
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
[build-system]
|
|
16
|
+
requires = ["uv_build>=0.11.7,<0.12.0"]
|
|
17
|
+
build-backend = "uv_build"
|
|
18
|
+
|
|
19
|
+
[dependency-groups]
|
|
20
|
+
dev = [
|
|
21
|
+
"mypy>=2.1.0",
|
|
22
|
+
"pytest>=9.0.3",
|
|
23
|
+
"ruff>=0.15.16",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
[tool.mypy]
|
|
27
|
+
exclude = '^private-doc/'
|
|
28
|
+
ignore_missing_imports = true
|
|
29
|
+
disable_error_code = ["arg-type", "assignment", "misc", "operator", "union-attr"]
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""Multiplayer package initialization."""
|
|
2
|
+
from enum import Enum
|
|
3
|
+
|
|
4
|
+
class PlayerRole(Enum):
|
|
5
|
+
"""Enumeration for player account roles."""
|
|
6
|
+
PLAYER = "player"
|
|
7
|
+
GROUP_ADMIN = "group_admin"
|
|
8
|
+
SERVER_ADMIN = "server_admin"
|
|
9
|
+
|
|
10
|
+
class GameState(Enum):
|
|
11
|
+
"""Enumeration for the current status of a game."""
|
|
12
|
+
PENDING = "pending"
|
|
13
|
+
PAUSING = "pausing"
|
|
14
|
+
IN_PROGRESS = "in_progress"
|
|
15
|
+
FINISHED = "finished"
|
|
16
|
+
|
|
17
|
+
class ParameterFamily(Enum):
|
|
18
|
+
"""Enumeration for optional parameter families."""
|
|
19
|
+
STATIC = "static"
|
|
20
|
+
DYNAMIC = "dynamic"
|
|
21
|
+
|
|
22
|
+
class SaveFormat(Enum):
|
|
23
|
+
"""Enumeration for the supported persistence formats of a save file."""
|
|
24
|
+
JSON = "json"
|
|
25
|
+
SQLITE = "sqlite"
|