$ show Shadowss/TravianZ
TravianZ is a self-hosted multiplayer browser strategy game server, a clone of the popular Travian game. It implements the complete game loop: village building, resource production, troop training, combat, hero system (T4), alliance management with bonuses, market trading, world wonders, and an admin panel for server management. The architecture is a PHP 8.3+/MySQL monolith with procedural entry points and class-based game logic. Key systems include a trait-based database layer (Database.php split into domain-specific traits), a cron-like automation engine (Automation.php split into traits), and a templating system using .tpl files. Features include support for 9 tribes, multi-language (English, French, Italian, Romanian, Chinese), Docker deployment, and an admin panel with CSRF protection and logging. The codebase has undergone significant refactoring from an older codebase, but still retains global state, mixed SQL access patterns (prepared statements alongside raw queries), and legacy JavaScript (MooTools). It is actively maintained with documented bug fixes and performance optimizations.
The LLM identified 4 files worth highlighting for reuse:
A static utility class that sorts a multidimensional array by multiple keys using a flexible syntax. Pure PHP, no dependencies, easily extractable for any project needing multi-key array sorting.
A set of functions for CSRF token generation, field rendering, verification, and a styled denial page. Self-contained and used inconsistently across admin mods, but the API is clean and standalone.
A class that resolves the real client IP from request headers with configurable trusted proxies and forwarded header support. Provides IP ban checking. The IP resolution logic is reusable as a standalone component.
A session-backed form helper that stores previous input values and error messages. Provides methods to get/set values and errors. Could be extracted for any PHP session-based form workflow.