Files
Main/Assets/GameAssets/Resources/Lua/Logic/TreasureHunt/TreasureHuntData.lua
2025-01-25 04:38:09 +08:00

115 lines
3.9 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

------------------------------------------------
--作者: dhq
--日期: 2019-07-18
--文件: TreasureHuntData.lua
--模块: TreasureHuntData
--描述: 寻宝的数据类
------------------------------------------------
local TreasureHuntData =
{
ID = nil,
--哪种活动
RewardType = nil,
--活动名字
RewardName = nil,
--单次花费
MoneyCost = nil,
--购买后获得的id_num
Item = nil,
--抽取次数 次数_道具id_数量
Times = nil,
--购买的金币数量 货币类型_num
Gold = nil,
--获得的积分 货币类型_num
Integral = nil,
--具体次数必中type中的一个道具
Frequency = nil,
--奖励字典(id,item)
NormalItemDict = nil,
SpecialItemDict = nil,
ShowModel = nil,
ModelPos = nil,
SpecialItemIdDict = nil,
--免费次数
FreeCount = 0,
--必中剩余消耗次数
LeftCount = 0,
--今日剩余次数
TodayCount = 0,
--每次抽奖上限
AllCount = 0,
--最多只能存放10个数据在机缘寻宝
MAX_DATA_COUNT = 10,
--当前服务器祝福值
CurSreverZhuFuValue = 0,
--最大祝福值
MaxSreverZhuFuValue = 0,
}
function TreasureHuntData:New(_cfg)
local _m = Utils.DeepCopy(self)
_m.NormalItemDict = Dictionary:New()
_m.SpecialItemDict = Dictionary:New()
_m.SpecialItemIdDict = {}
_m:RefeshData(_cfg)
return _m
end
function TreasureHuntData:RefeshData(_cfg)
if _cfg ~= nil then
--物品具体的配置
self.RewardType = tonumber(_cfg.RewardType)
self.RewardName = _cfg.RewardName
self.MoneyCost = _cfg.MoneyCost
self.Item = _cfg.Item
self.FreeCount = _cfg.FreeTimes
self.Times = _cfg.Times
self.Gold = _cfg.Gold
self.Integral = _cfg.Integral
self.Frequency = _cfg.Frequency
self.ShowModel = _cfg.ShowModel
if _cfg.ModelPos ~= nil then
self.ModelPos = Utils.SplitNumber(_cfg.ModelPos, "_")
else
self.ModelPos = {0, 0, 0}
end
self.MaxSreverZhuFuValue = _cfg.LuckLimit
self.AllCount = tonumber(DataConfig.DataGlobal[1586].Params)
local _count = 1
DataConfig.DataTreasureHunt:Foreach(
function(_, _huntCfg)
local _huntType = tonumber(_huntCfg.RewardType)
if _huntType == self.RewardType then
local _id = tonumber(_huntCfg.Id)
local _reward = tostring(_huntCfg.Reward)
local _type = tonumber(_huntCfg.Type)
--普通道具 IsShow字段小于0的就是不能显示的 最多只能放10个数据
if _type == 1 and tonumber(_huntCfg.IsShow) >= 0 then
if _huntType == 1 and _count <= self.MAX_DATA_COUNT then
self.NormalItemDict:Add(_id, _reward)
_count = _count + 1
else
self.NormalItemDict:Add(_id, _reward)
end
else
if _type == 2 then
local _rewardTable = Utils.SplitStrByTableS(_reward, {';', '_'})
for i = 1, #_rewardTable do
self.SpecialItemIdDict[_rewardTable[i][1]] = true
end
--极品道具使用isShow字段作为key
if not self.SpecialItemDict:ContainsKey(_huntCfg.IsShow) then
self.SpecialItemDict:Add(_huntCfg.IsShow, _reward)
end
end
end
end
end
)
--根据IsShow排个序
self.SpecialItemDict:SortKey(function(a, b) return a < b end)
end
end
return TreasureHuntData