empire-core 0.1.0__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.
- empire_core-0.1.0/.github/workflows/ci.yml +51 -0
- empire_core-0.1.0/.github/workflows/publish.yml +76 -0
- empire_core-0.1.0/.gitignore +138 -0
- empire_core-0.1.0/.pre-commit-config.yaml +22 -0
- empire_core-0.1.0/GEMINI.md +48 -0
- empire_core-0.1.0/PKG-INFO +162 -0
- empire_core-0.1.0/README.md +135 -0
- empire_core-0.1.0/STATUS.md +59 -0
- empire_core-0.1.0/TODO.md +26 -0
- empire_core-0.1.0/accounts.json.template +6 -0
- empire_core-0.1.0/docs/ACTION_COMMANDS.md +301 -0
- empire_core-0.1.0/docs/FEATURE_COMPARISON.md +51 -0
- empire_core-0.1.0/docs/FEATURE_PARITY.md +126 -0
- empire_core-0.1.0/docs/GAME_MECHANICS.md +566 -0
- empire_core-0.1.0/docs/PYGGE_COMPARISON.md +185 -0
- empire_core-0.1.0/docs/design/action_commands.md +68 -0
- empire_core-0.1.0/docs/design/architecture.md +50 -0
- empire_core-0.1.0/docs/design/deep_dive_findings.md +166 -0
- empire_core-0.1.0/docs/design/events.md +61 -0
- empire_core-0.1.0/docs/design/game_bundle_analysis.md +70 -0
- empire_core-0.1.0/docs/design/protocol.md +62 -0
- empire_core-0.1.0/docs/design/response_validation.md +114 -0
- empire_core-0.1.0/docs/design/state_management.md +64 -0
- empire_core-0.1.0/examples/battle_report_analyzer.py +162 -0
- empire_core-0.1.0/examples/demo.py +95 -0
- empire_core-0.1.0/examples/detailed_state_demo.py +135 -0
- empire_core-0.1.0/examples/map_persistence_demo.py +96 -0
- empire_core-0.1.0/examples/movement_tracker.py +222 -0
- empire_core-0.1.0/examples/quest_monitor.py +135 -0
- empire_core-0.1.0/examples/resource_monitor_bot.py +103 -0
- empire_core-0.1.0/examples/simple_farm_bot.py +119 -0
- empire_core-0.1.0/examples/world_mapper.py +133 -0
- empire_core-0.1.0/pyproject.toml +93 -0
- empire_core-0.1.0/pytest.ini +5 -0
- empire_core-0.1.0/src/empire_core/__init__.py +124 -0
- empire_core-0.1.0/src/empire_core/accounts.py +186 -0
- empire_core-0.1.0/src/empire_core/automation/__init__.py +24 -0
- empire_core-0.1.0/src/empire_core/automation/alliance_tools.py +266 -0
- empire_core-0.1.0/src/empire_core/automation/battle_reports.py +196 -0
- empire_core-0.1.0/src/empire_core/automation/building_queue.py +242 -0
- empire_core-0.1.0/src/empire_core/automation/defense_manager.py +124 -0
- empire_core-0.1.0/src/empire_core/automation/map_scanner.py +370 -0
- empire_core-0.1.0/src/empire_core/automation/multi_account.py +296 -0
- empire_core-0.1.0/src/empire_core/automation/quest_automation.py +94 -0
- empire_core-0.1.0/src/empire_core/automation/resource_manager.py +380 -0
- empire_core-0.1.0/src/empire_core/automation/target_finder.py +153 -0
- empire_core-0.1.0/src/empire_core/automation/tasks.py +224 -0
- empire_core-0.1.0/src/empire_core/automation/unit_production.py +719 -0
- empire_core-0.1.0/src/empire_core/cli.py +69 -0
- empire_core-0.1.0/src/empire_core/client/__init__.py +0 -0
- empire_core-0.1.0/src/empire_core/client/actions.py +412 -0
- empire_core-0.1.0/src/empire_core/client/client.py +469 -0
- empire_core-0.1.0/src/empire_core/client/commands.py +201 -0
- empire_core-0.1.0/src/empire_core/client/defense.py +156 -0
- empire_core-0.1.0/src/empire_core/config.py +87 -0
- empire_core-0.1.0/src/empire_core/events/__init__.py +35 -0
- empire_core-0.1.0/src/empire_core/events/base.py +154 -0
- empire_core-0.1.0/src/empire_core/events/manager.py +85 -0
- empire_core-0.1.0/src/empire_core/exceptions.py +42 -0
- empire_core-0.1.0/src/empire_core/network/__init__.py +0 -0
- empire_core-0.1.0/src/empire_core/network/connection.py +229 -0
- empire_core-0.1.0/src/empire_core/protocol/__init__.py +0 -0
- empire_core-0.1.0/src/empire_core/protocol/packet.py +104 -0
- empire_core-0.1.0/src/empire_core/state/__init__.py +0 -0
- empire_core-0.1.0/src/empire_core/state/manager.py +649 -0
- empire_core-0.1.0/src/empire_core/state/models.py +207 -0
- empire_core-0.1.0/src/empire_core/state/quest_models.py +60 -0
- empire_core-0.1.0/src/empire_core/state/report_models.py +115 -0
- empire_core-0.1.0/src/empire_core/state/unit_models.py +75 -0
- empire_core-0.1.0/src/empire_core/state/world_models.py +254 -0
- empire_core-0.1.0/src/empire_core/storage/__init__.py +1 -0
- empire_core-0.1.0/src/empire_core/storage/database.py +237 -0
- empire_core-0.1.0/src/empire_core/utils/__init__.py +0 -0
- empire_core-0.1.0/src/empire_core/utils/battle_sim.py +172 -0
- empire_core-0.1.0/src/empire_core/utils/calculations.py +170 -0
- empire_core-0.1.0/src/empire_core/utils/crypto.py +8 -0
- empire_core-0.1.0/src/empire_core/utils/decorators.py +69 -0
- empire_core-0.1.0/src/empire_core/utils/enums.py +111 -0
- empire_core-0.1.0/src/empire_core/utils/helpers.py +252 -0
- empire_core-0.1.0/src/empire_core/utils/response_awaiter.py +153 -0
- empire_core-0.1.0/test_all_imports.py +9 -0
- empire_core-0.1.0/tests/manual_network_test.py +114 -0
- empire_core-0.1.0/tests/manual_state_population_test.py +59 -0
- empire_core-0.1.0/tests/real_network_test.py +46 -0
- empire_core-0.1.0/tests/test_account_pool.py +59 -0
- empire_core-0.1.0/tests/test_actions.py +103 -0
- empire_core-0.1.0/tests/test_events.py +48 -0
- empire_core-0.1.0/tests/test_handshake.py +93 -0
- empire_core-0.1.0/tests/test_response_awaiter.py +146 -0
- empire_core-0.1.0/uv.lock +2034 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [master]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [master]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
lint:
|
|
11
|
+
name: Lint & Type Check
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
|
|
16
|
+
- name: Install uv
|
|
17
|
+
uses: astral-sh/setup-uv@v4
|
|
18
|
+
with:
|
|
19
|
+
version: "latest"
|
|
20
|
+
|
|
21
|
+
- name: Set up Python
|
|
22
|
+
run: uv python install 3.12
|
|
23
|
+
|
|
24
|
+
- name: Install dependencies
|
|
25
|
+
run: uv sync --extra dev
|
|
26
|
+
|
|
27
|
+
- name: Run pre-commit
|
|
28
|
+
uses: pre-commit/action@v3.0.1
|
|
29
|
+
|
|
30
|
+
test:
|
|
31
|
+
name: Test (Python ${{ matrix.python-version }})
|
|
32
|
+
runs-on: ubuntu-latest
|
|
33
|
+
strategy:
|
|
34
|
+
matrix:
|
|
35
|
+
python-version: ["3.10", "3.11", "3.12"]
|
|
36
|
+
steps:
|
|
37
|
+
- uses: actions/checkout@v4
|
|
38
|
+
|
|
39
|
+
- name: Install uv
|
|
40
|
+
uses: astral-sh/setup-uv@v4
|
|
41
|
+
with:
|
|
42
|
+
version: "latest"
|
|
43
|
+
|
|
44
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
45
|
+
run: uv python install ${{ matrix.python-version }}
|
|
46
|
+
|
|
47
|
+
- name: Install dependencies
|
|
48
|
+
run: uv sync --extra dev
|
|
49
|
+
|
|
50
|
+
- name: Run tests
|
|
51
|
+
run: uv run pytest -v
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_run:
|
|
5
|
+
workflows: ["CI"]
|
|
6
|
+
types: [completed]
|
|
7
|
+
branches: [master]
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
release:
|
|
12
|
+
name: Semantic Release
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
|
|
15
|
+
concurrency: release
|
|
16
|
+
permissions:
|
|
17
|
+
contents: write
|
|
18
|
+
outputs:
|
|
19
|
+
released: ${{ steps.release.outputs.released }}
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v4
|
|
22
|
+
with:
|
|
23
|
+
fetch-depth: 0
|
|
24
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
|
25
|
+
|
|
26
|
+
- name: Install uv
|
|
27
|
+
uses: astral-sh/setup-uv@v4
|
|
28
|
+
with:
|
|
29
|
+
version: "latest"
|
|
30
|
+
|
|
31
|
+
- name: Set up Python
|
|
32
|
+
run: uv python install 3.12
|
|
33
|
+
|
|
34
|
+
- name: Install dependencies
|
|
35
|
+
run: uv sync --extra dev
|
|
36
|
+
|
|
37
|
+
- name: Semantic Release
|
|
38
|
+
id: release
|
|
39
|
+
env:
|
|
40
|
+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
41
|
+
run: |
|
|
42
|
+
output=$(uv run semantic-release version 2>&1) || true
|
|
43
|
+
echo "$output"
|
|
44
|
+
if echo "$output" | grep -q "No release will be made"; then
|
|
45
|
+
echo "released=false" >> $GITHUB_OUTPUT
|
|
46
|
+
elif [ -d "dist" ] && [ "$(ls -A dist)" ]; then
|
|
47
|
+
echo "released=true" >> $GITHUB_OUTPUT
|
|
48
|
+
uv run semantic-release publish
|
|
49
|
+
else
|
|
50
|
+
echo "released=false" >> $GITHUB_OUTPUT
|
|
51
|
+
fi
|
|
52
|
+
|
|
53
|
+
publish:
|
|
54
|
+
name: Publish to PyPI
|
|
55
|
+
needs: release
|
|
56
|
+
if: needs.release.outputs.released == 'true'
|
|
57
|
+
runs-on: ubuntu-latest
|
|
58
|
+
environment: pypi
|
|
59
|
+
permissions:
|
|
60
|
+
id-token: write
|
|
61
|
+
steps:
|
|
62
|
+
- uses: actions/checkout@v4
|
|
63
|
+
|
|
64
|
+
- name: Install uv
|
|
65
|
+
uses: astral-sh/setup-uv@v4
|
|
66
|
+
with:
|
|
67
|
+
version: "latest"
|
|
68
|
+
|
|
69
|
+
- name: Set up Python
|
|
70
|
+
run: uv python install 3.12
|
|
71
|
+
|
|
72
|
+
- name: Build package
|
|
73
|
+
run: uv build
|
|
74
|
+
|
|
75
|
+
- name: Upload to PyPI
|
|
76
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
*.egg-info/
|
|
24
|
+
.installed.cfg
|
|
25
|
+
*.egg
|
|
26
|
+
|
|
27
|
+
# PyInstaller
|
|
28
|
+
# Usually these files are written by a python script from a template
|
|
29
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
30
|
+
*.manifest
|
|
31
|
+
*.spec
|
|
32
|
+
|
|
33
|
+
# Installer logs
|
|
34
|
+
pip-log.txt
|
|
35
|
+
pip-delete-this-directory.txt
|
|
36
|
+
|
|
37
|
+
# Unit test / coverage reports
|
|
38
|
+
htmlcov/
|
|
39
|
+
.tox/
|
|
40
|
+
.nox/
|
|
41
|
+
.coverage
|
|
42
|
+
.coverage.*
|
|
43
|
+
.cache
|
|
44
|
+
nosetests.xml
|
|
45
|
+
coverage.xml
|
|
46
|
+
*.cover
|
|
47
|
+
*.py,cover
|
|
48
|
+
.hypothesis/
|
|
49
|
+
.pytest_cache/
|
|
50
|
+
|
|
51
|
+
# Translations
|
|
52
|
+
*.mo
|
|
53
|
+
*.pot
|
|
54
|
+
|
|
55
|
+
# Django stuff:
|
|
56
|
+
*.log
|
|
57
|
+
local_settings.py
|
|
58
|
+
db.sqlite3
|
|
59
|
+
db.sqlite3-journal
|
|
60
|
+
|
|
61
|
+
# Flask stuff:
|
|
62
|
+
instance/
|
|
63
|
+
.webassets-cache
|
|
64
|
+
|
|
65
|
+
# Scrapy stuff:
|
|
66
|
+
.scrapy
|
|
67
|
+
|
|
68
|
+
# Sphinx documentation
|
|
69
|
+
docs/_build/
|
|
70
|
+
|
|
71
|
+
# PyBuilder
|
|
72
|
+
target/
|
|
73
|
+
|
|
74
|
+
# Jupyter Notebook
|
|
75
|
+
.ipynb_checkpoints
|
|
76
|
+
|
|
77
|
+
# IPython
|
|
78
|
+
profile_default/
|
|
79
|
+
ipython_config.py
|
|
80
|
+
|
|
81
|
+
# pyenv
|
|
82
|
+
.python-version
|
|
83
|
+
|
|
84
|
+
# pipenv
|
|
85
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
86
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
87
|
+
# with no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
88
|
+
# install all needed dependencies.
|
|
89
|
+
#Pipfile.lock
|
|
90
|
+
|
|
91
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
|
92
|
+
__pypackages__/
|
|
93
|
+
|
|
94
|
+
# Celery stuff
|
|
95
|
+
celerybeat-schedule
|
|
96
|
+
celerybeat.pid
|
|
97
|
+
|
|
98
|
+
# SageMath parsed files
|
|
99
|
+
*.sage.py
|
|
100
|
+
|
|
101
|
+
# Environments
|
|
102
|
+
.env
|
|
103
|
+
.venv
|
|
104
|
+
env/
|
|
105
|
+
venv/
|
|
106
|
+
ENV/
|
|
107
|
+
env.bak/
|
|
108
|
+
venv.bak/
|
|
109
|
+
|
|
110
|
+
# Spyder project settings
|
|
111
|
+
.spyderproject
|
|
112
|
+
.spyproject
|
|
113
|
+
|
|
114
|
+
# Rope project settings
|
|
115
|
+
.ropeproject
|
|
116
|
+
|
|
117
|
+
# mkdocs documentation
|
|
118
|
+
/site
|
|
119
|
+
|
|
120
|
+
# mypy
|
|
121
|
+
.mypy_cache/
|
|
122
|
+
.dmypy.json
|
|
123
|
+
dmypy.json
|
|
124
|
+
|
|
125
|
+
# Pyre type checker
|
|
126
|
+
.pyre/
|
|
127
|
+
|
|
128
|
+
# Editors
|
|
129
|
+
.vscode/
|
|
130
|
+
.idea/
|
|
131
|
+
*.swp
|
|
132
|
+
*.swo
|
|
133
|
+
|
|
134
|
+
# Config
|
|
135
|
+
accounts.json
|
|
136
|
+
*.db
|
|
137
|
+
*.db-shm
|
|
138
|
+
*.db-wal
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Pre-commit configuration for EmpireCore
|
|
2
|
+
repos:
|
|
3
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
4
|
+
rev: v0.1.14
|
|
5
|
+
hooks:
|
|
6
|
+
- id: ruff
|
|
7
|
+
args: [ --fix ]
|
|
8
|
+
- id: ruff-format
|
|
9
|
+
|
|
10
|
+
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
11
|
+
rev: v1.8.0
|
|
12
|
+
hooks:
|
|
13
|
+
- id: mypy
|
|
14
|
+
additional_dependencies: [ pydantic, aiohttp, python-dotenv, typer, sqlmodel, aiosqlite, sqlalchemy, types-tabulate ]
|
|
15
|
+
args: []
|
|
16
|
+
|
|
17
|
+
- repo: https://github.com/compilerla/conventional-pre-commit
|
|
18
|
+
rev: v3.1.0
|
|
19
|
+
hooks:
|
|
20
|
+
- id: conventional-pre-commit
|
|
21
|
+
stages: [ commit-msg ]
|
|
22
|
+
args: []
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# EmpireCore - AI Context File
|
|
2
|
+
|
|
3
|
+
## Project Overview
|
|
4
|
+
**EmpireCore** is a modern, async Python library for automating the browser game *Goodgame Empire*.
|
|
5
|
+
It provides a high-level, type-safe API for interacting with the game server via WebSocket (SmartFoxServer protocol).
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Technical Stack & Tooling
|
|
10
|
+
* **Package Manager**: `uv` (standard for this repo).
|
|
11
|
+
* **Build System**: `hatchling` (PEP 621).
|
|
12
|
+
* **Linter/Formatter**: `ruff`.
|
|
13
|
+
* **Type Checker**: `mypy`.
|
|
14
|
+
* **Git Hooks**: `pre-commit` (configured for Ruff, Mypy, and Conventional Commits).
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Core Architecture
|
|
19
|
+
|
|
20
|
+
### 1. Account System (`empire_core.accounts`)
|
|
21
|
+
The entry point for all automation.
|
|
22
|
+
* **`AccountRegistry` (`accounts`)**: Singleton that loads credentials from `accounts.json`.
|
|
23
|
+
* **`Account`**: Represents a game account. Use `account.get_client()` to start.
|
|
24
|
+
|
|
25
|
+
### 2. The Client (`empire_core.client`)
|
|
26
|
+
* **Composition over Inheritance**: Features are exposed via composed services.
|
|
27
|
+
* `client.quests`, `client.reports`, `client.alliance`, `client.chat`, `client.defense`.
|
|
28
|
+
|
|
29
|
+
### 3. State Management (`empire_core.state`)
|
|
30
|
+
* **`GameState`**: The source of truth. Updated automatically by incoming packets.
|
|
31
|
+
* **Models**: Pydantic v2 models for type safety.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Development Guidelines
|
|
36
|
+
|
|
37
|
+
1. **Conventional Commits**: All commits must follow the `feat:`, `fix:`, `refactor:` pattern.
|
|
38
|
+
2. **Type Safety**: `mypy` must pass with zero errors. Always use type hints.
|
|
39
|
+
3. **No God Objects**: Keep `EmpireClient` lean. Add logic to Services or Managers.
|
|
40
|
+
4. **CLI first**: New high-level status or diagnostic features should be added to `cli.py`.
|
|
41
|
+
|
|
42
|
+
## Essential Commands
|
|
43
|
+
```bash
|
|
44
|
+
uv sync --extra dev # Sync all dependencies
|
|
45
|
+
uv run empire status # CLI check
|
|
46
|
+
uv run pytest # Run tests
|
|
47
|
+
uv run pre-commit run --all-files # Final check before commit
|
|
48
|
+
```
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: empire-core
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Asynchronous Python framework for Goodgame Empire
|
|
5
|
+
Project-URL: Repository, https://github.com/eschnitzler/EmpireCore
|
|
6
|
+
Author-email: E Joseph <east1499@gmail.com>
|
|
7
|
+
License: MIT
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
|
+
Requires-Dist: aiohttp>=3.9
|
|
10
|
+
Requires-Dist: aiosqlite>=0.19.0
|
|
11
|
+
Requires-Dist: pydantic>=2.5
|
|
12
|
+
Requires-Dist: python-dotenv>=1.0
|
|
13
|
+
Requires-Dist: sqlmodel>=0.0.14
|
|
14
|
+
Requires-Dist: tabulate>=0.9.0
|
|
15
|
+
Requires-Dist: tqdm>=4.66.0
|
|
16
|
+
Requires-Dist: typer>=0.9.0
|
|
17
|
+
Provides-Extra: dev
|
|
18
|
+
Requires-Dist: mypy>=1.8; extra == 'dev'
|
|
19
|
+
Requires-Dist: pre-commit>=3.5.0; extra == 'dev'
|
|
20
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
21
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
22
|
+
Requires-Dist: python-semantic-release>=9.0.0; extra == 'dev'
|
|
23
|
+
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
|
24
|
+
Requires-Dist: sqlalchemy[mypy]; extra == 'dev'
|
|
25
|
+
Requires-Dist: types-tabulate; extra == 'dev'
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
<p align="center">
|
|
29
|
+
<img src="https://img.shields.io/badge/python-3.10+-blue.svg" alt="Python 3.10+">
|
|
30
|
+
<img src="https://img.shields.io/badge/asyncio-powered-green.svg" alt="Asyncio">
|
|
31
|
+
<img src="https://img.shields.io/badge/pydantic-v2-purple.svg" alt="Pydantic v2">
|
|
32
|
+
<img src="https://img.shields.io/badge/tool-uv-orange.svg" alt="UV">
|
|
33
|
+
<img src="https://img.shields.io/badge/status-WIP-red.svg" alt="Work in Progress">
|
|
34
|
+
</p>
|
|
35
|
+
|
|
36
|
+
<h1 align="center">EmpireCore</h1>
|
|
37
|
+
|
|
38
|
+
<p align="center">
|
|
39
|
+
<strong>Modern async Python library for Goodgame Empire automation</strong>
|
|
40
|
+
</p>
|
|
41
|
+
|
|
42
|
+
<p align="center">
|
|
43
|
+
<a href="#features">Features</a> •
|
|
44
|
+
<a href="#installation">Installation</a> •
|
|
45
|
+
<a href="#quick-start">Quick Start</a> •
|
|
46
|
+
<a href="#examples">Examples</a> •
|
|
47
|
+
<a href="#documentation">Documentation</a>
|
|
48
|
+
</p>
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
> **⚠️ Work in Progress**
|
|
53
|
+
>
|
|
54
|
+
> This library is under active development. APIs may change, and some features are incomplete or untested. Use at your own risk.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Features
|
|
59
|
+
|
|
60
|
+
| Category | Capabilities |
|
|
61
|
+
|----------|-------------|
|
|
62
|
+
| **Connection** | WebSocket, auto-reconnect, login cooldown handling |
|
|
63
|
+
| **State Tracking** | Player, castles, resources, buildings, units, movements |
|
|
64
|
+
| **Actions** | Attacks, transports, recruiting, building, with response validation |
|
|
65
|
+
| **Automation** | Task loops, multi-account, target finder, map scanner |
|
|
66
|
+
| **CLI** | Account status, login testing, state summary |
|
|
67
|
+
|
|
68
|
+
## Installation
|
|
69
|
+
|
|
70
|
+
This project uses [uv](https://github.com/astral-sh/uv) for blazing-fast dependency management.
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
git clone https://github.com/eschnitzler/EmpireCore.git
|
|
74
|
+
cd EmpireCore
|
|
75
|
+
|
|
76
|
+
# Install dependencies and create venv automatically
|
|
77
|
+
uv sync
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Traditional Installation (Pip)
|
|
81
|
+
```bash
|
|
82
|
+
python3 -m venv .venv
|
|
83
|
+
source .venv/bin/activate
|
|
84
|
+
pip install .
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Configuration
|
|
88
|
+
|
|
89
|
+
Create an `accounts.json` file in the root directory. You can use the provided template:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
cp accounts.json.template accounts.json
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Then edit `accounts.json` with your credentials. This file is git-ignored to keep your credentials safe.
|
|
96
|
+
|
|
97
|
+
## Quick Start
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
import asyncio
|
|
101
|
+
from empire_core import accounts
|
|
102
|
+
|
|
103
|
+
async def main():
|
|
104
|
+
# Load default account from accounts.json
|
|
105
|
+
account = accounts.get_default()
|
|
106
|
+
if not account:
|
|
107
|
+
print("Please configure accounts.json first!")
|
|
108
|
+
return
|
|
109
|
+
|
|
110
|
+
# Create client directly from account object
|
|
111
|
+
client = account.get_client()
|
|
112
|
+
|
|
113
|
+
await client.login()
|
|
114
|
+
await client.get_detailed_castle_info()
|
|
115
|
+
|
|
116
|
+
player = client.state.local_player
|
|
117
|
+
print(f"{player.name} | Level {player.level} | {player.gold} gold")
|
|
118
|
+
|
|
119
|
+
await client.close()
|
|
120
|
+
|
|
121
|
+
asyncio.run(main())
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## CLI Tool
|
|
125
|
+
|
|
126
|
+
The library includes a CLI for quick operations:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
# Check configured accounts
|
|
130
|
+
uv run empire status
|
|
131
|
+
|
|
132
|
+
# Test login and show player stats
|
|
133
|
+
uv run empire login
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Running Examples & Tests
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
# Run the demo
|
|
140
|
+
uv run examples/demo.py
|
|
141
|
+
|
|
142
|
+
# Run unit tests
|
|
143
|
+
uv run pytest
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Development
|
|
147
|
+
|
|
148
|
+
We use `ruff` for linting and `mypy` for type checking.
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
# Setup pre-commit hooks
|
|
152
|
+
uv run pre-commit install
|
|
153
|
+
|
|
154
|
+
# Run all checks manually
|
|
155
|
+
uv run pre-commit run --all-files
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
<p align="center">
|
|
161
|
+
<sub>For educational purposes only. Use responsibly.</sub>
|
|
162
|
+
</p>
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://img.shields.io/badge/python-3.10+-blue.svg" alt="Python 3.10+">
|
|
3
|
+
<img src="https://img.shields.io/badge/asyncio-powered-green.svg" alt="Asyncio">
|
|
4
|
+
<img src="https://img.shields.io/badge/pydantic-v2-purple.svg" alt="Pydantic v2">
|
|
5
|
+
<img src="https://img.shields.io/badge/tool-uv-orange.svg" alt="UV">
|
|
6
|
+
<img src="https://img.shields.io/badge/status-WIP-red.svg" alt="Work in Progress">
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
<h1 align="center">EmpireCore</h1>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<strong>Modern async Python library for Goodgame Empire automation</strong>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
<p align="center">
|
|
16
|
+
<a href="#features">Features</a> •
|
|
17
|
+
<a href="#installation">Installation</a> •
|
|
18
|
+
<a href="#quick-start">Quick Start</a> •
|
|
19
|
+
<a href="#examples">Examples</a> •
|
|
20
|
+
<a href="#documentation">Documentation</a>
|
|
21
|
+
</p>
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
> **⚠️ Work in Progress**
|
|
26
|
+
>
|
|
27
|
+
> This library is under active development. APIs may change, and some features are incomplete or untested. Use at your own risk.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Features
|
|
32
|
+
|
|
33
|
+
| Category | Capabilities |
|
|
34
|
+
|----------|-------------|
|
|
35
|
+
| **Connection** | WebSocket, auto-reconnect, login cooldown handling |
|
|
36
|
+
| **State Tracking** | Player, castles, resources, buildings, units, movements |
|
|
37
|
+
| **Actions** | Attacks, transports, recruiting, building, with response validation |
|
|
38
|
+
| **Automation** | Task loops, multi-account, target finder, map scanner |
|
|
39
|
+
| **CLI** | Account status, login testing, state summary |
|
|
40
|
+
|
|
41
|
+
## Installation
|
|
42
|
+
|
|
43
|
+
This project uses [uv](https://github.com/astral-sh/uv) for blazing-fast dependency management.
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
git clone https://github.com/eschnitzler/EmpireCore.git
|
|
47
|
+
cd EmpireCore
|
|
48
|
+
|
|
49
|
+
# Install dependencies and create venv automatically
|
|
50
|
+
uv sync
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Traditional Installation (Pip)
|
|
54
|
+
```bash
|
|
55
|
+
python3 -m venv .venv
|
|
56
|
+
source .venv/bin/activate
|
|
57
|
+
pip install .
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Configuration
|
|
61
|
+
|
|
62
|
+
Create an `accounts.json` file in the root directory. You can use the provided template:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
cp accounts.json.template accounts.json
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Then edit `accounts.json` with your credentials. This file is git-ignored to keep your credentials safe.
|
|
69
|
+
|
|
70
|
+
## Quick Start
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
import asyncio
|
|
74
|
+
from empire_core import accounts
|
|
75
|
+
|
|
76
|
+
async def main():
|
|
77
|
+
# Load default account from accounts.json
|
|
78
|
+
account = accounts.get_default()
|
|
79
|
+
if not account:
|
|
80
|
+
print("Please configure accounts.json first!")
|
|
81
|
+
return
|
|
82
|
+
|
|
83
|
+
# Create client directly from account object
|
|
84
|
+
client = account.get_client()
|
|
85
|
+
|
|
86
|
+
await client.login()
|
|
87
|
+
await client.get_detailed_castle_info()
|
|
88
|
+
|
|
89
|
+
player = client.state.local_player
|
|
90
|
+
print(f"{player.name} | Level {player.level} | {player.gold} gold")
|
|
91
|
+
|
|
92
|
+
await client.close()
|
|
93
|
+
|
|
94
|
+
asyncio.run(main())
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## CLI Tool
|
|
98
|
+
|
|
99
|
+
The library includes a CLI for quick operations:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
# Check configured accounts
|
|
103
|
+
uv run empire status
|
|
104
|
+
|
|
105
|
+
# Test login and show player stats
|
|
106
|
+
uv run empire login
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Running Examples & Tests
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
# Run the demo
|
|
113
|
+
uv run examples/demo.py
|
|
114
|
+
|
|
115
|
+
# Run unit tests
|
|
116
|
+
uv run pytest
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Development
|
|
120
|
+
|
|
121
|
+
We use `ruff` for linting and `mypy` for type checking.
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
# Setup pre-commit hooks
|
|
125
|
+
uv run pre-commit install
|
|
126
|
+
|
|
127
|
+
# Run all checks manually
|
|
128
|
+
uv run pre-commit run --all-files
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
<p align="center">
|
|
134
|
+
<sub>For educational purposes only. Use responsibly.</sub>
|
|
135
|
+
</p>
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# EmpireCore Status
|
|
2
|
+
|
|
3
|
+
## Current Status: PRODUCTION READY 🚀
|
|
4
|
+
|
|
5
|
+
The core API, state management, and modern toolchain are implemented and verified.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## What's Working
|
|
10
|
+
|
|
11
|
+
### 1. Modern Toolchain (NEW)
|
|
12
|
+
- [x] `uv` for dependency management & lightning-fast builds
|
|
13
|
+
- [x] PEP 621 compliant `pyproject.toml`
|
|
14
|
+
- [x] `ruff` for ultra-fast linting and formatting
|
|
15
|
+
- [x] `mypy` for 100% type safety in the core library
|
|
16
|
+
- [x] `pre-commit` hooks for automatic quality checks
|
|
17
|
+
- [x] CLI Tool (`uv run empire`) for account & login management
|
|
18
|
+
|
|
19
|
+
### 2. Login & Authentication
|
|
20
|
+
- [x] Robust `AccountRegistry` supporting `accounts.json`
|
|
21
|
+
- [x] `Account` objects as primary entry points (`account.get_client()`)
|
|
22
|
+
- [x] WebSocket handshake and XT authentication
|
|
23
|
+
- [x] Login cooldown (Error 453) detection & handling
|
|
24
|
+
|
|
25
|
+
### 3. State Tracking & Services
|
|
26
|
+
- [x] Service-based composition (`client.quests`, `client.reports`, etc.)
|
|
27
|
+
- [x] Real-time state updates from SFS packets
|
|
28
|
+
- [x] Comprehensive Pydantic models for Players, Castles, and World objects
|
|
29
|
+
- [x] Real-time movement tracking and arrival events
|
|
30
|
+
|
|
31
|
+
### 4. Game Actions
|
|
32
|
+
- [x] Attacks, scouts, and transports
|
|
33
|
+
- [x] Building upgrades and unit recruitment
|
|
34
|
+
- [x] Tax collection and item usage
|
|
35
|
+
- [x] Private and alliance chat messaging
|
|
36
|
+
|
|
37
|
+
### 5. Automation Framework
|
|
38
|
+
- [x] `tasks.loop` decorator (discord.py style)
|
|
39
|
+
- [x] `MapScanner` for spiral exploration
|
|
40
|
+
- [x] `BuildingManager` with priority queues
|
|
41
|
+
- [x] `MultiAccountManager` for multi-session operations
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Project Structure
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
empire_core/
|
|
49
|
+
├── accounts.py # AccountRegistry and Account models
|
|
50
|
+
├── cli.py # Click/Typer CLI implementation
|
|
51
|
+
├── client/ # Client and Service logic
|
|
52
|
+
├── state/ # Game state and Pydantic models
|
|
53
|
+
├── automation/ # Background tasks and managers
|
|
54
|
+
└── network/ # SFS protocol and WebSocket handling
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
**Last Updated:** December 21, 2025
|