How melledy/lunarcore works
Main Components
a. Network & Communication Layer:
• The “server/packet” packages (both recv and send) and the “server/game” packages show the implementation of network message parsing, routing, and KCP listener networking.
• The Fiddler integration (documented in the README) indicates that there’s an HTTP tunable part for redirecting client connections locally.
b. Game Logic & Command Processing:
• The “game” package covers many subsystems such as account management, battle and challenge logic, chat, inventory and player management.
• The “command” package (with commands like /account, /avatar, /heal, etc.) implements an in-game command system, likely using a command pattern.
c. Data & Resource Management:
• The “data” package (including both generated proto files and custom/excel data readers under “data/excel”) manages configuration, game resources, and runtime game data.
• The “data/config” and “data/custom” directories indicate a rich configuration backbone.
d. Persistence & Database:
• The “database” package contains classes for connecting to an internal MongoDB instance as well as managing data storage separately.
e. HTTP Server Interface:
• The “server/http” package contains HTTP handlers that support various endpoints (e.g., token login, status checking, etc.).
f. Plugin Architecture:
• The “plugin” package offers an extensibility point so new game features or modifications can be introduced without affecting the core logic.
g. Utilities:
• The “util” packages support ancillary actions such as file handling, cryptography, and logging integration.
Relationships and Data Flows
• Client interactions (both the game client and HTTP-based calls) are initially handled by the Network Listener (KCP Listener and HTTP Server).
• Incoming packets are processed by the Packet Dispatcher (based on “server/packet/recv”) which extracts commands/requests.
• Commands are channeled into the Command Manager and further dispatched to the Game Logic modules.
• Game Logic components (spanning account, battle, inventory, gacha, chat, etc.) coordinate with the Data & Resource Management modules to load and update game state.
• Persistence is abstracted via database interfaces (in the “database” package) to read/write persistent player data.
• External configuration files (downloaded and placed in the “resources” folder) are loaded at startup via resource loaders.
• Internal dependencies like Utility functions and Plugin management overlay support common mechanisms across tiers.
Architectural Patterns and Design Principles
• Modularity is evident: separate packages for network, game logic, data loading, and utilities suggest good separation of concerns.
• Command pattern in the Command packages supports loosely coupled game commands.
• A layered architecture is in use: Presentation (network interface) → Application/Command processing → Domain (game logic) → Data/Persistence.