| | |
| | |
|
| | | GameWorld.DebugLog("购买物品: shopType=%s,itemIndex=%s,clientBuyCount=%s,totalItemList=%s,mainItemID=%s,needPackSpaceDict=%s"
|
| | | % (shopType, itemIndex, clientBuyCount, totalItemList, mainItemID, needPackSpaceDict), curPlayer.GetPlayerID())
|
| | | |
| | | mailKey = ipyData.GetMailKey()
|
| | | isLackPack = False #是否背包不足
|
| | | for packType, needSpace in needPackSpaceDict.items():
|
| | | if needSpace > ItemCommon.GetItemPackSpace(curPlayer, packType, needSpace):
|
| | | curPlayer.ShopResult(itemIndex, IPY_GameWorld.tsrNoPlace)
|
| | | PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_676165", [packType])
|
| | | return
|
| | | isLackPack = True
|
| | | if mailKey:
|
| | | break
|
| | | else:
|
| | | curPlayer.ShopResult(itemIndex, IPY_GameWorld.tsrNoPlace)
|
| | | PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_676165", [packType])
|
| | | return
|
| | | sendMailKey = mailKey if isLackPack and mailKey else '' #背包不足且配置了mailKey的才发邮件
|
| | |
|
| | | # 购买限制条件扩展
|
| | | if CheckBuyItemLimitEx(curPlayer, shopType, itemIndex, mainItemID, ipyData.GetLimitValue()):
|
| | |
| | | #已经在查询中, 不重复查询
|
| | | GameWorld.DebugLog("全服购买次数已经在查询中, 不重复查询 itemIndex=%s" % itemIndex)
|
| | | return
|
| | | cmdStr = '%s' % ([itemIndex, serverLimitCnt, clientBuyCount, totalItemList, mainItemID, limitBuyCnt])
|
| | | cmdStr = '%s' % ([itemIndex, serverLimitCnt, clientBuyCount, totalItemList, mainItemID, limitBuyCnt, sendMailKey])
|
| | | GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(curPlayer.GetID(), 0, 0,
|
| | | "GetStoreServerBuyCnt", cmdStr, len(cmdStr))
|
| | | #设置状态查询中
|
| | | curPlayer.SetDict(ChConfig.Def_PlayerKey_StoreQueryState, 1)
|
| | | return
|
| | | #-------------------------开始购买物品-----------------------------
|
| | | DoBuyStoreItem(curPlayer, itemIndex, clientBuyCount, totalItemList, mainItemID, limitBuyCnt, ipyData)
|
| | | DoBuyStoreItem(curPlayer, itemIndex, clientBuyCount, totalItemList, mainItemID, limitBuyCnt, sendMailKey, ipyData)
|
| | |
|
| | | return
|
| | |
|
| | | def DoBuyStoreItem(curPlayer, itemIndex, clientBuyCount, totalItemList, mainItemID, limitBuyCnt, ipyData=None):
|
| | | def DoBuyStoreItem(curPlayer, itemIndex, clientBuyCount, totalItemList, mainItemID, limitBuyCnt, sendMailKey, ipyData=None):
|
| | | if not ipyData:
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("Store", itemIndex)
|
| | | priceType, itemPrice = ipyData.GetMoneyType(), ipyData.GetMoneyNum()
|
| | | itemPrice *= clientBuyCount
|
| | | shopType = ipyData.GetShopType()
|
| | |
|
| | | beforeMoney = PlayerControl.GetMoney(curPlayer, priceType)
|
| | |
| | | "ItemPrice":itemPrice, "MoneyType":priceType,
|
| | | "BeforeMoney":beforeMoney, "AfterMoney":afterMoney}
|
| | | isForceEvent = priceType not in [IPY_GameWorld.TYPE_Price_Silver_Money]
|
| | | |
| | |
|
| | | itemControl = ItemControler.PlayerItemControler(curPlayer)
|
| | | for itemID, itemCount, isBind in totalItemList:
|
| | | curItemObj = ItemControler.GetOutPutItemObj(itemID, itemCount, isBind)
|
| | | if not curItemObj:
|
| | | continue
|
| | | userData = curItemObj.GetUserData()
|
| | | packType = ChConfig.GetItemPackType(curItemObj.GetType())
|
| | | if not itemControl.PutInItem(packType, curItemObj, event=[ChConfig.ItemGive_BuyItem, isForceEvent, dataDict]):
|
| | | if not sendMailKey:
|
| | | packType = ChConfig.GetItemPackType(curItemObj.GetType())
|
| | | if not itemControl.PutInItem(packType, curItemObj, event=[ChConfig.ItemGive_BuyItem, isForceEvent, dataDict]):
|
| | | curItemObj.Clear()
|
| | | continue
|
| | | else:
|
| | | curItemObj.Clear()
|
| | | continue
|
| | | |
| | | EventShell.EventRespons_BuyItem(curPlayer, itemID, itemCount)
|
| | |
|
| | | if ipyData.GetNotifyMark() and itemID == mainItemID:
|
| | | PlayerControl.WorldNotify(0, ipyData.GetNotifyMark(), [curPlayer.GetName(), mainItemID, userData])
|
| | | |
| | | if sendMailKey:
|
| | | PlayerControl.SendMailByKey(sendMailKey, [curPlayer.GetID()], totalItemList, detail=dataDict)
|
| | | #触发任务购买物品
|
| | | EventShell.EventRespons_ShopBuy(curPlayer, shopType)
|
| | | #curPlayer.ShopResult(itemIndex, IPY_GameWorld.tsrShopOK)
|