How eduardoapaiva/trabalhoredes works
Batalha Naval is a TCP client/server game for simultaneous two-player matches. Players connect, are paired by the server, place ships, take turns firing, and receive updated boards and win/loss results. The server also handles reconnect-to-match requests and disconnect cleanup. The map separates client interaction, server orchestration, game rules and state, and terminal rendering. Some server and game-rule code is excerpted only partially; README-documented capabilities are shown where their exact internal calls are not visible.
Main entry points: server.c Server runtime · struct_jogo.c Match registry · terminal.c Terminal views · funcoes.c Turn and combat
Components 14
Client interaction
- Client app
client.c
Server orchestration
- Server runtime
server.c - Matchmaking
server.c - Client registry
src/struct_cliente.c - Match registry
src/struct_jogo.c
Game domain
- Player state
includes/struct_cliente.h - Match state
includes/struct_jogo.h - Board setup
src/funcoes.c - Ship placement
src/funcoes.c - Turn and combat
src/funcoes.c - Game configuration
includes/consts.h
Game presentation
- Terminal views
src/terminal.c - Board formatting
src/funcoes.c
Other components
- Players
Connections 19
- Players → Client app: enter commands
README.md - Client app → Server runtime: exchange TCP messages
README.md - Server runtime → Matchmaking: pair players
README.md - Server runtime → Client registry: register and remove
server.c - Server runtime → Match registry: create and remove matches
server.c - Matchmaking → Match registry: create match
- Match registry → Match state: initializes
src/struct_jogo.c - Match registry → Player state: assigns players
src/struct_jogo.c - Server runtime → Board setup: prepares boards
- Server runtime → Ship placement: validates placement
- Server runtime → Turn and combat: validates attacks
server.c - Turn and combat → Match state: updates boards and scores
src/funcoes.c - Server runtime → Terminal views: dispatches game views
server.c - Turn and combat → Terminal views: reports outcomes
src/funcoes.c - Terminal views → Board formatting: formats boards
src/terminal.c - Terminal views → Client app: sends rendered state
src/terminal.c - Game configuration → Board setup: sets ship fleet
src/funcoes.c - Players → Server runtime: disconnect
README.md - Server runtime → Matchmaking: find another match
server.c