Пример #1
0
    def _process(self, params):
        token = params.get('token')
        skillID = params.get('skill_id')
        cost = params.get('costValue')
        cost = int(cost)
        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 player.costResource(ResourceType.gems,cost):
                heroSkillData = player.getSkillInfo(skillID)
                heroSkillData.last_use_time = GameTools.datetime2string(GameTools.getDatetimeNow() - datetime.timedelta(days=1))
            else:
                returnData = MessData(ErrorCode.resourceNotEnough)

        str = MessageTools.encode(returnData)

        self.write(str)
        self.finish()
        if player != None:
            playerDataManager.checkNeedSave2DB(player.player_id)
Пример #2
0
    def post(self):
        bodyData = self.request.body
        dictData = MessageTools.decode(bodyData)
        token = dictData.get('token')
        player = playerDataManager.getPlayerByToken(token)

        returnData = MessData()
        if player == None:
            returnData = MessData(ErrorCode.tokenOutData)
        elif player.getSkillInfo(7).skillLevel == 0 and player.getSkillInfo(0).skillLevel < static.pvp_level_limit:
            returnData = MessData(ErrorCode.pvpNOTUnlockNow)
        else:
            # Íæ¼Òconnect id¼ì²â
            connect_id = dictData.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

            player_id = player.player_id
            if not rankManager.checkPlayerInRanking(player_id):
                rankManager.addRank(player_id)
            if player.costResource(ResourceType.gems,10):
                player.last_challenge_datetime = GameTools.datetime2string(GameTools.getDatetimeNow() - datetime.timedelta(minutes = 20))
            else:
                returnData = MessData(ErrorCode.resourceNotEnough)
        str = MessageTools.encode(returnData)

        self.write(str)
        self.finish()
Пример #3
0
 def __init__(self,data):
     self.skillID = data[0]
     self.skillLevel = data[1]
     if data[2] == None or data[2] =="" or data[2] == " ":
         yesterday = datetime.datetime.now() - datetime.timedelta(days = 1)
         self.last_use_time = GameTools.datetime2string(yesterday)
     else:
         self.last_use_time = data[2]
Пример #4
0
 def createAccount(self,udid,name):
     tableName = 'player_base_info'
     fields = []
     values = []
     fields.append('playerid')
     fields.append('udid')
     fields.append('name')
     fields.append('last_cmd_time')
     self.player_max_id += 1
     playerid = self.server_id + self.player_max_id
     values.append(playerid)
     values.append(udid)
     values.append(name)
     timeNowStr = GameTools.datetime2string(datetime.datetime.now())
     values.append(timeNowStr)
     db_Manager.insertIntoTable(tableName,fields,values)
     self.updatePlayerMaxID(self.player_max_id)
Пример #5
0
    def loadSkills(self):
        tableName = "player_skill"
        fields = "skill_id,level,last_use_time"
        conditon = "player_id = %s" % self.player_id
        data = db_Manager.selectDataFromTable(tableName,fields,conditon)
        skillids = []
        for skillData in data:
            heroSkill = HeroSkillData(skillData)
            if heroSkill.skillID == 0 and heroSkill.skillLevel < 1:
                heroSkill.skillLevel = 1

            skillids.append(heroSkill.skillID)
            self.skills.append(heroSkill)

        for skillidInTable in range(8):
            if not skillidInTable in skillids:
                fields = []
                fields.append('player_id')
                fields.append('skill_id')
                fields.append('level')
                fields.append('last_use_time')
                values = []
                values.append(self.player_id)
                values.append(skillidInTable)
                if skillidInTable == 0:
                    values.append(1)
                else:
                    values.append(0)

                t_now =  GameTools.getDatetimeNow()
                t_ok = t_now- datetime.timedelta(days = 1)
                t_now_string = GameTools.datetime2string(t_ok)
                values.append(t_now_string)
                db_Manager.insertIntoTable(tableName,fields,values)

                skillData = []
                skillData.append(skillidInTable)
                if skillidInTable == 0:
                    skillData.append(1)
                else:
                    skillData.append(0)
                skillData.append(t_now_string)
                heroSkill = HeroSkillData(skillData)
                self.skills.append(heroSkill)