Exemplo n.º 1
0
def get_high_scores():
    """Returns an array of the top NUM_HIGH_SCORES high scores."""
    # make sure this is the user' first time playing
    q = db.GqlQuery(GQL_HIGH_SCORES)
    hscores = q.fetch(NUM_HIGH_SCORES)

    # pad out the list with junk if we don't have the min # of high scores yet
    num_missing = NUM_HIGH_SCORES - len(hscores)
    if num_missing > 0:
        junk_entry = HighScore()
        junk_entry.name = '???'
        junk_entry.date = None
        junk_entry.score = 0
        hscores += (num_missing * [junk_entry])

    return hscores