Defining the basic card data: an introduction to ECS entities and components, part 2

The cards in our game are ECS entities, with the CardData component attached to them:

In addition to the CardData component, cards also have one of the following type-specific components attached to them depending on their type:

Note how these new component definitions provide an ad-hoc form of polymorphism: whenever we are interested in cards, generally speaking and irrespective of their concrete type, we can filter entities by their CardData component. On the other hand, whenever we are interested in a certain type of cards, we can filter them by their type-specific component instead. A common piece of advice for traditional object-oriented databases is to prefer composition over inheritance, and the ECS provides just that by default.

Finally, every card (except for abilities) has a StatData component attached to it:

This component stores the numeric stat value of the card. While we could store this value directly inside every type-specific component, it is useful to move it into its own independent component, because doing so will simplify writing code that deals with stats irrespective of the card's type (like certain abilities we will cover later in the course).