I want to create many ammo types and obviously a gun uses a particular ammo type so I need an easy way to look it up for ammo consumption. I am creating a inheritance system for a factory that takes data from files and convert them to objects so if I end up going to add crazy amount of types everything stays in good order. Now I am wondering how far I should take this in the OOP sense.
Say I have many different types of bullets should I create a Bullet class that holds these bullets and compare by a int or string identifier if the weapon can fire that bullet? Creating a class for every bullet type seems over kill but does compare it easily.
Bullets will mostly have the same behavior so I should probably stop at the Bullet class. Rockets however behave a bit differently from each other. Some will be guided, they have different damage types and some other behaviors. Still these could be implemented within the same class.
The point is what would be a good way to look these up? I can create a weapon that uses ammo of the type [bullet] with a string "5.56mm". So I should firstly look in my inventory if I have ammo of the type bullet and then check if that ammo has the string with "5.56mm". This is kind of error prone though. What about using "static final int"?
In the weapon factory I would get a ammo type from a file and assign the value to "int ammoType" to the corresponding global. In the ammo factory I can do the same. Then I would compare the ammo [class] first and second these global types. I still have the readability in my data files and besides much quicker look ups they are error prone (as long as the data files are consistent).
I'd like to here some thoughts about this, I'm having a hard time wrapping my head around the wole subject but I think I am getting there.