juho05 / tictactoe-backend

A TicTacToe TCP multiplayer server.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TicTacToe multiplayer server

License Go version

A TicTacToe TCP multiplayer server.

Features

  • Unlimited 1v1 matches in parallel
  • Winner/tie detection
  • Disconnect handling

Clients

  • CLI by juho05
  • WPF by Zersaeger

Commands

Sends

  • ping
    • Expects a pong response
  • match-found:[xo], e.g. match-found:x
    • Is sent once a match is found
    • Contains your sign (x or o)
  • your-turn
    • It's your turn (send a click message)
  • their-turn
    • Your opponent needs to send a click message
  • opponent-disconnected
    • Your opponent disconnected
  • board:000000000, e.g. board:120000000
    • Is sent once the board status changes
    • Contains the content of all fields
      • Content represented using integers
        • 0: empty
        • 1: cross
        • 2: circle
      • Left to right, top to bottom
        • In this example the top left field is filled with a cross and the one to the right of it with a circle
  • winner:000, e.g. winner:048
    • Is sent once you win
    • Contains the indices of the winning streak (in the example top-left to bottom-right)
  • loser:000, e.g. loser:048
    • Is sent once you lose
    • Contains the indices of the winning streak (in the example top-left to bottom-right)
  • tie
    • Is sent once all fields are filled without a winner

Receives

  • ping
    • Responds with pong

In a match

  • click:[0-8], e.g. click:2
    • Only allowed when it is your turn
    • Only allowed when the field is empty
    • Fill the field with the specified index with your sign
  • again
    • Can be sent once the game is complete
    • If both parties send this command, the game will be restarted

Setup

Prerequisites

  • Go 1.17+

Cloning the repo

git clone https://github.com/juho05/tictactoe-backend.git
cd tictactoe-backend

Building

go build -o tictactoe-backend ./cmd/main.go

Running

./tictactoe-backend

License

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Copyright

Copyright © 2022 Julian Hofmann

About

A TicTacToe TCP multiplayer server.

License:GNU General Public License v3.0


Languages

Language:Go 100.0%