This will be my first development series I publish on the world wide web. The idea is to develop a Doppelkopf online game. In this first part I briefly introduce the game, it’s entities, and which technology stack I will use.
Doppelkopf is a card-game played with four players. A game consits of 40 cards (at least in the version I usually play, that is without the 8 and 9 cards) from 10 to Ass in four colors, and each card double. During a normal game, each player needs to find his or her partner. Also, players can bid to score more points in the end (in Germany it is common to play with little cash, or write down the points to pay it out in the end). With each round a player / a team tries to beat other player’s cards. All points of the cards are counted at the end of the game. The team who has more than 120 points wins the game.
Before starting to develop, we need to identify the different entities and their responsibilities. Then it becomes more “natural” to implement the structures within the source-code, resulting in better extendable and maintainable code.
Thus, I list the entities here:
- Card (from 10 to Ass in the four colors)
- Carddeck (all 40 cards)
- Player (a person participating in the game)
- Hand (the cards a player has in his hand)
- GameOption (either normal, marriage, or solo games)
- Game (the game, finishes when all playerer played all cards)
Also, we need to choose a technology stack. As I wish to get some more experience developing software with Rust - as we use it within our “Encryption 4 All” project - the logical choice is Rust for developing the backend server.
Since a game needs to update players in real-time for a smooth experience, I would like to experiment with websockets, as I have never used it before. Websockets is a protocol that enables event-based communication. Hereby the server pushes updates to subscribed clients, rather than clients pulling (via for instance AJAX requests) every couple of milli seconds. Interestingly, parts of the client could be written in Rust, as there is a socketio implementation for Rust which makes it possible to handle websockets. Then, we could compile the Rust client to webassembly, and subsequently load it into any modern web-browser. The frontend itself I would like to write in React as it is the most used JS lib for building UIs.
In the following blogpost I will go into more detail of the entities, and what their relationship is, and how we consequently can implement them within Rust.