| | |
| | | import traceback
|
| | | import random
|
| | | import ReadChConfig
|
| | | import ChItem
|
| | | import PlayerSuccess
|
| | | import PlayerFamily
|
| | | import ChPyNetSendPack
|
| | | import NetPackCommon
|
| | | import Operate_EquipStone
|
| | | import PlayerFairyCeremony
|
| | | import PlayerActBossTrial
|
| | | import PlayerMagicWeapon
|
| | | import PlayerXiangong
|
| | | import IpyGameDataPY
|
| | | import DataRecordPack
|
| | | import PlayerGubao
|
| | | import PyGameData
|
| | | import PlayerVip
|
| | | import ChEquip
|
| | | import PlayerHero
|
| | | import ObjPool
|
| | |
|
| | | import math
|
| | | import time
|
| | |
| | | if packIndex == ShareDefine.rptRune:
|
| | | runeSource = tagItem.GetUserAttr(ShareDefine.Def_IudetRuneSource) or 1
|
| | | setItemKeyData = GetRuneItemKeyData(tagItem.GetItemTypeID(), tagItem.GetUserAttr(ShareDefine.Def_IudetRuneLV), source=runeSource)
|
| | | elif packIndex == ShareDefine.rptGatherSoul:
|
| | | setItemKeyData = GetGatherSoulItemKeyData(tagItem.GetItemTypeID(), tagItem.GetUserAttr(ShareDefine.Def_IudetGatherSoulLV))
|
| | |
|
| | | |
| | | refreshPlaceList = []
|
| | | for place in xrange(ItemCommon.GetVPackCnt(packIndex)):
|
| | | itemKeyData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_VPackItem % (packIndex, place))
|
| | |
| | | return True
|
| | | if itemID not in ChConfig.Def_TransformItemIDList:
|
| | | return False
|
| | | if itemID == ChConfig.Def_ItemID_FamilyContribution:
|
| | | PlayerFamily.AddPlayerFamilyActiveValue(curPlayer, itemCount, True, ShareDefine.Def_AddFAVReason_UseItem, True)
|
| | | elif itemID == ChConfig.Def_ItemID_SilverMoney:
|
| | | if itemID == ChConfig.Def_ItemID_SilverMoney:
|
| | | PlayerControl.GiveMoney(curPlayer, IPY_GameWorld.TYPE_Price_Silver_Money, itemCount)
|
| | | elif itemID == ChConfig.Def_ItemID_FamilyActive:
|
| | | 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_Money, itemCount, moneyEventName, addDict)
|
| | | elif itemID == ChConfig.Def_ItemID_FuncSysPrivilege:
|
| | | PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_FuncSysPrivilege, itemCount)
|
| | | elif itemID == ChConfig.Def_ItemID_FCPartyPoint:
|
| | | PlayerFairyCeremony.AddFCPartyPoint(curPlayer, itemCount)
|
| | | elif itemID == ChConfig.Def_ItemID_BTGMPoint:
|
| | | PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_BTGMPoint, itemCount)
|
| | | elif itemID == ChConfig.Def_ItemID_GuShenMoney:
|
| | |
| | | PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_GongdePoint, itemCount)
|
| | | elif itemID == ChConfig.Def_ItemID_FamilyFlagWarPoint:
|
| | | PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_FamilyFlagWarPoint, itemCount)
|
| | | elif itemID == ChConfig.Def_ItemID_SuccessScore:
|
| | | PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_SuccessSocre, itemCount, moneyEventName, addDict)
|
| | | return True
|
| | |
|
| | | def __CrossServerPutInItem(self, packIndex, tagItem, event=["", False, {}]):
|
| | |
| | | isNeedRecord = False
|
| | | itemID = tagItem.GetItemTypeID()
|
| | | #激活成就的道具
|
| | | if tagItem.GetType() in [ChConfig.Def_ItemType_ActiveMWItem, ChConfig.Def_ItemType_ActiveMWItem2]:
|
| | | PlayerMagicWeapon.DoActiveMW(curPlayer, tagItem.GetEffectByIndex(0).GetEffectValue(0))
|
| | | tagItem.Clear()
|
| | | return True
|
| | | #if tagItem.GetType() in [ChConfig.Def_ItemType_ActiveMWItem, ChConfig.Def_ItemType_ActiveMWItem2]:
|
| | | # PlayerMagicWeapon.DoActiveMW(curPlayer, tagItem.GetEffectByIndex(0).GetEffectValue(0))
|
| | | # tagItem.Clear()
|
| | | # return True
|
| | | itemEff = tagItem.GetEffectByIndex(0)
|
| | | #物品碎片
|
| | | if itemEff.GetEffectID() == ChConfig.Def_Effect_ItemCount:
|
| | | SetItemCountByID(curPlayer, itemID, GetItemCountByID(curPlayer, itemID) + tagItemCount)
|
| | | tagItem.Clear()
|
| | | return True
|
| | | #古宝碎片
|
| | | if itemEff.GetEffectID() == ChConfig.Def_Effect_GubaoPiece:
|
| | | gubaoID = itemEff.GetEffectValue(0)
|
| | | if gubaoID:
|
| | | PlayerGubao.AddGubaoPiece(curPlayer, gubaoID, tagItemCount, itemID)
|
| | | tagItem.Clear()
|
| | | return True
|
| | | #气运
|
| | | if itemEff.GetEffectID() == ChConfig.Def_Effect_TiandaoQiyun:
|
| | | isAutoUse = itemEff.GetEffectValue(1)
|
| | |
| | | PlayerXiangong.AddTiandaoQiyun(curPlayer, addQiyun, {"ItemID":itemID, "ItemCount":tagItemCount, "isAutoUse":1})
|
| | | tagItem.Clear()
|
| | | return True
|
| | | #直升VIP
|
| | | if itemEff.GetEffectID() == ChConfig.Def_Effect_VIPLVCard:
|
| | | isAutoUse = itemEff.GetEffectValue(1)
|
| | | if isAutoUse:
|
| | | tagVIPLV = itemEff.GetEffectValue(0)
|
| | | isOK, _ = PlayerVip.UpgradeVIPLV(curPlayer, tagVIPLV)
|
| | | if isOK:
|
| | | #GameWorld.DebugLog("直升VIP默认使用")
|
| | | tagItem.Clear()
|
| | | return True
|
| | | #增加副本次数
|
| | | if itemEff.GetEffectID() == ChConfig.Def_Effect_AddFBCnt:
|
| | | isAutoUse = itemEff.GetEffectValue(1)
|
| | |
| | | #GameWorld.DebugLog("增加副本次数默认使用! mapID=%s" % mapID)
|
| | | tagItem.Clear()
|
| | | return True
|
| | | #活动道具自动转化
|
| | | if PlayerActBossTrial.CheckActItemAutoTransform(curPlayer, tagItem, itemID, tagItemCount):
|
| | | tagItem.Clear()
|
| | | return True
|
| | | |
| | | |
| | | if itemID in ChConfig.Def_TransformItemIDList or tagItem.GetType() == ChConfig.Def_ItemType_AutoUseMoney:
|
| | | # 直接转化为对应货币的物品仅在放入背包时直接转化,否则还是以真实物品的形式存在,但堆叠上限需要做特殊处理
|
| | | if packIndex == IPY_GameWorld.rptItem:
|
| | |
| | | def IsRuneItemNeedRecord(curItem, plusLV):
|
| | | return plusLV > 0 or curItem.GetItemColor() >= ChConfig.Def_Quality_Orange
|
| | |
|
| | | # 聚魂物品存储字典数值数据结构: 前5位为物品ID, 6~8位为强化等级
|
| | | def GetGatherSoulItemKeyData(itemID, GatherSoulLV):
|
| | | return min(GatherSoulLV, 999) * 100000 + itemID
|
| | | def GetGatherSoulItemID(keyData): return keyData % 100000
|
| | | def GetGatherSoulItemPlusLV(keyData): return keyData % 100000000 / 100000
|
| | | def IsGatherSoulItemNeedRecord(curItem, plusLV):
|
| | | return plusLV > 0 or curItem.GetItemColor() >= ChConfig.Def_Quality_Orange
|
| | |
|
| | | def SetVPackItemKeyData(curPlayer, packIndex, place, keyData, isSync=True):
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_VPackItem % (packIndex, place), keyData)
|
| | | if isSync:
|
| | |
| | | itemCount = GetItemCountByID(curPlayer, itemID)
|
| | | if not itemCount and not force:
|
| | | continue
|
| | | countInfo = ChPyNetSendPack.tagMCAutoItemCount()
|
| | | countInfo = ObjPool.GetPoolMgr().acquire(ChPyNetSendPack.tagMCAutoItemCount)
|
| | | countInfo.Clear()
|
| | | countInfo.ItemID = itemID
|
| | | countInfo.ItemCount = itemCount
|
| | |
| | | if not itemCountList:
|
| | | return
|
| | |
|
| | | clientPack = ChPyNetSendPack.tagMCAutoItemCountRefresh()
|
| | | clientPack = ObjPool.GetPoolMgr().acquire(ChPyNetSendPack.tagMCAutoItemCountRefresh)
|
| | | clientPack.Clear()
|
| | | clientPack.ItemCountList = itemCountList
|
| | | clientPack.Count = len(clientPack.ItemCountList)
|
| | |
| | | return False
|
| | |
|
| | | if isAuctionItem:
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("AuctionItem", itemID)
|
| | | ipyData = None #IpyGameDataPY.GetIpyGameData("AuctionItem", itemID)
|
| | | if not ipyData:
|
| | | GameWorld.ErrLog("非拍卖物品,默认转为非拍品! itemID=%s,itemCount=%s,isAuctionItem=%s"
|
| | | % (itemID, itemCount, isAuctionItem), curPlayer.GetPlayerID())
|
| | |
| | | def GetItemCountByID(curPlayer, itemID):
|
| | | return curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ItemCount % itemID)
|
| | | def SetItemCountByID(curPlayer, itemID, itemCount, isSync=True):
|
| | | befCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ItemCount % itemID)
|
| | | itemCount = max(0, min(itemCount, ChConfig.Def_UpperLimit_DWord))
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ItemCount % itemID, itemCount)
|
| | | |
| | | # 检查碎片溢出自动转化,数量增加时才检查
|
| | | if itemCount > befCount:
|
| | | #GameWorld.DebugLog("碎片数量增加,检查溢出! itemID=%s,itemCount=%s,befCount=%s" % (itemID, itemCount, befCount))
|
| | | if PlayerGubao.AutoTransGubaoPiece(curPlayer, itemID):
|
| | | PyGameData.g_transItemSign = 1
|
| | | |
| | | if isSync:
|
| | | Sync_AutoItemCount(curPlayer, [itemID])
|
| | | return itemCount
|
| | | def CheckItemEnoughByID(curPlayer, itemID, needCount):
|
| | | itemCount = GetItemCountByID(curPlayer, itemID)
|
| | | if itemCount < needCount:
|
| | | GameWorld.DebugLog("物品碎片不足! itemID=%s,itemCount=%s < %s" % (itemID, itemCount, needCount))
|
| | | return False
|
| | | return True
|
| | | def DelItemCountByID(curPlayer, itemID, delCount, isSync=True):
|
| | | itemCount = GetItemCountByID(curPlayer, itemID)
|
| | | if itemCount < delCount:
|
| | | GameWorld.DebugLog("扣除物品碎片不足! itemID=%s,itemCount=%s < %s" % (itemID, itemCount, delCount))
|
| | | return False
|
| | | SetItemCountByID(curPlayer, itemID, itemCount - delCount, isSync)
|
| | | return True
|
| | |
|
| | | ## 设置物品数量
|
| | | # @param item 物品实例
|
| | |
| | | itemEff = itemData.GetEffectByIndex(0)
|
| | | if itemEff.GetEffectID() == ChConfig.Def_Effect_ItemCount:
|
| | | return True
|
| | | if itemEff.GetEffectID() == ChConfig.Def_Effect_GubaoPiece:
|
| | | gubaoID = itemEff.GetEffectValue(0)
|
| | | if gubaoID:
|
| | | return True
|
| | | return False
|
| | |
|
| | | def GetOutPutItemObj(itemID, itemCount=1, isAuctionItem=False, expireTime=0, curPlayer=None, setAttrDict=None):
|
| | |
| | | def CheckPackSpaceEnough(curPlayer, itemList, isNotify=True):
|
| | | ## 检查玩家对应背包是否足够放入物品
|
| | | needPackSpaceDict = {}
|
| | | for itemID, itemCnt, isAuctionItem in itemList:
|
| | | for itemInfo in itemList:
|
| | | if not itemInfo:
|
| | | continue
|
| | | itemID, itemCnt = itemInfo[:2]
|
| | | isAuctionItem = itemInfo[2] if len(itemInfo) > 2 else 0
|
| | | curItem = GameWorld.GetGameData().GetItemByTypeID(itemID)
|
| | | if not curItem:
|
| | | return False
|