9300 【BT5】【主干】【后端】新增:法器进阶(支持自动购买限购物品)
# Conflicts:
# ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/UseItem/ItemCommon.py
| | |
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_DelPackIndex, int(itemIndexs))
|
| | | return
|
| | |
|
| | | def PayAutoBuyItem(curPlayer, lackItemDict, priceType, costType=ChConfig.Def_Cost_Unknown, infoDict={}):
|
| | | ''' 支付自动购买物品消耗,从商城中购买,直接扣钱,不产生物品
|
| | | 一般用于基础商店自动购买物品,不考虑复杂的限购逻辑
|
| | | '''
|
| | | |
| | | addLimitCountInfo = {}
|
| | | totalMoney = 0
|
| | | # 计算自动购买消耗
|
| | | for itemID, lackCnt in lackItemDict.items():
|
| | | if lackCnt <= 0:
|
| | | continue
|
| | | |
| | | curItem = GameWorld.GetGameData().GetItemByTypeID(itemID)
|
| | | if not curItem:
|
| | | return
|
| | | |
| | | ipyData = ItemCommon.GetShopItemPriceIpyData(itemID, priceType)
|
| | | if not ipyData:
|
| | | return
|
| | | |
| | | itemIndex = ipyData.GetID()
|
| | | shopType = ipyData.GetShopType()
|
| | | itemMoney = ipyData.GetMoneyNum()
|
| | | limitCntList = ipyData.GetLimitCnt()
|
| | | if limitCntList:
|
| | | limitBuyCnt = limitCntList[0]
|
| | | curDayBuyCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ShopItemDayBuyCnt % itemIndex)
|
| | | canBuyCnt = max(0, limitBuyCnt - curDayBuyCnt)
|
| | | if canBuyCnt < lackCnt:
|
| | | GameWorld.Log("自动购买次数不足!shopType=%s,itemIndex=%s,itemID=%s,limitBuyCnt=%s,curDayBuyCnt=%s,canBuyCnt=%s < %s" |
| | | % (shopType, itemIndex, itemID, limitBuyCnt, curDayBuyCnt, canBuyCnt, lackCnt), curPlayer.GetPlayerID())
|
| | | return
|
| | | addLimitCountInfo[itemIndex] = lackCnt
|
| | | |
| | | totalMoney += (lackCnt * itemMoney)
|
| | | |
| | | if totalMoney <= 0:
|
| | | return
|
| | | |
| | | GameWorld.DebugLog("扣除自动购买消耗: lackItemDict=%s,priceType=%s,totalMoney=%s,costType=%s,addLimitCountInfo=%s" |
| | | % (lackItemDict, priceType, totalMoney, costType, addLimitCountInfo), curPlayer.GetPlayerID())
|
| | | |
| | | if not PlayerControl.PayMoney(curPlayer, priceType, totalMoney, costType, infoDict):
|
| | | return
|
| | | |
| | | if addLimitCountInfo:
|
| | | syncIndexList = []
|
| | | for itemIndex, lackCnt in addLimitCountInfo.items():
|
| | | curDayBuyCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ShopItemDayBuyCnt % itemIndex)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ShopItemDayBuyCnt % itemIndex, curDayBuyCnt + lackCnt)
|
| | | syncIndexList.append(itemIndex)
|
| | | SyncShopItemTodayBuyCount(curPlayer, syncIndexList)
|
| | | |
| | | return True
|
| | |
|
| | | ##购买物品
|
| | | # @param curPlayer 玩家实例
|
| | | # @param tick 时间戳
|
| | |
| | | import IPY_GameWorld
|
| | | import PlayerControl
|
| | | import ChPyNetSendPack
|
| | | import FunctionNPCCommon
|
| | | import NetPackCommon
|
| | | import IpyGameDataPY
|
| | | import ItemCommon
|
| | |
| | | delCnt = costItemCount
|
| | | if lackCnt > 0:
|
| | | autoBuyMoneyType = IPY_GameWorld.TYPE_Price_Gold_Money
|
| | | lackCost = ItemCommon.GetAutoBuyItemNeedGold({costItemID:lackCnt}, autoBuyMoneyType)
|
| | | if lackCost <= 0:
|
| | | return
|
| | | infoDict = {ChConfig.Def_Cost_Reason_SonKey:costItemID}
|
| | | if not PlayerControl.PayMoney(curPlayer, autoBuyMoneyType, lackCost, ChConfig.Def_Cost_FaQi, infoDict):
|
| | | if not FunctionNPCCommon.PayAutoBuyItem(curPlayer, {costItemID:lackCnt}, autoBuyMoneyType, ChConfig.Def_Cost_FaQi, infoDict):
|
| | | return
|
| | | delCnt -= lackCnt
|
| | |
|