示例#1
0
    def post(self):
        playerid = self.request.get('playerid')
        amount = self.request.get('amount') # player.getnuminvestors()
        lastid = self.request.get('lastid')
        
        player = doo.getplayer(playerid)
        amount = round(float(amount), 2)
        
        numpi = 10
        
        query = PlayerInvestment.all()
        query.filter("investmentid =", player.playerid)
        if lastid:
            query.filter("playerid >", lastid)
        query.order("playerid")
        playerinvestments = query.fetch(numpi)
        
        for pi in playerinvestments:
            if not pi.amount:
                continue
            investor = doo.getplayer(pi.playerid)
            payout = round((player.money * player.growth) / amount, 2)

            investor.money += payout
            investor.money = round(investor.money, 2)
            
            investor.totalinvestedamount += payout
            investor.totalinvestedamount = round(investor.totalinvestedamount, 2)
            
            pi.amount += payout
            pi.amount = round(pi.amount, 2)
            
            player.money += payout
            player.money = round(player.money, 2)
            
            player.totalinvestorsamount += payout
            player.totalinvestorsamount = round(player.totalinvestorsamount, 2)

            pi.put()
            investor.put()
            
            #doo.message(investor, 'You received a dividend of %s from %s' % (payout, player.name))
        
        player.put()
        
        if len(playerinvestments) >= numpi:
            lastid = playerinvestments[-1].playerid
            taskqueue.add(url='/tasks/payoutgrowth', params={'amount': amount, 'playerid': playerid, 'lastid':lastid})
示例#2
0
    def post(self):
        playerid = self.request.get('playerid')
        amount = self.request.get('amount')
        lastid = self.request.get('lastid')
        
        player = doo.getplayer(playerid)
        amount = round(float(amount), 2)
        
        numpi = 10
        
        query = PlayerInvestment.all()
        query.filter("investmentid =", player.playerid)
        if lastid:
            query.filter("playerid >", lastid)
        query.order("playerid")
        playerinvestments = query.fetch(numpi)
        
        for pi in playerinvestments:
            if not pi.amount:
                continue
            investor = doo.getplayer(pi.playerid)
            payout = round(float(float((float(pi.amount) / float(player.totalinvestorsamount)))) * float(amount), 2)
            #tempplayer = doo.getplayer(pi.playerid)
            investor.money += payout
            investor.money = round(investor.money, 2)
            player.money -= payout
            player.money = round(player.money, 2)

            player.lastdividendamount += payout

            investor.put()
            doo.message(investor, 'You received a dividend of %s from %s' % (payout, player.name))
        
        if player.totalinvestorsamount > 0 and player.lastdividendamount > 99:
            player.points += 1
        
        player.put()
        
        if len(playerinvestments) < numpi:
            if player.solid:
                player.taxes = 0.0
                player.put()
        else:
            lastid = playerinvestments[-1].playerid
            taskqueue.add(url='/tasks/dividendpayer', params={'amount': amount, 'playerid': playerid, 'lastid':lastid})