Making Monsters with the Type Object Pattern
In the last chapter, we worked on a system of interchangeable algorithms (strategies) that could be assigned at runtime or during gameplay without the client knowing the nitty-gritty details. In this chapter, we’re going to take a step back from behavior and put our sights on data and the Type Object pattern, which lets you create different configurations of the same object with the least number of classes (because all the cool kids use flat hierarchies).
Specifically, we’ll try to find common data that all related objects share, separate it out into its own class, and inject it back into the object we want to configure. You can create infinite combinations of the same object by giving them different types (shared data templates) without a huge class hierarchy that needs babysitting every time you add or modify the code!
For example, a hero or heroine could be a human, giant, or elf, but they all have hp, stamina,...