示例#1
0
 def addPet(self, templateId, quality=1, statu=1):
     '''添加一个宠物'''
     self.initCharacterPetInfo()
     if self.getPetNum() >= MAXPETCNT:
         return -1  #宠物数量达到上限
     pet = Pet(templateId=templateId, owner=self._owner.baseInfo.id)
     result = pet.InsertIntoDB()
     if result:
         msg = Lg().g(422) % pet.baseInfo.getName()
         if statu:
             pushOtherMessage(905, msg, [self._owner.getDynamicId()])
         else:
             self._owner.msgbox.putFightTMsg(msg)
         self._pets[pet.baseInfo.id] = pet
         return pet.baseInfo.getName()
示例#2
0
 def GetTuJianPetList(self, ttype, page, limit=7):
     '''获取图鉴信息
     @param ttype: int 图鉴的类型
     '''
     itemslist = self._owner.pack._package._PropsPagePack._items
     collectpetlist = [dbCharacterPet.PET_ITEM.get(item['itemComponent'].baseInfo.itemTemplateId)\
                 for item in itemslist]
     petlist = self._activepets + collectpetlist
     petSjlist = []
     slInfo = {}
     for petId in petlist:
         if not petId:
             continue
         petInfo = dbCharacterPet.PET_TEMPLATE.get(petId)
         if petInfo.get('attrType', 1) == ttype:
             info = {}
             viewFlag = petId in self._activepets
             info['petName'] = petInfo.get('nickname', u'')
             info['petLevel'] = 1
             info['petId'] = petId
             info['viewFlag'] = viewFlag
             pet = Pet(templateId=petId)
             info['quality'] = pet.attribute.getPetQuality()
             petSjlist.append(info)
     maxPage = int(math.ceil(len(petSjlist) * 1.0 / 7))
     if maxPage < 1:
         maxPage = 1
     slInfo['sjPro'] = int(
         math.ceil(
             len(self._activepets) / len(dbCharacterPet.PET_TEMPLATE)))
     slInfo['curPage'] = page
     slInfo['maxPage'] = maxPage
     slInfo['sjListPet'] = petSjlist[(page - 1) * limit:page * limit]
     return slInfo
示例#3
0
def getXYlist(pid, lv, page):
    '''获取幸运值兑换的宠物列表
    return  {'zong':zong,'date':date}
    '''
    player = PlayersManager().getPlayerByID(pid)
    if not player:
        return {'result': False, 'message': Lg().g(18)}
    data = player.petShop.getXyShopBylv(lv, page)
    ttlist = player.pet.getHasPetTemplatelist()  #获取已经获取的宠物的模版列表
    li = []

    for item in data['date']:
        #        le=random.randint(1,5)
        pi = Pet(templateId=item['id'], level=1)  #宠物信息
        info = pi.formatPetInfo()  #宠物属性
        val = {}
        val['id'] = item['id']
        val['wSkill'] = info['skillname']
        val['wTexing'] = info['texing']
        val['wLiliang'] = info['Str']
        val['wZhili'] = info['Wis']
        val['wNaili'] = info['Vit']
        val['wMinjie'] = info['Dex']
        val['wWugong'] = info['PhyAtt']
        val['wMogong'] = info['MigAtt']
        val['wGongsu'] = info['Speed']
        val['wBaoji'] = info['CriRate']
        val['wWufang'] = info['PhyDef']
        val['wMofang'] = info['MigDef']
        val['wMingzhong'] = info['HitRate']
        val['wShanbi'] = info['Dodge']
        val['wKaobao'] = info['Block']
        val['color'] = int(info['quality'])
        if item['id'] in ttlist:
            val['wGuyongzhi'] = 1  #是否标记已拥有  1标记  -1不标记
        else:
            val['wGuyongzhi'] = -1  #是否标记已拥有  1标记  -1不标记
        val['wName'] = item['nickname']
        val['wGuYongXingYunZhi'] = item['xy']
        val['type'] = item['type']
        val['icon'] = item['icon']
        val['level'] = 1
        li.append(val)
    data['data'] = li
    return data
示例#4
0
def getXYlist(pid, lv, page):
    """获取幸运值兑换的宠物列表
    return  {'zong':zong,'date':date}
    """
    player = PlayersManager().getPlayerByID(pid)
    if not player:
        return {"result": False, "message": Lg().g(18)}
    data = player.petShop.getXyShopBylv(lv, page)
    ttlist = player.pet.getHasPetTemplatelist()  # 获取已经获取的宠物的模版列表
    li = []

    for item in data["date"]:
        #        le=random.randint(1,5)
        pi = Pet(templateId=item["id"], level=1)  # 宠物信息
        info = pi.formatPetInfo()  # 宠物属性
        val = {}
        val["id"] = item["id"]
        val["wSkill"] = info["skillname"]
        val["wTexing"] = info["texing"]
        val["wLiliang"] = info["Str"]
        val["wZhili"] = info["Wis"]
        val["wNaili"] = info["Vit"]
        val["wMinjie"] = info["Dex"]
        val["wWugong"] = info["PhyAtt"]
        val["wMogong"] = info["MigAtt"]
        val["wGongsu"] = info["Speed"]
        val["wBaoji"] = info["CriRate"]
        val["wWufang"] = info["PhyDef"]
        val["wMofang"] = info["MigDef"]
        val["wMingzhong"] = info["HitRate"]
        val["wShanbi"] = info["Dodge"]
        val["wKaobao"] = info["Block"]
        val["color"] = int(info["quality"])
        if item["id"] in ttlist:
            val["wGuyongzhi"] = 1  # 是否标记已拥有  1标记  -1不标记
        else:
            val["wGuyongzhi"] = -1  # 是否标记已拥有  1标记  -1不标记
        val["wName"] = item["nickname"]
        val["wGuYongXingYunZhi"] = item["xy"]
        val["type"] = item["type"]
        val["icon"] = item["icon"]
        val["level"] = 1
        li.append(val)
    data["data"] = li
    return data
示例#5
0
 def initCharacterPetInfo(self):
     '''初始化角色宠物信息'''
     if self._hasInit:
         return
     petlist = dbCharacterPet.getCharacterAllPet(self._owner.baseInfo.id)
     for petid in petlist:
         petId = petid[0]
         pet = Pet(petId=petId)
         self._pets[petId] = pet
     self._hasInit = 1
示例#6
0
    def addPet(self, templateId, quality=1, level=1, statu=1):
        '''添加一个宠物'''

        self.initCharacterPetInfo()
        if self.getPetNum() >= MAXPETCNT:
            return -1  #宠物数量达到上限
        if self.hasThisType(templateId):
            return -2  #已经拥有该种类型的宠物
        pet = Pet(templateId=templateId,
                  level=level,
                  owner=self._owner.baseInfo.id)
        result = pet.InsertIntoDB()
        if result:
            msg = Lg().g(422) % pet.baseInfo.getName()
            if statu:
                pushOtherMessage(905, msg, [self._owner.getDynamicId()])
            else:
                self._owner.msgbox.putFightTMsg(msg)
            self._pets[pet.baseInfo.id] = pet
            self._owner.daily.noticeDaily(10, 0, len(self._pets))
            self.appendPetCollect(templateId)
            return pet.baseInfo.getName()
示例#7
0
 def getconfigto(self,val):
     '''工具相关'''
     data={}
     data['fashi']=[]
     data['zhanshi']=[]
     data['youxia']=[]
     fashil=eval(val['fashi'])
     for fs in fashil:
         pi=Pet(templateId=fs,level=1)#宠物信息
         data['fashi'].append(pi.formatPetInfo())#添加法师推荐的宠物信息
     zhanshil=eval(val['zhanshi'])
     for zs in zhanshil:
         pi=Pet(templateId=zs,level=1)#宠物信息
         data['zhanshi'].append(pi.formatPetInfo())#添加战士推荐的宠物信息
     youxial=eval(val['youxia'])
     for zs in youxial:
         pi=Pet(templateId=zs,level=1)#宠物信息
         data['youxia'].append(pi.formatPetInfo())#添加战士推荐的宠物信息
     return data
示例#8
0
 def GetOnePetTuJianInfo(self, petId):
     '''获取某个宠物的收集信息
     '''
     info = {}
     petinfo = dbCharacterPet.PET_TEMPLATE.get(petId)
     info['pet'] = Pet(templateId=petId)
     requiredId = petinfo.get('soulrequired')
     info[
         'curHun'] = self._owner.pack._package._PropsPagePack.countItemTemplateId(
             requiredId)
     info['maxHun'] = petinfo.get('soulcount')
     if petId in self._activepets:
         info['curHun'] = info['maxHun']
     info['reqCoin'] = self._owner.level.getLevel() * 2000
     return info
示例#9
0
 def initCharacterPetInfo(self):
     '''初始化角色宠物信息'''
     if self._hasInit:
         return
     petlist = dbCharacterPet.getCharacterAllPet(self._owner.baseInfo.id)
     collectstr = dbCharacterPet.getCharacterCollect(
         self._owner.baseInfo.id)
     for petid in petlist:
         petId = petid[0]
         pet = Pet(petId=petId)
         self._pets[petId] = pet
     if collectstr is None:
         dbCharacterPet.insertCharacterCollect(self._owner.baseInfo.id)
     else:
         self._activepets = eval("[%s]" % collectstr)
     self._hasInit = 1
示例#10
0
def getPetShopInfo(pid, npcid, istrue):
    '''获取宠物商店信息
    @param pid: int 角色信息
    @param npcid: int NPCid
    @param istrue: int 是否是立即刷新
    '''
    player = PlayersManager().getPlayerByID(pid)
    if not player:
        return {'result': False, 'message': Lg().g(18)}

    if istrue:
        if player.petShop.cs >= 0 and player.petShop.getTime() <= 0:  #免费刷新
            player.petShop.cs -= 1  #每天免费刷新次数-1
        else:  #使用钻石刷新
            gold = player.finance.getGold()
            if gold >= 10:
                #                player.finance.updateGold(gold-10)
                player.finance.consGold(10, 4)
                player.petShop.xy += 1
            else:
                pushOtherMessage(905, Lg().g(165), [player.dynamicId])
                return {'result': False, 'message': Lg().g(165)}
        player.petShop.suiji(npcid, True)  #刷新
        player.quest.specialTaskHandle(116)  #特殊任务处理
    data = {}
    data['result'] = True
    data['message'] = Lg().g(166)
    op = {-1: True, 1: False}
    ps = player.petShop  #宠物商店类
    data['xingyunzhi'] = ps.xy  #幸运
    data['refreshTime'] = ps.getTime()  #剩余时间\
    data['isClose'] = op.get(ps.isoption)  #是否打开 1开启消费提示 -1 关闭消费提示
    data['shengYuCiShu'] = ps.getsycs()  #剩余次数
    tj = ps.getPetConfigByLv(npcid)  #推荐组合   data={} data['fashi']=[]
    data['fashiPet'] = tj['fashi']  #[宠物模板信息]
    data['zhanshiPet'] = tj['zhanshi']  #[宠物模板信息]
    data['youxiaPet'] = tj['youxia']  #[宠物模板信息]
    petlist = ps.getShopInfo(
        npcid)  #获取四个宠物信息 petlist[宠物模板信息,宠物模板信息,宠物模板信息,宠物模板信息]
    data['wowInfo'] = []
    if len(petlist) > 0:
        ttlist = player.pet.getHasPetTemplatelist()  #获取已经获取的宠物的模版列表
        for items in petlist:  #item 宠物模板信息
            item = items[0]
            pi = Pet(templateId=item['id'], level=items[1])  #宠物信息
            info = pi.formatPetInfo()  #宠物属性
            val = {}
            val['id'] = item['id']
            val['wSkill'] = info['skillname']
            val['wTexing'] = info['texing']
            val['wLiliang'] = int(info['Str'])
            val['wZhili'] = int(info['Wis'])
            val['wNaili'] = int(info['Vit'])
            val['wMinjie'] = int(info['Dex'])
            val['wWugong'] = int(info['PhyAtt'])
            val['wMogong'] = int(info['MigAtt'])
            val['wGongsu'] = int(info['Speed'])
            val['wBaoji'] = int(info['CriRate'])
            val['wWufang'] = int(info['PhyDef'])
            val['wMofang'] = int(info['MigDef'])
            val['wMingzhong'] = int(info['HitRate'])
            val['wShanbi'] = int(info['Dodge'])
            val['wKaobao'] = int(info['Block'])
            val['color'] = int(info['quality'])
            if item['id'] in ttlist:
                val['wGuyongzhi'] = 1  #是否标记已拥有  1标记  -1不标记
            else:
                val['wGuyongzhi'] = -1  #是否标记已拥有  1标记  -1不标记
            val['wName'] = item['nickname']
            val['wGuYongJinBi'] = item['coin']
            val['wGuYongXingYunZhi'] = item['xy']
            val['type'] = item['type']
            val['icon'] = item['icon']
            val['level'] = items[1]
            data['wowInfo'].append(val)
    return data
示例#11
0
def getPetShopInfo(pid, npcid, istrue):
    """获取宠物商店信息
    @param pid: int 角色信息
    @param npcid: int NPCid
    @param istrue: int 是否是立即刷新
    """
    player = PlayersManager().getPlayerByID(pid)
    if not player:
        return {"result": False, "message": Lg().g(18)}

    if istrue:
        if player.petShop.cs >= 0 and player.petShop.getTime() <= 0:  # 免费刷新
            player.petShop.cs -= 1  # 每天免费刷新次数-1
        else:  # 使用钻石刷新
            gold = player.finance.getGold()
            if gold >= 10:
                #                player.finance.updateGold(gold-10)
                player.finance.consGold(10, 4)
                player.petShop.xy += 1
            else:
                pushOtherMessage(905, Lg().g(165), [player.dynamicId])
                return {"result": False, "message": Lg().g(165)}
        player.petShop.suiji(npcid, True)  # 刷新
        player.quest.specialTaskHandle(116)  # 特殊任务处理
    data = {}
    data["result"] = True
    data["message"] = Lg().g(166)
    op = {-1: True, 1: False}
    ps = player.petShop  # 宠物商店类
    data["xingyunzhi"] = ps.xy  # 幸运
    data["refreshTime"] = ps.getTime()  # 剩余时间\
    data["isClose"] = op.get(ps.isoption)  # 是否打开 1开启消费提示 -1 关闭消费提示
    data["shengYuCiShu"] = ps.getsycs()  # 剩余次数
    tj = ps.getPetConfigByLv(npcid)  # 推荐组合   data={} data['fashi']=[]
    data["fashiPet"] = tj["fashi"]  # [宠物模板信息]
    data["zhanshiPet"] = tj["zhanshi"]  # [宠物模板信息]
    data["youxiaPet"] = tj["youxia"]  # [宠物模板信息]
    petlist = ps.getShopInfo(npcid)  # 获取四个宠物信息 petlist[宠物模板信息,宠物模板信息,宠物模板信息,宠物模板信息]
    data["wowInfo"] = []
    if len(petlist) > 0:
        ttlist = player.pet.getHasPetTemplatelist()  # 获取已经获取的宠物的模版列表
        for items in petlist:  # item 宠物模板信息
            item = items[0]
            pi = Pet(templateId=item["id"], level=items[1])  # 宠物信息
            info = pi.formatPetInfo()  # 宠物属性
            val = {}
            val["id"] = item["id"]
            val["wSkill"] = info["skillname"]
            val["wTexing"] = info["texing"]
            val["wLiliang"] = int(info["Str"])
            val["wZhili"] = int(info["Wis"])
            val["wNaili"] = int(info["Vit"])
            val["wMinjie"] = int(info["Dex"])
            val["wWugong"] = int(info["PhyAtt"])
            val["wMogong"] = int(info["MigAtt"])
            val["wGongsu"] = int(info["Speed"])
            val["wBaoji"] = int(info["CriRate"])
            val["wWufang"] = int(info["PhyDef"])
            val["wMofang"] = int(info["MigDef"])
            val["wMingzhong"] = int(info["HitRate"])
            val["wShanbi"] = int(info["Dodge"])
            val["wKaobao"] = int(info["Block"])
            val["color"] = int(info["quality"])
            if item["id"] in ttlist:
                val["wGuyongzhi"] = 1  # 是否标记已拥有  1标记  -1不标记
            else:
                val["wGuyongzhi"] = -1  # 是否标记已拥有  1标记  -1不标记
            val["wName"] = item["nickname"]
            val["wGuYongJinBi"] = item["coin"]
            val["wGuYongXingYunZhi"] = item["xy"]
            val["type"] = item["type"]
            val["icon"] = item["icon"]
            val["level"] = items[1]
            data["wowInfo"].append(val)
    return data