dungeoncoder 0.2.0__py3-none-any.whl

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.
Files changed (77) hide show
  1. dungeoncoder/__init__.py +4 -0
  2. dungeoncoder/__main__.py +254 -0
  3. dungeoncoder/_api_config.py +6 -0
  4. dungeoncoder/_generated/__init__.py +8 -0
  5. dungeoncoder/_generated/api/__init__.py +1 -0
  6. dungeoncoder/_generated/api/game/__init__.py +1 -0
  7. dungeoncoder/_generated/api/game/get_statistics.py +158 -0
  8. dungeoncoder/_generated/api/game/get_version.py +166 -0
  9. dungeoncoder/_generated/api/hero/__init__.py +1 -0
  10. dungeoncoder/_generated/api/hero/ask_oracle.py +192 -0
  11. dungeoncoder/_generated/api/hero/configure.py +207 -0
  12. dungeoncoder/_generated/api/hero/drop.py +207 -0
  13. dungeoncoder/_generated/api/hero/get_inventory.py +188 -0
  14. dungeoncoder/_generated/api/hero/get_items_at_position.py +188 -0
  15. dungeoncoder/_generated/api/hero/interact.py +188 -0
  16. dungeoncoder/_generated/api/hero/is_abyss_in_front.py +188 -0
  17. dungeoncoder/_generated/api/hero/is_at_goal.py +192 -0
  18. dungeoncoder/_generated/api/hero/is_collision_in_front.py +188 -0
  19. dungeoncoder/_generated/api/hero/is_enemy_in_front.py +188 -0
  20. dungeoncoder/_generated/api/hero/is_facing_north.py +188 -0
  21. dungeoncoder/_generated/api/hero/is_switch_in_front.py +188 -0
  22. dungeoncoder/_generated/api/hero/is_torch_in_front.py +188 -0
  23. dungeoncoder/_generated/api/hero/move.py +188 -0
  24. dungeoncoder/_generated/api/hero/peek_item_value.py +211 -0
  25. dungeoncoder/_generated/api/hero/pickup.py +207 -0
  26. dungeoncoder/_generated/api/hero/read_item_value.py +188 -0
  27. dungeoncoder/_generated/api/hero/sense_goal.py +192 -0
  28. dungeoncoder/_generated/api/hero/set_pace.py +207 -0
  29. dungeoncoder/_generated/api/hero/turn_left.py +188 -0
  30. dungeoncoder/_generated/api/level/__init__.py +1 -0
  31. dungeoncoder/_generated/api/level/load_level.py +190 -0
  32. dungeoncoder/_generated/api/level/reset_level.py +158 -0
  33. dungeoncoder/_generated/client.py +271 -0
  34. dungeoncoder/_generated/errors.py +14 -0
  35. dungeoncoder/_generated/models/__init__.py +47 -0
  36. dungeoncoder/_generated/models/api_error_response.py +98 -0
  37. dungeoncoder/_generated/models/api_error_response_status.py +7 -0
  38. dungeoncoder/_generated/models/boolean_result.py +96 -0
  39. dungeoncoder/_generated/models/boolean_result_status.py +7 -0
  40. dungeoncoder/_generated/models/configure_params.py +84 -0
  41. dungeoncoder/_generated/models/distance_param.py +76 -0
  42. dungeoncoder/_generated/models/name_param.py +76 -0
  43. dungeoncoder/_generated/models/nullable_integer_result.py +104 -0
  44. dungeoncoder/_generated/models/nullable_integer_result_status.py +7 -0
  45. dungeoncoder/_generated/models/nullable_string_result.py +104 -0
  46. dungeoncoder/_generated/models/nullable_string_result_status.py +7 -0
  47. dungeoncoder/_generated/models/pace_params.py +76 -0
  48. dungeoncoder/_generated/models/statistics.py +217 -0
  49. dungeoncoder/_generated/models/statistics_result.py +104 -0
  50. dungeoncoder/_generated/models/statistics_result_status.py +7 -0
  51. dungeoncoder/_generated/models/string_array_result.py +100 -0
  52. dungeoncoder/_generated/models/string_array_result_status.py +7 -0
  53. dungeoncoder/_generated/models/tiled_level.py +67 -0
  54. dungeoncoder/_generated/models/version_result.py +104 -0
  55. dungeoncoder/_generated/models/version_result_result.py +84 -0
  56. dungeoncoder/_generated/models/version_result_status.py +7 -0
  57. dungeoncoder/_generated/types.py +53 -0
  58. dungeoncoder/asciimap.py +824 -0
  59. dungeoncoder/dungeoncoder.py +482 -0
  60. dungeoncoder/generator.py +213 -0
  61. dungeoncoder/packs/gelaende.json +1 -0
  62. dungeoncoder/packs/items.json +67 -0
  63. dungeoncoder/packs/station.json +1 -0
  64. dungeoncoder/packs/studio.json +1 -0
  65. dungeoncoder/packs/tilesets.json +1 -0
  66. dungeoncoder/packs/werkstatt.json +1 -0
  67. dungeoncoder/replay.py +80 -0
  68. dungeoncoder/requirements.txt +2 -0
  69. dungeoncoder/sim.py +792 -0
  70. dungeoncoder/testing.py +63 -0
  71. dungeoncoder/trace.py +92 -0
  72. dungeoncoder/variants.py +112 -0
  73. dungeoncoder-0.2.0.dist-info/METADATA +37 -0
  74. dungeoncoder-0.2.0.dist-info/RECORD +77 -0
  75. dungeoncoder-0.2.0.dist-info/WHEEL +5 -0
  76. dungeoncoder-0.2.0.dist-info/licenses/LICENSE.txt +25 -0
  77. dungeoncoder-0.2.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,192 @@
1
+ from http import HTTPStatus
2
+ from typing import Any, cast
3
+ from urllib.parse import quote
4
+
5
+ import httpx
6
+
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...types import Response, UNSET
9
+ from ... import errors
10
+
11
+ from ...models.api_error_response import ApiErrorResponse
12
+ from ...models.nullable_string_result import NullableStringResult
13
+ from ...types import UNSET, Unset
14
+ from typing import cast
15
+
16
+
17
+
18
+ def _get_kwargs(
19
+ *,
20
+ hero: int | Unset = UNSET,
21
+
22
+ ) -> dict[str, Any]:
23
+
24
+
25
+
26
+
27
+ params: dict[str, Any] = {}
28
+
29
+ params["hero"] = hero
30
+
31
+
32
+ params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
33
+
34
+
35
+ _kwargs: dict[str, Any] = {
36
+ "method": "get",
37
+ "url": "/hero/ask_oracle",
38
+ "params": params,
39
+ }
40
+
41
+
42
+ return _kwargs
43
+
44
+
45
+
46
+ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> ApiErrorResponse | NullableStringResult | None:
47
+ if response.status_code == 200:
48
+ response_200 = NullableStringResult.from_dict(response.json())
49
+
50
+
51
+
52
+ return response_200
53
+
54
+ if response.status_code == 500:
55
+ response_500 = ApiErrorResponse.from_dict(response.json())
56
+
57
+
58
+
59
+ return response_500
60
+
61
+ if client.raise_on_unexpected_status:
62
+ raise errors.UnexpectedStatus(response.status_code, response.content)
63
+ else:
64
+ return None
65
+
66
+
67
+ def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[ApiErrorResponse | NullableStringResult]:
68
+ return Response(
69
+ status_code=HTTPStatus(response.status_code),
70
+ content=response.content,
71
+ headers=response.headers,
72
+ parsed=_parse_response(client=client, response=response),
73
+ )
74
+
75
+
76
+ def sync_detailed(
77
+ *,
78
+ client: AuthenticatedClient | Client,
79
+ hero: int | Unset = UNSET,
80
+
81
+ ) -> Response[ApiErrorResponse | NullableStringResult]:
82
+ r""" The oracle's advice, the first step of a shortest way to the exit (\"north\", \"east\", \"south\" or
83
+ \"west\"); null on the goal or without a way. Needs the map property `orakel`.
84
+
85
+ Args:
86
+ hero (int | Unset):
87
+
88
+ Raises:
89
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
90
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
91
+
92
+ Returns:
93
+ Response[ApiErrorResponse | NullableStringResult]
94
+ """
95
+
96
+
97
+ kwargs = _get_kwargs(
98
+ hero=hero,
99
+
100
+ )
101
+
102
+ response = client.get_httpx_client().request(
103
+ **kwargs,
104
+ )
105
+
106
+ return _build_response(client=client, response=response)
107
+
108
+ def sync(
109
+ *,
110
+ client: AuthenticatedClient | Client,
111
+ hero: int | Unset = UNSET,
112
+
113
+ ) -> ApiErrorResponse | NullableStringResult | None:
114
+ r""" The oracle's advice, the first step of a shortest way to the exit (\"north\", \"east\", \"south\" or
115
+ \"west\"); null on the goal or without a way. Needs the map property `orakel`.
116
+
117
+ Args:
118
+ hero (int | Unset):
119
+
120
+ Raises:
121
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
122
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
123
+
124
+ Returns:
125
+ ApiErrorResponse | NullableStringResult
126
+ """
127
+
128
+
129
+ return sync_detailed(
130
+ client=client,
131
+ hero=hero,
132
+
133
+ ).parsed
134
+
135
+ async def asyncio_detailed(
136
+ *,
137
+ client: AuthenticatedClient | Client,
138
+ hero: int | Unset = UNSET,
139
+
140
+ ) -> Response[ApiErrorResponse | NullableStringResult]:
141
+ r""" The oracle's advice, the first step of a shortest way to the exit (\"north\", \"east\", \"south\" or
142
+ \"west\"); null on the goal or without a way. Needs the map property `orakel`.
143
+
144
+ Args:
145
+ hero (int | Unset):
146
+
147
+ Raises:
148
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
149
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
150
+
151
+ Returns:
152
+ Response[ApiErrorResponse | NullableStringResult]
153
+ """
154
+
155
+
156
+ kwargs = _get_kwargs(
157
+ hero=hero,
158
+
159
+ )
160
+
161
+ response = await client.get_async_httpx_client().request(
162
+ **kwargs
163
+ )
164
+
165
+ return _build_response(client=client, response=response)
166
+
167
+ async def asyncio(
168
+ *,
169
+ client: AuthenticatedClient | Client,
170
+ hero: int | Unset = UNSET,
171
+
172
+ ) -> ApiErrorResponse | NullableStringResult | None:
173
+ r""" The oracle's advice, the first step of a shortest way to the exit (\"north\", \"east\", \"south\" or
174
+ \"west\"); null on the goal or without a way. Needs the map property `orakel`.
175
+
176
+ Args:
177
+ hero (int | Unset):
178
+
179
+ Raises:
180
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
181
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
182
+
183
+ Returns:
184
+ ApiErrorResponse | NullableStringResult
185
+ """
186
+
187
+
188
+ return (await asyncio_detailed(
189
+ client=client,
190
+ hero=hero,
191
+
192
+ )).parsed
@@ -0,0 +1,207 @@
1
+ from http import HTTPStatus
2
+ from typing import Any, cast
3
+ from urllib.parse import quote
4
+
5
+ import httpx
6
+
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...types import Response, UNSET
9
+ from ... import errors
10
+
11
+ from ...models.api_error_response import ApiErrorResponse
12
+ from ...models.boolean_result import BooleanResult
13
+ from ...models.configure_params import ConfigureParams
14
+ from ...types import UNSET, Unset
15
+ from typing import cast
16
+
17
+
18
+
19
+ def _get_kwargs(
20
+ *,
21
+ body: ConfigureParams,
22
+ hero: int | Unset = UNSET,
23
+
24
+ ) -> dict[str, Any]:
25
+ headers: dict[str, Any] = {}
26
+
27
+
28
+
29
+
30
+ params: dict[str, Any] = {}
31
+
32
+ params["hero"] = hero
33
+
34
+
35
+ params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
36
+
37
+
38
+ _kwargs: dict[str, Any] = {
39
+ "method": "post",
40
+ "url": "/hero/configure",
41
+ "params": params,
42
+ }
43
+
44
+ _kwargs["json"] = body.to_dict()
45
+
46
+ headers["Content-Type"] = "application/json"
47
+
48
+ _kwargs["headers"] = headers
49
+ return _kwargs
50
+
51
+
52
+
53
+ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> ApiErrorResponse | BooleanResult | None:
54
+ if response.status_code == 200:
55
+ response_200 = BooleanResult.from_dict(response.json())
56
+
57
+
58
+
59
+ return response_200
60
+
61
+ if response.status_code == 500:
62
+ response_500 = ApiErrorResponse.from_dict(response.json())
63
+
64
+
65
+
66
+ return response_500
67
+
68
+ if client.raise_on_unexpected_status:
69
+ raise errors.UnexpectedStatus(response.status_code, response.content)
70
+ else:
71
+ return None
72
+
73
+
74
+ def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[ApiErrorResponse | BooleanResult]:
75
+ return Response(
76
+ status_code=HTTPStatus(response.status_code),
77
+ content=response.content,
78
+ headers=response.headers,
79
+ parsed=_parse_response(client=client, response=response),
80
+ )
81
+
82
+
83
+ def sync_detailed(
84
+ *,
85
+ client: AuthenticatedClient | Client,
86
+ body: ConfigureParams,
87
+ hero: int | Unset = UNSET,
88
+
89
+ ) -> Response[ApiErrorResponse | BooleanResult]:
90
+ """ Set the hero's display name and sprite variant.
91
+
92
+ Args:
93
+ hero (int | Unset):
94
+ body (ConfigureParams):
95
+
96
+ Raises:
97
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
98
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
99
+
100
+ Returns:
101
+ Response[ApiErrorResponse | BooleanResult]
102
+ """
103
+
104
+
105
+ kwargs = _get_kwargs(
106
+ body=body,
107
+ hero=hero,
108
+
109
+ )
110
+
111
+ response = client.get_httpx_client().request(
112
+ **kwargs,
113
+ )
114
+
115
+ return _build_response(client=client, response=response)
116
+
117
+ def sync(
118
+ *,
119
+ client: AuthenticatedClient | Client,
120
+ body: ConfigureParams,
121
+ hero: int | Unset = UNSET,
122
+
123
+ ) -> ApiErrorResponse | BooleanResult | None:
124
+ """ Set the hero's display name and sprite variant.
125
+
126
+ Args:
127
+ hero (int | Unset):
128
+ body (ConfigureParams):
129
+
130
+ Raises:
131
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
132
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
133
+
134
+ Returns:
135
+ ApiErrorResponse | BooleanResult
136
+ """
137
+
138
+
139
+ return sync_detailed(
140
+ client=client,
141
+ body=body,
142
+ hero=hero,
143
+
144
+ ).parsed
145
+
146
+ async def asyncio_detailed(
147
+ *,
148
+ client: AuthenticatedClient | Client,
149
+ body: ConfigureParams,
150
+ hero: int | Unset = UNSET,
151
+
152
+ ) -> Response[ApiErrorResponse | BooleanResult]:
153
+ """ Set the hero's display name and sprite variant.
154
+
155
+ Args:
156
+ hero (int | Unset):
157
+ body (ConfigureParams):
158
+
159
+ Raises:
160
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
161
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
162
+
163
+ Returns:
164
+ Response[ApiErrorResponse | BooleanResult]
165
+ """
166
+
167
+
168
+ kwargs = _get_kwargs(
169
+ body=body,
170
+ hero=hero,
171
+
172
+ )
173
+
174
+ response = await client.get_async_httpx_client().request(
175
+ **kwargs
176
+ )
177
+
178
+ return _build_response(client=client, response=response)
179
+
180
+ async def asyncio(
181
+ *,
182
+ client: AuthenticatedClient | Client,
183
+ body: ConfigureParams,
184
+ hero: int | Unset = UNSET,
185
+
186
+ ) -> ApiErrorResponse | BooleanResult | None:
187
+ """ Set the hero's display name and sprite variant.
188
+
189
+ Args:
190
+ hero (int | Unset):
191
+ body (ConfigureParams):
192
+
193
+ Raises:
194
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
195
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
196
+
197
+ Returns:
198
+ ApiErrorResponse | BooleanResult
199
+ """
200
+
201
+
202
+ return (await asyncio_detailed(
203
+ client=client,
204
+ body=body,
205
+ hero=hero,
206
+
207
+ )).parsed
@@ -0,0 +1,207 @@
1
+ from http import HTTPStatus
2
+ from typing import Any, cast
3
+ from urllib.parse import quote
4
+
5
+ import httpx
6
+
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...types import Response, UNSET
9
+ from ... import errors
10
+
11
+ from ...models.api_error_response import ApiErrorResponse
12
+ from ...models.boolean_result import BooleanResult
13
+ from ...models.name_param import NameParam
14
+ from ...types import UNSET, Unset
15
+ from typing import cast
16
+
17
+
18
+
19
+ def _get_kwargs(
20
+ *,
21
+ body: NameParam,
22
+ hero: int | Unset = UNSET,
23
+
24
+ ) -> dict[str, Any]:
25
+ headers: dict[str, Any] = {}
26
+
27
+
28
+
29
+
30
+ params: dict[str, Any] = {}
31
+
32
+ params["hero"] = hero
33
+
34
+
35
+ params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
36
+
37
+
38
+ _kwargs: dict[str, Any] = {
39
+ "method": "post",
40
+ "url": "/hero/drop",
41
+ "params": params,
42
+ }
43
+
44
+ _kwargs["json"] = body.to_dict()
45
+
46
+ headers["Content-Type"] = "application/json"
47
+
48
+ _kwargs["headers"] = headers
49
+ return _kwargs
50
+
51
+
52
+
53
+ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> ApiErrorResponse | BooleanResult | None:
54
+ if response.status_code == 200:
55
+ response_200 = BooleanResult.from_dict(response.json())
56
+
57
+
58
+
59
+ return response_200
60
+
61
+ if response.status_code == 500:
62
+ response_500 = ApiErrorResponse.from_dict(response.json())
63
+
64
+
65
+
66
+ return response_500
67
+
68
+ if client.raise_on_unexpected_status:
69
+ raise errors.UnexpectedStatus(response.status_code, response.content)
70
+ else:
71
+ return None
72
+
73
+
74
+ def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[ApiErrorResponse | BooleanResult]:
75
+ return Response(
76
+ status_code=HTTPStatus(response.status_code),
77
+ content=response.content,
78
+ headers=response.headers,
79
+ parsed=_parse_response(client=client, response=response),
80
+ )
81
+
82
+
83
+ def sync_detailed(
84
+ *,
85
+ client: AuthenticatedClient | Client,
86
+ body: NameParam,
87
+ hero: int | Unset = UNSET,
88
+
89
+ ) -> Response[ApiErrorResponse | BooleanResult]:
90
+ """ Drop the named item from the hero's inventory.
91
+
92
+ Args:
93
+ hero (int | Unset):
94
+ body (NameParam):
95
+
96
+ Raises:
97
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
98
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
99
+
100
+ Returns:
101
+ Response[ApiErrorResponse | BooleanResult]
102
+ """
103
+
104
+
105
+ kwargs = _get_kwargs(
106
+ body=body,
107
+ hero=hero,
108
+
109
+ )
110
+
111
+ response = client.get_httpx_client().request(
112
+ **kwargs,
113
+ )
114
+
115
+ return _build_response(client=client, response=response)
116
+
117
+ def sync(
118
+ *,
119
+ client: AuthenticatedClient | Client,
120
+ body: NameParam,
121
+ hero: int | Unset = UNSET,
122
+
123
+ ) -> ApiErrorResponse | BooleanResult | None:
124
+ """ Drop the named item from the hero's inventory.
125
+
126
+ Args:
127
+ hero (int | Unset):
128
+ body (NameParam):
129
+
130
+ Raises:
131
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
132
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
133
+
134
+ Returns:
135
+ ApiErrorResponse | BooleanResult
136
+ """
137
+
138
+
139
+ return sync_detailed(
140
+ client=client,
141
+ body=body,
142
+ hero=hero,
143
+
144
+ ).parsed
145
+
146
+ async def asyncio_detailed(
147
+ *,
148
+ client: AuthenticatedClient | Client,
149
+ body: NameParam,
150
+ hero: int | Unset = UNSET,
151
+
152
+ ) -> Response[ApiErrorResponse | BooleanResult]:
153
+ """ Drop the named item from the hero's inventory.
154
+
155
+ Args:
156
+ hero (int | Unset):
157
+ body (NameParam):
158
+
159
+ Raises:
160
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
161
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
162
+
163
+ Returns:
164
+ Response[ApiErrorResponse | BooleanResult]
165
+ """
166
+
167
+
168
+ kwargs = _get_kwargs(
169
+ body=body,
170
+ hero=hero,
171
+
172
+ )
173
+
174
+ response = await client.get_async_httpx_client().request(
175
+ **kwargs
176
+ )
177
+
178
+ return _build_response(client=client, response=response)
179
+
180
+ async def asyncio(
181
+ *,
182
+ client: AuthenticatedClient | Client,
183
+ body: NameParam,
184
+ hero: int | Unset = UNSET,
185
+
186
+ ) -> ApiErrorResponse | BooleanResult | None:
187
+ """ Drop the named item from the hero's inventory.
188
+
189
+ Args:
190
+ hero (int | Unset):
191
+ body (NameParam):
192
+
193
+ Raises:
194
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
195
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
196
+
197
+ Returns:
198
+ ApiErrorResponse | BooleanResult
199
+ """
200
+
201
+
202
+ return (await asyncio_detailed(
203
+ client=client,
204
+ body=body,
205
+ hero=hero,
206
+
207
+ )).parsed