I'm creating a turn and text-based strategy game in Django on Google App Engine with app-engine-patch. The simplified concept is that each player build can several different units and buildings to improve their base and fight other players for points.
My question involves the designing of the Django models, it seems to me that the buildings and units, which will have different attack power, life and such, should be their own models like so:
class Unit(db.Model):
name = db.StringProperty()
type = db.ReferenceProperty(UnitType)
targets = KeyListProperty(UnitType)
attack = db.IntegerProperty()
life = db.IntegerProperty()
price = db.IntegerProperty()
My problem then comes to how to easiest be able to set the players amount of a specific unit/building. As an example a player should be able to purchase, say 15 airplanes.
I then could just set "airplane" as an IntegerProperty in the player model and use the unit name as an identifier when getting the attack power and life of the airplane. That would however not be a very dynamic design, since the player model does not know if the unit "airplane" is actually present yet. I would like the player model to mirror the existing Unit/Building-models in someway.
This is my first try on a web-based game so I might be totally off track, does anyone have input on this? Is there a better way to do it?