502 lines
21 KiB
Lua
502 lines
21 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 activity = require "Activity"
|
|||
|
|
local taskListEvent = require "TaskListEvent"
|
|||
|
|
local json = require "json"
|
|||
|
|
local ActivityFlipCard = oo.class(activity)
|
|||
|
|
|
|||
|
|
ActivityFlipCard.ActivityType = dataType.ActivityType_FlipCard
|
|||
|
|
|
|||
|
|
ActivityFlipCard.TaskType_Daily = 1 -- 每日任务
|
|||
|
|
ActivityFlipCard.TaskType_Normal = 2 -- 常规任务
|
|||
|
|
|
|||
|
|
function ActivityFlipCard:Init()
|
|||
|
|
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- 玩家翻翻乐数据初始化
|
|||
|
|
function ActivityFlipCard:InitData(player, activityType)
|
|||
|
|
-- 翻翻乐数据
|
|||
|
|
local activityId, startTime, endTime = self:GetActivityInfo(player, activityType)
|
|||
|
|
local cfgActivity = skynet.server.gameConfig:GetPlayerAllCfg(player, "Activity")
|
|||
|
|
local level = 0
|
|||
|
|
for k, v in pairs(cfgActivity) do
|
|||
|
|
if v.activityType == dataType.ActivityType_FlipCard then -- 活动翻翻乐
|
|||
|
|
level = v.level
|
|||
|
|
break
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- 是否存在数据
|
|||
|
|
if player.gameData.activity[activityType] ~= nil--存在玩家活动数据
|
|||
|
|
and next(player.gameData.activity[activityType])
|
|||
|
|
and player.gameData.activity[activityType].flipCardId == activityId then--活动id相同,说明已经初始化过数据了
|
|||
|
|
return
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--是否需要初始化
|
|||
|
|
if activityId > 0 and player.gameData.level >= level then
|
|||
|
|
|
|||
|
|
-- 玩家对应配置
|
|||
|
|
local cfgFlipCards = skynet.server.gameConfig:GetPlayerCurCfg(player, "FlipCards", activityId)
|
|||
|
|
local cfgCardTask = skynet.server.gameConfig:GetPlayerAllCfg(player, "FlipCardsTask")
|
|||
|
|
local cfgCardLevel = skynet.server.gameConfig:GetPlayerAllCfg(player, "FlipCardsLevel")
|
|||
|
|
player.gameData.activity[activityType]={}--清理以往的活动数据
|
|||
|
|
player.gameData.activity[activityType].flipCardId = activityId -- 本次活动id
|
|||
|
|
player.gameData.activity[activityType].activeValue = 0 -- 活跃值
|
|||
|
|
player.gameData.activity[activityType].nowFlipCardData = {} -- 本次游戏数据
|
|||
|
|
player.gameData.activity[activityType].cardTasks = {} -- 活跃值任务
|
|||
|
|
player.gameData.activity[activityType].flipCardInfos = {} -- 玩家翻翻乐的相关信息
|
|||
|
|
for i = 1, #cfgFlipCards.cardsLevelId, 1 do
|
|||
|
|
local levelId =cfgFlipCards.cardsLevelId[i]
|
|||
|
|
player.gameData.activity[activityType].flipCardInfos[i] = {}
|
|||
|
|
player.gameData.activity[activityType].flipCardInfos[i].id = levelId -- 当前关卡等级
|
|||
|
|
player.gameData.activity[activityType].flipCardInfos[i].needActValue = cfgCardLevel[levelId].activeValue -- 当前关卡需要的活跃值
|
|||
|
|
if i == 1 then
|
|||
|
|
player.gameData.activity[activityType].flipCardInfos[i].status = 1 -- 当前关卡状态 0 未解锁 1已解锁 2已完成
|
|||
|
|
player.gameData.activity[activityType].nowFlipCardData.id = 1
|
|||
|
|
else
|
|||
|
|
player.gameData.activity[activityType].flipCardInfos[i].status = 0 -- 当前关卡状态 0 未解锁 1已解锁 2已完成
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
for k, v in pairs(cfgCardTask) do
|
|||
|
|
-- 任务数据 id , 任务类型 , 进度 , 状态
|
|||
|
|
table.insert(player.gameData.activity[activityType].cardTasks, {
|
|||
|
|
id = v.id,
|
|||
|
|
type = v.taskType,
|
|||
|
|
progress = 0,
|
|||
|
|
status = skynet.server.task.TaskStatus_NoComplete
|
|||
|
|
})
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- 本次游戏数据初始
|
|||
|
|
player.gameData.activity[activityType].nowFlipCardData.gameEndTime = 0
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- 每次登录需要进行修改的数据
|
|||
|
|
function ActivityFlipCard:LoginInitData(player)
|
|||
|
|
|
|||
|
|
-- 重置翻翻乐红点
|
|||
|
|
skynet.server.msgTips:Reset(player, 102)
|
|||
|
|
skynet.server.msgTips:Reset(player, 103)
|
|||
|
|
|
|||
|
|
--检查是否需要清理过期道具
|
|||
|
|
self:CheckFlipCardGoods(player)
|
|||
|
|
|
|||
|
|
-- 检查应该初始还是结束活动
|
|||
|
|
local cfgActivity = skynet.server.gameConfig:GetPlayerAllCfg(player, "Activity")
|
|||
|
|
|
|||
|
|
-- 翻翻乐数据
|
|||
|
|
local activityId, startTime, endTime = self:GetActivityInfo(player, self.ActivityType)
|
|||
|
|
|
|||
|
|
--活动未开启
|
|||
|
|
if activityId == 0 then
|
|||
|
|
return
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
local level = 0
|
|||
|
|
for k, v in pairs(cfgActivity) do
|
|||
|
|
if v.activityType == dataType.ActivityType_FlipCard then -- 活动翻翻乐
|
|||
|
|
level = v.level
|
|||
|
|
break
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
if player.gameData.level >= level then
|
|||
|
|
|
|||
|
|
--检查初始化
|
|||
|
|
self:InitData(player, self.ActivityType)
|
|||
|
|
|
|||
|
|
if player.gameData.activity[self.ActivityType]
|
|||
|
|
and next(player.gameData.activity[self.ActivityType]) ~= nil and
|
|||
|
|
player.gameData.activity[self.ActivityType].flipCardId ~= nil then
|
|||
|
|
-- 判断该活动是否到期
|
|||
|
|
if skynet.GetTime() > endTime or activityId > player.gameData.activity[self.ActivityType].flipCardId then
|
|||
|
|
-- player.gameData.activity[self.ActivityType].id = v.id -- 记录该活动的id
|
|||
|
|
-- 初始玩家数据
|
|||
|
|
player.gameData.activity[self.ActivityType] = {}
|
|||
|
|
else
|
|||
|
|
-- 红点系统
|
|||
|
|
if player.gameData.activity[self.ActivityType] and next(player.gameData.activity[self.ActivityType]) ~= nil then
|
|||
|
|
self:CheckFlipCardLevel(player)
|
|||
|
|
-- 有关卡可以挑战时 添加对应红点
|
|||
|
|
for k, v in pairs(player.gameData.activity[self.ActivityType].flipCardInfos) do
|
|||
|
|
if v.status == 1 then
|
|||
|
|
skynet.server.msgTips:AddNoNotice(player, 103)
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
-- 有活跃值可以领取时 添加对应红点
|
|||
|
|
for k, v in pairs(player.gameData.activity[self.ActivityType].cardTasks) do
|
|||
|
|
if v.status == skynet.server.task.TaskStatus_AlreadyComplete then
|
|||
|
|
skynet.server.msgTips:AddNoNotice(player, 102)
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--检查是否需要清理过期道具
|
|||
|
|
function ActivityFlipCard:CheckFlipCardGoods(player)
|
|||
|
|
|
|||
|
|
-- 翻翻乐数据
|
|||
|
|
local activityId, _, _,_ = self:GetActivityInfo(player, self.ActivityType)
|
|||
|
|
|
|||
|
|
--没有活动数据,直接返回
|
|||
|
|
if not player.gameData.activity[self.ActivityType] or next(player.gameData.activity[self.ActivityType]) == nil then
|
|||
|
|
if activityId <= 0 then
|
|||
|
|
|
|||
|
|
local cfgFliCars= skynet.server.gameConfig:GetPlayerAllCfg(player, "FlipCards")
|
|||
|
|
for _, cfgFliCar in ipairs(cfgFliCars) do
|
|||
|
|
local goodsCount=skynet.server.bag:GetGoodsCount(player,dataType.GoodsType_Prop, cfgFliCar.ticketId)
|
|||
|
|
if goodsCount > 0 then
|
|||
|
|
log.info(string.format("清理过期玫瑰卡牌数据2,道具id:%d,数量:%d",cfgFliCar.ticketId,goodsCount))
|
|||
|
|
|
|||
|
|
--扣除道具
|
|||
|
|
skynet.server.bag:RemoveGoods(player,dataType.GoodsType_Prop, cfgFliCar.ticketId ,goodsCount)--扣除玫瑰卡片
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
return
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--活动不相等
|
|||
|
|
if player.gameData.activity[self.ActivityType].flipCardId ~= activityId then
|
|||
|
|
|
|||
|
|
local cfgFliCar= skynet.server.gameConfig:GetPlayerCurCfg(player, "FlipCards", player.gameData.activity[self.ActivityType].flipCardId)
|
|||
|
|
if cfgFliCar ~= nil then
|
|||
|
|
local goodsCount=skynet.server.bag:GetGoodsCount(player,dataType.GoodsType_Prop, cfgFliCar.ticketId)
|
|||
|
|
if goodsCount > 0 then
|
|||
|
|
--log.info(string.format("清理过期玫瑰卡牌数据2,活动id:%d,道具id:%d,数量:%d",player.gameData.activity[self.ActivityType].flipCardId,cfgFliCar.ticketId ,goodsCount))
|
|||
|
|
|
|||
|
|
--扣除道具
|
|||
|
|
skynet.server.bag:RemoveGoods(player,dataType.GoodsType_Prop, cfgFliCar.ticketId ,goodsCount)--扣除玫瑰卡片
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
player.gameData.activity[self.ActivityType] = {}
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- 翻翻乐 展示
|
|||
|
|
function ActivityFlipCard:Show(player, c2sData, s2cData)
|
|||
|
|
c2sData.data = assert(pb.decode("C2SActivityFlipCardShow", c2sData.data))
|
|||
|
|
local data = {}
|
|||
|
|
|
|||
|
|
-- 判断一下是否需要初始化玩家数据
|
|||
|
|
--if player.gameData.activity[self.ActivityType] == nil or next(player.gameData.activity[self.ActivityType]) == nil then
|
|||
|
|
self:InitData(player, self.ActivityType)
|
|||
|
|
--end
|
|||
|
|
self:CheckFlipCardLevel(player)
|
|||
|
|
-- 玩家翻翻乐的相关信息
|
|||
|
|
data.flipCardInfos = {}
|
|||
|
|
for k, v in pairs(player.gameData.activity[self.ActivityType].flipCardInfos) do
|
|||
|
|
table.insert(data.flipCardInfos, v)
|
|||
|
|
end
|
|||
|
|
s2cData.cmd = pb.enum("MsgType", "CMD_S2C_ActivityFlipCardShow")
|
|||
|
|
s2cData.data = assert(pb.encode("S2CActivityFlipCardShow", data))
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- 翻翻乐 开始游戏
|
|||
|
|
function ActivityFlipCard:Start(player, c2sData, s2cData)
|
|||
|
|
c2sData.data = assert(pb.decode("C2SActivityFlipCardStart", c2sData.data))
|
|||
|
|
local data = {}
|
|||
|
|
local id = c2sData.data.id -- 翻翻乐关卡id
|
|||
|
|
local cfgCardLevel = skynet.server.gameConfig:GetPlayerAllCfg(player, "FlipCardsLevel")
|
|||
|
|
for k, v in pairs(player.gameData.activity[self.ActivityType].flipCardInfos) do
|
|||
|
|
if v.id == id and v.status == 1 then
|
|||
|
|
-- local cfgFlipCards = skynet.server.gameConfig:GetPlayerAllCfg(player, "FlipCards",
|
|||
|
|
-- player.gameData.activity[self.ActivityType].flipCardId)
|
|||
|
|
player.gameData.activity[self.ActivityType].nowFlipCardData.id = id
|
|||
|
|
player.gameData.activity[self.ActivityType].nowFlipCardData.gameEndTime = skynet.GetTime() + cfgCardLevel[id].levelTime
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
data.id = id
|
|||
|
|
data.endTime = player.gameData.activity[self.ActivityType].nowFlipCardData.gameEndTime
|
|||
|
|
s2cData.cmd = pb.enum("MsgType", "CMD_S2C_ActivityFlipCardStart")
|
|||
|
|
s2cData.data = assert(pb.encode("S2CActivityFlipCardStart", data))
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- 翻翻乐 完成翻翻乐
|
|||
|
|
function ActivityFlipCard:Finish(player, c2sData, s2cData)
|
|||
|
|
c2sData.data = assert(pb.decode("C2SActivityFlipCardFinish", c2sData.data))
|
|||
|
|
local data = {}
|
|||
|
|
local isFinish = c2sData.data.isFinish -- 是否完成翻翻乐
|
|||
|
|
-- 判断当前时间是否完成
|
|||
|
|
-- if isFinish and skynet.GetTime() < player.gameData.activity[self.ActivityType].nowFlipCardData.gameEndTime then
|
|||
|
|
if isFinish then
|
|||
|
|
-- 完成游戏 发放对应奖励
|
|||
|
|
local cfgCardLevel = skynet.server.gameConfig:GetPlayerAllCfg(player, "FlipCardsLevel")
|
|||
|
|
local rewardId = cfgCardLevel[player.gameData.activity[self.ActivityType].nowFlipCardData.id].levelReward
|
|||
|
|
-- 发放对应奖励
|
|||
|
|
local eventId = pb.enum("EnumMoneyChangeEventID", "EventID_112")
|
|||
|
|
|
|||
|
|
local id = player.gameData.activity[self.ActivityType].nowFlipCardData.id -- 当前关卡id
|
|||
|
|
|
|||
|
|
--查找索引
|
|||
|
|
for index, value in ipairs(player.gameData.activity[self.ActivityType].flipCardInfos) do
|
|||
|
|
if value.id == id then
|
|||
|
|
player.gameData.activity[self.ActivityType].flipCardInfos[index].status = skynet.server.task.TaskStatus_AlreadyComplete
|
|||
|
|
break
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
player:GiveReward(rewardId, eventId, 1)
|
|||
|
|
data.rewardId = rewardId
|
|||
|
|
-- 有关卡可以挑战时 添加对应红点
|
|||
|
|
local redDot = false
|
|||
|
|
for k, v in pairs(player.gameData.activity[self.ActivityType].flipCardInfos) do
|
|||
|
|
if v.status == 1 then
|
|||
|
|
redDot = true
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
if not redDot then
|
|||
|
|
skynet.server.msgTips:ReduceAll(player, 103)
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--检查是否有新的关卡开启
|
|||
|
|
self:CheckFlipCardLevel(player)
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- 初始游戏数据
|
|||
|
|
player.gameData.activity[self.ActivityType].nowFlipCardData.gameEndTime = 0
|
|||
|
|
s2cData.cmd = pb.enum("MsgType", "CMD_S2C_ActivityFlipCardFinish")
|
|||
|
|
s2cData.data = assert(pb.encode("S2CActivityFlipCardFinish", data))
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- 翻翻乐 任务展示
|
|||
|
|
function ActivityFlipCard:TaskShow(player, c2sData, s2cData)
|
|||
|
|
c2sData.data = assert(pb.decode("C2SActivityFlipCardTaskShow", c2sData.data))
|
|||
|
|
local data = {}
|
|||
|
|
data.taskInfos = self:GetShowTaskData(player)
|
|||
|
|
-- log.info('翻翻乐任务展示', skynet.server.common:TableToString(data))
|
|||
|
|
s2cData.cmd = pb.enum("MsgType", "CMD_S2C_ActivityFlipCardTaskShow")
|
|||
|
|
s2cData.data = assert(pb.encode("S2CActivityFlipCardTaskShow", data))
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- 翻翻乐 任务获取
|
|||
|
|
function ActivityFlipCard:TaskGet(player, c2sData, s2cData)
|
|||
|
|
c2sData.data = assert(pb.decode("C2SActivityFlipCardTaskGet", c2sData.data))
|
|||
|
|
local data = {}
|
|||
|
|
local taskId = c2sData.data.taskId -- 任务id
|
|||
|
|
|
|||
|
|
local activityId, startTime, endTime = self:GetActivityInfo(player, self.ActivityType)
|
|||
|
|
-- 玩家对应配置
|
|||
|
|
local cfgFlipCards = skynet.server.gameConfig:GetPlayerCurCfg(player, "FlipCards", activityId)
|
|||
|
|
|
|||
|
|
for k, v in pairs(player.gameData.activity[self.ActivityType].cardTasks) do
|
|||
|
|
if v.id == taskId and v.status == skynet.server.task.TaskStatus_AlreadyComplete then
|
|||
|
|
-- 完成任务 修改对应数据
|
|||
|
|
local cfgCardTask = skynet.server.gameConfig:GetPlayerCurCfg(player, "FlipCardsTask", v.id)
|
|||
|
|
-- player.gameData.activity[self.ActivityType].activeValue =
|
|||
|
|
-- player.gameData.activity[self.ActivityType].activeValue + cfgCardTask.point
|
|||
|
|
skynet.server.bag:AddGoods(player, dataType.GoodsType_Prop, cfgFlipCards.ticketId, cfgCardTask.point)
|
|||
|
|
v.status = skynet.server.task.TaskStatus_AlreadyGet
|
|||
|
|
skynet.server.msgTips:Reduce(player, 102)
|
|||
|
|
self:CheckFlipCardLevel(player)
|
|||
|
|
log.debug(string.format("玩家 %d 翻翻乐 任务完成领取积分 任务ID %d", player.userId, taskId))
|
|||
|
|
break
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
data.taskId = taskId
|
|||
|
|
data.taskInfos = self:GetShowTaskData(player)
|
|||
|
|
-- data.activeValue = player.gameData.activity[self.ActivityType].activeValue
|
|||
|
|
s2cData.cmd = pb.enum("MsgType", "CMD_S2C_ActivityFlipCardTaskGet")
|
|||
|
|
s2cData.data = assert(pb.encode("S2CActivityFlipCardTaskGet", data))
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- 翻翻乐 修改任务 kind 任务类型 count 数值
|
|||
|
|
function ActivityFlipCard:Modify(player, kind, count)
|
|||
|
|
-- 如果没有开启的翻翻乐 则返回
|
|||
|
|
local cfgActivity = skynet.server.gameConfig:GetPlayerAllCfg(player, "Activity")
|
|||
|
|
local activityId, startTime, endTime = self:GetActivityInfo(player, self.ActivityType)
|
|||
|
|
if activityId == 0 then
|
|||
|
|
return
|
|||
|
|
end
|
|||
|
|
local level = 0
|
|||
|
|
for k, v in pairs(cfgActivity) do
|
|||
|
|
if v.activityType == dataType.ActivityType_FlipCard then -- 活动翻翻乐
|
|||
|
|
level = v.level
|
|||
|
|
break
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--if player.gameData.activity[self.ActivityType] == nil and player.gameData.level > level then
|
|||
|
|
self:InitData(player, self.ActivityType)
|
|||
|
|
--end
|
|||
|
|
|
|||
|
|
if not player.gameData.activity[self.ActivityType] or not player.gameData.activity[self.ActivityType].cardTasks then
|
|||
|
|
return
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
log.debug(string.format("玩家 %d 翻翻乐 任务修改 种类 %d 数量 %d", player.userId, kind, count))
|
|||
|
|
for k, v in pairs(player.gameData.activity[self.ActivityType].cardTasks) do
|
|||
|
|
if v.type == kind and v.status == skynet.server.task.TaskStatus_NoComplete then
|
|||
|
|
-- 获取最大进度
|
|||
|
|
local cfgCardTask = skynet.server.gameConfig:GetPlayerCurCfg(player, "FlipCardsTask", v.id)
|
|||
|
|
local maxProgress = cfgCardTask.value
|
|||
|
|
v.progress = v.progress + count
|
|||
|
|
-- 检查是否完成任务
|
|||
|
|
if v.progress >= maxProgress then
|
|||
|
|
if skynet.server.task.TaskStatus_NoComplete == v.status then
|
|||
|
|
skynet.server.msgTips:Add(player, 102)
|
|||
|
|
end
|
|||
|
|
v.status = skynet.server.task.TaskStatus_AlreadyComplete
|
|||
|
|
v.progress = maxProgress
|
|||
|
|
log.debug(string.format("玩家 %d 翻翻乐 任务修改 种类 %d 数量 %d", player.userId, kind,
|
|||
|
|
count))
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- 翻翻乐 获取可以显示的任务
|
|||
|
|
function ActivityFlipCard:GetShowTaskData(player)
|
|||
|
|
local data = {}
|
|||
|
|
-- 翻翻乐数据
|
|||
|
|
local activityId, startTime, endTime = self:GetActivityInfo(player, self.ActivityType)
|
|||
|
|
|
|||
|
|
-- 没有开启的活动
|
|||
|
|
if activityId <= 0 then
|
|||
|
|
return data
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
local cfgActivity = skynet.server.gameConfig:GetPlayerAllCfg(player, "Activity")
|
|||
|
|
for k, v in pairs(player.gameData.activity[self.ActivityType].cardTasks) do
|
|||
|
|
-- 未完成和已完成才会显示
|
|||
|
|
for k1, v1 in pairs(cfgActivity) do
|
|||
|
|
if v1.activityType == dataType.ActivityType_FlipCard and v1.level <= player.gameData.level and v1.activityId == activityId then
|
|||
|
|
-- if skynet.server.task.TaskStatus_AlreadyGet == v.status then
|
|||
|
|
table.insert(data, {
|
|||
|
|
id = v.id,
|
|||
|
|
progress = v.progress,
|
|||
|
|
status = v.status
|
|||
|
|
})
|
|||
|
|
-- end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- 将完成的任务排到最后
|
|||
|
|
local sortData = {}
|
|||
|
|
for k, v in pairs(data) do
|
|||
|
|
if skynet.server.task.TaskStatus_AlreadyGet ~= v.status then
|
|||
|
|
-- if v.id == 15 then
|
|||
|
|
-- -- 判断玩家的家园如果是满级的话就不刷新这个任务出来
|
|||
|
|
-- local groupId = skynet.server.group:GetGroupID(player)
|
|||
|
|
-- local groupInfo = skynet.server.group:GetGroup(groupId)
|
|||
|
|
-- if groupId and groupInfo ~= nil then
|
|||
|
|
-- -- log.info('if23123123',groupId)
|
|||
|
|
-- if groupInfo.communityLevel == 5 and skynet.server.task.TaskStatus_NoComplete == v.status then
|
|||
|
|
|
|||
|
|
-- else
|
|||
|
|
-- table.insert(sortData, v)
|
|||
|
|
-- end
|
|||
|
|
-- else
|
|||
|
|
-- -- log.info('else111',groupId)
|
|||
|
|
-- table.insert(sortData, v)
|
|||
|
|
-- end
|
|||
|
|
-- else
|
|||
|
|
table.insert(sortData, v)
|
|||
|
|
--end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
for k, v in pairs(data) do
|
|||
|
|
if skynet.server.task.TaskStatus_AlreadyGet == v.status then
|
|||
|
|
table.insert(sortData, v)
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
data = sortData
|
|||
|
|
return data
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- 翻翻乐 检查是否有新的关卡解锁
|
|||
|
|
function ActivityFlipCard:CheckFlipCardLevel(player)
|
|||
|
|
local cfgCardLevel = skynet.server.gameConfig:GetPlayerAllCfg(player, "FlipCardsLevel")
|
|||
|
|
local id =player.gameData.activity[self.ActivityType].nowFlipCardData.id
|
|||
|
|
|
|||
|
|
local indexId = 0
|
|||
|
|
|
|||
|
|
--查找索引
|
|||
|
|
for index, value in ipairs(player.gameData.activity[self.ActivityType].flipCardInfos) do
|
|||
|
|
if value.id == id then
|
|||
|
|
indexId =index
|
|||
|
|
break
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--没有下一个关卡
|
|||
|
|
if indexId == 0 then
|
|||
|
|
return
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
local activityId, startTime, endTime = self:GetActivityInfo(player, self.ActivityType)
|
|||
|
|
|
|||
|
|
--活动未开启
|
|||
|
|
if activityId == 0 then
|
|||
|
|
return
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- 玩家对应配置
|
|||
|
|
local cfgFlipCards = skynet.server.gameConfig:GetPlayerCurCfg(player, "FlipCards", activityId)
|
|||
|
|
|
|||
|
|
if player.gameData.activity[self.ActivityType].flipCardInfos[indexId].status == skynet.server.task.TaskStatus_AlreadyComplete then
|
|||
|
|
|
|||
|
|
local atId = player.gameData.activity[self.ActivityType].nowFlipCardData.id
|
|||
|
|
|
|||
|
|
--查找下一个节点
|
|||
|
|
local nextId = 0
|
|||
|
|
for _, value in ipairs(cfgFlipCards.cardsLevelId) do
|
|||
|
|
if value > atId and (nextId > value or nextId ==0 )then
|
|||
|
|
nextId = value
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--是否没有下一关卡
|
|||
|
|
if nextId == 0 then
|
|||
|
|
return
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
--更新下一个节点id
|
|||
|
|
player.gameData.activity[self.ActivityType].nowFlipCardData.id = nextId
|
|||
|
|
|
|||
|
|
-- if player.gameData.activity[self.ActivityType].nowFlipCardData.id < 8 then
|
|||
|
|
-- player.gameData.activity[self.ActivityType].nowFlipCardData.id = player.gameData.activity[self.ActivityType].nowFlipCardData.id + 1
|
|||
|
|
-- end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- 判断积分解锁关卡
|
|||
|
|
if skynet.server.bag:GetGoodsCount(player, dataType.GoodsType_Prop, cfgFlipCards.ticketId) >=
|
|||
|
|
cfgCardLevel[player.gameData.activity[self.ActivityType].nowFlipCardData.id].activeValue
|
|||
|
|
and player.gameData.activity[self.ActivityType].flipCardInfos[indexId].status == 0 then
|
|||
|
|
player.gameData.activity[self.ActivityType].flipCardInfos[indexId].status = skynet.server.task.TaskStatus_NoComplete
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- -- 翻翻乐 检查是否有新的关卡解锁
|
|||
|
|
-- function ActivityFlipCard:RedDotCheck(player)
|
|||
|
|
|
|||
|
|
-- end
|
|||
|
|
|
|||
|
|
-- 定义一个回调函数
|
|||
|
|
local function onEventFired(player , taskId , count)
|
|||
|
|
|
|||
|
|
--翻翻乐
|
|||
|
|
ActivityFlipCard:Modify(player,taskId,count)
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
-- 注册事件处理函数
|
|||
|
|
taskListEvent:Register(onEventFired,"翻翻乐任务")
|
|||
|
|
|
|||
|
|
skynet.server.activityFlipCard = ActivityFlipCard
|
|||
|
|
return ActivityFlipCard
|