Welcome to the Battleship Server! This project is a multiplayer implementation of the classic Battleship game, built using Go. The server handles player connections, matchmaking, and game logic.
- Matchmaking: Players can find matches or create/join private rooms. [Working]
- Ship Placement: Players can place their ships on a 10x10 grid. [Yea this ain't wokring yet]
- Battle Mode: Once all ships are placed, the battle begins (game logic to be implemented). [Haven't even started yet]
- Dynamic Rooms: Create private rooms with unique IDs for private matches. [Working]
The server listens on localhost:8080 for incoming connections. Players connect via TCP and interact with the server using predefined commands.
FIND_MATCH: Find a random opponent.CREATE_PRIVATE: Create a private room.JOIN_PRIVATE:<RoomID>: Join a private room using the room ID.PLACE_SHIP:<ShipName>:<StartCoord>:<Direction>: Place a ship on the board.
- Players connect to the server and provide their name.
- Players can choose to find a match or create/join a private room.
- Once matched, players place their ships on the board.
- When all ships are placed, the battle begins (to be implemented).
The Board struct represents the 10x10 grid. Ships are placed on the grid, and the board is serialized for communication with the client.
The Player struct holds player-specific data, including their connection, name, board, and opponent.
The server supports both random matchmaking and private rooms. Private rooms are identified by unique IDs generated using a random alphanumeric string.
Ships are placed on the board using the PLACE_SHIP command. The server validates the placement to ensure ships do not overlap or go out of bounds.
- The board serialization method (
Serialize) is not working as expected. The client may not parse the board correctly. - The main game logic for the battle phase is yet to be implemented.
- Implement the battle logic.
- Enhance error handling and logging.
- Allow customization of ship types and counts. Somethig like a blitz mode.
- Improve the client-side experience.
- Go 1.16 or later
- Clone the repository.
- Navigate to the project directory.
- Run the server:
go run main.go
- The server will start on
localhost:8080.
Use the Battleship client.
This project was inspired by the classic Battleship game and built with a focus on learning Go. Special thanks to random YouTube videos and my divine intuition for guidance lmao!