| | |
| | |
|
| | | return True
|
| | |
|
| | | #// A3 10 购买商城物品 #tagCMBuyItem
|
| | | #
|
| | | #struct tagCMBuyItem
|
| | | #{
|
| | | # tagHead Head;
|
| | | # WORD BuyItemIndex; //购买的物品索引
|
| | | # DWORD BuyCount; //购买数量
|
| | | #};
|
| | | def PyBuyItem(index, clientData, tick):
|
| | | curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
| | | itemIndex = clientData.BuyItemIndex
|
| | | buyCount = clientData.BuyCount
|
| | | OnBuyItem(curPlayer, itemIndex, buyCount)
|
| | | return
|
| | |
|
| | | ##购买物品
|
| | | # @param curPlayer 玩家实例
|
| | | # @param tick 时间戳
|
| | | # @return 返回值真, 逻辑运行成功
|
| | | def BuyItem(curPlayer, tick):
|
| | | |
| | | if GameWorld.IsCrossServer():
|
| | | return
|
| | | |
| | | buyItemList = IPY_GameWorld.IPY_CBuyItemList()
|
| | | itemIndex = buyItemList.GetBuyItemIndex()
|
| | | if itemIndex < 0:
|
| | | return
|
| | | |
| | | clientBuyCount = buyItemList.GetBuyCount()
|
| | | if not clientBuyCount:
|
| | | OnBuyItem(curPlayer, itemIndex, clientBuyCount)
|
| | | return
|
| | |
|
| | | def OnBuyItem(curPlayer, itemIndex, clientBuyCount):
|
| | | GameWorld.DebugLog("购买商城物品: itemIndex=%s,clientBuyCount=%s" % (itemIndex, clientBuyCount), curPlayer.GetPlayerID())
|
| | | if GameWorld.IsCrossServer():
|
| | | return
|
| | | if itemIndex < 0 or clientBuyCount <= 0:
|
| | | return
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("Store", itemIndex)
|
| | | if not ipyData:
|
| | | return
|
| | |
| | | if limitBuyCnt > 0:
|
| | | dayBuyCntKey = ChConfig.Def_PDict_ShopItemDayBuyCnt % itemIndex
|
| | | curDayBuyCnt = curPlayer.NomalDictGetProperty(dayBuyCntKey)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, dayBuyCntKey, curDayBuyCnt + clientBuyCount)
|
| | | updDayBuyCnt = min(curDayBuyCnt + clientBuyCount, ChConfig.Def_UpperLimit_DWord)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, dayBuyCntKey, updDayBuyCnt)
|
| | | GameWorld.DebugLog("更新商城物品限购次数: itemIndex=%s,curDayBuyCnt=%s,clientBuyCount=%s,updDayBuyCnt=%s/%s" |
| | | % (itemIndex, curDayBuyCnt, clientBuyCount, updDayBuyCnt, limitBuyCnt), curPlayer.GetPlayerID())
|
| | | SyncShopItemTodayBuyCount(curPlayer, [itemIndex])
|
| | |
|
| | | dataDict = {"ShopType":shopType, "ShopItemIndex":itemIndex, "ClientBuyCount":clientBuyCount,
|
| | |
| | | "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, False, curPlayer=curPlayer)
|
| | | if not curItemObj:
|
| | | continue
|
| | | userData = curItemObj.GetUserData()
|
| | | curItemObj.Clear()
|
| | | if not sendMailKey:
|
| | | packType = ChConfig.GetItemPackType(curItemObj)
|
| | | if not itemControl.PutInItem(packType, curItemObj, event=[ChConfig.ItemGive_BuyItem, isForceEvent, dataDict]):
|
| | | curItemObj.Clear()
|
| | | continue
|
| | | else:
|
| | | curItemObj.Clear()
|
| | | if not ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, isBind, event=[ChConfig.ItemGive_BuyItem, isForceEvent, dataDict]):
|
| | | GameWorld.ErrLog("购买商城物品放入背包失败! itemID=%s, itemCount=%s" % (itemID, itemCount), curPlayer.GetPlayerID())
|
| | | EventShell.EventRespons_BuyItem(curPlayer, itemID, itemCount)
|
| | |
|
| | | if ipyData.GetNotifyMark() and itemID == mainItemID:
|