HomeServer/Server/AllServer/GameServer/Store.lua

2007 lines
111 KiB
Lua
Raw Permalink Normal View History

2024-11-20 15:41:09 +08:00
local skynet = require "skynet"
local oo = require "Class"
local log = require "Log"
local pb = require "pb"
local dataType = require "DataType"
local errorInfo = require "ErrorInfo"
local bag = require "Bag"
local design = require "Design"
local json = require "json"
local activitySignPack = require "ActivitySignPack"
local Store = oo.class()
Store.TriggerPack_Update = 1
Store.TriggerPack_SpeedUp = 2
Store.TriggerPack_Plant = 3
Store.TriggerPack_UpGrade = 4
Store.TriggerPack_NewPlayerClothes = 5 --新手触发服装礼包
Store.TriggerPack_NewPlayerNormal = 6 --新手实惠礼包
Store.TriggerPack_NewPlayerFurniture = 7 --新手暖屋礼包
Store.TriggerPack_NewPlayerClothesPack = 8 --逐浪新衣礼包
--进行拍屏的礼包类型
Store.PopUpPack_Every = 1 --每次登陆
Store.PopUpPack_Day = 2 --每日首次登陆
Store.PopUpPack_First = 3 --首次开启
--初始化商城礼包数据
function Store:Init()
end
--玩家登陆初始化数据
function Store:LoginInitData( player )
self:InitData( player )
end
--玩家礼包数据初始化
function Store:InitData( player )
function Do()
--重置商城红点
skynet.server.msgTips:Reset(player , 27)
skynet.server.msgTips:Reset(player , 28)
skynet.server.msgTips:Reset(player , 29)
skynet.server.msgTips:Reset(player , 30)
skynet.server.msgTips:Reset(player , 63)
skynet.server.msgTips:Reset(player , 95)
--玩家对应的配置
local cfgStorePack = skynet.server.gameConfig:GetPlayerAllCfg( player , "StorePack") --获取玩家对应配置文件StorePack
local cfgGrowthFund = skynet.server.gameConfig:GetPlayerAllCfg( player , "GrowthFund") --获取配置文件GrowthFund中的数据
local cfgHouse = skynet.server.gameConfig:GetPlayerAllCfg( player , "House") --获取配置文件House中的数据
local cfgSValue = skynet.server.gameConfig:GetPlayerAllCfg( player , "SValue") --获取配置文件SValue中的数据
--6级开启商城 判断是否是第一次加载
if player.gameData.level >= cfgSValue.storeUnlockLvl and next(player.gameData.storePack.storePackInfo)==nil then
log.debug("第一次加载商城")
--拍屏礼包相关数据赋值
player.gameData.storePack.popupPackInfo = {}
--满足购买了对应户型的条件 进行添加触发礼包
for k , v in pairs(player.gameData.house) do
if v.status >= 3 and next(cfgHouse[v.id].unlockPack) ~= nil then
--添加该礼包
for k1 ,v1 in pairs(cfgHouse[v.id].unlockPack) do
local count = v1
player.gameData.storePack.storePackInfo[ count ] = {}
player.gameData.storePack.storePackInfo[ count ].storeId = cfgStorePack[v1].id --礼包id
player.gameData.storePack.storePackInfo[ count ].buyTimes = 0 --玩家购买的次数
player.gameData.storePack.storePackInfo[ count ].historyBuyTimes = 0 --玩家历史购买次数
player.gameData.storePack.storePackInfo[ count ].buyStatus = false --玩家是否购买该礼包 付费成功 改为true ; 发放奖励后 改为false
player.gameData.storePack.storePackInfo[ count ].packLimit = cfgStorePack[v1].packLimit --礼包对应的购买次数 例 [1,2] (1日限购 2周限购 3限购购买) 每日限购2次
player.gameData.storePack.storePackInfo[ count ].look = false --玩家是否看过该礼包(配合限时礼包)
--同时添加该礼包的存在时间
player.gameData.storePack.storePackInfo[ count ].startTime = skynet.GetTime()
player.gameData.storePack.storePackInfo[ count ].failureTime = skynet.server.common:GetAfterSomeHour(cfgHouse[v.id].packValid)
player.gameData.storePack.storePackInfo[ count ].IsShow = true --是否继续展示packLimit[0] = 3 ,即限制购买的礼包 默认为true
player.gameData.storePack.storePackInfo[ count ].buyTime = 0 --该礼包的购买时间
end
end
end
for k ,v in pairs(cfgStorePack) do
--如果是功能触发礼包需要判断是否满足条件
if 7 ~= v.packType then
local count = v.id
player.gameData.storePack.storePackInfo[ count ] = {}
player.gameData.storePack.storePackInfo[ count ].storeId = v.id --礼包id
player.gameData.storePack.storePackInfo[ count ].buyTimes = 0 --玩家购买的次数
player.gameData.storePack.storePackInfo[ count ].historyBuyTimes = 0 --玩家历史购买次数
player.gameData.storePack.storePackInfo[ count ].buyStatus = false --玩家是否购买该礼包 付费成功 改为true ; 发放奖励后 改为false
player.gameData.storePack.storePackInfo[ count ].packLimit = v.packLimit --礼包对应的购买次数 例 [1,2] (1日限购 2周限购 3限购购买) 每日限购2次
if v.startTime ~= nil and v.startTime ~= '' then
player.gameData.storePack.storePackInfo[ count ].look = false --玩家是否看过该礼包(配合限时礼包)
else
player.gameData.storePack.storePackInfo[ count ].look = true --普通礼包不用该字段
end
player.gameData.storePack.storePackInfo[ count ].IsShow = true --是否继续展示packLimit[0] = 3 ,即限制购买的礼包 默认为true
--如果有主入口界面显示 同时添加该礼包的存在时间
if v.icon ~= nil and v.icon ~= "" then
player.gameData.storePack.storePackInfo[ count ].startTime = skynet.server.common:GetTime(v.startTime)
player.gameData.storePack.storePackInfo[ count ].failureTime = skynet.server.common:GetTime(v.endTime)
end
player.gameData.storePack.storePackInfo[ count ].buyTime = 0 --该礼包的购买时间
--确保玩家有当前礼包 月卡的拍屏单独处理
if v.mainFormPopUp ~= 0 and v.id ~= 61 then
--status: 0 不需要拍屏 1 需要拍屏 2 已经拍屏过了 未到开启或已过结束时间状态都是0 默认为0
if "" ~= v.startTime and "" ~= v.endTime and skynet.GetTime() >= skynet.server.common:GetTime(v.startTime) and skynet.GetTime() < skynet.server.common:GetTime(v.endTime) then
table.insert(player.gameData.storePack.popupPackInfo ,{id = v.id , status = 1 , type = v.mainFormPopUp})
else
table.insert(player.gameData.storePack.popupPackInfo ,{id = v.id , status = 0 , type = v.mainFormPopUp})
end
elseif v.mainFormPopUp ~= 0 and v.id == 61 then
table.insert(player.gameData.storePack.popupPackInfo ,{id = v.id , status = 1 , type = v.mainFormPopUp})
end
end
end
--月卡相关数据赋值
player.gameData.storePack.monthCard.buyStatus = false --月卡是否购买过
player.gameData.storePack.monthCard.day = -1 --月卡剩余天数
player.gameData.storePack.monthCard.getStatus = true --月卡本日奖励领取状态
player.gameData.storePack.monthCard.tryStatus = false --玩家体验月卡领取状态
--主界面首充赠礼显示的相关数据赋值
player.gameData.storePack.topUpShow = true
player.gameData.storePack.topUpEndTime = skynet.server.common:GetAfterSomeHour(cfgSValue.firstChargeMainUITime*24)
local count = 1
for k ,v in pairs(cfgSValue.firstChargeReward) do
player.gameData.storePack.topUpInfo[ count ] = {}
player.gameData.storePack.topUpInfo[ count ].day = count
player.gameData.storePack.topUpInfo[ count ].rewardId = v
player.gameData.storePack.topUpInfo[ count ].isGet = 0
player.gameData.storePack.topUpInfo[ count ].startTime = 0
count = count + 1
end
--成长基金相关数据赋值
--player.gameData.storePack.growthFund = {}
--player.gameData.storePack.growthFund.canShow = true --是否展示成长基金
--player.gameData.storePack.growthFund.rewardInfos = {} --成长基金奖励相关信息
--for k , v in pairs(cfgGrowthFund) do
-- player.gameData.storePack.growthFund.rewardInfos[ v.id ] = {}
-- player.gameData.storePack.growthFund.rewardInfos[ v.id ].id = v.id
-- player.gameData.storePack.growthFund.rewardInfos[ v.id ].status = 0 --该成长基金的状态 0未购买 1已购买未完成 2已购买已完成 3已领取
--end
--新手设计卡池商场礼包
self:InitNewPlayerRaffle(player,cfgStorePack,true)
elseif player.gameData.level >= cfgSValue.storeUnlockLvl and next(player.gameData.storePack.storePackInfo)~=nil then
log.debug("第n次加载商城")
--如果没有月卡相关的数据 则进行赋值
if not player.gameData.storePack.monthCard then
player.gameData.storePack.monthCard.buyStatus = false --月卡是否购买过
player.gameData.storePack.monthCard.day = -1 --月卡剩余天数 0 代表今天 -1 代表没有月卡
player.gameData.storePack.monthCard.getStatus = true --月卡本日奖励领取状态
player.gameData.storePack.monthCard.tryStatus = false --玩家体验月卡领取状态
end
--如果没有成长基金相关数据 则进行赋值
--if not player.gameData.storePack.growthFund then
-- player.gameData.storePack.growthFund = {}
-- player.gameData.storePack.growthFund.canShow = true --是否展示成长基金
-- player.gameData.storePack.growthFund.rewardInfos = {} --成长基金奖励相关信息
-- for k , v in pairs(cfgGrowthFund) do
-- player.gameData.storePack.growthFund.rewardInfos[ v.id ] = {}
-- player.gameData.storePack.growthFund.rewardInfos[ v.id ].id = v.id
-- player.gameData.storePack.growthFund.rewardInfos[ v.id ].status = 0 --该成长基金的状态 0未购买 1已购买未完成 2已购买已完成 3已领取
-- end
--end
--如果没有拍屏相关数据 则进行赋值
local notPopup = false
if not player.gameData.storePack.popupPackInfo then
player.gameData.storePack.popupPackInfo = {}
notPopup = true
end
local notExistPack = {}
for k ,v in pairs(cfgStorePack) do
--判断该礼包是否应该添加给该玩家
local isExist = false
for k1 , v1 in pairs(player.gameData.storePack.storePackInfo) do
if v.id == v1.storeId then
isExist = true
break
end
end
--将该礼包赋值给该玩家
if not isExist and 7 ~= v.packType then
local count = v.id
player.gameData.storePack.storePackInfo[ count ] = {}
player.gameData.storePack.storePackInfo[ count ].storeId = v.id --礼包id
player.gameData.storePack.storePackInfo[ count ].buyTimes = 0 --玩家购买的次数
player.gameData.storePack.storePackInfo[ count ].historyBuyTimes = 0 --玩家历史购买次数
player.gameData.storePack.storePackInfo[ count ].buyStatus = false --玩家是否购买该礼包 付费成功 改为true ; 发放奖励后 改为false
player.gameData.storePack.storePackInfo[ count ].packLimit = v.packLimit --礼包对应的购买次数 例 [1,2] (1日限购 2周限购 3限购购买) 每日限购2次
if v.startTime ~= nil and v.startTime ~= '' then
player.gameData.storePack.storePackInfo[ count ].look = false --玩家是否看过该礼包(配合限时礼包)
else
player.gameData.storePack.storePackInfo[ count ].look = true --普通礼包不用该字段
end
player.gameData.storePack.storePackInfo[ count ].IsShow = true --是否继续展示packLimit[0] = 3 ,即限制购买的礼包 默认为true
--如果有主入口界面显示 同时添加该礼包的存在时间
if v.icon ~= nil and v.icon ~= "" then
player.gameData.storePack.storePackInfo[ count ].startTime = skynet.server.common:GetTime(v.startTime)
player.gameData.storePack.storePackInfo[ count ].failureTime = skynet.server.common:GetTime(v.endTime)
end
player.gameData.storePack.storePackInfo[ count ].buyTime = 0 --该礼包的购买时间
isExist = true
elseif not isExist and 7 == v.packType then
--将不存在的触发礼包id添加到notExistPack中
table.insert(notExistPack , v.id)
end
--判断该玩家是否有该礼包 再进行添加对应拍屏礼包
if notPopup and isExist and v.mainFormPopUp ~= 0 then
if v.id == 61 then
table.insert(player.gameData.storePack.popupPackInfo ,{id = v.id , status = 1 , type = v.mainFormPopUp})
else
table.insert(player.gameData.storePack.popupPackInfo ,{id = v.id , status = 0 , type = v.mainFormPopUp})
end
elseif not notPopup and isExist and v.mainFormPopUp ~= 0 then
--进行添加还未记录的拍屏礼包
local isExist1 = false
for k1 , v1 in pairs(player.gameData.storePack.popupPackInfo) do
if v.id == v1.id then
isExist1 = true
break
end
end
if not isExist1 then
table.insert(player.gameData.storePack.popupPackInfo ,{id = v.id , status = 0 , type = v.mainFormPopUp})
end
end
end
--满足购买了对应户型的条件 进行添加对应礼包
for k , v in pairs(player.gameData.house) do
if v.status >= 3 and next(cfgHouse[v.id].unlockPack) ~= nil then
for k1 ,v1 in pairs(cfgHouse[v.id].unlockPack) do
--判断是否需要添加该礼包
local include = false
for k2,v2 in pairs(notExistPack) do
if v1 == v2 then
include = true
--同时在不存在的礼包id集合中移除该礼包
table.remove(notExistPack,k2)
break
end
end
if include then
local count = v1
player.gameData.storePack.storePackInfo[ count ] = {}
player.gameData.storePack.storePackInfo[ count ].storeId = cfgStorePack[v1].id --礼包id
player.gameData.storePack.storePackInfo[ count ].buyTimes = 0 --玩家购买的次数
player.gameData.storePack.storePackInfo[ count ].historyBuyTimes = 0 --玩家历史购买次数
player.gameData.storePack.storePackInfo[ count ].buyStatus = false --玩家是否购买该礼包 付费成功 改为true ; 发放奖励后 改为false
player.gameData.storePack.storePackInfo[ count ].packLimit = cfgStorePack[v1].packLimit --礼包对应的购买次数 例 [1,2] (1日限购 2周限购 3限购购买) 每日限购2次
player.gameData.storePack.storePackInfo[ count ].look = false --玩家是否看过该礼包(配合限时礼包)
--同时添加该礼包的存在时间
player.gameData.storePack.storePackInfo[ count ].startTime = skynet.GetTime()
player.gameData.storePack.storePackInfo[ count ].failureTime = skynet.server.common:GetAfterSomeHour(cfgHouse[v.id].packValid)
player.gameData.storePack.storePackInfo[ count ].IsShow = true --是否继续展示packLimit[0] = 3 ,即限制购买的礼包 默认为true
player.gameData.storePack.storePackInfo[ count ].buyTime = 0 --该礼包的购买时间
end
end
end
end
--满足购买了对应商城礼包的条件 进行添加触发礼包
--超优礼包
local triggeredGiftBagTime = cfgSValue.triggeredGiftBagTime --被触发的超优礼包id持续时间分钟
local triggerGiftBag = cfgSValue.triggerGiftBag --触发超优礼包的商城礼包id
--判断是否需要添加该礼包
local include = false
for k ,v in pairs(notExistPack) do
if triggeredGiftBagTime[1] == v then
include = true
--同时在不存在的礼包id集合中移除该礼包
table.remove(notExistPack,k)
break
end
end
for k ,v in pairs(triggerGiftBag) do
--判断玩家该商城礼包是否购买过
if include and player.gameData.storePack.storePackInfo[v].buyTimes > 0 then
local count = triggeredGiftBagTime[1]
player.gameData.storePack.storePackInfo[ count ] = {}
player.gameData.storePack.storePackInfo[ count ].storeId = cfgStorePack[triggeredGiftBagTime[1]].id --礼包id
player.gameData.storePack.storePackInfo[ count ].buyTimes = 0 --玩家购买的次数
player.gameData.storePack.storePackInfo[ count ].historyBuyTimes = 0 --玩家历史购买次数
player.gameData.storePack.storePackInfo[ count ].buyStatus = false --玩家是否购买该礼包 付费成功 改为true ; 发放奖励后 改为false
player.gameData.storePack.storePackInfo[ count ].packLimit = cfgStorePack[triggeredGiftBagTime[1]].packLimit --礼包对应的购买次数 例 [1,2] (1日限购 2周限购 3限购购买) 每日限购2次
player.gameData.storePack.storePackInfo[ count ].look = false --玩家是否看过该礼包(配合限时礼包)
--同时添加该礼包的存在时间
player.gameData.storePack.storePackInfo[ count ].startTime = skynet.GetTime()
player.gameData.storePack.storePackInfo[ count ].failureTime = skynet.GetTime() + triggeredGiftBagTime[2] * 60
player.gameData.storePack.storePackInfo[ count ].IsShow = true --是否继续展示packLimit[0] = 3 ,即限制购买的礼包 默认为true
player.gameData.storePack.storePackInfo[ count ].buyTime = 0 --该礼包的购买时间
elseif not include then
break
end
end
--当前限时卡池对应触发礼包
--获取对应卡池信息
local cfgRaffle = skynet.server.raffle:GetCfgRaffleByRaffleType( player , {skynet.server.raffle.LotteryType_3,skynet.server.raffle.LotteryType_4} )
if cfgRaffle~= nil then
--local cfgRaffle = skynet.server.gameConfig:GetPlayerCurCfg( player , "Raffle" , player.gameData.design.timeCardPoolInfo.id)
local limitGiftBagTime = cfgRaffle.triggerPack --被触发的卡池限时礼包id持续时间分钟
local limitGiftBag = cfgRaffle.packId --触发卡池限时礼包的商城礼包id
--判断是否需要添加该礼包
include = false
for k ,v in pairs(notExistPack) do
if limitGiftBagTime[1] == v then
include = true
--同时在不存在的礼包id集合中移除该礼包
table.remove(notExistPack,k)
break
end
end
for k ,v in pairs(limitGiftBag) do
--判断玩家该商城礼包是否购买过
if include and player.gameData.storePack.storePackInfo[v].buyTimes > 0 then
local count = limitGiftBagTime[1]
player.gameData.storePack.storePackInfo[ count ] = {}
player.gameData.storePack.storePackInfo[ count ].storeId = cfgStorePack[limitGiftBagTime[1]].id --礼包id
player.gameData.storePack.storePackInfo[ count ].buyTimes = 0 --玩家购买的次数
player.gameData.storePack.storePackInfo[ count ].historyBuyTimes = 0 --玩家历史购买次数
player.gameData.storePack.storePackInfo[ count ].buyStatus = false --玩家是否购买该礼包 付费成功 改为true ; 发放奖励后 改为false
player.gameData.storePack.storePackInfo[ count ].packLimit = cfgStorePack[limitGiftBagTime[1]].packLimit --礼包对应的购买次数 例 [1,2] (1日限购 2周限购 3限购购买) 每日限购2次
player.gameData.storePack.storePackInfo[ count ].look = false --玩家是否看过该礼包(配合限时礼包)
--同时添加该礼包的存在时间
player.gameData.storePack.storePackInfo[ count ].startTime = skynet.GetTime()
player.gameData.storePack.storePackInfo[ count ].failureTime = skynet.GetTime() + limitGiftBagTime[2] * 60
player.gameData.storePack.storePackInfo[ count ].IsShow = true --是否继续展示packLimit[0] = 3 ,即限制购买的礼包 默认为true
player.gameData.storePack.storePackInfo[ count ].buyTime = 0 --该礼包的购买时间
elseif not include then
break
end
end
end
--新手设计卡池商场礼包
self:InitNewPlayerRaffle(player,cfgStorePack,false)
end
if player.gameData.level >= cfgSValue.storeUnlockLvl then
--特殊处理下光子服的玩家礼包数据
if player.basicInfo.gameCgi == "chenzong_dwelstgz" and player.gameData.storePack.storePackInfo[151] then
player.gameData.storePack.storePackInfo[151] = nil
end
--获取玩家对应配置文件ValueAccumulate
local cfgValueAccumulate = skynet.server.gameConfig:GetPlayerAllCfg( player , "ValueAccumulate")
local nowTime = skynet.GetTime()
--初始化玩家积分奖励信息
if next(player.gameData.storePack.pointsInfo) == nil then
for k ,v in pairs(cfgValueAccumulate) do
player.gameData.storePack.pointsInfo[ k ] = {}
player.gameData.storePack.pointsInfo[ k ].id = v.id
player.gameData.storePack.pointsInfo[ k ].isGet = 0 --默认不可领取
end
elseif #player.gameData.storePack.pointsInfo < #cfgValueAccumulate then
for i = #player.gameData.storePack.pointsInfo + 1, #cfgValueAccumulate, 1 do
player.gameData.storePack.pointsInfo[ i ] = {}
player.gameData.storePack.pointsInfo[ i ].id = cfgValueAccumulate[i].id
player.gameData.storePack.pointsInfo[ i ].isGet = 0 --默认不可领取
end
end
--判断当前的时间是否达到首充奖励的时间
for k ,v in pairs(player.gameData.storePack.topUpInfo) do
if v.isGet == 0 and nowTime>=v.startTime and v.startTime~=0 then
v.isGet = 1
skynet.server.msgTips:AddNoNotice(player , 48)
end
end
--判断是否还需要在主界面显示首充赠礼
if nowTime >= player.gameData.storePack.topUpEndTime and player.gameData.storePack.topUpShow then
player.gameData.storePack.topUpShow = false
end
--拍屏礼包管理
for k , v in pairs(player.gameData.storePack.popupPackInfo) do
--月卡拍屏单独处理 购买后不进行拍屏
if v.id == 61 then
if player.gameData.storePack.monthCard.buyStatus then
v.status = 2
end
else
if v.status == 0 then
--没有开启的判断是否应该开启
local cfgOneStorePack = skynet.server.gameConfig:GetPlayerCurCfg( player , "StorePack" , v.id)
if cfgOneStorePack and cfgOneStorePack.startTime and cfgOneStorePack.startTime~="" and skynet.GetTime() >= skynet.server.common:GetTime(cfgOneStorePack.startTime)
and skynet.GetTime() < skynet.server.common:GetTime(cfgOneStorePack.endTime) then
v.status = 1
end
else
--开启了的判断是否应该结束
local cfgOneStorePack = skynet.server.gameConfig:GetPlayerCurCfg( player , "StorePack" , v.id)
if cfgOneStorePack and cfgOneStorePack.endTime and cfgOneStorePack.endTime~="" and skynet.GetTime() >= skynet.server.common:GetTime(cfgOneStorePack.endTime) then
v.status = 0
end
end
end
end
--如果有免费礼包可以获取则 商城显示红点
for k , v in pairs(cfgStorePack) do
--找到对应礼包 判断是否可以领取
if v.packType == 6 and player.gameData.storePack.storePackInfo[v.id].storeId and player.gameData.storePack.storePackInfo[v.id].buyTimes == 0 then
if v.packUI==1 then
skynet.server.msgTips:AddNoNotice(player , 27)
elseif v.packUI==2 then
skynet.server.msgTips:AddNoNotice(player , 28)
elseif v.packUI==3 then
skynet.server.msgTips:AddNoNotice(player , 29)
elseif v.packUI==4 then
skynet.server.msgTips:AddNoNotice(player , 30)
end
end
end
--如果有限时礼包未查看 商城显示红点
for k , v in pairs(player.gameData.storePack.storePackInfo) do
if v.look == false and v.IsShow then
local storePacK = {}
for k1 , v1 in pairs(cfgStorePack) do
if v1.id == v.storeId then
storePacK = v1
break
end
end
if next(storePacK) ~= nil then
local startTime = 0
local endTime = 0
if storePacK.startTime ~= '' and type(storePacK.startTime) == 'string' then
startTime = skynet.server.common:GetTime(storePacK.startTime)
endTime = skynet.server.common:GetTime(storePacK.endTime)
elseif storePacK.startTime ~= '' and type(storePacK.startTime) == 'number' then
startTime = storePacK.startTime
endTime = storePacK.endTime
end
if nowTime >= startTime and nowTime <= endTime and storePacK.packUI == 1 then
skynet.server.msgTips:AddNoNotice(player , 27)
elseif nowTime >= startTime and nowTime <= endTime and storePacK.packUI == 2 then
skynet.server.msgTips:AddNoNotice(player , 28)
elseif nowTime >= startTime and nowTime <= endTime and storePacK.packUI == 3 then
skynet.server.msgTips:AddNoNotice(player , 29)
elseif nowTime >= startTime and nowTime <= endTime and storePacK.packUI == 4 then
skynet.server.msgTips:AddNoNotice(player , 30)
end
else
player.gameData.storePack.storePackInfo[ k ] = nil
end
end
end
--如果月卡有未领取奖励 显示对应红点
if not player.gameData.storePack.monthCard.getStatus then
skynet.server.msgTips:AddNoNotice(player , 63)
end
--如果月卡有免费领取 显示对应红点
if player.gameData.storePack.monthCard.tryStatus == false then
skynet.server.msgTips:AddNoNotice(player , 95)
end
--主动推送含有icon的可购买礼包
self:SendIconPackToUser(player)
end
return true
end
--Do()
local ret,err = pcall(Do)
if not ret or not err then
local account = player.basicInfo.accountName
local userId = player.userId
log.info("内部错误信息 Store:InitData ", account ,userId ,ret ,err )
return false
end
--[[
--测试用 开启所有礼包
if player.gameData.level >= cfgSValue.storeUnlockLvl then
--商城开启相关礼包 类型7的直接可以购买
local cfgStorePack = skynet.server.gameConfig:GetPlayerAllCfg( player , "StorePack") --获取配置文件StorePack中的数据
for k , v in pairs(cfgStorePack) do
if 7 == v.packType then
local count = v.id
player.gameData.storePack.storePackInfo[ count ] = {}
player.gameData.storePack.storePackInfo[ count ].storeId = v.id --礼包id
player.gameData.storePack.storePackInfo[ count ].buyTimes = 0 --玩家购买的次数
player.gameData.storePack.storePackInfo[ count ].historyBuyTimes = 0 --玩家历史购买次数
player.gameData.storePack.storePackInfo[ count ].buyStatus = false --玩家是否购买该礼包 付费成功 改为true ; 发放奖励后 改为false
player.gameData.storePack.storePackInfo[ count ].packLimit = v.packLimit --礼包对应的购买次数 例 [1,2] (1日限购 2周限购 3限购购买) 每日限购2次
player.gameData.storePack.storePackInfo[ count ].look = false --玩家是否看过该礼包(配合限时礼包)
--同时添加该礼包的存在时间
player.gameData.storePack.storePackInfo[ count ].startTime = os.time()
player.gameData.storePack.storePackInfo[ count ].failureTime = skynet.server.common:GetAfterSomeHour(72)
player.gameData.storePack.storePackInfo[ count ].IsShow = true --是否继续展示packLimit[0] = 3 ,即限制购买的礼包 默认为true
end
end
end
]]
end
--添加新手限时卡池对应触发礼包
function Store:InitNewPlayerRaffle(player,cfgStorePack,isFirst)
--判断模块是否开启--这里不能用这个函数
if not player:IsUnlockSystem( dataType.UnlockSystem_ActivityNewPlayerRaffle ) and not isFirst then
--log.info("Store:InitNewPlayerRaffle 未开启新手限时触发礼包")
return
end
--是否开启新手限时触发礼包
local cfgNewPlayerRaffle=skynet.server.activityNewPlayerRaffle:CheckData(player)
if cfgNewPlayerRaffle ~= nil then
for _, storeId in ipairs(cfgNewPlayerRaffle.storepacklimit) do
--礼包是否存在,是否已经添加
if cfgStorePack[storeId] ~= nil and player.gameData.storePack.storePackInfo[storeId] == nil then
local cfgStorePackData = cfgStorePack[storeId]
player.gameData.storePack.storePackInfo[ storeId ] = {}
player.gameData.storePack.storePackInfo[ storeId ].storeId = storeId --礼包id
player.gameData.storePack.storePackInfo[ storeId ].buyTimes = 0 --玩家购买的次数
player.gameData.storePack.storePackInfo[ storeId ].historyBuyTimes = 0 --玩家历史购买次数
player.gameData.storePack.storePackInfo[ storeId ].buyStatus = false --玩家是否购买该礼包 付费成功 改为true ; 发放奖励后 改为false
player.gameData.storePack.storePackInfo[ storeId ].packLimit = cfgStorePackData.packLimit --礼包对应的购买次数 例 [1,2] (1日限购 2周限购 3限购购买) 每日限购2次
player.gameData.storePack.storePackInfo[ storeId ].look = false --玩家是否看过该礼包(配合限时礼包)
--同时添加该礼包的存在时间
player.gameData.storePack.storePackInfo[ storeId ].startTime = skynet.GetTime()
player.gameData.storePack.storePackInfo[ storeId ].failureTime = skynet.server.activityNewPlayerRaffle:GetActivityEndTime(player.gameData.NewPlayerRaffleMap[cfgNewPlayerRaffle.id].activityOpenTime)
player.gameData.storePack.storePackInfo[ storeId ].IsShow = true --是否继续展示packLimit[0] = 3 ,即限制购买的礼包 默认为true
player.gameData.storePack.storePackInfo[ storeId ].buyTime = 0 --该礼包的购买时间
end
end
end
end
--商城显示
function Store:Show( player , c2sData , s2cData )
c2sData.data = assert(pb.decode("C2SStoreShow", c2sData.data ))
local packUI = c2sData.data.packUI
local data = {}
data.packUI = packUI
--是否给玩家显示商城首充赠礼
local getAll = true --是否领取完毕
for k ,v in pairs(player.gameData.storePack.topUpInfo) do
if v.isGet ~= 2 then
getAll = false
break
end
end
if getAll then
data.canShowStoreTopUp = false
else
data.canShowStoreTopUp = true
end
data.storeInfos = {}
data.buyStoreId = {}
local cfgStorePack = skynet.server.gameConfig:GetPlayerAllCfg( player , "StorePack") --获取玩家对应配置文件StorePack
local nowTime = skynet.GetTime()
--判断玩家是不是审核玩家
if player:IsAudit() then
--如果是审核玩家则不限制礼包的显示时间
for k , v in pairs(cfgStorePack) do
if v.packUI == packUI then
local packInfo = player.gameData.storePack.storePackInfo[ v.id ]
if packInfo and v.startTime ~= nil and v.startTime ~= '' then
table.insert(data.storeInfos , {storeId=v.id , buyTimes=packInfo.buyTimes , failureTime = skynet.server.common:GetTime(v.endTime) , redDot = false})
elseif packInfo then
table.insert(data.storeInfos , {storeId=v.id , buyTimes=packInfo.buyTimes , failureTime = packInfo.failureTime , redDot = false})
end
if v.packUI == 4 and packInfo and packInfo.buyTimes > 0 then
table.insert(data.buyStoreId , v.id)
end
end
end
else
for k , v in pairs(cfgStorePack) do
local startTime = 0 --礼包对应的生效时间
local endTime = 0 --礼包对应的失效时间
--处理一下礼包时间
if v.startTime ~= nil and v.startTime ~= '' then
startTime = skynet.server.common:GetTime(v.startTime)
endTime = skynet.server.common:GetTime(v.endTime)
end
--已经购买次数
local buyTimes =0
--获取玩家对应的礼包数据
local packInfo = player.gameData.storePack.storePackInfo[ v.id ]
if packInfo and packInfo.buyTimes then
--提取购买次数--是否是分层礼包
buyTimes = packInfo.buyTimes+skynet.server.activityLevelPack:buyCount(player,v.id)
end
--将满足条件的礼包进行显示
if v.packUI == packUI and nowTime >= startTime then
--if v.packUI == packUI then
if packInfo and packInfo.look and packInfo.IsShow then
if packInfo.failureTime == nil and endTime == 0 then
table.insert(data.storeInfos , {storeId=v.id , buyTimes=buyTimes , failureTime = endTime , redDot = false})
elseif packInfo.failureTime == nil and endTime ~= 0 and nowTime <= endTime then
table.insert(data.storeInfos , {storeId=v.id , buyTimes=buyTimes , failureTime = endTime , redDot = false})
elseif packInfo.failureTime ~= nil and nowTime <= packInfo.failureTime then
table.insert(data.storeInfos , {storeId=v.id , buyTimes=buyTimes , failureTime = packInfo.failureTime , redDot = false})
end
elseif packInfo and not packInfo.look and packInfo.IsShow then
if packInfo.failureTime == nil and endTime == 0 then
table.insert(data.storeInfos , {storeId=v.id , buyTimes=buyTimes , failureTime = endTime , redDot = true})
elseif packInfo.failureTime == nil and endTime ~= 0 and nowTime <= endTime then
table.insert(data.storeInfos , {storeId=v.id , buyTimes=buyTimes , failureTime = endTime , redDot = true})
elseif packInfo.failureTime ~= nil and nowTime <= packInfo.failureTime then
table.insert(data.storeInfos , {storeId=v.id , buyTimes=buyTimes , failureTime = packInfo.failureTime , redDot = true})
end
self:DelRedDot(player , packUI)
--修改玩家对应礼包的读取状态
packInfo.look=true
end
end
--..有效时间
if v.packUI == 4 and ((nowTime >= startTime and nowTime<= endTime) or nowTime == endTime) then
if packInfo and buyTimes > 0 then
--有开始和结束时间的要判断下是否还继续显示
if packInfo.startTime and packInfo.failureTime and nowTime > packInfo.startTime and nowTime < packInfo.failureTime then
table.insert(data.buyStoreId , v.id)
elseif not packInfo.startTime and not packInfo.failureTime then
table.insert(data.buyStoreId , v.id)
end
end
end
end
end
--local count = 0 --进行显示的礼包当前数量
--local maxCount = skynet.server.gameConfig:GetPlayerAllCfg( player , "SValue").recommendPackMax --最大显示数量
--data.headlineInfos = {}
--for k , v in pairs(data.storeInfos) do
-- local cfgOneStorePack = skynet.server.gameConfig:GetPlayerCurCfg( player , "StorePack" , v.storeId)
-- --判断是否是需要进行头条展示的礼包
-- if cfgOneStorePack.display > 0 and count < maxCount then
-- table.insert(data.headlineInfos , v)
-- count = count + 1
-- end
--end
--打开商城时检测一下豪华月卡是否到期
skynet.server.luxuryCard:CheckOutOfTime( skynet.GetTime() , player )
s2cData.cmd = pb.enum("MsgType","CMD_S2C_StoreShow")
s2cData.data = assert(pb.encode("S2CStoreShow", data))
end
--商城购买
function Store:Buy( player , c2sData , s2cData , isPay )
isPay = isPay and isPay or false
c2sData.data = assert(pb.decode("C2SStoreBuy", c2sData.data ))
local storeId = c2sData.data.storeId
local buyCount = c2sData.data.buyCount
if buyCount < 0 then
buyCount = -buyCount
end
--获取配置文件SValue中的数据
local cfgSValue = skynet.server.gameConfig:GetPlayerAllCfg( player , "SValue")
--获取玩家对应配置文件StorePack的礼包数据
local cfgStorePack = skynet.server.gameConfig:GetPlayerCurCfg( player , "StorePack" , storeId)
local cfgAllStorePrice = skynet.server.gameConfig:GetPlayerAllCfg( player , "StorePrice" )
local cfgStorePrice = {}
for k ,v in pairs(cfgAllStorePrice) do
if v.storePackId == storeId then
cfgStorePrice.price = v.price
break
end
end
if next(cfgStorePrice) == nil then
cfgStorePrice.price = 0
end
--测试用
--skynet.server.design:Pay(player , storeId)
--skynet.server.passCheck:Pay(player , storeId)
skynet.server.raffle:Pay( player , storeId )
skynet.server.activityLimitedAccum:Pay( player , storeId )
local data = {}
data.storeInfo = {}
data.buyCount = buyCount
data.conversionInfos = {}
--处理一下礼包时间
local startTime = 0 --礼包对应的生效时间
local endTime = 0 --礼包对应的失效时间
if cfgStorePack.startTime ~= nil and cfgStorePack.startTime ~= '' then
startTime = skynet.server.common:GetTime(cfgStorePack.startTime)
endTime = skynet.server.common:GetTime(cfgStorePack.endTime)
end
--判断是否进行发放物品
local nowTime = skynet.GetTime()
local eventId = pb.enum("EnumMoneyChangeEventID","EventID_41")
--是否钻石购买
local isDiamond = false
if nowTime >= startTime or player:IsAudit() then
if cfgStorePrice.price > 0 and next(cfgStorePack.packExchange) == nil then --判断礼包是不是付费礼包
--获取钻石/人民币比例
local cfgSValue = skynet.server.gameConfig:GetPlayerAllCfg( player , "SValue")
local diamondEXchange= cfgSValue.diamondEXchange[2]
--获取钻石
local diamond = skynet.server.bag:GetGoodsCount(player,dataType.GoodsType_Prop, 28)--钻石{官网充值送的道具skd那边叫代金券}是否足够【这里28代表是钻石】
if (player.gameData.storePack.storePackInfo[storeId]~=nil
and player.gameData.storePack.storePackInfo[storeId].buyStatus) --已经充值
or skynet.server.gameConfig:IsTest() --测试服端不校验
or diamond * diamondEXchange>= cfgStorePrice.price then--钻石是否足够
--if true then
--判断该礼包有没有额外奖励
if next(cfgStorePack.packGift) ~= nil then
--给该玩家增加对应的物品
--判断购买次数是否有限制
if next(player.gameData.storePack.storePackInfo[storeId].packLimit) == nil then
if cfgStorePack.packGift[ 1 ] == 0 then
--每次购买赠送
data.conversionInfos = player:GiveReward(cfgStorePack.rewardId , eventId ,buyCount)
elseif cfgStorePack.packGift[ 1 ] == 1 and player.gameData.storePack.storePackInfo[storeId].historyBuyTimes == 0 then
--首次购买赠送
data.conversionInfos = player:GiveReward(cfgStorePack.rewardId , eventId , buyCount)
end
--原本应获取的物品
data.conversionInfos = player:GiveReward(cfgStorePack.rewardId , eventId , buyCount)
--修改玩家对应礼包的购买次数
self:ChangeBuyTimes( player , storeId)
elseif player.gameData.storePack.storePackInfo[storeId].packLimit[2] - player.gameData.storePack.storePackInfo[storeId].buyTimes >= buyCount then
--限制数-已购买数 >= 购买数
if cfgStorePack.packGift[ 1 ] == 0 then
--每次购买赠送
data.conversionInfos = player:GiveReward(cfgStorePack.rewardId , eventId ,buyCount)
elseif cfgStorePack.packGift[ 1 ] == 1 and player.gameData.storePack.storePackInfo[storeId].historyBuyTimes == 0 then
--首次购买赠送
data.conversionInfos = player:GiveReward(cfgStorePack.rewardId , eventId ,buyCount)
end
--原本应获取的物品
data.conversionInfos = player:GiveReward(cfgStorePack.rewardId , eventId ,buyCount)
--修改玩家对应礼包的购买次数
self:ChangeBuyTimes( player , storeId)
elseif player.gameData.storePack.storePackInfo[storeId].packLimit[2]-player.gameData.storePack.storePackInfo[storeId].buyTimes < buyCount then
s2cData.code=errorInfo.ErrorCode.StorePackBuyError
end
else
--给该玩家增加对应的物品
if next(player.gameData.storePack.storePackInfo[storeId].packLimit) == nil then
--无限制
data.conversionInfos = player:GiveReward(cfgStorePack.rewardId , eventId ,buyCount)
--修改玩家对应礼包的购买次数
self:ChangeBuyTimes( player , storeId)
elseif player.gameData.storePack.storePackInfo[storeId].packLimit[2]-player.gameData.storePack.storePackInfo[storeId].buyTimes>=buyCount then
--有限制
data.conversionInfos = player:GiveReward(cfgStorePack.rewardId , eventId ,buyCount)
--修改玩家对应礼包的购买次数
self:ChangeBuyTimes( player , storeId)
elseif player.gameData.storePack.storePackInfo[storeId].packLimit[2]-player.gameData.storePack.storePackInfo[storeId].buyTimes < buyCount then
s2cData.code=errorInfo.ErrorCode.StorePackBuyError
end
end
--发放奖励后将状态修改为false
player.gameData.storePack.storePackInfo[storeId].buyStatus = false
--扣除钻石
if diamond * diamondEXchange >= cfgStorePrice.price then
log.debug(string.format("玩家 %s 购买礼包扣钻石 %s钻石%dcfgStorePrice.price:%d",player.userId,storeId,diamond,tostring(cfgStorePrice.price/ diamondEXchange)))
--扣除道具--道具id 是28 钻石 这里写死以往规则
skynet.server.bag:RemoveGoods(player,dataType.GoodsType_Prop, 28,tostring(cfgStorePrice.price/ diamondEXchange))
--添加相关日志
skynet.server.playerRecord:Add( player.userId , dataType.RecordType_101 , 0 , dataType.GoodsType_Prop, 28, tostring(cfgStorePrice.price/ diamondEXchange) )
--标记钻石购买
isDiamond = true
end
else
s2cData.code=errorInfo.ErrorCode.StorePackBuyError
end
elseif next(cfgStorePack.packExchange) ~= nil then --判断是不是兑换礼包
--判断该礼包是否是无限制的
if next(cfgStorePack.packLimit) ~= nil then
--判断是否还可以购买
if player.gameData.storePack.storePackInfo[storeId].packLimit[ 2 ] - player.gameData.storePack.storePackInfo[storeId].buyTimes >= buyCount then
--先扣除玩家货币
-- 设计稿归因
if storeId == 51 then
eventId = pb.enum("EnumMoneyChangeEventID","EventID_16")
elseif storeId == 52 then
eventId = pb.enum("EnumMoneyChangeEventID","EventID_17")
elseif storeId == 53 then
eventId = pb.enum("EnumMoneyChangeEventID","EventID_18")
end
local isSuccess = player:MoneyChange(cfgStorePack.packExchange[1] , -cfgStorePack.packExchange[2]*buyCount , eventId)
--再增加对应的物品
if isSuccess ~= false then
data.conversionInfos = player:GiveReward(cfgStorePack.rewardId , eventId , buyCount)
self:ChangeBuyTimes( player , storeId ,buyCount)
else
s2cData.code=errorInfo.ErrorCode.NoEnoughMoney
end
end
else
--先扣除玩家货币
-- 设计稿归因
if storeId == 51 then
eventId = pb.enum("EnumMoneyChangeEventID","EventID_16")
elseif storeId == 52 then
eventId = pb.enum("EnumMoneyChangeEventID","EventID_17")
elseif storeId == 53 then
eventId = pb.enum("EnumMoneyChangeEventID","EventID_18")
end
local isSuccess = player:MoneyChange(cfgStorePack.packExchange[1] , -cfgStorePack.packExchange[2]*buyCount , eventId)
--再增加对应的物品
if isSuccess ~= false then
data.conversionInfos = player:GiveReward(cfgStorePack.rewardId, eventId , buyCount )
self:ChangeBuyTimes( player , storeId ,buyCount)
else
s2cData.code=errorInfo.ErrorCode.NoEnoughMoney
end
end
elseif cfgStorePack.packType == 6 then --判断是不是免费礼包
--判断该礼包是否是无限制的
if next(cfgStorePack.packLimit) ~= nil then
--判断是否还可以购买
if cfgStorePack.packLimit[ 2 ] - player.gameData.storePack.storePackInfo[storeId].buyTimes >= buyCount then
data.conversionInfos = player:GiveReward(cfgStorePack.rewardId, eventId , buyCount )
self:ChangeBuyTimes( player , storeId ,buyCount)
--消除红点
self:DelRedDot( player , cfgStorePack.packUI)
else
s2cData.code=errorInfo.ErrorCode.StorePackBuyError
end
end
end
else
s2cData.code=errorInfo.ErrorCode.StorePackBuyError
end
--通行证处理
if 7 == storeId and (skynet.server.gameConfig:IsTest() or isDiamond) then
--测试服通行证在这里才会发放
skynet.server.passCheck:Pay( player , storeId )
end
--将该礼包的奖励信息返回给客户端
for k ,v in pairs(player.gameData.storePack.storePackInfo) do
if storeId == v.storeId then
data.storeInfo = {storeId = storeId , buyTimes = v.buyTimes , failureTime = v.failureTime ,redDot = false}
break
end
end
--判断购买的礼包是否会触发相应礼包
--超优礼包
local triggerGiftBag = cfgSValue.triggerGiftBag --触发超优礼包的商城礼包id
local triggeredGiftBagTime = cfgSValue.triggeredGiftBagTime --超优礼包的数据 礼包id 存在时间
for k , v in pairs(triggerGiftBag) do
if storeId == v and not player.gameData.storePack.storePackInfo[triggeredGiftBagTime[1]] then
self:InitData(player)
--主动推送一下对应礼包的packUI的信息
local c2sData1 = {}
local s2cData1 = {}
local showData = {}
showData.packUI = skynet.server.gameConfig:GetPlayerAllCfg( player , "StorePack" , triggeredGiftBagTime[1]).packUI
c2sData1.data = assert(pb.encode("C2SStoreShow", showData))
self:Show(player , c2sData1 , s2cData1)
local data1 = assert(pb.decode("S2CStoreShow", s2cData1.data))
skynet.server.gameServer:SendMsgToUser(player.userId, "CMD_S2C_StoreShow", data1)
elseif player.gameData.storePack.storePackInfo[triggeredGiftBagTime[1]] then
--已经触发过的话直接退出
break
end
end
--限时卡池的触发礼包
self:DesignTriggerPackByBuy(player , storeId)
--判断购买的礼包是否达到购买限制 若达到则不进行商城展示了
for k , v in pairs(player.gameData.storePack.storePackInfo) do
if storeId == v.storeId and v.packLimit[1] == 3 and (v.buyTimes>=v.packLimit [2] or skynet.server.activityLevelPack:buyCount(player,v.storeId) > 0 ) then
v.IsShow = false
--更新所有分层礼包购买次数
if skynet.server.activityLevelPack:buyCount(player,v.storeId) > 0 then
--活动是否开启
local cfgLevelPack =skynet.server.activityLevelPack:CheckDataAndGetActivity(player)
if cfgLevelPack ~=nil then
for _, id in ipairs(cfgLevelPack.storePackId) do
player.gameData.storePack.storePackInfo[id].IsShow = v.IsShow
player.gameData.storePack.storePackInfo[id].buyTimes = v.buyTimes
end
--主动推送当前活动信息
local data = {}
data.activityInfos = skynet.server.activity:GetAllActivityInfo( player )
skynet.server.gameServer:SendMsgToUser( player.userId , "CMD_S2C_UpdateShowUI" , data )
end
end
break
end
end
--如果购买的礼包还未进行拍屏 则不再进行拍屏
for k , v in pairs(player.gameData.storePack.popupPackInfo) do
if v.id == storeId and v.status == 1 and not player.gameData.storePack.storePackInfo[storeId].IsShow then
local data1 = {}
data1.popUpStoreInfo = {storeId = v.id , buyTimes = 0 , failureTime = 0 , redDot = false }
skynet.server.gameServer:SendMsgToUser( player.userId , "CMD_S2C_StoreIconPopUp" , data1 )
end
end
--是否需要添加限时签到奖励
activitySignPack:ChangeStore(player,storeId)
--是否是进阶礼包
skynet.server.activityStagePack:CheckStagePack(player,storeId)
--是否是存钱罐
skynet.server.activitySavingPot:CheckSavingPotPack( player , storeId )
--复刻商店
skynet.server.activityReplicaStore:Charge( player , storeId )
--没有异常,添加灵感积分
if s2cData.code == 0 and cfgStorePack ~= nil
and 7 ~= storeId
and skynet.server.gameConfig:IsTest()
and(cfgStorePack.packExchange == nil or not next(cfgStorePack.packExchange))
and not isPay then--不是充值回调购买
self:ChangePayInfo(player , storeId)--处理积分相关问题
end
s2cData.cmd = pb.enum("MsgType","CMD_S2C_StoreBuy")
s2cData.data = assert(pb.encode("S2CStoreBuy", data))
end
--首充奖励显示
function Store:TopUpShow( player, c2sData , s2cData)
c2sData.data = assert(pb.decode("C2SStoreTopUpShow", c2sData.data ))
local data = {}
data.endTime = player.gameData.storePack.topUpEndTime
data.topUpInfos = {}
for k , v in pairs(player.gameData.storePack.topUpInfo) do
table.insert(data.topUpInfos , {day = v.day , rewardId = v.rewardId ,isGet = v.isGet})
end
s2cData.cmd = pb.enum("MsgType","CMD_S2C_StoreTopUpShow")
s2cData.data = assert(pb.encode("S2CStoreTopUpShow", data))
end
--首充奖励领取
function Store:TopUpGet( player, c2sData , s2cData)
c2sData.data = assert(pb.decode("C2SStoreTopUpGet", c2sData.data ))
local day = c2sData.data.day
local data = {}
data.topUpInfos = {}
local getAll = true --是否领取完毕
for k ,v in pairs(player.gameData.storePack.topUpInfo) do
if v.isGet == 1 and v.day == day then
data.rewardId = v.rewardId
--进行发放奖励
local eventId = pb.enum("EnumMoneyChangeEventID","EventID_69")
player:GiveReward(v.rewardId , eventId, 1)
v.isGet = 2
skynet.server.msgTips:Reduce(player , 48)
end
table.insert(data.topUpInfos , {day = v.day , rewardId = v.rewardId ,isGet = v.isGet})
if v.isGet ~= 2 then
getAll = false
end
end
if getAll then
player.gameData.storePack.topUpShow = false
player.gameData.storePack.topUpEndTime = 0
self:SendIconPackToUser(player)
end
s2cData.cmd = pb.enum("MsgType","CMD_S2C_StoreTopUpGet")
s2cData.data = assert(pb.encode("S2CStoreTopUpGet", data))
end
--积分奖励显示
function Store:PointsShow( player, c2sData , s2cData)
c2sData.data = assert(pb.decode("C2SStorePointsShow", c2sData.data ))
local data = {}
--获取配置文件SValue中的数据
local cfgSValue = skynet.server.gameConfig:GetPlayerAllCfg( player , "SValue")
--玩家积分
data.points = player.gameData.storePack.rechargeAmount * cfgSValue.valueAccumulatePoint
data.pointsInfos = {}
for k ,v in pairs(player.gameData.storePack.pointsInfo) do
table.insert(data.pointsInfos , v)
end
s2cData.cmd = pb.enum("MsgType","CMD_S2C_StorePointsShow")
s2cData.data = assert(pb.encode("S2CStorePointsShow", data))
end
--积分奖励领取
function Store:PointsGet( player, c2sData , s2cData)
c2sData.data = assert(pb.decode("C2SStorePointsGet", c2sData.data ))
local id = c2sData.data.id
local data = {}
data.id = id
data.pointsInfos = {}
--获取玩家对应配置文件ValueAccumulate
local cfgValueAccumulate = skynet.server.gameConfig:GetPlayerAllCfg( player , "ValueAccumulate")
for k ,v in pairs(player.gameData.storePack.pointsInfo) do
if v.id == id and v.isGet == 1 then
--进行发放奖励
local eventId = pb.enum("EnumMoneyChangeEventID","EventID_70")
player:GiveReward(cfgValueAccumulate[id].pointAward, eventId , 1)
v.isGet = 2
skynet.server.msgTips:Reduce(player , 49)
end
table.insert(data.pointsInfos,v)
end
s2cData.cmd = pb.enum("MsgType","CMD_S2C_StorePointsGet")
s2cData.data = assert(pb.encode("S2CStorePointsGet", data))
end
--月卡界面显示
function Store:MonthCardShow( player, c2sData , s2cData)
c2sData.data = assert(pb.decode("C2SStoreMonthCardShow", c2sData.data ))
local data = {}
data.buyStatus = player.gameData.storePack.monthCard.buyStatus
data.day = player.gameData.storePack.monthCard.day
data.getStatus = player.gameData.storePack.monthCard.getStatus
data.tryStatus = player.gameData.storePack.monthCard.tryStatus
s2cData.cmd = pb.enum("MsgType","CMD_S2C_StoreMonthCardShow")
s2cData.data = assert(pb.encode("S2CStoreMonthCardShow", data))
end
--月卡 购买
function Store:MonthCardBuy( player, c2sData , s2cData)
c2sData.data = assert(pb.decode("C2SStoreMonthCardBuy", c2sData.data ))
local data = {}
local storeId = c2sData.data.storeId
local cfgAllStorePrice = skynet.server.gameConfig:GetPlayerAllCfg( player , "StorePrice" )
local cfgStorePrice = {}
for k ,v in pairs(cfgAllStorePrice) do
if v.storePackId == storeId then
cfgStorePrice.price = v.price
break
end
end
if next(cfgStorePrice) == nil then
cfgStorePrice.price = 0
end
--获取配置文件SValue中的数据
local cfgSValue = skynet.server.gameConfig:GetPlayerAllCfg( player , "SValue")
--获取钻石/人民币比例
local diamondEXchange= cfgSValue.diamondEXchange[2]
--获取钻石
local diamond = skynet.server.bag:GetGoodsCount(player,dataType.GoodsType_Prop, 28)--钻石{官网充值送的道具skd那边叫代金券}是否足够【这里28代表是钻石】
if player.gameData.storePack.monthCard.day >= 180 then
s2cData.code=errorInfo.ErrorCode.LuxuryCardOver180Days
else
if (player.gameData.storePack.storePackInfo[storeId]~=nil and player.gameData.storePack.storePackInfo[storeId].buyStatus)
or skynet.server.gameConfig:IsTest()
or diamond * diamondEXchange >= cfgStorePrice.price then--钻石是否足够
--if true then
--先修改玩家月卡数据
player.gameData.storePack.monthCard.buyStatus = true
--处理月卡续费问题
if player.gameData.storePack.monthCard.day > 0 then
player.gameData.storePack.monthCard.getStatus = player.gameData.storePack.monthCard.getStatus
player.gameData.storePack.monthCard.day = player.gameData.storePack.monthCard.day + cfgSValue.monthCardTime
else
player.gameData.storePack.monthCard.day = cfgSValue.monthCardTime
--非续费发放对应权益,并且重置每日奖励获取状态
player.gameData.storePack.monthCard.getStatus = false
self:MonthCardPower(player)
--增加对应红点
skynet.server.msgTips:Add(player, 63)
end
--发放对应奖励
local eventId = pb.enum("EnumMoneyChangeEventID","EventID_20")
player:GiveReward(cfgSValue.monthCardReward , eventId , 1)
--玩家不存在月卡信息
if player.gameData.storePack.storePackInfo[storeId]==nil then
player.gameData.storePack.storePackInfo[storeId]={}
end
player.gameData.storePack.storePackInfo[storeId].buyStatus = false
--扣除钻石
if diamond * diamondEXchange >= cfgStorePrice.price then
log.debug(string.format("玩家 %s 购买月卡扣钻石 %s钻石%dcfgStorePrice.price:%d",player.userId,storeId,diamond,tostring(cfgStorePrice.price/ diamondEXchange)))
--扣除道具--道具id 是28 钻石 这里写死以往规则
skynet.server.bag:RemoveGoods(player,dataType.GoodsType_Prop, 28,tostring(cfgStorePrice.price/ diamondEXchange))
--添加相关日志
skynet.server.playerRecord:Add( player.userId , dataType.RecordType_101 , 0 , dataType.GoodsType_Prop, 28, tostring(cfgStorePrice.price/ diamondEXchange) )
end
end
end
data.buyStatus = player.gameData.storePack.monthCard.buyStatus
data.day = player.gameData.storePack.monthCard.day
data.getStatus = player.gameData.storePack.monthCard.getStatus
s2cData.cmd = pb.enum("MsgType","CMD_S2C_StoreMonthCardBuy")
s2cData.data = assert(pb.encode("S2CStoreMonthCardBuy", data))
end
--月卡 领取
function Store:MonthCardGet( player, c2sData , s2cData)
c2sData.data = assert(pb.decode("C2SStoreMonthCardGet", c2sData.data ))
local data = {}
--修改月卡本日领取状态
if player.gameData.storePack.monthCard.buyStatus and not player.gameData.storePack.monthCard.getStatus then
player.gameData.storePack.monthCard.getStatus = true
else
return
end
--发奖修改为宝盒抽奖+固定奖励
local cfgSValue = skynet.server.gameConfig:GetPlayerAllCfg( player , "SValue")
local eventId = pb.enum("EnumMoneyChangeEventID","EventID_71")
local allRewardId = skynet.server.common:DeepCopy(cfgSValue.monthCardRewardId) --所有奖励的id
local rewardCount = cfgSValue.monthCardRewardNum --可以获取的数量
local rewardChance = skynet.server.common:DeepCopy(cfgSValue.monthCardRewardRatio) --对应奖励id的获取概率
local getRewardId = {} --本次获得的奖励id
for i = 1, rewardCount , 1 do
--记录本次抽奖的所有概率
local allChance = 0
for k , v in pairs(rewardChance) do
allChance = allChance + v * 100
end
--开始抽奖
local number = math.random(1,allChance)
local count = 0
for k , v in pairs(rewardChance) do
if number <= v * 100 + count then
--发放对应奖励
player:GiveReward(allRewardId[ k ] , eventId , 1)
table.insert(getRewardId ,allRewardId[ k ])
--移除对应奖励 防止重复发送
table.remove(allRewardId , k)
table.remove(rewardChance , k)
break
else
count = count + v * 100
end
end
end
--发放对应固定奖励
player:GiveReward(cfgSValue.monthCardDaily , eventId , 1)
skynet.server.msgTips:ReduceAll(player, 63)
data.buyStatus = player.gameData.storePack.monthCard.buyStatus
data.day = player.gameData.storePack.monthCard.day
table.insert(getRewardId , cfgSValue.monthCardDaily)
data.rewardIds = getRewardId
data.getStatus = player.gameData.storePack.monthCard.getStatus
s2cData.cmd = pb.enum("MsgType","CMD_S2C_StoreMonthCardGet")
s2cData.data = assert(pb.encode("S2CStoreMonthCardGet", data))
end
--限购礼包活动 显示
function Store:LimitPackShow( player, c2sData , s2cData)
c2sData.data = assert(pb.decode("C2SStoreLimitPackShow", c2sData.data ))
local data = {}
data.storeInfos = {}
--获取本次限购礼包活动的id
if player.gameData.activityManage[ dataType.ActivityType_AdvancePack ].id > 0 then
local activityId = skynet.server.gameConfig:GetPlayerCurCfg( player , "Activity" ,
player.gameData.activityManage[ dataType.ActivityType_AdvancePack ].id).activityId
local packIds = skynet.server.gameConfig:GetPlayerCurCfg( player , "AdvancePack" , activityId).packId
for k , v in pairs(packIds) do
local packInfo = player.gameData.storePack.storePackInfo[ v ]
table.insert(data.storeInfos , {storeId = v ,buyTimes = packInfo.buyTimes ,failureTime = 0,redDot = false})
--消除对应商城红点
if skynet.server.msgTips:GetOneTips(player , 29).count > 0 then
skynet.server.msgTips:Reduce(player , 29)
end
end
end
s2cData.cmd = pb.enum("MsgType","CMD_S2C_StoreLimitPackShow")
s2cData.data = assert(pb.encode("S2CStoreLimitPackShow", data))
end
--免费体验月卡
function Store:MonthCardTry( player, c2sData, s2cData)
c2sData.data = assert(pb.decode("C2SStoreMonthCardTry", c2sData.data ))
local data = {}
--判断玩家是否已经领取过体验卡
if not player.gameData.storePack.monthCard.tryStatus then
local cfgSValue = skynet.server.gameConfig:GetPlayerAllCfg( player , "SValue")
--判断玩家是否已经购买过月卡
if player.gameData.storePack.monthCard.buyStatus then
--购买过的就增加一天月卡时间
player.gameData.storePack.monthCard.day = player.gameData.storePack.monthCard.day + cfgSValue.monthCardFreeTime
player.gameData.storePack.monthCard.tryStatus = true
--消除对应红点
skynet.server.msgTips:Reduce(player, 95)
else
--先修改玩家月卡数据
player.gameData.storePack.monthCard.buyStatus = true
player.gameData.storePack.monthCard.day = cfgSValue.monthCardFreeTime - 1
player.gameData.storePack.monthCard.getStatus = false
--增加对应红点
skynet.server.msgTips:Add(player, 63)
--只发放对应权益
self:MonthCardPower(player)
player.gameData.storePack.monthCard.tryStatus = true
--消除对应红点
skynet.server.msgTips:Reduce(player, 95)
end
end
data.buyStatus = player.gameData.storePack.monthCard.buyStatus
data.day = player.gameData.storePack.monthCard.day
data.getStatus = player.gameData.storePack.monthCard.getStatus
data.tryStatus = player.gameData.storePack.monthCard.tryStatus
s2cData.cmd = pb.enum("MsgType","CMD_S2C_StoreMonthCardTry")
s2cData.data = assert(pb.encode("S2CStoreMonthCardTry", data))
end
--拍屏礼包管理
function Store:IconPopUp( player , c2sData , s2cData)
c2sData.data = assert(pb.decode("C2SStoreIconPopUp", c2sData.data ))
local popUpStoreInfo = c2sData.data.popUpStoreInfo
local data = {}
for k , v in pairs(player.gameData.storePack.popupPackInfo) do
if v.id == popUpStoreInfo.storeId and v.type ~= self.PopUpPack_Every then
v.status = 2
break
end
end
data.popUpStoreInfo = popUpStoreInfo
s2cData.cmd = pb.enum("MsgType","CMD_S2C_StoreIconPopUp")
s2cData.data = assert(pb.encode("S2CStoreIconPopUp", data))
end
--礼包头条展示 暂时没用
function Store:PackHeadline( player , c2sData , s2cData)
c2sData.data = assert(pb.decode("C2SStorePackHeadline", c2sData.data ))
local data = {}
local packUI = c2sData.data.packUI
data.storeInfos = {}
local count = 0 --进行显示的礼包当前数量
local maxCount = skynet.server.gameConfig:GetPlayerAllCfg( player , "SValue").recommendPackMax
for k , v in pairs(player.gameData.storePack.storePackInfo) do
local cfgOneStorePack = skynet.server.gameConfig:GetPlayerCurCfg( player , "StorePack" , v.storeId)
--判断是否是需要进行头条展示的礼包
if cfgOneStorePack.display > 0 and cfgOneStorePack.packUI == packUI then
local nowTime = skynet.GetTime()
--将满足条件的礼包进行显示
if v.failureTime ~= nil and nowTime < v.failureTime then
--处理有独立的失效时间的礼包
if v.look and v.IsShow then
--已经看过且还可以展示的礼包
table.insert(data.storeInfos , {storeId=v.id , buyTimes=v.buyTimes , failureTime = v.failureTime , redDot = false})
count = count + 1
elseif not v.look and v.IsShow then
table.insert(data.storeInfos , {storeId=v.id , buyTimes=v.buyTimes , failureTime = v.failureTime , redDot = true})
count = count + 1
end
elseif v.failureTime == nil then
--处理没有独立失效时间的礼包
local startTime = 0 --礼包对应的生效时间
local endTime = 0 --礼包对应的失效时间
--处理一下礼包时间
if cfgOneStorePack.startTime ~= nil and cfgOneStorePack.startTime ~= '' then
startTime = skynet.server.common:GetTime(cfgOneStorePack.startTime)
endTime = skynet.server.common:GetTime(cfgOneStorePack.endTime)
end
--确保礼包已经开始售卖
if nowTime >= startTime and endTime == 0 then
if v.look and v.IsShow then
table.insert(data.storeInfos , {storeId=v.id , buyTimes=v.buyTimes , failureTime = endTime , redDot = false})
count = count + 1
elseif not v.look and v.IsShow then
table.insert(data.storeInfos , {storeId=v.id , buyTimes=v.buyTimes , failureTime = endTime , redDot = true})
count = count + 1
end
elseif nowTime >= startTime and endTime ~= 0 and nowTime < endTime then
if v.look and v.IsShow then
table.insert(data.storeInfos , {storeId=v.id , buyTimes=v.buyTimes , failureTime = endTime , redDot = false})
count = count + 1
elseif not v.look and v.IsShow then
table.insert(data.storeInfos , {storeId=v.id , buyTimes=v.buyTimes , failureTime = endTime , redDot = true})
count = count + 1
end
end
end
--达到最大数量就直接退出
if count == maxCount then
break
end
end
end
s2cData.cmd = pb.enum("MsgType","CMD_S2C_StorePackHeadline")
s2cData.data = assert(pb.encode("S2CStorePackHeadline", data))
end
--成长基金展示
function Store:GrowthFundShow( player , c2sData , s2cData)
c2sData.data = assert(pb.decode("C2SStoreGrowthFundShow", c2sData.data ))
local data = {}
--根据成长基金显示的规则 返回玩家对应数据
local level = player.gameData.level
for k , v in pairs(player.gameData.storePack.growthFund.rewardInfos) do
--优先显示购买且已完成的成长基金
if v.status == 2 then
data.id = v.id
data.status = v.status
break
else
local cfgOneGrowthFund = skynet.server.gameConfig:GetPlayerCurCfg( player , "GrowthFund" , v.id)
if level < cfgOneGrowthFund.level then
data.id = v.id
data.status = v.status
break
end
end
end
s2cData.cmd = pb.enum("MsgType","CMD_S2C_StoreGrowthFundShow")
s2cData.data = assert(pb.encode("S2CStoreGrowthFundShow", data))
end
--成长基金获取
function Store:GrowthFundGet( player , c2sData , s2cData)
c2sData.data = assert(pb.decode("C2SStoreGrowthFundGet", c2sData.data ))
local data = {}
local id = c2sData.data.id
for k , v in pairs(player.gameData.storePack.growthFund.rewardInfos) do
if v.id == id and v.status == 2 then
--发放对应奖励
local cfgOneGrowthFund = skynet.server.gameConfig:GetPlayerCurCfg( player , "GrowthFund" , v.id)
local eventId = pb.enum("EnumMoneyChangeEventID","EventID_69")
player:GiveReward(cfgOneGrowthFund.rewardId , eventId, 1)
v.status = 3
data.rewardId = cfgOneGrowthFund.rewardId
end
end
--判断成长基金是否还需要展示
if id == #player.gameData.storePack.growthFund.rewardInfos then
player.gameData.storePack.growthFund.canShow = false
data.id = 0
data.status = 0
data.canShow = false
else
local rewardInfo = player.gameData.storePack.growthFund.rewardInfos[ id+1 ]
data.id = rewardInfo.id
data.status = rewardInfo.id
data.canShow = true
end
s2cData.cmd = pb.enum("MsgType","CMD_S2C_StoreGrowthFundGet")
s2cData.data = assert(pb.encode("S2CStoreGrowthFundGet", data))
end
--礼包是否还可以进行购买
function Store:CanBuy( player , c2sData , s2cData)
c2sData.data = assert(pb.decode("C2SStoreCanBuy", c2sData.data ))
local data = {}
local storeId = c2sData.data.storeId
local buyCount = c2sData.data.buyCount
data.storeId = storeId
data.buyCount = buyCount
if storeId == 7 then
--通行证
if player.gameData.passCheck.isVip then
data.canBuy = false
else
data.canBuy = true
end
elseif storeId == 61 then
--月卡
if player.gameData.storePack.monthCard.buyStatus then
if player.gameData.storePack.monthCard.day < 180 then
data.canBuy = true
else
data.canBuy = false
end
else
data.canBuy = true
end
elseif storeId == 225 then
--豪华月卡
if not skynet.server.luxuryCard:IsReBuy( player ) then
s2cData.code=errorInfo.ErrorCode.LuxuryCardOver180Days
data.canBuy = false
else
data.canBuy = true
end
else
local cfgOneStorePack = skynet.server.gameConfig:GetPlayerCurCfg( player , "StorePack" , storeId)
if next(cfgOneStorePack.packLimit) == nil then
--如果没有购买限制 则判断当前时间是否可以购买
if cfgOneStorePack.startTime == nil or cfgOneStorePack.startTime == '' then
data.canBuy = true
else
local startTime = skynet.server.common:GetTime(cfgOneStorePack.startTime)
local endTime = skynet.server.common:GetTime(cfgOneStorePack.endTime)
if skynet.GetTime() >= startTime and skynet.GetTime() < endTime then
data.canBuy = true
else
data.canBuy = false
end
end
else
--有限制的礼包 需判断当前时间和购买数量是否符合
for k ,v in pairs(player.gameData.storePack.storePackInfo) do
if v.storeId == storeId then
if v.buyTimes + buyCount > v.packLimit[2] then
--超出购买限制
data.canBuy = false
else
--还可以进行购买 判断当前时间是否满足
local startTime = 0 --礼包对应的生效时间
local endTime = 0 --礼包对应的失效时间
--处理一下礼包时间
if cfgOneStorePack.startTime ~= nil and cfgOneStorePack.startTime ~= '' then
startTime = skynet.server.common:GetTime(cfgOneStorePack.startTime)
endTime = skynet.server.common:GetTime(cfgOneStorePack.endTime)
end
if skynet.GetTime() >= startTime then
if v.failureTime == nil and endTime == 0 then
--没有时间限制
data.canBuy = true
elseif v.failureTime == nil and endTime ~= 0 and skynet.GetTime() <= endTime then
data.canBuy = true
elseif v.failureTime ~= nil and skynet.GetTime() <= v.failureTime then
data.canBuy = true
else
data.canBuy = false
end
else
data.canBuy = false
end
end
break
end
end
end
end
s2cData.cmd = pb.enum("MsgType","CMD_S2C_StoreCanBuy")
s2cData.data = assert(pb.encode("S2CStoreCanBuy", data))
end
--客户端确认商城礼包收货
function Store:ConfirmReceipt( player , c2sData , s2cData)
c2sData.data = assert(pb.decode("C2SConfirmReceiptStoreBuy", c2sData.data ))
local data = {}
local storeId = c2sData.data.storeId
local buyCount = c2sData.data.buyCount
for k , v in pairs(player.tmpData.sendStorePackIds) do
if v == storeId then
table.remove(player.tmpData.sendStorePackIds , k)
log.info(string.format("玩家 %s 购买礼包 %d 数量 %d 成功 可以移除相关数据" , player.account , storeId , buyCount))
break
end
end
s2cData.cmd = pb.enum("MsgType","CMD_S2C_ConfirmReceiptStoreBuy")
s2cData.data = assert(pb.encode("S2CConfirmReceiptStoreBuy", data))
end
--月卡权益 进行发放权益和收缴权益
function Store:MonthCardPower( player)
--获取配置文件SValue中的数据
local cfgSValue = skynet.server.gameConfig:GetPlayerAllCfg( player , "SValue")
if player.gameData.storePack.monthCard.buyStatus then
--巧手工坊权益
skynet.server.dyeworkshop:UnlockByMonthCard(player)
skynet.server.furnitureWorkShop:UnlockByMonthCard(player)
--月卡 头像&头像框
local monthCardHeadFrame = cfgSValue.monthCardHeadFrame --头像id 头像框id
skynet.server.personal:ChangeGainInfo(player , dataType.GoodsType_HeadAndHeadFrame , monthCardHeadFrame[ 1 ] , dataType.HeadType_Head , skynet.server.personal.AddGoods)
skynet.server.personal:ChangeGainInfo(player , dataType.GoodsType_HeadAndHeadFrame , monthCardHeadFrame[ 2 ] , dataType.HeadType_Frame , skynet.server.personal.AddGoods)
--主动推送一下玩家个人信息
local data = {}
data.newOwn = {}
table.insert(data.newOwn , {ownType = 1 , ownId = monthCardHeadFrame[ 1 ]})
table.insert(data.newOwn , {ownType = 2 , ownId = monthCardHeadFrame[ 2 ]})
skynet.server.gameServer:SendMsgToUser( player.userId , "CMD_S2C_PersonalUpdateOwnInfo" , data )
else
--移除 巧手工坊权益
skynet.server.dyeworkshop:UnlockByMonthCard(player)
skynet.server.furnitureWorkShop:UnlockByMonthCard(player)
--移除月卡 头像&头像框 同时设置玩家默认头像&头像框
local monthCardHeadFrame = cfgSValue.monthCardHeadFrame --头像id 头像框id
skynet.server.personal:ChangeGainInfo(player , dataType.GoodsType_HeadAndHeadFrame , monthCardHeadFrame[ 1 ] , dataType.HeadType_Head , skynet.server.personal.DelGoods)
skynet.server.personal:ChangeGainInfo(player , dataType.GoodsType_HeadAndHeadFrame , monthCardHeadFrame[ 2 ] , dataType.HeadType_Frame , skynet.server.personal.DelGoods)
if player.gameData.personal.headId == monthCardHeadFrame[ 1 ] then
player.gameData.personal.headId = 1
end
if player.gameData.personal.headFrameId == monthCardHeadFrame[ 2 ] then
player.gameData.personal.headFrameId = 13
end
end
end
--月卡权益 获取玩家的时间提速系数
function Store:GetTimeCoefficient( player , typeId)
--获取配置文件SValue中的数据
local cfgSValue = skynet.server.gameConfig:GetPlayerAllCfg( player , "SValue")
if player.gameData.storePack and player.gameData.storePack.monthCard.buyStatus then
return cfgSValue.monthCardSpeedTime[ typeId ]
else
return 1
end
end
--限时卡池十连抽触发礼包
function Store:TriggerPackMultiDraw(player,raffle)
local cfgSValue = skynet.server.gameConfig:GetPlayerAllCfg( player , "SValue")
local cfgStorePack = skynet.server.gameConfig:GetPlayerAllCfg( player , "StorePack")
--确保玩家已经解锁商城了
if player.gameData.level < cfgSValue.storeUnlockLvl then
return true
end
--抽取了十连抽后解锁对应礼包
local limitSpecialBag = raffle.rafflePack
--如果不存在该礼包 则添加该礼包
if not player.gameData.storePack.storePackInfo[limitSpecialBag[1]] then
local count = limitSpecialBag[1]
player.gameData.storePack.storePackInfo[ count ] = {}
player.gameData.storePack.storePackInfo[ count ].storeId = cfgStorePack[limitSpecialBag[1]].id --礼包id
player.gameData.storePack.storePackInfo[ count ].buyTimes = 0 --玩家购买的次数
player.gameData.storePack.storePackInfo[ count ].historyBuyTimes = 0 --玩家历史购买次数
player.gameData.storePack.storePackInfo[ count ].buyStatus = false --玩家是否购买该礼包 付费成功 改为true ; 发放奖励后 改为false
player.gameData.storePack.storePackInfo[ count ].packLimit = cfgStorePack[limitSpecialBag[1]].packLimit --礼包对应的购买次数 例 [1,2] (1日限购 2周限购 3限购购买) 每日限购2次
player.gameData.storePack.storePackInfo[ count ].look = false --玩家是否看过该礼包(配合限时礼包)
--同时添加该礼包的存在时间
player.gameData.storePack.storePackInfo[ count ].startTime = skynet.GetTime()
player.gameData.storePack.storePackInfo[ count ].failureTime = skynet.GetTime() + limitSpecialBag[2] * 60
player.gameData.storePack.storePackInfo[ count ].IsShow = true --是否继续展示packLimit[0] = 3 ,即限制购买的礼包 默认为true
player.gameData.storePack.storePackInfo[ count ].buyTime = 0 --该礼包的购买时间
end
self:SendIconPackToUser( player )
--player.gameData.onceSign.isFirstMultiDraw = true
end
--限时卡池 购买商城礼包触发礼包
function Store:DesignTriggerPackByBuy(player , storeId)
local cfgStorePack = skynet.server.gameConfig:GetPlayerAllCfg( player , "StorePack")
-- --确保当前有开启的限时卡池
-- if next(player.gameData.design.timeCardPoolInfo) == nil then
-- return true
-- end
--获取对应卡池信息
local cfgRaffle = skynet.server.raffle:GetCfgRaffleByRaffleType( player , {skynet.server.raffle.LotteryType_3,skynet.server.raffle.LotteryType_4} )
if cfgRaffle== nil then
return true
end
--local cfgRaffle = skynet.server.gameConfig:GetPlayerCurCfg( player , "Raffle" , cfgRaffle.id)
local limitGiftBag = cfgRaffle.packId --触发限时卡池的限时礼包的商城礼包id
local limitGiftBagTime = cfgRaffle.triggerPack --竹影礼包的数据 礼包id 存在时间
for k , v in pairs(limitGiftBag) do
if storeId == v and not player.gameData.storePack.storePackInfo[limitGiftBagTime[1]] then
self:InitData(player)
--主动推送一下对应礼包的packUI的信息
local c2sData1 = {}
local s2cData1 = {}
local showData = {}
showData.packUI = skynet.server.gameConfig:GetPlayerCurCfg( player , "StorePack" , limitGiftBagTime[1]).packUI
c2sData1.data = assert(pb.encode("C2SStoreShow", showData))
self:Show(player , c2sData1 , s2cData1)
local data1 = assert(pb.decode("S2CStoreShow", s2cData1.data))
skynet.server.gameServer:SendMsgToUser(player.userId, "CMD_S2C_StoreShow", data1)
elseif player.gameData.storePack.storePackInfo[limitGiftBagTime[1]] then
--已经触发过的话直接退出
break
end
end
end
--特殊触发礼包 等级礼包和道具礼包
function Store:TriggerPack( player , packType )
local cfgSValue = skynet.server.gameConfig:GetPlayerAllCfg( player , "SValue")
local cfgStorePack = skynet.server.gameConfig:GetPlayerAllCfg( player , "StorePack")
--确保玩家已经解锁商城了
if player.gameData.level < cfgSValue.storeUnlockLvl then
player.gameData.todayGain.updateUseCount = 0
player.gameData.todayGain.speedUpUseCount = 0
player.gameData.todayGain.plantUseCount = 0
return true
end
--存储对应礼包相关信息
local packInfo = {}
--加个标识,用来区分新礼包和旧礼包
local tag = 0
if self.TriggerPack_Update == packType then
--使用n次蜗壳币刷新触发刷新券礼包礼包有效时间(分钟),触发次数/天 例 2,58,120,1
packInfo = cfgSValue.triggerUpdatePack
--判断是否满足触发条件
if player.gameData.todayGain.updateUseCount ~= packInfo[ 1 ] then
return
end
return
elseif self.TriggerPack_SpeedUp == packType then
packInfo = cfgSValue.triggerSpeedUpPack
--判断是否满足触发条件
if player.gameData.todayGain.speedUpUseCount ~= packInfo[ 1 ] then
return
end
return
elseif self.TriggerPack_Plant == packType then
packInfo = cfgSValue.triggerPlantPack
--判断是否满足触发条件
if player.gameData.todayGain.plantUseCount ~= packInfo[ 1 ] then
return
end
return
elseif self.TriggerPack_UpGrade == packType then
--等级礼包的触发条件在其他地方进行判断
packInfo = cfgSValue.triggerUpgradePack
elseif self.TriggerPack_NewPlayerClothes == packType then
packInfo = cfgSValue.newPlayerTriggerPack
elseif self.TriggerPack_NewPlayerNormal == packType then
--新手实惠礼包触发条件等级≤n,x小时内手动刷新闲菜二手y次,触发礼包id,持续时间/小时)
packInfo = cfgSValue.newplayerNormalPack
tag = 1
elseif self.TriggerPack_NewPlayerFurniture == packType then
--新手实惠礼包触发条件等级≤n,x小时内手动刷新闲菜二手y次,触发礼包id,持续时间/小时)
packInfo = cfgSValue.newplayerFurniturePack
tag = 1
elseif self.TriggerPack_NewPlayerClothesPack == packType then
--逐浪新衣礼包触发条件未获得完整套装n,x小时内手动刷新优衣服饰y次,触发礼包id,持续时间/小时)
packInfo = cfgSValue.newplayerClothesPack
tag = 1
end
--如果不存在该礼包 则添加该礼包
if tag == 0 then
if not player.gameData.storePack.storePackInfo[ packInfo[2] ] and self.TriggerPack_NewPlayerClothes ~= packType then
local count = packInfo[2]
player.gameData.storePack.storePackInfo[ count ] = {}
player.gameData.storePack.storePackInfo[ count ].storeId = cfgStorePack[packInfo[2]].id --礼包id
player.gameData.storePack.storePackInfo[ count ].buyTimes = 0 --玩家购买的次数
player.gameData.storePack.storePackInfo[ count ].historyBuyTimes = 0 --玩家历史购买次数
player.gameData.storePack.storePackInfo[ count ].buyStatus = false --玩家是否购买该礼包 付费成功 改为true ; 发放奖励后 改为false
player.gameData.storePack.storePackInfo[ count ].packLimit = cfgStorePack[packInfo[2]].packLimit --礼包对应的购买次数 例 [1,2] (1日限购 2周限购 3限购购买) 每日限购2次
player.gameData.storePack.storePackInfo[ count ].look = false --玩家是否看过该礼包(配合限时礼包)
--同时添加该礼包的存在时间
player.gameData.storePack.storePackInfo[ count ].startTime = skynet.GetTime()
player.gameData.storePack.storePackInfo[ count ].failureTime = skynet.GetTime() + packInfo[3] * 60
player.gameData.storePack.storePackInfo[ count ].IsShow = true --是否继续展示packLimit[0] = 3 ,即限制购买的礼包 默认为true
player.gameData.storePack.storePackInfo[ count ].buyTime = 0 --该礼包的购买时间
elseif not player.gameData.storePack.storePackInfo[ packInfo[1] ] and self.TriggerPack_NewPlayerClothes == packType then
local count = packInfo[1]
player.gameData.storePack.storePackInfo[ count ] = {}
player.gameData.storePack.storePackInfo[ count ].storeId = cfgStorePack[packInfo[1]].id --礼包id
player.gameData.storePack.storePackInfo[ count ].buyTimes = 0 --玩家购买的次数
player.gameData.storePack.storePackInfo[ count ].historyBuyTimes = 0 --玩家历史购买次数
player.gameData.storePack.storePackInfo[ count ].buyStatus = false --玩家是否购买该礼包 付费成功 改为true ; 发放奖励后 改为false
player.gameData.storePack.storePackInfo[ count ].packLimit = cfgStorePack[packInfo[1]].packLimit --礼包对应的购买次数 例 [1,2] (1日限购 2周限购 3限购购买) 每日限购2次
player.gameData.storePack.storePackInfo[ count ].look = false --玩家是否看过该礼包(配合限时礼包)
--同时添加该礼包的存在时间
player.gameData.storePack.storePackInfo[ count ].startTime = skynet.GetTime()
player.gameData.storePack.storePackInfo[ count ].failureTime = skynet.GetTime() + (packInfo[3] * dataType.OneDaySec)
player.gameData.storePack.storePackInfo[ count ].IsShow = true --是否继续展示packLimit[0] = 3 ,即限制购买的礼包 默认为true
player.gameData.storePack.storePackInfo[ count ].buyTime = 0 --该礼包的购买时间
else
--存在该礼包 如果是可重复触发的礼包 则再重新修改对应数据
if self.TriggerPack_UpGrade == packType then
--等级触发礼包单独处理
if not skynet.server.common:IsSameDay(player.gameData.storePack.storePackInfo[ packInfo[2] ].startTime , skynet.GetTime()) then
local count = packInfo[2]
player.gameData.storePack.storePackInfo[ count ].buyTimes = 0
player.gameData.storePack.storePackInfo[ count ].look = false --玩家是否看过该礼包(配合限时礼包)
--同时修改该礼包的存在时间
player.gameData.storePack.storePackInfo[ count ].startTime = skynet.GetTime()
player.gameData.storePack.storePackInfo[ count ].failureTime = skynet.GetTime() + packInfo[3] * 60
player.gameData.storePack.storePackInfo[ count ].IsShow = true --继续展示该礼包
end
else
local count = packInfo[2]
player.gameData.storePack.storePackInfo[ count ].buyTimes = 0
player.gameData.storePack.storePackInfo[ count ].look = false --玩家是否看过该礼包(配合限时礼包)
--同时修改该礼包的存在时间
player.gameData.storePack.storePackInfo[ count ].startTime = skynet.GetTime()
player.gameData.storePack.storePackInfo[ count ].failureTime = skynet.GetTime() + packInfo[3] * 60
player.gameData.storePack.storePackInfo[ count ].IsShow = true --继续展示该礼包
end
end
else
if not player.gameData.storePack.storePackInfo[ packInfo[4] ] then
local count = packInfo[4]
player.gameData.storePack.storePackInfo[ count ] = {}
player.gameData.storePack.storePackInfo[ count ].storeId = cfgStorePack[packInfo[4]].id --礼包id
player.gameData.storePack.storePackInfo[ count ].buyTimes = 0 --玩家购买的次数
player.gameData.storePack.storePackInfo[ count ].historyBuyTimes = 0 --玩家历史购买次数
player.gameData.storePack.storePackInfo[ count ].buyStatus = false --玩家是否购买该礼包 付费成功 改为true ; 发放奖励后 改为false
player.gameData.storePack.storePackInfo[ count ].packLimit = cfgStorePack[packInfo[4]].packLimit --礼包对应的购买次数 例 [1,2] (1日限购 2周限购 3限购购买) 每日限购2次
player.gameData.storePack.storePackInfo[ count ].look = false --玩家是否看过该礼包(配合限时礼包)
--同时添加该礼包的存在时间
player.gameData.storePack.storePackInfo[ count ].startTime = skynet.GetTime()
player.gameData.storePack.storePackInfo[ count ].failureTime = skynet.GetTime() + packInfo[5] * 3600
player.gameData.storePack.storePackInfo[ count ].IsShow = true --是否继续展示packLimit[0] = 3 ,即限制购买的礼包 默认为true
player.gameData.storePack.storePackInfo[ count ].buyTime = 0 --该礼包的购买时间
if cfgStorePack[packInfo[4]].mainFormPopUp ~= nil and cfgStorePack[packInfo[4]].mainFormPopUp ~= "" then
table.insert(player.gameData.storePack.popupPackInfo ,{id = count , status = 1 , type = cfgStorePack[packInfo[4]].mainFormPopUp })
end
else
--如果未购买过则刷新,已经买过了就不再重置
if player.gameData.storePack.storePackInfo[ packInfo[4] ].buyTimes == 0 then
local count = packInfo[4]
player.gameData.storePack.storePackInfo[ count ].look = false --玩家是否看过该礼包(配合限时礼包)
--同时修改该礼包的存在时间
player.gameData.storePack.storePackInfo[ count ].startTime = skynet.GetTime()
player.gameData.storePack.storePackInfo[ count ].failureTime = skynet.GetTime() + packInfo[5] * 3600
player.gameData.storePack.storePackInfo[ count ].IsShow = true --继续展示该礼包
end
end
end
self:SendIconPackToUser( player )
end
--主动推送含有icon的可购买礼包
function Store:SendIconPackToUser( player )
local cfgStorePack = skynet.server.gameConfig:GetPlayerAllCfg( player , "StorePack")
local data = {}
data.storeInfos ={}
local nowTime = skynet.GetTime()
--找到该玩家还可以购买含有icon的所有礼包
for k , v in pairs(cfgStorePack) do
if v.icon ~= nil and v.icon~="" then
for k1 , v1 in pairs(player.gameData.storePack.storePackInfo) do
if v.id == v1.storeId and not v1.look and v1.buyTimes < v1.packLimit[ 2 ] and v1.IsShow and nowTime >= v1.startTime and nowTime < v1.failureTime then
table.insert(data.storeInfos , {storeId=v.id , buyTimes=v1.buyTimes , failureTime = v1.failureTime ,redDot = true})
elseif v.id == v1.storeId and v1.look and v1.buyTimes < v1.packLimit[ 2 ] and v1.IsShow and nowTime >= v1.startTime and nowTime < v1.failureTime then
table.insert(data.storeInfos , {storeId=v.id , buyTimes=v1.buyTimes , failureTime = v1.failureTime ,redDot = false})
end
end
end
end
--是否给玩家显示商城首充赠礼
local getAll = true --是否领取完毕
local start = false --是否开启首充
for k ,v in pairs(player.gameData.storePack.topUpInfo) do
if v.isGet > 0 then
start = true
end
if v.isGet ~= 2 then
getAll = false
end
end
if not start and not getAll then
getAll = true
end
if not getAll then
data.canShowStoreTopUp = true
else
if start then
data.canShowStoreTopUp = false
elseif nowTime >= player.gameData.storePack.topUpEndTime and not start then
data.canShowStoreTopUp = false
elseif nowTime < player.gameData.storePack.topUpEndTime and not start then
data.canShowStoreTopUp = true
end
end
data.storeTopUpFailureTime = player.gameData.storePack.topUpEndTime
skynet.server.gameServer:SendMsgToUser( player.userId , "CMD_S2C_StoreIconShow" , data )
end
--登录的时候主动推送一次月卡信息
function Store:SendMonthCardInfoToUser( player )
local data = {}
if player.gameData.storePack then
data.buyStatus = player.gameData.storePack.monthCard.buyStatus
data.day = player.gameData.storePack.monthCard.day
data.getStatus = player.gameData.storePack.monthCard.getStatus
data.tryStatus = player.gameData.storePack.monthCard.tryStatus
end
skynet.server.gameServer:SendMsgToUser( player.userId , "CMD_S2C_StoreMonthCardShow" , data )
end
--礼包购买
function Store:Pay( player , storeId , s2cData )
local c2sData = {}
local buyData = {}
buyData.storeId = storeId
--充值礼包默认为1
buyData.buyCount = 1
if storeId == 61 then
c2sData.data = assert(pb.encode("C2SStoreMonthCardBuy", buyData))
elseif storeId == 225 then
c2sData.data = assert(pb.encode("C2SLuxuryMonthCardBuy", buyData))
else
c2sData.data = assert(pb.encode("C2SStoreBuy", buyData))
end
if not player.gameData.storePack.storePackInfo[storeId] then
--这里为空,可能存在补发充值,因为商城相关的充值已经关了,数据也不会有。所以这里可以直接发放礼包。
if 61 == storeId or 225 == storeId then
--!!!!如果61和225没有初始化可能发不了这两个礼包后面空了看一下有可能还没初始化这块数据玩家就充值了月卡和豪华月卡
local cfgStorePack = skynet.server.gameConfig:GetPlayerAllCfg( player , "StorePack") --获取玩家对应配置文件StorePack
local curStoreCfg = cfgStorePack[storeId]
player.gameData.storePack.storePackInfo[ storeId ] = {}
player.gameData.storePack.storePackInfo[ storeId ].storeId = curStoreCfg.id --礼包id
player.gameData.storePack.storePackInfo[ storeId ].buyTimes = 0 --玩家购买的次数
player.gameData.storePack.storePackInfo[ storeId ].historyBuyTimes = 0 --玩家历史购买次数
player.gameData.storePack.storePackInfo[ storeId ].buyStatus = false --玩家是否购买该礼包 付费成功 改为true ; 发放奖励后 改为false
player.gameData.storePack.storePackInfo[ storeId ].packLimit = curStoreCfg.packLimit --礼包对应的购买次数 例 [1,2] (1日限购 2周限购 3限购购买) 每日限购2次
if curStoreCfg.startTime ~= nil and curStoreCfg.startTime ~= '' then
player.gameData.storePack.storePackInfo[ storeId ].look = false --玩家是否看过该礼包(配合限时礼包)
else
player.gameData.storePack.storePackInfo[ storeId ].look = true --普通礼包不用该字段
end
player.gameData.storePack.storePackInfo[ storeId ].IsShow = true --是否继续展示packLimit[0] = 3 ,即限制购买的礼包 默认为true
--如果有主入口界面显示 同时添加该礼包的存在时间
if curStoreCfg.icon ~= nil and curStoreCfg.icon ~= "" then
player.gameData.storePack.storePackInfo[ storeId ].startTime = skynet.server.common:GetTime(curStoreCfg.startTime)
player.gameData.storePack.storePackInfo[ storeId ].failureTime = skynet.server.common:GetTime(curStoreCfg.endTime)
end
player.gameData.storePack.storePackInfo[ storeId ].buyTime = 0 --该礼包的购买时间
log.info(string.format("玩家 %d 月卡或者豪华月卡为啥会是空的,这里再初始化一下 充值ID %d ",player.userId, storeId ))
else
local cfgStorePack = skynet.server.gameConfig:GetPlayerCurCfg( player , "StorePack" , storeId)
local cfgAllStorePrice = skynet.server.gameConfig:GetPlayerAllCfg( player , "StorePrice")
local rewardId = cfgStorePack.rewardId
if not rewardId then
local eventId = pb.enum("EnumMoneyChangeEventID","EventID_123")
self:GiveReward( rewardId , eventId)
end
--找到对应礼包充值价值
local payPrice = 0
for k , v in pairs(cfgAllStorePrice) do
if v.storePackId == storeId then
payPrice = v.price
break
end
end
if payPrice ~= 0 then
--修改玩家的充值额度
player.gameData.storePack.rechargeAmount = player.gameData.storePack.rechargeAmount + ( payPrice / 100 )
local myPartnerId = player.gameData.partner.id
skynet.server.personal:SetDetail( myPartnerId , "rechargeAmount" , player.gameData.storePack.rechargeAmount )
end
log.info(string.format("玩家 %d 商城礼包已经过期,需要单独补发相关充值物品 充值ID %d ",player.userId, storeId ))
return
end
end
--将对应礼包的购买状态置为 true
player.gameData.storePack.storePackInfo[storeId].buyStatus = true
--修改玩家的充值相关信息
self:ChangePayInfo(player , storeId)
--判断购买的是不是月卡
if storeId == 61 then
self:MonthCardBuy(player , c2sData ,s2cData)
self:ChangeBuyTimes(player , storeId)
local data = assert(pb.decode("S2CStoreMonthCardBuy", s2cData.data))
skynet.server.gameServer:SendMsgToUser(player.userId, "CMD_S2C_StoreMonthCardBuy", data)
--限时灵感积分
skynet.server.activityLimitedAccum:Pay( player , storeId )
--豪华月卡
elseif storeId == 225 then
skynet.server.luxuryCard:Buy( player,c2sData , s2cData )
local data = assert(pb.decode("S2CLuxuryMonthCardBuy", s2cData.data))
skynet.server.gameServer:SendMsgToUser(player.userId, "CMD_S2C_LuxuryMonthCardBuy", data)
--限时灵感积分
skynet.server.activityLimitedAccum:Pay( player , storeId )
--购买完后主动推送一次豪华月卡信息
--skynet.server.luxuryCard:SendLuxuryCardInfoToUser(player)
else
self:Buy(player , c2sData , s2cData , true)
local data = assert(pb.decode("S2CStoreBuy", s2cData.data))
skynet.server.gameServer:SendMsgToUser(player.userId, "CMD_S2C_StoreBuy", data, s2cData.code)
end
end
--修改玩家对应礼包的购买次数和购买时间
function Store:ChangeBuyTimes( player , storeId , buyCount)
for k ,v in pairs(player.gameData.storePack.storePackInfo) do
if v.storeId == storeId and buyCount == nil then
player.gameData.storePack.storePackInfo[storeId].buyTimes=player.gameData.storePack.storePackInfo[storeId].buyTimes+1
player.gameData.storePack.storePackInfo[storeId].historyBuyTimes=player.gameData.storePack.storePackInfo[storeId].historyBuyTimes+1
player.gameData.storePack.storePackInfo[storeId].buyTime = skynet.GetTime()
elseif v.storeId == storeId and buyCount ~= nil then
player.gameData.storePack.storePackInfo[storeId].buyTimes=player.gameData.storePack.storePackInfo[storeId].buyTimes+buyCount
player.gameData.storePack.storePackInfo[storeId].historyBuyTimes=player.gameData.storePack.storePackInfo[storeId].historyBuyTimes+buyCount
player.gameData.storePack.storePackInfo[storeId].buyTime = skynet.GetTime()
end
end
end
--修改玩家充值相关信息
function Store:ChangePayInfo(player , storeId)
local cfgStorePack = skynet.server.gameConfig:GetPlayerAllCfg( player , "StorePack")
local cfgAllStorePrice = skynet.server.gameConfig:GetPlayerAllCfg( player , "StorePrice")
local cfgSValue = skynet.server.gameConfig:GetPlayerAllCfg( player , "SValue")
local cfgValueAccumulate = skynet.server.gameConfig:GetPlayerAllCfg( player , "ValueAccumulate")
--找到对应礼包充值信息
local cfgStorePrice = {}
for k , v in pairs(cfgAllStorePrice) do
if v.storePackId == storeId then
cfgStorePrice.price = v.price
break
end
end
if next(cfgStorePrice) == nil then
cfgStorePrice.price = 0
end
--修改玩家的充值额度
local rechargeCount = cfgStorePrice.price/100
player.gameData.storePack.rechargeAmount = player.gameData.storePack.rechargeAmount + rechargeCount
local myPlayerId = player.gameData.partner.id
if myPlayerId then
--充值时更新下最新的充值记录
skynet.server.personal:SetDetail( myPlayerId , "rechargeAmount" , player.gameData.storePack.rechargeAmount )
end
--判断充值是否达到触发首充奖励的额度
local startTopUP = false
for k ,v in pairs(player.gameData.storePack.topUpInfo) do
if v.isGet ~= 0 then
startTopUP = true --已经开启过首充赠礼了
end
end
if player.gameData.storePack.rechargeAmount >= cfgSValue.firstChargeLimit and not startTopUP then
for k ,v in pairs(player.gameData.storePack.topUpInfo) do
if k == 1 then
--第一天默认可以领取
v.isGet = 1
v.startTime = skynet.GetTime()
skynet.server.msgTips:Add(player , 48)
else
v.isGet = 0
v.startTime = skynet.server.common:GetAfterSomeDay(k-1)
end
end
end
--判断积分是否达到可以领取对应的积分奖励
for k ,v in pairs(cfgValueAccumulate) do
if player.gameData.storePack.rechargeAmount * cfgSValue.valueAccumulatePoint >= v.point and player.gameData.storePack.pointsInfo[k].isGet == 0 then
player.gameData.storePack.pointsInfo[k].isGet = 1 --修改为可以领取
skynet.server.msgTips:Add(player , 49) --同时添加对应红点
end
end
--通知客户端
local data ={}
data.points = player.gameData.storePack.rechargeAmount * cfgSValue.valueAccumulatePoint
skynet.server.gameServer:SendMsgToUser(player.userId, "CMD_S2C_PointsChange", data)
end
--消除红点
function Store:DelRedDot( player , packUI)
--消除红点
if packUI==1 then
skynet.server.msgTips:Reduce(player , 27)
elseif packUI==2 then
skynet.server.msgTips:Reduce(player , 28)
elseif packUI==3 then
skynet.server.msgTips:Reduce(player , 29)
elseif packUI==4 then
skynet.server.msgTips:Reduce(player , 30)
end
end
--积分修改后判断是否需要更新奖励
function Store:ChangePoint( player )
if player.gameData.storePack then
local cfgAll = skynet.server.gameConfig:GetPlayerAllCfg( player , "ValueAccumulate" )
--判断是否需要修改玩家对应奖励状态
local cfgSValue = skynet.server.gameConfig:GetPlayerAllCfg( player , "SValue" )
for k ,v in pairs(cfgAll) do
if player.gameData.storePack.rechargeAmount * cfgSValue.valueAccumulatePoint >= v.point and player.gameData.storePack.pointsInfo[k].isGet == 0 then
player.gameData.storePack.pointsInfo[k].isGet = 1 --修改为可以领取
skynet.server.msgTips:Add(player , 49) --同时添加对应红点
end
end
--限时累充积分修改
if next(player.gameData.design.timeCardPoolInfo) ~= nil then
for k , v in pairs(player.gameData.design.timeCardPoints) do
if v.raffleId == 48 then
--判断积分是否达到可以领取对应的积分奖励
local cfgLimitedAccum = skynet.server.gameConfig:GetPlayerCurCfg( player , "LimitedAccum" , k )
for k1 ,v1 in pairs(cfgLimitedAccum.value) do
if v.points >= v1 and v.pointsInfo[k1].isGet == 0 then
v.pointsInfo[k1].isGet = 1 --修改为可以领取
skynet.server.msgTips:Add(player , 94) --同时添加对应红点
end
end
end
end
end
end
local cfgSValue = skynet.server.gameConfig:GetPlayerAllCfg( player , "SValue")
--通知客户端
local data = {}
data.points = player.gameData.storePack.rechargeAmount * cfgSValue.valueAccumulatePoint
skynet.server.gameServer:SendMsgToUser(player.userId, "CMD_S2C_PointsChange", data)
end
skynet.server.store = Store
return Store