def get(self, key): game_key = ndb.Key(urlsafe=key) user = users.get_current_user() if not game_key: webapp2.abort(404, 'Game not found') game = game_key.get() characters = models.Character.query(ancestor=game_key).fetch(limit=100) player_characters = [c for c in characters if c.player == user] other_characters = [c for c in characters if not c.player == user] player_character = None if player_characters: player_character = player_characters[0] game_owner = user in game.admins template_values = { "title": game.title, "game": game, "your_character": player_character, "game_owner": game_owner, "other_characters": other_characters, } template = templates.get_template('game.html') self.response.write(template.render(template_values))
def __init__(self, template_key, template=None): self.args = None # populated by self.generate() self.description = None # populated by self.generate_description() if template_key != "Noop": self.template = get_template(template_key, self, template) self._dialogue_type = "human_give_command" self._replace = None self._is_dialogue = False
def get(self): template_values = { "title": "Play", } template = templates.get_template('index.html') self.response.write(template.render(template_values))
def get(self): user = users.get_current_user() template_values = { "title": "Home", "user": user, "games_created": [ g for g in models.Game.query(models.Game.creator == user)], "games_playing": [ g for g in models.Game.query(models.Game.players.IN([user]))], "games_invited": [g for g in models.Game.query(models.Game.invited_emails.IN([user.email()]))], } template = templates.get_template('home.html') self.response.write(template.render(template_values))