Since the roll of dice are random, the Rules.Game class also has a FakeRoll function for testing, which of course isn't accessible from the client. One main priority was to keep network traffic low, in case many users start playing at the same time. The game rules are developed in C# and is a part of the backend. I also realized early that the game state had to be kept on the server and that the client should have as little game rules as possible. TDD is my choice of method when calculations get complicated and you don't want to spend hours and days tracking down ugly bugs. For these reasons, I decided to develop the rules of the game using Test Driven Development (TDD) and keep them in a separate DLL. If the move of a checker prevents using the other dice, you can't move that checker. But there are a few complex situations also, for example that you always have to use both dice if you can. If the opponent has only one checker on a point, you can hit it and that checker is moved to the bar, forced to start from point zero. If an opponent has two or more checkers on a point, that point is blocked. The rules (3) of Backgammon might look quite simple at first: Roll the dice and move checkers the number you get on the dice towards your home. The communication between frontend and backend is done with websockets during game play and a REST API for everything else.įor frontend, I use Angular 15 and the game board is drawn on an HTML canvas element. For SQL Server database integration, I use Entity Framework Core with code first migrations. You authenticate via Facebook or Google Oauth 2.0. The application is hosted on Azure (10) as an App Service and the data is stored in SQL Server. Some of the game features are listed below: It's by no means a complete guide of my code, but you can find the source open to read on GitHub (2). In this article, I share the technologies I use and small things I think can be useful if you plan to start a similar project. The main goal was to try to improve my full stack developer skills and perhaps discover a new trick or two. Read about how to develop an online game on Azure.ĭuring the last month or so, I've spent most of my free time building an online backgammon game.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |