I'm writing a roguelike where objects and floor can be made of different materials. For instance, let's say we can have a wooden chair, an iron chair, a golden chair, and so on.
I've got an Object class (I know, the name is terrible), which is more or less using a composite pattern, and a Material class. Material have different important properties (noise, color...). For the time being, there are 5 different instances of materials, created at the initialization of the game.
How would connect an instance of Object with one of the 5 instances of materials ? I see three simple solutions :
Using a pointer. Simple and brutal.
Using an integer material-id, then get the materials out of a table when engine manipulates the object for various purposes (display, attack analysis, etc.). Not very beautiful, I think, and not very flexible.
Using an integer material-id, then get the materials out of a std::map. A bit more flexible, but still not perfect.
Do you see other possibilities ? If not, what would you choose (and why) ? Thanks in advance !