Some checks failed
Release / release (push) Has been cancelled
Full-stack dashboard for controlling, automating, and analyzing Artifacts MMO characters via the game's HTTP API. Backend (FastAPI): - Async Artifacts API client with rate limiting and retry - 6 automation strategies (combat, gathering, crafting, trading, task, leveling) - Automation engine with runner, manager, cooldown tracker, pathfinder - WebSocket relay (game server -> frontend) - Game data cache, character snapshots, price history, analytics - 9 API routers, 7 database tables, 3 Alembic migrations - 108 unit tests Frontend (Next.js 15 + shadcn/ui): - Live character dashboard with HP/XP bars and cooldowns - Character detail with stats, equipment, inventory, skills, manual actions - Automation management with live log streaming - Interactive canvas map with content-type coloring and zoom/pan - Bank management, Grand Exchange with price charts - Events, logs, analytics pages with Recharts - WebSocket auto-reconnect with query cache invalidation - Settings page, error boundaries, dark theme Infrastructure: - Docker Compose (dev + prod) - GitHub Actions CI/CD - Documentation (Architecture, Automation, Deployment, API)
45 lines
1.4 KiB
Python
45 lines
1.4 KiB
Python
import logging
|
|
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from app.models.character_snapshot import CharacterSnapshot
|
|
from app.schemas.game import CharacterSchema
|
|
from app.services.artifacts_client import ArtifactsClient
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class CharacterService:
|
|
"""High-level service for character data and snapshot management."""
|
|
|
|
async def get_all(self, client: ArtifactsClient) -> list[CharacterSchema]:
|
|
"""Return all characters belonging to the authenticated account."""
|
|
return await client.get_characters()
|
|
|
|
async def get_one(self, client: ArtifactsClient, name: str) -> CharacterSchema:
|
|
"""Return a single character by name."""
|
|
return await client.get_character(name)
|
|
|
|
async def take_snapshot(
|
|
self,
|
|
db: AsyncSession,
|
|
client: ArtifactsClient,
|
|
) -> list[CharacterSnapshot]:
|
|
"""Fetch current character states and persist snapshots.
|
|
|
|
Returns the list of newly created snapshot rows.
|
|
"""
|
|
characters = await client.get_characters()
|
|
snapshots: list[CharacterSnapshot] = []
|
|
|
|
for char in characters:
|
|
snapshot = CharacterSnapshot(
|
|
name=char.name,
|
|
data=char.model_dump(mode="json"),
|
|
)
|
|
db.add(snapshot)
|
|
snapshots.append(snapshot)
|
|
|
|
await db.commit()
|
|
logger.info("Saved %d character snapshots", len(snapshots))
|
|
return snapshots
|