def get(self): #user = get_user_or_redirect(self) user = users.get_current_user() if not user: self.redirect(users.create_login_url(self.request.uri)) #ahora vamos a obtener el personaje del jugador player = Player.getPlayer(user) if not player: self.redirect('/game/myplayer/') return #obtenemos el mapa por defecto mapa = Map.getTheMap() channel_id = channel.create_channel(mapa.name) posicion = PlayerOnMap.addPlayerOrGetPosition(mapa, player) #avisamos de un nuevo jugador data = {'type':'player_login', 'player_name':posicion.player.name, 'player_id':int(posicion.player.key().id()), 'pos_x':int(posicion.pos_x), 'pos_y':int(posicion.pos_y), 'player_type':posicion.player.type } channel.send_message(mapa.name, simplejson.dumps(data)) values = {'titulo':'Game Page','user':user,'player':player,'mapa':mapa,'channel_id':channel_id} mostrar(self.response, "game.html", values)
def get(self): user = get_user_or_redirect(self) player = Player.getPlayer(user) if player: form = PlayerForm(instance=player) else: form = PlayerForm() values = {'titulo':'My Player','user':user,'form':form} mostrar(self.response, "game/myplayer.html", values)
def post(self): user = get_user_or_redirect(self) player = Player.getPlayer(user) if player: form = PlayerForm(data=self.request.POST, instance=player) else: form = PlayerForm(data=self.request.POST) if form.is_valid(): player = form.save(commit=False) player.owner = user player.put() self.redirect('/game/') #si estamos aca es porque el form no es valido values = {'titulo':'My Player','user':user,'form':form} mostrar(self.response, "game/myplayer.html", values)
def get(self): user = users.get_current_user() if user: url = users.create_logout_url(self.request.uri) url_linktext = 'Logout' else: url = users.create_login_url(self.request.uri) url_linktext = 'Login' values = { 'titulo':'Inicio', 'url':url, 'url_linktext':url_linktext, 'user':user } mostrar(self.response, "index.html", values)
def get(self): values = { 'titulo':'About', } mostrar(self.response, "about.html", values)
def get(self): values = {'titulo':'Game Tag','debug':True} mostrar(self.response, "game/gametag.html",values)