| | |
| | | import ChPyNetSendPack
|
| | | import NetPackCommon
|
| | | import Operate_EquipStone
|
| | | import Operate_EquipSuitCompose
|
| | | import PlayerMagicWeapon
|
| | | import IpyGameDataPY
|
| | | import DataRecordPack
|
| | | import EventShell
|
| | | import ChEquip
|
| | |
|
| | | import math
|
| | | import time
|
| | | #---------------------------------------------------------------------
|
| | | ## 放不下主角背包放入万能背包的逻辑, curGiveItem 要先 SetCount
|
| | | # @param curPlayer 当前玩家
|
| | | # @param curGiveItem 要先 SetCount |
| | | # @return None or True
|
| | | # @remarks 函数详细说明.
|
| | | def DoLogic_PutItemInPack(curPlayer, curGiveItem, showEff=False, showSysInfo=False, event=["", False, {}]):
|
| | | return __DoLogic_PutItemInPack(curPlayer, curGiveItem, [IPY_GameWorld.rptItem, IPY_GameWorld.rptAnyWhere],
|
| | | showEff=showEff, showSysInfo=showSysInfo, event=event)
|
| | |
|
| | |
|
| | | ## 获得背包的一个空格子
|
| | | def GetItemPackSpaceIndex(curPlayer, packindex):
|
| | |
| | | for i in range(0, curPack.GetCount()):
|
| | | item = curPack.GetAt(i)
|
| | |
|
| | | if not ItemCommon.CheckItemCanUse(item):
|
| | | if not ItemCommon.CheckItemCanUse(item) or GetIsAuctionItem(item):
|
| | | continue
|
| | |
|
| | | if item.GetItemTypeID() == id:
|
| | |
| | | for i in range(0, curPack.GetCount()):
|
| | | item = curPack.GetAt(i)
|
| | |
|
| | | if not ItemCommon.CheckItemCanUse(item):
|
| | | if not ItemCommon.CheckItemCanUse(item) or GetIsAuctionItem(item):
|
| | | continue
|
| | |
|
| | | if item.GetItemTypeID() == id:
|
| | |
| | | for i in range(0, curPack.GetCount()):
|
| | | item = curPack.GetAt(i)
|
| | |
|
| | | if not ItemCommon.CheckItemCanUse(item):
|
| | | if not ItemCommon.CheckItemCanUse(item) or GetIsAuctionItem(item):
|
| | | continue
|
| | |
|
| | | effect = item.GetEffectByIndex(0)
|
| | |
| | | for i in range(0, curPack.GetCount()):
|
| | |
|
| | | item = curPack.GetAt(i)
|
| | | if not ItemCommon.CheckItemCanUse(item):
|
| | | if not ItemCommon.CheckItemCanUse(item) or GetIsAuctionItem(item):
|
| | | continue
|
| | |
|
| | | if item.GetItemTypeID() != id:
|
| | |
| | | # @return True or False
|
| | | # @remarks 函数详细说明.
|
| | | def CanPackItemByItemType(srcItemID, srcItemIsBind, destItemID, destItemIsBind):
|
| | | if srcItemID == destItemID and srcItemIsBind == destItemIsBind:
|
| | | ## 拍品项目,只有非拍品可堆叠,即绑定物品
|
| | | if srcItemID == destItemID and srcItemIsBind == destItemIsBind and not srcItemIsBind:
|
| | | return True
|
| | | return False
|
| | |
|
| | |
| | | return True
|
| | | return False
|
| | |
|
| | | #物品属性判断------------------------------------------------------------------
|
| | | ## 使用物品检查是否满足属性
|
| | | # @param curPlayer 当前玩家
|
| | | # @param curItem 当前物品
|
| | | # @return False or True
|
| | | def CheckItemAttrLimit(curPlayer, curItem):
|
| | | # 取消限制的物品
|
| | | if curItem.GetUserAttr(ShareDefine.Def_IudetCancelUseLimit) == 1:
|
| | | return True
|
| | | #智力为基础限制
|
| | | if curItem.GetLimitPNE() > curPlayer.GetPNE():
|
| | | return False
|
| | | |
| | | #由于可变属性强化表加载问题, 暂时不处理强化表的属性点限制,以物品表为主,如有需要再开启此判断 20151210 by hxp
|
| | | # 从强化表中获得数据,装备强化限制力量 敏捷
|
| | | # if curItem.GetType() in ReadChConfig.GetEvalChConfig("EquipPlus_EquipType"):
|
| | | # plusInfo = ...
|
| | | # |
| | | # if plusInfo is None:
|
| | | # GameWorld.ErrLog("tagItemPlus.txt can't find equip:%s" % curItem.GetItemTypeID())
|
| | | # return False
|
| | | # |
| | | # limitSTR, limitPHY = plusInfo.GetLimitSTR(), plusInfo.GetLimitPHY()
|
| | | # |
| | | # # 物品表中获得信息
|
| | | # else:
|
| | | limitSTR, limitPHY = curItem.GetLimitSTR(), curItem.GetLimitPHY()
|
| | | |
| | | if limitSTR > curPlayer.GetSTR() or limitPHY > curPlayer.GetPHY():
|
| | | return False
|
| | | |
| | | return True
|
| | |
|
| | |
|
| | | #物品使用等级判断----------------------------------------------------------------
|
| | | ## 物品使用等级判断
|
| | | # @param curPlayer 玩家
|
| | |
| | | # @param itemMark 当前物品
|
| | | # @return 是否是贵重品
|
| | | def IsValuableItem(curItem):
|
| | | |
| | | #装备是否卓越物品
|
| | | #===========================================================================
|
| | | # ValuableItemQualityList = ReadChConfig.GetEvalChConfig("ValuableItemQuality")
|
| | | # if curItem.GetItemQuality() in ValuableItemQualityList:
|
| | | # return True
|
| | | # |
| | | # # 贵重物品配置[[贵重物品id], [贵重物品类型], 贵重物品加强等级, 贵重物品追加等级]
|
| | | # valuablesInfo = ReadChConfig.GetEvalChConfig("ValuablesConfigInfo")
|
| | | # valuablesIDList, valuablesTypeList, valuableMinStar, valuableAddAttrLV = valuablesInfo
|
| | | # |
| | | # #物品ID满足
|
| | | # if curItem.GetItemTypeID() in valuablesIDList:
|
| | | # return True
|
| | | # |
| | | # #物品类型满足 |
| | | # if curItem.GetType() in valuablesTypeList:
|
| | | # return True
|
| | | # |
| | | # #普通装备判定
|
| | | # if ItemCommon.CheckItemIsEquip(curItem):
|
| | | # |
| | | # #套装物品
|
| | | # if curItem.GetIsSuite():
|
| | | # return True
|
| | | # |
| | | # #装备强化星级
|
| | | # if curItem.GetItemStarLV() >= valuableMinStar:
|
| | | # return True
|
| | | #===========================================================================
|
| | |
|
| | | return False
|
| | |
|
| | |
|
| | |
| | | SetItemCount(srcItem, srcItem.GetCount() - realPutCount)
|
| | | SetItemCount(destItem, destItem.GetCount() + realPutCount)
|
| | |
|
| | | SetItemIsBind(destItem, True)
|
| | | #SetItemIsBind(destItem, True)
|
| | | return True
|
| | | #2. 目标位置有东西, 并且可以堆叠
|
| | | if (CanPackItem(srcItem, destItem) and maxPackCount > destItem.GetCount()):
|
| | |
| | | # return False
|
| | |
|
| | | #职业检查
|
| | | if not ItemCommon.JobUseable(curPlayer, curItem):
|
| | | if not ItemCommon.CheckJob(curPlayer, curItem):
|
| | | if needNotify:
|
| | | PlayerControl.NotifyCode(curPlayer, "GeRen_lhs_31379")
|
| | |
|
| | |
| | | #等级检查
|
| | | if not CheckItemUseLV(curPlayer, curItem, needNotify):
|
| | | return False
|
| | |
|
| | | #使用物品检查是否满足属性
|
| | | if not CheckItemAttrLimit(curPlayer, curItem):
|
| | | if needNotify:
|
| | | PlayerControl.NotifyCode(curPlayer, "itemuse_andyshao_671654")
|
| | | return False
|
| | | |
| | | |
| | | #=======================================================================
|
| | | # #马匹检查
|
| | | # if curItem.GetType() == ChConfig.Def_Item_Type_Horse and not CheckCanEquipHorse(curPlayer):
|
| | |
| | |
|
| | | ## 交换装备
|
| | | # @param curItem 当前物品
|
| | | # @param equipPlace 装备位置
|
| | | # @param equipPackIndex 装备背包格子
|
| | | # @return True or False
|
| | | # @remarks 函数详细说明.
|
| | | def SwitchEquip(self, curItem, equipPlace):
|
| | | def SwitchEquip(self, curItem, equipPackIndex):
|
| | | curPlayer = self.__Player
|
| | | equipPack = self.__PlayerEquip
|
| | |
|
| | | curEquip = equipPack.GetAt(equipPlace)
|
| | | curEquip = equipPack.GetAt(equipPackIndex)
|
| | |
|
| | | #GameWorld.Log("装备位置%d"%equipPlace)
|
| | | if curEquip.IsEmpty():
|
| | |
| | |
|
| | | # 计算装备的珍品数量
|
| | | 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)
|
| | | # 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
|
| | |
|
| | | def GetStartEquipCount(self):
|
| | | curPlayer = self.__Player
|
| | | return curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_StartEquipCnt)
|
| | | return 0
|
| | | #curPlayer = self.__Player
|
| | | #return curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_StartEquipCnt)
|
| | |
|
| | | ## 装备当前物品
|
| | | # @param curItem 当前物品
|
| | | # @param packEquipIndex 客户端发来装备位置(IPY_GameWorld.retMax 代表服务器自动装备)
|
| | | # @param equipPackIndex 客户端发来装备位置(IPY_GameWorld.retMax 代表服务器自动装备)
|
| | | # @return 替换的位置 -1表示替换失败
|
| | | def EquipItem(self, curItem, packEquipIndex):
|
| | | def EquipItem(self, curItem, equipPackIndex):
|
| | | if not self.PlayerCanEquipItem(curItem, True):
|
| | | return -1
|
| | |
|
| | | equipPlace = curItem.GetEquipPlace()
|
| | | if packEquipIndex != equipPlace:
|
| | | #仙器有两个位置,其他装备检查装备位置和填表是否一致
|
| | | if equipPlace not in ChConfig.Def_FairyCanList and packEquipIndex not in ChConfig.Def_FairyCanList:
|
| | | return -1
|
| | |
|
| | | |
| | | curPlayer = self.__Player
|
| | | equipPack = self.__PlayerEquip
|
| | | equipItem = equipPack.GetAt(packEquipIndex)
|
| | | equipItem = equipPack.GetAt(equipPackIndex)
|
| | | desItemID, desUserData = [0, ''] if equipItem.IsEmpty() else [equipItem.GetItemTypeID(), equipItem.GetUserData()]
|
| | | srcItemID, srcUserData = curItem.GetItemTypeID(), curItem.GetUserData()
|
| | | # 装备绑定处理 在 DoLogic_ItemBindType函数有处理,此处注释掉
|
| | | # if not curItem.GetIsBind():
|
| | | # SetItemIsBind(curItem, True)
|
| | | |
| | | 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, packEquipIndex)
|
| | | result = self.SwitchEquip(curItem, equipPackIndex)
|
| | | if result:
|
| | | #穿戴某阶某品质的装备成就
|
| | | PlayerSuccess.DoEquipSuccessLogic(curPlayer)
|
| | | #换装宝石处理
|
| | | Operate_EquipStone.DoMoveEquipStone(curPlayer, packEquipIndex)
|
| | | #套装降级处理
|
| | | Operate_EquipSuitCompose.CheckEquipSuitReduce(curPlayer, packEquipIndex)
|
| | | EventShell.EventRespons_EquipStar(curPlayer)
|
| | | 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 packEquipIndex if result else -1
|
| | | 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 当前装备
|
| | | # @param curItem 当前物品
|
| | |
| | |
|
| | | equipID = curEquip.GetItemTypeID()
|
| | | userData = curEquip.GetUserData()
|
| | | equipPlace = curEquip.GetEquipPlace()
|
| | | suiteID = curEquip.GetSuiteID()
|
| | | itemClassLV = ItemCommon.GetItemClassLV(curEquip)
|
| | | #该物品锁定不执行==============================================
|
| | | if curEquip.GetIsLocked():
|
| | | PlayerControl.NotifyCode(curPlayer, "RescannotEquip")
|
| | |
| | | #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()
|
| | | #套装降级处理
|
| | | Operate_EquipSuitCompose.CheckEquipSuitReduce(curPlayer, equipIndex)
|
| | | EventShell.EventRespons_EquipStar(curPlayer)
|
| | | 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.PutIn(curEquip)
|
| | | #===============================================================================
|
| | | return equipID, equipIndex
|
| | | return equipID, equipPlace, itemClassLV
|
| | |
|
| | | #是否能放入物品(第几个物品栏, 物品序号, 放入的物品, 放入物品ID, 物品是否绑定)
|
| | | #===============================================================================
|
| | |
| | | PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_FamilyActivity, itemCount)
|
| | | elif itemID == ChConfig.Def_ItemID_SP:
|
| | | PlayerControl.PlayerAddZhenQi(curPlayer, itemCount)
|
| | | elif itemID == ChConfig.Def_ItemID_GoldPaper:
|
| | | PlayerControl.GiveMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Paper, itemCount)
|
| | | #elif itemID == ChConfig.Def_ItemID_GoldPaper:
|
| | | # PlayerControl.GiveMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Paper, itemCount, eventName, addDict)
|
| | | elif itemID == ChConfig.Def_ItemID_RealmPoint:
|
| | | PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_RealmPoint, itemCount)
|
| | | elif itemID == ChConfig.Def_ItemID_BossReborn:
|
| | |
| | | PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_SoulCore, itemCount)
|
| | | elif itemID == ChConfig.Def_ItemID_Honor:
|
| | | PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_Honor, itemCount)
|
| | | elif itemID == ChConfig.Def_ItemID_GoldMoney:
|
| | | PlayerControl.GiveMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money, itemCount)
|
| | | elif itemID == ChConfig.Def_ItemID_XianyuanCoin:
|
| | | PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_XianyuanCoin, itemCount)
|
| | | return True
|
| | |
|
| | | def __CrossServerPutInItem(self, packIndex, tagItem, event=["", False, {}]):
|
| | | ## 跨服获得物品
|
| | | if packIndex not in [IPY_GameWorld.rptItem, ShareDefine.rptDogzItem]:
|
| | | #GameWorld.DebugLog("跨服获得物品不同步, packIndex=%s" % (packIndex))
|
| | | return
|
| | | curPlayer = self.__Player
|
| | | serverGroupID = PlayerControl.GetPlayerServerGroupID(curPlayer)
|
| | | itemData = [tagItem.GetItemTypeID(), tagItem.GetCount(), tagItem.GetIsBind(), tagItem.GetUserData()]
|
| | |
| | | self.__CrossServerPutInItem(packIndex, tagItem, event)
|
| | | tagItem.Clear()
|
| | | return True
|
| | | if CheckChangeOldItem(curPlayer, tagItem):
|
| | | tagItem.Clear()
|
| | | return True
|
| | | packIndex = ChConfig.GetItemPackType(curItemData.GetType(), packIndex)
|
| | |
|
| | | if not self.CanPutInItem(packIndex, tagItem.GetItemTypeID(), GetItemCount(tagItem), tagItem.GetIsBind(), defaultPile):
|
| | | tagItemCount = GetItemCount(tagItem)
|
| | | isAuctionItem = GetIsAuctionItem(tagItem)
|
| | | if not self.CanPutInItem(packIndex, tagItem.GetItemTypeID(), tagItemCount, isAuctionItem, defaultPile):
|
| | | GameWorld.DebugLog("背包满,不能放入物品 count = %d"%GetItemCount(tagItem))
|
| | | tagItem.Clear()
|
| | | return False
|
| | |
|
| | | isNeedRecord = False
|
| | | itemID = tagItem.GetItemTypeID()
|
| | | #激活成就的道具
|
| | | if tagItem.GetType() == ChConfig.Def_ItemType_SuccessItem:
|
| | | PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_GetSpecialItem, 1, [tagItem.GetEffectByIndex(0).GetEffectValue(0)])
|
| | | PlayerMagicWeapon.DoActiveMW(curPlayer, tagItem.GetEffectByIndex(0).GetEffectValue(0))
|
| | | tagItem.Clear()
|
| | | return True
|
| | | if itemID in ChConfig.Def_TransformItemIDList:
|
| | | # 直接转化为对应货币的物品仅在放入背包时直接转化,否则还是以真实物品的形式存在,但堆叠上限需要做特殊处理
|
| | |
| | | return True
|
| | | defaultPile = True
|
| | | maxPackCount = ChConfig.Def_UpperLimit_DWord # 转化物品叠加上限不取物品表的, 暂定堆叠上限20亿
|
| | | elif isAuctionItem:
|
| | | maxPackCount = tagItemCount
|
| | | defaultPile = False # 新放入的拍品只能放空位置,所以不判断堆叠
|
| | | #isBind = False
|
| | | isNeedRecord = True # 拍品要记录
|
| | | else:
|
| | | maxPackCount = curItemData.GetPackCount()
|
| | |
|
| | |
| | |
|
| | | curPack = self.__PlayerItemManager.GetPack(packIndex)
|
| | | #itemFactory = GameWorld.GetItemFactory()
|
| | | isBind = tagItem.GetIsBind()
|
| | | isNeedRecord = False
|
| | | #isBind = tagItem.GetIsBind()
|
| | | # 目前暂只记录放入背包的
|
| | | if packIndex in [IPY_GameWorld.rptItem, ShareDefine.rptTreasure, ShareDefine.rptRune, ShareDefine.rptGatherSoul]:
|
| | | if not isNeedRecord and packIndex in [IPY_GameWorld.rptItem, ShareDefine.rptTreasure, ShareDefine.rptRune, ShareDefine.rptGatherSoul]:
|
| | | isNeedRecord = ItemNeedRecord(tagItem) or isForceEvent
|
| | | putResult = False
|
| | |
|
| | |
| | | #可以摆放
|
| | | if curItemCount > canPutinCount:
|
| | | #需要创建新物品放入
|
| | | curCreateItem = GetOutPutItemObj(tagItem.GetItemTypeID(), canPutinCount, isBind)
|
| | | curCreateItem = GetOutPutItemObj(tagItem.GetItemTypeID(), canPutinCount, isAuctionItem)
|
| | | #注意: 不能在这里AssignItem, 否则会有2个物品指针指向同一个物品实例 . 巨大的错误在这一句 : curCreateItem.Assign(tagItem)
|
| | | #如果是装备,那么 maxPackCount 为1 这里会循环自动创建新物品,所以直接 GetOutPutItemObj 即可, 暂不支持定制装备拆解
|
| | |
|
| | |
| | | if legendAttrIDCount and legendAttrValueCount and legendAttrIDCount == legendAttrValueCount:
|
| | | return
|
| | |
|
| | | legendAttrInfo = GetAddEquipLegendAttr(curItem)
|
| | | curPlayer = self.__Player
|
| | | legendAttrInfo = GetAddEquipLegendAttr(curItem, curPlayer)
|
| | | if not legendAttrInfo:
|
| | | return
|
| | |
|
| | |
| | | curItem.AddUserAttr(ShareDefine.Def_IudetLegendAttrValue, legendAttrValueList[i])
|
| | | ItemCommon.MakeEquipGS(curItem)
|
| | | updScore = ItemCommon.GetEquipGearScore(curItem)
|
| | | GameWorld.ErrLog("传奇属性异常,重新刷新一次属性: packType=%s,itemID=%s,legendAttrIDList=%s,legendAttrValueList=%s,srcScore=%s,updScore=%s" |
| | | GameWorld.DebugLog("传奇属性异常,重新刷新一次属性: packType=%s,itemID=%s,legendAttrIDList=%s,legendAttrValueList=%s,srcScore=%s,updScore=%s" |
| | | % (packType, curItem.GetItemTypeID(), legendAttrIDList, legendAttrValueList, srcScore, updScore), curPlayer.GetPlayerID())
|
| | | return
|
| | |
|
| | | def CheckRolePackEquipAttr(self):
|
| | | ''' 玩家上线修复装备属性bug
|
| | | 版本1:邮件给装备没有传奇属性,检查无传奇属性装备
|
| | | 版本2:绝版属性数值调整,已获得的装备重新刷下
|
| | | '''
|
| | | curPlayer = self.__Player
|
| | | checkVersion = 20190103
|
| | | key = "LoginCheckEquipAttr"
|
| | | curVersion = curPlayer.NomalDictGetProperty(key)
|
| | | if curVersion == checkVersion:
|
| | | return
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | GameWorld.Log("玩家上线处理装备属性! curVersion=%s,checkVersion=%s" % (curVersion, checkVersion), playerID)
|
| | | |
| | | outOfPrintAttrItemDict = {} # 有绝版属性的定制物品属性信息 {itemID:[绝版属性ID列表, 绝版属性数值列表], ...}
|
| | | ipyDataMgr = IpyGameDataPY.IPY_Data()
|
| | | for i in xrange(ipyDataMgr.GetAppointItemCount()):
|
| | | ipyData = ipyDataMgr.GetAppointItemByIndex(i)
|
| | | outOfPrintAttrList = ipyData.GetOutOfPrintAttr()
|
| | | outOfPrintAttrValueList = ipyData.GetOutOfPrintAttrValue()
|
| | | if not outOfPrintAttrList or len(outOfPrintAttrList) != len(outOfPrintAttrValueList):
|
| | | continue
|
| | | itemID = GetAppointItemRealID(ipyData.GetID())
|
| | | if not itemID:
|
| | | continue
|
| | | outOfPrintAttrItemDict[itemID] = [outOfPrintAttrList, outOfPrintAttrValueList]
|
| | | |
| | | checkPackList = [IPY_GameWorld.rptEquip, IPY_GameWorld.rptItem, IPY_GameWorld.rptWarehouse]
|
| | | for packType in checkPackList:
|
| | | curPack = curPlayer.GetItemManager().GetPack(packType)
|
| | | for i in xrange(curPack.GetCount()):
|
| | | curItem = curPack.GetAt(i)
|
| | | #GameWorld.DebugLog("packType=%s,i=%s" % (packType, i))
|
| | | if curItem.IsEmpty():
|
| | | continue
|
| | | isEquip = ItemCommon.CheckItemIsEquip(curItem)
|
| | | if not isEquip:
|
| | | continue
|
| | | itemID = curItem.GetItemTypeID()
|
| | | self.CheckEquipAttr(packType, curItem)
|
| | | |
| | | # 重刷绝版属性
|
| | | if itemID in outOfPrintAttrItemDict:
|
| | | outOfPrintAttrList, outOfPrintAttrValueList = outOfPrintAttrItemDict[itemID]
|
| | | curItem.ClearUserAttr(ShareDefine.Def_IudetOutOfPrintAttrID)
|
| | | curItem.ClearUserAttr(ShareDefine.Def_IudetOutOfPrintAttrValue)
|
| | | for outOfPrintAttrIndex in xrange(len(outOfPrintAttrList)):
|
| | | curItem.AddUserAttr(ShareDefine.Def_IudetOutOfPrintAttrID, outOfPrintAttrList[outOfPrintAttrIndex])
|
| | | curItem.AddUserAttr(ShareDefine.Def_IudetOutOfPrintAttrValue, outOfPrintAttrValueList[outOfPrintAttrIndex])
|
| | | GameWorld.Log(" 玩家登录重刷装备绝版属性: packType=%s,i=%s,itemID=%s,outOfPrintAttrList=%s,outOfPrintAttrValueList=%s" |
| | | % (packType, i, itemID, outOfPrintAttrList, outOfPrintAttrValueList), playerID)
|
| | | |
| | | PlayerControl.NomalDictSetProperty(curPlayer, key, checkVersion)
|
| | | # curPlayer = self.__Player
|
| | | # checkVersion = 20190103
|
| | | # key = "LoginCheckEquipAttr"
|
| | | # curVersion = curPlayer.NomalDictGetProperty(key)
|
| | | # if curVersion == checkVersion:
|
| | | # return
|
| | | # playerID = curPlayer.GetPlayerID()
|
| | | # GameWorld.Log("玩家上线处理装备属性! curVersion=%s,checkVersion=%s" % (curVersion, checkVersion), playerID)
|
| | | # PlayerControl.NomalDictSetProperty(curPlayer, key, checkVersion)
|
| | | return
|
| | |
|
| | | ## 是否能放入物品
|
| | | # @param packIndex 背包索引
|
| | | # @param curItemID 当前物品ID
|
| | | # @param curItemCount 当前物品数量
|
| | | # @param isBind 是否绑定
|
| | | # @param isAuctionItem 是否拍品
|
| | | # @param defaultPile 默认先判断是否能进行物品堆叠
|
| | | # @return True or False
|
| | | # @remarks 函数详细说明.
|
| | | def CanPutInItem(self, packIndex, curItemID, curItemCount, isBind, defaultPile=True):
|
| | | def CanPutInItem(self, packIndex, curItemID, curItemCount, isAuctionItem, defaultPile=True):
|
| | | if GameWorld.IsCrossServer():
|
| | | return True
|
| | | checkRet, putIndex = self.CanPutInItemEx(packIndex, curItemID, curItemCount, isBind, defaultPile)
|
| | | checkRet, putIndex = self.CanPutInItemEx(packIndex, curItemID, curItemCount, isAuctionItem, defaultPile)
|
| | | return checkRet
|
| | |
|
| | | ## 是否能放入物品
|
| | | # @param packIndex 背包索引
|
| | | # @param curItemID 当前物品ID
|
| | | # @param curItemCount 当前物品数量
|
| | | # @param isBind 是否绑定
|
| | | # @param isAuctionItem 是否拍品
|
| | | # @param defaultPile 默认先判断是否能进行物品堆叠
|
| | | # @return True or False, 第一个可放入的位置
|
| | | # @remarks 函数详细说明.
|
| | | def CanPutInItemEx(self, packIndex, curItemID, curItemCount, isBind, defaultPile=True):
|
| | | def CanPutInItemEx(self, packIndex, curItemID, curItemCount, isAuctionItem, defaultPile=True):
|
| | | gameData = GameWorld.GetGameData()
|
| | | curItemData = gameData.GetItemByTypeID(curItemID)
|
| | |
|
| | |
| | | if packIndex == IPY_GameWorld.rptItem:
|
| | | return True, 0
|
| | | maxPackCount = ChConfig.Def_UpperLimit_DWord # 转化物品叠加上限不取物品表的, 暂定堆叠上限20亿
|
| | | elif isAuctionItem:
|
| | | maxPackCount = curItemCount
|
| | | defaultPile = False # 新放入的拍品只能放空位置,所以不判断堆叠
|
| | | else:
|
| | | maxPackCount = curItemData.GetPackCount()
|
| | |
|
| | |
| | | if item.GetIsLocked():
|
| | | continue
|
| | |
|
| | | if (CanPackItemByItemType(item.GetItemTypeID(), item.GetIsBind(), curItemID, isBind) and
|
| | | if (CanPackItemByItemType(item.GetItemTypeID(), item.GetIsBind(), curItemID, isAuctionItem) and
|
| | | maxPackCount > GetItemCount(item)):
|
| | | #该物品锁定不执行==============================================
|
| | | #可堆叠
|
| | |
| | | curItemTypeID = curItem.GetItemTypeID()
|
| | | #curItemGUID = curItem.GetGUID()
|
| | | curItemCount = curItem.GetCount()
|
| | | curItemIsBind = curItem.GetIsBind()
|
| | | #curItemIsBind = curItem.GetIsBind()
|
| | | isAuctionItem = GetIsAuctionItem(curItem)
|
| | | #toPackIndex = ChConfig.GetItemPackType(curItem.GetType(), toPackIndex)
|
| | |
|
| | | # 常规物品转移到虚拟符印背包
|
| | |
| | | return False
|
| | | return itemControl.PutItemInVPack(toPackIndex, curItem)
|
| | |
|
| | | checkRet, putIndex = itemControl.CanPutInItemEx(toPackIndex, curItemTypeID, curItemCount, curItemIsBind)
|
| | | checkRet, putIndex = itemControl.CanPutInItemEx(toPackIndex, curItemTypeID, curItemCount, isAuctionItem)
|
| | | if not checkRet:
|
| | | return False
|
| | | return DragItem(curPlayer, fromPackIndex, itemIndex, toPackIndex, putIndex, curItemCount)
|
| | |
| | | if itemType1 == itemType2:
|
| | | if item1.GetItemColor() == item2.GetItemColor():
|
| | | if item1.GetItemQuality() == item2.GetItemQuality():
|
| | | if item1.GetItemTypeID() == item2.GetItemTypeID():
|
| | | if item1.GetIsBind() == item2.GetIsBind():
|
| | | return -cmp(item1.GetCount(), item2.GetCount())
|
| | | return -cmp(item1.GetIsBind(), item2.GetIsBind())
|
| | | return cmp(item1.GetItemTypeID(), item2.GetItemTypeID())
|
| | | else:
|
| | | return cmp(0-item1.GetItemQuality(), 0-item2.GetItemQuality())
|
| | |
| | | for curItem in curList:
|
| | | curCount = curItem.GetCount()
|
| | |
|
| | | if not CanPackItem(curItem, addItem) :
|
| | | if not CanPackItem(curItem, addItem):
|
| | | continue
|
| | |
|
| | | if curCount >= packCount:
|
| | |
| | |
|
| | | return
|
| | |
|
| | | #---------------------------------------------------------------------
|
| | | ## 给玩家物品
|
| | | # @param curPlayer 当前玩家
|
| | | # @param itemID 物品ID
|
| | | # @param itemCount 物品数量
|
| | | # @param itemIsBind 物品是否绑定
|
| | | # @param packIndexList 背包索引列表
|
| | | # @param showEff 显示放入背包的特效
|
| | | # @param defaultPile 默认先判断是否能进行物品堆叠
|
| | | # @param returnItemObj 是否返回物品对象
|
| | | # @param showSysInfo 是否显示系统提示
|
| | | # @return 布尔值
|
| | | # @remarks |
| | | def GivePlayerItem(curPlayer, itemID, itemCount, itemIsBind, packIndexList, showEff=False, defaultPile=True,
|
| | | returnItemObj=False, showSysInfo=False, event=["", False, {}]):
|
| | | def GivePlayerItem(curPlayer, itemID, itemCount, isAuctionItem, packIndexList, event=["", False, {}]):
|
| | | '''给玩家物品
|
| | | @param isAuctionItem: 是否拍品
|
| | | '''
|
| | | if itemCount <= 0:
|
| | | return False
|
| | |
|
| | |
| | | if not curItemData:
|
| | | return False
|
| | |
|
| | | if isAuctionItem:
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("AuctionItem", itemID)
|
| | | if not ipyData:
|
| | | GameWorld.ErrLog("非拍卖物品,默认转为非拍品! itemID=%s,itemCount=%s,isAuctionItem=%s" |
| | | % (itemID, itemCount, isAuctionItem), curPlayer.GetPlayerID())
|
| | | isAuctionItem = 0
|
| | | |
| | | defaultPack = IPY_GameWorld.rptItem if not packIndexList else packIndexList[0]
|
| | | packIndex = ChConfig.GetItemPackType(curItemData.GetType(), defaultPack)
|
| | | if packIndex != defaultPack or not packIndexList:
|
| | | packIndexList = [packIndex]
|
| | |
|
| | | if not __Check_CanPutItemInPack(curPlayer, itemID, itemCount, itemIsBind, packIndexList, defaultPile):
|
| | | #物品管理器
|
| | | canPutIn = False
|
| | | itemControl = PlayerItemControler(curPlayer)
|
| | | for packIndex in packIndexList:
|
| | | #可以放入背包
|
| | | if itemControl.CanPutInItem(packIndex, itemID, itemCount, isAuctionItem):
|
| | | canPutIn = True
|
| | | break
|
| | | if not canPutIn:
|
| | | #不可放入
|
| | | return False
|
| | |
|
| | |
| | | if GetAppointItemRealID(itemID):
|
| | | isOK = False
|
| | | for _ in xrange(itemCount):
|
| | | if GivePlayerAppointItem(curPlayer, itemID, itemIsBind, showEff, showSysInfo, event):
|
| | | if GivePlayerAppointItem(curPlayer, itemID, isAuctionItem, event):
|
| | | isOK = True # 只要有成功的就返回成功,防止异常情况失败可能导致被刷
|
| | | return isOK
|
| | |
|
| | |
| | | if ItemCommon.GetIsEquip(curItemData):
|
| | | isOK = False
|
| | | for _ in xrange(itemCount):
|
| | | outPutEquip = GetOutPutItemObj(itemID, 1, itemIsBind)
|
| | | if __DoLogic_PutItemInPack(curPlayer, outPutEquip, packIndexList, showEff, defaultPile, returnItemObj,
|
| | | showSysInfo, event):
|
| | | outPutEquip = GetOutPutItemObj(itemID, 1, isAuctionItem, curPlayer=curPlayer)
|
| | | if not outPutEquip:
|
| | | return isOK
|
| | | if DoLogic_PutItemInPack(curPlayer, outPutEquip, event, packIndexList):
|
| | | isOK = True # 只要有成功的就返回成功,防止异常情况失败可能导致被刷
|
| | | return isOK
|
| | |
|
| | | giveItem = GetOutPutItemObj(itemID, itemCount, itemIsBind)
|
| | | giveItem = GetOutPutItemObj(itemID, itemCount, isAuctionItem, curPlayer=curPlayer)
|
| | | if not giveItem:
|
| | | GameWorld.ErrLog('GivePlayerItem itemID = %s, Error, giveCnt = %s, isBind = %s' % \
|
| | | (itemID, itemCount, itemIsBind), curPlayer.GetID())
|
| | | return False
|
| | | |
| | | #将物品放入背包
|
| | | return __DoLogic_PutItemInPack(curPlayer, giveItem, packIndexList, showEff, defaultPile, returnItemObj,
|
| | | showSysInfo, event)
|
| | | return DoLogic_PutItemInPack(curPlayer, giveItem, event, packIndexList)
|
| | |
|
| | |
|
| | | ## 给玩家定制物品表物品\PyMapTable\AppointItemList.txt
|
| | | # @param curPlayer 当前玩家
|
| | | # @param index 表index
|
| | | # @param isBind 是否绑定
|
| | | # @param showEff 显示放入背包的特效
|
| | | # @return 布尔值
|
| | | def GivePlayerAppointItem(curPlayer, index, isBind, showEff=False, showSysInfo=False, event=["", False, {}]):
|
| | | itemDictData = GetAppointItemDictData(index, isBind)
|
| | | 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)
|
| | |
|
| | | return GivePlayerEquip(curPlayer, itemDictData, showEff, showSysInfo=showSysInfo, event=event)
|
| | |
|
| | | ## 获取定制表物品数据
|
| | | # @param index 表index
|
| | | # @param isBind 是否绑定
|
| | | # @return ItemDictData
|
| | | def GetAppointItemDictData(index, isBind):
|
| | | itemID = GetAppointItemRealID(index)
|
| | | def GetAppointItemDictData(appointID, isAuctionItem):
|
| | | '''获取定制表物品数据,定制物品默认个数1
|
| | | @param appointID 定制表ID
|
| | | @param isAuctionItem 是否拍品
|
| | | '''
|
| | | itemID = GetAppointItemRealID(appointID)
|
| | | if not itemID:
|
| | | return {}
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("AppointItem", index)
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("AppointItem", appointID)
|
| | | if not ipyData:
|
| | | GameWorld.ErrLog("GivePlayerAppointItem() Index=%s not data" % (index))
|
| | | return {}
|
| | | itemDictData = {}
|
| | |
|
| | | itemDictData['legendAttrID'] = ipyData.GetLegendAttrID()
|
| | | itemDictData['legendAttrValue'] = ipyData.GetLegendAttrValue()
|
| | | itemDictData['SuiteLV'] = ipyData.GetSuiteLV()
|
| | | itemDictData['ItemID'] = itemID
|
| | | itemDictData['CancelUseLimit'] = ipyData.GetCancelUseLimit()
|
| | |
|
| | | # 设置是否绑定
|
| | | itemDictData['IsBind'] = isBind
|
| | | itemDictData['IsAuctionItem'] = isAuctionItem
|
| | |
|
| | | #装备绝版属性,随等级变化
|
| | | itemDictData['OutOfPrintAttrID'] = ipyData.GetOutOfPrintAttr()
|
| | | itemDictData['OutOfPrintAttrValue'] = ipyData.GetOutOfPrintAttrValue()
|
| | | return itemDictData
|
| | |
|
| | | def GetAppointItemRealID(itemID):
|
| | |
| | | ## 根据物品data字典给玩家装备/翅膀
|
| | | # @param curPlayer:玩家实例
|
| | | # @param itemData:物品数据
|
| | | # @param showEff:是否显示放入背包特效
|
| | | # @param packType:背包类型
|
| | | # @param defaultPile 默认先判断是否能进行物品堆叠
|
| | | # @param showSysInfo 是否显示系统提示
|
| | | # @return None
|
| | | def GivePlayerEquip(curPlayer, itemData, showEff=False, packType=[IPY_GameWorld.rptItem, IPY_GameWorld.rptAnyWhere],
|
| | | defaultPile=True, returnItemObj=False, showSysInfo=False, event=["", False, {}]):
|
| | | def GivePlayerEquip(curPlayer, itemData, event=["", False, {}], packType=[IPY_GameWorld.rptItem, IPY_GameWorld.rptAnyWhere],
|
| | | defaultPile=True):
|
| | | equipItem = GetItemByData(itemData)
|
| | | #将物品放入背包
|
| | | return __DoLogic_PutItemInPack(curPlayer, equipItem, packType, showEff, defaultPile, returnItemObj, showSysInfo, event)
|
| | | return DoLogic_PutItemInPack(curPlayer, equipItem, event, packType, defaultPile)
|
| | |
|
| | |
|
| | | ## 根据物品data字典创建物品
|
| | |
| | | return
|
| | |
|
| | | itemID = int(itemData.get('ItemID', 0))
|
| | | equipItem = ItemCommon.CreateSingleItem(itemID)
|
| | | isAuctionItem = int(itemData.get('IsAuctionItem', 0))
|
| | | equipItem = ItemCommon.CreateSingleItem(itemID, isAuctionItem=isAuctionItem)
|
| | | if not equipItem:
|
| | | return
|
| | |
|
| | |
| | | #tmpEquipData.starLV = int(itemData.get('StarLV', '0'))
|
| | | #tmpEquipData.holeCnt = int(itemData.get('HoleCount', '0'))
|
| | | #tmpEquipData.stoneData = eval(itemData.get('StoneData', '[]'))
|
| | | tmpEquipData.isBind = int(itemData.get('IsBind', '0'))
|
| | | tmpEquipData.isSuite = int(itemData.get('IsSuit', '0'))
|
| | | tmpEquipData.suiteLV = int(itemData.get('SuiteLV', '0'))
|
| | | if tmpEquipData.suiteLV:
|
| | | tmpEquipData.isSuite = 1
|
| | | 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', [])
|
| | | |
| | | tmpEquipData.OutOfPrintAttrIDList = itemData.get('OutOfPrintAttrID', []) # 绝版属性ID
|
| | | tmpEquipData.OutOfPrintAttrValueList = itemData.get('OutOfPrintAttrValue', []) # 绝版属性最大值
|
| | |
|
| | | # 装备附加属性
|
| | | ChItem.EquipAddAdditionEx(equipItem, tmpEquipData)
|
| | |
| | |
|
| | |
|
| | | #---------------------------------------------------------------------
|
| | | ##检查是否可以放入此物品.
|
| | | # @param curPlayer 玩家实例
|
| | | # @param giveItemID 物品ID
|
| | | # @param giveItemCnt 物品数量
|
| | | # @param giveItemBind 物品是否绑定
|
| | | # @param packIndexList 背包列表
|
| | | # @param defaultPile 默认先判断是否能进行物品堆叠
|
| | | # @return 返回值无意义
|
| | | # @remarks 客户端封包响应
|
| | | def __Check_CanPutItemInPack(curPlayer, giveItemID, giveItemCnt, giveItemBind, packIndexList, defaultPile=True):
|
| | | #物品管理器
|
| | | itemControl = PlayerItemControler(curPlayer)
|
| | | |
| | | for packIndex in packIndexList:
|
| | | #可以放入背包
|
| | | if itemControl.CanPutInItem(packIndex, giveItemID, giveItemCnt, giveItemBind, defaultPile):
|
| | | return True
|
| | |
|
| | | #不可放入
|
| | | return False
|
| | |
|
| | | ## 执行物品放入背包逻辑
|
| | | # @param curPlayer 背包拥有者
|
| | | # @param curGiveItem 放入的物品
|
| | | # @param packIndexList 背包索引列表
|
| | | # @param showEff 放入背包特效
|
| | | # @param defaultPile 默认先判断是否能进行物品堆叠
|
| | | # @param returnItemObj 是否返回物品对象
|
| | | # @param showSysInfo 是否显示系统提示
|
| | | # @return 布尔值
|
| | | def __DoLogic_PutItemInPack(curPlayer, curGiveItem, packIndexList, showEff=False, defaultPile=True,
|
| | | returnItemObj=False, showSysInfo=False, event=["", False, {}]):
|
| | | def DoLogic_PutItemInPack(curPlayer, curGiveItem, event=["", False, {}], packIndexList=[IPY_GameWorld.rptItem, IPY_GameWorld.rptAnyWhere], defaultPile=True):
|
| | | #itemID = curGiveItem.GetItemTypeID()
|
| | | #count = curGiveItem.GetCount()
|
| | | itemControl = PlayerItemControler(curPlayer)
|
| | |
| | | # PlayerControl.NotifyCode(curPlayer, "ObtainRes01", [itemID, count])
|
| | | #===================================================================
|
| | |
|
| | | if returnItemObj:
|
| | | return curGiveItem
|
| | | return True
|
| | |
|
| | | #玩家背包已满, 清空物品,否则创建物品不删除,将导致内存溢出
|
| | | curGiveItem.Clear()
|
| | | #前面验证过了, 走到这里就是逻辑Bug了
|
| | | GameWorld.ErrLog('ItemControler.GivePlayerItem Error 物品无法放入背包')
|
| | | GameWorld.ErrLog('DoLogic_PutItemInPack Error 物品无法放入背包')
|
| | | return False
|
| | |
|
| | | ## 设置物品是否绑定
|
| | | # @param curGiveItem 物品实例
|
| | | # @param isBind 是否绑定
|
| | | # @return None
|
| | | # @remarks |
| | | def SetItemIsBind(curGiveItem, isBind):
|
| | | #isBind = False
|
| | | curGiveItem.SetIsBind(isBind)
|
| | | ## 是否拍品
|
| | | def GetIsAuctionItem(curItem): return curItem.GetIsBind()
|
| | | def SetIsAuctionItem(curItem, isAuctionItem, curPlayer=None):
|
| | | curItem.SetIsBind(isAuctionItem)
|
| | | |
| | | if isAuctionItem:
|
| | | curItem.SetUserAttr(ShareDefine.Def_IudetAuctionItemCreateTime, int(time.time()))
|
| | | return
|
| | | |
| | | if not curPlayer:
|
| | | return
|
| | | |
| | | if ItemCommon.GetIsEquip(curItem):
|
| | | # 生成传奇属性
|
| | | legendAttrInfo = GetAddEquipLegendAttr(curItem, curPlayer)
|
| | | if not legendAttrInfo:
|
| | | return
|
| | | attrIDList, attrValueList = legendAttrInfo
|
| | | updateDict = {ShareDefine.Def_IudetLegendAttrID:attrIDList, ShareDefine.Def_IudetLegendAttrValue:attrValueList}
|
| | | delKeyList = [ShareDefine.Def_IudetAuctionItemCreateTime]
|
| | | ItemCommon.UpdateItemUserData(curItem, updateDict, delKeyList, isUpdateGS=True)
|
| | | |
| | | return
|
| | |
|
| | |
|
| | | ## 设置物品数量
|
| | | # @param item 物品实例
|
| | |
| | | return item.GetUserAttr(ShareDefine.Def_IudetItemCount)
|
| | | return item.GetCount()
|
| | |
|
| | | def GetItemNeedPackCount(packType, itemData, itemCount):
|
| | | def GetItemNeedPackCount(packType, itemData, itemCount, isAuctionItem=0):
|
| | | if isAuctionItem:
|
| | | return 1
|
| | | if itemData.GetItemTypeID() in ChConfig.Def_TransformItemIDList:
|
| | | # 货币直接转换的物品如果是放入背包的则不需要暂用格子,放入其他的背包的则按物品叠加上限算
|
| | | if packType == IPY_GameWorld.rptItem:
|
| | |
| | | #---无空位置,替换---
|
| | | return placeList[0]
|
| | |
|
| | | def GetOutPutItemObj(itemID, itemCount=1, isBind=0, expireTime=0):
|
| | | def GetOutPutItemObj(itemID, itemCount=1, isAuctionItem=False, expireTime=0, curPlayer=None, isAllAttr=False):
|
| | | ''' 获取功能产出的物品实例
|
| | | @param isAuctionItem: 是否拍品,默认非拍品
|
| | | @param expireTime: 有效时间,时间单位由时效类型决定
|
| | | @param curPlayer: 产出该物品时的玩家,非拍品时需传入该值,物品某些属性由玩家等级决定,如传奇属性
|
| | | @param isAllAttr: 是否生成该装备所有属性,GM创建物品时用,需验证相关权限
|
| | | '''
|
| | | curItem = ItemCommon.CreateSingleItem(itemID, itemCount, isBind, expireTime)
|
| | | curItem = ItemCommon.CreateSingleItem(itemID, itemCount, isAuctionItem, expireTime)
|
| | | if not curItem:
|
| | | GameWorld.ErrLog("产出物品异常,无法创建物品 = %s" % (itemID))
|
| | | return
|
| | |
| | | if GetAppointItemRealID(itemID):
|
| | | curItem.Clear()
|
| | | #GameWorld.DebugLog("清除给定制物品之前已经创建的物品ID=%s" % itemID)
|
| | | return GetItemByData(GetAppointItemDictData(itemID, isBind))
|
| | | return GetItemByData(GetAppointItemDictData(itemID, isAuctionItem))
|
| | | |
| | | # 拍品不处理其他属性
|
| | | if isAuctionItem:
|
| | | return curItem
|
| | |
|
| | | tmpEquipData = SingleEquipTmpData()
|
| | |
|
| | | # 传奇属性
|
| | | legendAttrInfo = GetAddEquipLegendAttr(curItem)
|
| | | legendAttrInfo = GetAddEquipLegendAttr(curItem, curPlayer, isAllAttr)
|
| | | if legendAttrInfo:
|
| | | tmpEquipData.legendAttrIDList = legendAttrInfo[0]
|
| | | tmpEquipData.legendAttrValueList = legendAttrInfo[1]
|
| | |
| | | ChItem.EquipAddAdditionEx(curItem, tmpEquipData)
|
| | | return curItem
|
| | |
|
| | | def GetAddEquipLegendAttr(curItem):
|
| | | def GetAddEquipLegendAttr(curItem, curPlayer, isAllAttr=False):
|
| | | '''获取生成到装备上的传奇属性
|
| | | @return: None-没有传奇属性; 传奇属性字典-[[传奇属性效果ID列表], [属性值列表]]
|
| | | @return: None 或者 [[传奇属性效果ID列表], [属性值列表]]
|
| | | '''
|
| | | if GetIsAuctionItem(curItem):
|
| | | #GameWorld.DebugLog("拍品无法生成传奇属性!")
|
| | | return
|
| | | itemID = curItem.GetItemTypeID()
|
| | | itemType = curItem.GetType()
|
| | | if itemType == ChConfig.Def_ItemType_retWing:
|
| | | return __GetAddWingLegendAttr(curItem)
|
| | | |
| | | itemColor = curItem.GetItemColor()
|
| | | itemClassLV = ItemCommon.GetItemClassLV(curItem)
|
| | | itemQuality = curItem.GetItemQuality()
|
| | | key = (itemColor, itemQuality)
|
| | | isDogzEquip = ItemCommon.GetIsDogzEquip(curItem)
|
| | | # {(颜色,星级):[一般属性条数, 追求属性条数, 固定属性条数], ...}
|
| | | if isDogzEquip:
|
| | | #神兽装备条数不一样
|
| | | legAttrCntDict = IpyGameDataPY.GetFuncEvalCfg("LegendAttrCount", 2)
|
| | | else:
|
| | | legAttrCntDict = IpyGameDataPY.GetFuncEvalCfg("LegendAttrCount")
|
| | | if key not in legAttrCntDict:
|
| | | #GameWorld.DebugLog("该装备品质没有传奇属性: itemColor=%s,itemQuality=%s" % (itemColor, itemQuality))
|
| | | isSuit = 1 if curItem.GetSuiteID() else 0
|
| | | # 1. 定条数
|
| | | attrCountIpyData = IpyGameDataPY.GetIpyGameDataNotLog("EquipLegendAttrCount", itemType, itemColor, isSuit, itemQuality)
|
| | | if not attrCountIpyData:
|
| | | if itemColor >= ChConfig.Def_Quality_Purple:
|
| | | GameWorld.DebugLog("该装备没有传奇属性: itemID=%s" % (itemID))
|
| | | return
|
| | | commAttrCnt, goodAttrCnt, specAttrCnt = legAttrCntDict[key]
|
| | | |
| | | # {装备位:[[一般属性ID列表], [追求属性ID列表], [固定属性ID列表]], ...}
|
| | | equipPlace = curItem.GetEquipPlace()
|
| | | legAttrRuleDict = IpyGameDataPY.GetFuncEvalCfg("LegendAttrRule")
|
| | | if equipPlace not in legAttrRuleDict:
|
| | | #GameWorld.DebugLog("该装备位没有传奇属性, equipPlace=%s" % equipPlace)
|
| | | legendAttrCountInfoList = attrCountIpyData.GetLegendAttrCountInfo() # 传奇属性条数信息 [[条数, [属性类型库编号, ...]], ...]
|
| | | if not legendAttrCountInfoList:
|
| | | return
|
| | | commAttrList, goodAttrList, specAttrList = legAttrRuleDict[equipPlace]
|
| | |
|
| | | randAttrIDList = [] # 先随机传奇属性类型
|
| | | if commAttrCnt:
|
| | | randAttrIDList.extend(random.sample(commAttrList, min(len(commAttrList), commAttrCnt)))
|
| | | if goodAttrCnt:
|
| | | randAttrIDList.extend(random.sample(goodAttrList, min(len(goodAttrList), goodAttrCnt)))
|
| | | if specAttrCnt:
|
| | | if type(specAttrList) == int:
|
| | | if specAttrList:
|
| | | randAttrIDList.append(specAttrList)
|
| | | else:
|
| | | randAttrIDList.extend(random.sample(specAttrList, min(len(specAttrList), specAttrCnt)))
|
| | | |
| | | if not curPlayer:
|
| | | GameWorld.ErrLog("生成装备传奇属性时玩家不存在!itemID=%s" % (itemID))
|
| | | return
|
| | | |
| | | playerID, playerLV = curPlayer.GetPlayerID(), curPlayer.GetLV()
|
| | | # 2. 定属性ID
|
| | | attrTypeIpyData = IpyGameDataPY.GetIpyGameData("EquipLegendAttrType", itemType)
|
| | | if not attrTypeIpyData:
|
| | | return
|
| | | legendAttrTypeLibDict = attrTypeIpyData.GetLegendAttrTypeLib() # 传奇属性类型库 {属性类型库编号:[属性ID,...], ...}
|
| | | |
| | | curLegAttrIDList = []
|
| | | curLegAttrValueList = []
|
| | | # {属性ID:{颜色:数值, ...}, ...}
|
| | | if isDogzEquip:
|
| | | # 神兽装备数值不一样 |
| | | legAttrValueColorDict = IpyGameDataPY.GetFuncEvalCfg("LegendAttrValueByColor2", 1, {})
|
| | | legAttrValueClassLVColorDict = IpyGameDataPY.GetFuncEvalCfg("LegendAttrValueByColor2", 2, {})
|
| | | itemClassLV = ItemCommon.GetItemClassLV(curItem)
|
| | | if isAllAttr:
|
| | | if curPlayer.GetGMLevel() != 90:
|
| | | return
|
| | | for attrIDList in legendAttrTypeLibDict.values():
|
| | | curLegAttrIDList += attrIDList
|
| | | #GameWorld.DebugLog("所有传奇属性: %s" % (curLegAttrIDList), playerID)
|
| | | else:
|
| | | legAttrValueColorDict = IpyGameDataPY.GetFuncEvalCfg("LegendAttrValueByColor", 1, {})
|
| | | legAttrValueClassLVColorDict = IpyGameDataPY.GetFuncEvalCfg("LegendAttrValueByColor", 2, {})
|
| | | legAttrValueClassLVDict = IpyGameDataPY.GetFuncEvalCfg("LegendAttrValueByClassLV")
|
| | | for attrID in randAttrIDList:
|
| | | if attrID in legAttrValueColorDict:
|
| | | colorValueDict = legAttrValueColorDict[attrID]
|
| | | if itemColor not in colorValueDict:
|
| | | GameWorld.ErrLog("没有配置传奇属性ID装备颜色对应的数值, attrID=%s,itemColor=%s" % (attrID, itemColor))
|
| | | continue
|
| | | attrValue = colorValueDict[itemColor]
|
| | | # {属性ID:{阶:{颜色:数值, ...}, ...}, ...}
|
| | | elif attrID in legAttrValueClassLVColorDict:
|
| | | classLVColorValueDict = legAttrValueClassLVColorDict[attrID]
|
| | | if itemClassLV in classLVColorValueDict:
|
| | | colorValueDict = classLVColorValueDict[itemClassLV]
|
| | | else:
|
| | | minClassLV, maxClassLV = min(classLVColorValueDict), max(classLVColorValueDict)
|
| | | if itemClassLV <= minClassLV:
|
| | | colorValueDict = classLVColorValueDict[minClassLV]
|
| | | elif itemClassLV >= maxClassLV:
|
| | | colorValueDict = classLVColorValueDict[maxClassLV]
|
| | | else:
|
| | | GameWorld.ErrLog("没有配置传奇属性ID装备阶级颜色对应的数值, attrID=%s,itemClassLV=%s" % (attrID, itemClassLV))
|
| | | continue
|
| | | if itemColor not in colorValueDict:
|
| | | GameWorld.ErrLog("没有配置传奇属性ID装备阶级颜色对应的数值, attrID=%s,itemClassLV=%s,itemColor=%s" % (attrID, itemClassLV, itemColor))
|
| | | continue
|
| | | attrValue = colorValueDict[itemColor]
|
| | | elif attrID in legAttrValueClassLVDict:
|
| | | classLVValueDict = legAttrValueClassLVDict[attrID]
|
| | | if itemClassLV in classLVValueDict:
|
| | | attrValue = classLVValueDict[itemClassLV]
|
| | | else:
|
| | | minClassLV, maxClassLV = min(classLVValueDict), max(classLVValueDict)
|
| | | if itemClassLV <= minClassLV:
|
| | | attrValue = classLVValueDict[minClassLV]
|
| | | elif itemClassLV >= maxClassLV:
|
| | | attrValue = classLVValueDict[maxClassLV]
|
| | | else:
|
| | | GameWorld.ErrLog("没有配置传奇属性ID装备阶级对应的数值, attrID=%s,itemClassLV=%s" % (attrID, itemClassLV))
|
| | | continue
|
| | | else:
|
| | | GameWorld.ErrLog("没有配置传奇属性ID对应的数值, attrID=%s" % attrID)
|
| | | continue
|
| | | |
| | | curLegAttrIDList.append(attrID)
|
| | | #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("itemClassLV=%s,itemColor=%s,itemQuality=%s,commAttrCnt=%s,goodAttrCnt=%s,specAttrCnt=%s" |
| | | # % (itemClassLV, itemColor, itemQuality, commAttrCnt, goodAttrCnt, specAttrCnt))
|
| | | # GameWorld.DebugLog("commAttrList=%s, goodAttrList=%s, specAttrList=%s" % (commAttrList, goodAttrList, specAttrList))
|
| | | # GameWorld.DebugLog("randAttrIDList=%s,curLegAttrIDList=%s, curLegAttrValueList=%s" |
| | | # % (randAttrIDList, curLegAttrIDList, curLegAttrValueList))
|
| | | #GameWorld.DebugLog(" 随机属性: attrID=%s,attrValue=%s,playerLV=%s,curLibNum=%s,valueList=%s" |
| | | # % (attrID, attrValue, playerLV, curLibNum, valueList), playerID)
|
| | | return [curLegAttrIDList, curLegAttrValueList]
|
| | |
|
| | | def __GetAddWingLegendAttr(curItem):
|
| | | # {阶数:条数, ...}
|
| | | wingLegAttrCntDict = IpyGameDataPY.GetFuncEvalCfg("WingLegendAttrCount")
|
| | | itemClassLV = ItemCommon.GetItemClassLV(curItem)
|
| | | if itemClassLV not in wingLegAttrCntDict:
|
| | | GameWorld.DebugLog("该翅膀阶级没有传奇属性, 阶数=%s" % itemClassLV)
|
| | | return
|
| | | legAttrCnt = wingLegAttrCntDict[itemClassLV]
|
| | | # {阶数:{属性ID1:[数值随机列表], 属性ID2:[数值随机列表]},阶数:{属性ID1:[数值随机列表], 属性ID2:[数值随机列表]},...}
|
| | | wingLegAttrValueDict = IpyGameDataPY.GetFuncEvalCfg("WingLegendAttrValue")
|
| | | if itemClassLV not in wingLegAttrValueDict:
|
| | | GameWorld.ErrLog("该翅膀阶级没有配置对应的传奇属性数值, 阶数=%s" % itemClassLV) |
| | | return
|
| | | curClassLVLegAttrDict = wingLegAttrValueDict[itemClassLV]
|
| | | attrIDList = curClassLVLegAttrDict.keys()
|
| | | legAttrCnt = min(len(attrIDList), legAttrCnt)
|
| | | GameWorld.DebugLog("生成翅膀传奇属性: itemClassLV=%s,legAttrCnt=%s,attrIDList=%s" % (itemClassLV, legAttrCnt, attrIDList))
|
| | | if not legAttrCnt:
|
| | | return
|
| | | curLegAttrIDList = random.sample(attrIDList, legAttrCnt)
|
| | | #curLegAttrIDList.sort()
|
| | | curLegAttrValueList = [random.choice(curClassLVLegAttrDict[attrID]) for attrID in curLegAttrIDList]
|
| | | GameWorld.DebugLog(" curLegAttrIDList=%s, curLegAttrValueList=%s" % (curLegAttrIDList, curLegAttrValueList))
|
| | | return [curLegAttrIDList, curLegAttrValueList]
|
| | |
|
| | | ##创建物品所需的动态数据
|
| | | #
|
| | |
| | | self.source = ShareDefine.Item_Source_Unkown #物品来源
|
| | | self.legendAttrIDList = [] # 传奇属性ID
|
| | | self.legendAttrValueList = [] # 传奇属性值
|
| | | |
| | | self.OutOfPrintAttrIDList = [] # 绝版属性ID
|
| | | self.OutOfPrintAttrValueList = [] # 绝版属性最大值
|
| | | return
|
| | |
|
| | | def ClearPack(curPlayer, packType):
|
| | |
| | | curItem.Clear()
|
| | | return
|
| | |
|
| | | def PutItemInTempSwap(curPlayer, itemID, isBind=1):
|
| | | def PutItemInTempSwap(curPlayer, itemID, isAuctionItem=0):
|
| | | ## 临时背包放入物品
|
| | | # 临时交换背包目前只开放1个格子,每次放入前先清空再放入
|
| | | ClearPack(curPlayer, ShareDefine.rptTempSwap)
|
| | | return GivePlayerItem(curPlayer, itemID, 1, isBind, [ShareDefine.rptTempSwap])
|
| | | return GivePlayerItem(curPlayer, itemID, 1, isAuctionItem, [ShareDefine.rptTempSwap])
|
| | |
|
| | | def OpenPickupItemPutInTemp(curPlayer, isClearItem):
|
| | | ''' 开启拾取的物品放入临时存放背包
|
| | |
| | | mailItemList = []
|
| | | for tempItem in tempItemList:
|
| | | mailItemList.append(ItemCommon.GetMailItemDict(tempItem))
|
| | | mailItemList +=extraItemList
|
| | | mailItemList += extraItemList
|
| | | mailTypeKey = ShareDefine.DefaultLackSpaceMailType if not mailTypeKey else mailTypeKey
|
| | | PlayerControl.SendMailByKey(mailTypeKey, [curPlayer.GetPlayerID()], mailItemList)
|
| | | else:
|
| | | itemControl = PlayerItemControler(curPlayer)
|
| | | for tempItem in tempItemList:
|
| | | itemControl.PutInItem(IPY_GameWorld.rptItem, tempItem, event=event)
|
| | | for itemID, itemCnt, isBind in extraItemList:
|
| | | GivePlayerItem(curPlayer, itemID, itemCnt, isBind, |
| | | [IPY_GameWorld.rptItem], event=event)
|
| | | for itemID, itemCnt, isAuctionItem in extraItemList:
|
| | | GivePlayerItem(curPlayer, itemID, itemCnt, isAuctionItem, [IPY_GameWorld.rptItem], event=event)
|
| | |
|
| | | ClearPack(curPlayer, ShareDefine.rptTempItem)
|
| | | return
|
| | |
|
| | | def GivePlayerItemOrMail(curPlayer, itemList, mailKey=None, event=["", False, {}]):
|
| | | ##给物品,背包满则发邮件
|
| | | needPackSpaceDict = {}
|
| | | for itemID, itemCnt, isAuctionItem in itemList:
|
| | | curItem = GameWorld.GetGameData().GetItemByTypeID(itemID)
|
| | | if not curItem:
|
| | | GameWorld.ErrLog('GivePlayerItemOrMail 物品ID不存在 itemID=%s'%itemID, curPlayer.GetID())
|
| | | return
|
| | | packType = ChConfig.GetItemPackType(curItem.GetType())
|
| | | needSpace = GetItemNeedPackCount(packType, curItem, itemCnt, isAuctionItem)
|
| | | needPackSpaceDict[packType] = needPackSpaceDict.get(packType, 0) + needSpace
|
| | | isSendMail = False
|
| | | for packType, needSpace in needPackSpaceDict.items():
|
| | | if needSpace > ItemCommon.GetItemPackSpace(curPlayer, packType, needSpace):
|
| | | isSendMail = True
|
| | | break
|
| | | |
| | | if isSendMail:
|
| | | PlayerControl.SendMailByKey(mailKey, [curPlayer.GetPlayerID()], itemList)
|
| | | GameWorld.DebugLog("GivePlayerItemOrMail背包空间不够,发送邮件: mailItemList=%s" % str(itemList), curPlayer.GetPlayerID())
|
| | | else:
|
| | | for itemID, itemCnt, isAuctionItem in itemList:
|
| | | GivePlayerItem(curPlayer, itemID, itemCnt, isAuctionItem, [IPY_GameWorld.rptItem], event=event)
|
| | | return
|
| | |
|
| | | def CheckChangeOldItem(curPlayer, tagItem):
|
| | | ##替换旧物品
|
| | | itemID = tagItem.GetItemTypeID()
|
| | | changeOldItemDict = IpyGameDataPY.GetFuncEvalCfg('ChangeOldItem', 1, {})
|
| | | if itemID not in changeOldItemDict:
|
| | | return
|
| | | itemCnt = GetItemCount(tagItem)
|
| | | isBind = tagItem.GetIsBind()
|
| | | toItemID, toCnt, mailKey = changeOldItemDict[itemID]
|
| | | giveCnt = itemCnt * toCnt
|
| | | PlayerControl.SendMailByKey(mailKey, [curPlayer.GetPlayerID()], [[toItemID, giveCnt, isBind]])
|
| | | return True
|
| | |
|
| | | def LoginCheckChangeOldItem(curPlayer):
|
| | | ##登录检查替换旧物品
|
| | | giveItemDict = {}
|
| | | mailDict = {}
|
| | | for packIndex in [IPY_GameWorld.rptItem, IPY_GameWorld.rptWarehouse, ShareDefine.rptTreasure]:
|
| | | curPack = curPlayer.GetItemManager().GetPack(packIndex)
|
| | | for i in xrange(curPack.GetCount()):
|
| | | curItem = curPack.GetAt(i)
|
| | | if not curItem:
|
| | | continue
|
| | | itemID = curItem.GetItemTypeID()
|
| | | changeOldItemDict = IpyGameDataPY.GetFuncEvalCfg('ChangeOldItem', 1, {})
|
| | | if itemID not in changeOldItemDict:
|
| | | continue
|
| | | isBind = curItem.GetIsBind()
|
| | | itemCount = curItem.GetCount()
|
| | | toItemID, toCnt, mailKey = changeOldItemDict[itemID]
|
| | | giveCnt = itemCount * toCnt
|
| | | keyStr = '%s_%s'%(toItemID, isBind)
|
| | | giveItemDict[keyStr] = giveItemDict.get(keyStr, 0) + giveCnt
|
| | | ItemCommon.DelItem(curPlayer, curItem, itemCount, False, "ChangeOldItem")
|
| | | if mailKey not in mailDict:
|
| | | mailDict[mailKey] = [keyStr]
|
| | | if keyStr not in mailDict[mailKey]:
|
| | | mailDict[mailKey].append(keyStr)
|
| | | for mailKey, keyStrList in mailDict.items():
|
| | | itemList = []
|
| | | for keyStr in keyStrList:
|
| | | if keyStr not in giveItemDict:
|
| | | continue
|
| | | giveCnt = giveItemDict[keyStr]
|
| | | itemID, isBind = keyStr.split('_')
|
| | | itemList.append([int(itemID), giveCnt, int(isBind)])
|
| | | PlayerControl.SendMailByKey(mailKey, [curPlayer.GetID()], itemList)
|
| | | return |