From 12ddd56131d5a61232ae3ed1333caeb301d67d26 Mon Sep 17 00:00:00 2001 From: hxp <ale99527@vip.qq.com> Date: 星期二, 02 十一月 2021 19:15:59 +0800 Subject: [PATCH] 9300 【BT5】【主干】【后端】新增:法器进阶(支持自动购买限购物品) --- ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/FunctionNPCCommon.py | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 55 insertions(+), 0 deletions(-) diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/FunctionNPCCommon.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/FunctionNPCCommon.py index a0306f0..8221f83 100644 --- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/FunctionNPCCommon.py +++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/FunctionNPCCommon.py @@ -531,6 +531,61 @@ 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 时间戳 -- Gitblit v1.8.0