| | |
| | | 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
|
| | |
| | | return item
|
| | |
|
| | | return None
|
| | |
|
| | | ## 检查是否可以换马匹
|
| | | # @param curPlayer 当前玩家
|
| | | # @return None or True
|
| | | # @remarks 函数详细说明.
|
| | | def CheckCanEquipHorse(curPlayer):
|
| | | if curPlayer.GetPlayerVehicle() == IPY_GameWorld.pvHorse :
|
| | | #DJ_Res_Horses_AlreadyEquip 对不起,您处于骑马状态中,操作无效
|
| | | PlayerControl.NotifyCode(curPlayer, "DJ_Res_Horses_AlreadyEquip")
|
| | | return
|
| | | |
| | | horsePack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptHorse)
|
| | | if not GetPackIsEmpty(horsePack):
|
| | | #Horses_Bag_NoRoom 对不起,您的马匹背包中有物品,操作无效!
|
| | | PlayerControl.NotifyCode(curPlayer, "Horses_Bag_NoRoom")
|
| | | return
|
| | | |
| | | return True
|
| | |
|
| | | #===============================================================================
|
| | | # #将物品放入增值栏的一个空位置中,如果失败,替换第一个位置
|
| | |
| | | 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, 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, {}]):
|
| | |
| | | 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)
|
| | |
| | | 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):
|