Exemplo n.º 1
0
    def verifyPVPFight(self,tap_count,crital_count, playerInfo,target_hp):
        # if tap_count > 30 * 60:
        #     return  False
        tap_count = 15 * 40
        # if tap_count > 100 and crital_count > tap_count * 0.99 :
        #     return  False  # critall verify closed now !!!

        if playerInfo.isUseSkillNow():
            return True

        partnerDPS = playerInfo.GetPartnerDPSSum()
        heroTapDMG = playerInfo.GetHeroDPS()



        # 只做最简单的验证,
        playerBuffList = playerInfo.pvpBuffs
        playerBuffs = {}
        for index in range(len(playerBuffList)):
            playerBuffs[index] = playerBuffList[index]
        buff21Value = playerBuffs.get(21,0)  # 对BOSS伤害增加
        buff11Value = playerBuffs.get(11,0)  # 战斗时间增加
        buff4Value = playerBuffs.get(4,0)  # 小伙伴攻速
        timeSeconds = 30 * (1 + buff11Value / 1000)

        tap_count = 15 * (timeSeconds + 10)
        buff2Value = playerBuffs.get(2,0)  # 英雄点击伤害增加
        buff5Value = playerBuffs.get(5,0)  # 所有小伙伴攻击力
        # partnerDPS = player.GetPartnerDPSSum()
        # heroTapDMG = player.GetHeroDPS()

        critalMin = gloabalBase.getValue("BaseCrital")
        critalMax = gloabalBase.getValue("CritalMax")
        critalbuffValue = playerBuffs.get(10,0)
        critalbuffValue += critalMin
        critalbuffValue = min(critalbuffValue,critalMax)

        critalBaseRate = gloabalBase.getValue("BaseCritalRate")
        critalRate = critalBaseRate + critalbuffValue / 1000 *10
        critalDMG = heroTapDMG * critalRate * crital_count

        hertHp = heroTapDMG * (1 +buff2Value/ 1000) * tap_count + partnerDPS * \
                                                                  (1+ buff4Value / 1000) * (1+ buff5Value / 1000) * timeSeconds + critalDMG
        hertHp = hertHp *(1 + buff21Value / 1000)

        # return hertHp * 10 > target_hp #colose the pvp fight virify.
        return  True
Exemplo n.º 2
0
    def post(self):
        bodyData = self.request.body
        dictData = MessageTools.decode(bodyData)
        udid = dictData['udid']
        name = dictData['name']
        cdkey = dictData.get('cdkey', '')
        returnData = MessData()
        player = None
        open_activate = True

        # 账户验证
        name = name.strip()
        contains = name.find(';') >= 0 or name.find(' ') > 0 or len(name) == 0
        charCount = len(name)
        max_length = gloabalBase.getValue('MAX_LENGTH_OF_NAME')
        max_length = int(max_length)

        # 长度验证
        if contains or charCount > max_length:
            returnData = MessData(ErrorCode.name_illegal)

        # 非法字符验证
        elif illegalWordManager.ContainIllegalWord(name):
            returnData = MessData(ErrorCode.name_illegal)

        # 是否已被使用验证
        elif not playerDataManager.isSign(udid):
            if playerDataManager.isNameUsed(name):
                returnData = MessData(ErrorCode.name_used)
            else:
                playerDataManager.createAccount(udid,name)
                player = playerDataManager.loginUseUidd(udid)
                player.connect_id = playerDataManager.create_connect_id(player.player_id)       # 重新生成连接ID
                player.revial = 1
                returnData.data = player
                player.server_date_time = GameTools.getDateTimeNowString()

        # 通过
        else:
            player = playerDataManager.loginUseUidd(udid)
            player.server_date_time = GameTools.getDateTimeNowString()
            player.connect_id = playerDataManager.create_connect_id(player.player_id)       # 重新生成连接ID
            returnData.data = player
            player.calculateOfflineResource()

        message = MessageTools.encode(returnData,False)

        if player != None:                          # 重置离线奖励
            player.offlineCash = 0

            # 使用cdkey
            if open_activate is True:
                cdkey_obj.is_use = True
                cdkey_obj.usedtime = datetime.datetime.now()
                cdkey_obj.use_udid = udid
                cdkey_obj.save()

        self.write(message)
        self.finish()
Exemplo n.º 3
0
    def updateDailyData(self):
        dateTimeNow = GameTools.getDatetimeNow()
        lastDateTimeNow = GameTools.string2datetime(self.daily_datetime)
        if dateTimeNow.year != lastDateTimeNow.year or dateTimeNow.month != lastDateTimeNow.month or dateTimeNow.day != lastDateTimeNow.day:
            self.daily_datetime = GameTools.getDateTimeNowString()

            self.chanllenge_num = int(gloabalBase.getValue('daily_challenge_num'))
            self.buy_del_challenge_cd_num = 0
            self.add_chanllenge_num = 0
            self.random_reward_num = 0
    def _process(self, params):
        token = params.get('token')
        reward_type = params.get('reward_type')
        addValue = params.get('add_value')
        addValue = int (addValue)
        player = playerDataManager.getPlayerByToken(token)
        returnData = MessData()
        if player == None:
            returnData = MessData(ErrorCode.tokenOutData)
        else:
            # Íæ¼Òconnect id¼ì²â
            connect_id = params.get('connect_id', '')    # Íæ¼ÒÁ¬½Óid
            ck_connectid = playerDataManager.check_connect_id(obj=player, post_connect_id=connect_id)
            if ck_connectid[0] is False:
                returnData = MessData(ck_connectid[1])
                self.write(MessageTools.encode(returnData))
                self.finish()
                return

            value = randomRewardManager.getValue(reward_type)
            # verify addValue at here!

            value = addValue
            max_time = gloabalBase.getValue('RandomRewardDailyMaxTimes')
            player.refreshTimeData()
            if player.random_reward_num < max_time:

                if reward_type ==1 or reward_type == 3:
                    player.addResource(ResourceType.cash,value)
                elif reward_type == 2 or reward_type == 4:
                    player.addResource(ResourceType.gems,value)
                player.random_reward_num += 1

            else:
                returnData = MessData(ErrorCode.resourceNotEnough)
        str = MessageTools.encode(returnData)

        self.write(str)
        self.finish()
        if player != None:
            playerDataManager.checkNeedSave2DB(player.player_id)
Exemplo n.º 5
0
    def post(self):
        bodyData = self.request.body
        params = MessageTools.decode(bodyData)
        token = params.get('token')

        player = playerDataManager.getPlayerByToken(token)
        returnData = MessData()

        # 玩家登录检测
        if player == None:
            returnData = MessData(ErrorCode.tokenOutData)
            self.write(MessageTools.encode(returnData))
            self.finish()
            return

        # 玩家connect id检测
        connect_id = params.get('connect_id', '')    # 玩家连接id
        ck_connectid = playerDataManager.check_connect_id(obj=player, post_connect_id=connect_id)
        if ck_connectid[0] is False:
            returnData = MessData(ck_connectid[1])
            self.write(MessageTools.encode(returnData))
            self.finish()
            return

        # 钻石检测
        cost = gloabalBase.getValue('use_skill_cost')
        if player.gems < cost:
            returnData = MessData(ErrorCode.resourceNotEnough)
            self.write(MessageTools.encode(returnData))
            self.finish()
            return

        player.gems -= cost

        str = MessageTools.encode(returnData)
        self.write(str)
        self.finish()

        if player != None:
            playerDataManager.checkNeedSave2DB(player.player_id)
Exemplo n.º 6
0
    def _process(self, params):
        token = params.get('token')
        drawtimes = params.get('drawtimes',1)
        free_draw = params.get('free_draw',0)
        player = playerDataManager.getPlayerByToken(token)
        returnData = MessData()

        if player == None:
            returnData = MessData(ErrorCode.tokenOutData)
        else:
            # Íæ¼Òconnect id¼ì²â
            connect_id = params.get('connect_id', '')    # Íæ¼ÒÁ¬½Óid
            ck_connectid = playerDataManager.check_connect_id(obj=player, post_connect_id=connect_id)
            if ck_connectid[0] is False:
                returnData = MessData(ck_connectid[1])
                self.write(MessageTools.encode(returnData))
                self.finish()
                return

            if free_draw == 1:
                if GameTools.getDatetimeNow() < GameTools.string2datetime(player.last_free_draw_datetime)  + datetime.timedelta(hours = 23):
                    returnData = MessData(ErrorCode.skillincd)
                    str = MessageTools.encode(returnData)

                    self.write(str)
                    self.finish()
                    if player != None:
                        playerDataManager.checkNeedSave2DB(player.player_id)
                    return
            cost = 0
            if drawtimes == 1:
                if free_draw == 0:
                    cost = int(gloabalBase.getValue('draw1cost'))
            else:
                cost = int(gloabalBase.getValue('draw10cost'))

            if player.costResource(ResourceType.gems,cost):
                if free_draw == 1:
                    player.last_free_draw_datetime = GameTools.getDateTimeNowString()

                rewards = []
                if drawtimes == 1:
                    rewards = drawRewardManager.draw1Reward(player.game_level)
                else:
                    rewards = drawRewardManager.draw10Reward(player.game_level)

                for resourceAndVlue in rewards:
                    itemid = resourceAndVlue.itemid
                    value = resourceAndVlue.value
                    item = itemTable.getItemConstInfo(itemid)
                    resourceId = item.buftype
                    player.addResource(resourceId,value)

                    if item.quliaty > 3:
                        drawHistoryManager.pushIntoHistory(player.name,resourceAndVlue)
                returnData.data = rewards
            else:
                returnData = MessData(ErrorCode.resourceNotEnough)
        str = MessageTools.encode(returnData)

        self.write(str)
        self.finish()
        if player != None:
            playerDataManager.checkNeedSave2DB(player.player_id)