| | |
| | | import EventReport
|
| | | import ChItem
|
| | | import IpyGameDataPY
|
| | | import Operate_EquipStone
|
| | | import Operate_EquipWash
|
| | | import FormulaControl
|
| | | import ChPyNetSendPack
|
| | | import NetPackCommon
|
| | | import PyGameData
|
| | |
| | | PyGameData.EquipItemSkillIDList = []
|
| | | PyGameData.DailyUseCountLimitItemIDList = []
|
| | | PyGameData.AutoTransformCountItemIDList = []
|
| | | PyGameData.MoneyItemIDDict = {}
|
| | |
|
| | | gameData = GameWorld.GetGameData()
|
| | | for i in range(0, gameData.GetItemCount()):
|
| | |
| | |
|
| | | itemEff = findItemData.GetEffectByIndex(0)
|
| | | curEffID = itemEff.GetEffectID()
|
| | | if curEffID == ChConfig.Def_Effect_EquipStone:
|
| | | stoneEffType = itemEff.GetEffectValue(0)
|
| | | stoneLevel = itemEff.GetEffectValue(1)
|
| | | PyGameData.g_stoneLevelIDDict[(stoneEffType, stoneLevel)] = itemID
|
| | | elif curEffID == ChConfig.Def_Effect_ItemCount:
|
| | | if curEffID == ChConfig.Def_Effect_ItemCount:
|
| | | PyGameData.AutoTransformCountItemIDList.append(itemID)
|
| | | elif curEffID == ChConfig.Def_Effect_ItemGiveMoney:
|
| | | moneyValue = itemEff.GetEffectValue(0)
|
| | | moneyType = itemEff.GetEffectValue(1)
|
| | | if moneyValue == 1 and moneyType:
|
| | | PyGameData.MoneyItemIDDict[moneyType] = itemID
|
| | |
|
| | | if GetIsEquip(findItemData):
|
| | | for skillIndex in xrange(findItemData.GetAddSkillCount()):
|
| | |
| | |
|
| | | if PyGameData.AutoTransformCountItemIDList:
|
| | | GameWorld.Log("自动转化为物品个数的物品ID列表: %s" % PyGameData.AutoTransformCountItemIDList)
|
| | | |
| | | GameWorld.Log("货币类型1个数量对应物品ID: %s" % PyGameData.MoneyItemIDDict)
|
| | | if not PyGameData.MoneyItemIDDict:
|
| | | GameWorld.SendGameErrorEx("InitPyItemError", "启动加载物品数据异常! itemCount=%s" % gameData.GetItemCount())
|
| | | PyGameData.InitPyItem = True
|
| | | return
|
| | |
|
| | | def GetMoneyItemID(moneyType):
|
| | | ## 获取货币类型对应的物品ID
|
| | | if moneyType not in PyGameData.MoneyItemIDDict:
|
| | | GameWorld.ErrLog("没有该货币类型对应的物品ID! moneyType=%s" % moneyType)
|
| | | return 0
|
| | | return PyGameData.MoneyItemIDDict[moneyType]
|
| | |
|
| | | ## 物品触发技能增加buff
|
| | | # @param curPlayer 当前玩家
|
| | |
| | | @param isAuctionItem: 是否拍品,默认非拍品
|
| | | @param expireTime: 有效时间,时间单位由时效类型决定
|
| | | '''
|
| | | if itemCount < 1:
|
| | | if itemCount < 1 or not itemID:
|
| | | GameWorld.ErrLog("创建物品个数不能少于1! itemID=%s,itemCount=%s" % (itemID, itemCount))
|
| | | return
|
| | | curSingleItem = GameWorld.GetItemFactory().CreateItem(itemID)
|
| | |
| | | return
|
| | | curSingleItem.SetRemainHour(outTimeServerDay)
|
| | |
|
| | | if isAuctionItem:
|
| | | if IpyGameDataPY.GetIpyGameDataNotLog("AuctionItem", itemID):
|
| | | ItemControler.SetIsAuctionItem(curSingleItem, isAuctionItem)
|
| | | else:
|
| | | GameWorld.DebugLog("拍卖物品表不存在该ID!创建拍品失败,默认转为非拍品!itemID=%s" % itemID)
|
| | | #if isAuctionItem:
|
| | | # if IpyGameDataPY.GetIpyGameDataNotLog("AuctionItem", itemID):
|
| | | # ItemControler.SetIsAuctionItem(curSingleItem, isAuctionItem)
|
| | | # else:
|
| | | # GameWorld.DebugLog("拍卖物品表不存在该ID!创建拍品失败,默认转为非拍品!itemID=%s" % itemID)
|
| | |
|
| | | ItemControler.SetItemCount(curSingleItem, itemCount)
|
| | |
|
| | |
| | | PlayerHero.InitHeroItem(curSingleItem)
|
| | | elif GetIsEquip(curSingleItem):
|
| | | setAttrDict = GetCreateEquipAttr(curSingleItem, curPlayer, setAttrDict)
|
| | | if setAttrDict == None:
|
| | | curSingleItem.Clear()
|
| | | return
|
| | | elif GetIsMGGuayu(curSingleItem):
|
| | | setAttrDict = GetCreateMGGuayuAttr(curSingleItem, curPlayer, setAttrDict)
|
| | | if setAttrDict == None:
|
| | | curSingleItem.Clear()
|
| | | return
|
| | |
| | | @param curPlayer: 可能为None
|
| | | @param setAttrDict: 直接设置物品的属性 {key:value, ...} key支持 ShareDefine.Def_IudetXXX字符串 或 自定key
|
| | | @return: None - 异常情况,物品实例需要clear
|
| | | equipAttrDict - 生成后的最新属性k:v字典,可直接用于 SetCreateEquipAttr
|
| | | equipAttrDict - 生成后的最新属性k:v字典,可直接用于 AddCreateItemAttr
|
| | | '''
|
| | | if setAttrDict == None:
|
| | | setAttrDict = {}
|
| | |
| | | GameWorld.DebugLog(" legendAttrIDList=%s,legendAttrValueList=%s" % (legendAttrIDList, legendAttrValueList), playerID)
|
| | |
|
| | | GameWorld.DebugLog(" 装备最终属性: equipAttrDict=%s,setAttrDict=%s" % (equipAttrDict, setAttrDict), playerID)
|
| | | return equipAttrDict
|
| | |
|
| | | def GetCreateMGGuayuAttr(curItem, curPlayer=None, setAttrDict=None):
|
| | | '''获取生成命格卦玉所有属性
|
| | | @param curPlayer: 可能为None
|
| | | @param setAttrDict: 直接设置物品的属性 {key:value, ...} key支持 ShareDefine.Def_IudetXXX字符串 或 自定key
|
| | | @return: None - 异常情况,物品实例需要clear
|
| | | equipAttrDict - 生成后的最新属性k:v字典,可直接用于 AddCreateItemAttr
|
| | | '''
|
| | | if setAttrDict == None:
|
| | | setAttrDict = {}
|
| | | playerID = 0 if not curPlayer else curPlayer.GetPlayerID()
|
| | | itemID = curItem.GetItemTypeID()
|
| | | itemType = curItem.GetType()
|
| | | itemColor = curItem.GetItemColor()
|
| | | equipAttrDict = {}
|
| | | |
| | | # 定制属性,如有需要可扩展
|
| | | |
| | | if not curPlayer:
|
| | | return
|
| | | |
| | | gwLV = max(1, curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MGGanwuLV))
|
| | | gwIpyData = IpyGameDataPY.GetIpyGameData("MGGanwuLV", gwLV)
|
| | | colorIpyData = IpyGameDataPY.GetIpyGameData("MGGuayuQuality", itemColor)
|
| | | typeIpyData = IpyGameDataPY.GetIpyGameData("MGGuayuType", itemType)
|
| | | if not gwIpyData or not colorIpyData or not typeIpyData:
|
| | | return
|
| | | |
| | | # 四维基础值、加成值
|
| | | baseAttrDict = {ChConfig.AttrID_Atk:[gwIpyData.GetAtkBase(), colorIpyData.GetAtkPlus()],
|
| | | ChConfig.AttrID_Def:[gwIpyData.GetDefBase(), colorIpyData.GetDefPlus()],
|
| | | ChConfig.AttrID_MaxHP:[gwIpyData.GetHPBase(), colorIpyData.GetHPPlus()],
|
| | | ChConfig.AttrID_AtkSpeed:[gwIpyData.GetAtkSpeedBase(), colorIpyData.GetAtkSpeedPlus()],
|
| | | }
|
| | | batAttrBaseDict = gwIpyData.GetBatAttrBaseDict() # 其他战斗属性基础值字典,{属性ID:基础值, ...}
|
| | | |
| | | # 四维占比
|
| | | attrProportion = typeIpyData.GetBaseAttrProportion()
|
| | | |
| | | randfloat = random.uniform # 随机一个ab区间的数 [a, b],ab支持小数
|
| | | |
| | | itemLV = setAttrDict.get(str(ShareDefine.Def_IudetItemLV), 0)
|
| | | if not itemLV:
|
| | | # 随机等级
|
| | | lowLV, highLV = IpyGameDataPY.GetFuncEvalCfg("MinggeTY", 2)
|
| | | randLVList = range(max(gwLV + lowLV, 1), gwLV + highLV)
|
| | | itemLV = random.choice(randLVList)
|
| | | equipAttrDict[str(ShareDefine.Def_IudetItemLV)] = itemLV
|
| | | |
| | | GameWorld.DebugLog("生成命格卦玉: gwLV=%s,itemID=%s,itemLV=%s,itemColor=%s,itemType=%s" % (gwLV, itemID, itemLV, itemColor, itemType), playerID)
|
| | | legendAttrIDList = setAttrDict.get(str(ShareDefine.Def_IudetLegendAttrID))
|
| | | legendAttrValueList = setAttrDict.get(str(ShareDefine.Def_IudetLegendAttrValue))
|
| | | if legendAttrIDList != None and legendAttrValueList != None and len(legendAttrIDList) == len(legendAttrValueList):
|
| | | equipAttrDict[str(ShareDefine.Def_IudetLegendAttrID)] = legendAttrIDList
|
| | | equipAttrDict[str(ShareDefine.Def_IudetLegendAttrValue)] = legendAttrValueList
|
| | | else:
|
| | | fixedAttrID = typeIpyData.GetFixedAttrID() # 固定属性
|
| | | attrIDLib = typeIpyData.GetAttrIDLib() # 随机属性库
|
| | | libAttrCnt = 0 # 随机属性个数
|
| | | libAttrCntNeedLVList = IpyGameDataPY.GetFuncEvalCfg("MinggeCfg", 1)
|
| | | for needGWLV in libAttrCntNeedLVList:
|
| | | if gwLV >= needGWLV:
|
| | | libAttrCnt += 1
|
| | | else:
|
| | | break
|
| | | attrRangeDefault = colorIpyData.GetAttrRange()
|
| | | attrRangeDict = colorIpyData.GetAttrRangeDict()
|
| | | |
| | | random.shuffle(attrIDLib)
|
| | | randAttrList = attrIDLib[:libAttrCnt]
|
| | | attrIDList = [fixedAttrID] + randAttrList
|
| | | GameWorld.DebugLog(" attrIDList=%s,libAttrCnt=%s,%s" % (attrIDList, libAttrCnt, attrIDLib), playerID)
|
| | | |
| | | legendAttrIDList = []
|
| | | legendAttrValueList = []
|
| | | for attrID in attrIDList:
|
| | | |
| | | # 基础四维计算
|
| | | if attrID in baseAttrDict:
|
| | | baseValue, plusValue = baseAttrDict[attrID]
|
| | | attrValue = eval(IpyGameDataPY.GetFuncCompileCfg("MinggeTY", 3))
|
| | | GameWorld.DebugLog(" attrID=%s,attrValue=%s,baseValue=%s,plusValue=%s,attrProportion=%s" |
| | | % (attrID, attrValue, baseValue, plusValue, attrProportion), playerID)
|
| | | |
| | | # 其他战斗属性
|
| | | else:
|
| | | baseValue = batAttrBaseDict.get(attrID, 0)
|
| | | attrRange = attrRangeDict.get(attrID, attrRangeDefault)
|
| | | if not attrRange or len(attrRange) != 2:
|
| | | continue
|
| | | attrMin, attrMax = attrRange
|
| | | plusValue = random.randint(attrMin, attrMax)
|
| | | attrValue = baseValue + plusValue
|
| | | GameWorld.DebugLog(" attrID=%s,attrValue=%s,baseValue=%s,plusValue=%s,(%s~%s)" % (attrID, attrValue, baseValue, plusValue, attrMin, attrMax), playerID)
|
| | | |
| | | legendAttrIDList.append(attrID)
|
| | | legendAttrValueList.append(attrValue)
|
| | | |
| | | if legendAttrIDList:
|
| | | equipAttrDict[str(ShareDefine.Def_IudetLegendAttrID)] = legendAttrIDList
|
| | | equipAttrDict[str(ShareDefine.Def_IudetLegendAttrValue)] = legendAttrValueList
|
| | | |
| | | # 意象技能
|
| | | if itemType in IpyGameDataPY.GetFuncEvalCfg("MinggeTY", 4):
|
| | | yxSkillTypeIDList = IpyGameDataPY.GetFuncEvalCfg("MinggeTY", 5)
|
| | | randSkillTypeID = random.choice(yxSkillTypeIDList) if yxSkillTypeIDList else 0
|
| | | if randSkillTypeID:
|
| | | equipAttrDict[str(ShareDefine.Def_IudetAddSkillID)] = [randSkillTypeID]
|
| | | GameWorld.DebugLog(" itemType=%s,randSkillTypeID=%s" % (itemType, randSkillTypeID), playerID)
|
| | | |
| | | GameWorld.DebugLog(" 卦玉最终属性: equipAttrDict=%s,setAttrDict=%s" % (equipAttrDict, setAttrDict), playerID)
|
| | | return equipAttrDict
|
| | |
|
| | | def SetItemUserData(curItem, dataInfo):
|
| | |
| | | keyStr = ChConfig.Def_VPackCnt_Dict[packindex]
|
| | | return IpyGameDataPY.GetFuncCfg(keyStr)
|
| | |
|
| | |
|
| | | ## 杀怪掉落提示
|
| | | # @param curPlayer 当前玩家
|
| | | # @return None
|
| | | def NotifyItemDropByKill(curPlayer, curItem, npcID, notifyMark='', mapID=0):
|
| | | return #吕超说此处屏蔽
|
| | |
|
| | | def CacheNotifyEquipDetailInfo(curPlayer, curEquip):
|
| | | ''' 缓存装备广播信息中的装备明细信息
|
| | | 因为本版本需要的查看的内容相对较多,为了减少全服广播流量消耗,所以先进行缓存,玩家点击查看时再进行查询
|
| | | '''
|
| | | |
| | | guid = curEquip.GetGUID()
|
| | | packType = curEquip.GetItemPlaceType()
|
| | | packIndex = curEquip.GetItemPlaceIndex()
|
| | | if packType != IPY_GameWorld.rptEquip:
|
| | | return guid
|
| | | |
| | | classLV = GetItemClassLV(curEquip)
|
| | | if not classLV:
|
| | | return guid
|
| | | |
| | | itemID = curEquip.GetItemTypeID()
|
| | | #部位星级
|
| | | equipStar = ChEquip.GetEquipPartStarByRank(curPlayer, packIndex, curEquip)
|
| | | |
| | | #部位强化数据
|
| | | plusLV = ChEquip.GetEquipPartPlusLV(curPlayer, packType, packIndex)
|
| | | plusEvolveLV = ChEquip.GetEquipPartPlusEvolveLV(curPlayer, packType, packIndex)
|
| | | |
| | | #部位洗练数据
|
| | | washLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_EquipWashLV % packIndex)
|
| | | washValueList = []
|
| | | for attrNum in xrange(1, Operate_EquipWash.Def_EquipWashMaxAttrCount + 1):
|
| | | value = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_EquipWashValue % (packIndex, attrNum))
|
| | | washValueList.append(value)
|
| | | |
| | | #部位宝石数据
|
| | | stoneIDList = Operate_EquipStone.GetEquipIndexStoneIDList(curPlayer, packIndex)
|
| | | |
| | | #本阶已穿装备ID [[itemID,star], ...]
|
| | | classItems = [] |
| | | ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition('EquipPlaceIndexMap', {'ClassLV':classLV}, True)
|
| | | if ipyDataList:
|
| | | equipPack = curPlayer.GetItemManager().GetPack(packType)
|
| | | for ipyData in ipyDataList:
|
| | | index = ipyData.GetGridIndex()
|
| | | classEquip = equipPack.GetAt(index)
|
| | | if not classEquip or classEquip.IsEmpty():
|
| | | continue
|
| | | equipID = classEquip.GetItemTypeID()
|
| | | star = ChEquip.GetEquipPartStarByRank(curPlayer, index, classEquip)
|
| | | classItems.append([equipID, star])
|
| | | |
| | | cacheInfo = [guid, itemID, equipStar, plusLV, plusEvolveLV, washLV, washValueList, stoneIDList, classItems]
|
| | | cacheInfo = json.dumps(cacheInfo, ensure_ascii=False)
|
| | | GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(0, 0, 0, "NotifyEquipDetailInfo", cacheInfo, len(cacheInfo))
|
| | | return guid
|
| | |
|
| | | ## 使用物品的特殊提示
|
| | | # @param curPlayer 当前玩家
|
| | | # @param useItemID 使用物品
|
| | |
| | |
|
| | | # 记录玩家背包获得物品
|
| | | if packType in [IPY_GameWorld.rptItem, ShareDefine.rptTreasure] or packType in ShareDefine.Def_VPack_TypeList:
|
| | | EventReport.WriteEvent_item_record(curPlayer, 1, operateType, itemNoteDict, noteDict)
|
| | | pass
|
| | |
|
| | | return
|
| | |
|
| | |
| | |
|
| | | # 记录玩家背包物品删除
|
| | | if packType in [IPY_GameWorld.rptItem, ShareDefine.rptTreasure] or packType in ShareDefine.Def_VPack_TypeList:
|
| | | EventReport.WriteEvent_item_record(curPlayer, 0, operateType, itemNoteDict, noteDict)
|
| | | pass
|
| | |
|
| | | return
|
| | |
|
| | | def DR_EquipItemChange(curPlayer, curEquip, eventName, addDict={}):
|
| | | # 记录装备物品属性变更
|
| | | noteDict = GetItemNoteDict(curEquip, 1)
|
| | | noteDict.update(addDict)
|
| | | noteDict["packType"] = curEquip.GetItemPlaceType()
|
| | | DataRecordPack.DR_EquipMachining(curPlayer, eventName, noteDict)
|
| | | return
|
| | |
|
| | | #===============================================================================
|
| | |
| | | ## 返回是否神兽装备
|
| | | return curItem.GetType() in ChConfig.Def_DogzEquiipType
|
| | |
|
| | | def GetIsMGGuayu(curItem):
|
| | | ## 是否命格卦玉
|
| | | return curItem.GetType() in ChConfig.Def_MGGuayuType
|
| | |
|
| | | #---------------------------------------------------------------------
|
| | | ##遍历数据库查找合适的物品, 通过 效果ID + 效果A值确定物品
|
| | | # @param itemType 物品类型
|
| | |
| | | DR_DelItem(curPlayer, packIndex, "VPack_%s" % packIndex if not eventName else eventName, dataDict)
|
| | | ItemControler.Sync_VPackItem_Clear(curPlayer, packIndex, placeList)
|
| | | return
|
| | |
|
| | |
|
| | | ## 获取物品最高强化进化等级
|
| | | # @param itemType: 物品类型
|
| | | # @return 最大星级,0为不可强化
|
| | | def GetItemMaxPlusEvolveLV(curPlayer, equipPackindex, curItem):
|
| | | packType = IPY_GameWorld.rptEquip
|
| | | curPlusLV = ChEquip.GetEquipPartPlusLV(curPlayer, packType, equipPackindex)
|
| | | equipPlace = curItem.GetEquipPlace()
|
| | | ipyData = IpyGameDataPY.InterpolationSearch('EquipPlusEvolve', 'NeedPlusLV', curPlusLV, {'EquipPlace':equipPlace})
|
| | | if not ipyData:
|
| | | return 0
|
| | | return ipyData.GetEvolveLV()
|
| | |
|
| | |
|
| | | ## 获取物品最高星数
|
| | | # @param itemType: 物品类型
|
| | | # @return 最大星级,0为不可强化
|
| | | def GetItemMaxStar(curItem):
|
| | | itemColor = curItem.GetItemColor()
|
| | | maxStarDict = IpyGameDataPY.GetFuncEvalCfg('EquipPartStar', 1)
|
| | | if str(itemColor) not in maxStarDict:
|
| | | return 0
|
| | | classLV = GetItemClassLV(curItem)
|
| | | return maxStarDict[str(itemColor)].get(str(classLV), 0)
|
| | |
|
| | | ## 获取物品阶级或品级
|
| | | def GetItemClassLV(curItem):
|
| | | return curItem.GetLV()
|
| | |
|
| | | def GetWingLV(curItem):
|
| | | ## 获取翅膀代数等级
|
| | | wingLVDict = IpyGameDataPY.GetFuncEvalCfg("WingLV", 1)
|
| | | return wingLVDict.get(str(curItem.GetLV()), 0)
|
| | |
|
| | | ## 装备评分
|
| | | def GetEquipGearScore(curItem):
|