/Board-games-library

Client-Server C# library for board games

Primary LanguageC#MIT LicenseMIT

Board games library

tgLib is a lightweight Client-Server C# library for board games. It is modular and very easy to use. It provides functionalities for server and client which can be used independently. The code is provided with server and client application examples, and with tgLib class diagram for good understanding how it works. The client application implements the well-known Connect4 game. You can have a look at the video gameplay on my youtube channel.

Gameplay video on youtube

Features

  • Sever can run in background mode or window mode
  • Data management using file or database
  • Player data management (registration, login, score)
  • Concurrency through multithreading (one thread per client)

Requirements

The code has been compiled with visual studio 2013 (.Net Framework 4.5) without any special package or library. Although I didn't test it with another version of visual studio, I assume it should work for any version of visual studio let's say greater or equal to 2010. Also, I use Microsoft.ACE.OLEDB.12.0 as provider in the server application example. So you will need to install it if you intend to use the same provider or you can just use another .Net provider.

Architecture

The library is designed in two modules : the client module which implements client functionalities and the server module for server functionalities. Each module follows MVC architecture.

Project architecture

tgLib class diagram

How it works

tgLib is very simple, the view of the server application should implement the IServerView interface of tgLib and that's all for the server side ☺️. On the other side, the client application game class should inherit from the Game class of tgLib and the view should also implement the IClientView interface of tgLib. The diagrams below show how the server and client examples have been designed. It is a good example of how to use tgLib for any board game.

Server App class diagram Client App class diagram Client state machine           diagram

Running the examples

You can find in the readyToUse directory the client EXE and the server EXE in which I embedded the tgLib.dll for convenience thanks to Fody package. Unfortunatelly, I couldn't do the same with the user DB (access db). I run my tests on the same machine, so please do not hesitate to raise an issue.

Once the server has started, the client can connect and logged if he has already registered. Otherwise, he can register with by filling his login and password, or he can stay as anonymous player. Of course as anonymous player he have no score history.

Once the client is connected or logged, he can see the list of connected players and choose the player he want to challenge. The selected player on his side receives the challenge request and can reject or accept it. If the request is accepted, the both players can begin the game and cannot receive any other request while playing. During a game, the challengers can communicate through a chat box on the right panel. Moreover, any challenger can abort the game at any time.

Authors

  • F. Ndongmo Silatsa

Licence

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

  • Dominikus Herzberg for his explantions of the Connect4 algorithm.
  • qu1j0t3 wo has implemented an efficient Connect4 algorithm in Java.