Created
September 28, 2014 18:51
-
-
Save fisherds/c43fc732000b6a62b37b to your computer and use it in GitHub Desktop.
Datastore models used in the Dice with Friends web app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from google.appengine.ext import ndb | |
| class Player(ndb.Model): | |
| """ Information for a player. """ | |
| display_name = ndb.StringProperty() | |
| def get_name(self): | |
| """Returns the best name available for a Player.""" | |
| if self.display_name: | |
| return self.display_name | |
| return self.key.string_id() # email address | |
| class Game(ndb.Model): | |
| """ Dice with Friends game. """ | |
| creator_key = ndb.KeyProperty(kind=Player) | |
| invitee_key = ndb.KeyProperty(kind=Player) | |
| creator_scores = ndb.IntegerProperty(repeated=True) | |
| invitee_scores = ndb.IntegerProperty(repeated=True) | |
| last_touch_date_time = ndb.DateTimeProperty(auto_now=True) | |
| is_complete = ndb.BooleanProperty(default=False) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment