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 DesignLottery = oo.class(lottery) DesignLottery.lotteryType = dataType.LotteryType_LongTime --初始化数据 function DesignLottery:InitData( player , lotteryType ) if not player.gameData.lottery[ lotteryType ] then player.gameData.lottery[ lotteryType ] = {} end player.gameData.nextFreeTime = os.time() --下一次免费抽奖时间 end --金币抽奖展示 function DesignLottery: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 DesignLottery: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 os.time() >= player.gameData.nextFreeTime then player:AddTodayData("goldCoinLotteryFreeCount", 1) player.gameData.nextFreeTime = os.time() + 900 --下一次15分钟后 isVaild = true elseif lotteryType == self.LotteryType_Free and os.time() < 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 DesignLottery:StartLottery() end skynet.server.designLottery = DesignLottery return DesignLottery