local Purchase_Controller = {} function Purchase_Controller.GetCostNums(type, buyCount) if type == LuaConst.ActivityType.GuildMine then local dataCount = DataSheetManager.MinePlunderCost:GetDataCount() local purchaseNums = MDL.GuildMine.GetMinePurchaseNum() local maxCost = DataSheetManager.MinePlunderCost:GetDataByID(dataCount) local costNum = 0 for i = purchaseNums + 1, (purchaseNums + buyCount) do local cost = i > dataCount and maxCost or DataSheetManager.MinePlunderCost:GetDataByID(i).MinePlunderCostNum costNum = cost + costNum end return costNum else local payData = DataSheetManager.ActivityData:GetDataByID(type).PayNum local purchaseNums = MDL.Purchase.GetPurchaseNumsByType(type) local maxCost = payData[#payData] local costNum = 0 for i = purchaseNums + 1, (purchaseNums + buyCount) do local cost = i > #payData and maxCost or payData[i] costNum = cost + costNum end return costNum end end function Purchase_Controller.GetPreviewCostNums(type, buyCount) local payData = DataSheetManager.ActivityData:GetDataByID(type).PayNum local maxCost = payData[#payData] local costNum = 0 for i = 1, buyCount do local cost = i > #payData and maxCost or payData[i] costNum = cost + costNum end return costNum end function Purchase_Controller.ClickPurchaseNums(type, buyCount) local payItemId if type == LuaConst.ActivityType.GuildMine then local curPayNum = MDL.GuildMine.GetMinePurchaseNum() payItemId = DataSheetManager.MinePlunderCost:GetDataByID(curPayNum > 0 and curPayNum or 1).MinePlunderCostItem else payItemId = DataSheetManager.ActivityData:GetDataByID(type).PayItem end local hasNums = MDL.Currency.GetMoneyCount(payItemId) local costNums = Purchase_Controller.GetCostNums(type, buyCount) local availablePurchaseNums = MDL.Purchase.GetAvailablePurchaseTimes(type) if availablePurchaseNums > 0 then if hasNums >= costNums then MDL.Purchase.PurchaseNumsReq(type, buyCount) return true else local name = UTL.Item.GetItemDataSpliceByType(payItemId).Name CTL.Tips.AddTipsMsg(Const_IDS["IDS_HeroBiography_NoMoney"], name) end else CTL.Tips.AddTipsMsg(Const_IDS["IDS_HeroBiography_NoPayTime"]) end return false end return Purchase_Controller