How franciscolh04/projeto-rc works
Project Type and Purpose
• This is a networked, console-based Mastermind game written in C, with a clear client–server split.
• The server (“GS.c” & friends) runs the game logic and manages player state; the client (“communication.c” & “player.c”) handles user I/O and communicates with the server.
• A small common library (“verifications.c”) is shared for input validation.
File Structure
Top-level:
• Makefile – build orchestration
• README.md – (minimal) grading info
src/
• client/
– communication.c/.h → socket I/O, message framing
– player.c/.h → user input loop, result display
• common/
– verifications.c/.h → shared checks (e.g. valid guess format)
• server/
– GS.c/.h → game server main, listener loop
– command_handler.c/.h → parsing incoming commands, routing
– game.c/.h → central game-state machine, turn logic
– state.c/.h → in-memory model of players, guesses, results
– mastermind.c → core algorithm (compare guess vs. solution)
Extract Architectural Patterns and Components
a. Client–Server architecture (request→response over TCP/UDP sockets)
b. Modular layering on the server:
– Listener & dispatcher (GS)
– Command parser & router
– Game engine (game + mastermind)
– State repository
c. Shared validation logic in a separate module (DRY principle).
• Components:
1. Client Module
• Player Interface (player.c)
• Communication Layer (communication.c)
2. Network Layer
• Socket channel (TCP)
3. Server Module
• GS (listener & connection manager)
• Command Handler
• Game Engine
– Mastermind Algorithm
– Game Logic
• State Store
4. Common Library
• Verifications (shared between client & server builds)
5. Build System (Makefile)
• Interactions:
• Player Interface → Communication Layer → Network → GS
• GS → Command Handler → Game Engine → State Store → Command Handler → GS → Network → Client
• Both client and server link against the Common Library for input/command verifications.
Call-outs for Key Technologies & Patterns
• C language, POSIX sockets
• Makefile build targets (e.g., “client”, “server”, “common”)
• Modular layering on the server: separation of concerns (listener, parsing, logic, state)
• Client event loop vs. server multi–client handling (if any threading or select/poll is used)