I am creating a game strategy with rotation and text strategy in Django in the Google App Engine using the engine-patch application. A simplified concept is that each player can create several different units and buildings to improve their base and fight with other players for points.
My question includes the design of Django models, it seems to me that buildings and units that will have different attack power, life, etc., should be their own models, such as:
class Unit(db.Model):
name = db.StringProperty()
type = db.ReferenceProperty(UnitType)
targets = KeyListProperty(UnitType)
attack = db.IntegerProperty()
life = db.IntegerProperty()
price = db.IntegerProperty()
Now my problem is how it is easiest to set the number of players in a certain unit / building. As an example, a player should be able to buy, say, 15 aircraft.
Then I could just set the “plane” as IntegerProperty in the player’s model and use the unit name as an identifier when receiving the attack power and life of the plane. This, however, would not be a very dynamic design, as the player’s model does not know if the “aircraft” unit is actually present. I would like the player model to reflect the existing Unit / Building models.
This is my first attempt at a web game, so I can be a complete SUV, does anyone have any input on this? Is there a better way to do this?
source
share