empire-core 0.7.3__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.
- empire_core/__init__.py +36 -0
- empire_core/_archive/actions.py +511 -0
- empire_core/_archive/automation/__init__.py +24 -0
- empire_core/_archive/automation/alliance_tools.py +266 -0
- empire_core/_archive/automation/battle_reports.py +196 -0
- empire_core/_archive/automation/building_queue.py +242 -0
- empire_core/_archive/automation/defense_manager.py +124 -0
- empire_core/_archive/automation/map_scanner.py +370 -0
- empire_core/_archive/automation/multi_account.py +296 -0
- empire_core/_archive/automation/quest_automation.py +94 -0
- empire_core/_archive/automation/resource_manager.py +380 -0
- empire_core/_archive/automation/target_finder.py +153 -0
- empire_core/_archive/automation/tasks.py +224 -0
- empire_core/_archive/automation/unit_production.py +719 -0
- empire_core/_archive/cli.py +68 -0
- empire_core/_archive/client_async.py +469 -0
- empire_core/_archive/commands.py +201 -0
- empire_core/_archive/connection_async.py +228 -0
- empire_core/_archive/defense.py +156 -0
- empire_core/_archive/events/__init__.py +35 -0
- empire_core/_archive/events/base.py +153 -0
- empire_core/_archive/events/manager.py +85 -0
- empire_core/accounts.py +190 -0
- empire_core/client/__init__.py +0 -0
- empire_core/client/client.py +459 -0
- empire_core/config.py +87 -0
- empire_core/exceptions.py +42 -0
- empire_core/network/__init__.py +0 -0
- empire_core/network/connection.py +378 -0
- empire_core/protocol/__init__.py +0 -0
- empire_core/protocol/models/__init__.py +339 -0
- empire_core/protocol/models/alliance.py +186 -0
- empire_core/protocol/models/army.py +444 -0
- empire_core/protocol/models/attack.py +229 -0
- empire_core/protocol/models/auth.py +216 -0
- empire_core/protocol/models/base.py +403 -0
- empire_core/protocol/models/building.py +455 -0
- empire_core/protocol/models/castle.py +317 -0
- empire_core/protocol/models/chat.py +150 -0
- empire_core/protocol/models/defense.py +300 -0
- empire_core/protocol/models/map.py +269 -0
- empire_core/protocol/packet.py +104 -0
- empire_core/services/__init__.py +31 -0
- empire_core/services/alliance.py +222 -0
- empire_core/services/base.py +107 -0
- empire_core/services/castle.py +221 -0
- empire_core/state/__init__.py +0 -0
- empire_core/state/manager.py +398 -0
- empire_core/state/models.py +215 -0
- empire_core/state/quest_models.py +60 -0
- empire_core/state/report_models.py +115 -0
- empire_core/state/unit_models.py +75 -0
- empire_core/state/world_models.py +269 -0
- empire_core/storage/__init__.py +1 -0
- empire_core/storage/database.py +237 -0
- empire_core/utils/__init__.py +0 -0
- empire_core/utils/battle_sim.py +172 -0
- empire_core/utils/calculations.py +170 -0
- empire_core/utils/crypto.py +8 -0
- empire_core/utils/decorators.py +69 -0
- empire_core/utils/enums.py +111 -0
- empire_core/utils/helpers.py +252 -0
- empire_core/utils/response_awaiter.py +153 -0
- empire_core/utils/troops.py +93 -0
- empire_core-0.7.3.dist-info/METADATA +197 -0
- empire_core-0.7.3.dist-info/RECORD +67 -0
- empire_core-0.7.3.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Attack and spy protocol models.
|
|
3
|
+
|
|
4
|
+
Commands:
|
|
5
|
+
- cra: Create/send attack
|
|
6
|
+
- csm: Send spy mission
|
|
7
|
+
- gas: Get attack presets
|
|
8
|
+
- msd: Skip attack cooldown
|
|
9
|
+
- sdc: Skip defense cooldown
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
from pydantic import ConfigDict, Field
|
|
15
|
+
|
|
16
|
+
from .base import BaseRequest, BaseResponse, UnitCount
|
|
17
|
+
|
|
18
|
+
# =============================================================================
|
|
19
|
+
# CRA - Create Attack
|
|
20
|
+
# =============================================================================
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class CreateAttackRequest(BaseRequest):
|
|
24
|
+
"""
|
|
25
|
+
Send an attack to a target.
|
|
26
|
+
|
|
27
|
+
Command: cra
|
|
28
|
+
Payload: {
|
|
29
|
+
"CID": source_castle_id,
|
|
30
|
+
"TX": target_x,
|
|
31
|
+
"TY": target_y,
|
|
32
|
+
"TK": target_kingdom,
|
|
33
|
+
"U": [{"UID": unit_id, "C": count}, ...],
|
|
34
|
+
"T": [{"TID": tool_id, "C": count}, ...], # optional
|
|
35
|
+
"AT": attack_type, # 1=attack, 2=support, etc.
|
|
36
|
+
}
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
command = "cra"
|
|
40
|
+
|
|
41
|
+
castle_id: int = Field(alias="CID")
|
|
42
|
+
target_x: int = Field(alias="TX")
|
|
43
|
+
target_y: int = Field(alias="TY")
|
|
44
|
+
target_kingdom: int = Field(alias="TK", default=0)
|
|
45
|
+
units: list[UnitCount] = Field(alias="U", default_factory=list)
|
|
46
|
+
tools: list[UnitCount] = Field(alias="T", default_factory=list)
|
|
47
|
+
attack_type: int = Field(alias="AT", default=1) # 1=attack
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class CreateAttackResponse(BaseResponse):
|
|
51
|
+
"""
|
|
52
|
+
Response to attack creation.
|
|
53
|
+
|
|
54
|
+
Command: cra
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
command = "cra"
|
|
58
|
+
|
|
59
|
+
movement_id: int = Field(alias="MID", default=0)
|
|
60
|
+
arrival_time: int = Field(alias="AT", default=0) # Unix timestamp
|
|
61
|
+
error_code: int = Field(alias="E", default=0)
|
|
62
|
+
error_message: str | None = Field(alias="EM", default=None)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
# =============================================================================
|
|
66
|
+
# CSM - Send Spy Mission
|
|
67
|
+
# =============================================================================
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class SendSpyRequest(BaseRequest):
|
|
71
|
+
"""
|
|
72
|
+
Send a spy mission to a target.
|
|
73
|
+
|
|
74
|
+
Command: csm
|
|
75
|
+
Payload: {
|
|
76
|
+
"CID": source_castle_id,
|
|
77
|
+
"TX": target_x,
|
|
78
|
+
"TY": target_y,
|
|
79
|
+
"TK": target_kingdom,
|
|
80
|
+
"SC": spy_count,
|
|
81
|
+
}
|
|
82
|
+
"""
|
|
83
|
+
|
|
84
|
+
command = "csm"
|
|
85
|
+
|
|
86
|
+
castle_id: int = Field(alias="CID")
|
|
87
|
+
target_x: int = Field(alias="TX")
|
|
88
|
+
target_y: int = Field(alias="TY")
|
|
89
|
+
target_kingdom: int = Field(alias="TK", default=0)
|
|
90
|
+
spy_count: int = Field(alias="SC", default=1)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class SendSpyResponse(BaseResponse):
|
|
94
|
+
"""
|
|
95
|
+
Response to spy mission.
|
|
96
|
+
|
|
97
|
+
Command: csm
|
|
98
|
+
"""
|
|
99
|
+
|
|
100
|
+
command = "csm"
|
|
101
|
+
|
|
102
|
+
movement_id: int = Field(alias="MID", default=0)
|
|
103
|
+
arrival_time: int = Field(alias="AT", default=0)
|
|
104
|
+
error_code: int = Field(alias="E", default=0)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
# =============================================================================
|
|
108
|
+
# GAS - Get Attack Presets
|
|
109
|
+
# =============================================================================
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
class GetPresetsRequest(BaseRequest):
|
|
113
|
+
"""
|
|
114
|
+
Get saved attack presets.
|
|
115
|
+
|
|
116
|
+
Command: gas
|
|
117
|
+
Payload: {"CID": castle_id} or {} (empty for all)
|
|
118
|
+
"""
|
|
119
|
+
|
|
120
|
+
command = "gas"
|
|
121
|
+
|
|
122
|
+
castle_id: int | None = Field(alias="CID", default=None)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
class AttackPreset(BaseResponse):
|
|
126
|
+
"""A saved attack preset."""
|
|
127
|
+
|
|
128
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
129
|
+
|
|
130
|
+
preset_id: int = Field(alias="PID")
|
|
131
|
+
name: str = Field(alias="N")
|
|
132
|
+
units: list[UnitCount] = Field(alias="U", default_factory=list)
|
|
133
|
+
tools: list[UnitCount] = Field(alias="T", default_factory=list)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
class GetPresetsResponse(BaseResponse):
|
|
137
|
+
"""
|
|
138
|
+
Response containing attack presets.
|
|
139
|
+
|
|
140
|
+
Command: gas
|
|
141
|
+
"""
|
|
142
|
+
|
|
143
|
+
command = "gas"
|
|
144
|
+
|
|
145
|
+
presets: list[AttackPreset] = Field(alias="P", default_factory=list)
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
# =============================================================================
|
|
149
|
+
# MSD - Skip Attack Cooldown
|
|
150
|
+
# =============================================================================
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
class SkipAttackCooldownRequest(BaseRequest):
|
|
154
|
+
"""
|
|
155
|
+
Skip attack cooldown using rubies.
|
|
156
|
+
|
|
157
|
+
Command: msd
|
|
158
|
+
Payload: {"CID": castle_id}
|
|
159
|
+
"""
|
|
160
|
+
|
|
161
|
+
command = "msd"
|
|
162
|
+
|
|
163
|
+
castle_id: int = Field(alias="CID")
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
class SkipAttackCooldownResponse(BaseResponse):
|
|
167
|
+
"""
|
|
168
|
+
Response to skipping attack cooldown.
|
|
169
|
+
|
|
170
|
+
Command: msd
|
|
171
|
+
"""
|
|
172
|
+
|
|
173
|
+
command = "msd"
|
|
174
|
+
|
|
175
|
+
success: bool = Field(default=True)
|
|
176
|
+
rubies_spent: int = Field(alias="RS", default=0)
|
|
177
|
+
error_code: int = Field(alias="E", default=0)
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
# =============================================================================
|
|
181
|
+
# SDC - Skip Defense Cooldown
|
|
182
|
+
# =============================================================================
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
class SkipDefenseCooldownRequest(BaseRequest):
|
|
186
|
+
"""
|
|
187
|
+
Skip defense cooldown using rubies.
|
|
188
|
+
|
|
189
|
+
Command: sdc
|
|
190
|
+
Payload: {"CID": castle_id}
|
|
191
|
+
"""
|
|
192
|
+
|
|
193
|
+
command = "sdc"
|
|
194
|
+
|
|
195
|
+
castle_id: int = Field(alias="CID")
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
class SkipDefenseCooldownResponse(BaseResponse):
|
|
199
|
+
"""
|
|
200
|
+
Response to skipping defense cooldown.
|
|
201
|
+
|
|
202
|
+
Command: sdc
|
|
203
|
+
"""
|
|
204
|
+
|
|
205
|
+
command = "sdc"
|
|
206
|
+
|
|
207
|
+
success: bool = Field(default=True)
|
|
208
|
+
rubies_spent: int = Field(alias="RS", default=0)
|
|
209
|
+
error_code: int = Field(alias="E", default=0)
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
__all__ = [
|
|
213
|
+
# CRA - Create Attack
|
|
214
|
+
"CreateAttackRequest",
|
|
215
|
+
"CreateAttackResponse",
|
|
216
|
+
# CSM - Send Spy
|
|
217
|
+
"SendSpyRequest",
|
|
218
|
+
"SendSpyResponse",
|
|
219
|
+
# GAS - Get Presets
|
|
220
|
+
"GetPresetsRequest",
|
|
221
|
+
"GetPresetsResponse",
|
|
222
|
+
"AttackPreset",
|
|
223
|
+
# MSD - Skip Attack Cooldown
|
|
224
|
+
"SkipAttackCooldownRequest",
|
|
225
|
+
"SkipAttackCooldownResponse",
|
|
226
|
+
# SDC - Skip Defense Cooldown
|
|
227
|
+
"SkipDefenseCooldownRequest",
|
|
228
|
+
"SkipDefenseCooldownResponse",
|
|
229
|
+
]
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Authentication protocol models.
|
|
3
|
+
|
|
4
|
+
Commands:
|
|
5
|
+
- lli: Login
|
|
6
|
+
- lre: Register new account
|
|
7
|
+
- vpn: Check username availability
|
|
8
|
+
- vln: Check if username exists (for login)
|
|
9
|
+
- lpp: Password recovery
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
from pydantic import ConfigDict, Field
|
|
15
|
+
|
|
16
|
+
from .base import BaseRequest, BaseResponse
|
|
17
|
+
|
|
18
|
+
# =============================================================================
|
|
19
|
+
# LLI - Login
|
|
20
|
+
# =============================================================================
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class LoginRequest(BaseRequest):
|
|
24
|
+
"""
|
|
25
|
+
Login request.
|
|
26
|
+
|
|
27
|
+
Command: lli
|
|
28
|
+
Payload: {"NM": "username", "PW": "password", "L": "en", "AID": "..."}
|
|
29
|
+
|
|
30
|
+
Note: The actual login is typically handled by the client's login() method
|
|
31
|
+
which manages the full authentication flow including handshake.
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
command = "lli"
|
|
35
|
+
|
|
36
|
+
username: str = Field(alias="NM")
|
|
37
|
+
password: str = Field(alias="PW")
|
|
38
|
+
language: str = Field(alias="L", default="en")
|
|
39
|
+
app_id: str | None = Field(alias="AID", default=None)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class PlayerData(BaseRequest):
|
|
43
|
+
"""Player data returned after login."""
|
|
44
|
+
|
|
45
|
+
model_config = ConfigDict(populate_by_name=True, extra="allow")
|
|
46
|
+
|
|
47
|
+
player_id: int = Field(alias="PID")
|
|
48
|
+
player_name: str = Field(alias="PN")
|
|
49
|
+
alliance_id: int | None = Field(alias="AID", default=None)
|
|
50
|
+
alliance_name: str | None = Field(alias="AN", default=None)
|
|
51
|
+
level: int = Field(alias="L", default=1)
|
|
52
|
+
experience: int = Field(alias="XP", default=0)
|
|
53
|
+
rubies: int = Field(alias="R", default=0)
|
|
54
|
+
coins: int = Field(alias="C", default=0)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class LoginResponse(BaseResponse):
|
|
58
|
+
"""
|
|
59
|
+
Login response.
|
|
60
|
+
|
|
61
|
+
Command: lli
|
|
62
|
+
Contains player data on successful login.
|
|
63
|
+
"""
|
|
64
|
+
|
|
65
|
+
command = "lli"
|
|
66
|
+
|
|
67
|
+
player: PlayerData | None = Field(alias="P", default=None)
|
|
68
|
+
session_id: str | None = Field(alias="SID", default=None)
|
|
69
|
+
error_code: int = Field(alias="E", default=0)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
# =============================================================================
|
|
73
|
+
# LRE - Register
|
|
74
|
+
# =============================================================================
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class RegisterRequest(BaseRequest):
|
|
78
|
+
"""
|
|
79
|
+
Register new account request.
|
|
80
|
+
|
|
81
|
+
Command: lre
|
|
82
|
+
Payload: {"NM": "username", "PW": "password", "EM": "email", "L": "en"}
|
|
83
|
+
"""
|
|
84
|
+
|
|
85
|
+
command = "lre"
|
|
86
|
+
|
|
87
|
+
username: str = Field(alias="NM")
|
|
88
|
+
password: str = Field(alias="PW")
|
|
89
|
+
email: str = Field(alias="EM")
|
|
90
|
+
language: str = Field(alias="L", default="en")
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class RegisterResponse(BaseResponse):
|
|
94
|
+
"""
|
|
95
|
+
Register response.
|
|
96
|
+
|
|
97
|
+
Command: lre
|
|
98
|
+
"""
|
|
99
|
+
|
|
100
|
+
command = "lre"
|
|
101
|
+
|
|
102
|
+
success: bool = Field(alias="S", default=False)
|
|
103
|
+
error_code: int = Field(alias="E", default=0)
|
|
104
|
+
error_message: str | None = Field(alias="EM", default=None)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
# =============================================================================
|
|
108
|
+
# VPN - Check Username Availability
|
|
109
|
+
# =============================================================================
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
class CheckUsernameAvailableRequest(BaseRequest):
|
|
113
|
+
"""
|
|
114
|
+
Check if a username is available for registration.
|
|
115
|
+
|
|
116
|
+
Command: vpn
|
|
117
|
+
Payload: {"NM": "username"}
|
|
118
|
+
"""
|
|
119
|
+
|
|
120
|
+
command = "vpn"
|
|
121
|
+
|
|
122
|
+
username: str = Field(alias="NM")
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
class CheckUsernameAvailableResponse(BaseResponse):
|
|
126
|
+
"""
|
|
127
|
+
Response for username availability check.
|
|
128
|
+
|
|
129
|
+
Command: vpn
|
|
130
|
+
"""
|
|
131
|
+
|
|
132
|
+
command = "vpn"
|
|
133
|
+
|
|
134
|
+
available: bool = Field(alias="A", default=False)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
# =============================================================================
|
|
138
|
+
# VLN - Check Username Exists (for login)
|
|
139
|
+
# =============================================================================
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
class CheckUsernameExistsRequest(BaseRequest):
|
|
143
|
+
"""
|
|
144
|
+
Check if a username exists (for login validation).
|
|
145
|
+
|
|
146
|
+
Command: vln
|
|
147
|
+
Payload: {"NM": "username"}
|
|
148
|
+
"""
|
|
149
|
+
|
|
150
|
+
command = "vln"
|
|
151
|
+
|
|
152
|
+
username: str = Field(alias="NM")
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
class CheckUsernameExistsResponse(BaseResponse):
|
|
156
|
+
"""
|
|
157
|
+
Response for username existence check.
|
|
158
|
+
|
|
159
|
+
Command: vln
|
|
160
|
+
"""
|
|
161
|
+
|
|
162
|
+
command = "vln"
|
|
163
|
+
|
|
164
|
+
exists: bool = Field(alias="E", default=False)
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
# =============================================================================
|
|
168
|
+
# LPP - Password Recovery
|
|
169
|
+
# =============================================================================
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
class PasswordRecoveryRequest(BaseRequest):
|
|
173
|
+
"""
|
|
174
|
+
Request password recovery email.
|
|
175
|
+
|
|
176
|
+
Command: lpp
|
|
177
|
+
Payload: {"EM": "email"} or {"NM": "username"}
|
|
178
|
+
"""
|
|
179
|
+
|
|
180
|
+
command = "lpp"
|
|
181
|
+
|
|
182
|
+
email: str | None = Field(alias="EM", default=None)
|
|
183
|
+
username: str | None = Field(alias="NM", default=None)
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
class PasswordRecoveryResponse(BaseResponse):
|
|
187
|
+
"""
|
|
188
|
+
Response for password recovery request.
|
|
189
|
+
|
|
190
|
+
Command: lpp
|
|
191
|
+
"""
|
|
192
|
+
|
|
193
|
+
command = "lpp"
|
|
194
|
+
|
|
195
|
+
success: bool = Field(alias="S", default=False)
|
|
196
|
+
error_code: int = Field(alias="E", default=0)
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
__all__ = [
|
|
200
|
+
# LLI - Login
|
|
201
|
+
"LoginRequest",
|
|
202
|
+
"LoginResponse",
|
|
203
|
+
"PlayerData",
|
|
204
|
+
# LRE - Register
|
|
205
|
+
"RegisterRequest",
|
|
206
|
+
"RegisterResponse",
|
|
207
|
+
# VPN - Username Available
|
|
208
|
+
"CheckUsernameAvailableRequest",
|
|
209
|
+
"CheckUsernameAvailableResponse",
|
|
210
|
+
# VLN - Username Exists
|
|
211
|
+
"CheckUsernameExistsRequest",
|
|
212
|
+
"CheckUsernameExistsResponse",
|
|
213
|
+
# LPP - Password Recovery
|
|
214
|
+
"PasswordRecoveryRequest",
|
|
215
|
+
"PasswordRecoveryResponse",
|
|
216
|
+
]
|