1487 lines
79 KiB
Lua
1487 lines
79 KiB
Lua
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 shop = require "Shop"
|
|
local Design = oo.class(shop)
|
|
|
|
Design.lotteryType = dataType.LotteryType_LongTime
|
|
|
|
Design.BoxType_Normal = 1 --签到奖励类型 普通
|
|
Design.BoxType_Blind = 2 --签到奖励类型 盲盒
|
|
|
|
Design.LotteryType_1= 1 --初级家具卡池
|
|
Design.LotteryType_2= 2 --高级家具卡池
|
|
Design.LotteryType_3= 3 --限时家具卡池
|
|
|
|
Design.TicketType_1= 1 --高级设计稿
|
|
Design.TicketType_2= 2 --初级设计稿
|
|
Design.TicketType_3= 3 --限时设计稿
|
|
|
|
Design.LotteryId = {}
|
|
local configType = skynet.server.gameConfig:GetConfigType( "Main" , 1 )
|
|
Design.LotteryId[ configType ] = {}
|
|
Design.LotteryId[ configType ].limitedLotteryId = 0
|
|
Design.LotteryId[ configType ].goldLotteryId = 1
|
|
Design.LotteryId[ configType ].advancedLotteryId = 2
|
|
|
|
configType = skynet.server.gameConfig:GetConfigType( "A" , 1 )
|
|
Design.LotteryId[ configType ] = {}
|
|
Design.LotteryId[ configType ].limitedLotteryId = 0
|
|
Design.LotteryId[ configType ].goldLotteryId = 1
|
|
Design.LotteryId[ configType ].advancedLotteryId = 2
|
|
|
|
configType = skynet.server.gameConfig:GetConfigType( "B" , 1 )
|
|
Design.LotteryId[ configType ] = {}
|
|
Design.LotteryId[ configType ].limitedLotteryId = 0
|
|
Design.LotteryId[ configType ].goldLotteryId = 1
|
|
Design.LotteryId[ configType ].advancedLotteryId = 2
|
|
|
|
Design.LotteryTimes_One = 1 --抽一次
|
|
Design.LotteryTimes_Ten = 2 --抽十次
|
|
|
|
--设置开奖的ID
|
|
function Design:SetLotteryId( player , keyName , keyValue )
|
|
local configType = player.basicInfo.configType
|
|
self.LotteryId[ configType][ keyName] = tonumber(keyValue)
|
|
end
|
|
|
|
--获取开奖的ID
|
|
function Design:GetLotteryId( player , keyName , keyValue )
|
|
local configType = player.basicInfo.configType
|
|
return self.LotteryId[ configType][ keyName]
|
|
end
|
|
|
|
--初始化数据
|
|
function Design:InitData( player )
|
|
--初始化设计空间相关信息
|
|
--没有对应数据进行初始化 兼容老玩家数据
|
|
if not player.gameData.design.timeCardPoints then
|
|
player.gameData.design.timeCardPoints = {}
|
|
end
|
|
|
|
--限时卡池数据
|
|
local activityId,startTime,endTime,id = skynet.server.activity:GetActivityInfo( player , dataType.ActivityType_Raffle , self.LotteryType_3 )
|
|
if activityId > 0 then
|
|
local cfgRaffle = skynet.server.gameConfig:GetPlayerCurCfg( player , "Raffle" , activityId )
|
|
player.gameData.design.timeCardPoolInfo.id = activityId --该限时卡池的id
|
|
player.gameData.design.timeCardPoolInfo.activityId = id --该活动的id
|
|
player.gameData.design.timeCardPoolInfo.ticket = cfgRaffle.ticket --该限时卡池使用的卡券
|
|
end
|
|
if player.gameData.design.timeCardPoolInfo.id then
|
|
--获取对应卡池信息
|
|
local cfgRaffle = skynet.server.gameConfig:GetPlayerCurCfg( player , "Raffle" , player.gameData.design.timeCardPoolInfo.id )
|
|
player.gameData.design.timeCardPoolInfo.timeCount = 0 --限时卡池的保底抽数 每次保底后清除
|
|
player.gameData.design.timeCardPoolInfo.designCount = 0 --限时卡池的设计次数
|
|
player.gameData.design.timeCardPoolInfo.first10Design = false --本次限时卡池的第一次十连抽
|
|
player.gameData.design.timeCardPoolInfo.last10FurCount = 0 --上次十连抽抽中的罕见套间家具数量
|
|
player.gameData.design.timeCardPoolInfo.design10Count = 0 --十连抽的数量 用于暗保
|
|
player.gameData.design.timeCardPoolInfo.timeAward = {} --限时卡池的奖励信息
|
|
local count = 1
|
|
for k ,v in pairs(cfgRaffle.raffleNum) do
|
|
player.gameData.design.timeCardPoolInfo.timeAward[ count ] = {}
|
|
player.gameData.design.timeCardPoolInfo.timeAward[ count ].id = count --id 用于领取
|
|
player.gameData.design.timeCardPoolInfo.timeAward[ count ].status = 0 --当前状态 0 未解锁 1 未领取 2 已领取
|
|
player.gameData.design.timeCardPoolInfo.timeAward[ count ].needDesignCount = v --需要的设计次数
|
|
player.gameData.design.timeCardPoolInfo.timeAward[ count ].rewardInfo = cfgRaffle.numReward[ k ] --奖励信息
|
|
count = count + 1
|
|
end
|
|
player.gameData.design.timeCardPoolInfo.timeSignIn = {} --限时卡池的签到信息
|
|
player.gameData.design.timeCardPoolInfo.timeSignInCount = 0 --限时卡池的签到天数
|
|
count = 1
|
|
for k ,v in pairs(cfgRaffle.signReward) do
|
|
if count == 1 then
|
|
--第一天默认可以领取
|
|
player.gameData.design.timeCardPoolInfo.timeSignIn[ count ] = {}
|
|
player.gameData.design.timeCardPoolInfo.timeSignIn[ count ].day = count --day 用于领取
|
|
player.gameData.design.timeCardPoolInfo.timeSignIn[ count ].status = 1 --当前状态 0 未解锁 1 未领取 2 已领取
|
|
player.gameData.design.timeCardPoolInfo.timeSignIn[ count ].rewardId = v --奖励id
|
|
count = count + 1
|
|
skynet.server.msgTips:Add(player , 69)
|
|
else
|
|
player.gameData.design.timeCardPoolInfo.timeSignIn[ count ] = {}
|
|
player.gameData.design.timeCardPoolInfo.timeSignIn[ count ].day = count --day 用于领取
|
|
player.gameData.design.timeCardPoolInfo.timeSignIn[ count ].status = 0 --当前状态 0 未解锁 1 未领取 2 已领取
|
|
player.gameData.design.timeCardPoolInfo.timeSignIn[ count ].rewardId = v --奖励id
|
|
count = count + 1
|
|
end
|
|
end
|
|
--新玩家当天未解锁限时卡池不会访问该方法,会导致签到天数未更新
|
|
if skynet.server.common:IsSameDay( player.basicInfo.lastLoginTime , skynet.GetTime()) then
|
|
player.gameData.design.timeCardPoolInfo.timeSignInCount = 1
|
|
end
|
|
end
|
|
--限时卡池开启的时候有对应的限时累充活动开启
|
|
local activityId1,startTime1,endTime1 = skynet.server.activity:GetActivityInfo( player , dataType.ActivityType_LimitedAccum )
|
|
if activityId1 > 0 then
|
|
local cfgLimitedAccum = skynet.server.gameConfig:GetPlayerCurCfg( player , "LimitedAccum" , activityId1 )
|
|
if player.gameData.design.timeCardPoints[ cfgLimitedAccum.id ] == nil then
|
|
--初始对应限时卡池累充信息
|
|
player.gameData.design.timeCardPoints[ cfgLimitedAccum.id ] = {}
|
|
player.gameData.design.timeCardPoints[ cfgLimitedAccum.id ].raffleId = player.gameData.design.timeCardPoolInfo.id
|
|
player.gameData.design.timeCardPoints[ cfgLimitedAccum.id ].points = 0
|
|
player.gameData.design.timeCardPoints[ cfgLimitedAccum.id ].pointsInfo = {}
|
|
local count1 = 1
|
|
for k , v in pairs(cfgLimitedAccum.value) do
|
|
player.gameData.design.timeCardPoints[ cfgLimitedAccum.id ].pointsInfo[ count1 ] = {}
|
|
player.gameData.design.timeCardPoints[ cfgLimitedAccum.id ].pointsInfo[ count1 ].id = count1
|
|
player.gameData.design.timeCardPoints[ cfgLimitedAccum.id ].pointsInfo[ count1 ].isGet = 0 --0 不可领取 1 可以领取 2 已领取
|
|
count1 = count1 + 1
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
--登录时需修改的数据
|
|
function Design:LoginChangeData( player )
|
|
local cfgSValue = skynet.server.gameConfig:GetPlayerAllCfg( player , "SValue")
|
|
if cfgSValue.drawUnlockLvl <= player.gameData.level then
|
|
skynet.server.msgTips:Reset(player , 68)
|
|
skynet.server.msgTips:Reset(player , 69)
|
|
skynet.server.msgTips:Reset(player , 94)
|
|
--检查是否有可以领取的限时奖励
|
|
self:CheckCanGetReward(player)
|
|
--如果限时卡池过期了 则将未领取的奖励通过邮件发放给玩家 同时清除相关数据
|
|
if player.gameData.design.timeCardPoolInfo.id then
|
|
local nowTime = skynet.GetTime()
|
|
local id,startTime,endTime = 0,0,0
|
|
local cfgActivity = skynet.server.gameConfig:GetPlayerAllCfg(player , "Activity")
|
|
|
|
if nil == player.gameData.design.timeCardPoolInfo.activityId then
|
|
local activityId,startTime,endTime,id = skynet.server.activity:GetActivityInfo( player , dataType.ActivityType_Raffle , self.LotteryType_3 )
|
|
if activityId > 0 then
|
|
player.gameData.design.timeCardPoolInfo.activityId = id
|
|
end
|
|
end
|
|
|
|
for k , v in pairs(cfgActivity) do
|
|
if v.id == player.gameData.design.timeCardPoolInfo.activityId then
|
|
id = v.id
|
|
startTime = skynet.server.common:GetTime(v.startTime)
|
|
endTime = skynet.server.common:GetTime(v.endTime)
|
|
break
|
|
end
|
|
end
|
|
|
|
if nowTime > endTime then
|
|
--未领取累抽奖励补发
|
|
local award = {}
|
|
for k, v in pairs(player.gameData.design.timeCardPoolInfo.timeAward) do
|
|
if 1 == v.status then
|
|
local rewardInfo = skynet.server.common:Split(v.rewardInfo, "_")
|
|
rewardInfo[1], rewardInfo[2] = tonumber(rewardInfo[1]), tonumber(rewardInfo[2])
|
|
local rewards = {}
|
|
if rewardInfo[1] == self.BoxType_Normal then
|
|
table.insert(award, {type = dataType.GoodsType_RewardId , id = rewardInfo[2] , count = 1})
|
|
elseif rewardInfo[1] == self.BoxType_Blind then
|
|
rewards = self:BoxReward(player, player.gameData.design.timeCardPoolInfo.id)
|
|
for k1, v1 in pairs(rewards) do
|
|
table.insert(award, v1)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
if 0 ~= #award then
|
|
skynet.server.mail:AddNewMail(player, skynet.server.mail.MailType_Award, "未领取的奖励", "限时卡池中未领取的奖励", award, true)
|
|
end
|
|
--限时卡池 午后甜茶额外发送邮件 且 有多余的草莓设计稿
|
|
local haveCount = skynet.server.bag:GetGoodsCount(player, dataType.GoodsType_Prop, 22)
|
|
if id == cfgSValue.couponExchangeActivityMail[1] and haveCount > 0 then
|
|
local exchangeCount = math.min(cfgSValue.strawberryCouponExchangeLimit,
|
|
math.ceil(haveCount / cfgSValue.strawberryCouponExchangeRate[1] * cfgSValue.strawberryCouponExchangeRate[2]))
|
|
local extraAward = {}
|
|
table.insert(extraAward, { type = dataType.GoodsType_Prop, id = 2, count = exchangeCount })
|
|
local cfgOneMail = skynet.server.gameConfig:GetPlayerCurCfg(player, "Mail", cfgSValue.couponExchangeActivityMail[2])
|
|
skynet.server.mail:AddNewMail(player, skynet.server.mail.MailType_Award, cfgOneMail.mailTitle, cfgOneMail.mailContent, extraAward, true)
|
|
--减少对应的设计稿
|
|
skynet.server.bag:RemoveGoods(player, dataType.GoodsType_Prop, 22, haveCount)
|
|
end
|
|
|
|
--初始限时卡池
|
|
player.gameData.design.timeCardPoolInfo = {}
|
|
--初始对应一元礼包购买状态
|
|
player.gameData.design.isBuyStorePack8 = false
|
|
elseif nowTime >= startTime and nowTime <= endTime then
|
|
--红点系统
|
|
for k, v in pairs(player.gameData.design.timeCardPoolInfo.timeAward) do
|
|
if v.status == 1 then
|
|
skynet.server.msgTips:AddNoNotice(player, 68)
|
|
end
|
|
end
|
|
for k, v in pairs(player.gameData.design.timeCardPoolInfo.timeSignIn) do
|
|
if v.status == 1 then
|
|
skynet.server.msgTips:AddNoNotice(player, 69)
|
|
end
|
|
end
|
|
for k, v in pairs(player.gameData.design.timeCardPoints) do
|
|
if player.gameData.design.timeCardPoolInfo.id == v.raffleId then
|
|
for k1, v1 in pairs(v.pointsInfo) do
|
|
if v1.isGet == 1 then
|
|
skynet.server.msgTips:AddNoNotice(player, 94)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
else
|
|
--都不满足的条件下只有修改了服务器时间
|
|
self:InitData(player)
|
|
end
|
|
end
|
|
--检查是否有新的限时卡池
|
|
if next(player.gameData.design.timeCardPoolInfo) == nil then
|
|
self:InitData(player)
|
|
end
|
|
end
|
|
end
|
|
|
|
--设计抽奖展示
|
|
function Design:Show( player , c2sData , s2cData )
|
|
c2sData.data = assert(pb.decode("C2SDesignShow", c2sData.data ))
|
|
local data = {}
|
|
if not player:IsUnlockSystem( dataType.UnlockSystem_DesignHouse ) then
|
|
s2cData.code = errorInfo.ErrorCode.ErrRequestParam
|
|
else
|
|
local design = player.gameData.design
|
|
local cfgRaffle = skynet.server.gameConfig:GetPlayerAllCfg( player , "Raffle")
|
|
|
|
--初级卡池
|
|
local activityId1,startTime1,endTime1 = skynet.server.activity:GetActivityInfo( player , dataType.ActivityType_Raffle , self.LotteryType_1 )
|
|
--高级卡池
|
|
local activityId2,startTime2,endTime2 = skynet.server.activity:GetActivityInfo( player , dataType.ActivityType_Raffle , self.LotteryType_2 )
|
|
--限时卡池
|
|
local activityId3,startTime3,endTime3 = skynet.server.activity:GetActivityInfo( player , dataType.ActivityType_Raffle , self.LotteryType_3 )
|
|
|
|
if activityId1 ~= 0 then
|
|
self:SetLotteryId( player , "goldLotteryId" , activityId1 )
|
|
else
|
|
self:SetLotteryId( player , "goldLotteryId" , 1 )
|
|
end
|
|
if activityId2 ~= 0 then
|
|
self:SetLotteryId( player , "advancedLotteryId" , activityId2 )
|
|
else
|
|
self:SetLotteryId( player , "advancedLotteryId" , 2 )
|
|
end
|
|
if activityId3 ~= 0 then
|
|
--在线玩家活动开启的时候修改对应数据
|
|
if player.gameData.design.timeCardPoolInfo.id == nil or player.gameData.design.timeCardPoolInfo.id ~= activityId3 then
|
|
--玩家只有首次初始化卡池数据,新的一期都不会初始化了,加个 player.gameData.design.timeCardPoolInfo.id ~= activityId3 判断,才会初始化
|
|
self:InitData( player )
|
|
end
|
|
--self:SetLotteryId( player , "limitedLotteryId" , player.gameData.design.timeCardPoolInfo.id )
|
|
--self.TicketType_3 = player.gameData.design.timeCardPoolInfo.ticket
|
|
--上面两句不知道陈林为啥会去修改当前配置,导致一个玩家上线,可能把旧配置给更上去,导致卡池不是当期,所以注释掉
|
|
|
|
self:SetLotteryId( player , "limitedLotteryId" , activityId3 )
|
|
local cfgRaffle = skynet.server.gameConfig:GetPlayerCurCfg( player , "Raffle" , activityId3 )
|
|
self.TicketType_3 = cfgRaffle.ticket --该限时卡池使用的卡券
|
|
else
|
|
self:SetLotteryId( player , "limitedLotteryId" , 0 )
|
|
self.TicketType_3 = 3
|
|
self:LoginChangeData( player )
|
|
end
|
|
|
|
data.cardPoolInfos = {}
|
|
table.insert(data.cardPoolInfos , {raffleId = self:GetLotteryId( player , "goldLotteryId" ) ,
|
|
raffleType = self.LotteryType_1 , startTime = startTime1 , endTime = endTime1})
|
|
table.insert(data.cardPoolInfos , {raffleId = self:GetLotteryId( player , "advancedLotteryId" ) ,
|
|
raffleType = self.LotteryType_2 , startTime = startTime2 , endTime = endTime2})
|
|
if self:GetLotteryId( player , "limitedLotteryId" ) > 0 then
|
|
table.insert(data.cardPoolInfos , {raffleId = self:GetLotteryId( player , "limitedLotteryId" ) ,
|
|
raffleType = self.LotteryType_3 , startTime = startTime3 , endTime = endTime3})
|
|
end
|
|
|
|
data.designCurrency = self:GetTicket( player )
|
|
data.basicFreeTime = design.basicFreeTime
|
|
data.advancedFreeTime = design.advancedFreeTime
|
|
data.isBuyStorePack8 = design.isBuyStorePack8
|
|
|
|
--保底次数
|
|
data.highCount = 10 - design.highCount --高级
|
|
if player.gameData.design.timeCardPoolInfo.id then
|
|
data.timeCount = 10 - design.timeCardPoolInfo.timeCount --限时
|
|
end
|
|
|
|
--是否可以显示相关UI 按照顺序 限时卡池签到
|
|
data.isShowUI = {}
|
|
if player.gameData.design.timeCardPoolInfo.id then
|
|
local isShowUI = false
|
|
for k ,v in pairs(player.gameData.design.timeCardPoolInfo.timeSignIn) do
|
|
if v.status ~= 2 then
|
|
isShowUI = true
|
|
break
|
|
end
|
|
end
|
|
table.insert(data.isShowUI , isShowUI)
|
|
end
|
|
end
|
|
s2cData.cmd = pb.enum("MsgType","CMD_S2C_DesignShow")
|
|
s2cData.data = assert(pb.encode("S2CDesignShow", data))
|
|
end
|
|
|
|
--设计抽奖展示
|
|
function Design:Lottery( player , c2sData , s2cData )
|
|
c2sData.data = assert(pb.decode("C2SDesignLottery", c2sData.data ))
|
|
local data = {}
|
|
local cfgSValue = skynet.server.gameConfig:GetPlayerAllCfg( player , "SValue")
|
|
local lotteryType = c2sData.data.lotteryType
|
|
local lotteryTimes = c2sData.data.lotteryTimes
|
|
|
|
if not lotteryType or not lotteryTimes or lotteryType < self.LotteryType_1 or lotteryType > self.LotteryType_3 or lotteryTimes < self.LotteryTimes_One or lotteryTimes > self.LotteryTimes_Ten then
|
|
s2cData.code = errorInfo.ErrorCode.ErrRequestParam
|
|
elseif self.LotteryType_3 == lotteryType and 0 == self:GetLotteryId( player , "limitedLotteryId" ) then
|
|
s2cData.code = errorInfo.ErrorCode.ActivityClosed
|
|
elseif not player:IsUnlockSystem( dataType.UnlockSystem_DesignHouse ) then
|
|
s2cData.code = errorInfo.ErrorCode.ErrRequestParam
|
|
else
|
|
local design = player.gameData.design
|
|
local moneyType,moneyCount = 0,0
|
|
local reduceCount = 0 --扣除券数量
|
|
data.isFree = false --客户端打点用 是不是免费抽
|
|
|
|
if self.LotteryTimes_One == lotteryTimes then --抽一次
|
|
reduceCount = 1
|
|
if self.LotteryType_1 == lotteryType and skynet.GetTime() >= design.basicFreeTime then
|
|
reduceCount = 0
|
|
data.isFree = true
|
|
design.basicFreeTime = skynet.GetTime() + (cfgSValue.goldRaffleTypeFreeTime * 60 ) --1天后再领
|
|
end
|
|
|
|
if self.LotteryType_2 == lotteryType and skynet.GetTime() >= design.advancedFreeTime then
|
|
reduceCount = 0
|
|
data.isFree = true
|
|
design.advancedFreeTime = skynet.GetTime() + (cfgSValue.voluteRaffleTypeFreeTime * 60 ) --1天后再领
|
|
end
|
|
|
|
if self.LotteryType_2 == lotteryType then
|
|
--增加对应高级卡池的积分 一次加10分
|
|
design.highStorePoints = design.highStorePoints + cfgSValue.raffleIntegral
|
|
design.highCount = design.highCount + 1 --增加高级卡池的保底次数
|
|
elseif self.LotteryType_3 == lotteryType then
|
|
design.timeCardPoolInfo.designCount = design.timeCardPoolInfo.designCount + 1 --增加限时卡池的设计次数
|
|
design.timeCardPoolInfo.timeCount = design.timeCardPoolInfo.timeCount + 1 --增加限时卡池的保底次数
|
|
--判断是否达到设计次数奖励
|
|
self:CheckCanGetReward(player)
|
|
end
|
|
elseif self.LotteryTimes_Ten == lotteryTimes then --抽十次
|
|
reduceCount = 10
|
|
if self.LotteryType_2 == lotteryType then
|
|
--增加对应高级卡池的积分
|
|
design.highStorePoints = design.highStorePoints + reduceCount * cfgSValue.raffleIntegral
|
|
design.highCount = design.highCount + 10 --增加高级卡池的保底次数
|
|
elseif self.LotteryType_3 == lotteryType then
|
|
design.timeCardPoolInfo.designCount = design.timeCardPoolInfo.designCount + 10 --增加限时卡池的设计次数
|
|
design.timeCardPoolInfo.timeCount = design.timeCardPoolInfo.timeCount + 10 --增加限时卡池的保底次数
|
|
design.timeCardPoolInfo.design10Count = design.timeCardPoolInfo.design10Count + 1 --增加限时卡池的十连抽次数
|
|
--判断是否达到设计次数奖励
|
|
self:CheckCanGetReward(player)
|
|
end
|
|
end
|
|
|
|
log.debug(string.format("玩家 %d 设计间 抽奖类型 %d 抽奖次数 %d 扣除前 金币数量 %d 蜗壳数量 %d 券数量 %d %d %d",
|
|
player.userId , lotteryType,reduceCount, player.gameData.coin , player.gameData.volute ,
|
|
skynet.server.bag:GetGoodsCount( player , dataType.GoodsType_Prop , 1) ,
|
|
skynet.server.bag:GetGoodsCount( player , dataType.GoodsType_Prop , 2) ,
|
|
skynet.server.bag:GetGoodsCount( player , dataType.GoodsType_Prop , self.TicketType_3) ))
|
|
|
|
--开始计算扣除货币数量
|
|
local isEnoughMoney = false
|
|
local lotteryId = 0
|
|
if self.LotteryType_1 == lotteryType then --初级家具卡池
|
|
if 0 ~= reduceCount and not skynet.server.bag:RemoveGoods( player , dataType.GoodsType_Prop , 1 , reduceCount) then
|
|
s2cData.code = errorInfo.ErrorCode.NoEnoughGoods
|
|
else
|
|
isEnoughMoney = true
|
|
end
|
|
lotteryId = self:GetLotteryId( player , "goldLotteryId" )
|
|
elseif self.LotteryType_2 == lotteryType then --高级家具卡池
|
|
if 0 ~= reduceCount and not skynet.server.bag:RemoveGoods( player , dataType.GoodsType_Prop , 2 , reduceCount) then
|
|
s2cData.code = errorInfo.ErrorCode.NoEnoughGoods
|
|
else
|
|
isEnoughMoney = true
|
|
end
|
|
lotteryId = self:GetLotteryId( player , "advancedLotteryId" )
|
|
elseif self.LotteryType_3 == lotteryType then --限时家具卡池
|
|
--if 0 ~= reduceCount and not skynet.server.bag:RemoveGoods( player , dataType.GoodsType_Prop , player.gameData.design.timeCardPoolInfo.ticket , reduceCount) then
|
|
if 0 ~= reduceCount and not skynet.server.bag:RemoveGoods( player , dataType.GoodsType_Prop , self.TicketType_3 , reduceCount) then
|
|
s2cData.code = errorInfo.ErrorCode.NoEnoughGoods
|
|
else
|
|
isEnoughMoney = true
|
|
end
|
|
lotteryId = self:GetLotteryId( player , "limitedLotteryId" )
|
|
end
|
|
|
|
if not isEnoughMoney then
|
|
s2cData.code = errorInfo.ErrorCode.NoEnoughMoney
|
|
else
|
|
log.debug(string.format("玩家 %d 设计间 扣除券数量 %d 扣除后 金币数量 %d 蜗壳数量 %d 券数量 %d %d %d", player.userId , reduceCount , player.gameData.coin , player.gameData.volute ,
|
|
skynet.server.bag:GetGoodsCount( player , dataType.GoodsType_Prop , 1) ,
|
|
skynet.server.bag:GetGoodsCount( player , dataType.GoodsType_Prop , 2) ,
|
|
skynet.server.bag:GetGoodsCount( player , dataType.GoodsType_Prop , self.TicketType_3)))
|
|
local goods1 = self:GetFurniture( player , lotteryId , dataType.FurnitureQuality_Common ) --普通家具
|
|
local goods2 = self:GetFurniture( player , lotteryId , dataType.FurnitureQuality_Special ) --稀有家具
|
|
local goods3 = self:GetFurniture( player , lotteryId , dataType.FurnitureQuality_Rare ) --罕见家具
|
|
log.debug(string.format("玩家 %d 设计间 商品数量 %d %d %d", player.userId , #goods1 , #goods2 , #goods3))
|
|
|
|
--开始抽奖
|
|
data.rewards = {}
|
|
local goodsType = 0
|
|
local goodsId = 0
|
|
if self.LotteryTimes_One == lotteryTimes then --抽一次
|
|
--判断是否触发保底 就只有初级卡池没有保底
|
|
if lotteryType == self.LotteryType_2 and design.highCount >= 10 then
|
|
design.highCount = design.highCount - 10
|
|
goodsType,goodsId = self:StartLottery( player , lotteryType , true , goods1 , goods2 , goods3 )
|
|
local goodsInfo = { goodsType = goodsType , goodsId = goodsId , goodsCount = 1 }
|
|
--local isNewGoods = not player:IsBuyGoods( goodsType , goodsId ) --不存在就是新的
|
|
local isNewGoods = not skynet.server.illustration:IsExistGoods( player , goodsType , goodsId ) --不存在就是新的
|
|
table.insert( data.rewards ,{ item = goodsInfo , isNew = isNewGoods } )
|
|
skynet.server.msgTips:Reduce(player , 31)
|
|
elseif lotteryType == self.LotteryType_3 and design.timeCardPoolInfo.timeCount >= 10 then
|
|
design.timeCardPoolInfo.timeCount = design.timeCardPoolInfo.timeCount - 10
|
|
goodsType,goodsId = self:StartLottery( player , lotteryType , true , goods1 , goods2 , goods3 )
|
|
local goodsInfo = { goodsType = goodsType , goodsId = goodsId , goodsCount = 1 }
|
|
--local isNewGoods = not player:IsBuyGoods( goodsType , goodsId ) --不存在就是新的
|
|
local isNewGoods = not skynet.server.illustration:IsExistGoods( player , goodsType , goodsId ) --不存在就是新的
|
|
table.insert( data.rewards ,{ item = goodsInfo , isNew = isNewGoods } )
|
|
else
|
|
goodsType,goodsId = self:StartLottery( player , lotteryType , false , goods1 , goods2 , goods3 )
|
|
local goodsInfo = { goodsType = goodsType , goodsId = goodsId , goodsCount = 1 }
|
|
--local isNewGoods = not player:IsBuyGoods( goodsType , goodsId ) --不存在就是新的
|
|
local isNewGoods = not skynet.server.illustration:IsExistGoods( player , goodsType , goodsId ) --不存在就是新的
|
|
table.insert( data.rewards ,{ item = goodsInfo , isNew = isNewGoods } )
|
|
|
|
if self.LotteryType_1 == lotteryType then
|
|
skynet.server.msgTips:Reduce(player , 34)
|
|
elseif self.LotteryType_2 == lotteryType then
|
|
skynet.server.msgTips:Reduce(player , 31)
|
|
end
|
|
end
|
|
--判断是否需要归零保底
|
|
local cfgFurniture = skynet.server.gameConfig:GetPlayerCurCfg( player , "Furniture" , goodsId )
|
|
if lotteryType == self.LotteryType_2 and cfgFurniture.quality > 1 and cfgFurniture.suitType > 0 then
|
|
--高级保底品质为套装
|
|
design.highCount = 0
|
|
elseif lotteryType == self.LotteryType_3 and cfgFurniture.quality > 2 then
|
|
--限时保底品质为罕见
|
|
design.timeCardPoolInfo.timeCount = 0
|
|
end
|
|
elseif self.LotteryTimes_Ten == lotteryTimes then --抽十次
|
|
local rand = 0 --10连抽必定触发保底
|
|
local count = 0 --用于处理提前出货
|
|
local rareSuitCount = 0 --记录限时卡池一次十连抽中的罕见套装家具数量
|
|
if self.LotteryType_2 == lotteryType then
|
|
rand = 10 - design.highCount%10
|
|
count = design.highCount
|
|
elseif self.LotteryType_3 == lotteryType then
|
|
rand = 10 - design.timeCardPoolInfo.timeCount%10
|
|
count = design.timeCardPoolInfo.timeCount
|
|
end
|
|
for i = 1, 10, 1 do
|
|
if rand == i and ( self.LotteryType_2 == lotteryType or self.LotteryType_3 == lotteryType ) then --只有高级和限时卡池才有保底
|
|
goodsType,goodsId = self:StartLottery( player , lotteryType , true , goods1 , goods2 , goods3 )
|
|
local goodsInfo = { goodsType = goodsType , goodsId = goodsId , goodsCount = 1 }
|
|
--local isNewGoods = not player:IsBuyGoods( goodsType , goodsId ) --不存在就是新的
|
|
local isNewGoods = not skynet.server.illustration:IsExistGoods( player , goodsType , goodsId ) --不存在就是新的
|
|
table.insert( data.rewards ,{ item = goodsInfo , isNew = isNewGoods } )
|
|
count = rand
|
|
else
|
|
goodsType,goodsId = self:StartLottery( player , lotteryType , false , goods1 , goods2 , goods3 )
|
|
local goodsInfo = { goodsType = goodsType , goodsId = goodsId , goodsCount = 1 }
|
|
--local isNewGoods = not player:IsBuyGoods( goodsType , goodsId ) --不存在就是新的
|
|
local isNewGoods = not skynet.server.illustration:IsExistGoods( player , goodsType , goodsId ) --不存在就是新的
|
|
table.insert( data.rewards ,{ item = goodsInfo , isNew = isNewGoods } )
|
|
--提前出货 修改相关数据
|
|
local cfgFurniture = skynet.server.gameConfig:GetPlayerCurCfg( player , "Furniture" , goodsId )
|
|
if lotteryType == self.LotteryType_2 and cfgFurniture.quality > 1 and cfgFurniture.suitType > 0 then
|
|
--本次就不会再有保底
|
|
rand = 0
|
|
count = i
|
|
elseif lotteryType == self.LotteryType_3 and cfgFurniture.quality > 2 then
|
|
--本次就不会再有保底
|
|
rand = 0
|
|
count = i
|
|
end
|
|
end
|
|
--移除限时卡池已经获取到罕见物品
|
|
local cfgFurniture = skynet.server.gameConfig:GetPlayerCurCfg( player , "Furniture" , goodsId )
|
|
if lotteryType == self.LotteryType_3 and cfgFurniture.quality > 2 then
|
|
for k, v in pairs(goods3) do
|
|
if goodsId == v.id then
|
|
table.remove( goods3 , k)
|
|
if v.isSuit then
|
|
rareSuitCount = rareSuitCount + 1
|
|
end
|
|
break
|
|
end
|
|
end
|
|
end
|
|
if dataType.GoodsType_Decorate == goodsType then
|
|
self:DeleteAlreadyDec( goodsType , goodsId , goods1 , goods2 , goods3 )
|
|
end
|
|
--如果罕见家具为空了 则重新获取一次道具
|
|
if 0 == #goods3 then
|
|
goods3 = self:GetFurniture( player , lotteryId , dataType.FurnitureQuality_Rare , true )
|
|
end
|
|
end
|
|
--修改对应的卡池保底
|
|
if lotteryType == self.LotteryType_2 then
|
|
design.highCount = 10 - count
|
|
elseif lotteryType == self.LotteryType_3 then
|
|
--暗保机制 只用于限时卡池
|
|
--log.info("count",count)
|
|
--log.info("design.timeCardPoolInfo.timeCount",design.timeCardPoolInfo.timeCount)
|
|
--log.info("rareSuitCount",rareSuitCount)
|
|
--log.info("design.timeCardPoolInfo.last10FurCount",design.timeCardPoolInfo.last10FurCount)
|
|
--log.info("design.timeCardPoolInfo.design10Count",design.timeCardPoolInfo.design10Count)
|
|
if design.timeCardPoolInfo.last10FurCount >= cfgSValue.hiddenRaffleNegative[1] then
|
|
--如果上一次十连抽中的罕见套间数量大于配置数量 则本次抽中的罕见套间数量固定
|
|
if rareSuitCount > cfgSValue.hiddenRaffleNegative[2] then
|
|
--只用处理抽中的数量大于固定数量的情况
|
|
local needGetNew = false
|
|
local nowCount = count
|
|
for i=1,10,1 do
|
|
local reward = data.rewards[i]
|
|
local cfgFurniture = skynet.server.gameConfig:GetPlayerCurCfg( player , "Furniture" , reward.item.goodsId )
|
|
--如果该套件家具的索引小于保底索引 则不用重新获取
|
|
if cfgFurniture.quality > 2 and cfgFurniture.suitType > 0 then
|
|
if needGetNew then
|
|
--重新获取一次
|
|
local allGoods = goods1
|
|
for k , v in pairs(goods2) do
|
|
table.insert(allGoods,v)
|
|
end
|
|
local goodsType1,goodsId1 = self:AppointLottery(allGoods,false)
|
|
reward.item.goodsType = goodsType1
|
|
reward.item.goodsId = goodsId1
|
|
reward.isNew = not skynet.server.illustration:IsExistGoods( player , goodsType1 , goodsId1 ) --不存在就是新的
|
|
elseif i <= nowCount then
|
|
nowCount = i
|
|
needGetNew = true
|
|
end
|
|
end
|
|
end
|
|
design.timeCardPoolInfo.design10Count = 1
|
|
design.timeCardPoolInfo.last10FurCount = cfgSValue.hiddenRaffleNegative[2]
|
|
design.timeCardPoolInfo.timeCount = 10 - nowCount
|
|
else
|
|
if rareSuitCount < cfgSValue.hiddenRaffleNegative[2] then
|
|
--如果保底的不是套间家具 则重新获取一次
|
|
local reward = data.rewards[count]
|
|
local cfgFurniture = skynet.server.gameConfig:GetPlayerCurCfg( player , "Furniture" , reward.item.goodsId )
|
|
if cfgFurniture.quality > 2 and cfgFurniture.suitType == 0 then
|
|
--重新获取一次
|
|
local goodsType1,goodsId1 = self:AppointLottery(goods3,true)
|
|
reward.item.goodsType = goodsType1
|
|
reward.item.goodsId = goodsId1
|
|
reward.isNew = not skynet.server.illustration:IsExistGoods( player , goodsType1 , goodsId1 )
|
|
end
|
|
end
|
|
design.timeCardPoolInfo.design10Count = 1
|
|
design.timeCardPoolInfo.last10FurCount = cfgSValue.hiddenRaffleNegative[2]
|
|
design.timeCardPoolInfo.timeCount = 10 - count
|
|
end
|
|
elseif design.timeCardPoolInfo.design10Count > cfgSValue.hiddenRafflePositive[1]
|
|
and design.timeCardPoolInfo.last10FurCount <= cfgSValue.hiddenRaffleNegative[2] then
|
|
--如果本次十连抽数为暗保抽数 且 上一次抽到的罕见套间为保底个数
|
|
design.timeCardPoolInfo.design10Count = 0 --暗保后重置
|
|
design.timeCardPoolInfo.last10FurCount = cfgSValue.hiddenRafflePositive[2]
|
|
if rareSuitCount == cfgSValue.hiddenRaffleNegative[2] then
|
|
--如果保底的不是套间家具 则重新获取一次
|
|
local reward = data.rewards[count]
|
|
local cfgFurniture = skynet.server.gameConfig:GetPlayerCurCfg( player , "Furniture" , reward.item.goodsId )
|
|
if cfgFurniture.quality > 2 and cfgFurniture.suitType == 0 then
|
|
--重新获取一次
|
|
local goodsType1,goodsId1 = self:AppointLottery(goods3,true)
|
|
reward.item.goodsType = goodsType1
|
|
reward.item.goodsId = goodsId1
|
|
reward.isNew = not skynet.server.illustration:IsExistGoods( player , goodsType1 , goodsId1 )
|
|
end
|
|
--如果本次抽到的罕见套间为保底个数 则新增一个
|
|
while(true) do
|
|
local random = math.random(1,10)
|
|
if random ~= count then
|
|
if random > count then
|
|
design.timeCardPoolInfo.timeCount = 10 - random
|
|
else
|
|
design.timeCardPoolInfo.timeCount = 10 - count
|
|
end
|
|
--重新获取一次
|
|
local goodsType1,goodsId1 = self:AppointLottery(goods3,true)
|
|
data.rewards[random].item.goodsType = goodsType1
|
|
data.rewards[random].item.goodsId = goodsId1
|
|
data.rewards[random].isNew = not skynet.server.illustration:IsExistGoods( player , goodsType1 , goodsId1 ) --不存在就是新的
|
|
break
|
|
end
|
|
end
|
|
elseif rareSuitCount < cfgSValue.hiddenRaffleNegative[2] then
|
|
--如果本次抽到的罕见套间比保底个数还少 则新增至暗堡个数
|
|
local random = 0
|
|
if count > 1 then
|
|
random = math.random(1,count-1)
|
|
else
|
|
random = math.random(count+1,10)
|
|
end
|
|
--额外获取一个套间家具
|
|
local goodsType1,goodsId1 = self:AppointLottery(goods3,true)
|
|
data.rewards[random].item.goodsType = goodsType1
|
|
data.rewards[random].item.goodsId = goodsId1
|
|
data.rewards[random].isNew = not skynet.server.illustration:IsExistGoods( player , goodsType1 , goodsId1 )
|
|
--保底的重新获取 将之修改为套间家具
|
|
goodsType1,goodsId1 = self:AppointLottery(goods3,true)
|
|
data.rewards[count].item.goodsType = goodsType1
|
|
data.rewards[count].item.goodsId = goodsId1
|
|
data.rewards[count].isNew = not skynet.server.illustration:IsExistGoods( player , goodsType1 , goodsId1 )
|
|
|
|
design.timeCardPoolInfo.timeCount = count == 1 and 10 - random or 10 - count
|
|
elseif rareSuitCount > cfgSValue.hiddenRafflePositive[2] then
|
|
--如果本次抽到的罕见套间大于暗保个数 则减少对应个数至暗保个数
|
|
for i=1,rareSuitCount - cfgSValue.hiddenRafflePositive[2] ,1 do
|
|
for k , v in pairs(data.rewards) do
|
|
local cfgFurniture = skynet.server.gameConfig:GetPlayerCurCfg( player , "Furniture" , v.item.goodsId )
|
|
if cfgFurniture.quality > 2 and cfgFurniture.suitType > 0 then
|
|
--重新获取一次
|
|
local allGoods = goods1
|
|
for k1 , v1 in pairs(goods2) do
|
|
table.insert(allGoods,v1)
|
|
end
|
|
local goodsType1,goodsId1 = self:AppointLottery(allGoods,false)
|
|
v.item.goodsType = goodsType1
|
|
v.item.goodsId = goodsId1
|
|
break
|
|
end
|
|
end
|
|
end
|
|
design.timeCardPoolInfo.timeCount = 10 - count
|
|
elseif rareSuitCount == cfgSValue.hiddenRafflePositive[2] then
|
|
design.timeCardPoolInfo.timeCount = 10 - count
|
|
end
|
|
elseif design.timeCardPoolInfo.design10Count < cfgSValue.hiddenRafflePositive[1]
|
|
and rareSuitCount >= cfgSValue.hiddenRaffleNegative[1] then
|
|
--如果本次十连抽数不是暗保抽数 且 且本次抽到的罕见套间大于固定数量
|
|
design.timeCardPoolInfo.design10Count = 0 --直接重置暗保抽数
|
|
design.timeCardPoolInfo.timeCount = 10 - count
|
|
design.timeCardPoolInfo.last10FurCount = rareSuitCount
|
|
else
|
|
design.timeCardPoolInfo.timeCount = 10 - count
|
|
design.timeCardPoolInfo.last10FurCount = rareSuitCount
|
|
end
|
|
end
|
|
end
|
|
|
|
--发放奖励
|
|
for k, v in pairs( data.rewards ) do
|
|
log.debug(string.format("玩家 %d 设计间 发放奖励 商品类型 %d 商品ID %d 商品数量 %d", player.userId , v.item.goodsType , v.item.goodsId , v.item.goodsCount ))
|
|
skynet.server.bag:AddGoods( player , v.item.goodsType , v.item.goodsId , v.item.goodsCount )
|
|
end
|
|
end
|
|
end
|
|
--如果是第一次限定卡池的十连抽 触发商城对应礼包
|
|
if lotteryType == self.LotteryType_3 and lotteryTimes == self.LotteryTimes_Ten then
|
|
if not player.gameData.design.timeCardPoolInfo.first10Design then
|
|
player.gameData.design.timeCardPoolInfo.first10Design = true
|
|
skynet.server.store:TriggerPackMultiDraw(player)
|
|
end
|
|
end
|
|
data.lotteryType = lotteryType
|
|
data.designCurrency = self:GetTicket( player )
|
|
--保底次数
|
|
data.highCount = 10 - player.gameData.design.highCount --高级
|
|
if player.gameData.design.timeCardPoolInfo.id then
|
|
if player.gameData.design.timeCardPoolInfo.timeCount >= 10 then
|
|
player.gameData.design.timeCardPoolInfo.timeCount = player.gameData.design.timeCardPoolInfo.timeCount%10
|
|
end
|
|
data.timeCount = 10 - player.gameData.design.timeCardPoolInfo.timeCount --限时
|
|
end
|
|
--是否可以分享
|
|
if 0 == player.gameData.todayGain.designShare then
|
|
data.canShare = true
|
|
else
|
|
data.canShare = false
|
|
end
|
|
s2cData.cmd = pb.enum("MsgType","CMD_S2C_DesignLottery")
|
|
s2cData.data = assert(pb.encode("S2CDesignLottery", data))
|
|
end
|
|
|
|
--设计分享
|
|
function Design:Share( player , c2sData , s2cData )
|
|
c2sData.data = assert(pb.decode("C2SDesignShare", c2sData.data ))
|
|
local data = {}
|
|
local cfgSValue = skynet.server.gameConfig:GetPlayerAllCfg( player , "SValue")
|
|
local haveReward = false
|
|
if 0 == player.gameData.todayGain.designShare then
|
|
--本日未分享 发放对应奖励并修改相关数据
|
|
player.gameData.todayGain.designShare = 1
|
|
local eventId = pb.enum("EnumMoneyChangeEventID","EventID_24")
|
|
player:MoneyChange( cfgSValue.shareReward[1] , cfgSValue.shareReward[2] , eventId)
|
|
haveReward = true
|
|
end
|
|
data.designShare = player.gameData.todayGain.designShare
|
|
data.haveReward = haveReward
|
|
s2cData.cmd = pb.enum("MsgType","CMD_S2C_DesignShare")
|
|
s2cData.data = assert(pb.encode("S2CDesignShare", data))
|
|
end
|
|
|
|
--限时卡池奖励界面显示
|
|
function Design:TimeAwardShow( player , c2sData , s2cData )
|
|
c2sData.data = assert(pb.decode("C2SDesignTimeAwardShow", c2sData.data ))
|
|
local data = {}
|
|
local design = player.gameData.design
|
|
data.designCount = design.timeCardPoolInfo.designCount
|
|
data.timeAwardInfos = {}
|
|
for k ,v in pairs(design.timeCardPoolInfo.timeAward) do
|
|
local rewardInfo = skynet.server.common:Split( v.rewardInfo ,"_" )
|
|
rewardInfo[1],rewardInfo[2] = tonumber(rewardInfo[1]),tonumber(rewardInfo[2])
|
|
if rewardInfo[1] == self.BoxType_Normal then
|
|
table.insert(data.timeAwardInfos , {id = v.id,status = v.status,needDesignCount = v.needDesignCount,rewardType = rewardInfo[1],rewardId = rewardInfo[2]})
|
|
else
|
|
table.insert(data.timeAwardInfos , {id = v.id,status = v.status,needDesignCount = v.needDesignCount,rewardType = rewardInfo[1],rewardId = 0})
|
|
end
|
|
end
|
|
local activityId,startTime,endTime = skynet.server.activity:GetActivityInfo( player , dataType.ActivityType_Raffle , self.LotteryType_3 )
|
|
data.endTime = endTime
|
|
data.startTime = startTime
|
|
s2cData.cmd = pb.enum("MsgType","CMD_S2C_DesignTimeAwardShow")
|
|
s2cData.data = assert(pb.encode("S2CDesignTimeAwardShow", data))
|
|
end
|
|
|
|
--限时卡池奖励获取
|
|
function Design:TimeAwardGet( player , c2sData , s2cData )
|
|
c2sData.data = assert(pb.decode("C2SDesignTimeAwardGet", c2sData.data ))
|
|
local data = {}
|
|
local timeAwardId = c2sData.data.timeAwardId
|
|
local design = player.gameData.design
|
|
data.designCount = design.timeCardPoolInfo.designCount
|
|
data.timeAwardInfos = {}
|
|
data.conversionInfo = {}
|
|
for k , v in pairs(design.timeCardPoolInfo.timeAward) do
|
|
local rewardInfo = skynet.server.common:Split( v.rewardInfo ,"_" )
|
|
rewardInfo[1],rewardInfo[2] = tonumber(rewardInfo[1]),tonumber(rewardInfo[2])
|
|
if v.id == timeAwardId and 1 == v.status then
|
|
if rewardInfo[1] == self.BoxType_Normal then
|
|
--发放对应奖励 并修改相关数据
|
|
local eventId = pb.enum("EnumMoneyChangeEventID","EventID_61")
|
|
--被转化的奖励
|
|
local conversionInfo = player:GiveReward(rewardInfo[2] , eventId ,1)
|
|
local rewards = skynet.server.playerLand:GetRewardInfo(player , rewardInfo[2])
|
|
data.rewardInfos = rewards
|
|
data.conversionInfo = conversionInfo
|
|
--判断奖励是否包含头像或头像框
|
|
local haveHead = false
|
|
for k1 , v1 in pairs(rewards) do
|
|
if v1.type == dataType.GoodsType_HeadAndHeadFrame then
|
|
haveHead = true
|
|
break
|
|
end
|
|
end
|
|
if haveHead then
|
|
--主动推送一下玩家个人信息
|
|
local data1 = {}
|
|
data1.newOwn = {}
|
|
for k1 , v1 in pairs(rewards) do
|
|
local cfgHead = skynet.server.gameConfig:GetPlayerCurCfg( player , "Head" , v1.id )
|
|
table.insert(data1.newOwn , {ownType = cfgHead.type , ownId = v1.id})
|
|
end
|
|
skynet.server.gameServer:SendMsgToUser( player.userId , "CMD_S2C_PersonalUpdateOwnInfo" , data1 )
|
|
end
|
|
else
|
|
--盲盒奖励
|
|
local reward = self:BoxReward(player,player.gameData.design.timeCardPoolInfo.id)
|
|
for k1 , v1 in pairs(reward) do
|
|
skynet.server.bag:AddGoods( player , dataType.GoodsType_Furniture , v1.id , v1.count )
|
|
end
|
|
data.rewardInfos = reward
|
|
end
|
|
v.status = 2
|
|
skynet.server.msgTips:Reduce(player , 68)
|
|
end
|
|
if rewardInfo[1] == self.BoxType_Normal then
|
|
table.insert(data.timeAwardInfos , {id = v.id,status = v.status,needDesignCount = v.needDesignCount,rewardType = rewardInfo[1],rewardId = rewardInfo[2]})
|
|
else
|
|
table.insert(data.timeAwardInfos , {id = v.id,status = v.status,needDesignCount = v.needDesignCount,rewardType = rewardInfo[1],rewardId = 0})
|
|
end
|
|
end
|
|
local activityId,startTime,endTime = skynet.server.activity:GetActivityInfo( player , dataType.ActivityType_Raffle , self.LotteryType_3 )
|
|
data.endTime = endTime
|
|
s2cData.cmd = pb.enum("MsgType","CMD_S2C_DesignTimeAwardGet")
|
|
s2cData.data = assert(pb.encode("S2CDesignTimeAwardGet", data))
|
|
end
|
|
|
|
--高级卡池兑换商店显示
|
|
function Design:HighStoreShow( player , c2sData , s2cData )
|
|
c2sData.data = assert(pb.decode("C2SDesignHighStoreShow", c2sData.data ))
|
|
local data = {}
|
|
data.highStorePoints = player.gameData.design.highStorePoints
|
|
data.highStoreInfos = self:GetHighStoreInfo( player )
|
|
s2cData.cmd = pb.enum("MsgType","CMD_S2C_DesignHighStoreShow")
|
|
s2cData.data = assert(pb.encode("S2CDesignHighStoreShow", data))
|
|
end
|
|
|
|
--高级卡池兑换商店兑换
|
|
function Design:HighStoreRedeem( player , c2sData , s2cData )
|
|
c2sData.data = assert(pb.decode("C2SDesignHighStoreRedeem", c2sData.data ))
|
|
local data = {}
|
|
local cfgDecoration = skynet.server.gameConfig:GetPlayerAllCfg( player , "Decoration")
|
|
|
|
local goodsType = c2sData.data.goodsType
|
|
local goodsId = c2sData.data.goodsId
|
|
local redeemCount = c2sData.data.redeemCount
|
|
if dataType.GoodsType_Furniture == goodsType then
|
|
local cfgFurniture = skynet.server.gameConfig:GetPlayerCurCfg( player , "Furniture" , goodsId )
|
|
local needPoints = cfgFurniture.integral * redeemCount --需要的积分
|
|
if player.gameData.design.highStorePoints >= needPoints then
|
|
--积分足够 扣除相应积分 增加对应物品
|
|
player.gameData.design.highStorePoints = player.gameData.design.highStorePoints - needPoints
|
|
skynet.server.bag:AddGoods(player,goodsType,goodsId,redeemCount)
|
|
data.highRedeemPoints = player.gameData.design.highStorePoints
|
|
data.highRedeemInfos = self:GetHighStoreInfo( player )
|
|
data.awards = {type = goodsType,id = goodsId,count = redeemCount}
|
|
else
|
|
s2cData.code = errorInfo.ErrorCode.NoEnoughPoint
|
|
end
|
|
elseif dataType.GoodsType_Decorate == goodsType then
|
|
local needPoints = cfgDecoration[goodsId].integral * redeemCount --需要的积分
|
|
if player.gameData.design.highStorePoints >= needPoints then
|
|
--积分足够 扣除相应积分 增加对应物品
|
|
player.gameData.design.highStorePoints = player.gameData.design.highStorePoints - needPoints
|
|
skynet.server.bag:AddGoods(player,goodsType,goodsId,redeemCount)
|
|
data.highRedeemPoints = player.gameData.design.highStorePoints
|
|
data.highRedeemInfos = self:GetHighStoreInfo( player )
|
|
data.awards = {type = goodsType,id = goodsId,count = redeemCount}
|
|
else
|
|
s2cData.code = errorInfo.ErrorCode.NoEnoughPoint
|
|
end
|
|
end
|
|
s2cData.cmd = pb.enum("MsgType","CMD_S2C_DesignHighStoreRedeem")
|
|
s2cData.data = assert(pb.encode("S2CDesignHighStoreRedeem", data))
|
|
end
|
|
|
|
--限时卡池签到显示
|
|
function Design:TimeSignInShow( player , c2sData , s2cData )
|
|
c2sData.data = assert(pb.decode("C2SDesignTimeSignInShow", c2sData.data ))
|
|
local data = {}
|
|
data.timeSignIns = {}
|
|
if player.gameData.design.timeCardPoolInfo.id then
|
|
for k ,v in pairs(player.gameData.design.timeCardPoolInfo.timeSignIn) do
|
|
table.insert(data.timeSignIns , v)
|
|
end
|
|
end
|
|
s2cData.cmd = pb.enum("MsgType","CMD_S2C_DesignTimeSignInShow")
|
|
s2cData.data = assert(pb.encode("S2CDesignTimeSignInShow", data))
|
|
end
|
|
|
|
--限时卡池签到获取
|
|
function Design:TimeSignInGet( player , c2sData , s2cData )
|
|
c2sData.data = assert(pb.decode("C2SDesignTimeSignInGet", c2sData.data ))
|
|
local data = {}
|
|
local day = c2sData.data.day
|
|
data.timeSignIns = {}
|
|
local isShowUI = false
|
|
if player.gameData.design.timeCardPoolInfo.id then
|
|
for k , v in pairs(player.gameData.design.timeCardPoolInfo.timeSignIn) do
|
|
if v.day == day and v.status == 1 then
|
|
v.status = 2
|
|
local eventId = pb.enum("EnumMoneyChangeEventID","EventID_62")
|
|
player:GiveReward(v.rewardId , eventId , 1)
|
|
data.rewardId = v.rewardId
|
|
skynet.server.msgTips:Reduce(player , 69)
|
|
end
|
|
if v.status ~= 2 then
|
|
isShowUI = true
|
|
end
|
|
table.insert(data.timeSignIns , v)
|
|
end
|
|
end
|
|
data.isShowUI = isShowUI
|
|
s2cData.cmd = pb.enum("MsgType","CMD_S2C_DesignTimeSignInGet")
|
|
s2cData.data = assert(pb.encode("S2CDesignTimeSignInGet", data))
|
|
end
|
|
|
|
--设计概览
|
|
function Design:OverviewShow( player , c2sData ,s2cData )
|
|
c2sData.data = assert(pb.decode("C2SDesignOverviewShow", c2sData.data ))
|
|
local data = {}
|
|
data.overviewInfos = {}
|
|
local designType = c2sData.data.designType
|
|
if designType == self.LotteryType_1 then
|
|
local raffleId = self:GetLotteryId( player , "goldLotteryId" )
|
|
data.overviewInfos = self:GetGoodsInfo( player , raffleId)
|
|
elseif designType == self.LotteryType_2 then
|
|
local raffleId = self:GetLotteryId( player , "advancedLotteryId" )
|
|
data.overviewInfos = self:GetGoodsInfo( player , raffleId)
|
|
elseif designType == self.LotteryType_3 then
|
|
local raffleId = self:GetLotteryId( player , "limitedLotteryId" )
|
|
data.overviewInfos = self:GetGoodsInfo( player , raffleId)
|
|
end
|
|
s2cData.cmd = pb.enum("MsgType","CMD_S2C_DesignOverviewShow")
|
|
s2cData.data = assert(pb.encode("S2CDesignOverviewShow", data))
|
|
end
|
|
|
|
--限时累积充值展示
|
|
function Design:TimePointsShow( player , c2sData ,s2cData )
|
|
c2sData.data = assert(pb.decode("C2SDesignTimePointsShow", c2sData.data ))
|
|
local data = {}
|
|
--玩家积分
|
|
local raffleId = player.gameData.design.timeCardPoolInfo.id
|
|
--没有数据进行初始化
|
|
if raffleId == nil then
|
|
self:InitData(player)
|
|
raffleId = player.gameData.design.timeCardPoolInfo.id
|
|
end
|
|
if raffleId then
|
|
for k , v in pairs(player.gameData.design.timeCardPoints) do
|
|
if raffleId == v.raffleId then
|
|
data.points = v.points
|
|
data.pointsInfos = {}
|
|
for k1 ,v1 in pairs(v.pointsInfo) do
|
|
table.insert(data.pointsInfos , v1)
|
|
end
|
|
data.accumId = k
|
|
break
|
|
end
|
|
end
|
|
end
|
|
s2cData.cmd = pb.enum("MsgType","CMD_S2C_DesignTimePointsShow")
|
|
s2cData.data = assert(pb.encode("S2CDesignTimePointsShow", data))
|
|
end
|
|
|
|
--限时累积充值获取
|
|
function Design:TimePointsGet( player , c2sData ,s2cData )
|
|
c2sData.data = assert(pb.decode("C2SDesignTimePointsGet", c2sData.data ))
|
|
local id = c2sData.data.id
|
|
local data = {}
|
|
data.id = id
|
|
data.pointsInfos = {}
|
|
--获取玩家对应配置文件ValueAccumulate
|
|
local raffleId = player.gameData.design.timeCardPoolInfo.id
|
|
if raffleId then
|
|
for k , v in pairs(player.gameData.design.timeCardPoints) do
|
|
if raffleId == v.raffleId then
|
|
local cfgLimitedAccum = skynet.server.gameConfig:GetPlayerCurCfg( player , "LimitedAccum" , k )
|
|
for k1 ,v1 in pairs(v.pointsInfo) do
|
|
if v1.id == id and v1.isGet == 1 then
|
|
--进行发放奖励
|
|
local eventId = pb.enum("EnumMoneyChangeEventID","EventID_107")
|
|
player:GiveReward(cfgLimitedAccum.rewardId[k1], eventId , 1)
|
|
v1.isGet = 2
|
|
skynet.server.msgTips:Reduce(player , 94)
|
|
end
|
|
table.insert(data.pointsInfos,v1)
|
|
end
|
|
data.accumId = k
|
|
end
|
|
end
|
|
end
|
|
s2cData.cmd = pb.enum("MsgType","CMD_S2C_DesignTimePointsGet")
|
|
s2cData.data = assert(pb.encode("S2CDesignTimePointsGet", data))
|
|
end
|
|
|
|
--开始抽奖
|
|
function Design:StartLottery( player , lotteryType , isTenFloor , goods1 , goods2 , goods3 )
|
|
local cfgSValue = skynet.server.gameConfig:GetPlayerAllCfg( player , "SValue")
|
|
local design = player.gameData.design
|
|
local tenMustCount = cfgSValue.voluteRaffleRareNewGua --十连抽奖必出数量
|
|
|
|
--获取抽取概率
|
|
local rate = {} --1-普通 2-稀有 3-罕见
|
|
if self.LotteryType_1 == lotteryType then
|
|
rate[1],rate[2],rate[3] = cfgSValue.goldRaffleFurnitureRatio[2] * 100,cfgSValue.goldRaffleFurnitureRatio[1] * 100,0
|
|
skynet.server.taskListEvent:Modify( player , 9 , 1 )
|
|
elseif self.LotteryType_2 == lotteryType then
|
|
skynet.server.levelTask:Modify( player , 48 , 1 )
|
|
skynet.server.taskListEvent:Modify( player , 10 , 1 )
|
|
skynet.server.taskListEvent:Modify( player , 48 , 1 )
|
|
rate[1],rate[2],rate[3] = cfgSValue.seniorRaffleFurnitureRatio[3] * 100,cfgSValue.seniorRaffleFurnitureRatio[2] * 100,cfgSValue.seniorRaffleFurnitureRatio[1] * 100
|
|
elseif self.LotteryType_3 == lotteryType then
|
|
rate[1],rate[2],rate[3] = cfgSValue.voluteRaffleFurnitureRatio[3] * 100,cfgSValue.voluteRaffleFurnitureRatio[2] * 100,cfgSValue.voluteRaffleFurnitureRatio[1] * 100
|
|
end
|
|
|
|
rate[1],rate[2],rate[3] = math.floor(rate[1]),math.floor(rate[2]),math.floor(rate[3]) --取个整
|
|
|
|
local allRate = 0 --统计总概率
|
|
for k, v in pairs( rate ) do
|
|
allRate = allRate + v
|
|
end
|
|
local rand = math.random(1,allRate) --随机概率
|
|
local randIndex = 0 --对应概率索引
|
|
local allCount = 0
|
|
for k, v in pairs( rate ) do
|
|
allCount = allCount + v
|
|
if rand <= allCount then
|
|
randIndex = k
|
|
break
|
|
end
|
|
end
|
|
log.debug(string.format("玩家 %d 设计间 概率区间【1, %d】 分别抽取概率 %d %d %d 随机值 %d 商品品质 %d", player.userId , allRate , rate[1],rate[2],rate[3] ,rand ,randIndex))
|
|
|
|
local goodsType = 0
|
|
local goodsId = 0
|
|
if isTenFloor then
|
|
--开启保底
|
|
local noBuyGoods = {} --把未购买的家具和装修选出来
|
|
for k, v in pairs( goods3 ) do
|
|
if v.isSuit and not player:IsBuyGoods( v.type , v.id ) then
|
|
table.insert( noBuyGoods , v )
|
|
end
|
|
end
|
|
|
|
--确实都是购买了的,那么只随机家具
|
|
if 0 == #noBuyGoods then
|
|
for k, v in pairs( goods3 ) do
|
|
if dataType.GoodsType_Furniture == v.type then
|
|
table.insert( noBuyGoods , v )
|
|
end
|
|
end
|
|
end
|
|
goodsType,goodsId = self:GetRandOneGoods( noBuyGoods )
|
|
else
|
|
--不保底
|
|
if dataType.FurnitureQuality_Common == randIndex then
|
|
goodsType,goodsId = self:GetRandOneGoods( goods1 )
|
|
elseif dataType.FurnitureQuality_Special == randIndex then
|
|
goodsType,goodsId = self:GetRandOneGoods( goods2 )
|
|
elseif dataType.FurnitureQuality_Rare == randIndex then
|
|
goodsType,goodsId = self:GetRandOneGoods( goods3 )
|
|
end
|
|
end
|
|
|
|
design.curLotteryCount = design.curLotteryCount + 1
|
|
|
|
skynet.server.levelTask:Modify( player , 37 , 1 )
|
|
skynet.server.achieveTask:Modify( player , 37 , 1)
|
|
skynet.server.taskListEvent:Modify( player , 37 , 1)
|
|
if self.LotteryType_1 == lotteryType then
|
|
skynet.server.levelTask:Modify( player , 69 , 1 )
|
|
skynet.server.taskListEvent:Modify( player , 69 , 1 )
|
|
end
|
|
log.debug(string.format("玩家 %d 设计间 随机商品 %d", player.userId , goodsId or 0 ))
|
|
--成就任务处理
|
|
local cfgFurniture = skynet.server.gameConfig:GetPlayerCurCfg( player , "Furniture" , goodsId )
|
|
if cfgFurniture.quality ~= 3 then
|
|
skynet.server.achieveTask:Modify( player , 60 , 1) --未获取到罕见家具
|
|
skynet.server.taskListEvent:Modify( player , 60 , 1) --未获取到罕见家具
|
|
end
|
|
return goodsType,goodsId
|
|
end
|
|
|
|
--指定抽奖 用于暗保
|
|
function Design:AppointLottery( allGoods , isFloor )
|
|
local goodsType = dataType.GoodsType_Furniture
|
|
local goodsId = 0
|
|
local count = 0
|
|
while(count < 100) do
|
|
if isFloor then
|
|
local index = math.random(1,#allGoods)
|
|
if allGoods[index].isSuit then
|
|
goodsId = allGoods[index].id
|
|
break
|
|
end
|
|
count = count + 1
|
|
else
|
|
local index = math.random(1,#allGoods)
|
|
goodsId = allGoods[index].id
|
|
break
|
|
end
|
|
end
|
|
if goodsId == 0 then
|
|
local index = math.random(1,#allGoods)
|
|
goodsId = allGoods[index].id
|
|
end
|
|
return goodsType,goodsId
|
|
end
|
|
|
|
--商城充值
|
|
function Design:Pay( player , storeId )
|
|
if next(player.gameData.design.timeCardPoolInfo) ~= nil then
|
|
local cfgRaffle = skynet.server.gameConfig:GetPlayerCurCfg( player , "Raffle" , player.gameData.design.timeCardPoolInfo.id )
|
|
--一元礼包显示控制
|
|
if cfgRaffle.limitPack == storeId then
|
|
player.gameData.design.isBuyStorePack8 = true
|
|
end
|
|
--对应限时累充数据修改
|
|
--找到对应礼包充值价格
|
|
local packPrice = 0
|
|
local cfgAllStorePrice = skynet.server.gameConfig:GetPlayerAllCfg( player , "StorePrice")
|
|
for k , v in pairs(cfgAllStorePrice) do
|
|
if v.storePackId == storeId then
|
|
packPrice = v.price
|
|
break
|
|
end
|
|
end
|
|
--修改玩家的卡池累充额度
|
|
for k , v in pairs(player.gameData.design.timeCardPoints) do
|
|
if cfgRaffle.id == v.raffleId then
|
|
local cfgSValue = skynet.server.gameConfig:GetPlayerAllCfg( player , "SValue" )
|
|
v.points = v.points + packPrice/100 * cfgSValue.valueAccumulatePoint
|
|
--判断积分是否达到可以领取对应的积分奖励
|
|
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
|
|
|
|
--获取家具 去除装修类型的物品
|
|
function Design:GetFurniture( player , lotteryId , quality , getAll)
|
|
local goods = {} --家具和装修
|
|
local cfgFur = {}
|
|
local cfgDec = {}
|
|
local cfgRaffle = skynet.server.gameConfig:GetPlayerCurCfg( player , "Raffle" , lotteryId )
|
|
|
|
--添加散件家具
|
|
if dataType.FurnitureQuality_Common == quality then
|
|
cfgFur = cfgRaffle.ordinaryFurId
|
|
cfgDec = cfgRaffle.ordinaryDecId
|
|
elseif dataType.FurnitureQuality_Special == quality then
|
|
cfgFur = cfgRaffle.rarityFurId
|
|
cfgDec = cfgRaffle.rarityDecId
|
|
elseif dataType.FurnitureQuality_Rare == quality then
|
|
cfgFur = skynet.server.common:DeepCopy(cfgRaffle.rareFurId)
|
|
cfgDec = cfgRaffle.rareDecId
|
|
end
|
|
for k, v in pairs( cfgFur ) do
|
|
table.insert( goods , { type = dataType.GoodsType_Furniture , id = v , isSuit = false })
|
|
end
|
|
|
|
--获取装修 装修类只能通过其他方式获取
|
|
--for k, v in pairs( cfgDec ) do
|
|
-- if not player:IsBuyGoods( dataType.GoodsType_Decorate , v ) then
|
|
-- --未购买的装修才加入进来
|
|
-- table.insert( goods , { type = dataType.GoodsType_Decorate , id = v , isSuit = false })
|
|
-- end
|
|
--end
|
|
|
|
local cfgAllFurniture = skynet.server.gameConfig:GetPlayerAllCfg( player , "Furniture")
|
|
if self.LotteryType_3 == cfgRaffle.raffleType then
|
|
--如果是限时卡池 则只能抽取未拥有的罕见家具
|
|
goods = {}
|
|
local ownGoods = {} --存储拥有的家具
|
|
--套装
|
|
for k1, v1 in pairs( cfgRaffle.suitId ) do
|
|
for k2, v2 in pairs(cfgAllFurniture) do
|
|
if v1 == v2.suitType and quality == v2.quality and not player:IsBuyGoods( dataType.GoodsType_Furniture , v2.id ) then
|
|
table.insert( goods , { type = dataType.GoodsType_Furniture , id = v2.id , isSuit = true })
|
|
elseif v1 == v2.suitType and quality == v2.quality and player:IsBuyGoods( dataType.GoodsType_Furniture , v2.id ) then
|
|
table.insert( ownGoods , { type = dataType.GoodsType_Furniture , id = v2.id , isSuit = true })
|
|
end
|
|
end
|
|
end
|
|
--散件
|
|
if self.LotteryType_3 == cfgRaffle.raffleType and dataType.FurnitureQuality_Rare == quality then
|
|
for k, v in pairs( cfgFur ) do
|
|
if not player:IsBuyGoods( dataType.GoodsType_Furniture , v ) then
|
|
--如果不拥有则添加进去
|
|
table.insert( goods , { type = dataType.GoodsType_Furniture , id = v , isSuit = false })
|
|
end
|
|
end
|
|
end
|
|
--全都有了 就随便抽了 or 特殊处理保底问题
|
|
if 0 == #goods or getAll then
|
|
--套装
|
|
goods = ownGoods
|
|
--散件
|
|
for k, v in pairs( cfgFur ) do
|
|
table.insert( goods , { type = dataType.GoodsType_Furniture , id = v , isSuit = false })
|
|
end
|
|
end
|
|
elseif self.LotteryType_2 == cfgRaffle.raffleType then
|
|
--高级卡池的罕见家具替换为套装家具
|
|
for k1, v1 in pairs( cfgRaffle.suitId ) do
|
|
for k2, v2 in pairs(cfgAllFurniture) do
|
|
if v1 == v2.suitType and (quality - 1) == v2.quality then
|
|
table.insert( goods , { type = dataType.GoodsType_Furniture , id = v2.id , isSuit = true })
|
|
end
|
|
end
|
|
end
|
|
elseif self.LotteryType_1 == cfgRaffle.raffleType then
|
|
for k1, v1 in pairs( cfgRaffle.suitId ) do
|
|
for k2, v2 in pairs(cfgAllFurniture) do
|
|
if v1 == v2.suitType and quality == v2.quality then
|
|
table.insert( goods , { type = dataType.GoodsType_Furniture , id = v2.id , isSuit = true })
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
--套装装修
|
|
--local cfgAllDecoration = skynet.server.gameConfig:GetPlayerAllCfg( player , "Decoration")
|
|
--for k1, v1 in pairs( cfgRaffle.suitId ) do
|
|
-- for k2, v2 in pairs(cfgAllDecoration) do
|
|
-- if v1 == v2.suitType and quality == v2.quality and not player:IsBuyGoods( dataType.GoodsType_Decorate , v2.id ) then
|
|
-- table.insert( goods , { type = dataType.GoodsType_Decorate , id = v2.id , isSuit = true })
|
|
-- end
|
|
-- end
|
|
--end
|
|
return goods
|
|
end
|
|
|
|
--获取券信息
|
|
function Design:GetTicket( player )
|
|
local design = player.gameData.design
|
|
local data = {}
|
|
data.basicBluePrint = skynet.server.bag:GetGoodsCount( player , dataType.GoodsType_Prop , 1)
|
|
data.advancedBluePrint = skynet.server.bag:GetGoodsCount( player , dataType.GoodsType_Prop , 2)
|
|
--if player.gameData.design.timeCardPoolInfo.ticket then
|
|
--data.limitedBluePrint = skynet.server.bag:GetGoodsCount( player , dataType.GoodsType_Prop , player.gameData.design.timeCardPoolInfo.ticket)
|
|
--else
|
|
data.limitedBluePrint = skynet.server.bag:GetGoodsCount( player , dataType.GoodsType_Prop , self.TicketType_3)
|
|
--end
|
|
--玩家高级卡池的积分
|
|
data.highStorePoints = player.gameData.design.highStorePoints
|
|
return data
|
|
end
|
|
|
|
--获取不重复的商品
|
|
function Design:GetRandOneGoods( cfgAllGoods)
|
|
local randList = {}
|
|
local randIndex = nil
|
|
local newGoods = {}
|
|
local whileCount = 0
|
|
|
|
local goodsType = 0
|
|
local goodsId = 0
|
|
|
|
while true do
|
|
if 0 == #cfgAllGoods then
|
|
break
|
|
end
|
|
|
|
randIndex = math.random( 1, #cfgAllGoods)
|
|
if not randList[ randIndex ] then
|
|
--不存在新的列表就添加进去
|
|
goodsType = cfgAllGoods[ randIndex ].type
|
|
goodsId = cfgAllGoods[ randIndex ].id
|
|
randList[ randIndex ] = true
|
|
end
|
|
|
|
--找够了数据或者循环了1000次就退出
|
|
if 0 ~= goodsType or whileCount >= 1000 then
|
|
break
|
|
end
|
|
|
|
whileCount = whileCount + 1
|
|
end
|
|
return goodsType,goodsId
|
|
end
|
|
|
|
--删除已购买的装修
|
|
function Design:DeleteAlreadyDec( goodsType , goodsId , goods1 , goods2 , goods3 )
|
|
for k, v in pairs(goods1) do
|
|
if goodsType == v.type and goodsId == v.id then
|
|
table.remove( goods1 , k)
|
|
break
|
|
end
|
|
end
|
|
|
|
for k, v in pairs(goods2) do
|
|
if goodsType == v.type and goodsId == v.id then
|
|
table.remove( goods2 , k)
|
|
break
|
|
end
|
|
end
|
|
|
|
for k, v in pairs(goods3) do
|
|
if goodsType == v.type and goodsId == v.id then
|
|
table.remove( goods3 , k)
|
|
break
|
|
end
|
|
end
|
|
end
|
|
|
|
--检查是否有可以领取的限时奖励
|
|
function Design:CheckCanGetReward( player )
|
|
if player.gameData.design.timeCardPoolInfo.timeAward then
|
|
for k ,v in pairs(player.gameData.design.timeCardPoolInfo.timeAward) do
|
|
if player.gameData.design.timeCardPoolInfo.designCount >= v.needDesignCount and 0 == v.status then
|
|
v.status = 1
|
|
skynet.server.msgTips:Add(player , 68)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
--获取该玩家高级卡池兑换商店物品的信息
|
|
function Design:GetHighStoreInfo( player )
|
|
local cfgRaffle = skynet.server.gameConfig:GetPlayerAllCfg( player , "Raffle")
|
|
local cfgFurniture = skynet.server.gameConfig:GetPlayerAllCfg( player , "Furniture")
|
|
--存储兑换物品相关信息
|
|
local highStoreInfos = {}
|
|
--普通家具
|
|
local advancedLotteryId = self:GetLotteryId( player , "advancedLotteryId" )
|
|
for k ,v in pairs(cfgRaffle[ advancedLotteryId ].ordinaryFurId) do
|
|
local have = player:IsBuyGoods(dataType.GoodsType_Furniture,v) --是否拥有
|
|
local needPoints = skynet.server.gameConfig:GetPlayerCurCfg( player , "Furniture" , v).integral --需要的积分
|
|
table.insert(highStoreInfos , {goodsId=v , goodsType=dataType.GoodsType_Furniture,needPoints = needPoints,status = have,suitId = 0})
|
|
end
|
|
--普通装修
|
|
for k ,v in pairs(cfgRaffle[ advancedLotteryId ].ordinaryDecId) do
|
|
local have = player:IsBuyGoods(dataType.GoodsType_Decorate,v) --是否拥有
|
|
local needPoints = skynet.server.gameConfig:GetPlayerCurCfg( player , "Decoration" , v).integral --需要的积分
|
|
table.insert(highStoreInfos , {goodsId=v , goodsType=dataType.GoodsType_Decorate,needPoints=needPoints,status=have,suitId = 0})
|
|
end
|
|
--稀有家具
|
|
for k ,v in pairs(cfgRaffle[ advancedLotteryId ].rarityFurId) do
|
|
local have = player:IsBuyGoods(dataType.GoodsType_Furniture,v) --是否拥有
|
|
local needPoints = skynet.server.gameConfig:GetPlayerCurCfg( player , "Furniture" , v).integral --需要的积分
|
|
table.insert(highStoreInfos , {goodsId=v , goodsType=dataType.GoodsType_Furniture,needPoints=needPoints,status=have,suitId = 0})
|
|
end
|
|
--稀有装修
|
|
for k ,v in pairs(cfgRaffle[ advancedLotteryId ].rarityDecId) do
|
|
local have = player:IsBuyGoods(dataType.GoodsType_Decorate,v) --是否拥有
|
|
local needPoints = skynet.server.gameConfig:GetPlayerCurCfg( player , "Decoration" , v).integral --需要的积分
|
|
table.insert(highStoreInfos , {goodsId=v , goodsType=dataType.GoodsType_Decorate,needPoints=needPoints,status=have,suitId = 0})
|
|
end
|
|
--罕见家具
|
|
for k ,v in pairs(cfgRaffle[ advancedLotteryId ].rareFurId) do
|
|
local have = player:IsBuyGoods(dataType.GoodsType_Furniture,v) --是否拥有
|
|
local needPoints = skynet.server.gameConfig:GetPlayerCurCfg( player , "Furniture" , v).integral --需要的积分
|
|
table.insert(highStoreInfos , {goodsId=v , goodsType=dataType.GoodsType_Furniture,needPoints=needPoints,status=have,suitId = 0})
|
|
end
|
|
--罕见装修
|
|
for k ,v in pairs(cfgRaffle[ advancedLotteryId ].rareDecId) do
|
|
local have = player:IsBuyGoods(dataType.GoodsType_Decorate,v) --是否拥有
|
|
local needPoints = skynet.server.gameConfig:GetPlayerCurCfg( player , "Decoration" , v).integral --需要的积分
|
|
table.insert(highStoreInfos , {goodsId=v , goodsType=dataType.GoodsType_Decorate,needPoints=needPoints,status=have,suitId = 0})
|
|
end
|
|
--套装物品
|
|
for k ,v in pairs(cfgRaffle[ advancedLotteryId ].suitId) do
|
|
for k1, v1 in pairs( cfgFurniture ) do
|
|
if v == v1.suitType then
|
|
local have = player:IsBuyGoods(dataType.GoodsType_Furniture,v1.id) --是否拥有
|
|
local needPoints = v1.integral --需要的积分
|
|
table.insert(highStoreInfos , {goodsId=v1.id , goodsType=dataType.GoodsType_Furniture,needPoints=needPoints,status=have,suitId = v})
|
|
end
|
|
end
|
|
end
|
|
return highStoreInfos
|
|
end
|
|
|
|
--获取该玩家对应卡池的物品相关信息
|
|
function Design:GetGoodsInfo( player , raffleId)
|
|
local cfgRaffle = skynet.server.gameConfig:GetPlayerCurCfg( player , "Raffle" , raffleId)
|
|
local cfgFurniture = skynet.server.gameConfig:GetPlayerAllCfg( player , "Furniture")
|
|
local cfgDecoration = skynet.server.gameConfig:GetPlayerAllCfg( player , "Decoration")
|
|
--存储兑换物品相关信息
|
|
local overviewInfos = {}
|
|
for k ,v in pairs(cfgRaffle.ordinaryFurId) do
|
|
local have = player:IsBuyGoods(dataType.GoodsType_Furniture,v) --是否拥有
|
|
if have then
|
|
table.insert(overviewInfos , {goodsId = v , goodsType = dataType.GoodsType_Furniture})
|
|
end
|
|
end
|
|
--普通装修
|
|
for k ,v in pairs(cfgRaffle.ordinaryDecId) do
|
|
local have = player:IsBuyGoods(dataType.GoodsType_Decorate,v) --是否拥有
|
|
if have then
|
|
table.insert(overviewInfos , {goodsId = v , goodsType = dataType.GoodsType_Decorate})
|
|
end
|
|
end
|
|
--稀有家具
|
|
for k ,v in pairs(cfgRaffle.rarityFurId) do
|
|
local have = player:IsBuyGoods(dataType.GoodsType_Furniture,v) --是否拥有
|
|
if have then
|
|
table.insert(overviewInfos , {goodsId = v , goodsType = dataType.GoodsType_Furniture})
|
|
end
|
|
end
|
|
--稀有装修
|
|
for k ,v in pairs(cfgRaffle.rarityDecId) do
|
|
local have = player:IsBuyGoods(dataType.GoodsType_Decorate,v) --是否拥有
|
|
if have then
|
|
table.insert(overviewInfos , {goodsId = v , goodsType = dataType.GoodsType_Decorate})
|
|
end
|
|
end
|
|
--罕见家具
|
|
for k ,v in pairs(cfgRaffle.rareFurId) do
|
|
local have = player:IsBuyGoods(dataType.GoodsType_Furniture,v) --是否拥有
|
|
if have then
|
|
table.insert(overviewInfos , {goodsId = v , goodsType = dataType.GoodsType_Furniture})
|
|
end
|
|
end
|
|
--罕见装修
|
|
for k ,v in pairs(cfgRaffle.rareDecId) do
|
|
local have = player:IsBuyGoods(dataType.GoodsType_Decorate,v) --是否拥有
|
|
if have then
|
|
table.insert(overviewInfos , {goodsId = v , goodsType = dataType.GoodsType_Decorate})
|
|
end
|
|
end
|
|
--套装物品
|
|
for k ,v in pairs(cfgRaffle.suitId) do
|
|
for k1, v1 in pairs( cfgFurniture ) do
|
|
if v == v1.suitType then
|
|
local have = player:IsBuyGoods(dataType.GoodsType_Furniture,v1.id) --是否拥有
|
|
if have then
|
|
table.insert(overviewInfos , {goodsId = v1.id , goodsType = dataType.GoodsType_Furniture})
|
|
end
|
|
end
|
|
end
|
|
for k1, v1 in pairs( cfgDecoration ) do
|
|
if v == v1.suitType then
|
|
local have = player:IsBuyGoods(dataType.GoodsType_Decorate,v1.id) --是否拥有
|
|
if have then
|
|
table.insert(overviewInfos , {goodsId = v1.id , goodsType = dataType.GoodsType_Decorate})
|
|
end
|
|
end
|
|
end
|
|
end
|
|
return overviewInfos
|
|
end
|
|
|
|
--限时卡池即将过期 发送公告(取消)
|
|
function Design:TimeCardPoolExpiredCancel( player )
|
|
local nowTime = skynet.GetTime()
|
|
local activityId,startTime,endTime = skynet.server.activity:GetActivityInfo( player , dataType.ActivityType_Raffle , self.LotteryType_3 )
|
|
--确保该活动开启了
|
|
if activityId > 0 and nowTime > startTime then
|
|
--判断该活动是否是最后一天
|
|
if nowTime >= endTime - 24 * 60 * 60 and nowTime < endTime then
|
|
--发送公告
|
|
local title = "限时活动即将结束"
|
|
local content = "限时活动套件剩余时间已不足一天,请各位蜗宝们及时换取心仪的套件家具~"
|
|
skynet.server.announcement:AddAnnouncementByBS(title , content , skynet.server.announcement.EventAnnouncement)
|
|
end
|
|
end
|
|
end
|
|
|
|
--盲盒随机奖励
|
|
function Design:BoxReward( player , raffleId )
|
|
local cfgRaffle = skynet.server.gameConfig:GetPlayerCurCfg( player , "Raffle" , raffleId )
|
|
local cfgSValue = skynet.server.gameConfig:GetPlayerAllCfg( player , "SValue" )
|
|
local rewards = {}
|
|
local frameId = cfgRaffle.frameId --所有可以进行随机的家具id
|
|
local raffleBlindBoxReward = cfgSValue.raffleBlindBoxReward --设计奖励盲盒开启的已拥有套间家具与未拥有套间家具的占比
|
|
local haveFur = {} --拥有的家具id集合
|
|
local notFur = {} --未拥有的家具id集合
|
|
for k , v in pairs(frameId) do
|
|
local have = skynet.server.illustration:IsExistGoods( player , dataType.GoodsType_Furniture , v ) --是否拥有
|
|
if have then
|
|
table.insert(haveFur , v)
|
|
else
|
|
table.insert(notFur , v)
|
|
end
|
|
end
|
|
--没有未拥有的家具 则不用看中间值了
|
|
if #notFur == 0 then
|
|
local count = math.random(1 , #haveFur)
|
|
table.insert(rewards ,{ type = dataType.GoodsType_Furniture , id = haveFur[count] , count = 1})
|
|
else
|
|
--依照比例确定本次盲盒奖励是拥有还是未拥有
|
|
local count = math.random(1 , 10)
|
|
if count <= 10 * raffleBlindBoxReward then
|
|
local count1 = math.random(1 , #haveFur)
|
|
table.insert(rewards ,{ type = dataType.GoodsType_Furniture , id = haveFur[count1] , count = 1})
|
|
else
|
|
local count1 = math.random(1 , #notFur)
|
|
table.insert(rewards ,{ type = dataType.GoodsType_Furniture , id = notFur[count1] , count = 1})
|
|
end
|
|
end
|
|
return rewards
|
|
end
|
|
|
|
skynet.server.design = Design
|
|
return Design |