# Client Documentation ## Overview The **Smart Client** provides the user interface and interacts with the server coordinator using a request/response pattern. **Key Responsibilities:** - User interface for all game systems - Request/response communication with server - Local state caching and optimization - Fog of War rendering and management ## Architecture ### Smart Client Pattern From `architecture-technique.md`: - **No Streaming**: Pure request/response communication - **Stateless Requests**: Each request is independent - **Local Caching**: Client-side optimization for responsiveness - **FOW Integration**: Chunk-level fog of war rendering ### User Interface Systems #### Multi-Scale Interface From `map-system.md`: - **World View**: Diplomatic and strategic overview - **Regional View**: Logistics and major operations coordination - **Local View**: Factory management and base operations - **Detail View**: Combat oversight and precise control #### Factory Management Interface From `gameplay-industriel.md`: - **Production Line Design**: Factorio-like belt and assembler placement - **Resource Flow Visualization**: Real-time production monitoring - **Optimization Tools**: Bottleneck identification and efficiency metrics - **Automation Controls**: Production scheduling and priority management #### Vehicle Design Interface From `systeme-militaire.md`: - **Grid-Based Placement**: Component positioning on vehicle chassis - **Interface Controls**: Pick/place with A/E rotation, R for snap toggle - **Template System**: Save/load vehicle blueprints - **Validation Feedback**: Real-time design constraint checking #### Military Command Interface - **Frontline Visualization**: Persistent battle line display - **Auto-Battler Controls**: Strategic oversight without micro-management - **Intelligence Dashboard**: Reconnaissance and enemy analysis - **Strategic Planning**: Operation coordination and resource allocation ## Core Client Systems ### Communication Manager ```cpp class ClientCommunication { // Server communication ServerResponse sendRequest(const ClientRequest& request); void cacheResponse(const ServerResponse& response); bool hasValidCache(const RequestKey& key) const; // FOW management void updateFOW(const FOWData& data); bool isVisible(int chunkX, int chunkY) const; void requestChunkData(int chunkX, int chunkY); // State synchronization void synchronizeState(); void handleGlobalEvent(const GlobalEvent& event); }; ``` ### Interface Controllers #### Factory Interface - **Belt Placement**: Drag-and-drop belt network design - **Assembler Configuration**: Production recipe and priority settings - **Resource Monitoring**: Real-time throughput and efficiency display - **Expansion Planning**: Factory layout optimization tools #### Design Interface - **Component Library**: Available vehicle components and specifications - **Chassis Editor**: Irregular shape design and component placement - **Performance Calculator**: Real-time design statistics and validation - **Blueprint Manager**: Template save/load and sharing system #### Strategic Interface - **Company Dashboard**: Economic, military, and industrial overviews - **Diplomatic Panel**: Inter-company relations and negotiations - **Research Tree**: Technology progression and breakthrough system - **Analytics Dashboard**: Comprehensive metrics and trend analysis ### Performance Optimization #### Local Caching - **Response Caching**: Store frequently accessed data locally - **Predictive Loading**: Pre-fetch likely needed data - **Cache Invalidation**: Smart cache updates on state changes - **Compression**: Minimize bandwidth usage #### Rendering Optimization - **LOD System**: Level-of-detail based on zoom and relevance - **Culling**: Only render visible and relevant elements - **Chunk Streaming**: Dynamic loading of map data - **UI Responsiveness**: Maintain 60fps interface performance ## Client Request Patterns ### Common Request Types 1. **State Queries**: Get current system state (factory status, battles, etc.) 2. **Action Commands**: Execute player actions (place building, issue orders) 3. **Data Updates**: Refresh cached information (market prices, research progress) 4. **Event Subscriptions**: Register for relevant global events ### FOW-Aware Requests - **Visibility Checks**: Ensure requested data is visible to player - **Partial Information**: Handle incomplete data due to FOW - **Intelligence Requests**: Request reconnaissance on hidden areas - **Update Notifications**: Receive visibility changes and new intel ## Key Design Documents - `architecture-technique.md` - Smart Client specification - `gameplay-industriel.md` - Factory interface requirements - `systeme-militaire.md` - Vehicle design and combat interfaces - `map-system.md` - Multi-scale interface coordination - `mecaniques-jeu.md` - UI integration with game mechanics ## Implementation Notes - Request/response pattern eliminates complex state synchronization - Local caching provides responsive user experience - FOW integration requires careful visibility checking - Multi-scale interface demands efficient view switching