源战役客户端
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 

514 rindas
16 KiB

SupremeVipModel = SupremeVipModel or BaseClass(BaseVo, true)
local SupremeVipModel = SupremeVipModel
function SupremeVipModel:__init()
SupremeVipModel.Instance = self
self:Reset()
end
function SupremeVipModel:Reset()
self.sup_vip_type = 0 --是否是永久贵族 0|否 1|体验 2|永久
self.end_time = 0 --体验贵族结束时间戳
self.today_charge = 0 --今日充值
self.continue_day = 0 --体验贵族连续充值天数
self.now_day = 0 --体验贵族当前天数
self.gift_count = 0 --每日礼包领取次数
self.unlock_id = 0 --当前解锁序列
self.star_gold = 0 --今日星钻
self.shop_cfg = {} --排好序的星钻商城配置列表
self.shop_limit_data = {} --商城物品的限购信息
self.shop_limit_data_dic = {} --存一份以限购类型为键的表
self.exchange_rest_count_list = {} --剩余的兑换次数列表
self.is_first_open_train_drug = true --是否第一次打开培养丹兑换界面,第一次打开之后就要清掉红点
self.is_first_open_shop = true --是否第一次打开商城界面
self.supreme_vip_red_dot_info = {} --红点数据
-- self.login_red = true
self.daily_reward_day_state_list = {} --每日奖励前七天领奖状态
self.supreme_vip_login_days = 0 --七日登录当前天数
self:SetSupremeVipShopCfg()
self:InitCfg()
end
function SupremeVipModel:getInstance()
if SupremeVipModel.Instance == nil then
SupremeVipModel.Instance = SupremeVipModel.New()
end
return SupremeVipModel.Instance
end
function SupremeVipModel:InitCfg( )
self.cfg_total_charge = stringtotable(Config.Supvipkv["total_charge"].value)[1][3]
self.trial_sup_vip_active = stringtotable(Config.Supvipkv["trial_sup_vip_active"].value)[1][3]
self.gold_exchange_price_data = stringtotable(Config.Supvipkv["gold_exchange_price"].value)
end
--星钻商城配置信息
function SupremeVipModel:SetSupremeVipShopCfg( )
for k,v in pairs(Config.Supvipstore) do
table.insert(self.shop_cfg,v)
end
local sort_func = function ( a, b )
return a.index < b.index
end
table.sort(self.shop_cfg, sort_func)
end
--获取商城配置信息
function SupremeVipModel:GetSupremeVipShopCfg()
local true_cfg = {} --排除掉已经购买过的终身限购物品
for i,v in ipairs(self.shop_cfg) do
local is_unlocked = self:IsInUnLockList(i-1>=1 and i-1 or 1)
if is_unlocked then
if self.shop_limit_data[v.goods_id] then
if self.shop_limit_data[v.goods_id].count_type == 3 then
if self.shop_limit_data[v.goods_id].count == 0 then
table.insert(true_cfg,v)
end
else
table.insert(true_cfg,v)
end
else
table.insert(true_cfg,v)
end
end
end
return true_cfg
end
--获取贵族图标开放VIP等级
function SupremeVipModel:GetSupremeIconOpenVipLv( )
return Config.Supvipkv["trial_sup_vip_lv_limit"].value
end
--获取每日礼包配置信息
function SupremeVipModel:GetDailyGiftCfg( )
return stringtotable(Config.Supvipkv["daily_sup_vip_gift"].value)
end
--获取彩钻兑换常量配置
function SupremeVipModel:GetDiamondExchageCfg( )
return stringtotable(Config.Supvipkv["gold_exchange"].value)
end
--星钻库存超过时提醒的数值
function SupremeVipModel:GetMoneyLeftCfgNum( )
return Config.Supvipkv["remind_num"].value
end
--获取彩钻兑换比例(红钻数,彩钻数)
function SupremeVipModel:GetDiamondExchangeRatio( )
local data = self.gold_exchange_price_data
return data[1][1],data[1][2]
end
--获取激活一阶贵族的消耗
function SupremeVipModel:GetActivateSupremeVipCost( )
return self.trial_sup_vip_active
end
--获取激活永久贵族的消耗
function SupremeVipModel:GetActivateForeverSupremeVipCost( )
return self.cfg_total_charge
end
--保存贵族信息 45101
function SupremeVipModel:SetSupremeVipData(vo)
self.sup_vip_type = vo.sup_vip_type
self.end_time = vo.end_time
self.today_charge = vo.today_charge
self.total_charge = vo.total_charge
self.continue_day = vo.continue_day
self.now_day = vo.day
self.gift_count = vo.gift_count
RoleManager.Instance.mainRoleInfo:ChangeVar("sup_vip_type", self.sup_vip_type)
end
--获取一阶贵族结束时间戳
function SupremeVipModel:GetEndTime( )
return self.end_time
end
--保存贵族商城信息 45104
function SupremeVipModel:SetSupremeVipShopData(vo)
for k,v in pairs(vo.goods_list) do
self.shop_limit_data_dic[v.count_type] = self.shop_limit_data_dic[v.count_type] or {}
self.shop_limit_data_dic[v.count_type][v.goods_id] = v
self.shop_limit_data[v.goods_id] = v
end
self.unlock_id = vo.unlock_id
end
--更新贵族商城限购信息 45104
function SupremeVipModel:RefreshShopLimitData(vo)
for k,v in pairs(vo.goods_list) do
self.shop_limit_data_dic[v.count_type] = self.shop_limit_data_dic[v.count_type] or {}
self.shop_limit_data_dic[v.count_type][v.goods_id] = v
self.shop_limit_data[v.goods_id] = v
end
self.unlock_id = vo.unlock_id
end
--判断当前index的商品是否解锁能买
function SupremeVipModel:IsInUnLockList(index)
if self.shop_cfg[index] then
if self.shop_cfg[index].type == 1 then
return true
else
return index <= self.unlock_id
end
else
return false
end
end
--获取限购信息列表
function SupremeVipModel:GetLimitShopData(goods_id)
return self.shop_limit_data[goods_id] or nil
end
--保存今日星钻数 45106
function SupremeVipModel:SetStarDiamondData(vo)
self.star_gold = vo.star_gold
end
function SupremeVipModel:GetStarDiamondNum( )
return self.star_gold
end
--保存今日的兑换剩余次数
function SupremeVipModel:SetExchangeRestCounts(vo)
-- 1礼包|2彩钻|3培养丹
self.exchange_rest_count_list[vo.type] = vo.rest_count
end
--获取剩余兑换次数
function SupremeVipModel:GetExchangeRestCount(type)
return self.exchange_rest_count_list[type] or 0
end
--45109 每日礼包七天登录数据
function SupremeVipModel:SetSupremeVipSevenLoginData(vo)
self.daily_reward_day_state_list = vo.day_state
self.supreme_vip_login_days = vo.login_days
end
--七天登录当前天数
function SupremeVipModel:GetSupremeVipSevenLoginDays( )
return self.supreme_vip_login_days
end
--判断当前天对应奖励的领取状态
function SupremeVipModel:GetSupremeVipSevenLoginRewardState(day)
-- 领取状态 0|未领 1|领了一次 2|领了两次
local reward_state = 0
for k,v in pairs(self.daily_reward_day_state_list) do
if v.day_id == day then
reward_state = v.reward_state
break
end
end
return reward_state
end
--获取累计充值的天数
function SupremeVipModel:GetChargeDay( )
return self.continue_day
end
--是否拥有该主界面功能特权
function SupremeVipModel:HaveSupremeVipRight(index)
-- do return true end
if self:IsForeverSupremeVip() then
return true
else
if self:IsMomentSupremeVip() then
return index == 1 or index == 4
else
return false
end
end
end
--自己是否是永久贵族
function SupremeVipModel:IsForeverSupremeVip()
return self.sup_vip_type == 2
end
--自己是否是一阶贵族
function SupremeVipModel:IsMomentSupremeVip()
return self.sup_vip_type == 1
-- if self:IsForeverSupremeVip() then
-- return false
-- else
-- local now_time = TimeUtil:getServerTime()
-- if now_time < self.end_time then
-- return true
-- else
-- return false
-- end
-- end
end
function SupremeVipModel:GetSupVipType( )
return self.sup_vip_type
end
--根据时间戳计算一阶贵族还剩几天
function SupremeVipModel:GetLeftMomentSupremeVipDay()
local day_time = 1
local true_day = 0
local true_hour = 0
local true_time = 0
local hour_time = 0
local minute_time = 0
if self.end_time ~=0 then
local str = TimeUtil:timeConversion(self.end_time, "yy/mm/dd hh:mm")
local real_time = TimeUtil:ConvertFmStringToTime(str, 1)
true_time = real_time-TimeUtil:getServerTime()
true_day = true_time/86400
true_hour = true_time/3600
hour_time = math.ceil(true_time/3600)
minute_time = math.ceil(true_time/60)
day_time = math.ceil(true_day)
end
return day_time,true_day,hour_time,true_hour,minute_time
end
-------------红点
function SupremeVipModel:IsNeedRedAll( )
for k,v in pairs(SupremeVipConst.RED_DOT_TYPE) do
self:IsNeedRed(v)
end
end
function SupremeVipModel:IsNeedRed( tab_id )
local bool = false
if tab_id == SupremeVipConst.RED_DOT_TYPE.DailyGift then
bool = self:CheckDailyGiftRed()
elseif tab_id == SupremeVipConst.RED_DOT_TYPE.DiamondExchange then
bool = self:CheckDiamondExchangeRed()
elseif tab_id == SupremeVipConst.RED_DOT_TYPE.Shop then
bool = self:CheckShopRed()
elseif tab_id == SupremeVipConst.RED_DOT_TYPE.TrainDrugExchange then
bool = self:CheckTrainDrugExchangeRed()
elseif tab_id == SupremeVipConst.RED_DOT_TYPE.MoneyLeft then--特殊红点,用来显示倒计时标志的,与红点是互斥,红点优先
bool = self:CheckMoneyLeftRed()
elseif tab_id == SupremeVipConst.RED_DOT_TYPE.SevenLogin then
bool = self:CheckSevenLoginRed()
end
self.supreme_vip_red_dot_info[tab_id] = bool
self:Fire(SupremeVipConst.ANS_UPDATE_RED_DOT,tab_id)
end
function SupremeVipModel:GetAllRedDot( )
return self.supreme_vip_red_dot_info
end
function SupremeVipModel:GetMainButtonRed( )
local bool = false
for i,v in pairs(self.supreme_vip_red_dot_info) do
if v and i ~= SupremeVipConst.RED_DOT_TYPE.MoneyLeft then--特殊红点,用来显示倒计时标志的,与红点是互斥,红点优先
bool = true
break
end
end
return bool
end
-- 优化5:
-- 检测玩家的星钻货币存量,如果玩家的星钻货币存量是》=X(X值看下可否走配置),且玩家星钻商城存在可兑换物品,则主图标以及页签给与一个倒计时图标
-- 当玩家有操作导致存量<X,或无可兑换物品,倒计时图标消失
-- 请留意倒计时标记和红点互斥,如有外部图标有红点,优先显示红点
-- 优化6:
-- 玩家每次完成充值后,检查如玩家的星钻货币存量》=X(X看下可否走配置,同条目5中的X值一样),且玩家星钻商城存在可兑换物品,则主界面与页签给与一次性红点
-- 玩家进入点击一次星钻商城页签后,红点消失
-- 说明1:如满足条件则每充值一次就会触发一次
-- 说明2:内部页签的倒计时图标和红点也是互斥,有红点优先显示红点
function SupremeVipModel:GetMainButtonTimeCountDownFlag( )
return self.supreme_vip_red_dot_info[SupremeVipConst.RED_DOT_TYPE.MoneyLeft] and self.supreme_vip_red_dot_info[SupremeVipConst.RED_DOT_TYPE.MoneyLeft] or false
end
function SupremeVipModel:CheckDailyGiftRed( )
if not GetModuleIsOpen(451) then return false end
local login_days = self:GetSupremeVipSevenLoginDays()
if login_days <= 7 then
return false
end
local bool = false
bool = self:GetExchangeRestCount(SupremeVipConst.ExchangeType.DailyGift) > 0
return bool
end
function SupremeVipModel:CheckDiamondExchangeRed( )
if not GetModuleIsOpen(451) then return false end
local bool = false
local jinLock_num = RoleManager.Instance.mainRoleInfo.jinLock
local jinLock_ratio,jin_ratio = self:GetDiamondExchangeRatio()--彩钻红钻兑换比例数
local can_exchange = jinLock_num >= jinLock_ratio
bool = self:GetExchangeRestCount(SupremeVipConst.ExchangeType.Diamond) > 0 and can_exchange
return bool
end
function SupremeVipModel:CheckShopRed( )
if not GetModuleIsOpen(451) then return false end
if self.sup_vip_type == 0 then return false end
if not self.is_first_open_shop then return false end --每次登陆上线给次红点,之后不再给红点
local bool = false
local can_buy_cfg = {}--筛选出能购买物品的商品列表
for i,v in ipairs(self.shop_cfg) do
if self.shop_limit_data[v.goods_id] and v.index <= self.unlock_id then
local price_cfg = stringtotable(v.price)
local limit_cfg = stringtotable(v.limit_buy)
if not limit_cfg or #limit_cfg ~= 0 then --把不限购的筛选出去
local can_buy = limit_cfg[1][2]-self.shop_limit_data[v.goods_id].count > 0
if can_buy and price_cfg[1][1] == 11 and self.star_gold >= price_cfg[1][2] then
bool = true
break
end
end
end
end
return bool
end
function SupremeVipModel:CheckTrainDrugExchangeRed( )
return false
-- if not GetModuleIsOpen(451) then return false end
-- if not self.is_first_open_train_drug then return false end --每次登陆上线给次红点,之后不再给红点
-- local bool = false
-- local train_drug_cfg = self:GetTrainDrugExchangeTrueCfg()
-- local is_train_drug_enough = false
-- for k,v in pairs(train_drug_cfg) do
-- local _,goods_num1 = GoodsModel:getInstance():GetTypeGoodsNum(v.goods_id) --拿到限时物品数量
-- if goods_num1 >= 1 then
-- is_train_drug_enough = true
-- break
-- end
-- end
-- bool = self:GetExchangeRestCount(SupremeVipConst.ExchangeType.TrainDrug) > 0 and is_train_drug_enough
-- return bool
end
function SupremeVipModel:CheckMoneyLeftRed( )
if not GetModuleIsOpen(451) then return false end
if self.sup_vip_type == 0 then return false end
local bool = false
local remind_num = self:GetMoneyLeftCfgNum()
local star_gold_num = self:GetStarDiamondNum()
if star_gold_num >= remind_num then
--如果剩余的星钻数超过了配置值,判断是不是有东西可以买
local can_buy_cfg = {}--筛选出能购买物品的商品列表
for i,v in ipairs(self.shop_cfg) do
if self.shop_limit_data[v.goods_id] and v.index <= self.unlock_id then
local price_cfg = stringtotable(v.price)
local limit_cfg = stringtotable(v.limit_buy)
if not limit_cfg or #limit_cfg ~= 0 then --把不限购的筛选出去
local can_buy = limit_cfg[1][2]-self.shop_limit_data[v.goods_id].count > 0
if can_buy and price_cfg[1][1] == 11 and self.star_gold >= price_cfg[1][2] then
bool = true
break
end
end
end
end
end
return bool
end
function SupremeVipModel:CheckSevenLoginRed( )
if not GetModuleIsOpen(451) then return false end
local bool = false
local login_days = self:GetSupremeVipSevenLoginDays()
if login_days > 7 then
bool = false
else
for k,v in pairs(self.daily_reward_day_state_list) do
if self:IsForeverSupremeVip() then
if v.reward_state ~= 2 then
bool = true
end
elseif self:IsMomentSupremeVip() then
if v.reward_state == 0 then
bool = true
end
end
end
end
return bool
end
function SupremeVipModel:GetTrainDrugExchangeTrueCfg( )
-- local mainVo = RoleManager:getInstance():GetMainRoleVo()
local data = {}
local train_drug_cfg = {}
for k,v in pairs(Config.Supvipexchange) do
-- if mainVo.vip_flag >= v.min_vip and mainVo.vip_flag <= v.max_vip then
-- data[v.goods_id] = v
-- end
data[v.goods_id] = v
end
for k,v in pairs(data) do
table.insert(train_drug_cfg,v)
end
for i,v in ipairs(train_drug_cfg) do
v.goods_num = GoodsModel:getInstance():GetTypeGoodsNum(v.goods_id)
end
local sort_func = function ( a, b )
return a.goods_num > b.goods_num
end
table.sort(train_drug_cfg, sort_func)
return train_drug_cfg
end
function SupremeVipModel:GetDailyGiftRed( )
return self.supreme_vip_red_dot_info[SupremeVipConst.RED_DOT_TYPE.DailyGift] or false
end
function SupremeVipModel:GetDiamondExchangeRed( )
return self.supreme_vip_red_dot_info[SupremeVipConst.RED_DOT_TYPE.DiamondExchange] or false
end
function SupremeVipModel:GetShopRed( )
return self.supreme_vip_red_dot_info[SupremeVipConst.RED_DOT_TYPE.Shop] or false
end
function SupremeVipModel:GetTrainDrugExchangeRed( )
return false
-- return self.supreme_vip_red_dot_info[SupremeVipConst.RED_DOT_TYPE.TrainDrugExchange] or false
end
function SupremeVipModel:GetMoneyLeftRed( )
return self.supreme_vip_red_dot_info[SupremeVipConst.RED_DOT_TYPE.MoneyLeft] or false
end
function SupremeVipModel:GetSevenLoginRed( )
return self.supreme_vip_red_dot_info[SupremeVipConst.RED_DOT_TYPE.SevenLogin] or false
end