We’ve come to another big milestone in our game. We extended our game engine with a lot of new functionality — all within the design patterns that we established early on. And we added more complex UI elements into our game screen — learning about some new Blazor and Blazorize rendering features.
We had a great time building out the following:
- Inventory system – We created a separate class that manages the inventory. It hides the complexity of adding and removing items and collapsing non-unique items. The inventory tab also allowed us to learn how to create table layouts in Blazor.
- Random dice rolling – We looked at using a NuGet package and component that allows us to roll random dice of any type.
- Monster creation and combat – We reviewed creating model classes again and another factory for monsters. And with the monsters and random dice rolling, we built a very simplistic combat system… We will be enhancing it in future lessons.
- Trading system – We built a trading system, so that the player can sell the items they picked up over the course of adventuring. And we allow players to buy new items (or buy back what they sold). This feature allowed us to investigate building a modal screen in Blazor.
- Quest system – No roleplaying game is complete without the motivation for the player to go out adventuring. Quests are a common mechanism for doing that. We can build quests with pre-requisites (items needed to complete them), and then complete the quests and provide the player with various rewards.
Hopefully learning all of these parts of a game engine has made the experience more enjoyable. While building these features, we continued to learn about our design patterns and some new concepts — like dice rollers and modal windows in Blazor.
At the end of this chapter, we are going to create another Pull Request to merge our “chapter-3” branch changes into the main branch. For a refresher on how to create and complete a Git Pull Request, please jump back to Lesson 1.11 (if you need that).
Also providing another reminder that we can go back to each individual commit per lesson to look at the code changes there and the corresponding tests per lesson. Please look back at Lesson 2.11 to review how to get to specific commits in Azure DevOps.
In conclusion, we have developed a basic game engine. As we move into the next chapter, we are going to look at more advanced features of a game engine, like enhanced combat, game actions, recipes for crafting items, and loading game data from data files (rather than hard-coding them into the game engine code).
Note: As we move forward, our lessons are going to pick up pace. We aren’t going to continue going through the basics of creating new files and such… we can always go back to past lessons to refresh our memories on that. So the lessons will encapsulate larger changes and focus on the important code… not every single line. If you find you questions about code that isn’t explained, feel free to ask them in the lesson comments.