| | |
| | | import traceback
|
| | | import random
|
| | | import ReadChConfig
|
| | | import ChItem
|
| | | import PlayerSuccess
|
| | | import PlayerFamily
|
| | | import ChPyNetSendPack
|
| | | import NetPackCommon
|
| | | import PlayerXiangong
|
| | | import IpyGameDataPY
|
| | | import DataRecordPack
|
| | | import PlayerGubao
|
| | | import PyGameData
|
| | | import ChEquip
|
| | | import PlayerHero
|
| | | import ObjPool
|
| | |
|
| | | import math
|
| | | import time
|
| | |
| | | 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)
|
| | |
| | | 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)
|
| | |
| | | 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):
|