0

I'm using GAE to create a stats-recording app for a game my friends and I play. (Nerdy, maybe, but I'll take it.). Each game has a certain number of rounds, and each round has, among other things, a voting process. I want to record which players vote in each round.

However, I see in the documentation that you can't put a repeated StructuredProperty inside a repeated StructuredProperty, which I would need to do in order to record each vote in each round. Is there a way to do this without using LocalStructuredProperty (as I would like to be able to query those values in order to, for example, find out how a player voted over time, and I believe a LSP would not allow this?).

Here's the code for the data structure that I have now, with some comments explaining most things. The ones that right now can't work are team, approves, and rejects within round. Since the whole point of this is to track stuff like that, I really need to be able to query them, so I put a fake "ListProperty" in now...:

class GamePlayer(ndb.Model):
    name = ndb.StringProperty(required=True)
    role = ndb.StringProperty(required=True) # Spy, resistance, etc.
    seat = ndb.IntegerProperty(required=True) # Have to figure out how to calc this

class Game(ndb.Model):
    date = ndb.DateTimeProperty(required = True)
    players = ndb.StructuredProperty(GamePlayer, repeated=True)
    specials = ndb.StructuredProperty(repeated=True) # List of special chars used. Does it need to be a separate class, or just a list of strings?
    winner = ndb.BooleanProperty(required = True) # TRUE will be resistance, FALSE spies. Have it calculate?
    rounds = ndb.StructuredProperty(Round, repeated=True)

class Round(ndb.Model):
    number = ndb.IntegerProperty(required=True) # Have it count up
    votecount = ndb.IntegerProperty(required=True) # Will be 1-5
    mission = ndb.IntegerProperty(required=True) # Will also be 1-5
    leader = ndb.IntegerProperty(required=True) # Will be the seat number of the leading player
    team = ndb.ListProperty(required=True, repeated=True) # WILL NOT WORK. But, should be seat numbers of all team members
    approves = ndb.ListProperty(repeated=True) # WILL NOT WORK. But, should be seat nos. of all approving members
    rejects = ndb.ListProperty(repeated=True) # WILL NOT WORK. Maybe should be calculated from approves?
    approved = ndb.BooleanProperty(required=True) # Can be calculated maybe. Whether the team was approved or not.
    successes = ndb.IntegerProperty(required=True) # The number of success cards played
    fails = ndb.IntegerProperty(required=True) # The number of fail cards played
    succeeded = ndb.BooleanProperty(required=True) # Whether or not the mission succeeded.

Let me know what further info you might need to help and I will be happy to provide!

3
  • provide your code snippet, please
    – lucemia
    Apr 6, 2014 at 3:39
  • 1
    No you can't. Why not use a BlobProperty and store the a dict or whatever structure in that. The only thing you miss out on then is querying against the contents. Apr 6, 2014 at 3:45
  • Hey @lucemia I added in the code — let me know if that helps!
    – dangr
    Apr 7, 2014 at 1:55

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.