コード例 #1
0
 def getShopNpcInfo(self, placeId):
     '''获取商店npc信息'''
     shopNpcInfo = loader.get('shop', 'type', placeId, ['description'])
     shopNpcInfo = shopNpcInfo[0]
     npcId = loader.get('place_npc', 'placeId', placeId,
                        ['npcId'])[0]['npcId']
     npcImage = loader.getById('npc', npcId, ['image'])['image']
     shopNpcInfo['image'] = npcImage
     shopNpcInfo['id'] = npcId
     return shopNpcInfo
コード例 #2
0
 def enterInstance(self, placeId):
     '''进入副本'''
     id = self._owner.baseInfo.id
     energy = self._owner.attribute.getEnergy()
     location = placeId
     instanceId = self._instanceId
     instanceLayerId = self._instancePlaceId
     result = False
     status = self._owner.baseInfo.getStatus()
     if status != u'正常':
         return False, u"您已经处于" + status + u"状态"
     placeInfo = loader.getById('place', placeId, '*')
     if placeInfo['levelRequire'] > self._owner.level.getLevel():
         return False, u'您的级别不够,需要达到 %d 级才能进入' % placeInfo['levelRequire']
     if instanceId <> -1:
         if location <> instanceId:
             energy -= 10
             if energy < 0:
                 return False, u'活力不足'
             if self._enterInstanceCount >= self.MAXENTERCOUNT:
                 return False, u'今日进入副本次数已经达到两次,不可重新进入新副本'
             instanceLayers = loader.get('instance', 'entryPlace', location, ['layers'])[0]['layers']
             layers = loader.getById('instance_layer', instanceLayers, ['place'])['place']
             instanceLayerId = int(layers.split(';')[0])
             attrs = {'instanceId':location, 'instanceLayerId':instanceLayerId}
             result = dbaccess.updatePlayerInstanceProgressRecord(attrs, id)
             if result:
                 dbaccess.updatePlayerInfo(id, {'energy':energy, 'enterInstanceCount':self._enterInstanceCount + 1})
                 self.init()
         else:
             result = True
     else:
         layers = loader.get('instance', 'entryPlace', location, ['layers'])
         if len(layers) < 0:
             return False, u'没有相应的副本层'
         layers = layers[0]['layers']
         if layers:
             energy -= 10
             if energy < 0:
                 return False, u'活力不足'
             places = loader.getById('instance_layer', layers, ['place'])['place'].split(';')
             instanceLayerId = int(places[0])
             props = [0, id, location, instanceLayerId, 0]
             result = dbaccess.insertPlayerInstanceProgressRecord(props)
             if result:
                 dbaccess.updatePlayerInfo(id, {'energy':energy, 'enterInstanceCount':1})
                 self._enterInstanceCount = 1
             self.init()
         else:
             return False, u'没有相应的副本层'
     self._owner.attribute.setEnergy(energy)
     self._owner.baseInfo.setLocation(instanceLayerId)
     return result, ''
コード例 #3
0
    def getLearnableSkills(self):
        '''获取玩家可学技能信息'''
        learnableSkillsInfo = []

        profession = self._owner.profession.getProfession()
        skills = loader.get('skill', 'skillProfession', profession, '*')
        for skill in skills:
            skill['addEffectNames'] = []
            effects = []
            canLearn = self.checkLearnSkillRequire(skill, False)[0]
            if canLearn:
                group = skill["groupType"]
                learened = group in self.learned_skillpool
                canLearn = (not learened and skill["level"] == 1) or \
                           (learened and skill["level"] == self.learned_skillpool[group]["skillLevel"] + 1)
                if canLearn:
                    for effectId in skill['addEffect'].split(';'):
                        if int(effectId) <> -1:
                            effectInfo = loader.getById(
                                'effect', int(effectId),
                                ['name', 'description'])
                            effects.append(effectInfo['description'])
                            skill['addEffectNames'].append(effectInfo['name'])
                    learnableSkillsInfo.append({
                        'skillInfo': skill,
                        'skillLevel': skill['level'],
                        'effects': effects
                    })

        return learnableSkillsInfo
コード例 #4
0
    def getProfessionAllSkills(self):
        '''获取玩家当前职业的所有技能'''
        allSkills = []
        profession = self._owner.profession.getProfession()

        skills = loader.get('skill', 'skillProfession', profession, '*')
        for skill in skills:
            skill['addEffectNames'] = []
            group = skill["groupType"]
            learened = group in self.learned_skillpool

            display = (not learened and skill["level"] == 1) or \
                    (learened and skill["level"] == self.learned_skillpool[group]["skillLevel"] + 1) or \
                    (learened and skill["maxLevel"] == skill["level"] and skill["maxLevel"] == \
                       self.learned_skillpool[group]["skillLevel"])
            if display:
                effects = []
                splitEffects = skill["addEffect"].split(';')
                if (len(splitEffects) > 0 and int(splitEffects[0]) != -1):
                    for i in range(0, len(splitEffects)):
                        effectInfo = loader.getById('effect',
                                                    int(splitEffects[i]),
                                                    ['name', 'description'])
                        effects.append(effectInfo['description'])
                        skill['addEffectNames'].append(effectInfo['name'])

                allSkills.append({
                    'skillInfo': skill,
                    'skillLevel': skill['level'],
                    'effects': effects
                })

        return allSkills
コード例 #5
0
    def getProfessionAllSkills(self):
        '''获取玩家当前职业的所有技能'''
        allSkills = []
        profession = self._owner.profession.getProfession()

        skills = loader.get('skill', 'skillProfession', profession, '*')
        for skill in skills:
            skill['addEffectNames'] = []
            group = skill["groupType"]
            learened = group in self.learned_skillpool;

            display = (not learened and skill["level"] == 1) or \
                    (learened and skill["level"] == self.learned_skillpool[group]["skillLevel"] + 1) or \
                    (learened and skill["maxLevel"] == skill["level"] and skill["maxLevel"] == \
                       self.learned_skillpool[group]["skillLevel"])
            if display:
                effects = []
                splitEffects = skill["addEffect"].split(';')
                if (len(splitEffects) > 0 and int(splitEffects[0]) != -1):
                    for i in range(0, len(splitEffects)):
                        effectInfo = loader.getById('effect', int(splitEffects[i]), ['name', 'description'])
                        effects.append(effectInfo['description'])
                        skill['addEffectNames'].append(effectInfo['name'])

                allSkills.append({'skillInfo':skill, 'skillLevel':skill['level'], 'effects':effects})

        return allSkills
コード例 #6
0
    def commitQuest(self, questId):
        '''提交任务'''
        id = self._owner.baseInfo.id

        questTemlateId = dbaccess.getQuestTemplateByQuestId(questId)
        result = self.isSatifyProgressingQuestGoals(questTemlateId)
        if not result:
            return {'result':result, 'reason':u'该任务尚未达到目标,不能完成'}
        #收集型删除任务物品
        questgoals = loader.get('questgoal', 'questId', questTemlateId, ['itemId', 'itemCount'])
        for questgoal in questgoals:
            if questgoal['itemCount'] > 0:
                dbaccess.deleteCollectionQuestItems(questgoal['itemId'], id, questgoal['itemCount'])

        dbaccess.operateForCommitQuest(questId,id)

        record = dbaccess.getQuestRecordById(questId)
        templateInfo = loader.getById('quest_template', record[1], ['coinBonus', 'type', 'expBonus'])
        coin = self._owner.finance.getCoin() + templateInfo['coinBonus']
        exp = self._owner.level.getExp() + templateInfo['expBonus']
        self._owner.finance.setCoin(coin)
        self._owner.level.setExp(exp)
        professionStage = int(self._owner.profession.getProfessionStage())
        attrs = {'coin':coin, 'exp':exp}
        if templateInfo['type'] == 2:
            #对active_reward_quest表的修改;赏金任务物品奖励持久化
            dbaccess.updateTempActiveRewardQuestByQuestTemplateId(questTemlateId, id, {'isFinish':1, 'isLock':0})
        elif templateInfo['type'] == 4:
            #转职任务
            professionStage += 1
            attrs['professionStage'] = professionStage
        dbaccess.updatePlayerInfo(self._owner.baseInfo.id, attrs)
        self._owner.profession.setProfessionStage(professionStage)
        currentProfessionStageIndex = int(self._owner.profession.getProfessionStage()) - 1
        #奖励任务奖励物品,放入玩家临时包裹蓝中
        if record[6] <> -1:
            item = dbaccess.getItemInfo(record[6])
            self._owner.pack.putOneItemIntoTempPackage(item)
            pushMessage(str(self._owner.baseInfo.id), 'newTempPackage')
            
        self._owner.pack.setTempPackage()
        self._owner.pack.setPackage()

        self.setProgressingQuests()
        if templateInfo['type'] == 2:
            pushMessage(str(self._owner.baseInfo.id), 'questFinish');
        self._owner.level.updateLevel()
        exp = self._owner.level.getExp()
        maxExp = self._owner.level.getMaxExp()
        return {'result':True, 'data':{'exp':exp,'maxExp':maxExp, 'coin':coin, \
                                      'currentProfessionStageIndex':currentProfessionStageIndex}}
コード例 #7
0
def getBrotherPlaces(placeId, player):
    '''获取同级兄弟地点'''
    parent = loader.getById('place', placeId, ['parentId'])
    if not parent:
        return
    parentId = parent['parentId']
    if parentId == -1:
        return
    brothers = loader.get('place', 'parentId', parentId, '*')
    brotherList = []
    for elm in brothers:
        if elm['id'] == player.baseInfo.id:
            continue
        brotherList.append(elm)
    return brotherList
コード例 #8
0
ファイル: SceneUtil.py プロジェクト: freedream520/sanguogame
def getBrotherPlaces(placeId, player):
    '''获取同级兄弟地点'''
    parent = loader.getById('place', placeId, ['parentId'])
    if not parent:
        return
    parentId = parent['parentId']
    if parentId == -1:
        return
    brothers = loader.get('place', 'parentId', parentId, '*')
    brotherList = []
    for elm in brothers:
        if elm['id'] == player.baseInfo.id:
            continue
        brotherList.append(elm)
    return brotherList
コード例 #9
0
 def getShopItems(self, placeId):
     '''获取商店物品'''
     shopInfo = loader.get('shop', 'type', placeId, '*')[0]
     count = shopInfo['count']
     list = []
     for i in range(0, count):
         item = self.getOneShopItem(shopInfo)
         #            k = 0
         while not item:
             #                if k==5:
             #                    break
             #                k += 1
             item = self.getOneShopItem(shopInfo)
         if item:
             list.append(item)
     return list
コード例 #10
0
def getMapPlaceInfo(placeId):
    '''获取区域地图详细信息;list中第一项为区域信息,后面的均为其子地点'''
    placeInfo = loader.getById('place', placeId, '*')
    if not placeInfo:
        return
    regionsList = []
    regionId = placeInfo['regionId']
    if regionId <> -1:
        regionInfo = loader.getById('place', regionId, '*')
        regionsList.append(regionInfo)
    else:
        regionId = placeInfo['id']
    places = loader.get('place', 'regionId', regionId, '*')
    for place in places:
        if place['type'] == u'地点':
            regionsList.append(place)
    return regionsList
コード例 #11
0
ファイル: SceneUtil.py プロジェクト: freedream520/sanguogame
def getMapPlaceInfo(placeId):
    '''获取区域地图详细信息;list中第一项为区域信息,后面的均为其子地点'''
    placeInfo = loader.getById('place', placeId, '*')
    if not placeInfo:
        return
    regionsList = []
    regionId = placeInfo['regionId']
    if regionId <> -1:
        regionInfo = loader.getById('place', regionId, '*')
        regionsList.append(regionInfo)
    else:
        regionId = placeInfo['id']
    places = loader.get('place', 'regionId', regionId, '*')
    for place in places:
        if place['type'] == u'地点':
            regionsList.append(place)
    return regionsList
コード例 #12
0
 def init(self):
     id = self._owner.baseInfo.id
     record = dbaccess.getPlayerInstanceProgressRecord(id)
     if record:
         if record[2] != 0:
             self._instanceId = record[2]
             instanceInfo = loader.get('instance', 'entryPlace', record[2], ['layers'])[0]
             self._instanceName = loader.getById('place', record[2], ['name'])['name']
             self._instancePlaceId = record[3]
             self._instancePlaceName = loader.getById('place', record[3], ['name'])['name']
             if record[4] == 0:
                 self._isInstanceLocked = False
             else:
                 self._isInstanceLocked = True
             places = loader.getById('instance_layer', instanceInfo['layers'], ['place'])['place'].split(';')
             for elm in places:
                 elm = int(elm)
                 self._instanceLayers.append(elm)
コード例 #13
0
    def getRecievableQuestDetails(self, questTemplateId):
        '''获取可接任务详细信息'''
        templateInfo = loader.getById('quest_template', questTemplateId, '*')

        templateInfo = self.wrapRecievableQuestObject(templateInfo)
        questgoals = list(loader.get('questgoal', 'questId', questTemplateId, ['id', 'itemId', 'itemCount', 'killCount', 'npc']))
        for questgoal in questgoals:
            if questgoal['itemId'] <> -1:
                itemName = loader.getById('item_template', questgoal['itemId'], ['name'])['name']
            else:
                itemName = ''
            if questgoal['npc'] <> -1:
                npcNameInfo = loader.getById('npc', questgoal['npc'], ['name'])
                if npcNameInfo:
                    npcName = npcNameInfo['name']
                else:
                    npcName = u'无'
            else:
                npcName = ''
            questgoal['itemName'] = itemName
            npcInfo = {'id':questgoal['npc'], 'name':npcName}
            questgoal['npcInfo'] = npcInfo
            npcInfo = self._getQuestNpcInfo(questgoal['npc'], npcInfo)
            questgoal['parentPlaceList'] = self.getFullPlaceList(npcInfo)

        if templateInfo['dropConfig'] != -1:
            result = dbaccess.selectQuestItem(self._owner.baseInfo.id, questTemplateId)
            if result:
                itemId = result[0]
            else:
                dropItem = self._owner.dropping.getItemByDropping(templateInfo['dropConfig'])[0]
                if dropItem:
                    itemId = dropItem[0]
                    dbaccess.insertQuestTempItem(self._owner.baseInfo.id, questTemplateId, itemId)

            templateInfo['itemBonus'] = self.getQuestItemBouns(itemId)

        templateInfo['questgoals'] = questgoals
        templateInfo['questType'] = 'receieval'
        return templateInfo
コード例 #14
0
 def init(self):
     id = self._owner.baseInfo.id
     record = dbaccess.getPlayerInstanceProgressRecord(id)
     if record:
         if record[2] != 0:
             self._instanceId = record[2]
             instanceInfo = loader.get('instance', 'entryPlace', record[2],
                                       ['layers'])[0]
             self._instanceName = loader.getById('place', record[2],
                                                 ['name'])['name']
             self._instancePlaceId = record[3]
             self._instancePlaceName = loader.getById(
                 'place', record[3], ['name'])['name']
             if record[4] == 0:
                 self._isInstanceLocked = False
             else:
                 self._isInstanceLocked = True
             places = loader.getById('instance_layer',
                                     instanceInfo['layers'],
                                     ['place'])['place'].split(';')
             for elm in places:
                 elm = int(elm)
                 self._instanceLayers.append(elm)
コード例 #15
0
    def getLearnableSkills(self):
        '''获取玩家可学技能信息'''
        learnableSkillsInfo = []

        profession = self._owner.profession.getProfession()
        skills = loader.get('skill', 'skillProfession', profession, '*')
        for skill in skills:
            skill['addEffectNames'] = []
            effects = []
            canLearn = self.checkLearnSkillRequire(skill, False)[0]
            if canLearn:
                group = skill["groupType"]
                learened = group in self.learned_skillpool;
                canLearn = (not learened and skill["level"] == 1) or \
                           (learened and skill["level"] == self.learned_skillpool[group]["skillLevel"] + 1)
                if canLearn:
                    for effectId in skill['addEffect'].split(';'):
                        if int(effectId) <> -1:
                            effectInfo = loader.getById('effect', int(effectId), ['name', 'description'])
                            effects.append(effectInfo['description'])
                            skill['addEffectNames'].append(effectInfo['name'])
                    learnableSkillsInfo.append({'skillInfo':skill, 'skillLevel':skill['level'], 'effects':effects})

        return learnableSkillsInfo
コード例 #16
0
def getPlaceNpcs(placeId, player):
    '''获取场景npc列表'''
    characterId = player.baseInfo.id
    npc_place_list = []  #某一场景对应的所有npc模版信息列表
    place_npc_list = loader.get('place_npc', 'placeId', placeId,
                                ['npcId', 'questId'])
    quest_npc = {}  #{'{questTemplateId}':npcId}
    for elm in place_npc_list:
        #刷boss怪,根据有无boss任务
        progressingQuestList = player.quest.getProgressingRecordList()
        bossQuestIdList = []
        flag = True
        n = 0
        if elm['questId'] <> u'-1':
            tempList = elm['questId'].split(';')
            for element in tempList:
                element = int(element)
                bossQuestIdList.append(element)
            for progressingQuest in progressingQuestList:
                isBreak = False
                if progressingQuest['questTemplateId'] in bossQuestIdList:
                    sequentialGoal = loader.getById(
                        'quest_template', progressingQuest['questTemplateId'],
                        ['sequentialGoal'])['sequentialGoal']
                    if sequentialGoal == 0:  #非线性显示
                        break
                    else:
                        m = 0
                        progresses = progressingQuest['progressesDetails']
                        for progress in progresses:
                            if progress['killCount'] > 0:
                                if progress['currentKillCount'] == progress[
                                        'killCount']:
                                    if elm['npcId'] == progress['npcInfo'][
                                            'id']:
                                        m = 1
                                        break
                                    else:
                                        continue
                                else:
                                    if elm['npcId'] == progress['npcInfo'][
                                            'id']:
                                        isBreak = True
                                        flag = True
                                    break
                            elif progress['itemCount'] > 0:
                                itemId = loader.getById(
                                    'questgoal', progress['questgoalId'],
                                    ['itemId'])['itemId']
                                count = dbaccess.getCollectionQuestItemCount(
                                    itemId, characterId)
                                if count == progress['itemCount']:
                                    if elm['npcId'] == progress['npcInfo'][
                                            'id']:
                                        m = 1
                                        break
                                    else:
                                        continue
                                else:
                                    if elm['npcId'] == progress['npcInfo'][
                                            'id']:
                                        isBreak = True
                                        flag = True
                                    break
                            else:
                                if progress['hasTalkedToNpc'] == 1:
                                    if elm['npcId'] == progress['npcInfo'][
                                            'id']:
                                        m = 1
                                        break
                                    else:
                                        continue
                                else:
                                    if elm['npcId'] == progress['npcInfo'][
                                            'id']:
                                        isBreak = True
                                        flag = True
                                    break
                        if m == 1:
                            n = 1
                            break
                else:
                    flag = False
                    continue
                if isBreak:
                    break
        if n == 1:
            continue
        if flag:
            k = 0
            globalQuestId = 0
            for questId in bossQuestIdList:
                questId = str(questId)
                if quest_npc.has_key(str(questId)) or not quest_npc.has_key(
                        '0'):  #如果同任务的boss怪物已经有了,则此怪物不加入列表
                    k = 1
                    break
                globalQuestId = questId
            if k == 1:
                continue
            if len(progressingQuestList) == 0:
                if elm['questId'] == u'-1':
                    npcInfo = loader.getById('npc', elm['npcId'], '*')
                    if npcInfo == None:
                        continue
                    npc_place_list.append(npcInfo)
                    quest_npc[str(globalQuestId)] = elm['npcId']
            else:
                npcInfo = loader.getById('npc', elm['npcId'], '*')
                if npcInfo == None:
                    continue
                npc_place_list.append(npcInfo)
                quest_npc[str(globalQuestId)] = elm['npcId']
    return npc_place_list
コード例 #17
0
    def getOneShopItem(self, shopInfo):
        '''得到一个商店物品'''
        negtiveDelta = (self._owner.level.getLevel() -
                        shopInfo['qualityLevelNegtiveDelta']) / 3
        positiveDelta = (self._owner.level.getLevel() +
                         shopInfo['qualityLevelPositiveDelta']) / 3
        qualityLevel = random.randint(negtiveDelta, positiveDelta)
        goodTypes = shopInfo['goodsType'].split(';')

        types = []
        tempTypes1 = []  #存放>1000的临时数组
        tempTypes2 = []  #存放<=1000临时数组
        for elm in goodTypes:
            elm = int(elm)
            types.append(elm)
            if elm > 1000:
                tempTypes1.append(elm)
            else:
                tempTypes2.append(elm)
        for type1 in tempTypes1:
            for type2 in tempTypes2:
                type = type1 + type2
                types.append(type)

        itemTemplateList = loader.get('item_template', 'qualityLevel',
                                      qualityLevel, '*')
        shopItemList = []
        for itemTemplate in itemTemplateList:
            if itemTemplate['type'] in types:
                shopItemList.append(itemTemplate)
        if len(shopItemList) == 0:
            return None
        r = random.randint(0, len(shopItemList))
        if r > 0:
            r -= 1
        itemTemplate = shopItemList[r]
        #计算附加属性
        exAttrCount = self.getShopItemExtraAttrCount(shopInfo)
        extraAttributes = []
        name = u''
        for i in range(0, exAttrCount):
            attribute = self.getShopItemExtraAttr(shopInfo)
            flag = 0
            for elm in extraAttributes:
                if elm['id'] == attribute['id']:
                    attribute = self.getShopItemExtraAttr(shopInfo)
                    continue
                else:
                    flag += 1
                    continue
            if flag == len(extraAttributes):
                extraAttributes.append(attribute)
            name += attribute['name']

        info = {}
        info['itemTemplateInfo'] = itemTemplate
        info['extraAttributeList'] = extraAttributes
        bindType = itemTemplate['bind']
        bindTypeDesc = u''
        if bindType == 0:
            bindTypeDesc = u"非绑定物品"
        elif bindType == 1:
            bindTypeDesc = u"拾取即绑定"
        elif bindType == 2:
            bindTypeDesc = u"装备即绑定"
        else:
            bindTypeDesc = u""
        info['bindType'] = bindTypeDesc
        if name == u'':
            info['name'] = itemTemplate['name']
        else:
            info['name'] = name + "的" + itemTemplate['name']
        #价格
        extraAttribute = ''
        for elm in extraAttributes:
            extraAttribute += str(elm['id']) + ","
        info['sellPrice'] = self.getShopItemPrice(itemTemplate['id'],
                                                  extraAttribute)
        #层叠数
        if itemTemplate['stack'] <> -1:
            info['stack'] = 10
        else:
            info['stack'] = 1
        return info
コード例 #18
0
ファイル: SceneUtil.py プロジェクト: freedream520/sanguogame
def getPlaceNpcs(placeId, player):
    '''获取场景npc列表'''
    characterId = player.baseInfo.id
    npc_place_list = []#某一场景对应的所有npc模版信息列表
    place_npc_list = loader.get('place_npc', 'placeId', placeId, ['npcId', 'questId'])
    quest_npc = {}#{'{questTemplateId}':npcId}
    for elm in place_npc_list:
        #刷boss怪,根据有无boss任务
        progressingQuestList = player.quest.getProgressingRecordList()
        bossQuestIdList = []
        flag = True
        n = 0
        if elm['questId'] <> u'-1':
            tempList = elm['questId'].split(';')
            for element in tempList:
                element = int(element)
                bossQuestIdList.append(element)
            for progressingQuest in progressingQuestList:
                isBreak = False
                if progressingQuest['questTemplateId'] in bossQuestIdList:
                    sequentialGoal = loader.getById('quest_template', progressingQuest['questTemplateId'], ['sequentialGoal'])['sequentialGoal']
                    if sequentialGoal == 0:#非线性显示
                        break
                    else:
                        m = 0
                        progresses = progressingQuest['progressesDetails']
                        for progress in progresses:
                            if progress['killCount'] > 0:
                                if progress['currentKillCount'] == progress['killCount']:
                                    if elm['npcId'] == progress['npcInfo']['id']:
                                        m = 1
                                        break
                                    else:
                                        continue
                                else:
                                    if elm['npcId'] == progress['npcInfo']['id']:
                                        isBreak = True
                                        flag = True
                                    break
                            elif progress['itemCount'] > 0:
                                itemId = loader.getById('questgoal', progress['questgoalId'], ['itemId'])['itemId']
                                count = dbaccess.getCollectionQuestItemCount(itemId, characterId)
                                if count == progress['itemCount']:
                                    if elm['npcId'] == progress['npcInfo']['id']:
                                        m = 1
                                        break
                                    else:
                                        continue
                                else:
                                    if elm['npcId'] == progress['npcInfo']['id']:
                                        isBreak = True
                                        flag = True
                                    break
                            else:
                                if progress['hasTalkedToNpc'] == 1:
                                    if elm['npcId'] == progress['npcInfo']['id']:
                                        m = 1
                                        break
                                    else:
                                        continue
                                else:
                                    if elm['npcId'] == progress['npcInfo']['id']:
                                        isBreak = True
                                        flag = True
                                    break
                        if m == 1:
                            n = 1
                            break
                else:
                    flag = False
                    continue
                if isBreak:
                    break
        if n == 1:
            continue
        if flag:
            k = 0
            globalQuestId = 0
            for questId in bossQuestIdList:
                questId = str(questId)
                if quest_npc.has_key(str(questId)) or not quest_npc.has_key('0'):#如果同任务的boss怪物已经有了,则此怪物不加入列表
                    k = 1
                    break
                globalQuestId = questId
            if k == 1:
                continue
            if len(progressingQuestList) == 0:
                if elm['questId'] == u'-1':
                    npcInfo = loader.getById('npc', elm['npcId'], '*')
                    if npcInfo == None:
                        continue
                    npc_place_list.append(npcInfo)
                    quest_npc[str(globalQuestId)] = elm['npcId']
            else:
                npcInfo = loader.getById('npc', elm['npcId'], '*')
                if npcInfo == None:
                    continue
                npc_place_list.append(npcInfo)
                quest_npc[str(globalQuestId)] = elm['npcId']
    return npc_place_list
コード例 #19
0
 def enterInstance(self, placeId):
     '''进入副本'''
     id = self._owner.baseInfo.id
     energy = self._owner.attribute.getEnergy()
     location = placeId
     instanceId = self._instanceId
     instanceLayerId = self._instancePlaceId
     result = False
     status = self._owner.baseInfo.getStatus()
     if status != u'正常':
         return False, u"您已经处于" + status + u"状态"
     placeInfo = loader.getById('place', placeId, '*')
     if placeInfo['levelRequire'] > self._owner.level.getLevel():
         return False, u'您的级别不够,需要达到 %d 级才能进入' % placeInfo['levelRequire']
     if instanceId <> -1:
         if location <> instanceId:
             energy -= 10
             if energy < 0:
                 return False, u'活力不足'
             if self._enterInstanceCount >= self.MAXENTERCOUNT:
                 return False, u'今日进入副本次数已经达到两次,不可重新进入新副本'
             instanceLayers = loader.get('instance', 'entryPlace', location,
                                         ['layers'])[0]['layers']
             layers = loader.getById('instance_layer', instanceLayers,
                                     ['place'])['place']
             instanceLayerId = int(layers.split(';')[0])
             attrs = {
                 'instanceId': location,
                 'instanceLayerId': instanceLayerId
             }
             result = dbaccess.updatePlayerInstanceProgressRecord(attrs, id)
             if result:
                 dbaccess.updatePlayerInfo(
                     id, {
                         'energy': energy,
                         'enterInstanceCount': self._enterInstanceCount + 1
                     })
                 self.init()
         else:
             result = True
     else:
         layers = loader.get('instance', 'entryPlace', location, ['layers'])
         if len(layers) < 0:
             return False, u'没有相应的副本层'
         layers = layers[0]['layers']
         if layers:
             energy -= 10
             if energy < 0:
                 return False, u'活力不足'
             places = loader.getById('instance_layer', layers,
                                     ['place'])['place'].split(';')
             instanceLayerId = int(places[0])
             props = [0, id, location, instanceLayerId, 0]
             result = dbaccess.insertPlayerInstanceProgressRecord(props)
             if result:
                 dbaccess.updatePlayerInfo(id, {
                     'energy': energy,
                     'enterInstanceCount': 1
                 })
                 self._enterInstanceCount = 1
             self.init()
         else:
             return False, u'没有相应的副本层'
     self._owner.attribute.setEnergy(energy)
     self._owner.baseInfo.setLocation(instanceLayerId)
     return result, ''