Files
dune-dashboard/backend/app/services/world.py
T
Reditus be845f76f1 feat: complete React + Flask rebuild of dashboard
Backend:
- New Flask 3 app with service-layer architecture
- Pydantic v2 models and unified API response format
- psycopg3 connection pool with stored procedure support
- 14 services: DB, SSH, K8s, BGD, RMQ (admin + game), realtime, player, economy, guild, world, progression, character, audit, chat
- 30+ API endpoints covering players, guilds, economy, world, admin, server, files, director, chat
- SSE real-time events for battlegroup, chat, metrics, connection status
- SocketIO remote shell (xterm.js compatible)
- Settings CRUD, moderation (ban/kick/unban), audit logging
- Security: CSRF, rate limiting, CSP, HSTS, read-only SQL enforcement

Frontend:
- Vite + React 18 + TypeScript + Tailwind CSS
- 14 Dune house themes via CSS custom properties
- SWR for server state, Axios API client with interceptors
- 14 pages: Overview, Player Explorer + Detail, Guild Manager, Vehicles, Buildings, Map Viewer, Accounts, Server Control, Admin Tools (7 tabs), Chat Monitor, Remote Shell, File Browser, Director, Settings
- Player Detail with 6 tabs: overview, inventory, vehicles, buildings, progression, actions
- Admin Tools: broadcast, economy, world, character, functions, raw query, audit log
- Interactive canvas map viewer with zoom/pan/filter
- Toast notifications, connection badges, theme switcher

Other:
- Updated .gitignore for frontend/backend structure
- Updated README with new architecture, development guide, and project structure
- Legacy app/ templates/ static/ remain untouched
2026-05-23 07:08:30 +01:00

36 lines
1.3 KiB
Python

# World service — partitions, spice, teleport.
import logging
from app.models import PartitionInfo
from app.services.database import DatabaseService
logger = logging.getLogger(__name__)
class WorldService:
def __init__(self, db: DatabaseService):
self.db = db
def get_partitions(self, map_name: str = "") -> list[PartitionInfo]:
rows = self.db.call_function("get_partitions", [map_name])
return [PartitionInfo(
id=r.get("partition_id", 0),
map=r.get("map", ""),
dimension_index=r.get("dimension_index", 0),
label=r.get("label", ""),
definition=str(r.get("partition_definition", "")),
) for r in rows]
def teleport(self, fls_id: str, partition_id: int, x: float, y: float, z: float) -> bool:
self.db.call_procedure("admin_move_offline_player_to_partition", [fls_id, partition_id, (x, y, z)])
return True
def reset_spice(self, map_name: str, dimension_index: int) -> bool:
self.db.call_procedure("reset_global_spice_field_state", [map_name, dimension_index])
return True
def force_spice_spawn(self, server_id: str, spicefield_type_id: int) -> bool:
self.db.call_procedure("try_spawn_spicefield", [server_id, spicefield_type_id])
return True