StructuredProperty中的NDB列表属性(或类似)?

时间:2014-04-05 17:02:24

标签: python google-app-engine app-engine-ndb

我正在使用GAE为我的朋友和我玩的游戏创建一个统计录制应用程序。 (可能是书呆子,但我会接受它。)每场比赛都有一定数量的轮次,每轮比赛都有一个投票过程。我想记录每轮投票的球员。

但是,我在文档中看到你不能将重复的StructuredProperty放在重复的StructuredProperty中,为了记录每一轮的每一次投票,我需要这样做。有没有办法在不使用LocalStructuredProperty的情况下执行此操作(因为我希望能够查询这些值,例如,找出玩家如何随时间投票,我相信LSP不允许这样做?)。

这是我现在拥有的数据结构的代码,其中一些注释解释了大多数事情。现在无法工作的是团队,批准和拒绝。由于这一点的重点是跟踪这样的东西,我真的需要能够查询它们,所以我现在把一个假的“ListProperty”......:

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.

让我知道您可能需要提供哪些进一步信息,我很乐意提供!

0 个答案:

没有答案