How vcmi/vcmi works
• Engine Core / Library: This central “lib” directory and its submodules contain core game logic, domain models (game state, battle mechanics, map management), file/resource handling, and support for modding and scripting. Also note the “vcmi” include files.
• Client Components: All directories under “client” (plus “clientapp” and “vcmiqt”) comprise the graphical user interface, rendering (SDL-based rendering and other GUI modules), input handling, and audio/video media. Modules under “client/battle”, “client/mapView” and “client/gui” show that the client is split into various subdomains (battle, adventure map, lobby, etc.).
• Server Components: Directories like “server”, “serverapp” and “lobby” contain logic for turn-based processing, networking (queries, NetPacks, processors), and multiplayer state management.
• AI Modules: There are several AI directories (e.g. AI/BattleAI, AI/Nullkiller, AI/StupidAI, AI/VCAI) that encapsulate different strategies and evaluation algorithms. They interact with the engine core to compute game decisions.
• Scripting/Modding and Tools: The “scripting” folders (both for ERM and Lua) provide extensibility points so that behaviors can be injected or modified dynamically. The “mapeditor” and “launcher” directories are separate tools that leverage the engine libraries and graphical interface components.
• Build and Infrastructure: The project is built using CMake scripts, with additional support from Conan, CI/CD configurations, and platform-specific directories (android, ios, osx, win, xcode). Although these are mostly for infrastructure, they are important for showing how the components are built and deployed.
Relationships and Interactions Between Components
• The Engine Core acts as a shared library that both Client and Server depend on. This core contains game state management (battle, map, campaign), resource management, file I/O, and core game rules.
• The AI modules integrate with the Engine Core by reading game state and proposing moves/decisions. They form a plug‐in layer where multiple AI strategies can be swapped in.
• Scripting/Modding modules (Lua and ERM) extend the Engine Core, exposing APIs for game objects, events, and spells. These components allow modders to add new functionality without changing the core C++ code.
• Tools like the Launcher and Map Editor depend upon Engine and UI libraries, serving as separate applications that still leverage the same codebase.
• The build system (CMake, Conan, etc.) supports cross-platform compilation and module integration; for documentation, you may show these as auxiliary support systems.
Architectural Patterns and Design Principles
• Modularization and Separation of Concerns: The project clearly separates game logic (engine), presentation (client UI), networking (server and lobby), and supplementary services (AI, scripting). Each major folder namespace is dedicated to a specific layer.
• Client-Server Architecture: The multiplayer capabilities are segregated with clear client-side and server-side implementations that communicate via network protocols and “NetPack” messages.
• Plugin/Extension Patterns: The scripting system and modding framework are designed to expose interfaces (via Lua, ERM) that hook into the engine’s functionalities.
• Cross-platform Build Infrastructure: Emphasis on using CMake and various platform-specific folders under android, ios, osx, etc., highlight a design that isolates platform dependencies.