Skip to main content

Fully typed Python API for Goodgame Empire

Project description

Python 3.10+ Pydantic v2 UV Work in Progress

EmpireCore

Fully typed Python library for Goodgame Empire

FeaturesInstallationQuick StartServicesContributing


Warning: Work in Progress

This library is under active development. APIs may change, and some features are incomplete or untested.


Features

Category Description
Connection WebSocket with background threads, auto-reconnect, keepalive
Protocol Models Pydantic models for all GGE commands with type-safe request/response handling
Services High-level APIs for alliance, castle, and more - auto-attached to client
State Tracking Player, castles, resources, movements

Installation

# Using uv (recommended)
uv add empire-core

# Or with pip
pip install empire-core

For development:

git clone https://github.com/eschnitzler/EmpireCore.git
cd EmpireCore
uv sync

Quick Start

from empire_core import EmpireClient

client = EmpireClient(username="your_user", password="your_pass")
client.login()

# Services are auto-attached to the client
client.alliance.send_chat("Hello alliance!")
client.alliance.help_all()

castles = client.castle.get_all()
for c in castles:
    print(f"{c.castle_name} at ({c.x}, {c.y})")

client.close()

Services

Services provide high-level APIs and are automatically attached to the client.

AllianceService (client.alliance)

# Send chat message
client.alliance.send_chat("Hello!")

# Get chat history
history = client.alliance.get_chat_log()
for entry in history:
    print(f"{entry.player_name}: {entry.decoded_text}")

# Help all members
response = client.alliance.help_all()
print(f"Helped {response.helped_count} members")

# Subscribe to incoming messages
def on_message(msg):
    print(f"[{msg.player_name}] {msg.decoded_text}")

client.alliance.on_chat_message(on_message)

CastleService (client.castle)

# Get all castles
castles = client.castle.get_all()

# Get detailed info
details = client.castle.get_details(castle_id=12345)
print(f"Buildings: {len(details.buildings)}")

# Select a castle
client.castle.select(castle_id=12345)

# Get resources
resources = client.castle.get_resources(castle_id=12345)
print(f"Wood: {resources.wood}, Stone: {resources.stone}")

Protocol Models

For lower-level access, use protocol models directly:

from empire_core.protocol.models import (
    AllianceChatMessageRequest,
    GetCastlesRequest,
    parse_response,
)

# Build a request
request = AllianceChatMessageRequest.create("Hello 100%!")
packet = request.to_packet()
# -> "%xt%EmpireEx_21%acm%1%{"M": "Hello 100%!"}%"

# Send via client
client.send(request)

# Or wait for response
response = client.send(GetCastlesRequest(), wait=True)

Contributing

See CONTRIBUTING.md for:

  • Adding new protocol commands
  • Creating new services
  • Protocol model conventions
  • Testing guidelines

Architecture

empire_core/
├── client/          # EmpireClient - main entry point
├── protocol/
│   └── models/      # Pydantic models for GGE commands
├── services/        # High-level service APIs
├── state/           # Game state models
└── network/         # WebSocket connection

For educational purposes only. Use responsibly.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

empire_core-0.14.0.tar.gz (268.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

empire_core-0.14.0-py3-none-any.whl (118.5 kB view details)

Uploaded Python 3

File details

Details for the file empire_core-0.14.0.tar.gz.

File metadata

  • Download URL: empire_core-0.14.0.tar.gz
  • Upload date:
  • Size: 268.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for empire_core-0.14.0.tar.gz
Algorithm Hash digest
SHA256 6fbcb9a6115fa4730ac2cf0ce707bbac62b5cc088eacfc47ded46a5df6b9b589
MD5 682cd0c8113282c36455c376588fd8c1
BLAKE2b-256 c2b1bbee5b08be8e9c2dd25c3aa88ea1df7e51ae29d516c391e52c3377962803

See more details on using hashes here.

Provenance

The following attestation bundles were made for empire_core-0.14.0.tar.gz:

Publisher: publish.yml on eschnitzler/EmpireCore

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file empire_core-0.14.0-py3-none-any.whl.

File metadata

  • Download URL: empire_core-0.14.0-py3-none-any.whl
  • Upload date:
  • Size: 118.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for empire_core-0.14.0-py3-none-any.whl
Algorithm Hash digest
SHA256 57c87fe9ca341f20cfd4c62d3e49e1e34772fdc98e48b8a1ff8334dbc596ff39
MD5 36772dcf470dfe7507adf20849879470
BLAKE2b-256 7f19fc0d6e19ba1b05f0162240d41ebb016799a210a91b234a6d1172c4a77cb7

See more details on using hashes here.

Provenance

The following attestation bundles were made for empire_core-0.14.0-py3-none-any.whl:

Publisher: publish.yml on eschnitzler/EmpireCore

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page