Exemple #1
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
Exemple #2
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)
        
        player.checksalary()
        levelprogress, nextlevel = player.checklevel()
        
        occupation = player.getoccupation()
        numfriends = len(player.friends)
        
        template_values = {
            'player': player,
            'numfriends': numfriends,
            'occupation': occupation,
            'levelprogress': levelprogress,
            'nextlevel': nextlevel,
            }

        if player.mobile:
            templatefile = 'm_frontpage.html'
        else:
            templatefile = 'frontpage.html'
        path = os.path.join(os.path.dirname(__file__), templatefile)
        self.response.out.write(template.render(path, template_values))
Exemple #3
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)
            
        investmentamount = self.request.get('investmentamount')
        if investmentamount:
            investmentamount = round(float(investmentamount), 2)
        else:
            doo.makealert(player, 'eeeehhh, that amount does not compute, you\'re under arrest')
            self.error(404)
            return
        
        if not investmentamount:
            doo.makealert(player, 'eeeehhh, that amount does not compute, you\'re under arrest')
            self.error(404)
            return
        
        
        investment = doo.getplayer(self.request.get('investmentid'))

        if not player.addinvestment(investment, self.request.get('investmentamount')):
            self.error(404)
            return
    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)
            
        investment = doo.getplayer(self.request.get('param'))
        #totalinvestment = player.getinvestmentamount(investment.playerid)
        playerinvestment = doo.getplayerinvestment(player.playerid, investment.playerid)

        message = ''
        template_values = {
            'investment': investment,
            'playerinvestment': playerinvestment,
            'player': player,
            'message': message,
            }

        if player.mobile:
            templatefile = 'm_withdrawmoney.html'
        else:
            templatefile = 'withdrawmoney.html'
        path = os.path.join(os.path.dirname(__file__), templatefile)
        self.response.out.write(template.render(path, template_values))
Exemple #5
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)
            
        #myinvestors = doo.getinvestorsbyidlist(player.listinvestees().keys(), count=10, start=0)
        investors = player.getinvestors()
        #listinvestors = player.listinvestees()
        #investors = []
        
        #for investor in myinvestors:
        #    investors.append((investor.name, formattar.getmoney(listinvestors[investor.playerid]), investor.playerid))
        #    logging.info(investors)
                    

        template_values = {
            'investors': investors,
            'player': player,
            }


        if player.mobile:
            templatefile = 'm_myinvestors.html'
        else:
            templatefile = 'myinvestors.html'
        path = os.path.join(os.path.dirname(__file__), templatefile)
        self.response.out.write(template.render(path, template_values))
    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)
            
        stuff = doo.getstuffbyid(self.request.get('stuffid'))
        if not stuff:
            self.error(404)

        if stuff.ownerid != player.playerid:
            self.error(404)

        liquidationvalue = formattar.getmoney(stuff.liquidaterate * stuff.price)
        
        template_values = {
            'player': player,
            'stuff': stuff,
            'liquidationvalue': liquidationvalue,
            }

        path = os.path.join(os.path.dirname(__file__), 'liquidatestuff.html')
        self.response.out.write(template.render(path, template_values))
Exemple #7
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))
    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)

        self.response.out.write(len(player.messages))
Exemple #9
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)
            
        friend = doo.getplayer(self.request.get('playerid'))
        player.addfriend(friend)
    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)
            
        investment = doo.getplayer(self.request.get('investmentid'))

        message = player.withdraw(investment, self.request.get('withdrawamount'))
    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)
            
        stuff = doo.getstuffbyid(self.request.get('stuffid'))
        stuff.setforsale(True)
        
        self.response.out.write(stuff.name)
Exemple #12
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)

        template_values = {"player": player}

        path = os.path.join(os.path.dirname(__file__), "search.html")
        self.response.out.write(template.render(path, template_values))
    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)
        
        hash = str(self.request.get('hashname'))
        if not hash:
            hash = 'player'
        
        self.response.out.write(doo.getdocumentation(hash).text)
Exemple #14
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)

        stuff = doo.getstuffbyid(self.request.get("stuffid"))

        template_values = {"stuff": stuff, "player": player}

        path = os.path.join(os.path.dirname(__file__), "editstuff.html")
        self.response.out.write(template.render(path, template_values))
Exemple #15
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)

        alerts = player.getalerts()
        content = ""
        for alert in alerts:
            content += '<div class="messageitem">%s</div>' % (alert)

        if content:
            self.response.out.write(content)
Exemple #16
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)
        
        if self.request.get('current'):
            self.response.out.write(player.bgselection)
        elif self.request.get('bgnum'):
            player.bgselection = int(self.request.get('bgnum'))
            player.put()
        else:
            self.error(500)
Exemple #17
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)
            
        investment = doo.getplayer(self.request.get('param'))
        
        levelprogress, nextlevel = investment.checklevel()
        
        occupation = investment.getoccupation()
        
        solidstuff = doo.getsolidstuffbyplayerid(investment.playerid)
        
        meinthem = doo.getplayerinvestment(player.playerid, investment.playerid)
        theminme = doo.getplayerinvestment(investment.playerid, player.playerid)
        
        if investment.playerid in player.friends:
            friend = True
        else:
            friend = False
            
        lastdividenddate = formattar.getprettydate(investment.lastdividenddate)
            
    	template_values = {
            'investment': investment,
            'friend': friend,
            'solidstuff': solidstuff,
            'lastdividenddate': lastdividenddate,
            'meinthem': meinthem,
            'theminme': theminme,
            'player': player,
            'occupation': occupation,
            'levelprogress': levelprogress,
            'nextlevel': nextlevel,
            }

        if player.mobile:
            templatefile = 'm_playerinfo.html'
        else:
            templatefile = 'playerinfo.html'
        path = os.path.join(os.path.dirname(__file__), templatefile)
        self.response.out.write(template.render(path, template_values))
    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)
            
        if self.request.get('mobile'):
            player.mobile = True
        elif self.request.get('normal'):
            player.mobile = False
        else:
            player.mobile = True
            
        player.put()
    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)
            
        stuff = doo.getstuffbyid(self.request.get('stuffid'))
        if not stuff:
            self.error(404)

        if stuff.ownerid != player.playerid:
            self.error(404)
            
        if not doo.liquidatestuff(stuff.stuffid):
            doo.makealert(player, 'Liquidation of %s failed' % (stuff.name))
Exemple #20
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)

        friends = player.getfriends()

        template_values = {"friends": friends, "player": player}

        if player.mobile:
            templatefile = "m_myfriends.html"
        else:
            templatefile = "myfriends.html"
        path = os.path.join(os.path.dirname(__file__), templatefile)
        self.response.out.write(template.render(path, template_values))
    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)
            
        stuff = doo.getstuffbyid(self.request.get('stuffid'))
        owner = doo.getplayer(stuff.ownerid)
        
    	template_values = {
            'stuff': stuff,
            'player': player,
            'owner': owner,
            }

        path = os.path.join(os.path.dirname(__file__), 'storebuystuff.html')
        self.response.out.write(template.render(path, template_values))
Exemple #22
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)

        stuff = doo.getstuffbyid(self.request.get("stuffid"))

        if not player.buystuff(stuff):
            if player.money <= stuff.price:
                doo.makealert(player, "Hey Mcfly, you don't have enough money to purchase this item")
            else:
                doo.makealert(player, "Darn it, something went wrong with that purchase.")

            self.response.out.write("0")  # fail
        else:
            self.response.out.write("1")  # success
Exemple #23
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)
            
        template_values = {
            'player': player,
            }


        if player.mobile:
            templatefile = 'm_paydividend.html'
        else:
            templatefile = 'paydividend.html'
        path = os.path.join(os.path.dirname(__file__), templatefile)
        self.response.out.write(template.render(path, template_values))
Exemple #24
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)

        results = False

        searchplayer = None
        if self.request.get("playername"):
            searchplayer = doo.getplayerbyname(self.request.get("playername"), ignorecase=True)
            results = True

        template_values = {"player": player, "searchplayer": searchplayer, "results": results}

        path = os.path.join(os.path.dirname(__file__), "search.html")
        self.response.out.write(template.render(path, template_values))
Exemple #25
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)
        
        if self.request.get('dividendamount'):
            divamount = float(self.request.get('dividendamount'))
        else:
            self.redirect(404)
        
        if divamount <= player.money and divamount:
            player.payoutdividendamount(float(divamount))
            return
        else:
            doo.makealert(player, "You don't have that much to pay out")
            self.error(404)
            return
    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)
            
        
        stuffname = self.request.get('param')
        if not stuffname:
            self.error(404)
            return
        
        solidstuff = doo.getsolidstuffbystuffname(stuffname)
        stuff = solidstuff.getstuff()
        
        numforsale = stuff.getforsaleminusplayer()
        totalcost = stuff.price * numforsale
        #playerstuff = player.getplayerstuffbystuffid(stuff.stuffid)
        
        #logging.info(stuff.getforsaleminusplayer())
        #logging.info(player.getplayerstuffbystuffid(stuff.stuffid))
        
        template_values = {
            'solidstuff': solidstuff,
            'player': player,
            'stuff': stuff,
            'totalcost': totalcost,
            'numforsale': numforsale,
            #'playerstuff': playerstuff,
            }

        if player.mobile:
            templatefile = 'm_buystuffinbulk.html'
        else:
            templatefile = 'buystuffinbulk.html'
        path = os.path.join(os.path.dirname(__file__), templatefile)
        self.response.out.write(template.render(path, template_values))
Exemple #27
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)
            
        messageprice = doo.getmessagepricedisplay()
        
        template_values = {
            'player': player,
            'messageprice': messageprice,
            }

        if player.mobile:
            templatefile = 'm_inbox.html'
        else:
            templatefile = 'inbox.html'
        path = os.path.join(os.path.dirname(__file__), templatefile)
        self.response.out.write(template.render(path, template_values))
Exemple #28
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)

        if self.request.get("playername"):
            name = " ".join(self.request.get("playername").split())
            name = name.strip()
            if validator.validateplayername(str(name)):
                if doo.getplayerbyname(name, ignorecase=True) and player.namenormal != str(name).upper():
                    doo.makealert(player, "Rats, that name is already taken")
                else:
                    if player.name != str(name):
                        # doo.makealert(player, 'Name changed to %s' % (str(name)))
                        player.name = str(name)
                        player.namenormal = player.name.upper()
            else:
                doo.makealert(
                    player, "Invalid player name. You can only use letters and there must be more than 2 letters."
                )
        if self.request.get("playerpercent"):
            if validator.validatepercent(self.request.get("playerpercent")):
                player.percent = round(float(self.request.get("playerpercent")), 2) / 100
            else:
                doo.makealert(player, "Invalid percent")
        if len(self.request.get("playerabout")) < 300:
            player.about = str(self.request.get("playerabout"))

        if self.request.get("playeravatar"):
            player.avatar = db.Blob(images.resize(self.request.get("playeravatar"), 100, 100))
            player.avatarsmall = db.Blob(images.resize(self.request.get("playeravatar"), 30, 30))

        player.put()

        self.redirect("/hastymoney#!frontpage")
Exemple #29
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)
            
        investment = doo.getplayer(self.request.get('param'))

        template_values = {
            'investment': investment,
            'player': player,
            }

        if player.mobile:
            templatefile = 'm_investnow.html'
        else:
            templatefile = 'investnow.html'
        path = os.path.join(os.path.dirname(__file__), templatefile)
        self.response.out.write(template.render(path, template_values))
    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)
        
        stuffname = self.request.get('param')
        if not stuffname:
            self.error(404)
            return
            
        stuff = doo.getstuffbyname(stuffname)
        
        solidstuff = doo.getsolidstuffbystuffname(stuffname)
        
        playerstuff = player.getplayerstuffbystuffid(stuff.stuffid)
        if stuff.total:
            ownershippercent = '%.2f' % (float(playerstuff.total) / float(stuff.total) * 100)
        else:
            ownershippercent = '0.00'
        
    	template_values = {
            'stuff': stuff,
            'player': player,
            'playerstuff': playerstuff,
            'ownershippercent': ownershippercent,
            'solidstuff': solidstuff,
            }

        if player.mobile:
            templatefile = 'm_storebystuffname.html'
        else:
            templatefile = 'storebystuffname.html'
        path = os.path.join(os.path.dirname(__file__), templatefile)
        self.response.out.write(template.render(path, template_values))