This content originally appeared on DEV Community and was authored by Jackson Bowe
This is the first post (of hopefully many) where I will be documenting my journey creating a serverless multiplayer game; Mafia (name not final... unless???).
I'm going to use this first post to cover the tools I intend to use and give a general idea of what this game should look like at the end. So here we go...
What is this game?
I'm basing this game heavily on the popular table top game by the same name. It's a social deduction game in which a majority team, the Townies, try to root out the opposing minority team, the Mafia.
Members of the Mafia are aware of their allies and must work together to mislead the Town and avoid suspicion. Town players are not aware of anyone else's role and must use their deductive reasoning to locate evildoers.
Mechanics
The game isn't strictly turn based however it follows a similar principal. There are four states; Morning, Day, Evening, and Night.
During the Day all members of the town (inclusive of the mafia members) gather to discuss what leads they have found on the Mafia. At this time they may also decide to remove a player under suspicion of being a member of the Mafia.
At Evening, the public forum closes and players are given time to process they day's conversation, and if possible with their role they can chose a player to target that night. For example, a Detective may chose to follow another player and see who they visit that night. Mafia members are able to converse amongst themselves during this time.
During the Night the game processes all the player actions.
In the Morning, the events of the previous Night are revealed to the Town.
The cycle repeats until there is a winner.
Enough with the nerd stuff, tell me about the tech stack!
Heavy sarcasm :)
Tools I'm using to make this
I want the game to be playable in the web browser at this stage, may change in future. Also primarily using AWS for the backend.
Backend
- AWS ApiGateway for player to backend communication
- AWS DynamoDB as a database following Single Table Design principles
- AWS Cognito for user authentication
- AWS S3 for medium/large file storage (images etc.)
- AWS IoT Core for the pub/sub functionality (live updates)
- Postman to test and document the API
All application logic will be written in Python.
Frontend
The frontend will be made with Quasar Framework - a Vue.js wrapper. Quasar comes bundles with a wide array of prebuilt components and very thorough documentation. An additional benefit is that Quasar streamlines the process of packaging a single codebase into multiple deployment formats; web, mobile, and desktop. This sparks joy.
The glue
As I previously stated my goal with this project is 100% serverless, however there is another requirement that is just as important; 100% Infrastructure as Code. IaC is exactly as it reads, all infrastructure covered in the Backend section should be provisioned in code, with nothing needing to be created in AWS manually.
There are several benefits to this approach:
- Changes to Infrastructure can be tracked with Git. Manual editing via the AWS console is un-trackable and generates no history.
- The project can be deployed with a single command. If I deploy in Australia, and then have reason to deploy in North America, I must be able to do so with confidence and speed.
- The project can be destroyed with a single command. This is extremely important. If I determine that the cost becomes unsustainable I must be able to completely eradicate all traces of it with no remnants remaining. Scorched earth.
The IaC framework I will be using for this project is Serverless Stack (SST).
SST is a cloud architecture development kit that lets you provision Infrastructure as Code by leveraging the base AWS CDK with improvements geared towards serverless applications. If you've used any IaC providers in the past like Terraform, AWS CDK, Serverless, SAM etc. - I seriously recommend checking out SST. It's next level.
Process, MVP, and Timeline
This project is my way of diving head first into serverless cloud development. I'm using something I'm passionate about to motivate and upskill myself into a field that I think is the future. For this reason I will be attempting to follow as many best practices as I can, and sharing them here as I adopt them.
Below is a flow chart with my rough architecture plan. This will no doubt change as the project matures.
Process
User actions are sent via REST API to an AWS Api Gateway. This distributes requests to the appropriate lambda microservice, called Controllers. The Controllers handle all application logic between frontend and backend services such as the database.
As there is no server I am not able to maintain continuous state. All user actions must be written to the database. During the Night sequence, all user actions will be read from the database and combined with data about the game (settings etc.).
The combined user actions and game settings will be resolved using my custom MafiaEngine. This will return the resolved game state to be communicated back to the users.
Minimum Viable Product
The maximum number of players in a game is 15. A typical game will have 9 Town players, 3 Mafia players, and 3 Neutrals. A fully featured game will have large role diversity between the players, however as players can share the same role I will be aiming for the following.
Town: Citizen, Doctor, Bodyguard, Detective, Escort
Mafia: Mafioso, Liaison (evil Escort)
Neutral: Serial Killer, Survivor, Jester (of course)
The game will need a fully functioning lobby system, stage transitioning (morning/night/etc.), and state resolution.
Timeline
I began routine work in early January 2023 and have maintained decent weekly progress. I hope to have a playable version of this game out within 2 months (end April). Between now and then I will aim for regular updates and cover technical roadblocks and solutions.
Conclusion
I don't particularly want this series to be a generic game "devlog" thing. The real motivation behind this project was to get familiar with serverless cloud development and I think it's going to be a massive learning opportunity.
What I'm more interested in writing about it showing how I've implemented some serverless feature and provide a legitimate use case that it is fulfilling.
If this project sounds interesting I'd love to hear from you, especially if you see me running headlong into a classic pitfall.
Note: I'm keeping somewhat-up-to-date technical documentation for the project at https://mafia-sdg.netlify.app/.
Cheers,
This content originally appeared on DEV Community and was authored by Jackson Bowe
![](https://www.radiofree.org/wp-content/plugins/print-app/icon.jpg)
Jackson Bowe | Sciencx (2023-02-27T01:19:56+00:00) Mafia: A Serverless Multiplayer Game. Retrieved from https://www.scien.cx/2023/02/27/mafia-a-serverless-multiplayer-game/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.