# messengergp/battleshipsproject architecture

> Architecture diagram of the GitHub repository messengergp/battleshipsproject, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/messengergp/battleshipsproject
- Repository: https://github.com/messengergp/battleshipsproject

## Overview

This is a single-file, console Battleship game. A player chooses a new game, loads a saved game, or replays a completed game; setup places ships, turns accept coordinates and resolve shots, and a win records the finished state. Between turns, the game menu supports saving, loading, restarting, and exiting. The excerpt confirms the main game, combat, board, and finished-game persistence behavior; some menu and save/load wiring is inferred only where the excerpt shows the corresponding options or calls.

Main entry points: [`main.c`](https://github.com/messengergp/battleshipsproject/blob/main/main.c) (Turn handling), [`Finished_Game.sav`](https://github.com/messengergp/battleshipsproject/blob/main/Finished_Game.sav) (Completed save), [`Saved_Game.sav`](https://github.com/messengergp/battleshipsproject/blob/main/Saved_Game.sav) (In-progress save)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Console interface"]
  node_menu["Start and replay menu<br/>[main.c]"]
  node_game_menu["Between-turn menu<br/>[main.c]"]
  node_board_view["Board display<br/>[main.c]"]
end

subgraph group_game["Game runtime"]
  node_main["Game loop<br/>[main.c]"]
  node_setup["Game setup<br/>[main.c]"]
  node_placement["Ship placement<br/>[main.c]"]
  node_turn["Turn handling<br/>[main.c]"]
  node_combat["Shot resolution<br/>[main.c]"]
  node_state["Game state<br/>[main.c]"]
end

subgraph group_storage["Saved state"]
  node_saved[("In-progress save<br/>[Saved_Game.sav]")]
  node_finished[("Completed save<br/>[Finished_Game.sav]")]
  node_save_load["Save and load<br/>[main.c]"]
end

node_player(("Player"))

node_player -->|"chooses"| node_menu
node_menu -->|"starts or loads"| node_main
node_main -->|"initializes"| node_setup
node_setup -->|"places ships"| node_placement
node_main -->|"runs turns"| node_turn
node_turn -->|"resolves shot"| node_combat
node_turn -->|"displays board"| node_board_view
node_player -->|"fires at"| node_turn
node_main -->|"offers options"| node_game_menu
node_game_menu -->|"requests save or load"| node_save_load
node_save_load -->|"reads or writes"| node_saved
node_turn -->|"saves on win"| node_save_load
node_save_load -->|"reads or writes"| node_finished
node_main -->|"updates"| node_state
node_setup -->|"initializes"| node_state
node_turn -->|"updates"| node_state
node_menu -.->|"replays completed game"| node_finished

click node_menu "https://github.com/messengergp/battleshipsproject/blob/main/main.c"
click node_game_menu "https://github.com/messengergp/battleshipsproject/blob/main/main.c"
click node_board_view "https://github.com/messengergp/battleshipsproject/blob/main/main.c"
click node_main "https://github.com/messengergp/battleshipsproject/blob/main/main.c"
click node_setup "https://github.com/messengergp/battleshipsproject/blob/main/main.c"
click node_placement "https://github.com/messengergp/battleshipsproject/blob/main/main.c"
click node_turn "https://github.com/messengergp/battleshipsproject/blob/main/main.c"
click node_combat "https://github.com/messengergp/battleshipsproject/blob/main/main.c"
click node_state "https://github.com/messengergp/battleshipsproject/blob/main/main.c"
click node_saved "https://github.com/messengergp/battleshipsproject/blob/main/Saved_Game.sav"
click node_finished "https://github.com/messengergp/battleshipsproject/blob/main/Finished_Game.sav"
click node_save_load "https://github.com/messengergp/battleshipsproject/blob/main/main.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_menu,node_game_menu,node_board_view toneBlue
class node_main,node_setup,node_placement,node_turn,node_combat,node_state toneAmber
class node_saved,node_finished,node_save_load toneMint
class node_player toneIndigo
```

## Components

### Console interface

- [Start and replay menu](https://github.com/messengergp/battleshipsproject/blob/main/main.c): `main.c`
- [Between-turn menu](https://github.com/messengergp/battleshipsproject/blob/main/main.c): `main.c`
- [Board display](https://github.com/messengergp/battleshipsproject/blob/main/main.c): `main.c`

### Game runtime

- [Game loop](https://github.com/messengergp/battleshipsproject/blob/main/main.c): `main.c`
- [Game setup](https://github.com/messengergp/battleshipsproject/blob/main/main.c): `main.c`
- [Ship placement](https://github.com/messengergp/battleshipsproject/blob/main/main.c): `main.c`
- [Turn handling](https://github.com/messengergp/battleshipsproject/blob/main/main.c): `main.c`
- [Shot resolution](https://github.com/messengergp/battleshipsproject/blob/main/main.c): `main.c`
- [Game state](https://github.com/messengergp/battleshipsproject/blob/main/main.c): `main.c`

### Saved state

- [In-progress save](https://github.com/messengergp/battleshipsproject/blob/main/Saved_Game.sav): `Saved_Game.sav`
- [Completed save](https://github.com/messengergp/battleshipsproject/blob/main/Finished_Game.sav): `Finished_Game.sav`
- [Save and load](https://github.com/messengergp/battleshipsproject/blob/main/main.c): `main.c`

### Other components

- **Player**

## Connections

- Player → Start and replay menu: chooses
- Start and replay menu → Game loop: starts or loads
- Game loop → Game setup: initializes
- Game setup → Ship placement: places ships
- Game loop → Turn handling: runs turns
- Turn handling → Shot resolution: resolves shot
- Turn handling → Board display: displays board
- Player → Turn handling: fires at
- Game loop → Between-turn menu: offers options
- Between-turn menu → Save and load: requests save or load
- Save and load → In-progress save: reads or writes
- Turn handling → Save and load: saves on win
- Save and load → Completed save: reads or writes
- Game loop → Game state: updates
- Game setup → Game state: initializes
- Turn handling → Game state: updates
- Start and replay menu → Completed save: replays completed game
