Beispiel #1
0
    def get(self):
        user = users.get_current_user()
        if not user:
            self.redirect("/")

        player = doo.getplayerbyuser(user)
        if not player:
            player = doo.makeplayer(user.nickname(), user=user)
            
        toplayer = doo.getplayer(self.request.get('param'))
        if not toplayer:
            self.error(404)
        
        if toplayer.solid:
            return
            
        hasmoney = player.money >= doo.getmessageprice()
        
        messageprice = doo.getmessagepricedisplay()
        
        template_values = {
            'player': player,
            'toplayer': toplayer,
            'hasmoney': hasmoney,
            'messageprice': messageprice,
            }

        if player.mobile:
            templatefile = 'm_sendmessage.html'
        else:
            templatefile = 'sendmessage.html'
        path = os.path.join(os.path.dirname(__file__), templatefile)
        self.response.out.write(template.render(path, template_values))
Beispiel #2
0
    def post(self):
        user = users.get_current_user()
        if not user:
            self.redirect("/")

        player = doo.getplayerbyuser(user)
        if not player:
            player = doo.makeplayer(user.nickname(), user=user)
            
        toplayer = doo.getplayer(self.request.get('playerid'))
        if not toplayer:
            self.error(404)
            
        messagetext = self.request.get('messagetext')
        if not messagetext:
            self.error(404)
            return
            
        if player.money >= doo.getmessageprice() and not toplayer.solid:
            if not player.sendmessage(toplayer, messagetext):
                self.error(404)
                return
        else:
            self.error(404)
            return
Beispiel #3
0
 def sendmessage(self, toplayer, messagetext):
     if not toplayer.solid and self.money >= doo.getmessageprice() and len(messagetext) > 0 and len(messagetext) < 300:
         messagetext = '<span title="message sent %s"><a style="cursor:pointer;" onclick="gohere(\'playerinfo\', \'%s\');"><b>%s</b></a> says: %s<span>' % (formattar.prettydate(datetime.datetime.now()), self.playerid, self.name, messagetext)
         if doo.message(toplayer, messagetext):
             self.money -= float(doo.getmessageprice())
             self.put()
             return True
         else:
             #doo.makealert(self, 'Error sending message to %s' % (toplayer.name))
             #self.error(404)
             logging.info('here?')
             return False
     else:
         #doo.makealert(self, 'Error sending message to %s' % (toplayer.name))
         #self.error(404)
         logging.info('or here?')
         return False