HomeServer/lualib-src/Server-main/AllServer/GameServer/Lottery/GlodCoinLottery.lua
2024-11-20 15:41:37 +08:00

68 lines
2.5 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 lottery = require "Lottery"
local GlodCoinLottery = oo.class(lottery)
GlodCoinLottery.lotteryType = dataType.LotteryType_LongTime
--初始化数据
function GlodCoinLottery:InitData( player , lotteryType )
if not player.gameData.lottery[ lotteryType ] then
player.gameData.lottery[ lotteryType ] = {}
end
player.gameData.nextFreeTime = skynet.GetTime() --下一次免费抽奖时间
end
--金币抽奖展示
function GlodCoinLottery:Show( player , c2sData , s2cData )
c2sData.data = assert(pb.decode("C2SFlowerShopShow", c2sData.data ))
local data = {}
s2cData.cmd = pb.enum("MsgType","CMD_S2C_FlowerShopShow")
s2cData.data = assert(pb.encode("S2CFlowerShopShow", data))
end
--金币抽奖展示
function GlodCoinLottery:Lottery( player , c2sData , s2cData )
c2sData.data = assert(pb.decode("C2SFlowerShopShow", c2sData.data ))
local data = {}
local lotteryType = c2sData.data.lotteryType
local lotteryTimes = c2sData.data.lotteryTimes
if not lotteryType or not lotteryTimes then
s2cData.code = errorInfo.ErrorCode.ErrRequestParam
else
local isVaild = false
if lotteryType == self.LotteryType_Free and skynet.GetTime() >= player.gameData.nextFreeTime then
player:AddTodayData("goldCoinLotteryFreeCount", 1)
player.gameData.nextFreeTime = skynet.GetTime() + 900 --下一次15分钟后
isVaild = true
elseif lotteryType == self.LotteryType_Free and skynet.GetTime() < player.gameData.nextFreeTime then --时间未到
--返回错误无法获取
elseif lotteryType == self.LotteryType_LotteryType_Normal then
isVaild = true
end
if isVaild then
if self.LotteryTimes_One == lotteryTimes then --抽一次
self:StartLottery()
elseif self.LotteryTimes_Ten == lotteryTimes then --抽十次
for i = 1, 10, 1 do
self:StartLottery()
end
end
end
end
s2cData.cmd = pb.enum("MsgType","CMD_S2C_FlowerShopShow")
s2cData.data = assert(pb.encode("S2CFlowerShopShow", data))
end
--开始抽奖
function GlodCoinLottery:StartLottery()
end
skynet.server.glodCoinLottery = GlodCoinLottery
return GlodCoinLottery