|
|
|
|
@ -12,9 +12,9 @@ this._CountDownTimer = nil
|
|
|
|
|
this._IsRefresh = 0
|
|
|
|
|
this._RefreshShopList = {}
|
|
|
|
|
|
|
|
|
|
this.selectIndex = {shopType = 0,storeId = {}} --跳转到哪个位置
|
|
|
|
|
this.selectIndex2 = {shopType = 0,storeId = {}} --哪个位置需要显示特效
|
|
|
|
|
function this.SetSelectIndex(shopType,storeId,b)
|
|
|
|
|
this.selectIndex = { shopType = 0, storeId = {} } --跳转到哪个位置
|
|
|
|
|
this.selectIndex2 = { shopType = 0, storeId = {} } --哪个位置需要显示特效
|
|
|
|
|
function this.SetSelectIndex(shopType, storeId, b)
|
|
|
|
|
this.selectIndex.shopType = shopType
|
|
|
|
|
this.selectIndex.storeId = storeId
|
|
|
|
|
if b and b == 1 then
|
|
|
|
|
@ -32,7 +32,7 @@ function this.Initialize()
|
|
|
|
|
this._CountDownTimer = Timer.New(this.TimeUpdate, 1, -1, true)
|
|
|
|
|
this._CountDownTimer:Start()
|
|
|
|
|
end
|
|
|
|
|
this.isOpenNoviceGift=false --默认第一次登陆未打开
|
|
|
|
|
this.isOpenNoviceGift = false --默认第一次登陆未打开
|
|
|
|
|
|
|
|
|
|
-- 公会数据改变刷新公会商店排序
|
|
|
|
|
Game.GlobalEvent:AddEvent(GameEvent.Guild.DataUpdate, function()
|
|
|
|
|
@ -55,7 +55,6 @@ function this.InitData(func)
|
|
|
|
|
this.RequestAllShopData(func)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--- 重新获取商店数据
|
|
|
|
|
function this.RequestAllShopData(func)
|
|
|
|
|
Log("重新获取商店数据")
|
|
|
|
|
@ -71,7 +70,7 @@ function this.ReceiveShopData(msg)
|
|
|
|
|
for _, data in ipairs(msg.storeInfo) do
|
|
|
|
|
local storeInfo = ConfigManager.TryGetConfigData(ConfigName.StoreTypeConfig, data.id)
|
|
|
|
|
if not storeInfo then
|
|
|
|
|
LogError("StoreTypeConfig not find Id:"..data.id)
|
|
|
|
|
LogError("StoreTypeConfig not find Id:" .. data.id)
|
|
|
|
|
else
|
|
|
|
|
table.insert(this.allShopData, data)
|
|
|
|
|
end
|
|
|
|
|
@ -108,12 +107,12 @@ function this.UpdateShopData(msg)
|
|
|
|
|
-- end
|
|
|
|
|
-- end
|
|
|
|
|
--else
|
|
|
|
|
for index, olddata in ipairs(this.allShopData) do
|
|
|
|
|
if olddata.id == newdata.id then
|
|
|
|
|
_index = index
|
|
|
|
|
break
|
|
|
|
|
end
|
|
|
|
|
for index, olddata in ipairs(this.allShopData) do
|
|
|
|
|
if olddata.id == newdata.id then
|
|
|
|
|
_index = index
|
|
|
|
|
break
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
--end
|
|
|
|
|
|
|
|
|
|
if _index then
|
|
|
|
|
@ -121,7 +120,7 @@ function this.UpdateShopData(msg)
|
|
|
|
|
else
|
|
|
|
|
local storeInfo = ConfigManager.TryGetConfigData(ConfigName.StoreTypeConfig, newdata.id)
|
|
|
|
|
if not storeInfo then
|
|
|
|
|
LogError("StoreTypeConfig not find Id:"..newdata.id)
|
|
|
|
|
LogError("StoreTypeConfig not find Id:" .. newdata.id)
|
|
|
|
|
else
|
|
|
|
|
table.insert(this.allShopData, newdata)
|
|
|
|
|
end
|
|
|
|
|
@ -139,14 +138,10 @@ function this.UpdateShopData(msg)
|
|
|
|
|
this.CheckShopRefreshTime()
|
|
|
|
|
-- 更新事件
|
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.Shop.OnShopInfoChange)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--- 请求购买物品 isShowReward 没有弹恭喜获得 ,有 == 0 不弹
|
|
|
|
|
function this.RequestBuyShopItem(shopType, shopItemId, num, func,isShowReward)
|
|
|
|
|
function this.RequestBuyShopItem(shopType, shopItemId, num, func, isShowReward)
|
|
|
|
|
if not shopType or not shopItemId or not num then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
@ -194,10 +189,10 @@ function this.RequestBuyShopItem(shopType, shopItemId, num, func,isShowReward)
|
|
|
|
|
NetManager.RequestBuyShopItem(shopId, shopItemId, num, function(msg)
|
|
|
|
|
-- 显示掉落
|
|
|
|
|
if msg.drop.itemlist and #msg.drop.itemlist > 0 or
|
|
|
|
|
msg.drop.equipId and #msg.drop.equipId > 0 or
|
|
|
|
|
msg.drop.Hero and #msg.drop.Hero > 0 or
|
|
|
|
|
msg.drop.soulEquip and #msg.drop.soulEquip > 0 or
|
|
|
|
|
msg.drop.pokemon ~= nil and #msg.drop.pokemon > 0 --msg.drop.especialEquipId and #msg.drop.especialEquipId > 0
|
|
|
|
|
msg.drop.equipId and #msg.drop.equipId > 0 or
|
|
|
|
|
msg.drop.Hero and #msg.drop.Hero > 0 or
|
|
|
|
|
msg.drop.soulEquip and #msg.drop.soulEquip > 0 or
|
|
|
|
|
msg.drop.pokemon ~= nil and #msg.drop.pokemon > 0 --msg.drop.especialEquipId and #msg.drop.especialEquipId > 0
|
|
|
|
|
then
|
|
|
|
|
if isShowReward and isShowReward == 0 then
|
|
|
|
|
else
|
|
|
|
|
@ -225,27 +220,25 @@ function this.RequestBuyShopItem(shopType, shopItemId, num, func,isShowReward)
|
|
|
|
|
this.SortItemList(shopType)
|
|
|
|
|
|
|
|
|
|
-- 更新事件
|
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.Shop.OnShopInfoChange,false,false,false)
|
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.Shop.OnShopInfoChange, false, false, false)
|
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.Bag.BagGold)
|
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.Adventure.OnRefreshNextDayData)
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- 通过商店ID购买商品
|
|
|
|
|
function this.RequestBuyItemByShopId(shopId, shopItemId, num, func)
|
|
|
|
|
if not shopId or not shopItemId or not num then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NetManager.RequestBuyShopItem(shopId, shopItemId, num, function(msg)
|
|
|
|
|
-- 显示掉落
|
|
|
|
|
if msg.drop.itemlist and #msg.drop.itemlist > 0 or
|
|
|
|
|
msg.drop.equipId and #msg.drop.equipId > 0 or
|
|
|
|
|
msg.drop.Hero and #msg.drop.Hero > 0 or
|
|
|
|
|
msg.drop.soulEquip and #msg.drop.soulEquip > 0-- or
|
|
|
|
|
-- msg.drop.especialEquipId and #msg.drop.especialEquipId > 0
|
|
|
|
|
msg.drop.equipId and #msg.drop.equipId > 0 or
|
|
|
|
|
msg.drop.Hero and #msg.drop.Hero > 0 or
|
|
|
|
|
msg.drop.soulEquip and #msg.drop.soulEquip > 0 -- or
|
|
|
|
|
-- msg.drop.especialEquipId and #msg.drop.especialEquipId > 0
|
|
|
|
|
then
|
|
|
|
|
UIManager.OpenPanel(UIName.RewardItemPopup, msg.drop, 1)
|
|
|
|
|
end
|
|
|
|
|
@ -273,7 +266,6 @@ function this.RequestBuyItemByShopId(shopId, shopItemId, num, func)
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- 请求刷新商店数据
|
|
|
|
|
function this.RequestRefreshShop(shopType, isAuto, func)
|
|
|
|
|
if not shopType or isAuto == nil then
|
|
|
|
|
@ -363,6 +355,7 @@ function ShopManager.GetMainShopPageList()
|
|
|
|
|
end)
|
|
|
|
|
return _MainShopPages
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--- 获取商店主界面单个页签要显示的所有商店
|
|
|
|
|
function ShopManager.GetMainPageShopTypeList(page)
|
|
|
|
|
-- 去重
|
|
|
|
|
@ -389,11 +382,10 @@ end
|
|
|
|
|
function ShopManager.GetShopPageByShopType(shopType)
|
|
|
|
|
-- 去重
|
|
|
|
|
local shopTypeData = ConfigManager.GetConfigDataByKey(ConfigName.StoreTypeConfig, "StoreType", shopType)
|
|
|
|
|
assert(shopTypeData, Language[12860]..shopType)
|
|
|
|
|
assert(shopTypeData, Language[12860] .. shopType)
|
|
|
|
|
return shopTypeData.Pages
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- 刷新商店物品列表排序
|
|
|
|
|
function this.SortItemList(shopType)
|
|
|
|
|
-- 试炼副本商店不按sort字段排序
|
|
|
|
|
@ -403,7 +395,7 @@ function this.SortItemList(shopType)
|
|
|
|
|
for _, v in ipairs(this.allShopData) do
|
|
|
|
|
local storeInfo = ConfigManager.TryGetConfigData(ConfigName.StoreTypeConfig, v.id)
|
|
|
|
|
if not storeInfo then
|
|
|
|
|
LogError("StoreTypeConfig not find Id:"..v.id)
|
|
|
|
|
LogError("StoreTypeConfig not find Id:" .. v.id)
|
|
|
|
|
else
|
|
|
|
|
-- shopType不存在时全部刷新,否则按shoptype刷新
|
|
|
|
|
if not shopType or storeInfo.StoreType == shopType then
|
|
|
|
|
@ -431,7 +423,7 @@ function this.SortItemList(shopType)
|
|
|
|
|
-- 按sort排序
|
|
|
|
|
return aInfo.Sort < bInfo.Sort
|
|
|
|
|
end)
|
|
|
|
|
else--是试炼商店
|
|
|
|
|
else --是试炼商店
|
|
|
|
|
table.sort(v.storeItem, function(a, b)
|
|
|
|
|
local aId = a.id % _StoreItemIdFilter
|
|
|
|
|
local bId = b.id % _StoreItemIdFilter
|
|
|
|
|
@ -466,12 +458,13 @@ function this.GetShopDataByType(shopType)
|
|
|
|
|
--LogError("shopData len================="..#shopData)
|
|
|
|
|
return shopData
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 通过商店type获取商店数据
|
|
|
|
|
function this.GetShopDataByTypeAndFuncType(shopType,fType)
|
|
|
|
|
function this.GetShopDataByTypeAndFuncType(shopType, fType)
|
|
|
|
|
local shopData = nil
|
|
|
|
|
for _, v in ipairs(this.allShopData) do
|
|
|
|
|
local shopInfo = this.GetShopInfo(v.id)
|
|
|
|
|
if shopInfo and shopInfo.StoreType == shopType and shopInfo.FunctionType ==fType then
|
|
|
|
|
if shopInfo and shopInfo.StoreType == shopType and shopInfo.FunctionType == fType then
|
|
|
|
|
shopData = v
|
|
|
|
|
break
|
|
|
|
|
end
|
|
|
|
|
@ -479,6 +472,7 @@ function this.GetShopDataByTypeAndFuncType(shopType,fType)
|
|
|
|
|
--assert(shopData, "未找到商店数据,请检查数据表及后端数据,商店类型 == "..shopType)
|
|
|
|
|
return shopData
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 通过商店id获取商店数据
|
|
|
|
|
function this.GetShopDataByShopId(shopId)
|
|
|
|
|
local shopData = nil
|
|
|
|
|
@ -504,8 +498,6 @@ function this.GetAllShopDataByShopType(shopType)
|
|
|
|
|
return list
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- 通过商店id获取商店静态表数据
|
|
|
|
|
function this.GetShopInfo(shopId)
|
|
|
|
|
return ConfigManager.GetConfigData(ConfigName.StoreTypeConfig, shopId)
|
|
|
|
|
@ -519,11 +511,11 @@ function this.GetShopInfoByType(shopType)
|
|
|
|
|
return ConfigManager.GetConfigDataByKey(ConfigName.StoreTypeConfig, "StoreType", shopType)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- 获取商品信息
|
|
|
|
|
function this.GetShopItemInfo(id)
|
|
|
|
|
return ConfigManager.GetConfigData(ConfigName.StoreConfig, id % _StoreItemIdFilter)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 获取商品中包含的物品(物品数量要判断是否有玩家等级和vip等级加成)
|
|
|
|
|
function ShopManager.GetShopItemGoodsInfo(id)
|
|
|
|
|
local shopItemInfo = this.GetShopItemInfo(id)
|
|
|
|
|
@ -535,8 +527,9 @@ function ShopManager.GetShopItemGoodsInfo(id)
|
|
|
|
|
for _, exAdd in ipairs(shopItemInfo.ExtraAdd) do
|
|
|
|
|
local exType, exValue = exAdd[1], exAdd[2]
|
|
|
|
|
if exType == 1 then
|
|
|
|
|
local playerLevelExAdd = ConfigManager.GetConfigData(ConfigName.PlayerLevelConfig, PlayerManager.level).ExtraAdd
|
|
|
|
|
addValue = addValue + (playerLevelExAdd/10000)
|
|
|
|
|
local playerLevelExAdd = ConfigManager.GetConfigData(ConfigName.PlayerLevelConfig, PlayerManager.level)
|
|
|
|
|
.ExtraAdd
|
|
|
|
|
addValue = addValue + (playerLevelExAdd / 10000)
|
|
|
|
|
elseif exType == 2 then
|
|
|
|
|
vipAdd = PrivilegeManager.GetPrivilegeNumber(exValue)
|
|
|
|
|
addValue = addValue + vipAdd
|
|
|
|
|
@ -547,7 +540,7 @@ function ShopManager.GetShopItemGoodsInfo(id)
|
|
|
|
|
local id = g[1]
|
|
|
|
|
local num = g[2]
|
|
|
|
|
num = num * (1 + addValue)
|
|
|
|
|
table.insert(goods, {id, num})
|
|
|
|
|
table.insert(goods, { id, num })
|
|
|
|
|
end
|
|
|
|
|
return goods, addValue, vipAdd
|
|
|
|
|
end
|
|
|
|
|
@ -564,7 +557,7 @@ function this.GetShopItemData(shopType, itemId)
|
|
|
|
|
itemData = v
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
assert(itemData, Language[12861]..itemId)
|
|
|
|
|
assert(itemData, Language[12861] .. itemId)
|
|
|
|
|
return itemData
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@ -583,12 +576,13 @@ function this.IsPageActive(page)
|
|
|
|
|
end
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 判断商店是否是激活状态
|
|
|
|
|
function ShopManager.IsActive(shopType)
|
|
|
|
|
-- 获取数据
|
|
|
|
|
local shopData = this.GetShopDataByType(shopType)
|
|
|
|
|
if not shopData then
|
|
|
|
|
return false
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
-- 判断类型
|
|
|
|
|
local shopInfo = this.GetShopInfo(shopData.id)
|
|
|
|
|
@ -639,13 +633,13 @@ function ShopManager.IsActive(shopType)
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 获取最大刷新次数
|
|
|
|
|
-- -2 不支持手动刷新
|
|
|
|
|
-- 获取最大刷新次数
|
|
|
|
|
-- -2 不支持手动刷新
|
|
|
|
|
-- -1 无限制次数
|
|
|
|
|
function this.GetMaxRefreshCount(shopType)
|
|
|
|
|
-- 判断是否开启手动刷新
|
|
|
|
|
local shopInfo = this.GetShopInfoByType(shopType)
|
|
|
|
|
if shopInfo.IfManualRefresh[1] ~= 0 then -- 自动恢复次数的刷新类型
|
|
|
|
|
if shopInfo.IfManualRefresh[1] ~= 0 then -- 自动恢复次数的刷新类型
|
|
|
|
|
return shopInfo.IfManualRefresh[1]
|
|
|
|
|
elseif shopInfo.IfManualRefresh[1] == 0 and shopInfo.IfManualRefresh[2] == 0 then
|
|
|
|
|
return -2
|
|
|
|
|
@ -662,12 +656,11 @@ end
|
|
|
|
|
|
|
|
|
|
-- 获取商店剩余刷新次数 -2 不支持手动刷新 -1 无限制次数
|
|
|
|
|
function this.GetShopLeftRefreshCount(shopType)
|
|
|
|
|
|
|
|
|
|
local isAutoRecover, leftCount = this.IsAutoRecoverCount(shopType)
|
|
|
|
|
if isAutoRecover then
|
|
|
|
|
return leftCount
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- 获取最大刷新次数
|
|
|
|
|
local maxRefreshCount = this.GetMaxRefreshCount(shopType)
|
|
|
|
|
if maxRefreshCount < 0 then
|
|
|
|
|
@ -683,7 +676,7 @@ end
|
|
|
|
|
function this.IsAutoRecoverCount(shopType)
|
|
|
|
|
-- 判断是否是自动恢复免费次数的类型
|
|
|
|
|
local shopInfo = this.GetShopInfoByType(shopType)
|
|
|
|
|
if shopInfo.IfManualRefresh[1] == 0 then -- 自动恢复次数的刷新类型
|
|
|
|
|
if shopInfo.IfManualRefresh[1] == 0 then -- 自动恢复次数的刷新类型
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
-- 计算剩余免费次数
|
|
|
|
|
@ -692,14 +685,14 @@ function this.IsAutoRecoverCount(shopType)
|
|
|
|
|
local curTimeStamp = GetTimeStamp()
|
|
|
|
|
local shopData = this.GetShopDataByType(shopType)
|
|
|
|
|
local lastRefreshTime = math.floor(shopData.lastRefreshTime / 1000)
|
|
|
|
|
local leftCount = math.min(maxTime, math.floor(math.ceil(curTimeStamp - lastRefreshTime)/refreshTime))
|
|
|
|
|
local leftCount = math.min(maxTime, math.floor(math.ceil(curTimeStamp - lastRefreshTime) / refreshTime))
|
|
|
|
|
|
|
|
|
|
-- 如果没有免费次数了,但是有特权刷新次数
|
|
|
|
|
if leftCount <= 0 and shopInfo.RefreshPrivilege ~= 0 then
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
|
return true, leftCount
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@ -761,11 +754,11 @@ function this.CountShopRefreshLeftTime(shopId)
|
|
|
|
|
--local shopData = this.GetShopDataByType(shopType)
|
|
|
|
|
if #shopInfo.RefreshType == 0 or shopInfo.RefreshType[1] == 1 then
|
|
|
|
|
return -1
|
|
|
|
|
--- 固定时间点刷新
|
|
|
|
|
--- 固定时间点刷新
|
|
|
|
|
elseif shopInfo.RefreshType[1] == 2 then
|
|
|
|
|
local shopData = this.GetShopDataByType(shopType)
|
|
|
|
|
local lastRefreshTime = shopData.lastRefreshTime / 1000
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local N_TimeStamp = Today_N_OClockTimeStamp(shopInfo.RefreshType[2])
|
|
|
|
|
-- 距离上次刷新时间大于一天
|
|
|
|
|
if N_TimeStamp - lastRefreshTime > 86400 then
|
|
|
|
|
@ -794,26 +787,25 @@ function this.CountShopRefreshLeftTime(shopId)
|
|
|
|
|
-- 计算剩余时间
|
|
|
|
|
-- local lastTime = N_TimeStamp - curTimeStamp
|
|
|
|
|
-- return lastTime < 0 and 0 or lastTime
|
|
|
|
|
--- 按时间长度刷新
|
|
|
|
|
--- 按时间长度刷新
|
|
|
|
|
elseif shopInfo.RefreshType[1] == 3 then
|
|
|
|
|
local shopData = this.GetShopDataByType(shopType)
|
|
|
|
|
local shopData = this.GetShopDataByType(shopType)
|
|
|
|
|
if shopType == SHOP_TYPE.GUILD_SHOP or shopType == SHOP_TYPE.QIJIE_SHOP then
|
|
|
|
|
local lastRefreshTime = shopData.lastRefreshTime / 1000
|
|
|
|
|
local deltaSeconds = shopInfo.RefreshType[2] * 60 * 60
|
|
|
|
|
local lastTime = lastRefreshTime + deltaSeconds - GetTimeStamp()
|
|
|
|
|
return lastTime < 0 and 0 or lastTime
|
|
|
|
|
else
|
|
|
|
|
return shopData.endTime/1000 - GetTimeStamp()
|
|
|
|
|
return shopData.endTime / 1000 - GetTimeStamp()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--- 获取刷新剩余时间
|
|
|
|
|
function this.GetShopRefreshLeftTime(shopType)
|
|
|
|
|
return this._RefreshShopList[shopType] or -1
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- 获取商店剩余多少时间关闭 -1表示未开启/已关闭
|
|
|
|
|
function this.GetShopCloseTime(shopType)
|
|
|
|
|
-- 常驻商店没有关闭时间
|
|
|
|
|
@ -840,7 +832,7 @@ end
|
|
|
|
|
-- 获取商店自动恢复次数的刷新时间
|
|
|
|
|
function this.GetShopRefreshCountRecoverTime(shopType)
|
|
|
|
|
local shopInfo = this.GetShopInfoByType(shopType)
|
|
|
|
|
if shopInfo.IfManualRefresh[1] == 0 then -- 自动恢复次数的刷新类型
|
|
|
|
|
if shopInfo.IfManualRefresh[1] == 0 then -- 自动恢复次数的刷新类型
|
|
|
|
|
return -1
|
|
|
|
|
end
|
|
|
|
|
local maxTime = shopInfo.IfManualRefresh[1]
|
|
|
|
|
@ -848,8 +840,8 @@ function this.GetShopRefreshCountRecoverTime(shopType)
|
|
|
|
|
local curTimeStamp = GetTimeStamp()
|
|
|
|
|
local shopData = this.GetShopDataByType(shopType)
|
|
|
|
|
local lastRefreshTime = shopData.lastRefreshTime / 1000
|
|
|
|
|
local leftCount = math.min(maxTime, math.floor((curTimeStamp - lastRefreshTime)/refreshTime))
|
|
|
|
|
if leftCount == maxTime then
|
|
|
|
|
local leftCount = math.min(maxTime, math.floor((curTimeStamp - lastRefreshTime) / refreshTime))
|
|
|
|
|
if leftCount == maxTime then
|
|
|
|
|
return 0
|
|
|
|
|
end
|
|
|
|
|
-- 计算剩余时间
|
|
|
|
|
@ -857,7 +849,6 @@ function this.GetShopRefreshCountRecoverTime(shopType)
|
|
|
|
|
return refreshTime
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- 获取商品限制购买数量(返回-1 表示不限购)
|
|
|
|
|
function this.GetShopItemLimitBuyCount(itemId)
|
|
|
|
|
local itemInfo = this.GetShopItemInfo(itemId)
|
|
|
|
|
@ -894,7 +885,6 @@ function this.GetShopItemRemainBuyTimes(shopType, itemId)
|
|
|
|
|
if this.GetShopItemLimitBuyCount(itemId) == -1 then
|
|
|
|
|
return -1
|
|
|
|
|
else
|
|
|
|
|
|
|
|
|
|
return this.GetShopItemLimitBuyCount(itemId) - this.GetShopItemHadBuyTimes(shopType, itemId)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
@ -922,7 +912,7 @@ function this.GetShopItemMaxBuy(shopType, itemId)
|
|
|
|
|
local oriCostNum = 0
|
|
|
|
|
if itemInfo.PremiumType == 1 then
|
|
|
|
|
-- 用公式计算
|
|
|
|
|
local abcd = itemInfo.Cost[2]-- 公式常数
|
|
|
|
|
local abcd = itemInfo.Cost[2] -- 公式常数
|
|
|
|
|
for i = 0, 999 do
|
|
|
|
|
oriCostNum = math.floor(oriCostNum + CalculateCostCount(startNum + i, abcd))
|
|
|
|
|
local finalNum = math.floor(oriCostNum * discount)
|
|
|
|
|
@ -932,7 +922,7 @@ function this.GetShopItemMaxBuy(shopType, itemId)
|
|
|
|
|
end
|
|
|
|
|
elseif itemInfo.PremiumType == 2 then
|
|
|
|
|
-- 数组数量相加
|
|
|
|
|
local ary = itemInfo.Cost[2]-- 组数
|
|
|
|
|
local ary = itemInfo.Cost[2] -- 组数
|
|
|
|
|
for i = 1, 999 do
|
|
|
|
|
local addValue = ary[startNum + i] or ary[#ary]
|
|
|
|
|
oriCostNum = math.floor(oriCostNum + addValue)
|
|
|
|
|
@ -951,6 +941,7 @@ function this.calculateBuyCost(shopType, itemId, count)
|
|
|
|
|
local shopData = this.GetShopDataByType(shopType)
|
|
|
|
|
return this.CalculateCostCountByShopId(shopData.id, itemId, count)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this.CalculateCostCountByShopId(shopId, itemId, count)
|
|
|
|
|
local shopData = this.GetShopDataByShopId(shopId)
|
|
|
|
|
local startNum = nil
|
|
|
|
|
@ -971,13 +962,13 @@ function this.CalculateCostCountByShopId(shopId, itemId, count)
|
|
|
|
|
local oriCostNum = 0
|
|
|
|
|
if itemInfo.PremiumType == 1 then
|
|
|
|
|
-- 用公式计算
|
|
|
|
|
local abcd = itemInfo.Cost[2]-- 公式常数
|
|
|
|
|
local abcd = itemInfo.Cost[2] -- 公式常数
|
|
|
|
|
for i = 0, count - 1 do
|
|
|
|
|
oriCostNum = oriCostNum + CalculateCostCount(startNum + i, abcd)
|
|
|
|
|
end
|
|
|
|
|
elseif itemInfo.PremiumType == 2 then
|
|
|
|
|
-- 数组数量相加
|
|
|
|
|
local ary = itemInfo.Cost[2]-- 组数
|
|
|
|
|
local ary = itemInfo.Cost[2] -- 组数
|
|
|
|
|
for i = 1, count do
|
|
|
|
|
local addValue = ary[startNum + i] or ary[#ary]
|
|
|
|
|
oriCostNum = oriCostNum + addValue
|
|
|
|
|
@ -986,7 +977,7 @@ function this.CalculateCostCountByShopId(shopId, itemId, count)
|
|
|
|
|
-- 判断是否打折
|
|
|
|
|
local discount = itemInfo.IsDiscount == 1 and itemInfo.DiscountDegree * 0.1 or 1
|
|
|
|
|
local finalNum = oriCostNum * discount
|
|
|
|
|
return costId,finalNum, oriCostNum
|
|
|
|
|
return costId, finalNum, oriCostNum
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 外部增加商品购买次数,别瞎用
|
|
|
|
|
@ -1064,7 +1055,7 @@ function this.ShopCheckRPIsShow(shopType)
|
|
|
|
|
if _LastCheckTime and _LastCheckTime ~= 0 then
|
|
|
|
|
-- 商店查看时间小于刷新时间,显示红点
|
|
|
|
|
--Log("商店红点检测: 上次查看时间 = ".._LastCheckTime..", 商店刷新时间 = "..shopData.lastRefreshTime/1000)
|
|
|
|
|
if _LastCheckTime < shopData.lastRefreshTime/1000 then
|
|
|
|
|
if _LastCheckTime < shopData.lastRefreshTime / 1000 then
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
@ -1104,24 +1095,18 @@ function this.ShopRefreshRPIsShow(shopType)
|
|
|
|
|
-- return leftRefreshCount > 0
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- 向红点注册的检测方法
|
|
|
|
|
function this.ShopRedCheck(redType)
|
|
|
|
|
if redType == RedPointType.Guild_Shop or redType == RedPointType.Shop_Guild_Check then
|
|
|
|
|
return this.ShopCheckRPIsShow(SHOP_TYPE.GUILD_SHOP)
|
|
|
|
|
|
|
|
|
|
elseif redType == RedPointType.Arena_Shop or redType == RedPointType.Shop_Arena_Check then
|
|
|
|
|
return this.ShopCheckRPIsShow(SHOP_TYPE.ARENA_SHOP)
|
|
|
|
|
|
|
|
|
|
elseif redType == RedPointType.Shop_Roam_Check then
|
|
|
|
|
return this.ShopCheckRPIsShow(SHOP_TYPE.ROAM_SHOP)
|
|
|
|
|
|
|
|
|
|
elseif redType == RedPointType.Shop_Secret_Check then
|
|
|
|
|
return this.ShopCheckRPIsShow(SHOP_TYPE.SECRET_BOX_SHOP)
|
|
|
|
|
|
|
|
|
|
elseif redType == RedPointType.Shop_General_Check then
|
|
|
|
|
return this.ShopCheckRPIsShow(SHOP_TYPE.GENERAL_SHOP)
|
|
|
|
|
|
|
|
|
|
elseif redType == RedPointType.Shop_General_Refresh then
|
|
|
|
|
return this.ShopRefreshRPIsShow(SHOP_TYPE.GENERAL_SHOP)
|
|
|
|
|
elseif redType == RedPointType.Shop_Soul_Refresh then
|
|
|
|
|
@ -1155,13 +1140,11 @@ function this.CheckShopRedpot(shopType)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- 从本地加载红点数据
|
|
|
|
|
function this.LoadRedpotDataFromLocal()
|
|
|
|
|
-- 检测所有商店
|
|
|
|
|
for _, type in pairs(SHOP_TYPE) do
|
|
|
|
|
_ShopCheckTime[type] = PlayerPrefs.GetInt(PlayerManager.uid.."_ShopRedPot_"..type)
|
|
|
|
|
_ShopCheckTime[type] = PlayerPrefs.GetInt(PlayerManager.uid .. "_ShopRedPot_" .. type)
|
|
|
|
|
-- _RefreshBtnIsClick[type] = PlayerPrefs.GetInt(PlayerManager.uid.."_ShopBtnStatus_"..type) == 1
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
@ -1172,7 +1155,7 @@ function this.RefreshShopCheckTime(shopType)
|
|
|
|
|
|
|
|
|
|
-- 保存查看的时间戳
|
|
|
|
|
local curTimeStamp = GetTimeStamp()
|
|
|
|
|
PlayerPrefs.SetInt(PlayerManager.uid.."_ShopRedPot_"..shopType, curTimeStamp)
|
|
|
|
|
PlayerPrefs.SetInt(PlayerManager.uid .. "_ShopRedPot_" .. shopType, curTimeStamp)
|
|
|
|
|
_ShopCheckTime[shopType] = curTimeStamp
|
|
|
|
|
|
|
|
|
|
this.CheckShopRedpot(shopType)
|
|
|
|
|
@ -1203,12 +1186,75 @@ function this.CheckGoldIsFree()
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 检查是否有免费的可购买的商品
|
|
|
|
|
function this.CheckRedPointJiaozhufabao()
|
|
|
|
|
local isCanBuy = 1
|
|
|
|
|
local actConfig = ConfigManager.GetConfigDataByKey(ConfigName.ActivityGroups, "Id", ActivityTypeDef.Jiaozhufabao)
|
|
|
|
|
if actConfig then
|
|
|
|
|
--LogError("cccccccccccccccccccccccccccccccccccccccccccccccccccc")
|
|
|
|
|
local shopData = DynamicActivityManager.GetGiftDataByType(actConfig.ShopData)
|
|
|
|
|
if shopData then
|
|
|
|
|
for i = 1, #shopData do
|
|
|
|
|
if shopData[i].data.limitNum == 0 then
|
|
|
|
|
isCanBuy = 0
|
|
|
|
|
else
|
|
|
|
|
isCanBuy = (shopData[i].data.limitNum - shopData[i].data.boughtNum > 0) and 0 or 2
|
|
|
|
|
if shopData[i].data.linkAct then
|
|
|
|
|
isCanBuy = shopData[i].data.state == 0 and 0 or 2
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if (shopData[i].data.finalNum == 0 or shopData[i].data.linkAct) and isCanBuy == 0 then
|
|
|
|
|
--LogError("cccccccccccccccccccccccccccccccccccccccccccccccccccc")
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return this.CheckRedPointMeiRiTeHui()
|
|
|
|
|
else
|
|
|
|
|
return this.CheckRedPointMeiRiTeHui()
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
--LogError("cccccccccccccccccccccccccccccccccccccccccccccccccccc")
|
|
|
|
|
return this.CheckRedPointMeiRiTeHui()
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this.CheckRedPointMeiRiTeHui()
|
|
|
|
|
local isCanBuy = 1
|
|
|
|
|
local actConfig = ConfigManager.GetConfigDataByKey(ConfigName.ActivityGroups, "Id", ActivityTypeDef.MeiRiTeHui)
|
|
|
|
|
if actConfig then
|
|
|
|
|
--LogError("cccccccccccccccccccccccccccccccccccccccccccccccccccc")
|
|
|
|
|
local shopData = DynamicActivityManager.GetGiftDataByType(actConfig.ShopData)
|
|
|
|
|
if shopData then
|
|
|
|
|
for i = 1, #shopData do
|
|
|
|
|
if shopData[i].data.limitNum == 0 then
|
|
|
|
|
isCanBuy = 0
|
|
|
|
|
else
|
|
|
|
|
isCanBuy = (shopData[i].data.limitNum - shopData[i].data.boughtNum > 0) and 0 or 2
|
|
|
|
|
if shopData[i].data.linkAct then
|
|
|
|
|
isCanBuy = shopData[i].data.state == 0 and 0 or 2
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if (shopData[i].data.finalNum == 0 or shopData[i].data.linkAct) and isCanBuy == 0 then
|
|
|
|
|
--LogError("cccccccccccccccccccccccccccccccccccccccccccccccccccc")
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return false
|
|
|
|
|
else
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
--LogError("cccccccccccccccccccccccccccccccccccccccccccccccccccc")
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 检查是否有免费的可购买的商品
|
|
|
|
|
function this.HaveFreeBaby()
|
|
|
|
|
local haveFree = false
|
|
|
|
|
--新手礼包开启时 每天第一次登陆打开显示红点
|
|
|
|
|
if this.IsActive(SHOP_TYPE.NOVICE_GIFT_SHOP ) and this.CheckNoviceGiftData() then
|
|
|
|
|
if PatFaceManager.isFirstLog==0 and this.isOpenNoviceGift==false then
|
|
|
|
|
if this.IsActive(SHOP_TYPE.NOVICE_GIFT_SHOP) and this.CheckNoviceGiftData() then
|
|
|
|
|
if PatFaceManager.isFirstLog == 0 and this.isOpenNoviceGift == false then
|
|
|
|
|
haveFree = true
|
|
|
|
|
else
|
|
|
|
|
haveFree = false
|
|
|
|
|
@ -1244,27 +1290,25 @@ end
|
|
|
|
|
--检查是否有未购买的新手礼包
|
|
|
|
|
function this.CheckNoviceGiftData()
|
|
|
|
|
for i, v in ipairs(ShopManager.GetShopDataByType(SHOP_TYPE.NOVICE_GIFT_SHOP).storeItem) do
|
|
|
|
|
if v.buyNum==0 then
|
|
|
|
|
if v.buyNum == 0 then
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- 检测商店物品
|
|
|
|
|
function this.CheckShopItemList(list)
|
|
|
|
|
local itemList = {}
|
|
|
|
|
for _, item in ipairs(list) do
|
|
|
|
|
local info = this.GetShopItemInfo(item.id)
|
|
|
|
|
if info.OpenLv and
|
|
|
|
|
info.OpenLv[1] and info.OpenLv[1] <= PlayerManager.level then
|
|
|
|
|
-- info.OpenLv[2] and info.OpenLv[2] >= PlayerManager.level then
|
|
|
|
|
table.insert(itemList, item)
|
|
|
|
|
info.OpenLv[1] and info.OpenLv[1] <= PlayerManager.level then
|
|
|
|
|
-- info.OpenLv[2] and info.OpenLv[2] >= PlayerManager.level then
|
|
|
|
|
table.insert(itemList, item)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return itemList
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return this
|
|
|
|
|
return this
|
|
|
|
|
|