Commit 385b542a1f68836c5393a637a65a79cc4eef35ff
Merge branch 'bugfix' into tr/ts
Showing
35 changed files
with
1066 additions
and
260 deletions
Show diff stats
config/develop.lua
@@ -2,10 +2,11 @@ include("basic.lua") | @@ -2,10 +2,11 @@ include("basic.lua") | ||
2 | 2 | ||
3 | logd = 0 -- 是否开启日志 | 3 | logd = 0 -- 是否开启日志 |
4 | thread = 4 | 4 | thread = 4 |
5 | -codeurl = "192.168.8.223:9090" | 5 | +codeurl = "192.168.0.199:9090" |
6 | servId = 1 | 6 | servId = 1 |
7 | 7 | ||
8 | max_client = 64 | 8 | max_client = 64 |
9 | +max_queue = 64 | ||
9 | 10 | ||
10 | server_port = 12001 | 11 | server_port = 12001 |
11 | debug_port = 10001 | 12 | debug_port = 10001 |
src/GlobalVar.lua
1 | XXTEA_KEY = "699D448D6D24f7F941E9F6E99F823E18" | 1 | XXTEA_KEY = "699D448D6D24f7F941E9F6E99F823E18" |
2 | -RESET_TIME = 0 | 2 | +RESET_TIME = 4 |
3 | 3 | ||
4 | -START_RESET_TIME_BASE = 1584316800 -- 0时区 | 4 | +START_RESET_TIME_BASE = 1584316800 + RESET_TIME * 3600 -- 0时区 |
5 | DAY_SEC = 86400 | 5 | DAY_SEC = 86400 |
6 | TIME_ZONE = math.floor(os.difftime(START_RESET_TIME_BASE, os.time(os.date("!*t", START_RESET_TIME_BASE))) / 3600) -- 本地时区 | 6 | TIME_ZONE = math.floor(os.difftime(START_RESET_TIME_BASE, os.time(os.date("!*t", START_RESET_TIME_BASE))) / 3600) -- 本地时区 |
7 | 7 | ||
@@ -69,6 +69,7 @@ ItemType = { | @@ -69,6 +69,7 @@ ItemType = { | ||
69 | FuncOpen = 15, -- 管理功能开放 | 69 | FuncOpen = 15, -- 管理功能开放 |
70 | SpeedBox = 16, -- 加速箱子 | 70 | SpeedBox = 16, -- 加速箱子 |
71 | SelectItemBox = 17, -- 自选箱子 | 71 | SelectItemBox = 17, -- 自选箱子 |
72 | + CommonPaster = 18, -- 万能贴纸 | ||
72 | } | 73 | } |
73 | 74 | ||
74 | --在这个里面的会记录的是功能开放 对应类型open 而不是 ID | 75 | --在这个里面的会记录的是功能开放 对应类型open 而不是 ID |
@@ -211,6 +212,7 @@ AdvBackEventType = { | @@ -211,6 +212,7 @@ AdvBackEventType = { | ||
211 | Artifact = 24, --获得神器 | 212 | Artifact = 24, --获得神器 |
212 | Level = 25, -- 升级 | 213 | Level = 25, -- 升级 |
213 | LinkChooseOver = 26, -- 连锁事件结束 | 214 | LinkChooseOver = 26, -- 连锁事件结束 |
215 | + BuffEffect = 27, -- buff 效果 | ||
214 | } | 216 | } |
215 | 217 | ||
216 | AdvScoreType = { | 218 | AdvScoreType = { |
@@ -256,7 +258,7 @@ SettingStatus = { | @@ -256,7 +258,7 @@ SettingStatus = { | ||
256 | }, | 258 | }, |
257 | } | 259 | } |
258 | 260 | ||
259 | -EMAIL_LIMIT = 20 --邮件最大数量 | 261 | +EMAIL_LIMIT = 50 --邮件最大数量 |
260 | 262 | ||
261 | RedPointTags = { | 263 | RedPointTags = { |
262 | PvpCR = 1, | 264 | PvpCR = 1, |
@@ -307,9 +309,13 @@ MailId = { | @@ -307,9 +309,13 @@ MailId = { | ||
307 | } | 309 | } |
308 | 310 | ||
309 | TriggerEventType = { | 311 | TriggerEventType = { |
310 | - HangPass = 1, | ||
311 | - LevelUp = 2, | 312 | + HangPass = 1, |
313 | + AdvPass = 2, | ||
312 | TowerPass = 3, | 314 | TowerPass = 3, |
315 | + LevelUp = 4, | ||
316 | + AddNewHero = 5, | ||
317 | + SSRCount = 6, | ||
318 | + AfterTs = 7, -- 某时间以后 | ||
313 | } | 319 | } |
314 | 320 | ||
315 | DrawCardType = { | 321 | DrawCardType = { |
src/ProtocolCode.lua
@@ -7,6 +7,7 @@ actionCodes = { | @@ -7,6 +7,7 @@ actionCodes = { | ||
7 | Sys_commonNotice = 5, | 7 | Sys_commonNotice = 5, |
8 | Sys_maintainNotice = 6, | 8 | Sys_maintainNotice = 6, |
9 | Sys_customNotice = 7, | 9 | Sys_customNotice = 7, |
10 | + Sys_checkQueue = 8, | ||
10 | 11 | ||
11 | Gm_clientRequest = 20, | 12 | Gm_clientRequest = 20, |
12 | Gm_receiveResponse = 21, | 13 | Gm_receiveResponse = 21, |
@@ -47,6 +48,7 @@ actionCodes = { | @@ -47,6 +48,7 @@ actionCodes = { | ||
47 | Role_getDownloadCvRewardRpc = 132, | 48 | Role_getDownloadCvRewardRpc = 132, |
48 | Role_updateFeedbackInfoRpc = 133, | 49 | Role_updateFeedbackInfoRpc = 133, |
49 | Role_useSelectItemRpc = 134, -- 使用多选一礼包 | 50 | Role_useSelectItemRpc = 134, -- 使用多选一礼包 |
51 | + Role_broadGetSSR = 135, -- 全服广播 获得ssr英雄 | ||
50 | 52 | ||
51 | Adv_startAdvRpc = 151, | 53 | Adv_startAdvRpc = 151, |
52 | Adv_startHangRpc = 152, | 54 | Adv_startHangRpc = 152, |
@@ -208,6 +210,8 @@ actionCodes = { | @@ -208,6 +210,8 @@ actionCodes = { | ||
208 | Activity_sudokuRewardRpc = 652, | 210 | Activity_sudokuRewardRpc = 652, |
209 | Activity_actSignRpc = 653, | 211 | Activity_actSignRpc = 653, |
210 | Activity_actPaySignRewardNtf = 654, | 212 | Activity_actPaySignRewardNtf = 654, |
213 | + Activity_actCalendaTaskRpc = 655, | ||
214 | + Activity_actPaySignRpc = 656, | ||
211 | } | 215 | } |
212 | 216 | ||
213 | rpcResponseBegin = 10000 | 217 | rpcResponseBegin = 10000 |
src/actions/ActivityAction.lua
@@ -183,19 +183,22 @@ end | @@ -183,19 +183,22 @@ end | ||
183 | function _M.actPaySignRpc(agent, data) | 183 | function _M.actPaySignRpc(agent, data) |
184 | local role = agent.role | 184 | local role = agent.role |
185 | local msg = MsgPack.unpack(data) | 185 | local msg = MsgPack.unpack(data) |
186 | + local dayIndex = msg.day | ||
186 | local actGoodsFlag = role.storeData:getProperty("actGoodsFlag") | 187 | local actGoodsFlag = role.storeData:getProperty("actGoodsFlag") |
187 | local index = GetActGoodsIndex("paySignIn") | 188 | local index = GetActGoodsIndex("paySignIn") |
188 | - local flag = actGoodsFlag[index] or 0 | ||
189 | - if flag == 0 then return 1 end | 189 | + local ts = actGoodsFlag[index] or 0 |
190 | + if ts == 0 then return 1 end | ||
190 | 191 | ||
191 | - if not role.activity:isOpen("PaySignIn") then return 2 end | 192 | + local open, actId = role.activity:isOpen("PaySignIn") |
193 | + if not open then return 2 end | ||
192 | 194 | ||
193 | - local diffDay = diffFromOpen() + 1 | 195 | + local diffDay = diffFromTs(ts) + 1 |
194 | 196 | ||
195 | local curData = role.activity:getActData("PaySignIn") | 197 | local curData = role.activity:getActData("PaySignIn") |
198 | + if not curData then return 3 end | ||
196 | local reward, change = {} | 199 | local reward, change = {} |
197 | for day, csvData in ipairs(csvdb["pay_signInCsv"]) do | 200 | for day, csvData in ipairs(csvdb["pay_signInCsv"]) do |
198 | - if day <= diffDay then | 201 | + if day <= diffDay and day == dayIndex then |
199 | if not curData[day] then | 202 | if not curData[day] then |
200 | curData[day] = 1 | 203 | curData[day] = 1 |
201 | -- 奖励 | 204 | -- 奖励 |
@@ -203,8 +206,8 @@ function _M.actPaySignRpc(agent, data) | @@ -203,8 +206,8 @@ function _M.actPaySignRpc(agent, data) | ||
203 | reward[itemId] = (reward[itemId] or 0) + count | 206 | reward[itemId] = (reward[itemId] or 0) + count |
204 | end | 207 | end |
205 | end | 208 | end |
206 | - else | ||
207 | - break | 209 | + --else |
210 | + -- break | ||
208 | end | 211 | end |
209 | end | 212 | end |
210 | if next(reward) then | 213 | if next(reward) then |
@@ -213,7 +216,7 @@ function _M.actPaySignRpc(agent, data) | @@ -213,7 +216,7 @@ function _M.actPaySignRpc(agent, data) | ||
213 | end | 216 | end |
214 | 217 | ||
215 | role:log("activity", { | 218 | role:log("activity", { |
216 | - activity_id = curData[0], -- 活动ID(或活动指定任务的ID) | 219 | + activity_id = actId, -- 活动ID(或活动指定任务的ID) |
217 | activity_type = role.activity.ActivityType.PaySignIn, -- 活动类型,见活动类型枚举表 | 220 | activity_type = role.activity.ActivityType.PaySignIn, -- 活动类型,见活动类型枚举表 |
218 | activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} | 221 | activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} |
219 | }) | 222 | }) |
@@ -222,4 +225,42 @@ function _M.actPaySignRpc(agent, data) | @@ -222,4 +225,42 @@ function _M.actPaySignRpc(agent, data) | ||
222 | return true | 225 | return true |
223 | end | 226 | end |
224 | 227 | ||
228 | +function _M.actCalendaTaskRpc(agent, data) | ||
229 | + local role = agent.role | ||
230 | + local msg = MsgPack.unpack(data) | ||
231 | + local taskId = msg.id | ||
232 | + local calTask = role:getProperty("calTask") or {} | ||
233 | + local record = calTask["r"] or {} | ||
234 | + local flag = record[taskId] or 0 | ||
235 | + if flag == 1 then return 1 end | ||
236 | + local open, actId = role.activity:isOpen("CalendaTask") | ||
237 | + local actData = csvdb["activity_ctrlCsv"][actId] | ||
238 | + if not open then return 2 end | ||
239 | + if not actData then return 3 end | ||
240 | + | ||
241 | + local taskList = csvdb["activity_taskCsv"][actData.condition] | ||
242 | + if not taskList then return 4 end | ||
243 | + local taskCfg = taskList[taskId] | ||
244 | + if not taskCfg then return 5 end | ||
245 | + if taskCfg.key ~= actData.condition then return 6 end | ||
246 | + | ||
247 | + if (calTask[taskId] or 0) < taskCfg.condition1 then return 7 end | ||
248 | + | ||
249 | + record[taskId] = 1 | ||
250 | + calTask["r"] = record | ||
251 | + | ||
252 | + role:updateProperty({field = "calTask", value = calTask}) | ||
253 | + | ||
254 | + local reward, change = role:award(taskCfg.reward, {log = {desc = "calendaTask"}}) | ||
255 | + | ||
256 | + role:log("activity", { | ||
257 | + activity_id = taskId, -- 活动ID(或活动指定任务的ID) | ||
258 | + activity_type = role.activity.ActivityType.CalendaTask, -- 活动类型,见活动类型枚举表 | ||
259 | + activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} | ||
260 | + }) | ||
261 | + | ||
262 | + SendPacket(actionCodes.Activity_actCalendaTaskRpc, MsgPack.pack(role:packReward(reward, change))) | ||
263 | + return true | ||
264 | +end | ||
265 | + | ||
225 | return _M | 266 | return _M |
226 | \ No newline at end of file | 267 | \ No newline at end of file |
src/actions/AdvAction.lua
@@ -250,7 +250,7 @@ function _M.startHangRpc(agent, data) | @@ -250,7 +250,7 @@ function _M.startHangRpc(agent, data) | ||
250 | if not role:getAdvData():isRunning() then | 250 | if not role:getAdvData():isRunning() then |
251 | role:updateProperty({field = "advTeam", value = {}}) | 251 | role:updateProperty({field = "advTeam", value = {}}) |
252 | end | 252 | end |
253 | - | 253 | + role:pushMsg({type = "adv", slot = chapterId, time = adv_idle_time}) |
254 | role:changeUpdates({{type = "advHang", field = chapterId, value = info}}) | 254 | role:changeUpdates({{type = "advHang", field = chapterId, value = info}}) |
255 | 255 | ||
256 | role:changeAdvCount(adv_idle_energy) | 256 | role:changeAdvCount(adv_idle_energy) |
@@ -295,6 +295,7 @@ function _M.quickHangRpc(agent, data) | @@ -295,6 +295,7 @@ function _M.quickHangRpc(agent, data) | ||
295 | info.time = 0 | 295 | info.time = 0 |
296 | role:changeUpdates({{type = "advHang", field = chapterId, value = info}}) | 296 | role:changeUpdates({{type = "advHang", field = chapterId, value = info}}) |
297 | 297 | ||
298 | + role:pushCancel({type = "adv", slot = chapterId}) | ||
298 | role:mylog("adv_action", {desc = "advQuickHang", int1 = chapterId}) | 299 | role:mylog("adv_action", {desc = "advQuickHang", int1 = chapterId}) |
299 | 300 | ||
300 | SendPacket(actionCodes.Adv_quickHangRpc, '') | 301 | SendPacket(actionCodes.Adv_quickHangRpc, '') |
@@ -371,6 +372,7 @@ function _M.endHangRpc(agent, data) | @@ -371,6 +372,7 @@ function _M.endHangRpc(agent, data) | ||
371 | -- else | 372 | -- else |
372 | -- role:updateProperty({field = "advC", delta = -chapterData.limitlevel}) | 373 | -- role:updateProperty({field = "advC", delta = -chapterData.limitlevel}) |
373 | -- end | 374 | -- end |
375 | + role:pushCancel({type = "adv", slot = chapterId}) | ||
374 | else | 376 | else |
375 | return | 377 | return |
376 | end | 378 | end |
@@ -380,6 +382,8 @@ function _M.endHangRpc(agent, data) | @@ -380,6 +382,8 @@ function _M.endHangRpc(agent, data) | ||
380 | 382 | ||
381 | role:mylog("adv_action", {desc = "endHang", int1 = chapterId, short1 = cancel and 1 or 0}) | 383 | role:mylog("adv_action", {desc = "endHang", int1 = chapterId, short1 = cancel and 1 or 0}) |
382 | 384 | ||
385 | + role:checkTaskEnter("AdvHang", {}) | ||
386 | + | ||
383 | SendPacket(actionCodes.Adv_endHangRpc, MsgPack.pack({reward = reward, change = change, isFull = isFull})) | 387 | SendPacket(actionCodes.Adv_endHangRpc, MsgPack.pack({reward = reward, change = change, isFull = isFull})) |
384 | return true | 388 | return true |
385 | end | 389 | end |
@@ -435,6 +439,16 @@ function _M.finishTaskRpc(agent, data) | @@ -435,6 +439,16 @@ function _M.finishTaskRpc(agent, data) | ||
435 | role:checkTaskEnter("AdvOverTask", {id = taskId}) | 439 | role:checkTaskEnter("AdvOverTask", {id = taskId}) |
436 | 440 | ||
437 | adv:mylog({desc = "finishTask", int1 = taskId}) | 441 | adv:mylog({desc = "finishTask", int1 = taskId}) |
442 | + | ||
443 | + role:log("mission_pick_achiev", { | ||
444 | + mission_threadid = adv.chapterId, -- 大地图ID | ||
445 | + mission_threadname = (csvdb["adv_chapterCsv"][adv.chapterId] or {})["chapter"] or "auto", -- 大地图名称 | ||
446 | + mission_id = adv.level, -- 关卡ID | ||
447 | + mission_sequenceid = adv.logid, -- 本次拾荒ID,用于关联一次拾荒产生多条不同类型的日志 | ||
448 | + mission_pick_achiev_id = taskId, -- 任务ID | ||
449 | + mission_pick_achiev_reward = reward, -- 任务奖励,[{"id":101,"num":10},{"id":102,"num":20},{"id":103,"num":30}] | ||
450 | + }) | ||
451 | + | ||
438 | 452 | ||
439 | SendPacket(actionCodes.Adv_finishTaskRpc, MsgPack.pack(role:packReward(reward, change))) | 453 | SendPacket(actionCodes.Adv_finishTaskRpc, MsgPack.pack(role:packReward(reward, change))) |
440 | return true | 454 | return true |
@@ -497,6 +511,15 @@ function _M.useItemRpc(agent, data) | @@ -497,6 +511,15 @@ function _M.useItemRpc(agent, data) | ||
497 | adv:checkAchievement(adv.AchievType.UseItem, count, itemId) | 511 | adv:checkAchievement(adv.AchievType.UseItem, count, itemId) |
498 | adv:mylog({desc = "useItem", int1 = itemId, int2 = count}) | 512 | adv:mylog({desc = "useItem", int1 = itemId, int2 = count}) |
499 | 513 | ||
514 | + role:log("mission_pick_use", { | ||
515 | + mission_threadid = adv.chapterId, -- 大地图ID | ||
516 | + mission_threadname = (csvdb["adv_chapterCsv"][adv.chapterId] or {})["chapter"] or "auto", -- 大地图名称 | ||
517 | + mission_id = adv.level, -- 关卡ID | ||
518 | + item_id = itemId, -- 道具ID | ||
519 | + mission_pick_use_num = count, -- 道具使用量 | ||
520 | + mission_sequenceid = adv.logid, -- 本次拾荒ID,用于关联一次拾荒产生多条不同类型的日志 | ||
521 | + }) | ||
522 | + | ||
500 | for i = 1, count do | 523 | for i = 1, count do |
501 | adv:doActive(itemData.effect, target) -- target | 524 | adv:doActive(itemData.effect, target) -- target |
502 | end | 525 | end |
@@ -583,6 +606,7 @@ function _M.wearArtifactRpc(agent, data) | @@ -583,6 +606,7 @@ function _M.wearArtifactRpc(agent, data) | ||
583 | 606 | ||
584 | local status = adv:wearArtifact(slot, id) | 607 | local status = adv:wearArtifact(slot, id) |
585 | if not status then return 3 end | 608 | if not status then return 3 end |
609 | + | ||
586 | adv:saveDB() | 610 | adv:saveDB() |
587 | 611 | ||
588 | role:finishGuide(55) | 612 | role:finishGuide(55) |
@@ -608,7 +632,20 @@ function _M.upArtifactRpc(agent, data) | @@ -608,7 +632,20 @@ function _M.upArtifactRpc(agent, data) | ||
608 | if not adv:cost(cost, {}, true) then return 4 end | 632 | if not adv:cost(cost, {}, true) then return 4 end |
609 | 633 | ||
610 | local status = adv:artifactLevelUp(id) | 634 | local status = adv:artifactLevelUp(id) |
611 | - if not status then return 5 end | 635 | + if not status then |
636 | + return 5 | ||
637 | + else | ||
638 | + role:log("mission_pick_reform", { | ||
639 | + mission_threadid = adv.chapterId, -- 大地图ID | ||
640 | + mission_threadname = (csvdb["adv_chapterCsv"][adv.chapterId] or {})["chapter"] or "auto", -- 大地图名称 | ||
641 | + mission_id = adv.level, -- 关卡ID | ||
642 | + mission_pick_equip_id = id, -- 神器ID | ||
643 | + mission_pick_reform_beflv = curLevel, -- 神器原等级 | ||
644 | + mission_pick_reform_aftlv = curLevel + 1, -- 神器现等级 | ||
645 | + mission_pick_reform_cost = cost[ItemId.AdvPoint], -- 消耗探险点数 | ||
646 | + mission_sequenceid = adv.logid, -- 本次拾荒ID,用于关联一次拾荒产生多条不同类型的日志 | ||
647 | + }) | ||
648 | + end | ||
612 | adv:cost(cost, {log = {desc = "upArtifact", int1 = id}}) | 649 | adv:cost(cost, {log = {desc = "upArtifact", int1 = id}}) |
613 | adv:backCost(cost) | 650 | adv:backCost(cost) |
614 | if status == 1 then -- 现在穿着呢。更新下 | 651 | if status == 1 then -- 现在穿着呢。更新下 |
@@ -770,7 +807,7 @@ function _M.wheelSurfRpc(agent, data) | @@ -770,7 +807,7 @@ function _M.wheelSurfRpc(agent, data) | ||
770 | 807 | ||
771 | if not role:checkItemEnough(costs) then return 5 end | 808 | if not role:checkItemEnough(costs) then return 5 end |
772 | role:costItems(costs, {log = {desc = "advWheelSurf", int1 = ptype}}) | 809 | role:costItems(costs, {log = {desc = "advWheelSurf", int1 = ptype}}) |
773 | - role:addAdvLvExp(costs[ItemId.OldCoin] or 0) | 810 | + local oldLv, lv = role:addAdvLvExp(costs[ItemId.OldCoin] or 0) |
774 | local advDrawB = role:getProperty("advDrawB") | 811 | local advDrawB = role:getProperty("advDrawB") |
775 | advDrawB[ptype] = (advDrawB[ptype] or 0) + count | 812 | advDrawB[ptype] = (advDrawB[ptype] or 0) + count |
776 | role:updateProperty({field = "advDrawB", value = advDrawB}) | 813 | role:updateProperty({field = "advDrawB", value = advDrawB}) |
@@ -789,6 +826,16 @@ function _M.wheelSurfRpc(agent, data) | @@ -789,6 +826,16 @@ function _M.wheelSurfRpc(agent, data) | ||
789 | role:checkTaskEnter("AdvDraw", {count = count, ptype = ptype}) | 826 | role:checkTaskEnter("AdvDraw", {count = count, ptype = ptype}) |
790 | role:mylog("adv_action", {desc = "advWheelSurf", int1 = ptype, int2 = count}) | 827 | role:mylog("adv_action", {desc = "advWheelSurf", int1 = ptype, int2 = count}) |
791 | 828 | ||
829 | + role:log("mission_pick_fund", { | ||
830 | + item_id = ItemId.OldCoin, -- 资助花费道具ID | ||
831 | + mission_pick_fund_amount = costs[ItemId.OldCoin], -- 资助花费道具数量 | ||
832 | + mission_pick_fund_cnt = count, -- 资助花费道具次数,1或者10 | ||
833 | + mission_pick_fund_reward = reward, -- 资助获得奖励,[{"id":100,"num":10},{"id":101,"num":20},{"id":102,"num":30}] | ||
834 | + mission_pick_fund_stagereward = {}, -- 资助阶段奖励 | ||
835 | + mission_pick_fund_beflv = oldLv, -- 资助前资助等级 | ||
836 | + mission_pick_fund_aftlv = lv, -- 资助后资助等级 | ||
837 | + }) | ||
838 | + | ||
792 | SendPacket(actionCodes.Adv_wheelSurfRpc, MsgPack.pack({reward = backReward})) | 839 | SendPacket(actionCodes.Adv_wheelSurfRpc, MsgPack.pack({reward = backReward})) |
793 | return true | 840 | return true |
794 | end | 841 | end |
src/actions/DinerAction.lua
@@ -75,6 +75,9 @@ function _M.addSellRpc( agent, data ) | @@ -75,6 +75,9 @@ function _M.addSellRpc( agent, data ) | ||
75 | sells[slot].count = count | 75 | sells[slot].count = count |
76 | sells[slot].time = skynet.timex() - calSell.deltaTime | 76 | sells[slot].time = skynet.timex() - calSell.deltaTime |
77 | 77 | ||
78 | + local needTime = sells[slot].count * dishData.sell_time + sells[slot].time - skynet.timex() | ||
79 | + role:pushMsg({type = "food", slot = slot, time = needTime}) | ||
80 | + | ||
78 | -- 检查解锁的顾客 | 81 | -- 检查解锁的顾客 |
79 | local had = {} | 82 | local had = {} |
80 | for _, sell in pairs(sells) do | 83 | for _, sell in pairs(sells) do |
@@ -155,6 +158,7 @@ function _M.removeSellRpc( agent, data ) | @@ -155,6 +158,7 @@ function _M.removeSellRpc( agent, data ) | ||
155 | reward, change = role:award(reward, {log = {desc = "removeSell"}}) | 158 | reward, change = role:award(reward, {log = {desc = "removeSell"}}) |
156 | sells[slot].count = 0 | 159 | sells[slot].count = 0 |
157 | 160 | ||
161 | + role:pushCancel({type = "food", slot = slot}) | ||
158 | role:log("restaurant_sale", { | 162 | role:log("restaurant_sale", { |
159 | item_id = dish, -- 售卖物品ID | 163 | item_id = dish, -- 售卖物品ID |
160 | restaurant_sale_seat = slot, -- 售卖物品所在位置 | 164 | restaurant_sale_seat = slot, -- 售卖物品所在位置 |
src/actions/HangAction.lua
@@ -22,9 +22,12 @@ local function checkReward(role) | @@ -22,9 +22,12 @@ local function checkReward(role) | ||
22 | return false | 22 | return false |
23 | end | 23 | end |
24 | local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId] | 24 | local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId] |
25 | + local expCarbonData = csvdb["idle_battleCsv"][hangInfo.expCarbonId] | ||
25 | local nowCoinTime = math.min(skynet.timex(), hangInfo.endCoinTime or 0) | 26 | local nowCoinTime = math.min(skynet.timex(), hangInfo.endCoinTime or 0) |
26 | local nowItemTime = math.min(skynet.timex(), hangInfo.endItemTime or 0) | 27 | local nowItemTime = math.min(skynet.timex(), hangInfo.endItemTime or 0) |
27 | 28 | ||
29 | + local expCoef, itemCoef = role.storeData:getHangDropCoef() | ||
30 | + | ||
28 | -- 此次挂机,其中翻倍时长占多少 | 31 | -- 此次挂机,其中翻倍时长占多少 |
29 | local doubleTime = role.activity:getActHangDoubleTime(hangInfo.coinTime, nowCoinTime) | 32 | local doubleTime = role.activity:getActHangDoubleTime(hangInfo.coinTime, nowCoinTime) |
30 | local normalTime = nowCoinTime - hangInfo.coinTime - doubleTime | 33 | local normalTime = nowCoinTime - hangInfo.coinTime - doubleTime |
@@ -38,10 +41,10 @@ local function checkReward(role) | @@ -38,10 +41,10 @@ local function checkReward(role) | ||
38 | hangInfo.itemTime = nowItemTime | 41 | hangInfo.itemTime = nowItemTime |
39 | 42 | ||
40 | local items = role:getProperty("hangBag") | 43 | local items = role:getProperty("hangBag") |
41 | - coinCount = coinCount + coinDoubleCount | ||
42 | - items[ItemId.Gold] = math.floor((items[ItemId.Gold] or 0) + coinCount * carbonData.money) | ||
43 | - items[ItemId.Exp] = math.floor((items[ItemId.Exp] or 0) + coinCount * carbonData.exp) | ||
44 | - items[ItemId.PlayerExp] = math.floor((items[ItemId.PlayerExp] or 0) + coinCount * carbonData.playerExp) | 44 | + coinCount = (coinCount + coinDoubleCount) * expCoef |
45 | + items[ItemId.Gold] = math.floor((items[ItemId.Gold] or 0) + coinCount * expCarbonData.money) | ||
46 | + items[ItemId.Exp] = math.floor((items[ItemId.Exp] or 0) + coinCount * expCarbonData.exp) | ||
47 | + items[ItemId.PlayerExp] = math.floor((items[ItemId.PlayerExp] or 0) + coinCount * expCarbonData.playerExp) | ||
45 | 48 | ||
46 | local pool = {} | 49 | local pool = {} |
47 | for _, temp in pairs(carbonData.item:toArray()) do | 50 | for _, temp in pairs(carbonData.item:toArray()) do |
@@ -58,7 +61,8 @@ local function checkReward(role) | @@ -58,7 +61,8 @@ local function checkReward(role) | ||
58 | 61 | ||
59 | -- 特权卡挂机额外栏位 | 62 | -- 特权卡挂机额外栏位 |
60 | local privExtraCnt = role.storeData:getHangSlotExtraCount() | 63 | local privExtraCnt = role.storeData:getHangSlotExtraCount() |
61 | - local selfFC = role:getProperty("hangBagLimit") + privExtraCnt | 64 | + --local selfFC = role:getProperty("hangBagLimit") + privExtraCnt |
65 | + local selfFC = 50 | ||
62 | local selfIC = selfFC * globalCsv.idle_field_limit | 66 | local selfIC = selfFC * globalCsv.idle_field_limit |
63 | 67 | ||
64 | local function randomItem() | 68 | local function randomItem() |
@@ -73,6 +77,7 @@ local function checkReward(role) | @@ -73,6 +77,7 @@ local function checkReward(role) | ||
73 | if cur[1] == ItemId.BreakCost and doubleTime > 0 then | 77 | if cur[1] == ItemId.BreakCost and doubleTime > 0 then |
74 | cur[2] = cur[2] * 2 | 78 | cur[2] = cur[2] * 2 |
75 | end | 79 | end |
80 | + cur[2] = cur[2] * itemCoef | ||
76 | if (items[cur[1]] and math.ceil((items[cur[1]] + cur[2]) / globalCsv.idle_field_limit) > math.ceil(items[cur[1]] / globalCsv.idle_field_limit)) | 81 | if (items[cur[1]] and math.ceil((items[cur[1]] + cur[2]) / globalCsv.idle_field_limit) > math.ceil(items[cur[1]] / globalCsv.idle_field_limit)) |
77 | or not items[cur[1]] then --要占用新栏位的情况 | 82 | or not items[cur[1]] then --要占用新栏位的情况 |
78 | local addFC | 83 | local addFC |
@@ -139,6 +144,7 @@ function _M.startRpc( agent, data ) | @@ -139,6 +144,7 @@ function _M.startRpc( agent, data ) | ||
139 | local hangInfo = role:getProperty("hangInfo") | 144 | local hangInfo = role:getProperty("hangInfo") |
140 | local isNew = not hangInfo.carbonId | 145 | local isNew = not hangInfo.carbonId |
141 | hangInfo.carbonId = carbonId | 146 | hangInfo.carbonId = carbonId |
147 | + hangInfo.expCarbonId = isNew and carbonId or hangInfo.expCarbonId | ||
142 | local nowTime = skynet.timex() | 148 | local nowTime = skynet.timex() |
143 | if isNew then | 149 | if isNew then |
144 | hangInfo.coinTime = nowTime | 150 | hangInfo.coinTime = nowTime |
@@ -149,23 +155,16 @@ function _M.startRpc( agent, data ) | @@ -149,23 +155,16 @@ function _M.startRpc( agent, data ) | ||
149 | hangInfo.coinTime = math.min(nowTime, hangInfo.endCoinTime) | 155 | hangInfo.coinTime = math.min(nowTime, hangInfo.endCoinTime) |
150 | hangInfo.itemTime = math.min(nowTime, hangInfo.endItemTime) | 156 | hangInfo.itemTime = math.min(nowTime, hangInfo.endItemTime) |
151 | end | 157 | end |
158 | + | ||
159 | + role:pushMsg({type = "hang", time = math.min(hangInfo.endCoinTime - nowTime, hangInfo.endItemTime - nowTime)}) | ||
152 | if not role:checkHangPass(carbonId) then | 160 | if not role:checkHangPass(carbonId) then |
153 | hangInfo.bossTime = nowTime + carbonData.idle_time | 161 | hangInfo.bossTime = nowTime + carbonData.idle_time |
154 | else | 162 | else |
155 | hangInfo.bossTime = nil | 163 | hangInfo.bossTime = nil |
156 | end | 164 | end |
165 | + | ||
157 | role:updateProperty({field = "hangInfo", value = hangInfo}) | 166 | role:updateProperty({field = "hangInfo", value = hangInfo}) |
158 | 167 | ||
159 | - -- 指定当前引导的步骤 | ||
160 | - if carbonId == 10101 then | ||
161 | - role:saveGuide(5,11) | ||
162 | - elseif carbonId == 10102 then | ||
163 | - role:saveGuide(8,2) | ||
164 | - elseif carbonId == 10103 then | ||
165 | - role:saveGuide(9,2) | ||
166 | - elseif carbonId == 10220 then | ||
167 | - role:saveGuide(22,1) | ||
168 | - end | ||
169 | role:mylog("hang_action", {desc = "startHang", int1 = carbonId}) | 168 | role:mylog("hang_action", {desc = "startHang", int1 = carbonId}) |
170 | SendPacket(actionCodes.Hang_startRpc, '') | 169 | SendPacket(actionCodes.Hang_startRpc, '') |
171 | return true | 170 | return true |
@@ -193,12 +192,12 @@ function _M.startBattleRpc(agent, data) | @@ -193,12 +192,12 @@ function _M.startBattleRpc(agent, data) | ||
193 | return 1 | 192 | return 1 |
194 | end | 193 | end |
195 | 194 | ||
196 | - local hangInfo = role:getProperty("hangInfo") | ||
197 | - if curData.main ~= 1 then | ||
198 | - if carbonId ~= hangInfo.carbonId then | ||
199 | - return 2 | ||
200 | - end | ||
201 | - end | 195 | + --local hangInfo = role:getProperty("hangInfo") or {} |
196 | + --if curData.main ~= 1 then | ||
197 | + -- if carbonId ~= hangInfo.carbonId then | ||
198 | + -- return 2 | ||
199 | + -- end | ||
200 | + --end | ||
202 | 201 | ||
203 | if role:checkHangPass(carbonId) then | 202 | if role:checkHangPass(carbonId) then |
204 | return 3 | 203 | return 3 |
@@ -214,7 +213,7 @@ end | @@ -214,7 +213,7 @@ end | ||
214 | function _M.endBattleRpc(agent, data) | 213 | function _M.endBattleRpc(agent, data) |
215 | local role = agent.role | 214 | local role = agent.role |
216 | local msg = MsgPack.unpack(data) | 215 | local msg = MsgPack.unpack(data) |
217 | - local hangInfo = role:getProperty("hangInfo") | 216 | + local hangInfo = role:getProperty("hangInfo") or {} |
218 | if not msg.key or msg.key ~= _BattleKey then | 217 | if not msg.key or msg.key ~= _BattleKey then |
219 | SendPacket(actionCodes.Hang_endBattleRpc, MsgPack.pack({errorCode = 1})) | 218 | SendPacket(actionCodes.Hang_endBattleRpc, MsgPack.pack({errorCode = 1})) |
220 | return true | 219 | return true |
@@ -225,11 +224,12 @@ function _M.endBattleRpc(agent, data) | @@ -225,11 +224,12 @@ function _M.endBattleRpc(agent, data) | ||
225 | if not carbonData then | 224 | if not carbonData then |
226 | return 2 | 225 | return 2 |
227 | end | 226 | end |
228 | - if carbonData.main ~= 1 then | ||
229 | - if carbonId ~= hangInfo.carbonId then | ||
230 | - return 3 | ||
231 | - end | ||
232 | - end | 227 | + |
228 | + --if carbonData.main ~= 1 then | ||
229 | + -- if carbonId ~= hangInfo.carbonId then | ||
230 | + -- return 3 | ||
231 | + -- end | ||
232 | + --end | ||
233 | 233 | ||
234 | if role:checkHangPass(carbonId) then | 234 | if role:checkHangPass(carbonId) then |
235 | return 4 | 235 | return 4 |
@@ -255,12 +255,7 @@ function _M.endBattleRpc(agent, data) | @@ -255,12 +255,7 @@ function _M.endBattleRpc(agent, data) | ||
255 | 255 | ||
256 | -- 引导 | 256 | -- 引导 |
257 | if carbonId == 10101 then | 257 | if carbonId == 10101 then |
258 | - role:finishGuide(5) | ||
259 | - elseif carbonId == 10102 then | ||
260 | - role:finishGuide(8) | ||
261 | - role:saveGuide(9, 2) | ||
262 | - elseif carbonId == 10103 then | ||
263 | - role:finishGuide(9) | 258 | + role:finishGuide(6) |
264 | elseif carbonId == 20101 then | 259 | elseif carbonId == 20101 then |
265 | role:finishGuide(22) | 260 | role:finishGuide(22) |
266 | end | 261 | end |
@@ -273,12 +268,12 @@ function _M.endBattleRpc(agent, data) | @@ -273,12 +268,12 @@ function _M.endBattleRpc(agent, data) | ||
273 | end | 268 | end |
274 | local nextCarbonId = role:getNextCarbonId(carbonId) | 269 | local nextCarbonId = role:getNextCarbonId(carbonId) |
275 | -- 设置挂机关卡 | 270 | -- 设置挂机关卡 |
276 | - if isWin and hangInfo.carbonId < nextCarbonId then | ||
277 | - hangInfo.carbonId = nextCarbonId | ||
278 | - local cfg = csvdb["idle_battleCsv"][nextCarbonId] | ||
279 | - if cfg then | ||
280 | - hangInfo.bossTime = skynet.timex() + cfg.idle_time | ||
281 | - end | 271 | + if isWin then --and (hangInfo.carbonId or 0) < nextCarbonId then |
272 | + hangInfo.expCarbonId = carbonId | ||
273 | + --local cfg = csvdb["idle_battleCsv"][nextCarbonId] | ||
274 | + --if cfg then | ||
275 | + -- hangInfo.bossTime = skynet.timex() + cfg.idle_time | ||
276 | + --end | ||
282 | end | 277 | end |
283 | role:updateProperty({field = "hangInfo", value = hangInfo}) | 278 | role:updateProperty({field = "hangInfo", value = hangInfo}) |
284 | 279 | ||
@@ -334,7 +329,7 @@ function _M.roleFormatRpc(agent , data) | @@ -334,7 +329,7 @@ function _M.roleFormatRpc(agent , data) | ||
334 | hangTeam.leader = msg.leader | 329 | hangTeam.leader = msg.leader |
335 | hangTeam.supports = supports | 330 | hangTeam.supports = supports |
336 | role:saveHangTeam(hangTeam) | 331 | role:saveHangTeam(hangTeam) |
337 | - role:saveGuide(5,8) | 332 | + role:finishGuide(5) |
338 | SendPacket(actionCodes.Hang_roleFormatRpc, '') | 333 | SendPacket(actionCodes.Hang_roleFormatRpc, '') |
339 | return true | 334 | return true |
340 | end | 335 | end |
@@ -354,7 +349,9 @@ function _M.getRewardRpc(agent , data) | @@ -354,7 +349,9 @@ function _M.getRewardRpc(agent , data) | ||
354 | hangInfo.itemTime = nowTime | 349 | hangInfo.itemTime = nowTime |
355 | role:updateProperty({field = "hangBag", value = items}) | 350 | role:updateProperty({field = "hangBag", value = items}) |
356 | role:updateProperty({field = "hangInfo", value = hangInfo}) | 351 | role:updateProperty({field = "hangInfo", value = hangInfo}) |
357 | - role:checkTaskEnter("HangGet") | 352 | + role:pushMsg({type = "hang", time = globalCsv.idle_producetime_max}) |
353 | + | ||
354 | + role:checkTaskEnter("HangGet", {reward = reward}) | ||
358 | if reward[ItemId.Gold] then | 355 | if reward[ItemId.Gold] then |
359 | role:checkTaskEnter("HangGetGold", {count = reward[ItemId.Gold]}) | 356 | role:checkTaskEnter("HangGetGold", {count = reward[ItemId.Gold]}) |
360 | end | 357 | end |
@@ -382,6 +379,7 @@ function _M.quickRpc(agent , data) | @@ -382,6 +379,7 @@ function _M.quickRpc(agent , data) | ||
382 | local hangInfo = role:getProperty("hangInfo") | 379 | local hangInfo = role:getProperty("hangInfo") |
383 | if not hangInfo.carbonId then return end | 380 | if not hangInfo.carbonId then return end |
384 | local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId] | 381 | local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId] |
382 | + local expCarbonData = csvdb["idle_battleCsv"][hangInfo.expCarbonId] | ||
385 | 383 | ||
386 | local curCount = role.dailyData:getProperty("hangQC") + 1 | 384 | local curCount = role.dailyData:getProperty("hangQC") + 1 |
387 | local costs = globalCsv.idle_quickproduce_cost:toArray(true, "=") | 385 | local costs = globalCsv.idle_quickproduce_cost:toArray(true, "=") |
@@ -398,9 +396,9 @@ function _M.quickRpc(agent , data) | @@ -398,9 +396,9 @@ function _M.quickRpc(agent , data) | ||
398 | 396 | ||
399 | local coinCount = math.floor(time / globalCsv.idle_money_produce_cd) | 397 | local coinCount = math.floor(time / globalCsv.idle_money_produce_cd) |
400 | local itemCount = math.floor(time / globalCsv.idle_item_produce_cd) | 398 | local itemCount = math.floor(time / globalCsv.idle_item_produce_cd) |
401 | - reward[ItemId.Gold] = math.floor((reward[ItemId.Gold] or 0) + coinCount * carbonData.money) | ||
402 | - reward[ItemId.Exp] = math.floor((reward[ItemId.Exp] or 0) + coinCount * carbonData.exp) | ||
403 | - reward[ItemId.PlayerExp] = math.floor((reward[ItemId.PlayerExp] or 0) + coinCount * carbonData.playerExp) | 399 | + reward[ItemId.Gold] = math.floor((reward[ItemId.Gold] or 0) + coinCount * expCarbonData.money) |
400 | + reward[ItemId.Exp] = math.floor((reward[ItemId.Exp] or 0) + coinCount * expCarbonData.exp) | ||
401 | + reward[ItemId.PlayerExp] = math.floor((reward[ItemId.PlayerExp] or 0) + coinCount * expCarbonData.playerExp) | ||
404 | 402 | ||
405 | local pool = {} | 403 | local pool = {} |
406 | for _, temp in pairs(carbonData.item:toArray()) do | 404 | for _, temp in pairs(carbonData.item:toArray()) do |
@@ -490,8 +488,9 @@ function _M.buyBonusCountRpc(agent, data) | @@ -490,8 +488,9 @@ function _M.buyBonusCountRpc(agent, data) | ||
490 | end | 488 | end |
491 | 489 | ||
492 | local bonusC = role.dailyData:getProperty("bonusC") | 490 | local bonusC = role.dailyData:getProperty("bonusC") |
491 | + local extraCnt = role.storeData:getBonusExtraFightCount() | ||
493 | bonusC[btype] = bonusC[btype] or {c = 0, b = 0} | 492 | bonusC[btype] = bonusC[btype] or {c = 0, b = 0} |
494 | - local lastCount = globalCsv.bonus_daily_buy_count * coef - bonusC[btype]["b"] | 493 | + local lastCount = globalCsv.bonus_daily_buy_count * coef + extraCnt - bonusC[btype]["b"] |
495 | if math.illegalNum(count, 1, lastCount) then return 1 end | 494 | if math.illegalNum(count, 1, lastCount) then return 1 end |
496 | 495 | ||
497 | if not role:checkItemEnough({[ItemId.Diamond] = globalCsv.bonus_buy_cost * count}) then return 2 end | 496 | if not role:checkItemEnough({[ItemId.Diamond] = globalCsv.bonus_buy_cost * count}) then return 2 end |
@@ -531,12 +530,13 @@ function _M.startBonusBattleRpc(agent, data) | @@ -531,12 +530,13 @@ function _M.startBonusBattleRpc(agent, data) | ||
531 | 530 | ||
532 | local actData = csvdb["activity_ctrlCsv"][actId] | 531 | local actData = csvdb["activity_ctrlCsv"][actId] |
533 | 532 | ||
533 | + local extraCnt = role.storeData:getBonusExtraFightCount() | ||
534 | local coef = 1 | 534 | local coef = 1 |
535 | if open and actData then | 535 | if open and actData then |
536 | coef = tonumber(actData.condition2) | 536 | coef = tonumber(actData.condition2) |
537 | end | 537 | end |
538 | 538 | ||
539 | - if globalCsv.bonus_daily_count * coef - bonusC[bonusData.type]["c"] <= 0 then return 7 end | 539 | + if globalCsv.bonus_daily_count * coef + extraCnt - bonusC[bonusData.type]["c"] <= 0 then return 7 end |
540 | 540 | ||
541 | 541 | ||
542 | role.__bonusBattleCache = { | 542 | role.__bonusBattleCache = { |
@@ -556,6 +556,7 @@ function _M.endBonusBattleRpc(agent, data) | @@ -556,6 +556,7 @@ function _M.endBonusBattleRpc(agent, data) | ||
556 | if not role.__bonusBattleCache then return 1 end | 556 | if not role.__bonusBattleCache then return 1 end |
557 | local open, actId = role.activity:isOpen("BonusDouble") | 557 | local open, actId = role.activity:isOpen("BonusDouble") |
558 | local actData = csvdb["activity_ctrlCsv"][actId] | 558 | local actData = csvdb["activity_ctrlCsv"][actId] |
559 | + local extraCnt = role.storeData:getBonusExtraFightCount() | ||
559 | 560 | ||
560 | local coef = 1 | 561 | local coef = 1 |
561 | if open and actData then | 562 | if open and actData then |
@@ -573,7 +574,7 @@ function _M.endBonusBattleRpc(agent, data) | @@ -573,7 +574,7 @@ function _M.endBonusBattleRpc(agent, data) | ||
573 | -- 胜利扣除次数 | 574 | -- 胜利扣除次数 |
574 | local bonusC = role.dailyData:getProperty("bonusC") | 575 | local bonusC = role.dailyData:getProperty("bonusC") |
575 | bonusC[bonusData.type] = bonusC[bonusData.type] or {c = 0, b = 0} | 576 | bonusC[bonusData.type] = bonusC[bonusData.type] or {c = 0, b = 0} |
576 | - if globalCsv.bonus_daily_count * coef - bonusC[bonusData.type]["c"] <= 0 then return 3 end | 577 | + if globalCsv.bonus_daily_count * coef + extraCnt - bonusC[bonusData.type]["c"] <= 0 then return 3 end |
577 | bonusC[bonusData.type]["c"] = bonusC[bonusData.type]["c"] + 1 | 578 | bonusC[bonusData.type]["c"] = bonusC[bonusData.type]["c"] + 1 |
578 | role.dailyData:updateProperty({field = "bonusC", value = bonusC}) | 579 | role.dailyData:updateProperty({field = "bonusC", value = bonusC}) |
579 | 580 |
src/actions/HeroAction.lua
@@ -54,12 +54,11 @@ function _M.levelUpRpc( agent, data ) | @@ -54,12 +54,11 @@ function _M.levelUpRpc( agent, data ) | ||
54 | hero_upgrade_scoreget = hero:getProperty("battleV") - oldBattleV, -- 通过英雄升级提升的评分 | 54 | hero_upgrade_scoreget = hero:getProperty("battleV") - oldBattleV, -- 通过英雄升级提升的评分 |
55 | }) | 55 | }) |
56 | 56 | ||
57 | - if hero:getProperty("type") == 103 then | ||
58 | - role:finishGuide(7) | ||
59 | - end | ||
60 | hero:mylog({desc = "levelUp", int1 = hero:getProperty("level")}) | 57 | hero:mylog({desc = "levelUp", int1 = hero:getProperty("level")}) |
61 | 58 | ||
62 | role:checkTaskEnter("HeroLevelUp", {level = hero:getProperty("level")}) | 59 | role:checkTaskEnter("HeroLevelUp", {level = hero:getProperty("level")}) |
60 | + | ||
61 | + role:checkTaskEnter("HeroLvlCollect", {}) | ||
63 | SendPacket(actionCodes.Hero_levelUpRpc, '') | 62 | SendPacket(actionCodes.Hero_levelUpRpc, '') |
64 | return true | 63 | return true |
65 | end | 64 | end |
@@ -127,7 +126,13 @@ function _M.wakeRpc(agent, data) | @@ -127,7 +126,13 @@ function _M.wakeRpc(agent, data) | ||
127 | hero_rise_result = getChangeAttrJson(oldAttr, hero:getTotalAttrs()), --英雄觉醒效果,可记录效果ID,或json格式记录提升效果,{攻击:20,闪避:20,……..} | 126 | hero_rise_result = getChangeAttrJson(oldAttr, hero:getTotalAttrs()), --英雄觉醒效果,可记录效果ID,或json格式记录提升效果,{攻击:20,闪避:20,……..} |
128 | }) | 127 | }) |
129 | 128 | ||
129 | + if hero:getProperty("type") == 204 then | ||
130 | + role:finishGuide(7) | ||
131 | + end | ||
132 | + | ||
130 | SendPacket(actionCodes.Hero_wakeRpc, '') | 133 | SendPacket(actionCodes.Hero_wakeRpc, '') |
134 | + | ||
135 | + role:checkTaskEnter("HeroStarCollect", {}) | ||
131 | return true | 136 | return true |
132 | end | 137 | end |
133 | 138 | ||
@@ -595,6 +600,8 @@ function _M.referRunesRpc(agent, data) | @@ -595,6 +600,8 @@ function _M.referRunesRpc(agent, data) | ||
595 | }) | 600 | }) |
596 | end | 601 | end |
597 | end | 602 | end |
603 | + | ||
604 | + role:checkTaskEnter("RuneQualityCollect", {}) | ||
598 | 605 | ||
599 | SendPacket(actionCodes.Hero_referRunesRpc, "") | 606 | SendPacket(actionCodes.Hero_referRunesRpc, "") |
600 | return true | 607 | return true |
@@ -728,6 +735,13 @@ function _M.drawHeroRpc(agent, data) | @@ -728,6 +735,13 @@ function _M.drawHeroRpc(agent, data) | ||
728 | if btype ~= 1 then | 735 | if btype ~= 1 then |
729 | subType = 1 | 736 | subType = 1 |
730 | end | 737 | end |
738 | + | ||
739 | + if btype == 1 then | ||
740 | + -- 判断定向卡池活动开启 | ||
741 | + if not role.activity:isOpen("RaceDraw") then | ||
742 | + return | ||
743 | + end | ||
744 | + end | ||
731 | 745 | ||
732 | local buildTypeData = csvdb["build_typeCsv"][btype] | 746 | local buildTypeData = csvdb["build_typeCsv"][btype] |
733 | if not buildTypeData then return 2 end | 747 | if not buildTypeData then return 2 end |
@@ -806,26 +820,44 @@ function _M.drawHeroRpc(agent, data) | @@ -806,26 +820,44 @@ function _M.drawHeroRpc(agent, data) | ||
806 | end | 820 | end |
807 | end | 821 | end |
808 | 822 | ||
809 | - for itemId, oneData in pairs(isFloorBack and csvdb["build_floorCsv"] or csvdb["build_poolCsv"]) do | ||
810 | - local pool_str = "pool_" .. poolId | ||
811 | - if oneData[pool_str] and oneData[pool_str] ~= "" then | ||
812 | - local itemData = csvdb["itemCsv"][itemId] | ||
813 | - while itemData do | ||
814 | - if itemData.type ~= ItemType.Hero then break end | ||
815 | - local heroData = csvdb["unitCsv"][itemData.id - ItemStartId.Hero] | ||
816 | - if not heroData then break end | ||
817 | - local ok = true | ||
818 | - -- 保底是全随机,不用比较类型 | ||
819 | - if not isFloorBack then | ||
820 | - for idx, field in ipairs(condition) do | ||
821 | - if heroData[field] ~= values[idx] then ok = false break end | 823 | + local weight = 0 |
824 | + local up_pool = nil | ||
825 | + local rand_v = math.randomInt(1, 100) | ||
826 | + if values[1] == HeroQuality.SR then | ||
827 | + weight = unitPool["up_sr_weight"] | ||
828 | + up_pool = unitPool["up_sr_id"] | ||
829 | + elseif values[1] == HeroQuality.SSR then | ||
830 | + weight = unitPool["up_ssr_weight"] | ||
831 | + up_pool = unitPool["up_ssr_id"] | ||
832 | + end | ||
833 | + --print(poolId, rand_v, weight, up_pool, values[1]) | ||
834 | + if rand_v < weight and up_pool then | ||
835 | + up_pool = up_pool:toArray(true, "=") | ||
836 | + for k, v in ipairs(up_pool) do | ||
837 | + resultPool[v] = {1} | ||
838 | + end | ||
839 | + else | ||
840 | + for itemId, oneData in pairs(isFloorBack and csvdb["build_floorCsv"] or csvdb["build_poolCsv"]) do | ||
841 | + local pool_str = "pool_" .. poolId | ||
842 | + if oneData[pool_str] and oneData[pool_str] ~= "" then | ||
843 | + local itemData = csvdb["itemCsv"][itemId] | ||
844 | + while itemData do | ||
845 | + if itemData.type ~= ItemType.Hero then break end | ||
846 | + local heroData = csvdb["unitCsv"][itemData.id - ItemStartId.Hero] | ||
847 | + if not heroData then break end | ||
848 | + local ok = true | ||
849 | + -- 保底是全随机,不用比较类型 | ||
850 | + if not isFloorBack then | ||
851 | + for idx, field in ipairs(condition) do | ||
852 | + if heroData[field] ~= values[idx] then ok = false break end | ||
853 | + end | ||
822 | end | 854 | end |
855 | + if not ok then break end | ||
856 | + if oneData[pool_str] > 0 then | ||
857 | + resultPool[itemId] = {oneData[pool_str]} -- itemId, count, 概率 | ||
858 | + end | ||
859 | + break | ||
823 | end | 860 | end |
824 | - if not ok then break end | ||
825 | - if oneData[pool_str] > 0 then | ||
826 | - resultPool[itemId] = {oneData[pool_str]} -- itemId, count, 概率 | ||
827 | - end | ||
828 | - break | ||
829 | end | 861 | end |
830 | end | 862 | end |
831 | end | 863 | end |
@@ -833,9 +865,9 @@ function _M.drawHeroRpc(agent, data) | @@ -833,9 +865,9 @@ function _M.drawHeroRpc(agent, data) | ||
833 | 865 | ||
834 | role:costItems(cost, {log = {desc = "drawHero", int1 = btype, int2 = poolId}}) | 866 | role:costItems(cost, {log = {desc = "drawHero", int1 = btype, int2 = poolId}}) |
835 | 867 | ||
836 | - local guideHero | ||
837 | - if role:getProperty("newerGuide") == "11=1" then | ||
838 | - guideHero = 613 | 868 | + local guideHero = nil |
869 | + if role:getProperty("newerGuide") == "8=1" then | ||
870 | + guideHero = globalCsv.newdraw_hero_item_id or 503 | ||
839 | end | 871 | end |
840 | 872 | ||
841 | local ssrCount = 0 | 873 | local ssrCount = 0 |
@@ -854,12 +886,16 @@ function _M.drawHeroRpc(agent, data) | @@ -854,12 +886,16 @@ function _M.drawHeroRpc(agent, data) | ||
854 | local itemId = math.randWeight(resultPool, 1) | 886 | local itemId = math.randWeight(resultPool, 1) |
855 | if guideHero then | 887 | if guideHero then |
856 | itemId = guideHero | 888 | itemId = guideHero |
857 | - guideHero = nil | ||
858 | end | 889 | end |
859 | 890 | ||
860 | local itemData = csvdb["itemCsv"][itemId] | 891 | local itemData = csvdb["itemCsv"][itemId] |
861 | if itemData.quality == HeroQuality.SSR then | 892 | if itemData.quality == HeroQuality.SSR then |
862 | ssrCount = ssrCount + 1 | 893 | ssrCount = ssrCount + 1 |
894 | + if not guideHero then | ||
895 | + -- 广播获得ssr英雄 | ||
896 | + local ntf = {heroId = itemData.id - ItemStartId.Hero, nick = role:getProperty("name")} | ||
897 | + mcast_util.pub_world(actionCodes.Role_broadGetSSR, MsgPack.pack(ntf)) | ||
898 | + end | ||
863 | end | 899 | end |
864 | 900 | ||
865 | if itemData.quality >= HeroQuality.SR then | 901 | if itemData.quality >= HeroQuality.SR then |
@@ -890,7 +926,7 @@ function _M.drawHeroRpc(agent, data) | @@ -890,7 +926,7 @@ function _M.drawHeroRpc(agent, data) | ||
890 | if ssrCount > 0 then | 926 | if ssrCount > 0 then |
891 | role:checkTaskEnter("DrawSSR", {count = ssrCount}) | 927 | role:checkTaskEnter("DrawSSR", {count = ssrCount}) |
892 | end | 928 | end |
893 | - role:finishGuide(11) | 929 | + role:finishGuide(8) |
894 | 930 | ||
895 | role:log("gacha", { | 931 | role:log("gacha", { |
896 | gacha_id = poolId, -- 卡池ID | 932 | gacha_id = poolId, -- 卡池ID |
@@ -910,7 +946,28 @@ function _M.drawHeroRpc(agent, data) | @@ -910,7 +946,28 @@ function _M.drawHeroRpc(agent, data) | ||
910 | local drawCardReward, val = role:getDrawCardExtraReward(oldVal, newVal) | 946 | local drawCardReward, val = role:getDrawCardExtraReward(oldVal, newVal) |
911 | -- 空字符穿代表直接给英雄 走以前repayHeroRpc | 947 | -- 空字符穿代表直接给英雄 走以前repayHeroRpc |
912 | if drawCardReward == "" then | 948 | if drawCardReward == "" then |
913 | - local id = math.randWeight(csvdb["build_giftCsv"], "pool_1") | 949 | + local repayHeroMaxCount = role:getProperty("repayMaxC") or 0 |
950 | + repayHeroMaxCount = repayHeroMaxCount + 1 | ||
951 | + | ||
952 | + role:updateProperty({field = "repayMaxC", value = repayHeroMaxCount}) | ||
953 | + local even = repayHeroMaxCount % 2 | ||
954 | + local id = 0 | ||
955 | + if even == 1 then | ||
956 | + id = math.randWeight(csvdb["build_giftCsv"], "pool_1") | ||
957 | + else | ||
958 | + local giftHeroSet = {} | ||
959 | + for gid, cfg in pairs(csvdb["build_giftCsv"]) do | ||
960 | + if cfg["pool_1"] ~= 0 and not role:isHaveHero(gid - ItemStartId.Hero) then | ||
961 | + giftHeroSet[gid] = {1} | ||
962 | + end | ||
963 | + end | ||
964 | + if next(giftHeroSet) then | ||
965 | + id = math.randWeight(giftHeroSet, 1) | ||
966 | + end | ||
967 | + end | ||
968 | + if id == 0 then | ||
969 | + id = math.randWeight(csvdb["build_giftCsv"], "pool_1") | ||
970 | + end | ||
914 | 971 | ||
915 | local r,change = {} | 972 | local r,change = {} |
916 | local itemData = csvdb["itemCsv"][id] | 973 | local itemData = csvdb["itemCsv"][id] |
@@ -925,8 +982,9 @@ function _M.drawHeroRpc(agent, data) | @@ -925,8 +982,9 @@ function _M.drawHeroRpc(agent, data) | ||
925 | --end | 982 | --end |
926 | SendPacket(actionCodes.Hero_drawHeroExtraRewardNtf, MsgPack.pack(role:packReward(r, change))) | 983 | SendPacket(actionCodes.Hero_drawHeroExtraRewardNtf, MsgPack.pack(role:packReward(r, change))) |
927 | elseif drawCardReward and drawCardReward ~= "" then | 984 | elseif drawCardReward and drawCardReward ~= "" then |
928 | - role:award(drawCardReward, {log = {desc = "drawHeroExtraReward", int1 = oldVal, int2 = newVal}}) | ||
929 | - SendPacket(actionCodes.Hero_drawHeroExtraRewardNtf, MsgPack.pack({reward = drawCardReward:toNumMap()})) | 985 | + local r,change = {} |
986 | + r, change = role:award(drawCardReward, {log = {desc = "drawHeroExtraReward", int1 = oldVal, int2 = newVal}}) | ||
987 | + SendPacket(actionCodes.Hero_drawHeroExtraRewardNtf, MsgPack.pack(role:packReward(r, change))) | ||
930 | end | 988 | end |
931 | role:updateProperty({field = "repayHero", value = val}) | 989 | role:updateProperty({field = "repayHero", value = val}) |
932 | end | 990 | end |
@@ -1010,4 +1068,4 @@ function _M.changeCrown(agent, data) | @@ -1010,4 +1068,4 @@ function _M.changeCrown(agent, data) | ||
1010 | return true | 1068 | return true |
1011 | end | 1069 | end |
1012 | 1070 | ||
1013 | -return _M | ||
1014 | \ No newline at end of file | 1071 | \ No newline at end of file |
1072 | +return _M |
src/actions/RoleAction.lua
@@ -121,6 +121,9 @@ function _M.loginRpc( agent, data ) | @@ -121,6 +121,9 @@ function _M.loginRpc( agent, data ) | ||
121 | role:setProperty("device", device) | 121 | role:setProperty("device", device) |
122 | end | 122 | end |
123 | end | 123 | end |
124 | + if msg.token then | ||
125 | + role._pushToken = msg.token | ||
126 | + end | ||
124 | 127 | ||
125 | if not msg.isGMlogin then | 128 | if not msg.isGMlogin then |
126 | local banTime = role:getProperty("banTime") | 129 | local banTime = role:getProperty("banTime") |
@@ -261,7 +264,8 @@ function _M.loginRpc( agent, data ) | @@ -261,7 +264,8 @@ function _M.loginRpc( agent, data ) | ||
261 | 264 | ||
262 | -- 发下缓存的世界消息 | 265 | -- 发下缓存的世界消息 |
263 | local worldChatResponse = {worldChats = {}} | 266 | local worldChatResponse = {worldChats = {}} |
264 | - local ok, msgs = pcall(skynet.call, '.globald', "lua", "getWorldMsg", role._channelIdx) | 267 | + -- local ok, msgs = pcall(skynet.call, '.globald', "lua", "getWorldMsg", role._channelIdx) |
268 | + local ok, msgs = true, {} | ||
265 | if not ok then | 269 | if not ok then |
266 | msgs = {} | 270 | msgs = {} |
267 | end | 271 | end |
@@ -550,7 +554,7 @@ function _M.openTimeBoxRpc(agent, data) | @@ -550,7 +554,7 @@ function _M.openTimeBoxRpc(agent, data) | ||
550 | if boxL[slot] then return end | 554 | if boxL[slot] then return end |
551 | role:costItems({[itemId] = 1}, {log = {desc = "openTimeBox"}}) | 555 | role:costItems({[itemId] = 1}, {log = {desc = "openTimeBox"}}) |
552 | boxL[slot] = {id = itemId, time = skynet.timex() + randomData.openTime} | 556 | boxL[slot] = {id = itemId, time = skynet.timex() + randomData.openTime} |
553 | - | 557 | + role:pushMsg({type = "box", slot = slot, time = randomData.openTime}) |
554 | elseif oper == 2 then -- 领取 | 558 | elseif oper == 2 then -- 领取 |
555 | local quick = msg.quick | 559 | local quick = msg.quick |
556 | if not boxL[slot] then return end | 560 | if not boxL[slot] then return end |
@@ -561,6 +565,7 @@ function _M.openTimeBoxRpc(agent, data) | @@ -561,6 +565,7 @@ function _M.openTimeBoxRpc(agent, data) | ||
561 | costKey = math.ceil((boxL[slot].time - skynet.timex()) / (cost_pre[1] * 60)) * cost_pre[2] | 565 | costKey = math.ceil((boxL[slot].time - skynet.timex()) / (cost_pre[1] * 60)) * cost_pre[2] |
562 | if not role:checkItemEnough({[ItemId.BoxKey] = costKey}) then return end | 566 | if not role:checkItemEnough({[ItemId.BoxKey] = costKey}) then return end |
563 | role:costItems({[ItemId.BoxKey] = costKey}, {log = {desc = "openTimeBox"}}) | 567 | role:costItems({[ItemId.BoxKey] = costKey}, {log = {desc = "openTimeBox"}}) |
568 | + role:pushCancel({type = "box", slot = slot}) | ||
564 | end | 569 | end |
565 | local boxId = boxL[slot].id | 570 | local boxId = boxL[slot].id |
566 | local itemData = csvdb["itemCsv"][boxId] | 571 | local itemData = csvdb["itemCsv"][boxId] |
@@ -615,52 +620,57 @@ end | @@ -615,52 +620,57 @@ end | ||
615 | function _M.openSpeedUpBoxRpc(agent, data) | 620 | function _M.openSpeedUpBoxRpc(agent, data) |
616 | local role = agent.role | 621 | local role = agent.role |
617 | local msg = MsgPack.unpack(data) | 622 | local msg = MsgPack.unpack(data) |
618 | - | ||
619 | - local id = msg.id | ||
620 | - local count = msg.count | ||
621 | - local itemData = csvdb["itemCsv"][id] | ||
622 | - if not itemData or itemData.type ~= ItemType.SpeedBox then return end | ||
623 | - | ||
624 | - if math.illegalNum(count, 1, role:getItemCount(id)) then return end | ||
625 | - local useType, hour = table.unpack(itemData.use_effect:toArray(true, "=")) | ||
626 | - local time = hour * 60 * 60 | 623 | + local itemInfo = msg.itemInfo |
627 | 624 | ||
628 | local reward = {} | 625 | local reward = {} |
629 | - if useType == 1 then -- 挂机齿轮 | ||
630 | - local hangInfo = role:getProperty("hangInfo") | ||
631 | - if not hangInfo.carbonId then | ||
632 | - return | ||
633 | - end | ||
634 | - local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId] | ||
635 | - reward[ItemId.Gold] = math.floor(time / globalCsv.idle_money_produce_cd) * carbonData.money * count | ||
636 | - elseif useType == 2 then -- 挂机经验 | ||
637 | - local hangInfo = role:getProperty("hangInfo") | ||
638 | - if not hangInfo.carbonId then | ||
639 | - return | ||
640 | - end | ||
641 | - local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId] | ||
642 | - reward[ItemId.Exp] = math.floor(time / globalCsv.idle_money_produce_cd) * carbonData.exp * count | ||
643 | - elseif useType == 3 then -- 食材商人收入 | ||
644 | - local buildType = 6 | ||
645 | - local level = role.dinerData:getProperty("buildL"):getv(buildType, 1) | ||
646 | - local buildingData = csvdb["diner_buildingCsv"][buildType][level] | ||
647 | - if not buildingData then | ||
648 | - return 1 | ||
649 | - end | ||
650 | - local gfood = role.dinerData:getProperty("gfood") | ||
651 | - if not next(gfood) then return end | ||
652 | - for k , v in pairs(gfood) do | ||
653 | - local itemId = v.id | ||
654 | - local speed = globalCsv.diner_get_food_speed[csvdb["itemCsv"][itemId].quality] * buildingData.speed / 100 | ||
655 | - reward[itemId] = math.floor(time / speed) * count | 626 | + for i = 1, #itemInfo do |
627 | + local pair = itemInfo[i] | ||
628 | + local id = pair[1] | ||
629 | + local count = pair[2] | ||
630 | + local itemData = csvdb["itemCsv"][id] | ||
631 | + if not itemData or itemData.type ~= ItemType.SpeedBox then return end | ||
632 | + | ||
633 | + if math.illegalNum(count, 1, role:getItemCount(id)) then return 1 end | ||
634 | + local useType, hour = table.unpack(itemData.use_effect:toArray(true, "=")) | ||
635 | + local time = hour * 60 * 60 | ||
636 | + | ||
637 | + if useType == 1 then -- 挂机齿轮 | ||
638 | + local hangInfo = role:getProperty("hangInfo") | ||
639 | + if not hangInfo.expCarbonId then | ||
640 | + return 2 | ||
641 | + end | ||
642 | + local carbonData = csvdb["idle_battleCsv"][hangInfo.expCarbonId] | ||
643 | + reward[ItemId.Gold] = (reward[ItemId.Gold] or 0) + math.floor(time / globalCsv.idle_money_produce_cd) * carbonData.money * count | ||
644 | + elseif useType == 2 then -- 挂机经验 | ||
645 | + local hangInfo = role:getProperty("hangInfo") | ||
646 | + if not hangInfo.expCarbonId then | ||
647 | + return 3 | ||
648 | + end | ||
649 | + local carbonData = csvdb["idle_battleCsv"][hangInfo.expCarbonId] | ||
650 | + reward[ItemId.Exp] = (reward[ItemId.Exp] or 0) + math.floor(time / globalCsv.idle_money_produce_cd) * carbonData.exp * count | ||
651 | + elseif useType == 3 then -- 食材商人收入 | ||
652 | + local buildType = 6 | ||
653 | + local level = role.dinerData:getProperty("buildL"):getv(buildType, 1) | ||
654 | + local buildingData = csvdb["diner_buildingCsv"][buildType][level] | ||
655 | + if not buildingData then | ||
656 | + return 4 | ||
657 | + end | ||
658 | + local gfood = role.dinerData:getProperty("gfood") | ||
659 | + if not next(gfood) then return 5 end | ||
660 | + for k , v in pairs(gfood) do | ||
661 | + local itemId = v.id | ||
662 | + local speed = globalCsv.diner_get_food_speed[csvdb["itemCsv"][itemId].quality] * buildingData.speed / 100 | ||
663 | + reward[itemId] = (reward[itemId] or 0) + math.floor((time / speed) * count) | ||
664 | + end | ||
665 | + else | ||
666 | + return 6 | ||
656 | end | 667 | end |
657 | - else | ||
658 | - return | 668 | + |
669 | + role:costItems({[id] = count}, {log = {desc = "speedUpBox"}}) | ||
659 | end | 670 | end |
660 | 671 | ||
661 | - role:costItems({[id] = count}, {log = {desc = "speedUpBox"}}) | ||
662 | local change | 672 | local change |
663 | - reward, change = role:award(reward, {log = {desc = "speedUpBox"}, int1 = id, int2 = count}) | 673 | + reward, change = role:award(reward, {log = {desc = "speedUpBox"}}) |
664 | 674 | ||
665 | SendPacket(actionCodes.Role_openSpeedUpBoxRpc, MsgPack.pack(role:packReward(reward, change))) | 675 | SendPacket(actionCodes.Role_openSpeedUpBoxRpc, MsgPack.pack(role:packReward(reward, change))) |
666 | return true | 676 | return true |
@@ -671,17 +681,18 @@ function _M.storyBookRewardRpc(agent, data) | @@ -671,17 +681,18 @@ function _M.storyBookRewardRpc(agent, data) | ||
671 | local msg = MsgPack.unpack(data) | 681 | local msg = MsgPack.unpack(data) |
672 | local storyId = msg.id | 682 | local storyId = msg.id |
673 | local storyBookData = csvdb["story_bookCsv"][storyId] | 683 | local storyBookData = csvdb["story_bookCsv"][storyId] |
674 | - if not storyBookData then return end | 684 | + if not storyBookData then return 1 end |
675 | local storyStatus = role:getProperty("storyB") | 685 | local storyStatus = role:getProperty("storyB") |
676 | 686 | ||
677 | local status = (storyStatus[storyId] or {}).s | 687 | local status = (storyStatus[storyId] or {}).s |
678 | 688 | ||
679 | - if status == -1 then return end | 689 | + if status == -1 then return 2 end |
680 | 690 | ||
681 | if not status or status ~= 1 then | 691 | if not status or status ~= 1 then |
682 | - if storyBookData.unlockType == 1 and (role:getProperty("hangInfo").carbonId == tonumber(storyBookData.unlockData) or storyId == 1 or storyId == 2) then -- 挂机剧情正在挂机也可以领奖 | 692 | + --if storyBookData.unlockType == 1 and (role:getProperty("hangInfo").carbonId == tonumber(storyBookData.unlockData) or storyId == 1 or storyId == 2) then -- 挂机剧情正在挂机也可以领奖 |
693 | + if storyBookData.unlockType == 1 then -- 挂机剧情正在挂机也可以领奖 | ||
683 | else | 694 | else |
684 | - return | 695 | + return 3 |
685 | end | 696 | end |
686 | end | 697 | end |
687 | -- 获取奖励 | 698 | -- 获取奖励 |
@@ -936,7 +947,7 @@ function _M.chatRpc(agent, data) | @@ -936,7 +947,7 @@ function _M.chatRpc(agent, data) | ||
936 | end | 947 | end |
937 | end | 948 | end |
938 | mcast_util.pub_world(actionCodes.Role_chat, MsgPack.pack(response)) | 949 | mcast_util.pub_world(actionCodes.Role_chat, MsgPack.pack(response)) |
939 | - pcall(skynet.send, '.globald', "lua", "sendWorldMsg", role._channelIdx, response) | 950 | + -- pcall(skynet.send, '.globald', "lua", "sendWorldMsg", role._channelIdx, response) |
940 | role:mylog("role_action", {desc = "chatWorld", text1 = content}) | 951 | role:mylog("role_action", {desc = "chatWorld", text1 = content}) |
941 | end, | 952 | end, |
942 | -- 私聊 | 953 | -- 私聊 |
@@ -1226,7 +1237,7 @@ function _M.useSelectItemRpc(agent, data) | @@ -1226,7 +1237,7 @@ function _M.useSelectItemRpc(agent, data) | ||
1226 | local count = msg.count | 1237 | local count = msg.count |
1227 | if math.illegalNum(count, 1, role:getItemCount(itemId)) then return end | 1238 | if math.illegalNum(count, 1, role:getItemCount(itemId)) then return end |
1228 | local itemData = csvdb["itemCsv"][itemId] | 1239 | local itemData = csvdb["itemCsv"][itemId] |
1229 | - if itemData.type ~= ItemType.SelectItemBox then return end | 1240 | + if not (itemData.type == ItemType.SelectItemBox or itemData.type == ItemType.CommonPaster) then return end |
1230 | local itemMap = itemData.use_effect:toNumMap() | 1241 | local itemMap = itemData.use_effect:toNumMap() |
1231 | local reward, change = {} | 1242 | local reward, change = {} |
1232 | for k, v in pairs(itemMap) do | 1243 | for k, v in pairs(itemMap) do |
src/actions/StoreAction.lua
@@ -3,7 +3,20 @@ local _M = {} | @@ -3,7 +3,20 @@ local _M = {} | ||
3 | local serverId = tonumber(skynet.getenv("servId")) | 3 | local serverId = tonumber(skynet.getenv("servId")) |
4 | local md5 = require "md5" | 4 | local md5 = require "md5" |
5 | 5 | ||
6 | -local function makeOrder(roleId, rechargeId) | 6 | +local function makeOrder(role, rechargeId) |
7 | + local roleId = role:getProperty("id") | ||
8 | + local rechargeData = csvdb["shop_rechargeCsv"][rechargeId] | ||
9 | + if not rechargeData then | ||
10 | + skynet.error("recharge id not exist", rechargeId) | ||
11 | + return "" | ||
12 | + end | ||
13 | + local limit = rechargeData.limit | ||
14 | + local rechargeRecord = role:getProperty("payR") or {} | ||
15 | + if limit ~= 0 and limit <= (rechargeRecord[rechargeId] or 0) then | ||
16 | + skynet.error(string.format("recharge id:%d count over limit, user id:%d", rechargeId, roleId)) | ||
17 | + return "" | ||
18 | + end | ||
19 | + | ||
7 | local orderId = redisproxy:hincrby("autoincrement_set", "order", 1) | 20 | local orderId = redisproxy:hincrby("autoincrement_set", "order", 1) |
8 | local partnerOrderId = string.format("%d_%d_%d", serverId, roleId, orderId) | 21 | local partnerOrderId = string.format("%d_%d_%d", serverId, roleId, orderId) |
9 | local orderKey = string.format("order:%d:%d", roleId, orderId) | 22 | local orderKey = string.format("order:%d:%d", roleId, orderId) |
@@ -29,7 +42,7 @@ function _M.rechargeRpc(agent , data) | @@ -29,7 +42,7 @@ function _M.rechargeRpc(agent , data) | ||
29 | local roleId = role:getProperty("id") | 42 | local roleId = role:getProperty("id") |
30 | 43 | ||
31 | --创建订单号 | 44 | --创建订单号 |
32 | - local partnerOrderId = makeOrder(roleId, id) | 45 | + local partnerOrderId = makeOrder(role, id) |
33 | SendPacket(actionCodes.Store_rechargeRpc, MsgPack.pack({ order = partnerOrderId })) | 46 | SendPacket(actionCodes.Store_rechargeRpc, MsgPack.pack({ order = partnerOrderId })) |
34 | 47 | ||
35 | 48 | ||
@@ -78,7 +91,7 @@ function _M.googleRechargeRpc(agent, data) | @@ -78,7 +91,7 @@ function _M.googleRechargeRpc(agent, data) | ||
78 | 91 | ||
79 | role.ignoreHeartbeat = true | 92 | role.ignoreHeartbeat = true |
80 | --创建订单号 | 93 | --创建订单号 |
81 | - local partnerOrderId = makeOrder(roleId, id) | 94 | + local partnerOrderId = makeOrder(role, id) |
82 | -- 签名 | 95 | -- 签名 |
83 | local secret_key = "b7657fa7ccd44c16a35e3f454ac7a075" | 96 | local secret_key = "b7657fa7ccd44c16a35e3f454ac7a075" |
84 | local need = { | 97 | local need = { |
@@ -105,7 +118,7 @@ function _M.myCardRechargeRpc(agent, data) | @@ -105,7 +118,7 @@ function _M.myCardRechargeRpc(agent, data) | ||
105 | 118 | ||
106 | role.ignoreHeartbeat = true | 119 | role.ignoreHeartbeat = true |
107 | --创建订单号 | 120 | --创建订单号 |
108 | - local partnerOrderId = makeOrder(roleId, id) | 121 | + local partnerOrderId = makeOrder(role, id) |
109 | -- 签名 | 122 | -- 签名 |
110 | local secret_key = "48759e07540f46d9af17ec82669b4272" | 123 | local secret_key = "48759e07540f46d9af17ec82669b4272" |
111 | local need = { | 124 | local need = { |
@@ -131,7 +144,7 @@ function _M.iosRechargeRpc(agent, data) | @@ -131,7 +144,7 @@ function _M.iosRechargeRpc(agent, data) | ||
131 | 144 | ||
132 | role.ignoreHeartbeat = true | 145 | role.ignoreHeartbeat = true |
133 | --创建订单号 | 146 | --创建订单号 |
134 | - local partnerOrderId = makeOrder(roleId, id) | 147 | + local partnerOrderId = makeOrder(role, id) |
135 | -- 签名 | 148 | -- 签名 |
136 | local secret_key = "9647d2efe1074c73b9ac19af4337a70e" | 149 | local secret_key = "9647d2efe1074c73b9ac19af4337a70e" |
137 | local need = { | 150 | local need = { |
src/actions/TowerAction.lua
@@ -62,7 +62,7 @@ function _M.startBattleRpc(agent, data) | @@ -62,7 +62,7 @@ function _M.startBattleRpc(agent, data) | ||
62 | 62 | ||
63 | if not csvdb["tower_battleCsv"][id] then return end | 63 | if not csvdb["tower_battleCsv"][id] then return end |
64 | local curCount, nextTime = getUpdateTime(towerInfo.c, towerInfo.t) | 64 | local curCount, nextTime = getUpdateTime(towerInfo.c, towerInfo.t) |
65 | - if curCount < 1 then return end -- 没有次数返回 | 65 | + --if curCount < 1 then return end -- 没有次数返回 |
66 | 66 | ||
67 | --搞起来 | 67 | --搞起来 |
68 | towerInfo.c = curCount - 1 | 68 | towerInfo.c = curCount - 1 |
@@ -136,10 +136,15 @@ end | @@ -136,10 +136,15 @@ end | ||
136 | 136 | ||
137 | function _M.bugCountRpc(agent, data) | 137 | function _M.bugCountRpc(agent, data) |
138 | local role = agent.role | 138 | local role = agent.role |
139 | + local msg = MsgPack.unpack(data) | ||
140 | + local buyCount = msg.count | ||
139 | 141 | ||
140 | local towerInfo = role:getProperty("towerInfo") | 142 | local towerInfo = role:getProperty("towerInfo") |
141 | local curCount, nextTime = getUpdateTime(towerInfo.c, towerInfo.t) | 143 | local curCount, nextTime = getUpdateTime(towerInfo.c, towerInfo.t) |
142 | local needCount = globalCsv.tower_count_limit - curCount | 144 | local needCount = globalCsv.tower_count_limit - curCount |
145 | + if needCount > buyCount then | ||
146 | + needCount = buyCount | ||
147 | + end | ||
143 | if needCount > 0 then -- 补充 | 148 | if needCount > 0 then -- 补充 |
144 | local cost = globalCsv.tower_chance_item:toNumMap() | 149 | local cost = globalCsv.tower_chance_item:toNumMap() |
145 | for k , v in pairs(cost) do | 150 | for k , v in pairs(cost) do |
@@ -147,7 +152,7 @@ function _M.bugCountRpc(agent, data) | @@ -147,7 +152,7 @@ function _M.bugCountRpc(agent, data) | ||
147 | end | 152 | end |
148 | if not role:checkItemEnough(cost) then return end | 153 | if not role:checkItemEnough(cost) then return end |
149 | role:costItems(cost, {log = {desc = "towerCount"}}) | 154 | role:costItems(cost, {log = {desc = "towerCount"}}) |
150 | - curCount = globalCsv.tower_count_limit | 155 | + curCount = curCount + needCount |
151 | end | 156 | end |
152 | towerInfo.c = curCount | 157 | towerInfo.c = curCount |
153 | towerInfo.t = nextTime | 158 | towerInfo.t = nextTime |
src/adv/Adv.lua
@@ -51,6 +51,7 @@ function Adv:initByInfo(advInfo) | @@ -51,6 +51,7 @@ function Adv:initByInfo(advInfo) | ||
51 | self.cacheUnlock = advInfo.cacheUnlock or {} | 51 | self.cacheUnlock = advInfo.cacheUnlock or {} |
52 | self.shopStatus = advInfo.shopStatus or {} | 52 | self.shopStatus = advInfo.shopStatus or {} |
53 | self.support = advInfo.support or {} | 53 | self.support = advInfo.support or {} |
54 | + self.logid = advInfo.logid or "auto" | ||
54 | 55 | ||
55 | self.maps = {} | 56 | self.maps = {} |
56 | for id, map in ipairs(advInfo.maps or {}) do | 57 | for id, map in ipairs(advInfo.maps or {}) do |
@@ -102,6 +103,7 @@ function Adv:initByChapter(params) | @@ -102,6 +103,7 @@ function Adv:initByChapter(params) | ||
102 | self.shopStatus = self.shopStatus or {} | 103 | self.shopStatus = self.shopStatus or {} |
103 | self.support = self.support or {} | 104 | self.support = self.support or {} |
104 | self.battle = nil -- 清掉 老的 battle | 105 | self.battle = nil -- 清掉 老的 battle |
106 | + self.logid = self.owner:getActionUcode() | ||
105 | 107 | ||
106 | if isEnter then -- 把 支援效果初始化为易用用的形式 | 108 | if isEnter then -- 把 支援效果初始化为易用用的形式 |
107 | self:initSupport(support or {}) | 109 | self:initSupport(support or {}) |
@@ -206,6 +208,7 @@ function Adv:saveDB(notNotify) | @@ -206,6 +208,7 @@ function Adv:saveDB(notNotify) | ||
206 | advInfo.cacheUnlock = self.cacheUnlock | 208 | advInfo.cacheUnlock = self.cacheUnlock |
207 | advInfo.shopStatus = self.shopStatus | 209 | advInfo.shopStatus = self.shopStatus |
208 | advInfo.support = self.support | 210 | advInfo.support = self.support |
211 | + advInfo.logid = self.logid | ||
209 | advInfo.maps = {} | 212 | advInfo.maps = {} |
210 | 213 | ||
211 | self.battle:saveDB() | 214 | self.battle:saveDB() |
@@ -610,6 +613,15 @@ function Adv:wearArtifact(slot, id) | @@ -610,6 +613,15 @@ function Adv:wearArtifact(slot, id) | ||
610 | id = nil | 613 | id = nil |
611 | end | 614 | end |
612 | self:mylog({desc = "wearArtifact", int1 = id}) | 615 | self:mylog({desc = "wearArtifact", int1 = id}) |
616 | + self.owner:log("mission_pick_equip", { | ||
617 | + mission_threadid = self.chapterId, -- 大地图ID | ||
618 | + mission_threadname = (csvdb["adv_chapterCsv"][self.chapterId] or {})["chapter"] or "auto", -- 大地图名称 | ||
619 | + mission_id = self.level, -- 关卡ID | ||
620 | + mission_pick_equip_type = 1, --神器操作类型:1:装备,2:卸下 | ||
621 | + mission_pick_equip_id = id, --神器ID | ||
622 | + mission_pick_equip_lv = advAFGet[id], --神器等级 | ||
623 | + mission_sequenceid = self.logid, -- 本次拾荒ID,用于关联一次拾荒产生多条不同类型的日志 | ||
624 | + }) | ||
613 | 625 | ||
614 | self.owner:changeUpdates({{type = "advAFWear", field = slot, value = id}}) | 626 | self.owner:changeUpdates({{type = "advAFWear", field = slot, value = id}}) |
615 | return true | 627 | return true |
@@ -670,7 +682,6 @@ function Adv:artifactLevelUp(id, level) | @@ -670,7 +682,6 @@ function Adv:artifactLevelUp(id, level) | ||
670 | 682 | ||
671 | self:mylog({desc = "artifactLevelUp", int1 = id, int2 = level}) | 683 | self:mylog({desc = "artifactLevelUp", int1 = id, int2 = level}) |
672 | 684 | ||
673 | - | ||
674 | local status = 0 | 685 | local status = 0 |
675 | if curWear[id] then -- 穿着呢 | 686 | if curWear[id] then -- 穿着呢 |
676 | local oldData = csvdb["adv_artifactCsv"][id][advAFGet[id]] | 687 | local oldData = csvdb["adv_artifactCsv"][id][advAFGet[id]] |
@@ -815,6 +826,49 @@ function Adv:over(success, rewardRatio, overType) | @@ -815,6 +826,49 @@ function Adv:over(success, rewardRatio, overType) | ||
815 | 826 | ||
816 | self:mylog({desc = "over", short1 = success and 1 or 0, int1 = overType}) | 827 | self:mylog({desc = "over", short1 = success and 1 or 0, int1 = overType}) |
817 | 828 | ||
829 | + | ||
830 | + local team = self.owner:getProperty("advTeam") | ||
831 | + local player = {} | ||
832 | + local attrs = self.owner:getTeamBattleInfo(team).heros | ||
833 | + for attrName, _ in pairs(AdvAttsEnum) do | ||
834 | + for _, hero in pairs(attrs) do | ||
835 | + player[attrName] = (player[attrName] or 0) + hero[attrName] | ||
836 | + end | ||
837 | + player[attrName] = player[attrName] * (globalCsv.adv_battle_attr_ratio[attrName] or 1) | ||
838 | + end | ||
839 | + | ||
840 | + local battleV = 1 * player["hp"] | ||
841 | + + 2 * player["atk"] | ||
842 | + + 1.25 * player["def"] | ||
843 | + + 0.226 * player["hit"] | ||
844 | + + 0.26 * player["miss"] | ||
845 | + | ||
846 | + local heroList = {team.leader, team.leader2} | ||
847 | + for _, hid in pairs(team.heros) do | ||
848 | + if hid ~= team.leader and hid ~= team.leader2 then | ||
849 | + heroList[#heroList + 1] = hid | ||
850 | + end | ||
851 | + end | ||
852 | + | ||
853 | + self.owner:log("mission_pick", { | ||
854 | + mission_threadid = self.chapterId, -- 大地图ID | ||
855 | + mission_threadname = (csvdb["adv_chapterCsv"][self.chapterId] or {})["chapter"] or "auto", -- 大地图名称 | ||
856 | + mission_id = self.level, -- 关卡ID | ||
857 | + mission_herolist = heroList, -- 英雄ID列表,[111, 222, 333, 444, 555] 前两个为队长、副队长 | ||
858 | + mission_heroscore = battleV, -- 编队总评分 | ||
859 | + mission_teamlv = 0, -- 编队等级 | ||
860 | + mission_recscore = csvdb["adv_chapter_campsiteCsv"][self.chapterId][1].recommendValue, -- 关卡推荐评分 | ||
861 | + mission_floor_bef = 0, -- 进入前关卡层数 | ||
862 | + mission_floor_aft = self.level, -- 结束时关卡层数 | ||
863 | + mission_team_status = {HP = team.player.hp, SP = team.player.sp}, -- 队伍状态,{"HP":100, "SP":100, "curse":7} | ||
864 | + mission_result = success and 1 or (team.player.hp > 0 and 3 or 2), -- 战斗结果(0-无效,1-胜利,2-血量耗尽退出,3,主动退出) | ||
865 | + mission_reward = reward, -- 获得奖励,[{"id":101,"num":10},{"id":102,"num":20},{"id":103,"num":30}] | ||
866 | + mission_integral_bef = 0, -- 进入前积分 | ||
867 | + mission_integral_aft = score, -- 完成后积分 | ||
868 | + mission_cleartype = 1, -- 1正常通关;2代理拾荒 | ||
869 | + mission_sequenceid = self.logid, -- 本次拾荒ID,用于关联一次拾荒产生多条不同类型的日志 | ||
870 | + }) | ||
871 | + | ||
818 | local chapterId = self.chapterId | 872 | local chapterId = self.chapterId |
819 | self:clear() | 873 | self:clear() |
820 | self.owner:checkTaskEnter("AdvScore", {score = score}) | 874 | self.owner:checkTaskEnter("AdvScore", {score = score}) |
src/adv/AdvBattle.lua
@@ -76,6 +76,7 @@ function Battle:initPlayer() | @@ -76,6 +76,7 @@ function Battle:initPlayer() | ||
76 | end | 76 | end |
77 | player.exp = 0 | 77 | player.exp = 0 |
78 | player.sp = getAdvLvAttrUp(advAddAttrs, "sp", 100) | 78 | player.sp = getAdvLvAttrUp(advAddAttrs, "sp", 100) |
79 | + player.spMax = player.sp | ||
79 | player.growth = {} | 80 | player.growth = {} |
80 | player.passives = {} | 81 | player.passives = {} |
81 | 82 |
src/adv/AdvBuff.lua
@@ -576,6 +576,9 @@ end | @@ -576,6 +576,9 @@ end | ||
576 | 576 | ||
577 | function Buff:effect() | 577 | function Buff:effect() |
578 | self:decCount() | 578 | self:decCount() |
579 | + if self.buffData.show:sismember(2, " ") then | ||
580 | + self.owner.battle.adv:pushBackEvent(AdvBackEventType.BuffEffect, {etype = 2}) | ||
581 | + end | ||
579 | if self._effectValue then | 582 | if self._effectValue then |
580 | return self:_effectValue() | 583 | return self:_effectValue() |
581 | end | 584 | end |
src/adv/AdvPassive.lua
@@ -120,7 +120,7 @@ Passive.GET_BUFF = 28 --获得指定buff | @@ -120,7 +120,7 @@ Passive.GET_BUFF = 28 --获得指定buff | ||
120 | Passive.OPEN_BLOCK = 29 --翻开格子 | 120 | Passive.OPEN_BLOCK = 29 --翻开格子 |
121 | Passive.OPEN_MONSTER = 30 --翻开怪物 | 121 | Passive.OPEN_MONSTER = 30 --翻开怪物 |
122 | Passive.PLAYER_BUFF = 31 --玩家获得buff | 122 | Passive.PLAYER_BUFF = 31 --玩家获得buff |
123 | - | 123 | +Passive.PLAYER_BUFF_CLASSIFY = 35 -- 获得指定标签的buff |
124 | 124 | ||
125 | -- 不同的开启条件 | 125 | -- 不同的开启条件 |
126 | local PassiveCondFactory = {} | 126 | local PassiveCondFactory = {} |
@@ -183,6 +183,14 @@ PassiveCondFactory[Passive.GET_BUFF] = function(_Passive) | @@ -183,6 +183,14 @@ PassiveCondFactory[Passive.GET_BUFF] = function(_Passive) | ||
183 | end | 183 | end |
184 | PassiveCondFactory[Passive.PLAYER_BUFF] = PassiveCondFactory[Passive.GET_BUFF] | 184 | PassiveCondFactory[Passive.PLAYER_BUFF] = PassiveCondFactory[Passive.GET_BUFF] |
185 | 185 | ||
186 | +PassiveCondFactory[Passive.PLAYER_BUFF_CLASSIFY] = function(_Passive) | ||
187 | + _Passive._trigger = function(self, params) | ||
188 | + if params.classify:sismember(self.passiveData.value) then | ||
189 | + return true | ||
190 | + end | ||
191 | + end | ||
192 | +end | ||
193 | + | ||
186 | 194 | ||
187 | PassiveCondFactory[Passive.BORN_ONCE] = function(_Passive) | 195 | PassiveCondFactory[Passive.BORN_ONCE] = function(_Passive) |
188 | _Passive._afterRound = function(self) | 196 | _Passive._afterRound = function(self) |
src/adv/AdvPlayer.lua
@@ -163,7 +163,8 @@ function BaseObject:addBuff(buffId, releaser) | @@ -163,7 +163,8 @@ function BaseObject:addBuff(buffId, releaser) | ||
163 | table.insert(self.buffs, buff) | 163 | table.insert(self.buffs, buff) |
164 | buff:createAfter() | 164 | buff:createAfter() |
165 | end | 165 | end |
166 | - self:triggerPassive(Passive.GET_BUFF, {buffId = buffId}) | 166 | + self:triggerPassive(Passive.GET_BUFF, {trigger = releaser, buffId = buffId}) |
167 | + self:triggerPassive(Passive.PLAYER_BUFF_CLASSIFY, {trigger = releaser, classify = buffData.classify}) | ||
167 | return true | 168 | return true |
168 | end | 169 | end |
169 | 170 | ||
@@ -670,7 +671,7 @@ function Player:effectBattleBuff() | @@ -670,7 +671,7 @@ function Player:effectBattleBuff() | ||
670 | for _, buff in ipairs(self.buffs) do | 671 | for _, buff in ipairs(self.buffs) do |
671 | if not buff:isHide() and (buff:getType() == Buff.BATTLE_BUFF or buff:getType() == Buff.BATTLE_PASSIVE) then | 672 | if not buff:isHide() and (buff:getType() == Buff.BATTLE_BUFF or buff:getType() == Buff.BATTLE_PASSIVE) then |
672 | buff:effect() | 673 | buff:effect() |
673 | - if not buff.buffData.classify:sismember(7, " ") then -- 神器buff 不会清除 | 674 | + if not buff.buffData.classify:sismember(7, " ") and not buff.buffData.classify:sismember(8, " ") then -- 神器buff 不会清除 队长技 |
674 | buff:uncover() | 675 | buff:uncover() |
675 | end | 676 | end |
676 | end | 677 | end |
@@ -699,6 +700,10 @@ function Player:addBuff(buffId, releaser) | @@ -699,6 +700,10 @@ function Player:addBuff(buffId, releaser) | ||
699 | self.battle.adv:checkAchievement(self.battle.adv.AchievType.GetBuff, 1, buffId) | 700 | self.battle.adv:checkAchievement(self.battle.adv.AchievType.GetBuff, 1, buffId) |
700 | self.battle.adv:pushBackEvent(AdvBackEventType.Buff, {buffId = buffId}) | 701 | self.battle.adv:pushBackEvent(AdvBackEventType.Buff, {buffId = buffId}) |
701 | self.battle:triggerPassive(Passive.PLAYER_BUFF, {buffId = buffId}) | 702 | self.battle:triggerPassive(Passive.PLAYER_BUFF, {buffId = buffId}) |
703 | + local buffData = csvdb["adv_map_buffCsv"][buffId] | ||
704 | + if buffData and buffData.show:sismember(1, " ") then | ||
705 | + self.battle.adv:pushBackEvent(AdvBackEventType.BuffEffect, {etype = 1}) | ||
706 | + end | ||
702 | end | 707 | end |
703 | return status | 708 | return status |
704 | end | 709 | end |
src/agent.lua
@@ -29,12 +29,6 @@ _codeSession = {} | @@ -29,12 +29,6 @@ _codeSession = {} | ||
29 | --- {{{ 定时器相关 | 29 | --- {{{ 定时器相关 |
30 | local function handle_timeout() | 30 | local function handle_timeout() |
31 | if not agentInfo.open_timer then return end | 31 | if not agentInfo.open_timer then return end |
32 | - | ||
33 | - if not agentInfo.role then | ||
34 | - skynet.timeout(100, handle_timeout) | ||
35 | - return | ||
36 | - end | ||
37 | - | ||
38 | agent_util:update(agentInfo) | 32 | agent_util:update(agentInfo) |
39 | skynet.timeout(100, handle_timeout) | 33 | skynet.timeout(100, handle_timeout) |
40 | end | 34 | end |
@@ -274,6 +268,8 @@ function CMD.start(session, source, gate, fd, ip, hotfixs) | @@ -274,6 +268,8 @@ function CMD.start(session, source, gate, fd, ip, hotfixs) | ||
274 | end | 268 | end |
275 | end | 269 | end |
276 | 270 | ||
271 | + start_agent_timer() | ||
272 | + | ||
277 | -- 这里将消息伪装成 watchdog 发出,这样就由 A->B->C->B->A 变成 A->B->C->A | 273 | -- 这里将消息伪装成 watchdog 发出,这样就由 A->B->C->B->A 变成 A->B->C->A |
278 | skynet.redirect(gate, source, "lua", session, skynet.pack("forward", fd, 0, skynet.self())) | 274 | skynet.redirect(gate, source, "lua", session, skynet.pack("forward", fd, 0, skynet.self())) |
279 | end | 275 | end |
src/main.lua
1 | local skynet = require "skynet" | 1 | local skynet = require "skynet" |
2 | 2 | ||
3 | local max_client = tonumber(skynet.getenv("max_client")) | 3 | local max_client = tonumber(skynet.getenv("max_client")) |
4 | +local max_queue = tonumber(skynet.getenv("max_queue")) | ||
4 | 5 | ||
5 | skynet.start(function() | 6 | skynet.start(function() |
6 | print("Server start") | 7 | print("Server start") |
@@ -11,7 +12,7 @@ skynet.start(function() | @@ -11,7 +12,7 @@ skynet.start(function() | ||
11 | 12 | ||
12 | skynet.call(watchdog, "lua", "start", { | 13 | skynet.call(watchdog, "lua", "start", { |
13 | port = tonumber(skynet.getenv("server_port")), | 14 | port = tonumber(skynet.getenv("server_port")), |
14 | - maxclient = max_client, | 15 | + maxclient = max_client + max_queue + 10, |
15 | httpd = httpd, | 16 | httpd = httpd, |
16 | 17 | ||
17 | redishost = skynet.getenv("redis_host"), | 18 | redishost = skynet.getenv("redis_host"), |
src/models/Activity.lua
@@ -18,6 +18,7 @@ Activity.ActivityType = { | @@ -18,6 +18,7 @@ Activity.ActivityType = { | ||
18 | DrawHero = 12, --抽卡周 招募 | 18 | DrawHero = 12, --抽卡周 招募 |
19 | AdvDraw = 13, --拾荒抽周 资助 | 19 | AdvDraw = 13, --拾荒抽周 资助 |
20 | OpenBox = 14, --拆解周 时钟箱 | 20 | OpenBox = 14, --拆解周 时钟箱 |
21 | + RaceDraw = 16, -- 定向招募活动 | ||
21 | } | 22 | } |
22 | 23 | ||
23 | 24 | ||
@@ -344,8 +345,18 @@ activityFunc[Activity.ActivityType.PaySignIn] = { | @@ -344,8 +345,18 @@ activityFunc[Activity.ActivityType.PaySignIn] = { | ||
344 | ["init"] = function(self, actType, isCrossDay, notify) | 345 | ["init"] = function(self, actType, isCrossDay, notify) |
345 | self:updateActData(actType, {}, not notify) | 346 | self:updateActData(actType, {}, not notify) |
346 | end, | 347 | end, |
347 | - -- ["close"] = function(self, actType, notify) | ||
348 | - -- end, | 348 | + ["close"] = function(self, actType, notify) |
349 | + self.owner.storeData:SetActGoodsFlag("paySignIn", 0) | ||
350 | + | ||
351 | + local rechargeRecord = self.owner.storeData:getProperty("payR") | ||
352 | + for id, cfg in pairs(csvdb["shop_rechargeCsv"]) do | ||
353 | + if cfg.shop == 2 and cfg.type == CardType.PaySignCard then | ||
354 | + rechargeRecord[id] = nil | ||
355 | + break | ||
356 | + end | ||
357 | + end | ||
358 | + self.owner.storeData:updateProperty({field="payR", value=rechargeRecord}) | ||
359 | + end, | ||
349 | } | 360 | } |
350 | 361 | ||
351 | -- 充值反馈 | 362 | -- 充值反馈 |
@@ -367,6 +378,37 @@ activityFunc[Activity.ActivityType.PayBack] = { | @@ -367,6 +378,37 @@ activityFunc[Activity.ActivityType.PayBack] = { | ||
367 | -- end, | 378 | -- end, |
368 | } | 379 | } |
369 | 380 | ||
381 | +-- 英雄帖 | ||
382 | +activityFunc[Activity.ActivityType.CalendaTask] = { | ||
383 | + ["init"] = function(self, actType, isCrossDay, notify) | ||
384 | + local calTask = self.owner:getProperty("CalTask") | ||
385 | + calTask = {} | ||
386 | + local role = self.owner | ||
387 | + local buildL = role.dinerData:getProperty("buildL") | ||
388 | + local curLevel = buildL:getv(1, 1) | ||
389 | + role:checkTaskEnter("DinerLevelUp", {level = curLevel}) | ||
390 | + | ||
391 | + role:checkTaskEnter("HeroLvlCollect", {}) | ||
392 | + role:checkTaskEnter("HeroQualityCollect", {}) | ||
393 | + | ||
394 | + local curPopular = role.dinerData:getProperty("popular") | ||
395 | + role:checkTaskEnter("DinerPopular", {count = curPopular}) | ||
396 | + | ||
397 | + local rLevel = role:getProperty("level") | ||
398 | + role:checkTaskEnter("RoleLevelUp", {level = rLevel}) | ||
399 | + | ||
400 | + local towerInfo = role:getProperty("towerInfo") | ||
401 | + role:checkTaskEnter("TowerPass", {level = towerInfo.l}) | ||
402 | + --"PvpWin" | ||
403 | + role:checkTaskEnter("HangPass", {}) | ||
404 | + role:checkTaskEnter("HeroStarCollect", {}) | ||
405 | + role:checkTaskEnter("RuneQualityCollect", {}) | ||
406 | + | ||
407 | + end, | ||
408 | + -- ["close"] = function(self, actType, notify) | ||
409 | + -- end, | ||
410 | +} | ||
411 | + | ||
370 | function Activity:initActivity(actId, isCrossDay, notify) | 412 | function Activity:initActivity(actId, isCrossDay, notify) |
371 | local actData = csvdb["activity_ctrlCsv"][actId] | 413 | local actData = csvdb["activity_ctrlCsv"][actId] |
372 | if not actData then return end | 414 | if not actData then return end |
src/models/Diner.lua
@@ -298,6 +298,9 @@ function Diner:expediteSell(slot) | @@ -298,6 +298,9 @@ function Diner:expediteSell(slot) | ||
298 | self:checkDinerTask(DinerTask.SellDishType, expediteCount, math.ceil(sell.dish / 100)) | 298 | self:checkDinerTask(DinerTask.SellDishType, expediteCount, math.ceil(sell.dish / 100)) |
299 | self:checkDinerTask(DinerTask.SellDishRare, expediteCount, dishData.rarity) | 299 | self:checkDinerTask(DinerTask.SellDishRare, expediteCount, dishData.rarity) |
300 | self.owner:checkTaskEnter("FoodSell", {count = expediteCount}) | 300 | self.owner:checkTaskEnter("FoodSell", {count = expediteCount}) |
301 | + | ||
302 | + local needTime = sells[slot].count * dishData.sell_time + sells[slot].time - skynet.timex() | ||
303 | + self.owner:pushMsg({type = "food", slot = slot, time = needTime}) | ||
301 | end | 304 | end |
302 | return { | 305 | return { |
303 | expediteCount = expediteCount, | 306 | expediteCount = expediteCount, |
src/models/Hero.lua
@@ -109,4 +109,8 @@ function Hero:getCamp() | @@ -109,4 +109,8 @@ function Hero:getCamp() | ||
109 | return csvdb["unitCsv"][self:getProperty("type")].camp | 109 | return csvdb["unitCsv"][self:getProperty("type")].camp |
110 | end | 110 | end |
111 | 111 | ||
112 | +function Hero:getRare() | ||
113 | + return csvdb["unitCsv"][self:getProperty("type")].rare | ||
114 | +end | ||
115 | + | ||
112 | return Hero | 116 | return Hero |
113 | \ No newline at end of file | 117 | \ No newline at end of file |
src/models/Role.lua
@@ -27,6 +27,7 @@ function Role:ctor( properties ) | @@ -27,6 +27,7 @@ function Role:ctor( properties ) | ||
27 | self.runeBag = {} | 27 | self.runeBag = {} |
28 | self.advData = nil | 28 | self.advData = nil |
29 | self.activity = nil | 29 | self.activity = nil |
30 | + self._pushToken = nil | ||
30 | self.advElChapter = tonum(redisproxy:hget("adv_season", "chapter"), globalCsv.adv_endless_default_chapter) -- 无尽模式记录的赛季对应章节 | 31 | self.advElChapter = tonum(redisproxy:hget("adv_season", "chapter"), globalCsv.adv_endless_default_chapter) -- 无尽模式记录的赛季对应章节 |
31 | self.advOverTime = tonum(redisproxy:hget("adv_season", "overTime")) -- 无尽模式关闭时间戳 | 32 | self.advOverTime = tonum(redisproxy:hget("adv_season", "overTime")) -- 无尽模式关闭时间戳 |
32 | if self.advOverTime == 0 then | 33 | if self.advOverTime == 0 then |
@@ -111,6 +112,7 @@ Role.schema = { | @@ -111,6 +112,7 @@ Role.schema = { | ||
111 | hangBag = {"table", {}}, -- 背包 | 112 | hangBag = {"table", {}}, -- 背包 |
112 | hangBagLimit = {"number", globalCsv.idle_field_origin}, --背包上限 | 113 | hangBagLimit = {"number", globalCsv.idle_field_origin}, --背包上限 |
113 | bTeam = {"table", {}}, -- 奖励副本队伍 | 114 | bTeam = {"table", {}}, -- 奖励副本队伍 |
115 | + heroFormate = {"table", {}}, -- 自选编队 {adv={}, hang={}} | ||
114 | 116 | ||
115 | --引导相关 | 117 | --引导相关 |
116 | newerGuide = {"string","1=1"}, -- 新手引导 master=slave | 118 | newerGuide = {"string","1=1"}, -- 新手引导 master=slave |
@@ -161,6 +163,7 @@ Role.schema = { | @@ -161,6 +163,7 @@ Role.schema = { | ||
161 | emailSync = {"number", 0}, -- 已经同步到的邮件Id | 163 | emailSync = {"number", 0}, -- 已经同步到的邮件Id |
162 | 164 | ||
163 | repayHero = {"number", 0}, -- 招募次数 (除去友情招募) | 165 | repayHero = {"number", 0}, -- 招募次数 (除去友情招募) |
166 | + repayMaxC = {"number", 0}, -- 招募保底英雄领取次数 100一次 | ||
164 | floorHero = {"table", {}}, -- 招募保底 -- {[poolId] = count} | 167 | floorHero = {"table", {}}, -- 招募保底 -- {[poolId] = count} |
165 | ssrUp = {"table", {}}, -- ssr up -- {[poolId] = count} | 168 | ssrUp = {"table", {}}, -- ssr up -- {[poolId] = count} |
166 | newerDraw = {"table", {}}, -- 新手池子 {N, 1} 抽了多少次, 是否出了ssr | 169 | newerDraw = {"table", {}}, -- 新手池子 {N, 1} 抽了多少次, 是否出了ssr |
@@ -174,6 +177,8 @@ Role.schema = { | @@ -174,6 +177,8 @@ Role.schema = { | ||
174 | 177 | ||
175 | downCvR = {"number", 0}, -- 下载cv扩展包奖励 | 178 | downCvR = {"number", 0}, -- 下载cv扩展包奖励 |
176 | feedback = {"table", {}}, -- 反馈相关信息 {flag = false, count = 0} flag是否评论过,count 提示次数 | 179 | feedback = {"table", {}}, -- 反馈相关信息 {flag = false, count = 0} flag是否评论过,count 提示次数 |
180 | + | ||
181 | + calTask = {"table", {}}, -- 英雄令活动 日历任务活动 | ||
177 | } | 182 | } |
178 | 183 | ||
179 | 184 | ||
@@ -395,6 +400,7 @@ function Role:data() | @@ -395,6 +400,7 @@ function Role:data() | ||
395 | downCvR = self:getProperty("downCvR"), -- 下载cv扩展包奖励 | 400 | downCvR = self:getProperty("downCvR"), -- 下载cv扩展包奖励 |
396 | feedback = self:getProperty("feedback"), | 401 | feedback = self:getProperty("feedback"), |
397 | ctime = self:getProperty("ctime"), | 402 | ctime = self:getProperty("ctime"), |
403 | + calTask = self:getProperty("calTask"), | ||
398 | } | 404 | } |
399 | end | 405 | end |
400 | 406 |
src/models/RoleCross.lua
@@ -287,7 +287,7 @@ end | @@ -287,7 +287,7 @@ end | ||
287 | 287 | ||
288 | function CMD.friendBattleInfo(roleId) | 288 | function CMD.friendBattleInfo(roleId) |
289 | local info = CMD.getProperties(roleId, {"pvpTBC", "hangTB"}) | 289 | local info = CMD.getProperties(roleId, {"pvpTBC", "hangTB"}) |
290 | - return next(info.pvpTBC) and info.pvpTBC or info.hangTB | 290 | + return (next(info.pvpTBC) and next(info.pvpTBC.heros)) and info.pvpTBC or info.hangTB |
291 | end | 291 | end |
292 | 292 | ||
293 | function CMD.pvpCInfo(roleId) | 293 | function CMD.pvpCInfo(roleId) |
src/models/RoleLog.lua
@@ -81,6 +81,7 @@ local ItemReason = { | @@ -81,6 +81,7 @@ local ItemReason = { | ||
81 | birth = 1006, -- 出生奖励 | 81 | birth = 1006, -- 出生奖励 |
82 | actSign = 1007, -- 活动签到 | 82 | actSign = 1007, -- 活动签到 |
83 | actPaySign = 1008, -- 活动付费签到 | 83 | actPaySign = 1008, -- 活动付费签到 |
84 | + calendaTask = 1009, -- 英雄帖 | ||
84 | 85 | ||
85 | -- 餐厅 | 86 | -- 餐厅 |
86 | greenHourse = 1101, -- 食材获得 | 87 | greenHourse = 1101, -- 食材获得 |
@@ -421,6 +422,79 @@ local MethodType = { | @@ -421,6 +422,79 @@ local MethodType = { | ||
421 | gift_name = true, -- 礼包名称 | 422 | gift_name = true, -- 礼包名称 |
422 | gift_reason = true, -- 礼包发放原因,见发放原因枚举表 | 423 | gift_reason = true, -- 礼包发放原因,见发放原因枚举表 |
423 | }, | 424 | }, |
425 | + | ||
426 | + push_gift = { -- 礼包推送 | ||
427 | + gift_id = true, --礼包ID | ||
428 | + gift_name = true, --礼包名称 | ||
429 | + }, | ||
430 | + | ||
431 | + mission_pick = { --拾荒玩法 | ||
432 | + mission_threadid = true, -- 大地图ID | ||
433 | + mission_threadname = true, -- 大地图名称 | ||
434 | + mission_id = true, -- 关卡ID | ||
435 | + mission_herolist = "json", -- 英雄ID列表,[111, 222, 333, 444, 555] 前两个为队长、副队长 | ||
436 | + mission_heroscore = true, -- 编队总评分 | ||
437 | + mission_teamlv = true, -- 编队等级 | ||
438 | + mission_recscore = true, -- 关卡推荐评分 | ||
439 | + mission_floor_bef = true, -- 进入前关卡层数 | ||
440 | + mission_floor_aft = true, -- 结束时关卡层数 | ||
441 | + mission_team_status = "json", -- 队伍状态,{"HP":100, "SP":100, "curse":7} | ||
442 | + mission_result = true, -- 战斗结果(0-无效,1-胜利,2-血量耗尽退出,3,主动退出) | ||
443 | + mission_reward = "json", -- 获得奖励,[{"id":101,"num":10},{"id":102,"num":20},{"id":103,"num":30}] | ||
444 | + mission_integral_bef = true, -- 进入前积分 | ||
445 | + mission_integral_aft = true, -- 完成后积分 | ||
446 | + mission_cleartype = true, -- 1正常通关;2代理拾荒 | ||
447 | + mission_sequenceid = true, -- 本次拾荒ID,用于关联一次拾荒产生多条不同类型的日志 | ||
448 | + }, | ||
449 | + | ||
450 | + mission_pick_achiev = { --拾荒任务 | ||
451 | + mission_threadid = true, -- 大地图ID | ||
452 | + mission_threadname = true, -- 大地图名称 | ||
453 | + mission_id = true, -- 关卡ID | ||
454 | + mission_pick_achiev_id = true, -- 任务ID | ||
455 | + mission_pick_achiev_reward = "json", -- 任务奖励,[{"id":101,"num":10},{"id":102,"num":20},{"id":103,"num":30}] | ||
456 | + mission_sequenceid = true, -- 本次拾荒ID,用于关联一次拾荒产生多条不同类型的日志 | ||
457 | + }, | ||
458 | + | ||
459 | + mission_pick_equip = { -- 拾荒神器装备 | ||
460 | + mission_threadid = true, --大地图ID | ||
461 | + mission_threadname = true, --大地图名称 | ||
462 | + mission_id = true, --关卡ID | ||
463 | + mission_pick_equip_type = true, --神器操作类型:1:装备,2:卸下 | ||
464 | + mission_pick_equip_id = true, --神器ID | ||
465 | + mission_pick_equip_lv = true, --神器等级 | ||
466 | + mission_sequenceid = true, --本次拾荒ID,用于关联一次拾荒产生多条不同类型的日志 | ||
467 | + }, | ||
468 | + | ||
469 | + mission_pick_reform = { --拾荒神器升级 | ||
470 | + mission_threadid = true, -- 大地图ID | ||
471 | + mission_threadname = true, -- 大地图名称 | ||
472 | + mission_id = true, -- 关卡ID | ||
473 | + mission_pick_equip_id = true, -- 神器ID | ||
474 | + mission_pick_reform_beflv = true, -- 神器原等级 | ||
475 | + mission_pick_reform_aftlv = true, -- 神器现等级 | ||
476 | + mission_pick_reform_cost = true, -- 消耗探险点数 | ||
477 | + mission_sequenceid = true, -- 本次拾荒ID,用于关联一次拾荒产生多条不同类型的日志 | ||
478 | + }, | ||
479 | + | ||
480 | + mission_pick_use = { --拾荒任务道具使用 | ||
481 | + mission_threadid = true, -- 大地图ID | ||
482 | + mission_threadname = true, -- 大地图名称 | ||
483 | + mission_id = true, -- 关卡ID | ||
484 | + item_id = true, -- 道具ID | ||
485 | + mission_pick_use_num = true, -- 道具使用量 | ||
486 | + mission_sequenceid = true, -- 本次拾荒ID,用于关联一次拾荒产生多条不同类型的日志 | ||
487 | + }, | ||
488 | + | ||
489 | + mission_pick_fund = { --拾荒资助 | ||
490 | + item_id = true, -- 资助花费道具ID | ||
491 | + mission_pick_fund_amount = true, -- 资助花费道具数量 | ||
492 | + mission_pick_fund_cnt = true, -- 资助花费道具次数,1或者10 | ||
493 | + mission_pick_fund_reward = "json", -- 资助获得奖励,[{"id":100,"num":10},{"id":101,"num":20},{"id":102,"num":30}] | ||
494 | + mission_pick_fund_stagereward = "json", -- 资助阶段奖励 | ||
495 | + mission_pick_fund_beflv = true, -- 资助前资助等级 | ||
496 | + mission_pick_fund_aftlv = true, -- 资助后资助等级 | ||
497 | + }, | ||
424 | } | 498 | } |
425 | 499 | ||
426 | local function printError(info) | 500 | local function printError(info) |
src/models/RolePlugin.lua
@@ -452,7 +452,12 @@ function RolePlugin.bind(Role) | @@ -452,7 +452,12 @@ function RolePlugin.bind(Role) | ||
452 | newHero.owner = self | 452 | newHero.owner = self |
453 | newHero:saveBattleValue() | 453 | newHero:saveBattleValue() |
454 | self.heros[heroId] = newHero | 454 | self.heros[heroId] = newHero |
455 | - self:checkTaskEnter("AddHero", {heroType = heroType, wakeL = newHero:getProperty("wakeL"), camp = unitData.camp, job = unitData.job}, params.notNotify) | 455 | + local ssrCount = 0 |
456 | + if unitData.rare == HeroQuality.SSR then | ||
457 | + ssrCount = self:getSSRHeroCount() | ||
458 | + end | ||
459 | + self:checkTaskEnter("AddHero", {heroType = heroType, wakeL = newHero:getProperty("wakeL"), camp = unitData.camp, job = unitData.job, ssrCount = ssrCount}, params.notNotify) | ||
460 | + self:checkTaskEnter("HeroQualityCollect", {}) | ||
456 | if not params.notNotify then | 461 | if not params.notNotify then |
457 | local heroResponse = {} | 462 | local heroResponse = {} |
458 | table.insert(heroResponse, newHero:data()) | 463 | table.insert(heroResponse, newHero:data()) |
@@ -485,6 +490,16 @@ function RolePlugin.bind(Role) | @@ -485,6 +490,16 @@ function RolePlugin.bind(Role) | ||
485 | end | 490 | end |
486 | end | 491 | end |
487 | 492 | ||
493 | + function Role:getSSRHeroCount() | ||
494 | + local count = 0 | ||
495 | + for _, hero in pairs(self.heros) do | ||
496 | + if hero:getRare() == HeroQuality.SSR then | ||
497 | + count = count + 1 | ||
498 | + end | ||
499 | + end | ||
500 | + return count | ||
501 | + end | ||
502 | + | ||
488 | 503 | ||
489 | function Role:loadHeros() | 504 | function Role:loadHeros() |
490 | local roleId = self:getProperty("id") | 505 | local roleId = self:getProperty("id") |
@@ -1174,6 +1189,7 @@ function RolePlugin.bind(Role) | @@ -1174,6 +1189,7 @@ function RolePlugin.bind(Role) | ||
1174 | function Role:addAdvLvExp(exp) | 1189 | function Role:addAdvLvExp(exp) |
1175 | local advL = self:getProperty("advL") | 1190 | local advL = self:getProperty("advL") |
1176 | local level = advL[1] | 1191 | local level = advL[1] |
1192 | + local oldLevel = level | ||
1177 | local newExp = (advL[2] or 0) + exp | 1193 | local newExp = (advL[2] or 0) + exp |
1178 | 1194 | ||
1179 | if not csvdb["adv_level_fundCsv"][level + 1] then | 1195 | if not csvdb["adv_level_fundCsv"][level + 1] then |
@@ -1181,7 +1197,8 @@ function RolePlugin.bind(Role) | @@ -1181,7 +1197,8 @@ function RolePlugin.bind(Role) | ||
1181 | end | 1197 | end |
1182 | 1198 | ||
1183 | while newExp >= csvdb["adv_level_fundCsv"][level].exp do | 1199 | while newExp >= csvdb["adv_level_fundCsv"][level].exp do |
1184 | - if csvdb["adv_level_fundCsv"][level + 1] and self:advChapterIsOpen(100 + csvdb["adv_level_fundCsv"][level + 1].chapter) then -- 有下一级 | 1200 | + --if csvdb["adv_level_fundCsv"][level + 1] and self:advChapterIsOpen(100 + csvdb["adv_level_fundCsv"][level + 1].chapter) then -- 有下一级 |
1201 | + if csvdb["adv_level_fundCsv"][level + 1] then -- 有下一级 | ||
1185 | newExp = newExp - csvdb["adv_level_fundCsv"][level].exp | 1202 | newExp = newExp - csvdb["adv_level_fundCsv"][level].exp |
1186 | level = level + 1 | 1203 | level = level + 1 |
1187 | else | 1204 | else |
@@ -1195,6 +1212,7 @@ function RolePlugin.bind(Role) | @@ -1195,6 +1212,7 @@ function RolePlugin.bind(Role) | ||
1195 | advL[1] = level | 1212 | advL[1] = level |
1196 | advL[2] = newExp | 1213 | advL[2] = newExp |
1197 | self:updateProperty({field = "advL", value = advL}) | 1214 | self:updateProperty({field = "advL", value = advL}) |
1215 | + return oldLevel, level | ||
1198 | end | 1216 | end |
1199 | 1217 | ||
1200 | function Role:getAdvWheelSurfLv(ptype) | 1218 | function Role:getAdvWheelSurfLv(ptype) |
@@ -1742,7 +1760,36 @@ function RolePlugin.bind(Role) | @@ -1742,7 +1760,36 @@ function RolePlugin.bind(Role) | ||
1742 | end) | 1760 | end) |
1743 | return gift, checkPoint | 1761 | return gift, checkPoint |
1744 | end | 1762 | end |
1763 | + --[[ | ||
1764 | + "hang" : "挂机资源满", | ||
1765 | + "box" : "箱子拆解完毕", | ||
1766 | + "food" : "食物出售完毕", | ||
1767 | + "adv" : "代理拾荒完毕", | ||
1768 | + --]] | ||
1769 | + function Role:pushMsg(params) | ||
1770 | + if not self._pushToken or self._pushToken == "" then return end | ||
1771 | + if params.time <= 0 then | ||
1772 | + self:pushCancel(params) | ||
1773 | + return | ||
1774 | + end | ||
1775 | + local content = string.format("push:%d:%s:%s:%s", self:getProperty("id"), params.type, params.slot or 1, self._pushToken) | ||
1776 | + notifyClient({content = content, time = math.floor(params.time)}) | ||
1777 | + end | ||
1745 | 1778 | ||
1779 | + function Role:pushCancel(params) | ||
1780 | + if not self._pushToken or self._pushToken == "" then return end | ||
1781 | + local content = string.format("push:%d:%s:%s:%s", self:getProperty("id"), params.type, params.slot or 1, self._pushToken) | ||
1782 | + deleteNotify({content = content}) | ||
1783 | + end | ||
1784 | + | ||
1785 | + function Role:pushCancelAll(ptype) | ||
1786 | + if not self._pushToken or self._pushToken == "" then return end | ||
1787 | + local pattern = string.format("push:%d:*", self:getProperty("id")) | ||
1788 | + if ptype then | ||
1789 | + pattern = string.format("push:%d:%s:*", self:getProperty("id"), ptype) | ||
1790 | + end | ||
1791 | + deleteNotify({pattern = pattern}) | ||
1792 | + end | ||
1746 | end | 1793 | end |
1747 | 1794 | ||
1748 | return RolePlugin | 1795 | return RolePlugin |
1749 | \ No newline at end of file | 1796 | \ No newline at end of file |
src/models/RoleTask.lua
@@ -235,6 +235,8 @@ local StoreListener = { | @@ -235,6 +235,8 @@ local StoreListener = { | ||
235 | [TaskType.HangPass] = {{TriggerEventType.HangPass, f("id")}}, | 235 | [TaskType.HangPass] = {{TriggerEventType.HangPass, f("id")}}, |
236 | [TaskType.RoleLevelUp] = {{TriggerEventType.LevelUp, f("level")}}, | 236 | [TaskType.RoleLevelUp] = {{TriggerEventType.LevelUp, f("level")}}, |
237 | [TaskType.TowerPass] = {{TriggerEventType.TowerPass, f("level")}}, | 237 | [TaskType.TowerPass] = {{TriggerEventType.TowerPass, f("level")}}, |
238 | + [TaskType.AdvPass] = {{TriggerEventType.AdvPass, f("id")}}, | ||
239 | + [TaskType.AddHero] = {{TriggerEventType.AddNewHero, f("heroType")}, {TriggerEventType.SSRCount, f("ssrCount")}}, | ||
238 | } | 240 | } |
239 | } | 241 | } |
240 | 242 | ||
@@ -243,7 +245,7 @@ local CalendaTaskListener = { | @@ -243,7 +245,7 @@ local CalendaTaskListener = { | ||
243 | listen = { | 245 | listen = { |
244 | [TaskType.DrawHero] = {{1, 1, f("count")}}, | 246 | [TaskType.DrawHero] = {{1, 1, f("count")}}, |
245 | [TaskType.BonusPass]= {{2, 1}}, | 247 | [TaskType.BonusPass]= {{2, 1}}, |
246 | - [TaskType.AdvPass]= {{3, 1}}, | 248 | + [TaskType.AdvStart]= {{3, 1}}, |
247 | [TaskType.DinerLevelUp]= {{4, 2, f("level")}}, | 249 | [TaskType.DinerLevelUp]= {{4, 2, f("level")}}, |
248 | [TaskType.HeroLvlCollect]= {{5, 3}}, -- x名y级英雄 | 250 | [TaskType.HeroLvlCollect]= {{5, 3}}, -- x名y级英雄 |
249 | [TaskType.AdvHang]= {{6, 1}}, ---- | 251 | [TaskType.AdvHang]= {{6, 1}}, ---- |
@@ -255,11 +257,11 @@ local CalendaTaskListener = { | @@ -255,11 +257,11 @@ local CalendaTaskListener = { | ||
255 | [TaskType.RoleLevelUp]= {{12, 2, f("level")}}, | 257 | [TaskType.RoleLevelUp]= {{12, 2, f("level")}}, |
256 | [TaskType.TowerPass]= {{13, 2, f("level")}}, | 258 | [TaskType.TowerPass]= {{13, 2, f("level")}}, |
257 | [TaskType.HeroTalent]= {{14, 1}}, | 259 | [TaskType.HeroTalent]= {{14, 1}}, |
258 | - [TaskType.HangPass]= {{15, 2, f("id")}}, | 260 | + [TaskType.HangPass]= {{15, 3}}, |
259 | [TaskType.HeroStarCollect]= {{16, 3}}, | 261 | [TaskType.HeroStarCollect]= {{16, 3}}, |
260 | [TaskType.FoodSell]= {{17, 1, f("count")}}, | 262 | [TaskType.FoodSell]= {{17, 1, f("count")}}, |
261 | [TaskType.HangGet]= {{18, 3, f("reward")}}, | 263 | [TaskType.HangGet]= {{18, 3, f("reward")}}, |
262 | - [TaskType.RuneQualityCollect]= {{19, 3, f("id")}}, | 264 | + [TaskType.RuneQualityCollect]= {{19, 3}}, |
263 | [TaskType.OpenBox]= {{20, 3, f("count"), f("quality")}}, | 265 | [TaskType.OpenBox]= {{20, 3, f("count"), f("quality")}}, |
264 | } | 266 | } |
265 | } | 267 | } |
@@ -272,6 +274,7 @@ local TaskListeners = { | @@ -272,6 +274,7 @@ local TaskListeners = { | ||
272 | SudokuListener, | 274 | SudokuListener, |
273 | ActivityListener, | 275 | ActivityListener, |
274 | StoreListener, | 276 | StoreListener, |
277 | + CalendaTaskListener, | ||
275 | } | 278 | } |
276 | 279 | ||
277 | local RoleTask = {} | 280 | local RoleTask = {} |
@@ -579,14 +582,18 @@ function RoleTask.bind(Role) | @@ -579,14 +582,18 @@ function RoleTask.bind(Role) | ||
579 | end | 582 | end |
580 | 583 | ||
581 | function Role:checkActivityTask(notNotify, activityType, ...) | 584 | function Role:checkActivityTask(notNotify, activityType, ...) |
585 | + if not self.activity then return end | ||
582 | self.activity:checkActivity(notNotify, activityType, ...) | 586 | self.activity:checkActivity(notNotify, activityType, ...) |
583 | end | 587 | end |
584 | 588 | ||
585 | function Role:checkStoreTask(notNotify, triggerType, param) | 589 | function Role:checkStoreTask(notNotify, triggerType, param) |
590 | + if not self.storeData then return end | ||
586 | self.storeData:OnTriggerLimitTimePack(triggerType, param) | 591 | self.storeData:OnTriggerLimitTimePack(triggerType, param) |
587 | end | 592 | end |
588 | 593 | ||
589 | function Role:checkCalendaTask(notNotify, mainType, subType, param1, param2) | 594 | function Role:checkCalendaTask(notNotify, mainType, subType, param1, param2) |
595 | + --print("check calenda taskl", mainType, subType, param1, param2) | ||
596 | + if not self.activity then return end | ||
590 | local open, actId = self.activity:isOpen("CalendaTask") | 597 | local open, actId = self.activity:isOpen("CalendaTask") |
591 | local actData = csvdb["activity_ctrlCsv"][actId] | 598 | local actData = csvdb["activity_ctrlCsv"][actId] |
592 | if not actData then return end | 599 | if not actData then return end |
@@ -606,11 +613,86 @@ function RoleTask.bind(Role) | @@ -606,11 +613,86 @@ function RoleTask.bind(Role) | ||
606 | elseif subType == 2 then -- 直接赋值 | 613 | elseif subType == 2 then -- 直接赋值 |
607 | calTask[id] = param1 | 614 | calTask[id] = param1 |
608 | elseif subType == 3 then -- 自定义类型 | 615 | elseif subType == 3 then -- 自定义类型 |
616 | + if cfg.type == 7 then -- 英雄品质收集进度 | ||
617 | + local count = 0 | ||
618 | + for _, hero in pairs(self.heros) do | ||
619 | + local unitData = csvdb["unitCsv"][hero:getProperty("type")] | ||
620 | + if unitData then | ||
621 | + if cfg.condition2 <= unitData.rare then | ||
622 | + count = count + 1 | ||
623 | + end | ||
624 | + end | ||
625 | + end | ||
626 | + if (calTask[id] or 0) < count then | ||
627 | + calTask[id] = count | ||
628 | + end | ||
629 | + elseif cfg.type == 5 then -- 英雄等级收集进度 | ||
630 | + local count = 0 | ||
631 | + for _, hero in pairs(self.heros) do | ||
632 | + if cfg.condition2 <= hero:getProperty("level") then | ||
633 | + count = count + 1 | ||
634 | + end | ||
635 | + end | ||
636 | + if (calTask[id] or 0) < count then | ||
637 | + calTask[id] = count | ||
638 | + end | ||
639 | + elseif cfg.type == 16 then -- 英雄星级收集进度 | ||
640 | + local count = 0 | ||
641 | + for _, hero in pairs(self.heros) do | ||
642 | + if cfg.condition2 <= hero:getProperty("wakeL") then | ||
643 | + count = count + 1 | ||
644 | + end | ||
645 | + end | ||
646 | + if (calTask[id] or 0) < count then | ||
647 | + calTask[id] = count | ||
648 | + end | ||
649 | + elseif cfg.type == 18 then -- 挂机累计收获id,y个 | ||
650 | + for rid, v in pairs(param1) do | ||
651 | + if cfg.condition2 == rid then | ||
652 | + calTask[id] = (calTask[id] or 0) + v | ||
653 | + end | ||
654 | + end | ||
655 | + elseif cfg.type == 19 then -- x名英雄装备y品质以上符文套装 | ||
656 | + local count = 0 | ||
657 | + for _, hero in pairs(self.heros) do | ||
658 | + local rcount = 0 | ||
659 | + for _,uid in pairs(hero:getRunes()) do | ||
660 | + if uid > 0 then | ||
661 | + local runeData = self.runeBag[uid] | ||
662 | + if runeData then | ||
663 | + local csvData = csvdb["runeCsv"][runeData:getProperty("type")][runeData:getProperty("id")] | ||
664 | + | ||
665 | + if csvData and cfg.condition2 <= csvData.rarity then | ||
666 | + rcount = rcount + 1 | ||
667 | + end | ||
668 | + end | ||
669 | + end | ||
670 | + end | ||
671 | + if rcount == 6 then | ||
672 | + count = count + 1 | ||
673 | + end | ||
674 | + end | ||
675 | + calTask[id] = count | ||
676 | + elseif cfg.type == 20 then -- 开启x品质时钟箱子 | ||
677 | + if cfg.condition2 <= (param2 or 0) then | ||
678 | + calTask[id] = (calTask[id] or 0) + param2 | ||
679 | + end | ||
680 | + elseif cfg.type == 15 then -- 通关关卡 | ||
681 | + if (calTask[id] or 0) == 0 then | ||
682 | + local hangPass = self:getProperty("hangPass") | ||
683 | + local diff = math.floor(cfg.condition2 / 10000) | ||
684 | + if (hangPass[diff] or 0) >= cfg.condition1 then | ||
685 | + calTask[id] = 1 | ||
686 | + end | ||
687 | + end | ||
688 | + end | ||
609 | end | 689 | end |
610 | end | 690 | end |
611 | end | 691 | end |
612 | end | 692 | end |
613 | end | 693 | end |
694 | + self:updateProperty({field = "calTask", value = calTask, notNotify = notNotify}) | ||
695 | + --dump(calTask) | ||
614 | end | 696 | end |
615 | 697 | ||
616 | end | 698 | end |
src/models/RoleTimeReset.lua
@@ -90,7 +90,7 @@ function Role:updateTimeReset(now, notify) | @@ -90,7 +90,7 @@ function Role:updateTimeReset(now, notify) | ||
90 | self:setProperties({timeReset = timeReset, ltime = now}) | 90 | self:setProperties({timeReset = timeReset, ltime = now}) |
91 | 91 | ||
92 | response.timeReset = timeReset | 92 | response.timeReset = timeReset |
93 | - response.ltime = ltime | 93 | + response.ltime = now |
94 | 94 | ||
95 | if notify then | 95 | if notify then |
96 | self:notifyUpdateProperties(response) | 96 | self:notifyUpdateProperties(response) |
src/models/Store.lua
@@ -23,11 +23,11 @@ Store.schema = { | @@ -23,11 +23,11 @@ Store.schema = { | ||
23 | battleFR = {"string", ""}, -- 免费赛季卡领取记录 | 23 | battleFR = {"string", ""}, -- 免费赛季卡领取记录 |
24 | battleLR = {"string", ""}, -- 付费赛季卡领取记录 | 24 | battleLR = {"string", ""}, -- 付费赛季卡领取记录 |
25 | 25 | ||
26 | - limitTPack = {"table", {}}, -- 限时礼包 {id=expire_ts} | 26 | + limitTPack = {"table", {}}, -- 限时礼包 {id={expire_ts, trigger_type}} |
27 | privCardEx = {"number", 0}, -- 特权卡过期时间戳 | 27 | privCardEx = {"number", 0}, -- 特权卡过期时间戳 |
28 | getMailT1 = {"number",0}, -- 上次发送月卡福利邮件的时间 | 28 | getMailT1 = {"number",0}, -- 上次发送月卡福利邮件的时间 |
29 | getMailT2 = {"number",0}, -- 上次发送超级月卡福利邮件的时间 | 29 | getMailT2 = {"number",0}, -- 上次发送超级月卡福利邮件的时间 |
30 | - packTrigger = {"table", {}}, -- 礼包触发记录 {关卡难度1={id, 通关关卡数,升级数,爬塔层数}, ...} | 30 | + --packTrigger = {"table", {}}, -- 礼包触发记录 {关卡难度1={id, 通关关卡数,升级数,爬塔层数}, ...} |
31 | 31 | ||
32 | -- 活动商品购买记录 | 32 | -- 活动商品购买记录 |
33 | actGoodsFlag = {"table", {}}, -- ActGoodsType 1购买,0未购买 | 33 | actGoodsFlag = {"table", {}}, -- ActGoodsType 1购买,0未购买 |
@@ -57,7 +57,7 @@ end | @@ -57,7 +57,7 @@ end | ||
57 | function Store:onCrossDay() | 57 | function Store:onCrossDay() |
58 | self:sendMonthCardEmail() | 58 | self:sendMonthCardEmail() |
59 | self:deleteExpireLimitGoods() | 59 | self:deleteExpireLimitGoods() |
60 | - self:checkPaySignReward() | 60 | + --self:checkPaySignReward() |
61 | end | 61 | end |
62 | 62 | ||
63 | -- 删除过期商品 | 63 | -- 删除过期商品 |
@@ -65,10 +65,11 @@ function Store:deleteExpireLimitGoods() | @@ -65,10 +65,11 @@ function Store:deleteExpireLimitGoods() | ||
65 | local timeNow = skynet.timex() | 65 | local timeNow = skynet.timex() |
66 | local limitGoodsList = self:getProperty("limitTPack") | 66 | local limitGoodsList = self:getProperty("limitTPack") |
67 | for k, v in pairs(limitGoodsList) do | 67 | for k, v in pairs(limitGoodsList) do |
68 | - if timeNow > v then | 68 | + if timeNow > v[1] then |
69 | limitGoodsList[k] = nil | 69 | limitGoodsList[k] = nil |
70 | end | 70 | end |
71 | end | 71 | end |
72 | + self:updateProperty({field = "limitTPack", value = limitGoodsList, notNotify = true}) | ||
72 | end | 73 | end |
73 | 74 | ||
74 | -- 发送月卡邮件 | 75 | -- 发送月卡邮件 |
@@ -162,6 +163,26 @@ function Store:getGearExchangeCoef() | @@ -162,6 +163,26 @@ function Store:getGearExchangeCoef() | ||
162 | return 1 + coef | 163 | return 1 + coef |
163 | end | 164 | end |
164 | 165 | ||
166 | +-- 奖励关卡 特权卡额外数量 | ||
167 | +function Store:getBonusExtraFightCount() | ||
168 | + if self:isPrivCardExpire() then | ||
169 | + return 0 | ||
170 | + end | ||
171 | + | ||
172 | + local cnt = globalCsv.bonus_extra_fight_count or 1 | ||
173 | + return cnt | ||
174 | +end | ||
175 | + | ||
176 | +-- 挂机道具掉落系数 特权卡挂机掉落系数 | ||
177 | +function Store:getHangDropCoef() | ||
178 | + if self:isPrivCardExpire() then | ||
179 | + return 1, 1 | ||
180 | + end | ||
181 | + | ||
182 | + return (1 + globalCsv.hang_drop_exp_coef) or 1, (1 + globalCsv.hang_drop_item_coef) or 1 | ||
183 | +end | ||
184 | + | ||
185 | + | ||
165 | -- 购买通行证 | 186 | -- 购买通行证 |
166 | function Store:onBuyCard(type, duration, id) | 187 | function Store:onBuyCard(type, duration, id) |
167 | local timeNow = skynet.timex() | 188 | local timeNow = skynet.timex() |
@@ -203,7 +224,7 @@ end | @@ -203,7 +224,7 @@ end | ||
203 | 224 | ||
204 | --检测购买是否超过限制数量 | 225 | --检测购买是否超过限制数量 |
205 | function Store:checkRechargeRecord(limit, id) | 226 | function Store:checkRechargeRecord(limit, id) |
206 | - local rechargeRecord = self:getProperty("payR") | 227 | + local rechargeRecord = self:getProperty("payR") or {} |
207 | if limit ~= 0 and limit <= (rechargeRecord[id] or 0) then | 228 | if limit ~= 0 and limit <= (rechargeRecord[id] or 0) then |
208 | skynet.error(string.format("recharge id:%d count over limit, user id:%d", id, self.owner:getProperty("id"))) | 229 | skynet.error(string.format("recharge id:%d count over limit, user id:%d", id, self.owner:getProperty("id"))) |
209 | return false | 230 | return false |
@@ -292,96 +313,103 @@ end | @@ -292,96 +313,103 @@ end | ||
292 | --触发限时礼包 | 313 | --触发限时礼包 |
293 | function Store:OnTriggerLimitTimePack(eventType, param) | 314 | function Store:OnTriggerLimitTimePack(eventType, param) |
294 | local limitPack = self:getProperty("limitTPack") | 315 | local limitPack = self:getProperty("limitTPack") |
295 | - local payRecord = self:getProperty("payR") | 316 | + --local payRecord = self:getProperty("payR") |
296 | local timeNow = skynet.timex() | 317 | local timeNow = skynet.timex() |
297 | - local find = false | 318 | + --local find = false |
298 | -- 有未过期的限时礼包不再推送 | 319 | -- 有未过期的限时礼包不再推送 |
299 | - for k, v in pairs(limitPack) do | ||
300 | - if v > timeNow and not payRecord[k] then | ||
301 | - find = true | ||
302 | - break | ||
303 | - end | ||
304 | - end | ||
305 | - if find == true then | ||
306 | - return | ||
307 | - end | ||
308 | - limitPack = {} | ||
309 | - local hangPass = self.owner:getProperty("hangPass") | ||
310 | - local triggerRecord = self:getProperty("packTrigger") | ||
311 | - local result = {} | ||
312 | - local maxDiff = 0 | 320 | + --for k, v in pairs(limitPack) do |
321 | + -- if v > timeNow and not payRecord[k] then | ||
322 | + -- find = true | ||
323 | + -- break | ||
324 | + -- end | ||
325 | + --end | ||
326 | + --if find == true then | ||
327 | + -- return | ||
328 | + --end | ||
329 | + --local hangPass = self.owner:getProperty("hangPass") | ||
330 | + --local triggerRecord = self:getProperty("packTrigger") | ||
331 | + --local result = {} | ||
332 | + --local maxDiff = 0 | ||
313 | -- 取满足限时礼包关卡要求的对应数据 | 333 | -- 取满足限时礼包关卡要求的对应数据 |
314 | - for diff, maxCarbonId in pairs(hangPass) do | ||
315 | - for id, cfg in pairs(csvdb["shop_packCsv"]) do | ||
316 | - local range = cfg.showRange:toArray(true, "=") | ||
317 | - local beginRange = range[1] or 0 | ||
318 | - local endRange = range[2] or 0 | ||
319 | - if maxCarbonId > beginRange and maxCarbonId <= endRange and cfg.type == eventType then | ||
320 | - result[diff] = cfg | ||
321 | - maxDiff = math.max(maxDiff, diff) | ||
322 | - break | ||
323 | - end | ||
324 | - end | ||
325 | - end | ||
326 | - local shopGoodsId = 0 | ||
327 | - for diff, cfg in pairs(result) do | ||
328 | - if diff == maxDiff then | ||
329 | - local record = triggerRecord[diff] or {} | ||
330 | - if (record[0] or 0) ~= cfg.id and next(record) then | ||
331 | - record = {} | ||
332 | - end | ||
333 | - record[0] = cfg.id | ||
334 | - record[eventType] = (record[eventType] or 0) + 1 | ||
335 | - if record[eventType] > 0 and record[eventType] % 10 == 0 then | ||
336 | - local pool = cfg.packId:toArray(true, "=") | ||
337 | - local idx = math.random(1, #pool) | ||
338 | - shopGoodsId = pool[idx] | ||
339 | - end | ||
340 | - triggerRecord[diff] = record | 334 | + --for diff, maxCarbonId in pairs(hangPass) do |
335 | + -- for id, cfg in pairs(csvdb["shop_packCsv"]) do | ||
336 | + -- local range = cfg.showRange:toArray(true, "=") | ||
337 | + -- local beginRange = range[1] or 0 | ||
338 | + -- local endRange = range[2] or 0 | ||
339 | + -- if maxCarbonId > beginRange and maxCarbonId <= endRange and cfg.type == eventType then | ||
340 | + -- result[diff] = cfg | ||
341 | + -- maxDiff = math.max(maxDiff, diff) | ||
342 | + -- break | ||
343 | + -- end | ||
344 | + -- end | ||
345 | + --end | ||
346 | + local config = nil | ||
347 | + for id, cfg in pairs(csvdb["shop_packCsv"]) do | ||
348 | + if cfg.type == eventType and cfg.condition == param then | ||
349 | + config = cfg | ||
341 | end | 350 | end |
342 | end | 351 | end |
343 | - if shopGoodsId ~= 0 then | ||
344 | - local rechargeCfg = csvdb["shop_rechargeCsv"][shopGoodsId] | 352 | + if config ~= nil then |
353 | + local rechargeCfg = csvdb["shop_rechargeCsv"][config.packId] | ||
345 | if rechargeCfg then | 354 | if rechargeCfg then |
346 | - limitPack[rechargeCfg.id] = timeNow + rechargeCfg.time | 355 | + limitPack[rechargeCfg.id] = {timeNow + rechargeCfg.time, config.id} |
356 | + self.owner:log("push_gift", { | ||
357 | + gift_id = rechargeCfg.id, --礼包ID | ||
358 | + gift_name = rechargeCfg.title, --礼包名称 | ||
359 | + }) | ||
347 | self:updateProperty({field = "limitTPack", value = limitPack}) | 360 | self:updateProperty({field = "limitTPack", value = limitPack}) |
348 | end | 361 | end |
349 | end | 362 | end |
350 | - if next(result) then | ||
351 | - self:updateProperty({field = "packTrigger", value = triggerRecord}) | ||
352 | - end | 363 | + --if next(result) then |
364 | + -- self:updateProperty({field = "packTrigger", value = triggerRecord}) | ||
365 | + --end | ||
353 | end | 366 | end |
354 | 367 | ||
355 | function GetActGoodsIndex(goodsType) | 368 | function GetActGoodsIndex(goodsType) |
356 | return ActGoodsType[goodsType] or 0 | 369 | return ActGoodsType[goodsType] or 0 |
357 | end | 370 | end |
358 | 371 | ||
359 | --- 购买付费签到 按开服时间算奖励 | ||
360 | -function Store:onBuyPaySignCard(dur) | ||
361 | - local curTs = skynet.timex() | 372 | +function Store:SetActGoodsFlag(goodsType, flag) |
362 | local actGoodsFlag = self:getProperty("actGoodsFlag") or {} | 373 | local actGoodsFlag = self:getProperty("actGoodsFlag") or {} |
363 | - local goodsIndex = GetActGoodsIndex("paySignIn") | 374 | + local goodsIndex = GetActGoodsIndex(goodsType) |
364 | if goodsIndex == 0 then | 375 | if goodsIndex == 0 then |
365 | print("get act goods index fail :paySignIn") | 376 | print("get act goods index fail :paySignIn") |
366 | return | 377 | return |
367 | end | 378 | end |
368 | - actGoodsFlag[goodsIndex] = 1 | 379 | + actGoodsFlag[goodsIndex] = flag |
369 | self:updateProperty({field = "actGoodsFlag", value = actGoodsFlag}) | 380 | self:updateProperty({field = "actGoodsFlag", value = actGoodsFlag}) |
370 | - -- 发钱 | ||
371 | - local change | ||
372 | - local reward, curData = self.owner.activity:getPaySignReward() | ||
373 | - if next(reward) then | ||
374 | - self.owner.activity:updateActData("PaySignIn", curData) | ||
375 | - reward, change = self.owner:award(reward, {log = {desc = "actPaySign"}}) | ||
376 | - end | ||
377 | - | ||
378 | - self.owner:log("activity", { | ||
379 | - activity_id = 0, -- 活动ID(或活动指定任务的ID) | ||
380 | - activity_type = self.owner.activity.ActivityType.PaySignIn, -- 活动类型,见活动类型枚举表 | ||
381 | - activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} | ||
382 | - }) | 381 | +end |
383 | 382 | ||
384 | - SendPacket(actionCodes.Activity_actPaySignRewardNtf, MsgPack.pack(self.owner:packReward(reward, change))) | 383 | +-- 购买付费签到 按开服时间算奖励 |
384 | +function Store:onBuyPaySignCard(dur) | ||
385 | + local curTs = skynet.timex() | ||
386 | + curTs = getServerOpenTs() | ||
387 | + | ||
388 | + self:SetActGoodsFlag("paySignIn", curTs) | ||
389 | + | ||
390 | + --local actGoodsFlag = self:getProperty("actGoodsFlag") or {} | ||
391 | + --local goodsIndex = GetActGoodsIndex("paySignIn") | ||
392 | + --if goodsIndex == 0 then | ||
393 | + -- print("get act goods index fail :paySignIn") | ||
394 | + -- return | ||
395 | + --end | ||
396 | + --actGoodsFlag[goodsIndex] = 1 | ||
397 | + --self:updateProperty({field = "actGoodsFlag", value = actGoodsFlag}) | ||
398 | + -- 发钱 | ||
399 | + --local change | ||
400 | + --local reward, curData = self.owner.activity:getPaySignReward() | ||
401 | + --if next(reward) then | ||
402 | + -- self.owner.activity:updateActData("PaySignIn", curData) | ||
403 | + -- reward, change = self.owner:award(reward, {log = {desc = "actPaySign"}}) | ||
404 | + --end | ||
405 | + | ||
406 | + --self.owner:log("activity", { | ||
407 | + -- activity_id = 0, -- 活动ID(或活动指定任务的ID) | ||
408 | + -- activity_type = self.owner.activity.ActivityType.PaySignIn, -- 活动类型,见活动类型枚举表 | ||
409 | + -- activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} | ||
410 | + --}) | ||
411 | + | ||
412 | + --SendPacket(actionCodes.Activity_actPaySignRewardNtf, MsgPack.pack(self.owner:packReward(reward, change))) | ||
385 | end | 413 | end |
386 | 414 | ||
387 | function Store:checkPaySignReward() | 415 | function Store:checkPaySignReward() |
@@ -392,7 +420,35 @@ function Store:checkPaySignReward() | @@ -392,7 +420,35 @@ function Store:checkPaySignReward() | ||
392 | end | 420 | end |
393 | end | 421 | end |
394 | 422 | ||
423 | +-- 临时用 登录触发限时礼包 时间点以后 | ||
424 | +function Store:OnTriggerLimitTimePackAfterTs(eventType, param) | ||
425 | + local limitPack = self:getProperty("limitTPack") | ||
426 | + local timeNow = skynet.timex() | ||
427 | + local config = nil | ||
428 | + for id, cfg in pairs(csvdb["shop_packCsv"]) do | ||
429 | + local ts = toUnixtime(""..cfg.condition) | ||
430 | + if cfg.type == eventType and ts < param then | ||
431 | + config = cfg | ||
432 | + | ||
433 | + if config ~= nil then | ||
434 | + local rechargeCfg = csvdb["shop_rechargeCsv"][config.packId] | ||
435 | + if rechargeCfg then | ||
436 | + if not limitPack[rechargeCfg.id] then | ||
437 | + limitPack[rechargeCfg.id] = {timeNow + rechargeCfg.time, config.id} | ||
438 | + self.owner:log("push_gift", { | ||
439 | + gift_id = rechargeCfg.id, --礼包ID | ||
440 | + gift_name = rechargeCfg.title, --礼包名称 | ||
441 | + }) | ||
442 | + self:updateProperty({field = "limitTPack", value = limitPack, notNotify = false}) | ||
443 | + end | ||
444 | + end | ||
445 | + end | ||
446 | + end | ||
447 | + end | ||
448 | +end | ||
449 | + | ||
395 | function Store:data() | 450 | function Store:data() |
451 | + self:OnTriggerLimitTimePackAfterTs(TriggerEventType.AfterTs, skynet.timex()) | ||
396 | return { | 452 | return { |
397 | buyR = self:getProperty("buyR"), | 453 | buyR = self:getProperty("buyR"), |
398 | payR = self:getProperty("payR"), | 454 | payR = self:getProperty("payR"), |
@@ -405,7 +461,7 @@ function Store:data() | @@ -405,7 +461,7 @@ function Store:data() | ||
405 | battleLR = self:getProperty("battleLR"), | 461 | battleLR = self:getProperty("battleLR"), |
406 | limitTPack = self:getProperty("limitTPack"), | 462 | limitTPack = self:getProperty("limitTPack"), |
407 | privCardEx = self:getProperty("privCardEx"), | 463 | privCardEx = self:getProperty("privCardEx"), |
408 | - packTrigger = self:getProperty("packTrigger"), | 464 | + --packTrigger = self:getProperty("packTrigger"), |
409 | actGoodsFlag = self:getProperty("actGoodsFlag"), | 465 | actGoodsFlag = self:getProperty("actGoodsFlag"), |
410 | bpInfo = self:getProperty("bpInfo"), | 466 | bpInfo = self:getProperty("bpInfo"), |
411 | } | 467 | } |
src/services/agent_ctrl.lua
@@ -5,6 +5,7 @@ local netpack = require "skynet.netpack" | @@ -5,6 +5,7 @@ local netpack = require "skynet.netpack" | ||
5 | local xxtea = require "xxtea" | 5 | local xxtea = require "xxtea" |
6 | local deque = require "deque" | 6 | local deque = require "deque" |
7 | local datacenter = require "skynet.datacenter" | 7 | local datacenter = require "skynet.datacenter" |
8 | +local agent_queued = require "services.agent_queued" | ||
8 | 9 | ||
9 | local pcall = pcall | 10 | local pcall = pcall |
10 | local string_format = string.format | 11 | local string_format = string.format |
@@ -58,10 +59,15 @@ function _M:exit_agent(fd) | @@ -58,10 +59,15 @@ function _M:exit_agent(fd) | ||
58 | local agent = get_a(pack) | 59 | local agent = get_a(pack) |
59 | 60 | ||
60 | pcall(skynet.send, agent, "lua", "exit") | 61 | pcall(skynet.send, agent, "lua", "exit") |
61 | - pcall(skynet.send, poold, "lua", "feed") | ||
62 | 62 | ||
63 | self.f2u[fd] = nil | 63 | self.f2u[fd] = nil |
64 | self.u2f[uid] = nil | 64 | self.u2f[uid] = nil |
65 | + local nuid, nfd = agent_queued.pop() | ||
66 | + if not nuid then | ||
67 | + pcall(skynet.send, poold, "lua", "feed") | ||
68 | + else | ||
69 | + self:query_agent(nfd, nuid, true) | ||
70 | + end | ||
65 | end | 71 | end |
66 | 72 | ||
67 | -- @desc: 客户端连入 | 73 | -- @desc: 客户端连入 |
@@ -73,7 +79,11 @@ end | @@ -73,7 +79,11 @@ end | ||
73 | function _M:socket_close(fd) | 79 | function _M:socket_close(fd) |
74 | self.f2i[fd] = nil | 80 | self.f2i[fd] = nil |
75 | local uid = self.f2u[fd] | 81 | local uid = self.f2u[fd] |
76 | - if not uid then return end | 82 | + if not uid then |
83 | + -- 排队中? | ||
84 | + agent_queued.socket_close(fd) | ||
85 | + return | ||
86 | + end | ||
77 | self.f2e[fd] = skynet.timex() + AGENT_EXPIRE_TIME | 87 | self.f2e[fd] = skynet.timex() + AGENT_EXPIRE_TIME |
78 | 88 | ||
79 | if not self.u2f[uid] then | 89 | if not self.u2f[uid] then |
@@ -89,7 +99,11 @@ end | @@ -89,7 +99,11 @@ end | ||
89 | function _M:socket_error(fd) | 99 | function _M:socket_error(fd) |
90 | self.f2i[fd] = nil | 100 | self.f2i[fd] = nil |
91 | local uid = self.f2u[fd] | 101 | local uid = self.f2u[fd] |
92 | - if not uid then return end | 102 | + if not uid then |
103 | + -- 排队中? | ||
104 | + agent_queued.socket_close(fd) | ||
105 | + return | ||
106 | + end | ||
93 | 107 | ||
94 | if not self.u2f[uid] then | 108 | if not self.u2f[uid] then |
95 | self.f2u[fd] = nil | 109 | self.f2u[fd] = nil |
@@ -114,6 +128,7 @@ local next_log_time = 0 | @@ -114,6 +128,7 @@ local next_log_time = 0 | ||
114 | local CHECK_AGENT_STATUS_INTERVAL = 100 -- 检查agent状态的定时间隔 | 128 | local CHECK_AGENT_STATUS_INTERVAL = 100 -- 检查agent状态的定时间隔 |
115 | -- @desc: 检查agent状态,若过期,则让agent退出;并定时打日志统计在线人数 | 129 | -- @desc: 检查agent状态,若过期,则让agent退出;并定时打日志统计在线人数 |
116 | function _M:check_agent_status() | 130 | function _M:check_agent_status() |
131 | + agent_queued.handle_timeout() | ||
117 | local now = skynet.timex() | 132 | local now = skynet.timex() |
118 | if now >= next_check_time then | 133 | if now >= next_check_time then |
119 | next_check_time = now + CHECK_AGENT_STATUS_INTERVAL | 134 | next_check_time = now + CHECK_AGENT_STATUS_INTERVAL |
@@ -151,7 +166,7 @@ local function query_agent_response(fd, response) | @@ -151,7 +166,7 @@ local function query_agent_response(fd, response) | ||
151 | end | 166 | end |
152 | 167 | ||
153 | -- @desc: 玩家登陆第一个包,queryLogin,watchdog为客户端分配一个agent,并告诉gate分配成功,之后的消息直接走agent | 168 | -- @desc: 玩家登陆第一个包,queryLogin,watchdog为客户端分配一个agent,并告诉gate分配成功,之后的消息直接走agent |
154 | -function _M:query_agent(fd, uid) | 169 | +function _M:query_agent(fd, uid, isQueue) |
155 | local pack = self.u2f[uid] | 170 | local pack = self.u2f[uid] |
156 | if pack then | 171 | if pack then |
157 | local f = get_f(pack) | 172 | local f = get_f(pack) |
@@ -159,7 +174,6 @@ function _M:query_agent(fd, uid) | @@ -159,7 +174,6 @@ function _M:query_agent(fd, uid) | ||
159 | skynet.error(string.format("%s same fd %d", uid, fd)) | 174 | skynet.error(string.format("%s same fd %d", uid, fd)) |
160 | return | 175 | return |
161 | end | 176 | end |
162 | - | ||
163 | -- self.f2u[f] 肯定存在;self.f2e[f]不存在,则说明在线,则需要踢下线 | 177 | -- self.f2u[f] 肯定存在;self.f2e[f]不存在,则说明在线,则需要踢下线 |
164 | if not self.f2e[f] then | 178 | if not self.f2e[f] then |
165 | local head = string.pack("H", actionCodes.Sys_maintainNotice) | 179 | local head = string.pack("H", actionCodes.Sys_maintainNotice) |
@@ -182,12 +196,29 @@ function _M:query_agent(fd, uid) | @@ -182,12 +196,29 @@ function _M:query_agent(fd, uid) | ||
182 | self.f2u[f] = nil | 196 | self.f2u[f] = nil |
183 | self.u2f[uid] = set_pack(fd, agent) | 197 | self.u2f[uid] = set_pack(fd, agent) |
184 | else | 198 | else |
185 | - -- 该uid未存储,则说明至少超过10分钟未登陆,由agent池服务pop出一个agent | ||
186 | - local agent = self.factory:pop() | ||
187 | - if not agent then | ||
188 | - -- 服务器满 | ||
189 | - query_agent_response(fd, {ret = "RET_SERVER_FULL"}) | ||
190 | - return | 199 | + local agent |
200 | + if isQueue then | ||
201 | + agent = self.factory:pop() | ||
202 | + if agent then | ||
203 | + pcall(skynet.send, poold, "lua", "feed") | ||
204 | + else | ||
205 | + agent = skynet.newservice("agent") | ||
206 | + end | ||
207 | + else | ||
208 | + -- 该uid未存储,则说明至少超过10分钟未登陆,由agent池服务pop出一个agent | ||
209 | + if agent_queued.count() > 0 then | ||
210 | + -- 服务器满 开始排队 | ||
211 | + local rank = agent_queued.push(uid, fd) | ||
212 | + query_agent_response(fd, {ret = "RET_SERVER_FULL", rank = rank}) | ||
213 | + return | ||
214 | + end | ||
215 | + | ||
216 | + agent = self.factory:pop() | ||
217 | + if not agent then | ||
218 | + local rank = agent_queued.push(uid, fd) | ||
219 | + query_agent_response(fd, {ret = "RET_SERVER_FULL", rank = rank}) | ||
220 | + return | ||
221 | + end | ||
191 | end | 222 | end |
192 | 223 | ||
193 | local ok = pcall(skynet.call, agent, "lua", "start", gate_serv, fd, self.f2i[fd], hotfixList) | 224 | local ok = pcall(skynet.call, agent, "lua", "start", gate_serv, fd, self.f2i[fd], hotfixList) |
@@ -0,0 +1,154 @@ | @@ -0,0 +1,154 @@ | ||
1 | +-- 排队系统 | ||
2 | + | ||
3 | +require "ProtocolCode" | ||
4 | +require "shared.init" | ||
5 | +require "utils.init" | ||
6 | +require "GlobalVar" | ||
7 | +require "RedisKeys" | ||
8 | +require "skynet.manager" | ||
9 | + | ||
10 | +local queue = require "skynet.queue" | ||
11 | +local netpack = require "skynet.netpack" | ||
12 | +local socket = require "skynet.socket" | ||
13 | +local xxtea = require "xxtea" | ||
14 | + | ||
15 | +skynet = require "skynet" | ||
16 | + | ||
17 | +local MAX_COUNT = tonumber(skynet.getenv("max_queue")) | ||
18 | +-- 心跳定时间隔 | ||
19 | +local HEART_TIMER_INTERVAL = 30 | ||
20 | +local HEART_TIMEOUT_COUNT_MAX = 3 | ||
21 | + | ||
22 | +local CMD = {} | ||
23 | +local f2u = {} | ||
24 | +local u2i = {} -- {idx, fd, {lastHeart, timeOutCount, nextCheck}} | ||
25 | +local idx2u = {} | ||
26 | +local curIdx = 0 -- 下一个即将进入游戏的玩家索引 | ||
27 | +local nextIdx = 0 -- 新加的位置 | ||
28 | + | ||
29 | + | ||
30 | +local function getRank(uid) | ||
31 | + local info = u2i[uid] | ||
32 | + if not info then return -1 end | ||
33 | + return (info[1] + MAX_COUNT - curIdx) % MAX_COUNT + 1 | ||
34 | +end | ||
35 | + | ||
36 | + | ||
37 | +function SendPacket(actionCode, bin, client_fd) | ||
38 | + if #bin > 0 then bin = xxtea.encrypt(bin, XXTEA_KEY) end | ||
39 | + local head = string.pack("H", actionCode) | ||
40 | + return socket.write(client_fd, netpack.pack(head .. bin)) | ||
41 | +end | ||
42 | + | ||
43 | +local function checkQueue(fd) | ||
44 | + if not f2u[fd] then return end | ||
45 | + local info = u2i[f2u[fd]] | ||
46 | + if info then | ||
47 | + info[3][1] = skynet.timex() | ||
48 | + end | ||
49 | + local rank = getRank(f2u[fd]) | ||
50 | + SendPacket(actionCodes.Sys_checkQueue, MsgPack.pack({rank = rank}), fd) | ||
51 | +end | ||
52 | + | ||
53 | + | ||
54 | +skynet.register_protocol { | ||
55 | + name = "client", | ||
56 | + id = skynet.PTYPE_CLIENT, | ||
57 | + unpack = function (msg, sz) | ||
58 | + local data = skynet.tostring(msg, sz) | ||
59 | + local cmd = string.unpack("H", string.sub(data, 1, 2)) | ||
60 | + return cmd, string.sub(data, 3) | ||
61 | + end, | ||
62 | + dispatch = function(session, address, cmd, data) | ||
63 | + skynet.ignoreret() | ||
64 | + if cmd == actionCodes.Sys_checkQueue then | ||
65 | + checkQueue(session) | ||
66 | + end | ||
67 | + end | ||
68 | +} | ||
69 | + | ||
70 | +function CMD.push(uid, fd) | ||
71 | + uid = tostring(uid) | ||
72 | + if u2i[uid] then -- 存在] | ||
73 | + local oldfd = u2i[uid][2] | ||
74 | + if oldfd and oldfd ~= fd then | ||
75 | + -- 踢掉老的 | ||
76 | + SendPacket(actionCodes.Sys_maintainNotice, MsgPack.pack({body = "server_accountOccupied", iskey = true}), oldfd) | ||
77 | + skynet.timeout(10, function () | ||
78 | + skynet.call(gate_serv, "lua", "kick", oldfd) | ||
79 | + end) | ||
80 | + f2u[oldfd] = nil | ||
81 | + end | ||
82 | + u2i[uid][2] = fd | ||
83 | + f2u[fd] = uid | ||
84 | + u2i[uid][3] = {skynet.timex(), 0, skynet.timex() + HEART_TIMER_INTERVAL} | ||
85 | + else -- 新排队的用户 | ||
86 | + if nextIdx == curIdx and next(idx2u) then -- 满了 | ||
87 | + return | ||
88 | + end | ||
89 | + u2i[uid] = {nextIdx, fd, {skynet.timex(), 0, skynet.timex() + HEART_TIMER_INTERVAL}} | ||
90 | + f2u[fd] = uid | ||
91 | + idx2u[nextIdx] = uid | ||
92 | + nextIdx = (nextIdx + 1) % MAX_COUNT | ||
93 | + end | ||
94 | + skynet.call(gate_serv, "lua", "forward", fd, 0, skynet.self()) | ||
95 | + | ||
96 | + return getRank(uid) | ||
97 | +end | ||
98 | + | ||
99 | +function CMD.pop() | ||
100 | + while true do | ||
101 | + local uid = idx2u[curIdx] | ||
102 | + if not uid then return end -- 空的 | ||
103 | + local info = u2i[uid] | ||
104 | + if not info then | ||
105 | + idx2u[curIdx] = nil | ||
106 | + else | ||
107 | + if info[2] then | ||
108 | + -- 找到合适的了 | ||
109 | + u2i[uid] = nil | ||
110 | + idx2u[curIdx] = nil | ||
111 | + f2u[info[2]] = nil | ||
112 | + | ||
113 | + curIdx = (curIdx + 1) % MAX_COUNT | ||
114 | + return uid, info[2] | ||
115 | + else | ||
116 | + idx2u[curIdx] = nil | ||
117 | + u2i[uid] = nil | ||
118 | + end | ||
119 | + end | ||
120 | + curIdx = (curIdx + 1) % MAX_COUNT | ||
121 | + end | ||
122 | +end | ||
123 | + | ||
124 | + | ||
125 | +-- 下线了 | ||
126 | +function CMD.socket_close(fd) | ||
127 | + local uid = f2u[fd] | ||
128 | + if not uid then return end | ||
129 | + f2u[fd] = nil | ||
130 | + local info = u2i[uid] | ||
131 | + info[2] = nil | ||
132 | +end | ||
133 | + | ||
134 | +function CMD.handle_timeout() | ||
135 | + local now = skynet.timex() | ||
136 | + for uid, info in pairs(u2i) do | ||
137 | + if info[2] and info[3] and now >= info[3][3] then --存在fd 检查心跳 | ||
138 | + if info[3][1] - now > HEART_TIMER_INTERVAL or now - info[3][1] > HEART_TIMER_INTERVAL then | ||
139 | + info[3][2] = info[3][2] + 1 | ||
140 | + info[3][3] = now + HEART_TIMER_INTERVAL | ||
141 | + if info[3][2] >= HEART_TIMEOUT_COUNT_MAX then | ||
142 | + skynet.error("timeout! then queued will closed", info[2], uid) | ||
143 | + skynet.call(gate_serv, "lua", "kick", info[2]) | ||
144 | + end | ||
145 | + end | ||
146 | + end | ||
147 | + end | ||
148 | +end | ||
149 | + | ||
150 | +function CMD.count() | ||
151 | + return (nextIdx + MAX_COUNT - curIdx) % MAX_COUNT | ||
152 | +end | ||
153 | + | ||
154 | +return CMD |
src/services/agent_util.lua
@@ -17,15 +17,32 @@ local HEART_TIMEOUT_COUNT_MAX = 20 | @@ -17,15 +17,32 @@ local HEART_TIMEOUT_COUNT_MAX = 20 | ||
17 | local HEART_QUICK_COUNT_MAX = 5 | 17 | local HEART_QUICK_COUNT_MAX = 5 |
18 | -- 心跳定时间隔 | 18 | -- 心跳定时间隔 |
19 | local HEART_TIMER_INTERVAL = 5 | 19 | local HEART_TIMER_INTERVAL = 5 |
20 | +-- 忽略心跳的等待时间 | ||
21 | +local WAIT_IGNORE_HEART = 300 | ||
22 | + | ||
23 | +--开始忽略心跳的时间 | ||
24 | +local ignoreHeartTime = nil | ||
20 | 25 | ||
21 | local function check_heart_beat(agent, now) | 26 | local function check_heart_beat(agent, now) |
22 | -- 充值等操作不检查心跳 | 27 | -- 充值等操作不检查心跳 |
23 | local role = agent.role | 28 | local role = agent.role |
24 | - if role.ignoreHeartbeat then | 29 | + if not role or role.ignoreHeartbeat then |
25 | lastHeartCheckTime = now - HEART_TIMER_INTERVAL | 30 | lastHeartCheckTime = now - HEART_TIMER_INTERVAL |
26 | heartTimeoutCount = 0 | 31 | heartTimeoutCount = 0 |
32 | + | ||
33 | + if not ignoreHeartTime then | ||
34 | + ignoreHeartTime = now | ||
35 | + end | ||
36 | + | ||
37 | + if now - ignoreHeartTime >= WAIT_IGNORE_HEART then -- 等待太久了 踢掉 | ||
38 | + skynet.error("timeout! then agent will shut down by self with ignoreHeartbeat or no login", agent.client_fd) | ||
39 | + skynet.call(agent.gate_serv, "lua", "kick", agent.client_fd) | ||
40 | + ignoreHeartTime = nil | ||
41 | + end | ||
27 | return | 42 | return |
28 | end | 43 | end |
44 | + ignoreHeartTime = nil | ||
45 | + | ||
29 | if lastHeartCheckTime - now > HEART_TIMER_INTERVAL or | 46 | if lastHeartCheckTime - now > HEART_TIMER_INTERVAL or |
30 | now - lastHeartCheckTime > HEART_TIMER_INTERVAL then | 47 | now - lastHeartCheckTime > HEART_TIMER_INTERVAL then |
31 | heartTimeoutCount = heartTimeoutCount + 1 | 48 | heartTimeoutCount = heartTimeoutCount + 1 |
@@ -46,6 +63,7 @@ function _M:update(agent) | @@ -46,6 +63,7 @@ function _M:update(agent) | ||
46 | pcall(check_heart_beat, agent, now) | 63 | pcall(check_heart_beat, agent, now) |
47 | nextCheckTime = now + HEART_TIMER_INTERVAL | 64 | nextCheckTime = now + HEART_TIMER_INTERVAL |
48 | end | 65 | end |
66 | + if not role then return end | ||
49 | pcall(role.onRecoverTimer, role, now) | 67 | pcall(role.onRecoverTimer, role, now) |
50 | end | 68 | end |
51 | 69 | ||
@@ -73,6 +91,7 @@ end | @@ -73,6 +91,7 @@ end | ||
73 | function _M:reset() | 91 | function _M:reset() |
74 | heartTimeoutCount = 0 | 92 | heartTimeoutCount = 0 |
75 | heartQuickCount = 0 | 93 | heartQuickCount = 0 |
94 | + ignoreHeartTime = nil | ||
76 | lastHeartCheckTime = skynet.timex() | 95 | lastHeartCheckTime = skynet.timex() |
77 | end | 96 | end |
78 | 97 |
src/services/poold.lua
@@ -7,14 +7,15 @@ local deque = require "deque" | @@ -7,14 +7,15 @@ local deque = require "deque" | ||
7 | local CMD = {} | 7 | local CMD = {} |
8 | local factory | 8 | local factory |
9 | 9 | ||
10 | +local PRE_FEED_COUNT = 5 | ||
10 | local dead = 0 | 11 | local dead = 0 |
11 | -- agent死亡,通知poold补充,当累计到5个agent时,马上生成5个agent放入poold中 | 12 | -- agent死亡,通知poold补充,当累计到5个agent时,马上生成5个agent放入poold中 |
12 | -- 当然这里也可以写得更复杂,参考redis落地规则 | 13 | -- 当然这里也可以写得更复杂,参考redis落地规则 |
13 | function CMD.feed() | 14 | function CMD.feed() |
14 | dead = dead + 1 | 15 | dead = dead + 1 |
15 | - if dead == 5 then | 16 | + if dead == PRE_FEED_COUNT then |
16 | dead = 0 | 17 | dead = 0 |
17 | - for i=1, 5 do | 18 | + for i=1, PRE_FEED_COUNT do |
18 | factory:push(skynet.newservice("agent")) | 19 | factory:push(skynet.newservice("agent")) |
19 | end | 20 | end |
20 | end | 21 | end |
src/utils/CommonFunc.lua
@@ -161,6 +161,18 @@ function diffFromOpen() | @@ -161,6 +161,18 @@ function diffFromOpen() | ||
161 | return math.floor((now - openTime) / DAY_SEC) | 161 | return math.floor((now - openTime) / DAY_SEC) |
162 | end | 162 | end |
163 | 163 | ||
164 | +function diffFromTs(ts) | ||
165 | + local now = skynet.timex() | ||
166 | + local tm = os.date("*t", ts) | ||
167 | + | ||
168 | + local time = os.time({year = tm.year, month = tm.month, day = tm.day, hour = RESET_TIME}) | ||
169 | + if now < time then | ||
170 | + return 0 | ||
171 | + end | ||
172 | + | ||
173 | + return math.floor((now - time) / DAY_SEC) | ||
174 | +end | ||
175 | + | ||
164 | function getServerOpenTs() | 176 | function getServerOpenTs() |
165 | local openTime = os.time{ | 177 | local openTime = os.time{ |
166 | year = tonum(SERV_OPEN:sub(1,4)), | 178 | year = tonum(SERV_OPEN:sub(1,4)), |
@@ -298,7 +310,7 @@ function notifyClient(params) | @@ -298,7 +310,7 @@ function notifyClient(params) | ||
298 | params.key = "zhaolugame20170831" | 310 | params.key = "zhaolugame20170831" |
299 | 311 | ||
300 | local status, body = httpc.get(skynet.getenv("codeurl"), | 312 | local status, body = httpc.get(skynet.getenv("codeurl"), |
301 | - "/mipush/notify_user?" .. httpGetFormatData(params), {}, {}) | 313 | + "/push/notify_user?" .. httpGetFormatData(params), {}, {}) |
302 | if tonumber(status) ~= 200 then | 314 | if tonumber(status) ~= 200 then |
303 | skynet.error(status, body) | 315 | skynet.error(status, body) |
304 | return | 316 | return |
@@ -313,7 +325,7 @@ function deleteNotify(params) | @@ -313,7 +325,7 @@ function deleteNotify(params) | ||
313 | params.key = "zhaolugame20170831" | 325 | params.key = "zhaolugame20170831" |
314 | 326 | ||
315 | local status, body = httpc.get(skynet.getenv("codeurl"), | 327 | local status, body = httpc.get(skynet.getenv("codeurl"), |
316 | - "/mipush/delete_notify?" .. httpGetFormatData(params), {}, {}) | 328 | + "/push/delete_notify?" .. httpGetFormatData(params), {}, {}) |
317 | if tonumber(status) ~= 200 then | 329 | if tonumber(status) ~= 200 then |
318 | skynet.error(status, body) | 330 | skynet.error(status, body) |
319 | return | 331 | return |
src/utils/StringUtil.lua
@@ -347,4 +347,20 @@ function string.toMap(str, tonum, sep) | @@ -347,4 +347,20 @@ function string.toMap(str, tonum, sep) | ||
347 | end | 347 | end |
348 | end | 348 | end |
349 | return tab | 349 | return tab |
350 | +end | ||
351 | + | ||
352 | +--[[ | ||
353 | +from: 1=2=3=4 | ||
354 | +to: {1,2,3,4} | ||
355 | +]] | ||
356 | +function string.toMap(str, tonum, sep) | ||
357 | + local str_vec = string.split(str, " ") | ||
358 | + local tab = {} | ||
359 | + for _, v in pairs(str_vec) do | ||
360 | + local vec = string.split(v, sep) | ||
361 | + if #vec == 2 then | ||
362 | + tab[vec[1]] = tonum and tonumber(vec[2]) or vec[2] | ||
363 | + end | ||
364 | + end | ||
365 | + return tab | ||
350 | end | 366 | end |
351 | \ No newline at end of file | 367 | \ No newline at end of file |