| | |
| | | import DataRecordPack
|
| | | import PlayerGubao
|
| | | import PyGameData
|
| | | import EventShell
|
| | | import PlayerVip
|
| | | import ChEquip
|
| | | import PlayerHero
|
| | |
|
| | | import math
|
| | | import time
|
| | |
| | | self.__PlayerItem = self.__PlayerItemManager.GetPack(IPY_GameWorld.rptItem)
|
| | | return
|
| | |
|
| | | ## 玩家是否能装备物品 |
| | | # @param curItem 当前物品
|
| | | # @param needNotify 是否需要通知客户端
|
| | | # @return 布尔值
|
| | | # @remarks 函数详细说明.
|
| | | def PlayerCanEquipItem(self, curItem, needNotify):
|
| | | curPlayer = self.__Player
|
| | | #非法装备检查
|
| | | if curItem.GetIsLocked():
|
| | | if needNotify:
|
| | | PlayerControl.NotifyCode(curPlayer, "RescannotEquip")
|
| | | |
| | | return False
|
| | | |
| | | #任务物品检查
|
| | | if IsEventItem(curItem):
|
| | | if needNotify:
|
| | | PlayerControl.NotifyCode(curPlayer, "TaskRes")
|
| | | |
| | | return False
|
| | | |
| | | #数据库中是1开始
|
| | | # if curItem.GetEquipPlace() == 0:
|
| | | # if needNotify:
|
| | | # #物品不能装备
|
| | | # PlayerControl.NotifyCode(curPlayer, "GeRen_hgg_595819")
|
| | | #
|
| | | # return False
|
| | | |
| | | #职业检查
|
| | | if not ItemCommon.CheckJob(curPlayer, curItem):
|
| | | if needNotify:
|
| | | PlayerControl.NotifyCode(curPlayer, "GeRen_lhs_31379")
|
| | |
|
| | | return False
|
| | |
|
| | | #性别检查
|
| | | curItemNeedSexReq = curItem.GetSexReq()
|
| | | |
| | | if curItemNeedSexReq != ChConfig.Def_PlayerSex_All and curItemNeedSexReq != curPlayer.GetSex() :
|
| | | if needNotify:
|
| | | PlayerControl.NotifyCode(curPlayer, "SexErr")
|
| | |
|
| | | return False
|
| | |
|
| | | #等级检查
|
| | | if not CheckItemUseLV(curPlayer, curItem, needNotify):
|
| | | return False
|
| | | |
| | | #=======================================================================
|
| | | # #马匹检查
|
| | | # if curItem.GetType() == ChConfig.Def_Item_Type_Horse and not CheckCanEquipHorse(curPlayer):
|
| | | # return False
|
| | | #=======================================================================
|
| | |
|
| | | |
| | | return True
|
| | | |
| | | |
| | | ## 交换装备
|
| | | # @param curItem 当前物品
|
| | | # @param equipPackIndex 装备背包格子
|
| | |
| | | #curEquip.SetItemStarLV(0) # 交换下的装备星级设置为0
|
| | | return ItemCommon.SwitchItem(curPlayer, curEquip, curItem, IPY_GameWorld.rptEquip)
|
| | |
|
| | | return False |
| | | |
| | | # 计算装备的珍品数量
|
| | | def RefreshStartEquipCount(self):
|
| | | # curPlayer = self.__Player
|
| | | # count = 0
|
| | | # equipPack = self.__PlayerEquip
|
| | | # for i in xrange(equipPack.GetCount()):
|
| | | # curEquip = equipPack.GetAt(i)
|
| | | # |
| | | # if curEquip.IsEmpty():
|
| | | # continue
|
| | | # |
| | | # if not curEquip.GetItemQuality():
|
| | | # continue
|
| | | # |
| | | # count += 1
|
| | | # |
| | | # curPlayer.SetDict(ChConfig.Def_PlayerKey_StartEquipCnt, count)
|
| | | return
|
| | | return False
|
| | |
|
| | | def GetStartEquipCount(self):
|
| | | return 0
|
| | | #curPlayer = self.__Player
|
| | | #return curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_StartEquipCnt)
|
| | |
|
| | | ## 装备当前物品
|
| | | # @param curItem 当前物品
|
| | | # @param equipPackIndex 客户端发来装备位置(IPY_GameWorld.retMax 代表服务器自动装备)
|
| | | # @return 替换的位置 -1表示替换失败
|
| | | def EquipItem(self, curItem, equipPackIndex):
|
| | | if not self.PlayerCanEquipItem(curItem, True):
|
| | | return -1
|
| | | |
| | | classLV = ItemCommon.GetItemClassLV(curItem)
|
| | | equipPlace = curItem.GetEquipPlace()
|
| | | |
| | | curPlayer = self.__Player
|
| | | equipPack = self.__PlayerEquip
|
| | | equipItem = equipPack.GetAt(equipPackIndex)
|
| | | if not equipItem:
|
| | | return -1
|
| | | desItemID, desUserData = [0, ''] if equipItem.IsEmpty() else [equipItem.GetItemTypeID(), equipItem.GetUserData()]
|
| | | srcItemID, srcUserData = curItem.GetItemTypeID(), curItem.GetUserData()
|
| | | |
| | | befIsOrangeEquip = 1 if (not equipItem.IsEmpty() and equipItem.GetItemColor() >= ChConfig.Def_Quality_Orange) else 0
|
| | | aftIsOrangeEquip = 1 if curItem.GetItemColor() >= ChConfig.Def_Quality_Orange else 0
|
| | | |
| | | #--其他装备物品---
|
| | | #itemColor = curItem.GetItemColor()
|
| | | result = self.SwitchEquip(curItem, equipPackIndex)
|
| | | if result:
|
| | | #穿戴某阶某品质的装备成就
|
| | | PlayerSuccess.DoEquipSuccessLogic(curPlayer, classLV)
|
| | | #换装宝石处理
|
| | | Operate_EquipStone.DoMoveEquipStone(curPlayer, equipPackIndex)
|
| | | EventShell.EventRespons_EquipItem(curPlayer)
|
| | | dataDict = {'dotype':'EquipItem', 'desItemID':desItemID, 'desUserData':desUserData,'srcItemID':srcItemID,'srcUserData':srcUserData}
|
| | | DataRecordPack.Cache_FightPowerChangeInfo(curPlayer, ChConfig.PowerDownType_EquipChange, dataDict)
|
| | | self.__UpdEquipOrangeCount(befIsOrangeEquip, aftIsOrangeEquip)
|
| | | |
| | | self.RefreshStartEquipCount()
|
| | | return equipPlace if result else -1
|
| | | |
| | | def __UpdEquipOrangeCount(self, befIsOrangeEquip, aftIsOrangeEquip):
|
| | | #更新橙装数量
|
| | | curPlayer = self.__Player
|
| | | befEquipOrangeCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PlayerKey_EquipOrangeCount)
|
| | | aftEquipOrangeCount = max(0, befEquipOrangeCount + aftIsOrangeEquip - befIsOrangeEquip)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PlayerKey_EquipOrangeCount, aftEquipOrangeCount)
|
| | | GameWorld.DebugLog("更新橙装及以上件数: befIsOrangeEquip=%s,aftIsOrangeEquip=%s,befEquipOrangeCount=%s,aftEquipOrangeCount=%s" |
| | | % (befIsOrangeEquip, aftIsOrangeEquip, befEquipOrangeCount, aftEquipOrangeCount))
|
| | | return
|
| | |
|
| | | ## 替换可以叠加物品逻辑
|
| | | # @param curEquip 当前装备
|
| | |
| | | SetItemCount(curItem, sumValue - equipPackCount)
|
| | |
|
| | | return True
|
| | | |
| | | ## 卸载物品 |
| | | # @param equipIndex 装备索引
|
| | | # @param packIndex 背包索引
|
| | | # @return equipID , equipPlace
|
| | | # @remarks 函数详细说明.
|
| | | def UnEquipItem(self, equipIndex, packIndex):
|
| | | curPlayer = self.__Player
|
| | | equipItem = self.__PlayerEquip
|
| | | curEquip = equipItem.GetAt(equipIndex)
|
| | | #目标装备检查
|
| | | if curEquip == None or curEquip.IsEmpty():
|
| | | return
|
| | | |
| | | equipID = curEquip.GetItemTypeID()
|
| | | userData = curEquip.GetUserData()
|
| | | equipPlace = curEquip.GetEquipPlace()
|
| | | suiteID = curEquip.GetSuiteID()
|
| | | itemClassLV = ItemCommon.GetItemClassLV(curEquip)
|
| | | #该物品锁定不执行==============================================
|
| | | if curEquip.GetIsLocked():
|
| | | PlayerControl.NotifyCode(curPlayer, "RescannotEquip")
|
| | | return
|
| | | |
| | | if IsEventItem(curEquip):
|
| | | PlayerControl.NotifyCode(curPlayer, "TaskRes")
|
| | | return
|
| | | |
| | | #物品栏背包
|
| | | curPack = self.__PlayerItemManager.GetPack(IPY_GameWorld.rptItem)
|
| | | |
| | | if packIndex < 0 or packIndex >= curPack.GetCount():
|
| | | PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_676165", [IPY_GameWorld.rptItem])
|
| | | return
|
| | | |
| | | curEquipCount = curEquip.GetCount()
|
| | | |
| | | #装备为单数量物品无需遍历背包判定,以拖入的某个格子是否可以填充为判定 __CanDragItem
|
| | | #=======================================================================
|
| | | # if not self.CanPutInItem(IPY_GameWorld.rptItem, equipID, curEquipCount, curEquip.GetIsBind()):
|
| | | # #GameWorld.Log("玩家背包无法放入这个物品")
|
| | | # return
|
| | | #=======================================================================
|
| | | |
| | | #设置物品激活状态为False
|
| | | #curEquip.SetIsSoulActive(False)
|
| | | # if curEquip.GetItemStarLV() != 0:
|
| | | # curEquip.SetItemStarLV(0) # 脱下的物品星级设置为0
|
| | | |
| | | befIsOrangeEquip = 1 if curEquip.GetItemColor() >= ChConfig.Def_Quality_Orange else 0
|
| | | aftIsOrangeEquip = 0
|
| | | |
| | | #背包物品放入仓库
|
| | | if not DragItem(curPlayer, IPY_GameWorld.rptEquip, equipIndex, IPY_GameWorld.rptItem, packIndex, curEquipCount):
|
| | | return
|
| | | self.RefreshStartEquipCount()
|
| | | self.__UpdEquipOrangeCount(befIsOrangeEquip, aftIsOrangeEquip)
|
| | | |
| | | # 广播卸装
|
| | | if equipIndex in PlayerControl.GetFaceEquipIndexList(curPlayer) or equipPlace in ChConfig.Def_SyncEquipStateByIndex:
|
| | | curPlayer.Sync_UnEquipItem(equipID, equipIndex)
|
| | | if suiteID and itemClassLV == ChEquip.GetEquipFacadeClassLV(curPlayer):
|
| | | #脱当前外观阶的套装
|
| | | ChEquip.ChangeEquipfacadeByClassLV(curPlayer, itemClassLV)
|
| | | |
| | | EventShell.EventRespons_EquipItem(curPlayer)
|
| | | dataDict = {'dotype':'UnEquipItem', 'equipID':equipID, 'userData':userData}
|
| | | DataRecordPack.Cache_FightPowerChangeInfo(curPlayer, ChConfig.PowerDownType_EquipChange, dataDict)
|
| | | #===============================================================================
|
| | | # #destItemPlace = 卸下物品的位置 |
| | | # destItemPlace = curPack.GetAt(packIndex)
|
| | | # |
| | | # if destItemPlace == None or destItemPlace.IsEmpty() == 0:
|
| | | # #卸下目标不是空的
|
| | | # GameWorld.Log("卸下目标不是空的")
|
| | | # return
|
| | | # |
| | | # destItemPlace.PutIn(curEquip)
|
| | | #===============================================================================
|
| | | return equipID, equipPlace, itemClassLV
|
| | |
|
| | | #是否能放入物品(第几个物品栏, 物品序号, 放入的物品, 放入物品ID, 物品是否绑定)
|
| | | #===============================================================================
|
| | |
| | | def DoTransformItem(self, curPlayer, tagItem, event=["", False, {}]):
|
| | | ## 将特殊物品转化为对应数值
|
| | | itemID = tagItem.GetItemTypeID()
|
| | | itemCount = max(tagItem.GetUserAttr(ShareDefine.Def_IudetItemCount), tagItem.GetCount())
|
| | | itemCount = tagItem.GetCount()
|
| | | eventName, isForceEvent, addDict = event
|
| | | if isForceEvent:
|
| | | pass
|
| | |
| | | itemNoteDict = ItemCommon.GetItemNoteDict(item, canPutinCount, packItemCount, canPutinCount)
|
| | | ItemCommon.DR_GetItem(curPlayer, packIndex, eventName, itemNoteDict, addDict)
|
| | | else:
|
| | | #可以放下
|
| | | if isEquip:
|
| | | self.CheckEquipAttr(packIndex, tagItem)
|
| | | |
| | | if tagItem.GetGameWorldItemType() == IPY_GameWorld.gwitRoleItem:
|
| | | item.PutIn(tagItem)
|
| | | elif tagItem.GetGameWorldItemType() == IPY_GameWorld.gwitSingleItem:
|
| | |
| | | if isNeedRecord:
|
| | | itemNoteDict = ItemCommon.GetItemNoteDict(item, curItemCount, packItemCount, GetItemCount(item))
|
| | | ItemCommon.DR_GetItem(curPlayer, packIndex, eventName, itemNoteDict, addDict)
|
| | | |
| | | if item.GetType() == ChConfig.Def_ItemType_Hero:
|
| | | PlayerHero.OnGiveHeroItem(curPlayer, item)
|
| | | |
| | | break
|
| | |
|
| | | #放入东西
|
| | | return putResult
|
| | |
|
| | | def CheckEquipAttr(self, packType, curItem):
|
| | | legendAttrIDCount = curItem.GetUserAttrCount(ShareDefine.Def_IudetLegendAttrID)
|
| | | legendAttrValueCount = curItem.GetUserAttrCount(ShareDefine.Def_IudetLegendAttrValue)
|
| | | |
| | | if legendAttrIDCount and legendAttrValueCount and legendAttrIDCount == legendAttrValueCount:
|
| | | return
|
| | | |
| | | curPlayer = self.__Player
|
| | | legendAttrInfo = GetAddEquipLegendAttr(curItem, curPlayer)
|
| | | if not legendAttrInfo:
|
| | | return
|
| | | |
| | | curPlayer = self.__Player
|
| | | srcScore = ItemCommon.GetEquipGearScore(curItem)
|
| | | SetEquipLegendAttr(curItem, legendAttrInfo)
|
| | | ItemCommon.MakeEquipGS(curItem)
|
| | | updScore = ItemCommon.GetEquipGearScore(curItem)
|
| | | GameWorld.DebugLog("传奇属性异常,重新刷新一次属性: packType=%s,itemID=%s,srcScore=%s,updScore=%s" |
| | | % (packType, curItem.GetItemTypeID(), srcScore, updScore), curPlayer.GetPlayerID())
|
| | | return
|
| | |
|
| | | ## 是否能放入物品
|
| | | # @param packIndex 背包索引
|
| | | # @param curItemID 当前物品ID
|
| | |
| | | if endIndex == 0:
|
| | | endIndex = curPack.GetCount() - 1
|
| | | #检查是否能整理
|
| | | for i in range(0, curPack.GetCount()):
|
| | | curItem = curPack.GetAt(i)
|
| | | if curItem.GetIsLocked():
|
| | | #GameWorld.Log("物品有锁, 不允许重整")
|
| | | return
|
| | | #for i in range(0, curPack.GetCount()):
|
| | | # curItem = curPack.GetAt(i)
|
| | | # if curItem.GetIsLocked():
|
| | | # #GameWorld.Log("物品有锁, 不允许重整")
|
| | | # return
|
| | |
|
| | | # 整理方式不同区分
|
| | | if packIndex == IPY_GameWorld.rptWarehouse:
|
| | | if packIndex == ShareDefine.rptHero:
|
| | | if tick - curPlayer.GetResetItemTick() <= ChConfig.Def_ItemPackResetInterval:
|
| | | #GameWorld.DebugLog("重整背包时间间隔太短")
|
| | | return
|
| | | curPlayer.SetResetItemTick(tick)
|
| | | ResetHeroPack(curPlayer, curPack, beingIndex, endIndex)
|
| | | |
| | | elif packIndex == IPY_GameWorld.rptWarehouse:
|
| | | #验证间隔
|
| | | if tick - curPlayer.GetTickByType(ChConfig.TYPE_Player_Tick_WareHouseSort) < \
|
| | | ChConfig.TYPE_Player_Tick_Time[ChConfig.TYPE_Player_Tick_WareHouseSort]:
|
| | |
| | |
|
| | | ## 背包整理
|
| | | def ResetItem(curPlayer, packIndex, beingIndex, endIndex, tick):
|
| | |
|
| | | # 卡牌约定后端不整理背包,由前端自行排序
|
| | | #开始整理
|
| | | __DoResetItem(curPlayer, packIndex, beingIndex, endIndex, tick)
|
| | | curPlayer.Notify_PackResetOK()
|
| | | #__DoResetItem(curPlayer, packIndex, beingIndex, endIndex, tick)
|
| | | #curPlayer.Notify_PackResetOK()
|
| | | return
|
| | |
|
| | |
|
| | |
| | |
|
| | | return
|
| | |
|
| | | def ResetHeroPack(curPlayer, curPack, beingIndex, endIndex):
|
| | | itemList = []
|
| | | for i in range(beingIndex, endIndex + 1):
|
| | | curRoleItem = curPack.GetAt(i)
|
| | | if curRoleItem.IsEmpty():
|
| | | continue
|
| | | curItem = curRoleItem.GetItem() |
| | | itemList.append(curItem)
|
| | | itemList.sort(__CmpHeroPack)
|
| | | |
| | | curPack.WipePack(beingIndex, endIndex)
|
| | | putPlace = beingIndex
|
| | | for item in itemList:
|
| | | curPack.GetAt(putPlace).AssignItem(item, False)
|
| | | putPlace += 1
|
| | | |
| | | return
|
| | |
|
| | | def __CmpHeroPack(item1, item2):
|
| | | '''排序规则:上阵武将排前,未上阵武将排后,再各自按照以下规则排序
|
| | | 武将等级>突破等级>武将星级>武将品质>武将ID
|
| | | '''
|
| | | |
| | | posNum1, posNum2 = 0, 0
|
| | | for lpIndex in range(item1.GetUserAttrCount(ShareDefine.Def_IudetHeroLineup)):
|
| | | lineupValue = item1.GetUserAttrByIndex(ShareDefine.Def_IudetHeroLineup, lpIndex)
|
| | | lineupID, _, posNum = PlayerHero.GetLineupValue(lineupValue)
|
| | | if lineupID != ShareDefine.Lineup_Main:
|
| | | continue
|
| | | posNum1 = posNum
|
| | | break
|
| | | |
| | | for lpIndex in range(item2.GetUserAttrCount(ShareDefine.Def_IudetHeroLineup)):
|
| | | lineupValue = item2.GetUserAttrByIndex(ShareDefine.Def_IudetHeroLineup, lpIndex)
|
| | | lineupID, _, posNum = PlayerHero.GetLineupValue(lineupValue)
|
| | | if lineupID != ShareDefine.Lineup_Main:
|
| | | continue
|
| | | posNum2 = posNum
|
| | | break
|
| | | |
| | | if (posNum1 and posNum2) or (not posNum1 and not posNum2):
|
| | | lv1 = item1.GetUserAttr(ShareDefine.Def_IudetHeroLV)
|
| | | lv2 = item2.GetUserAttr(ShareDefine.Def_IudetHeroLV)
|
| | | if lv1 == lv2:
|
| | | bLV1 = item1.GetUserAttr(ShareDefine.Def_IudetHeroBreakLV)
|
| | | bLV2 = item2.GetUserAttr(ShareDefine.Def_IudetHeroBreakLV)
|
| | | if bLV1 == bLV2:
|
| | | star1 = item1.GetUserAttr(ShareDefine.Def_IudetHeroStar)
|
| | | star2 = item2.GetUserAttr(ShareDefine.Def_IudetHeroStar)
|
| | | if star1 == star2:
|
| | | heroID1 = item1.GetItemTypeID()
|
| | | heroID2 = item2.GetItemTypeID()
|
| | | ipyData1 = IpyGameDataPY.GetIpyGameData("Hero", heroID1)
|
| | | ipyData2 = IpyGameDataPY.GetIpyGameData("Hero", heroID2)
|
| | | quality1 = ipyData1.GetQuality() if ipyData1 else 0
|
| | | quality2 = ipyData2.GetQuality() if ipyData2 else 0
|
| | | if quality1 == quality2:
|
| | | return cmp(heroID1, heroID2)
|
| | | return -cmp(quality1, quality2)
|
| | | return -cmp(star1, star2)
|
| | | return -cmp(bLV1, bLV2)
|
| | | return -cmp(lv1, lv2)
|
| | | elif posNum1:
|
| | | return -1
|
| | | elif posNum2:
|
| | | return 1
|
| | | else:
|
| | | return cmp(item1.GetItemTypeID(), item2.GetItemTypeID())
|
| | | |
| | | #===============================================================================
|
| | | #Python 版重整物品
|
| | | # def ResetItem(curPlayer, curPackIndex, tick):
|
| | |
| | |
|
| | | return
|
| | |
|
| | | ## 清除背包中的任务物品
|
| | | # @param curPlayer 当前玩家
|
| | | # @param packIndex 背包类型
|
| | | # @return None
|
| | | # @remarks 函数详细说明.
|
| | | def ClearPackEventItem(curPlayer , packIndex):
|
| | | curPack = curPlayer.GetItemManager().GetPack(packIndex)
|
| | | itemList = []
|
| | | def CheckGiveBindMoneyTypeItem(curPlayer, checkMoneyType=None):
|
| | | ## 检查给绑定货币的展示物品
|
| | | bindMoneyItemInfo = IpyGameDataPY.GetFuncEvalCfg("PutInItemPack", 2, {})
|
| | |
|
| | | for i in range(0, curPack.GetCount()):
|
| | | item = curPack.GetAt(i)
|
| | | #空物品
|
| | | if not item or item.IsEmpty():
|
| | | needMoneyItemDict = {}
|
| | | for itemIDStr, moneyType in bindMoneyItemInfo.items():
|
| | | if checkMoneyType != None and moneyType != checkMoneyType:
|
| | | continue
|
| | | |
| | | #不是任务物品
|
| | | if not IsEventItem(item):
|
| | | if PlayerControl.GetMoney(curPlayer, moneyType): # 有货币时才需要
|
| | | needMoneyItemDict[int(itemIDStr)] = moneyType
|
| | | |
| | | if not needMoneyItemDict:
|
| | | #GameWorld.DebugLog("绑定货币显示物品已经都有了")
|
| | | return
|
| | | |
| | | curPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
|
| | | for i in xrange(curPack.GetCount()):
|
| | | curItem = curPack.GetAt(i)
|
| | | if not curItem or curItem.IsEmpty():
|
| | | continue
|
| | | |
| | | itemList.append(item)
|
| | | |
| | | curPlayerID = curPlayer.GetID()
|
| | | |
| | | for item in itemList:
|
| | | GameWorld.Log('###清空背包 = %s 中的任务物品 = %s' % (packIndex , item.GetItemTypeID()) , curPlayerID)
|
| | | item.Clear()
|
| | | itemID = curItem.GetItemTypeID()
|
| | | if itemID in needMoneyItemDict:
|
| | | needMoneyItemDict.pop(itemID)
|
| | | if not needMoneyItemDict:
|
| | | break
|
| | | |
| | | # 还有没给的物品补给,后端只负责给物品,不处理个数,前端对该类物品默认绑定货币对应的值来显示个数
|
| | | for itemID, moneyType in needMoneyItemDict.items():
|
| | | if not GivePlayerItem(curPlayer, itemID, 1, False, [IPY_GameWorld.rptItem]):
|
| | | break
|
| | | GameWorld.DebugLog("给绑定货币显示物品: moneyType=%s,itemID=%s" % (moneyType, itemID))
|
| | |
|
| | | return
|
| | |
|
| | | def GivePlayerItem(curPlayer, itemID, itemCount, isAuctionItem, packIndexList=None, event=["", False, {}]):
|
| | | def GivePlayerItem(curPlayer, itemID, itemCount, isAuctionItem, packIndexList=None, event=["", False, {}], setAttrDict=None):
|
| | | '''给玩家物品
|
| | | @param isAuctionItem: 是否拍品
|
| | | '''
|
| | |
| | | #不可放入
|
| | | return False
|
| | |
|
| | | #定制物品
|
| | | if GetAppointItemRealID(itemID):
|
| | | isOK = False
|
| | | for _ in xrange(itemCount):
|
| | | if GivePlayerAppointItem(curPlayer, itemID, isAuctionItem, event):
|
| | | isOK = True # 只要有成功的就返回成功,防止异常情况失败可能导致被刷
|
| | | return isOK
|
| | | |
| | | #装备
|
| | | if ItemCommon.GetIsEquip(curItemData):
|
| | | isOK = False
|
| | | for _ in xrange(itemCount):
|
| | | outPutEquip = GetOutPutItemObj(itemID, 1, isAuctionItem, curPlayer=curPlayer)
|
| | | outPutEquip = GetOutPutItemObj(itemID, 1, isAuctionItem, curPlayer=curPlayer, setAttrDict=setAttrDict)
|
| | | if not outPutEquip:
|
| | | return isOK
|
| | | if DoLogic_PutItemInPack(curPlayer, outPutEquip, event, packIndexList):
|
| | |
| | |
|
| | | #常规物品
|
| | | isOK = False
|
| | | for _ in range(itemCount/65535 + 1):
|
| | | for _ in range(itemCount/ChConfig.Def_ItemCount_Max + 1):
|
| | | if itemCount <= 0:
|
| | | break
|
| | | giveItem = GetOutPutItemObj(itemID, itemCount, isAuctionItem, curPlayer=curPlayer)
|
| | | giveItem = GetOutPutItemObj(itemID, itemCount, isAuctionItem, curPlayer=curPlayer, setAttrDict=setAttrDict)
|
| | | if not giveItem:
|
| | | return isOK
|
| | | giveCount = GetItemCount(giveItem)
|
| | |
| | | # @return: 给成功总数,0代表给失败了
|
| | |
|
| | | giveOKCount = 0
|
| | | for _ in range(itemCount/65535 + 1):
|
| | | for _ in range(itemCount/ChConfig.Def_ItemCount_Max + 1):
|
| | | if giveOKCount >= itemCount:
|
| | | break
|
| | | giveItem = GetOutPutItemObj(itemID, itemCount - giveOKCount, isAuctionItem, curPlayer=curPlayer)
|
| | |
| | | giveOKCount += curCount
|
| | |
|
| | | return giveOKCount
|
| | |
|
| | | def GivePlayerAppointItem(curPlayer, appointID, isAuctionItem, event=["", False, {}]):
|
| | | '''给玩家定制物品表物品,定制物品默认个数1
|
| | | @param appointID 定制表ID
|
| | | @param isAuctionItem 是否拍品
|
| | | '''
|
| | | itemDictData = GetAppointItemDictData(appointID, isAuctionItem)
|
| | | if not itemDictData:
|
| | | return False
|
| | | |
| | | return GivePlayerEquip(curPlayer, itemDictData, event=event)
|
| | |
|
| | | def GetAppointItemDictData(appointID, isAuctionItem):
|
| | | '''获取定制表物品数据,定制物品默认个数1
|
| | | @param appointID 定制表ID
|
| | | @param isAuctionItem 是否拍品
|
| | | '''
|
| | | itemID = GetAppointItemRealID(appointID)
|
| | | if not itemID:
|
| | | return {}
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("AppointItem", appointID)
|
| | | if not ipyData:
|
| | | return {}
|
| | | itemDictData = {}
|
| | | |
| | | itemDictData['legendAttrID'] = ipyData.GetLegendAttrID()
|
| | | itemDictData['legendAttrValue'] = ipyData.GetLegendAttrValue()
|
| | | itemDictData['ItemID'] = itemID
|
| | | itemDictData['CancelUseLimit'] = ipyData.GetCancelUseLimit()
|
| | | |
| | | itemDictData['IsAuctionItem'] = isAuctionItem
|
| | | |
| | | return itemDictData
|
| | |
|
| | | def GetAppointItemRealID(itemID):
|
| | | '''获取定制物品对应的真实物品ID'''
|
| | | curItem = GameWorld.GetGameData().GetItemByTypeID(itemID)
|
| | | if not curItem:
|
| | | return 0
|
| | | curEff = curItem.GetEffectByIndex(0)
|
| | | curEffID = curEff.GetEffectID()
|
| | | if curEffID != ChConfig.Def_Effect_AppointItem:
|
| | | return 0
|
| | | return curEff.GetEffectValue(0)
|
| | |
|
| | | ## 根据物品data字典给玩家装备/翅膀
|
| | | # @param curPlayer:玩家实例
|
| | | # @param itemData:物品数据
|
| | | # @param packType:背包类型
|
| | | # @param defaultPile 默认先判断是否能进行物品堆叠
|
| | | # @return None
|
| | | def GivePlayerEquip(curPlayer, itemData, event=["", False, {}], packType=[IPY_GameWorld.rptItem, IPY_GameWorld.rptAnyWhere],
|
| | | defaultPile=True):
|
| | | equipItem = GetItemByData(itemData)
|
| | | #将物品放入背包
|
| | | return DoLogic_PutItemInPack(curPlayer, equipItem, event, packType, defaultPile)
|
| | |
|
| | |
|
| | | ## 根据物品data字典创建物品
|
| | | # @param itemData:物品数据
|
| | | # @return ItemObj
|
| | | def GetItemByData(itemData):
|
| | | if not itemData:
|
| | | return
|
| | | |
| | | itemID = int(itemData.get('ItemID', 0))
|
| | | isAuctionItem = int(itemData.get('IsAuctionItem', 0))
|
| | | equipItem = ItemCommon.CreateSingleItem(itemID, isAuctionItem=isAuctionItem)
|
| | | if not equipItem:
|
| | | return
|
| | | |
| | | tmpEquipData = SingleEquipTmpData()
|
| | | |
| | | #tmpEquipData.starLV = int(itemData.get('StarLV', '0'))
|
| | | #tmpEquipData.holeCnt = int(itemData.get('HoleCount', '0'))
|
| | | #tmpEquipData.stoneData = eval(itemData.get('StoneData', '[]'))
|
| | | tmpEquipData.isBind = isAuctionItem
|
| | | #tmpEquipData.isSuite = int(itemData.get('IsSuit', '0'))
|
| | | #tmpEquipData.suiteLV = int(itemData.get('SuiteLV', '0'))
|
| | | #if tmpEquipData.suiteLV:
|
| | | # tmpEquipData.isSuite = 1
|
| | | tmpEquipData.source = int(itemData.get('Source', str(ShareDefine.Item_Source_Unkown)))
|
| | | |
| | | tmpEquipData.legendAttrIDList = itemData.get('legendAttrID', [])
|
| | | tmpEquipData.legendAttrValueList = itemData.get('legendAttrValue', [])
|
| | | |
| | | # 装备附加属性
|
| | | ChItem.EquipAddAdditionEx(equipItem, tmpEquipData)
|
| | | |
| | | if "UserData" in itemData:
|
| | | userData = itemData["UserData"]
|
| | | ItemCommon.SetItemUserData(equipItem, userData)
|
| | | |
| | | if "EquipGS" in itemData:
|
| | | equipGS = int(itemData["EquipGS"])
|
| | | ItemCommon.SetEquipGearScore(equipItem, equipGS)
|
| | | |
| | | |
| | | # 取消等级限制
|
| | | if itemData.get('CancelUseLimit', 0):
|
| | | equipItem.SetUserAttr(ShareDefine.Def_IudetCancelUseLimit, 1)
|
| | | |
| | | return equipItem
|
| | |
|
| | |
|
| | | #---------------------------------------------------------------------
|
| | | ## 执行物品放入背包逻辑
|
| | |
| | | if isAuctionItem:
|
| | | curItem.SetUserAttr(ShareDefine.Def_IudetAuctionItemCreateTime, int(time.time()))
|
| | | return
|
| | | |
| | | if not curPlayer:
|
| | | return
|
| | | |
| | | if ItemCommon.GetIsEquip(curItem):
|
| | | legendAttrIDCnt = curItem.GetUserAttrCount(ShareDefine.Def_IudetLegendAttrID)
|
| | | legendAttrValueCnt = curItem.GetUserAttrCount(ShareDefine.Def_IudetLegendAttrValue)
|
| | | if legendAttrIDCnt and legendAttrIDCnt == legendAttrValueCnt:
|
| | | legendAttrInfo = GetEquipLegendAttrGroup(curItem)
|
| | | #GameWorld.DebugLog("已经有传奇属性的拍品: %s" % str(legendAttrInfo))
|
| | | else:
|
| | | # 生成传奇属性
|
| | | legendAttrInfo = GetAddEquipLegendAttr(curItem, curPlayer)
|
| | | #GameWorld.DebugLog("重新生成传奇属性的拍品: %s" % str(legendAttrInfo))
|
| | | if not legendAttrInfo:
|
| | | return
|
| | | |
| | | updateDict = {}
|
| | | if legendAttrInfo[0]:
|
| | | updateDict[ShareDefine.Def_IudetLegendAttrID] = legendAttrInfo[0]
|
| | | updateDict[ShareDefine.Def_IudetLegendAttrValue] = legendAttrInfo[1]
|
| | | if legendAttrInfo[2]:
|
| | | updateDict[ShareDefine.Def_IudetLegendAttrIDShen] = legendAttrInfo[2]
|
| | | updateDict[ShareDefine.Def_IudetLegendAttrValueShen] = legendAttrInfo[3]
|
| | | if legendAttrInfo[4]:
|
| | | updateDict[ShareDefine.Def_IudetLegendAttrIDXian] = legendAttrInfo[4]
|
| | | updateDict[ShareDefine.Def_IudetLegendAttrValueXian] = legendAttrInfo[5]
|
| | | if legendAttrInfo[6]:
|
| | | updateDict[ShareDefine.Def_IudetLegendAttrIDJi] = legendAttrInfo[6]
|
| | | updateDict[ShareDefine.Def_IudetLegendAttrValueJi] = legendAttrInfo[7]
|
| | | |
| | | delKeyList = [ShareDefine.Def_IudetAuctionItemCreateTime]
|
| | | ItemCommon.UpdateItemUserData(curItem, updateDict, delKeyList, isUpdateGS=True)
|
| | | |
| | | return
|
| | |
|
| | | def GetItemCountByID(curPlayer, itemID):
|
| | |
| | | # @return None
|
| | | def SetItemCount(item, cnt, playerID=0, accID=0, playerName=""):
|
| | | if not item.IsEmpty():
|
| | | if cnt > 0 and IsPutinAutoTransformItem(item):
|
| | | item.SetUserAttr(ShareDefine.Def_IudetItemCount, min(cnt, ChConfig.Def_UpperLimit_DWord))
|
| | | else:
|
| | | item.SetCount(min(cnt, 65535))
|
| | | item.SetCount(min(cnt, ChConfig.Def_ItemCount_Max))
|
| | | else:
|
| | | try:
|
| | | 1 / 0
|
| | |
| | | GameWorld.ErrLog(errorInfo + str(traceback.extract_stack()) + "\n" + traceback.format_exc())
|
| | | raise
|
| | |
|
| | | def GetItemCount(item):
|
| | | if IsPutinAutoTransformItem(item):
|
| | | return item.GetUserAttr(ShareDefine.Def_IudetItemCount)
|
| | | return item.GetCount()
|
| | | def GetItemCount(item): return item.GetCount()
|
| | |
|
| | | def GetItemNeedPackCount(packType, itemData, itemCount, isAuctionItem=0):
|
| | | # 20201223 主干取消拍品有效时长设定
|
| | |
| | | return True
|
| | | return False
|
| | |
|
| | | ## 双手武器,需要两只手才拿得动
|
| | | # @param curEquip
|
| | | # @return bool
|
| | | def IsTwoHandedWeapon(curEquip):
|
| | | return curEquip.IsBothHands() == ShareDefine.Def_Weapon_Two_Handed
|
| | |
|
| | |
|
| | | ## 双持武器,左右手都可以拿得起来的武器
|
| | | # @param curEquip
|
| | | # @return bool
|
| | | def IsDualWeapons(curEquip):
|
| | | return curEquip.IsBothHands() == ShareDefine.Def_Weapon_Dual_Hands
|
| | |
|
| | |
|
| | | ## 装备多位置装备处理
|
| | | # @param equipPack 当前装备背包
|
| | | # @param packEquipIndex 客户端发来装备位置(IPY_GameWorld.retMax 代表服务器自动装备)
|
| | | # @param placeList 可装备的位置列表
|
| | | # @return 装备位置
|
| | | def GetMultiPlaceEquipPlace(equipPack, packEquipIndex, placeList):
|
| | | |
| | | #---客户端指定位置---
|
| | | if packEquipIndex in placeList:
|
| | | return packEquipIndex
|
| | | |
| | | #---服务端判断空位置---
|
| | | for placeIndex in placeList:
|
| | | curEquip = equipPack.GetAt(placeIndex)
|
| | | |
| | | if curEquip.IsEmpty():
|
| | | return placeIndex
|
| | | |
| | | elif IsTwoHandedWeapon(curEquip):
|
| | | #武器特殊处理,双手直接交换
|
| | | return placeIndex
|
| | | |
| | | #---无空位置,替换---
|
| | | return placeList[0]
|
| | |
|
| | | def GetOutPutItemObj(itemID, itemCount=1, isAuctionItem=False, expireTime=0, curPlayer=None, isAllAttr=False):
|
| | | def GetOutPutItemObj(itemID, itemCount=1, isAuctionItem=False, expireTime=0, curPlayer=None, setAttrDict=None):
|
| | | ''' 获取功能产出的物品实例
|
| | | @param isAuctionItem: 是否拍品,默认非拍品
|
| | | @param expireTime: 有效时间,时间单位由时效类型决定
|
| | | @param curPlayer: 产出该物品时的玩家,物品某些属性由玩家等级决定,如传奇属性
|
| | | @param isAllAttr: 是否生成该装备所有属性,GM创建物品时用,需验证相关权限
|
| | | @param setAttrDict: 直接设置物品的属性 {key:value, ...} key支持 ShareDefine.Def_IudetXXX字符串 或 自定key
|
| | | '''
|
| | | curItem = ItemCommon.CreateSingleItem(itemID, itemCount, isAuctionItem, expireTime)
|
| | | curItem = ItemCommon.CreateSingleItem(itemID, itemCount, isAuctionItem, expireTime, curPlayer, setAttrDict)
|
| | | if not curItem:
|
| | | GameWorld.ErrLog("产出物品异常,无法创建物品 = %s" % (itemID))
|
| | | return
|
| | | |
| | | # 非装备,无需设置属性
|
| | | if not ItemCommon.CheckItemIsEquip(curItem):
|
| | | return curItem
|
| | | |
| | | # 定制物品
|
| | | if GetAppointItemRealID(itemID):
|
| | | curItem.Clear()
|
| | | #GameWorld.DebugLog("清除给定制物品之前已经创建的物品ID=%s" % itemID)
|
| | | return GetItemByData(GetAppointItemDictData(itemID, isAuctionItem))
|
| | | |
| | | # # 拍品不处理其他属性
|
| | | # if isAuctionItem:
|
| | | # return curItem
|
| | | |
| | | tmpEquipData = SingleEquipTmpData()
|
| | | |
| | | # 传奇属性
|
| | | legendAttrInfo = GetAddEquipLegendAttr(curItem, curPlayer, isAllAttr)
|
| | | if legendAttrInfo:
|
| | | tmpEquipData.legendAttrIDList = legendAttrInfo[0]
|
| | | tmpEquipData.legendAttrValueList = legendAttrInfo[1]
|
| | | tmpEquipData.legendAttrIDListShen = legendAttrInfo[2]
|
| | | tmpEquipData.legendAttrValueListShen = legendAttrInfo[3]
|
| | | tmpEquipData.legendAttrIDListXian = legendAttrInfo[4]
|
| | | tmpEquipData.legendAttrValueListXian = legendAttrInfo[5]
|
| | | tmpEquipData.legendAttrIDListJi = legendAttrInfo[6]
|
| | | tmpEquipData.legendAttrValueListJi = legendAttrInfo[7]
|
| | | |
| | | # 其他装备属性
|
| | | ChItem.EquipAddAdditionEx(curItem, tmpEquipData)
|
| | | return curItem
|
| | |
|
| | | def GetAddEquipLegendAttr(curItem, curPlayer, isAllAttr=False):
|
| | | '''获取生成到装备上的传奇属性
|
| | | @return: None 或者 [传奇属性效果ID列表], [属性值列表], [神ID], [神值], [仙ID], [仙值], [极ID], [极值]
|
| | | '''
|
| | | # if GetIsAuctionItem(curItem):
|
| | | # #GameWorld.DebugLog("拍品无法生成传奇属性!")
|
| | | # return
|
| | | itemID = curItem.GetItemTypeID()
|
| | | itemType = curItem.GetType()
|
| | | itemColor = curItem.GetItemColor()
|
| | | itemQuality = curItem.GetItemQuality()
|
| | | isSuit = 1 if curItem.GetSuiteID() else 0
|
| | | |
| | | ipyData = IpyGameDataPY.GetIpyGameDataNotLog("EquipShenAttr", itemID)
|
| | | if ipyData:
|
| | | return ipyData.GetLegendAttrIDList(), ipyData.GetLegendAttrValueList(), \
|
| | | ipyData.GetShenAttrIDList(), ipyData.GetShenAttrValueList(), \
|
| | | ipyData.GetXianAttrIDList(), ipyData.GetXianAttrValueList(), \
|
| | | ipyData.GetJiAttrIDList(), ipyData.GetJiAttrValueList()
|
| | | |
| | | # 1. 定条数
|
| | | attrCountIpyData = IpyGameDataPY.GetIpyGameDataNotLog("EquipLegendAttrCount", itemType, itemColor, isSuit, itemQuality)
|
| | | if not attrCountIpyData:
|
| | | if itemColor >= ChConfig.Def_Quality_Purple:
|
| | | GameWorld.DebugLog("该装备没有传奇属性: itemID=%s" % (itemID))
|
| | | return
|
| | | legendAttrCountInfoList = attrCountIpyData.GetLegendAttrCountInfo() # 传奇属性条数信息 [[条数, [属性类型库编号, ...]], ...]
|
| | | if not legendAttrCountInfoList:
|
| | | return
|
| | | |
| | | if curPlayer:
|
| | | playerID, playerLV = curPlayer.GetPlayerID(), curPlayer.GetLV()
|
| | | else:
|
| | | playerID = 0
|
| | | playerLV = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_WorldAverageLv)
|
| | | GameWorld.Log("生成装备传奇属性时没有玩家等级, 取当前世界等级! itemID=%s,worldLV=%s" % (itemID, playerLV))
|
| | | |
| | | # 2. 定属性ID
|
| | | attrTypeIpyData = IpyGameDataPY.GetIpyGameData("EquipLegendAttrType", itemType)
|
| | | if not attrTypeIpyData:
|
| | | return
|
| | | legendAttrTypeLibDict = attrTypeIpyData.GetLegendAttrTypeLib() # 传奇属性类型库 {属性类型库编号:[属性ID,...], ...}
|
| | | |
| | | curLegAttrIDList = []
|
| | | curLegAttrValueList = []
|
| | | itemClassLV = ItemCommon.GetItemClassLV(curItem)
|
| | | if isAllAttr:
|
| | | if curPlayer.GetGMLevel() != 90:
|
| | | return
|
| | | for attrIDList in legendAttrTypeLibDict.values():
|
| | | curLegAttrIDList += attrIDList
|
| | | #GameWorld.DebugLog("所有传奇属性: %s" % (curLegAttrIDList), playerID)
|
| | | else:
|
| | | #GameWorld.DebugLog("随机传奇属性: itemID=%s,itemType=%s,itemClassLV=%s,itemColor=%s,isSuit=%s" |
| | | # % (itemID, itemType, itemClassLV, itemColor, isSuit), playerID)
|
| | | for attrCount, libNumList in legendAttrCountInfoList:
|
| | | attrIDList = []
|
| | | for libNum in libNumList:
|
| | | attrIDList.extend(legendAttrTypeLibDict.get(libNum, []))
|
| | | for curAttrID in curLegAttrIDList:
|
| | | if curAttrID in attrIDList:
|
| | | attrIDList.remove(curAttrID)
|
| | | if len(attrIDList) < attrCount:
|
| | | GameWorld.ErrLog("装备传奇属性ID库配置不够条数随机!itemID=%s,itemType=%s,legendAttrCountInfoList=%s,legendAttrTypeLibDict=%s" |
| | | % (itemID, itemType, legendAttrCountInfoList, legendAttrTypeLibDict), playerID)
|
| | | return
|
| | | curLegAttrIDList += random.sample(attrIDList, attrCount)
|
| | | #GameWorld.DebugLog(" 随机传奇属性: attrCount=%s,libNumList=%s,attrIDList=%s,curLegAttrIDList=%s" |
| | | # % (attrCount, libNumList, attrIDList, curLegAttrIDList), playerID)
|
| | | |
| | | # 3. 定数值
|
| | | attrValueIpyData = IpyGameDataPY.GetIpyGameData("EquipLegendAttrValue", itemType, itemClassLV, itemColor, isSuit, itemQuality)
|
| | | if not attrValueIpyData:
|
| | | GameWorld.ErrLog("传奇属性等级数值表找不到配置!itemID=%s,itemType=%s,itemClassLV=%s,itemColor=%s,isSuit=%s,itemQuality=%s" |
| | | % (itemID, itemType, itemClassLV, itemColor, isSuit, itemQuality), playerID)
|
| | | return
|
| | | |
| | | attrLVLibNumDict = attrValueIpyData.GetLVLegendAttrLibNumInfo() # {属性ID:{等级:库编号, ...}}
|
| | | for attrID in curLegAttrIDList:
|
| | | if attrID not in attrLVLibNumDict:
|
| | | GameWorld.ErrLog("传奇属性等级数值表没有配置属性ID对应等级库编号!itemID=%s,itemType=%s,itemClassLV=%s,itemColor=%s,isSuit=%s,attrID=%s" |
| | | % (itemID, itemType, itemClassLV, itemColor, isSuit, attrID), playerID)
|
| | | return
|
| | | curLibNum = None
|
| | | lvAttrLibList = attrLVLibNumDict[attrID]
|
| | | for lv, libNum in lvAttrLibList:
|
| | | if playerLV <= lv:
|
| | | curLibNum = libNum
|
| | | break
|
| | | if curLibNum == None:
|
| | | GameWorld.ErrLog("传奇属性等级数值表找不到属性ID对应等级库编号!itemID=%s,itemType=%s,itemClassLV=%s,itemColor=%s,isSuit=%s,attrID=%s,playerLV=%s" |
| | | % (itemID, itemType, itemClassLV, itemColor, isSuit, attrID, playerLV), playerID)
|
| | | return
|
| | | attrLibIpyData = attrValueIpyData = IpyGameDataPY.GetIpyGameData("EquipLegendAttrLib", attrID)
|
| | | if not attrLibIpyData:
|
| | | GameWorld.ErrLog("传奇属性库不存在传奇属性ID配置!itemID=%s,attrID=%s" % (itemID, attrID), playerID)
|
| | | return
|
| | | attrLibDict = attrLibIpyData.GetLegendAttrLib() # {库编号:[随机数值, ...], ...}
|
| | | if curLibNum not in attrLibDict:
|
| | | GameWorld.ErrLog("传奇属性库编号不存在!itemID=%s,attrID=%s,curLibNum=%s" % (itemID, attrID, curLibNum), playerID)
|
| | | return
|
| | | valueList = attrLibDict[curLibNum]
|
| | | attrValue = random.choice(valueList)
|
| | | curLegAttrValueList.append(attrValue)
|
| | | #GameWorld.DebugLog(" 随机属性: attrID=%s,attrValue=%s,playerLV=%s,curLibNum=%s,valueList=%s" |
| | | # % (attrID, attrValue, playerLV, curLibNum, valueList), playerID)
|
| | | return curLegAttrIDList, curLegAttrValueList, [], [], [], [], [], []
|
| | |
|
| | | def GetEquipLegendAttrAll(curItem):
|
| | | ## 获取装备传奇属性 - 所有分组合并返回
|
| | | legendAttrInfo = GetEquipLegendAttrGroup(curItem)
|
| | | legAttrIDList = legendAttrInfo[0] + legendAttrInfo[2] + legendAttrInfo[4] + legendAttrInfo[6]
|
| | | legAttrValueList = legendAttrInfo[1] + legendAttrInfo[3] + legendAttrInfo[5] + legendAttrInfo[7]
|
| | | return legAttrIDList, legAttrValueList
|
| | |
|
| | | def GetEquipLegendAttrGroup(curItem):
|
| | | ## 获取装备传奇属性 - 按类型分组返回
|
| | | |
| | | legAttrIDList, legAttrValueList = [], []
|
| | | legendAttrIDCnt = curItem.GetUserAttrCount(ShareDefine.Def_IudetLegendAttrID)
|
| | | legendAttrValueCnt = curItem.GetUserAttrCount(ShareDefine.Def_IudetLegendAttrValue)
|
| | | if legendAttrIDCnt == legendAttrValueCnt:
|
| | | for i in xrange(legendAttrIDCnt):
|
| | | legAttrIDList.append(curItem.GetUserAttrByIndex(ShareDefine.Def_IudetLegendAttrID, i))
|
| | | legAttrValueList.append(curItem.GetUserAttrByIndex(ShareDefine.Def_IudetLegendAttrValue, i))
|
| | | |
| | | shenAttrIDList, shenAttrValueList = [], []
|
| | | shenAttrIDCnt = curItem.GetUserAttrCount(ShareDefine.Def_IudetLegendAttrIDShen)
|
| | | shenAttrValueCnt = curItem.GetUserAttrCount(ShareDefine.Def_IudetLegendAttrValueShen)
|
| | | if shenAttrIDCnt == shenAttrValueCnt:
|
| | | for i in xrange(shenAttrIDCnt):
|
| | | shenAttrIDList.append(curItem.GetUserAttrByIndex(ShareDefine.Def_IudetLegendAttrIDShen, i))
|
| | | shenAttrValueList.append(curItem.GetUserAttrByIndex(ShareDefine.Def_IudetLegendAttrValueShen, i))
|
| | | |
| | | xianAttrIDList, xianAttrValueList = [], []
|
| | | xianAttrIDCnt = curItem.GetUserAttrCount(ShareDefine.Def_IudetLegendAttrIDXian)
|
| | | xianAttrValueCnt = curItem.GetUserAttrCount(ShareDefine.Def_IudetLegendAttrValueXian)
|
| | | if xianAttrIDCnt == xianAttrValueCnt:
|
| | | for i in xrange(xianAttrIDCnt):
|
| | | xianAttrIDList.append(curItem.GetUserAttrByIndex(ShareDefine.Def_IudetLegendAttrIDXian, i))
|
| | | xianAttrValueList.append(curItem.GetUserAttrByIndex(ShareDefine.Def_IudetLegendAttrValueXian, i))
|
| | | |
| | | jiAttrIDList, jiAttrValueList = [], []
|
| | | jiAttrIDCnt = curItem.GetUserAttrCount(ShareDefine.Def_IudetLegendAttrIDJi)
|
| | | jiAttrValueCnt = curItem.GetUserAttrCount(ShareDefine.Def_IudetLegendAttrValueJi)
|
| | | if jiAttrIDCnt == jiAttrValueCnt:
|
| | | for i in xrange(jiAttrIDCnt):
|
| | | jiAttrIDList.append(curItem.GetUserAttrByIndex(ShareDefine.Def_IudetLegendAttrIDJi, i))
|
| | | jiAttrValueList.append(curItem.GetUserAttrByIndex(ShareDefine.Def_IudetLegendAttrValueJi, i))
|
| | | |
| | | return legAttrIDList, legAttrValueList, shenAttrIDList, shenAttrValueList, xianAttrIDList, xianAttrValueList, jiAttrIDList, jiAttrValueList
|
| | |
|
| | | def SetEquipLegendAttr(curItem, legendAttrInfo):
|
| | | ## 设置装备传奇属性
|
| | | |
| | | legAttrIDList, legAttrValueList, shenAttrIDList, shenAttrValueList, \
|
| | | xianAttrIDList, xianAttrValueList, jiAttrIDList, jiAttrValueList = legendAttrInfo
|
| | | |
| | | # 普通传奇属性
|
| | | if legAttrIDList and legAttrValueList and len(legAttrIDList) == len(legAttrValueList):
|
| | | curItem.ClearUserAttr(ShareDefine.Def_IudetLegendAttrID)
|
| | | curItem.ClearUserAttr(ShareDefine.Def_IudetLegendAttrValue)
|
| | | for i in xrange(len(legAttrIDList)):
|
| | | curItem.AddUserAttr(ShareDefine.Def_IudetLegendAttrID, legAttrIDList[i])
|
| | | curItem.AddUserAttr(ShareDefine.Def_IudetLegendAttrValue, legAttrValueList[i])
|
| | | |
| | | # 神 传奇属性
|
| | | if shenAttrIDList and shenAttrValueList and len(shenAttrIDList) == len(shenAttrValueList):
|
| | | curItem.ClearUserAttr(ShareDefine.Def_IudetLegendAttrIDShen)
|
| | | curItem.ClearUserAttr(ShareDefine.Def_IudetLegendAttrValueShen)
|
| | | for i in xrange(len(shenAttrIDList)):
|
| | | curItem.AddUserAttr(ShareDefine.Def_IudetLegendAttrIDShen, shenAttrIDList[i])
|
| | | curItem.AddUserAttr(ShareDefine.Def_IudetLegendAttrValueShen, shenAttrValueList[i])
|
| | | |
| | | # 仙 传奇属性
|
| | | if xianAttrIDList and xianAttrValueList and len(xianAttrIDList) == len(xianAttrValueList):
|
| | | curItem.ClearUserAttr(ShareDefine.Def_IudetLegendAttrIDXian)
|
| | | curItem.ClearUserAttr(ShareDefine.Def_IudetLegendAttrValueXian)
|
| | | for i in xrange(len(xianAttrIDList)):
|
| | | curItem.AddUserAttr(ShareDefine.Def_IudetLegendAttrIDXian, xianAttrIDList[i])
|
| | | curItem.AddUserAttr(ShareDefine.Def_IudetLegendAttrValueXian, xianAttrValueList[i])
|
| | | |
| | | # 极 传奇属性
|
| | | if jiAttrIDList and jiAttrValueList and len(jiAttrIDList) == len(jiAttrValueList):
|
| | | curItem.ClearUserAttr(ShareDefine.Def_IudetLegendAttrIDJi)
|
| | | curItem.ClearUserAttr(ShareDefine.Def_IudetLegendAttrValueJi)
|
| | | for i in xrange(len(jiAttrIDList)):
|
| | | curItem.AddUserAttr(ShareDefine.Def_IudetLegendAttrIDJi, jiAttrIDList[i])
|
| | | curItem.AddUserAttr(ShareDefine.Def_IudetLegendAttrValueJi, jiAttrValueList[i])
|
| | | |
| | | return
|
| | |
|
| | | ##创建物品所需的动态数据
|
| | | #
|