123 lines
3.4 KiB
Lua
123 lines
3.4 KiB
Lua
|
||
------------------------------------------------
|
||
--作者: 王圣
|
||
--日期: 2020-08-31
|
||
--文件: WeekCrazySystem.lua
|
||
--模块: WeekCrazySystem
|
||
--描述: 周六狂欢系统
|
||
------------------------------------------------
|
||
--引用
|
||
local TimeUtils = CS.Thousandto.Core.Base.TimeUtils;
|
||
local WeekCrazySystem = {
|
||
--开始时间
|
||
StartTime = 0,
|
||
--结束时间时间
|
||
EndTime = 0,
|
||
--结束时间搓
|
||
RealEndTime = 0,
|
||
--购买数据
|
||
--{Id:商品Id, ListItem:物品列表 , Price: 价格, IsBuy : 是否购买 }
|
||
ListData = List:New()
|
||
}
|
||
|
||
function WeekCrazySystem:Initialize()
|
||
end
|
||
|
||
--获取商品列表
|
||
function WeekCrazySystem:GetDatas()
|
||
local occ = GameCenter.GameSceneSystem:GetLocalPlayer().IntOcc
|
||
if #self.ListData == 0 then
|
||
DataConfig.DataHappyWeek:Foreach(function(k, v)
|
||
local day = v.Day
|
||
if day == 6 then
|
||
local id = v.RechargeID
|
||
local des = v._Des
|
||
local isBuy = false
|
||
local cfg = GameCenter.PaySystem.PayDataIdDict[id]
|
||
local price = GameCenter.PaySystem:GetMoneyCountById(id)
|
||
local itemList = List:New()
|
||
local list = Utils.SplitStr(cfg.ServerCfgData.Reward, ';')
|
||
for i = 1,#list do
|
||
local subList = Utils.SplitNumber(list[i], '_')
|
||
if occ == subList[4] or subList[4] == 9 then
|
||
itemList:Add({Id = subList[1], Num = subList[2], IsBind = subList[3] == 1})
|
||
break
|
||
end
|
||
end
|
||
local data = {Id = id, Des = des, Price = price, IsBuy = isBuy, ListItem = itemList}
|
||
self.ListData:Add(data)
|
||
end
|
||
end)
|
||
end
|
||
return self.ListData
|
||
end
|
||
|
||
--获取商品id
|
||
function WeekCrazySystem:GetId(index)
|
||
local dataList = self:GetDatas()
|
||
if index <= #dataList then
|
||
return dataList[index].Id
|
||
end
|
||
return 0
|
||
end
|
||
|
||
--获取数据
|
||
function WeekCrazySystem:GetData(index)
|
||
local dataList = self:GetDatas()
|
||
if index <= #dataList then
|
||
return dataList[index]
|
||
end
|
||
return nil
|
||
end
|
||
|
||
--获取物品列表
|
||
function WeekCrazySystem:GetGoods(index)
|
||
local data = self:GetData(index)
|
||
if data == nil then
|
||
return nil
|
||
end
|
||
return data.ListItem
|
||
end
|
||
|
||
--获取商品数量
|
||
function WeekCrazySystem:GetCount()
|
||
local dataList = self:GetDatas()
|
||
return #dataList
|
||
end
|
||
|
||
--通过索引获取商品价格
|
||
function WeekCrazySystem:GetPrice(index)
|
||
local data = self:GetData(index)
|
||
if data == nil then
|
||
return 0
|
||
end
|
||
local price = GameCenter.PaySystem:GetMoneyCountById(data.Id)
|
||
return price
|
||
end
|
||
|
||
--获取描述
|
||
function WeekCrazySystem:GetDes(index)
|
||
local data = self:GetData(index)
|
||
if data == nil then
|
||
return nil
|
||
end
|
||
return data.Des
|
||
end
|
||
|
||
--获取剩余时间
|
||
function WeekCrazySystem:GetLeftTime()
|
||
local serveTime = GameCenter.HeartSystem.ServerZoneTime
|
||
local week = TimeUtils.GetStampTimeWeeklyNotZone(math.ceil(serveTime))
|
||
local hour, min, sec = TimeUtils.GetStampTimeHHMMSSNotZone(math.floor(serveTime))
|
||
local curSeconds = hour * 3600 + min * 60 + sec
|
||
if week == 0 then
|
||
week = 7
|
||
end
|
||
local endTime = 6 * 24 * 3600
|
||
local curTime = (week - 1) * 24 * 3600 + curSeconds
|
||
self.RealEndTime = endTime - curTime
|
||
return self.RealEndTime
|
||
end
|
||
|
||
return WeekCrazySystem
|