Commit 9b380e1a9f34eac3824bcb9147d353c6364dec3a
Merge branch 'tr/bugfix' into tr/publish/qa-dev
Showing
32 changed files
with
1489 additions
and
67 deletions
 
Show diff stats
src/GlobalVar.lua
| @@ -80,6 +80,8 @@ ItemType = { | @@ -80,6 +80,8 @@ ItemType = { | ||
| 80 | SpeedBox = 16, -- 加速箱子 | 80 | SpeedBox = 16, -- 加速箱子 | 
| 81 | SelectItemBox = 17, -- 自选箱子 | 81 | SelectItemBox = 17, -- 自选箱子 | 
| 82 | CommonPaster = 18, -- 万能贴纸 | 82 | CommonPaster = 18, -- 万能贴纸 | 
| 83 | + BossTicket = 20, -- boss挑战门票 | ||
| 84 | + Spark = 21, -- 火花 | ||
| 83 | } | 85 | } | 
| 84 | 86 | ||
| 85 | --在这个里面的会记录的是功能开放 对应类型open 而不是 ID | 87 | --在这个里面的会记录的是功能开放 对应类型open 而不是 ID | 
| @@ -310,6 +312,8 @@ CardType = { | @@ -310,6 +312,8 @@ CardType = { | ||
| 310 | PaySignCard = 6, -- 付费签到卡 | 312 | PaySignCard = 6, -- 付费签到卡 | 
| 311 | BattlePassCard = 7, -- 探索指令 | 313 | BattlePassCard = 7, -- 探索指令 | 
| 312 | ActBattleCommandCard = 8, -- 战令活动卡 | 314 | ActBattleCommandCard = 8, -- 战令活动卡 | 
| 315 | + NormalMonthCardLevelUp = 9, -- 月卡升级 | ||
| 316 | + SuperMonthCardLevelUp = 10, -- 超级月卡升级 | ||
| 313 | } | 317 | } | 
| 314 | 318 | ||
| 315 | ShopPackType = { | 319 | ShopPackType = { | 
| @@ -357,6 +361,7 @@ TriggerEventType = { | @@ -357,6 +361,7 @@ TriggerEventType = { | ||
| 357 | SSRCount = 6, | 361 | SSRCount = 6, | 
| 358 | AfterTs = 7, -- 某时间以后 | 362 | AfterTs = 7, -- 某时间以后 | 
| 359 | DrawHeroCnt = 8, -- 每日抽卡次数 | 363 | DrawHeroCnt = 8, -- 每日抽卡次数 | 
| 364 | + Appoint = 0, -- 触发指定id礼包 | ||
| 360 | } | 365 | } | 
| 361 | 366 | ||
| 362 | DrawCardType = { | 367 | DrawCardType = { | 
| @@ -369,7 +374,20 @@ DrawCardType = { | @@ -369,7 +374,20 @@ DrawCardType = { | ||
| 369 | TeamSystemType = { | 374 | TeamSystemType = { | 
| 370 | Hang = 1, | 375 | Hang = 1, | 
| 371 | BonusBattle = 2, | 376 | BonusBattle = 2, | 
| 372 | - Tower = 3, | ||
| 373 | Dinner = 4, | 377 | Dinner = 4, | 
| 374 | FriendBattle = 5, | 378 | FriendBattle = 5, | 
| 375 | -} | ||
| 376 | \ No newline at end of file | 379 | \ No newline at end of file | 
| 380 | +} | ||
| 381 | + | ||
| 382 | +-- 某个功能对其他系统功能的加成类型 | ||
| 383 | +SystemBnousType = { | ||
| 384 | + TowerBuff = 1, -- 电波塔内战斗开始时获得buff | ||
| 385 | + CrusadeTask = 2, -- 讨伐电台任务加速 | ||
| 386 | + DinerGet = 3, -- 食材供应商获取速度 | ||
| 387 | + DinerLimit = 4, -- 食材供应商上限 | ||
| 388 | + DinerSell = 5, -- 料理贩卖速度 | ||
| 389 | + DinerPrice = 6, -- 齿轮价格 | ||
| 390 | + Adv = 7, -- 代理拾荒获得额外道具 | ||
| 391 | + HangTime = 8, -- 挂机时间上限 | ||
| 392 | + PvpTicket = 9, -- 每周额外获得竞技场门票数量 | ||
| 393 | + SweepReward = 10, -- 奖励关卡每次扫荡额外获得道具 | ||
| 394 | +} | 
src/ProtocolCode.lua
| @@ -51,6 +51,8 @@ actionCodes = { | @@ -51,6 +51,8 @@ actionCodes = { | ||
| 51 | Role_broadGetSSR = 135, -- 全服广播 获得ssr英雄 | 51 | Role_broadGetSSR = 135, -- 全服广播 获得ssr英雄 | 
| 52 | Role_renameTeamRpc = 136, -- 编队改名 | 52 | Role_renameTeamRpc = 136, -- 编队改名 | 
| 53 | Role_accuseRpc = 137, -- 举报 | 53 | Role_accuseRpc = 137, -- 举报 | 
| 54 | + Role_loadSparks = 138, | ||
| 55 | + Role_updateSpark = 139, -- 更新火花 | ||
| 54 | 56 | ||
| 55 | Adv_startAdvRpc = 151, | 57 | Adv_startAdvRpc = 151, | 
| 56 | Adv_startHangRpc = 152, | 58 | Adv_startHangRpc = 152, | 
| @@ -102,6 +104,7 @@ actionCodes = { | @@ -102,6 +104,7 @@ actionCodes = { | ||
| 102 | Hero_drawHeroExtraRewardNtf = 224, | 104 | Hero_drawHeroExtraRewardNtf = 224, | 
| 103 | Hero_itemComposeRpc = 225, | 105 | Hero_itemComposeRpc = 225, | 
| 104 | Hero_setWishPoolRpc = 226, | 106 | Hero_setWishPoolRpc = 226, | 
| 107 | + Hero_changeSparkRpc = 227, | ||
| 105 | 108 | ||
| 106 | Hang_startRpc = 251, | 109 | Hang_startRpc = 251, | 
| 107 | Hang_checkRpc = 252, | 110 | Hang_checkRpc = 252, | 
| @@ -145,12 +148,15 @@ actionCodes = { | @@ -145,12 +148,15 @@ actionCodes = { | ||
| 145 | Tower_rankRpc = 353, | 148 | Tower_rankRpc = 353, | 
| 146 | Tower_bugCountRpc = 354, | 149 | Tower_bugCountRpc = 354, | 
| 147 | Tower_rankInfoRpc = 355, | 150 | Tower_rankInfoRpc = 355, | 
| 151 | + Tower_activeTowerBonusRpc = 356, | ||
| 148 | 152 | ||
| 149 | Car_makePotionRpc = 400, | 153 | Car_makePotionRpc = 400, | 
| 150 | Car_equipUpRpc = 401, | 154 | Car_equipUpRpc = 401, | 
| 151 | Car_runeUpRpc = 402, | 155 | Car_runeUpRpc = 402, | 
| 152 | Car_saleEquipRpc = 403, | 156 | Car_saleEquipRpc = 403, | 
| 153 | Car_saleRuneRpc = 404, | 157 | Car_saleRuneRpc = 404, | 
| 158 | + Car_sparkLvlUpRpc = 405, | ||
| 159 | + Car_sparkQualityUpRpc = 406, | ||
| 154 | 160 | ||
| 155 | 161 | ||
| 156 | Friend_searchRpc = 450, | 162 | Friend_searchRpc = 450, | 
| @@ -236,10 +242,18 @@ actionCodes = { | @@ -236,10 +242,18 @@ actionCodes = { | ||
| 236 | Activity_newSignRpc = 670, | 242 | Activity_newSignRpc = 670, | 
| 237 | Activity_advLevelRpc = 671, | 243 | Activity_advLevelRpc = 671, | 
| 238 | Activity_buyBattleCommandLvlRpc = 672, | 244 | Activity_buyBattleCommandLvlRpc = 672, | 
| 245 | + Activity_returnerTaskRpc = 673, | ||
| 239 | 246 | ||
| 240 | Radio_startQuestRpc = 700, | 247 | Radio_startQuestRpc = 700, | 
| 241 | Radio_finishQuestRpc = 701, | 248 | Radio_finishQuestRpc = 701, | 
| 242 | Radio_cancelQuestRpc = 702, | 249 | Radio_cancelQuestRpc = 702, | 
| 250 | + | ||
| 251 | + Seaport_getServerProcessRpc = 750, | ||
| 252 | + Seaport_donateRpc = 751, | ||
| 253 | + Seaport_donateRewardRpc = 752, | ||
| 254 | + Seaport_taskRpc = 753, | ||
| 255 | + Seaport_shopRpc = 754, | ||
| 256 | + Seaport_resetRpc = 755, | ||
| 243 | } | 257 | } | 
| 244 | 258 | ||
| 245 | rpcResponseBegin = 10000 | 259 | rpcResponseBegin = 10000 | 
src/RedisKeys.lua
| @@ -14,6 +14,8 @@ R_EMAIL_ITEM = "email:%d:%d" --邮件 | @@ -14,6 +14,8 @@ R_EMAIL_ITEM = "email:%d:%d" --邮件 | ||
| 14 | R_STORE = "role:%d:store" -- 商店 | 14 | R_STORE = "role:%d:store" -- 商店 | 
| 15 | R_ORDERS = "role:%d:orders" -- 订单 | 15 | R_ORDERS = "role:%d:orders" -- 订单 | 
| 16 | R_ORDER = "order:%d:%d" | 16 | R_ORDER = "order:%d:%d" | 
| 17 | +R_SPARKIDS = "role:%d:sparkIds" -- 玩家拥有火花自增id | ||
| 18 | +R_SPARK = "role:%d:spark:%d" -- 火花详细信息 | ||
| 17 | 19 | ||
| 18 | -- 通用排行榜 | 20 | -- 通用排行榜 | 
| 19 | RANK_COMMON = "rank:common:" | 21 | RANK_COMMON = "rank:common:" | 
| @@ -26,6 +28,15 @@ RANK_TYPE = { | @@ -26,6 +28,15 @@ RANK_TYPE = { | ||
| 26 | RANK_TOWER = "rank:tower" | 28 | RANK_TOWER = "rank:tower" | 
| 27 | RANK_TOWER_INFO = "rank:tower:info" | 29 | RANK_TOWER_INFO = "rank:tower:info" | 
| 28 | 30 | ||
| 31 | +RANK_TOWER1 = "rank:tower1" | ||
| 32 | +RANK_TOWER1_INFO = "rank:tower1:info" | ||
| 33 | + | ||
| 34 | +RANK_TOWER2 = "rank:tower2" | ||
| 35 | +RANK_TOWER2_INFO = "rank:tower2:info" | ||
| 36 | + | ||
| 37 | +RANK_TOWER3 = "rank:tower3" | ||
| 38 | +RANK_TOWER3_INFO = "rank:tower3:info" | ||
| 39 | + | ||
| 29 | -- adv | 40 | -- adv | 
| 30 | RANK_ADV = {"rank:adv1", "rank:adv2"} | 41 | RANK_ADV = {"rank:adv1", "rank:adv2"} | 
| 31 | RANK_ADV_INFO = "rank:adv:info" | 42 | RANK_ADV_INFO = "rank:adv:info" | 
| @@ -40,8 +51,8 @@ RANK_PVP_HIGHT = "rank:pvph" | @@ -40,8 +51,8 @@ RANK_PVP_HIGHT = "rank:pvph" | ||
| 40 | RANK_PVP_HIGHT_KEY = {"rank:pvph1", "rank:pvph2"} | 51 | RANK_PVP_HIGHT_KEY = {"rank:pvph1", "rank:pvph2"} | 
| 41 | RECORD_PVP_HIGH = "record:pvph:%d" | 52 | RECORD_PVP_HIGH = "record:pvph:%d" | 
| 42 | 53 | ||
| 43 | - | ||
| 44 | - | 54 | +SEAPORT_TRADE_TASK_1 = "seaport:task1" | 
| 55 | +SEAPORT_TRADE_TASK_2 = "seaport:task2" | ||
| 45 | 56 | ||
| 46 | FRIEND_KEY = "role:%d:friend" --哈希表 好友 | 57 | FRIEND_KEY = "role:%d:friend" --哈希表 好友 | 
| 47 | FRIEND_APPLY_KEY = "role:%d:apply" -- sort set 申请列表 | 58 | FRIEND_APPLY_KEY = "role:%d:apply" -- sort set 申请列表 | 
src/actions/ActivityAction.lua
| @@ -1370,4 +1370,52 @@ function _M.advLevelRpc(agent, data) | @@ -1370,4 +1370,52 @@ function _M.advLevelRpc(agent, data) | ||
| 1370 | return true | 1370 | return true | 
| 1371 | end | 1371 | end | 
| 1372 | 1372 | ||
| 1373 | +function _M.returnerTaskRpc(agent, data) | ||
| 1374 | + local role = agent.role | ||
| 1375 | + local msg = MsgPack.unpack(data) | ||
| 1376 | + | ||
| 1377 | + local taskId = msg.id or 0 | ||
| 1378 | + if taskId == 0 then return 0 end | ||
| 1379 | + | ||
| 1380 | + local returner = role:getProperty("returner") or {} | ||
| 1381 | + if not returner[taskId] then return 1 end | ||
| 1382 | + | ||
| 1383 | + local tday = specTime({hour = 4}) | ||
| 1384 | + local curAllDay = (tday - returner.time) / 86400 + 1 | ||
| 1385 | + | ||
| 1386 | + local TaskCsv = csvdb["activity_taskCsv"][76] or {} | ||
| 1387 | + local taskData = TaskCsv[taskId] | ||
| 1388 | + if not taskData then return 2 end | ||
| 1389 | + if curAllDay < taskData.day then return 2 end | ||
| 1390 | + | ||
| 1391 | + local status = returner.status or {} | ||
| 1392 | + if status[taskId] then return 3 end | ||
| 1393 | + | ||
| 1394 | + status[taskId] = 1 | ||
| 1395 | + returner.status = status | ||
| 1396 | + | ||
| 1397 | + local done = true | ||
| 1398 | + for _, data in pairs(TaskCsv) do | ||
| 1399 | + if not status[data.id] then | ||
| 1400 | + done = false | ||
| 1401 | + break | ||
| 1402 | + end | ||
| 1403 | + end | ||
| 1404 | + | ||
| 1405 | + if done then | ||
| 1406 | + returner = {} | ||
| 1407 | + end | ||
| 1408 | + | ||
| 1409 | + local reward, change = role:award(taskData.reward, {log = {desc = "returner", int1 = taskData.day, int2 = taskId}}) | ||
| 1410 | + | ||
| 1411 | + local pack = globalCsv.returner_pack:toArray(true,"=") | ||
| 1412 | + if pack[1] == taskData.id then | ||
| 1413 | + role:checkTaskEnter("Appoint", {id = pack[2]}) | ||
| 1414 | + end | ||
| 1415 | + | ||
| 1416 | + role:updateProperty({field = "returner", value = returner}) | ||
| 1417 | + SendPacket(actionCodes.Activity_returnerTaskRpc, MsgPack.pack(role:packReward(reward, change))) | ||
| 1418 | + return true | ||
| 1419 | +end | ||
| 1420 | + | ||
| 1373 | return _M | 1421 | return _M | 
src/actions/AdvAction.lua
| @@ -278,6 +278,7 @@ function _M.startHangRpc(agent, data) | @@ -278,6 +278,7 @@ function _M.startHangRpc(agent, data) | ||
| 278 | end | 278 | end | 
| 279 | adv_idle_time = adv_idle_time * 60 | 279 | adv_idle_time = adv_idle_time * 60 | 
| 280 | 280 | ||
| 281 | + | ||
| 281 | local advHang = role:getProperty("advHang") | 282 | local advHang = role:getProperty("advHang") | 
| 282 | if advHang[chapterId] then return 3 end --正在挂机 | 283 | if advHang[chapterId] then return 3 end --正在挂机 | 
| 283 | 284 | ||
| @@ -463,6 +464,15 @@ function _M.endHangRpc(agent, data) | @@ -463,6 +464,15 @@ function _M.endHangRpc(agent, data) | ||
| 463 | for itemId, count in pairs(idleReward) do | 464 | for itemId, count in pairs(idleReward) do | 
| 464 | idleReward[itemId] = count * adv_idle_reward_coef | 465 | idleReward[itemId] = count * adv_idle_reward_coef | 
| 465 | end | 466 | end | 
| 467 | + | ||
| 468 | + local bnousReward = role:getBnousAdv() | ||
| 469 | + for time, set in pairs(bnousReward) do | ||
| 470 | + local delta = math.floor(adv_idle_time / time) | ||
| 471 | + for key, value in pairs(set) do | ||
| 472 | + idleReward[key] = (idleReward[key] or 0) + value * delta | ||
| 473 | + end | ||
| 474 | + end | ||
| 475 | + | ||
| 466 | reward, change = role:award(idleReward, {log = {desc = "advHang", int1 = chapterId}}) | 476 | reward, change = role:award(idleReward, {log = {desc = "advHang", int1 = chapterId}}) | 
| 467 | else | 477 | else | 
| 468 | if cancel then | 478 | if cancel then | 
src/actions/CarAction.lua
| @@ -211,4 +211,92 @@ function _M.saleRuneRpc(agent, data ) | @@ -211,4 +211,92 @@ function _M.saleRuneRpc(agent, data ) | ||
| 211 | return true | 211 | return true | 
| 212 | end | 212 | end | 
| 213 | 213 | ||
| 214 | +function _M.sparkQualityUpRpc( agent, data ) | ||
| 215 | + local role = agent.role | ||
| 216 | + local msg = MsgPack.unpack(data) | ||
| 217 | + local uid = msg.uid | ||
| 218 | + local ownSpark = role.sparkBag[uid] | ||
| 219 | + if not ownSpark then return 1 end | ||
| 220 | + | ||
| 221 | + | ||
| 222 | + local cfg_id = ownSpark:getProperty("cfg_id") | ||
| 223 | + local level = ownSpark:getProperty("level") | ||
| 224 | + | ||
| 225 | + local sparkSet = csvdb["sparkCsv"][cfg_id] | ||
| 226 | + if not sparkSet then return 4 end | ||
| 227 | + local sparkData = sparkSet[level] | ||
| 228 | + if not sparkData then return 5 end | ||
| 229 | + | ||
| 230 | + if sparkData.star_up == 0 then return 6 end | ||
| 231 | + local cost = sparkData.star_item:toNumMap() | ||
| 232 | + if not role:checkItemEnough(cost) then | ||
| 233 | + return 7 | ||
| 234 | + end | ||
| 235 | + | ||
| 236 | + role:costItems(cost, {log = {desc = "sparkQualityUp", int1 = uid, int2 = level}}) | ||
| 237 | + | ||
| 238 | + local newSet = csvdb["sparkCsv"][sparkData.star_up] | ||
| 239 | + if not newSet then return 8 end | ||
| 240 | + local newSparkData = newSet[0] | ||
| 241 | + if not newSparkData then return 9 end | ||
| 242 | + local attrs = newSparkData.attr:toNumMap() | ||
| 243 | + ownSpark:addAttr(attrs) | ||
| 244 | + ownSpark:updateProperty({field = "level",value = 0}) | ||
| 245 | + ownSpark:updateProperty({field = "cfg_id",value = sparkData.star_up}) | ||
| 246 | + --role:checkTaskEnter("SparkQualityUp") | ||
| 247 | + | ||
| 248 | + | ||
| 249 | + ownSpark:mylog({desc = "sparkQualityUp", int1 = sparkData.id , int2 = sparkData.star_up}) | ||
| 250 | + | ||
| 251 | + SendPacket(actionCodes.Car_sparkQualityUpRpc, '') | ||
| 252 | + return true | ||
| 253 | +end | ||
| 254 | + | ||
| 255 | +function _M.sparkLvlUpRpc( agent, data ) | ||
| 256 | + local role = agent.role | ||
| 257 | + local msg = MsgPack.unpack(data) | ||
| 258 | + local uid = msg.uid | ||
| 259 | + local ownSpark = role.sparkBag[uid] | ||
| 260 | + if not ownSpark then return 1 end | ||
| 261 | + | ||
| 262 | + | ||
| 263 | + local cfg_id = ownSpark:getProperty("cfg_id") | ||
| 264 | + local level = ownSpark:getProperty("level") | ||
| 265 | + | ||
| 266 | + local sparkSet = csvdb["sparkCsv"][cfg_id] | ||
| 267 | + if not sparkSet then return 4 end | ||
| 268 | + local sparkData = sparkSet[level] | ||
| 269 | + if not sparkData then return 5 end | ||
| 270 | + | ||
| 271 | + if level >= #sparkSet then return 6 end | ||
| 272 | + local cost = sparkData.lv_up_item:toNumMap() | ||
| 273 | + if not role:checkItemEnough(cost) then | ||
| 274 | + return 7 | ||
| 275 | + end | ||
| 276 | + local weight = math.random(0, 100) | ||
| 277 | + local addLvl = 1 | ||
| 278 | + if weight < sparkData.probability then | ||
| 279 | + addLvl = 2 | ||
| 280 | + end | ||
| 281 | + | ||
| 282 | + role:costItems(cost, {log = {desc = "sparkLvlUp", int1 = uid, int2 = level}}) | ||
| 283 | + local attrs = {} | ||
| 284 | + for i = 1, addLvl do | ||
| 285 | + local cfg = sparkSet[level + i] | ||
| 286 | + if not cfg then break end | ||
| 287 | + for k, v in pairs(cfg.attr:toNumMap()) do | ||
| 288 | + attrs[k] = (attrs[k] or 0) + v | ||
| 289 | + end | ||
| 290 | + end | ||
| 291 | + ownSpark:addAttr(attrs) | ||
| 292 | + ownSpark:updateProperty({field = "level",value = level+addLvl}) | ||
| 293 | + --role:checkTaskEnter("SparkLvlUp") | ||
| 294 | + | ||
| 295 | + | ||
| 296 | + ownSpark:mylog({desc = "sparkLvlUp", int1 = level + addLvl}) | ||
| 297 | + | ||
| 298 | + SendPacket(actionCodes.Car_sparkLvlUpRpc, MsgPack.pack({big = (addLvl == 2)})) | ||
| 299 | + return true | ||
| 300 | +end | ||
| 301 | + | ||
| 214 | return _M | 302 | return _M | 
| 215 | \ No newline at end of file | 303 | \ No newline at end of file | 
src/actions/DinerAction.lua
| @@ -75,7 +75,8 @@ function _M.addSellRpc( agent, data ) | @@ -75,7 +75,8 @@ 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() | 78 | + local timeSub = role:getBnousDiner(3,dishData.sell_time) | 
| 79 | + local needTime = sells[slot].count * (dishData.sell_time + timeSub) + sells[slot].time - skynet.timex() | ||
| 79 | role:pushMsg({type = "food", slot = slot, time = needTime}) | 80 | role:pushMsg({type = "food", slot = slot, time = needTime}) | 
| 80 | 81 | ||
| 81 | -- 检查解锁的顾客 | 82 | -- 检查解锁的顾客 | 
| @@ -742,11 +743,15 @@ function _M.getGreenhouseRpc( agent, data ) | @@ -742,11 +743,15 @@ function _M.getGreenhouseRpc( agent, data ) | ||
| 742 | local now = skynet.timex() | 743 | local now = skynet.timex() | 
| 743 | local gfood = role.dinerData:getProperty("gfood") | 744 | local gfood = role.dinerData:getProperty("gfood") | 
| 744 | if not next(gfood) then return end | 745 | if not next(gfood) then return end | 
| 746 | + | ||
| 747 | + local timeAdd = role:getBnousDiner(2,globalCsv.diner_get_food_time_max) | ||
| 748 | + | ||
| 745 | for k , v in pairs(gfood) do | 749 | for k , v in pairs(gfood) do | 
| 746 | local itemId = v.id | 750 | local itemId = v.id | 
| 747 | local st = v.st | 751 | local st = v.st | 
| 748 | local speed = globalCsv.diner_get_food_speed[csvdb["itemCsv"][itemId].quality] * buildingData.speed / 100 | 752 | local speed = globalCsv.diner_get_food_speed[csvdb["itemCsv"][itemId].quality] * buildingData.speed / 100 | 
| 749 | - local endTime = st + globalCsv.diner_get_food_time_max | 753 | + speed = speed + role:getBnousDiner(1,speed) | 
| 754 | + local endTime = st + globalCsv.diner_get_food_time_max + timeAdd | ||
| 750 | local endTime2 = math.min(now, endTime) | 755 | local endTime2 = math.min(now, endTime) | 
| 751 | reward[itemId] = math.floor((endTime2 - st) / speed) | 756 | reward[itemId] = math.floor((endTime2 - st) / speed) | 
| 752 | if endTime2 == endTime then | 757 | if endTime2 == endTime then | 
src/actions/GmAction.lua
| @@ -166,6 +166,15 @@ function _M.rune(role, pms) | @@ -166,6 +166,15 @@ function _M.rune(role, pms) | ||
| 166 | return result | 166 | return result | 
| 167 | end | 167 | end | 
| 168 | 168 | ||
| 169 | +table.insert(helpDes, {"获得火花" , "spark", "零件id"}) | ||
| 170 | +function _M.spark(role, pms) | ||
| 171 | + local id = tonum(pms.pm1) | ||
| 172 | + local result = role:addSpark({id = id, log = {desc = "gm"}}) | ||
| 173 | + role:mylog("gm_action", {desc = "spark", int1 = id, key1 = pms.sender}) | ||
| 174 | + | ||
| 175 | + return result == 0 and "成功" or "失败" | ||
| 176 | +end | ||
| 177 | + | ||
| 169 | table.insert(helpDes, {"通关挂机副本", "fb", "挂卡id"}) | 178 | table.insert(helpDes, {"通关挂机副本", "fb", "挂卡id"}) | 
| 170 | function _M.fb(role, pms) -- 直接通关 | 179 | function _M.fb(role, pms) -- 直接通关 | 
| 171 | local carbonId = tonum(pms.pm1) | 180 | local carbonId = tonum(pms.pm1) | 
| @@ -483,13 +492,25 @@ function _M.advit(role, pms) | @@ -483,13 +492,25 @@ function _M.advit(role, pms) | ||
| 483 | end | 492 | end | 
| 484 | 493 | ||
| 485 | 494 | ||
| 486 | -table.insert(helpDes, {"爬塔到指定层", "tower", "层数"}) | 495 | +table.insert(helpDes, {"爬塔到指定层", "tower", "塔id", "层数"}) | 
| 487 | function _M.tower(role, pms) | 496 | function _M.tower(role, pms) | 
| 488 | - local level = tonum(pms.pm1, 1) | 497 | + local tType = tonum(pms.pm1, 1) | 
| 498 | + local level = tonum(pms.pm2, 1) | ||
| 499 | + local layer = (tType - 1) * 10000 + level | ||
| 489 | if not csvdb["tower_battleCsv"][level] then return "不存在" end | 500 | if not csvdb["tower_battleCsv"][level] then return "不存在" end | 
| 490 | - role:updateProperty({field = "towerInfo", value = {c = globalCsv.tower_count_limit, l = level}}) | 501 | + local values = role:getProperty("towerInfo") | 
| 502 | + if tType == 1 then | ||
| 503 | + values.l = layer | ||
| 504 | + elseif tType == 2 then | ||
| 505 | + values.l1 = layer | ||
| 506 | + elseif tType == 3 then | ||
| 507 | + values.l2 = layer | ||
| 508 | + elseif tType == 4 then | ||
| 509 | + values.l3 = layer | ||
| 510 | + end | ||
| 511 | + role:updateProperty({field = "towerInfo", value = values}) | ||
| 491 | 512 | ||
| 492 | - role:mylog("gm_action", {desc = "tower", int1 = level, key1 = pms.sender}) | 513 | + role:mylog("gm_action", {desc = "tower", int1 = tType, int2 = layer, key1 = pms.sender}) | 
| 493 | 514 | ||
| 494 | return "成功" | 515 | return "成功" | 
| 495 | end | 516 | end | 
| @@ -582,6 +603,13 @@ function _M.clearbag(role, pms) | @@ -582,6 +603,13 @@ function _M.clearbag(role, pms) | ||
| 582 | end | 603 | end | 
| 583 | role:delRunes(uids, {log = {desc = "gm"}}) | 604 | role:delRunes(uids, {log = {desc = "gm"}}) | 
| 584 | 605 | ||
| 606 | + -- 火花 | ||
| 607 | + uids = {} | ||
| 608 | + for uid, _ in pairs(role.sparkBag) do | ||
| 609 | + table.insert(uids, uid) | ||
| 610 | + end | ||
| 611 | + role:delSparks(uids, {log = {desc = "gm"}}) | ||
| 612 | + | ||
| 585 | return "成功" | 613 | return "成功" | 
| 586 | end | 614 | end | 
| 587 | 615 | 
src/actions/HangAction.lua
| @@ -326,6 +326,7 @@ function _M.roleFormatRpc(agent , data) | @@ -326,6 +326,7 @@ function _M.roleFormatRpc(agent , data) | ||
| 326 | local index = msg.index -- 阵容索引 | 326 | local index = msg.index -- 阵容索引 | 
| 327 | local title = msg.title -- 阵容名称 | 327 | local title = msg.title -- 阵容名称 | 
| 328 | local tactics = msg.tactics -- 战术 | 328 | local tactics = msg.tactics -- 战术 | 
| 329 | + local tower = msg.tower | ||
| 329 | local team = {} | 330 | local team = {} | 
| 330 | for slot, heroId in pairs(msg.heros) do | 331 | for slot, heroId in pairs(msg.heros) do | 
| 331 | if not role.heros[heroId] then | 332 | if not role.heros[heroId] then | 
| @@ -361,7 +362,11 @@ function _M.roleFormatRpc(agent , data) | @@ -361,7 +362,11 @@ function _M.roleFormatRpc(agent , data) | ||
| 361 | team.tactics = msg.tactics | 362 | team.tactics = msg.tactics | 
| 362 | end | 363 | end | 
| 363 | 364 | ||
| 364 | - role:setTeamFormat(index, team) | 365 | + if tower then | 
| 366 | + role:setTowerTeamFormat(index, team) | ||
| 367 | + else | ||
| 368 | + role:setTeamFormat(index, team) | ||
| 369 | + end | ||
| 365 | 370 | ||
| 366 | SendPacket(actionCodes.Hang_roleFormatRpc, '') | 371 | SendPacket(actionCodes.Hang_roleFormatRpc, '') | 
| 367 | return true | 372 | return true | 
| @@ -376,8 +381,9 @@ function _M.getRewardRpc(agent , data) | @@ -376,8 +381,9 @@ function _M.getRewardRpc(agent , data) | ||
| 376 | table.clear(items) | 381 | table.clear(items) | 
| 377 | local hangInfo = role:getProperty("hangInfo") | 382 | local hangInfo = role:getProperty("hangInfo") | 
| 378 | local nowTime = skynet.timex() | 383 | local nowTime = skynet.timex() | 
| 379 | - hangInfo.endItemTime = nowTime + globalCsv.idle_producetime_max | ||
| 380 | - hangInfo.endCoinTime = nowTime + globalCsv.idle_producetime_max | 384 | + local timeAdd = role:getBnousHangTime() | 
| 385 | + hangInfo.endItemTime = nowTime + globalCsv.idle_producetime_max + timeAdd | ||
| 386 | + hangInfo.endCoinTime = nowTime + globalCsv.idle_producetime_max + timeAdd | ||
| 381 | hangInfo.coinTime = nowTime | 387 | hangInfo.coinTime = nowTime | 
| 382 | hangInfo.itemTime = nowTime | 388 | hangInfo.itemTime = nowTime | 
| 383 | role:updateProperty({field = "hangBag", value = items}) | 389 | role:updateProperty({field = "hangBag", value = items}) | 
| @@ -508,7 +514,7 @@ function _M.buyBonusCountRpc(agent, data) | @@ -508,7 +514,7 @@ function _M.buyBonusCountRpc(agent, data) | ||
| 508 | return true | 514 | return true | 
| 509 | end | 515 | end | 
| 510 | 516 | ||
| 511 | -local function bonusWinReward(role, bonusData, rewardType, count) | 517 | +local function bonusWinReward(role, bonusData, rewardType, count, sweep) | 
| 512 | count = count or 1 | 518 | count = count or 1 | 
| 513 | 519 | ||
| 514 | local reward, change = {} | 520 | local reward, change = {} | 
| @@ -548,6 +554,13 @@ local function bonusWinReward(role, bonusData, rewardType, count) | @@ -548,6 +554,13 @@ local function bonusWinReward(role, bonusData, rewardType, count) | ||
| 548 | end | 554 | end | 
| 549 | end | 555 | end | 
| 550 | 556 | ||
| 557 | + if sweep then | ||
| 558 | + local bnousReward = role:getBnousSweep() | ||
| 559 | + for key, value in pairs(bnousReward) do | ||
| 560 | + reward[key] = (reward[key] or 0) + value * count | ||
| 561 | + end | ||
| 562 | + end | ||
| 563 | + | ||
| 551 | reward, change = role:award(reward, {log = {desc = "bonusBattle", int1 = bonusData.id}}) | 564 | reward, change = role:award(reward, {log = {desc = "bonusBattle", int1 = bonusData.id}}) | 
| 552 | role:checkTaskEnter("BonusPass", {id = bonusData.id, count = count}) | 565 | role:checkTaskEnter("BonusPass", {id = bonusData.id, count = count}) | 
| 553 | return reward, change | 566 | return reward, change | 
| @@ -589,7 +602,7 @@ function _M.startBonusBattleRpc(agent, data) | @@ -589,7 +602,7 @@ function _M.startBonusBattleRpc(agent, data) | ||
| 589 | bonusC[bonusData.type]["c"] = bonusC[bonusData.type]["c"] + count | 602 | bonusC[bonusData.type]["c"] = bonusC[bonusData.type]["c"] + count | 
| 590 | role.dailyData:updateProperty({field = "bonusC", value = bonusC}) | 603 | role.dailyData:updateProperty({field = "bonusC", value = bonusC}) | 
| 591 | 604 | ||
| 592 | - local reward, change = bonusWinReward(role, bonusData, 3, count) | 605 | + local reward, change = bonusWinReward(role, bonusData, 3, count, true) | 
| 593 | SendPacket(actionCodes.Hang_startBonusBattleRpc, MsgPack.pack({reward = reward, change = change})) | 606 | SendPacket(actionCodes.Hang_startBonusBattleRpc, MsgPack.pack({reward = reward, change = change})) | 
| 594 | 607 | ||
| 595 | role:checkTaskEnter("BonusQuick", {count = count}) | 608 | role:checkTaskEnter("BonusQuick", {count = count}) | 
src/actions/HeroAction.lua
| @@ -105,6 +105,25 @@ function _M.wakeRpc(agent, data) | @@ -105,6 +105,25 @@ function _M.wakeRpc(agent, data) | ||
| 105 | if not role:checkItemEnough(cost) then | 105 | if not role:checkItemEnough(cost) then | 
| 106 | return 4 | 106 | return 4 | 
| 107 | end | 107 | end | 
| 108 | + local curLevel = hero:getProperty("wakeL") | ||
| 109 | + local sparkInfo = hero:getProperty("spark") | ||
| 110 | + -- 大于等于7的时候需要装备火花才能升 | ||
| 111 | + if curLevel >= 7 then | ||
| 112 | + if #sparkInfo == 0 then | ||
| 113 | + return 5 | ||
| 114 | + end | ||
| 115 | + local ok = false | ||
| 116 | + for _, info in ipairs(sparkInfo) do | ||
| 117 | + local cfg = csvdb["sparkCsv"][info.cfg_id][info.level or 0] | ||
| 118 | + if not cfg then return 6 end | ||
| 119 | + if cfg.star == curLevel then | ||
| 120 | + ok = true | ||
| 121 | + break | ||
| 122 | + end | ||
| 123 | + end | ||
| 124 | + if not ok then return 7 end | ||
| 125 | + end | ||
| 126 | + | ||
| 108 | 127 | ||
| 109 | role:costItems(cost, {log = {desc = "heroWake", int1 = msg.id, int2 = hero:getProperty("type")}}) | 128 | role:costItems(cost, {log = {desc = "heroWake", int1 = msg.id, int2 = hero:getProperty("type")}}) | 
| 110 | 129 | ||
| @@ -112,7 +131,6 @@ function _M.wakeRpc(agent, data) | @@ -112,7 +131,6 @@ function _M.wakeRpc(agent, data) | ||
| 112 | local oldBattleV = hero:getProperty("battleV") | 131 | local oldBattleV = hero:getProperty("battleV") | 
| 113 | hero:updateProperty({field = "wakeL", delta = 1}) | 132 | hero:updateProperty({field = "wakeL", delta = 1}) | 
| 114 | 133 | ||
| 115 | - local curLevel = hero:getProperty("wakeL") | ||
| 116 | role:checkTaskEnter("Wake", {heroType = typ, wakeL = curLevel}) | 134 | role:checkTaskEnter("Wake", {heroType = typ, wakeL = curLevel}) | 
| 117 | if curLevel == 3 then -- 解锁cg | 135 | if curLevel == 3 then -- 解锁cg | 
| 118 | role:checkTaskEnter("WakeCG", {heroType = typ}) | 136 | role:checkTaskEnter("WakeCG", {heroType = typ}) | 
| @@ -1193,4 +1211,52 @@ function _M.setWishPoolRpc(agent, data) | @@ -1193,4 +1211,52 @@ function _M.setWishPoolRpc(agent, data) | ||
| 1193 | return true | 1211 | return true | 
| 1194 | end | 1212 | end | 
| 1195 | 1213 | ||
| 1214 | +function _M.changeSparkRpc(agent, data) | ||
| 1215 | + local role = agent.role | ||
| 1216 | + local msg = MsgPack.unpack(data) | ||
| 1217 | + | ||
| 1218 | + local idx = msg.index | ||
| 1219 | + local sparkId = msg.spark_id | ||
| 1220 | + local heroId = msg.hero_id | ||
| 1221 | + local hero = role.heros[heroId] | ||
| 1222 | + if not hero then return 1 end | ||
| 1223 | + | ||
| 1224 | + local spark = role.sparkBag[sparkId] | ||
| 1225 | + if not spark then return 2 end | ||
| 1226 | + | ||
| 1227 | + local lvl = spark:getProperty("level") | ||
| 1228 | + local cfgId = spark:getProperty("cfg_id") | ||
| 1229 | + | ||
| 1230 | + local dataSet = csvdb["sparkCsv"][cfgId] | ||
| 1231 | + if not dataSet then return 3 end | ||
| 1232 | + local cfg = dataSet[lvl] | ||
| 1233 | + if not cfg then return 4 end | ||
| 1234 | + | ||
| 1235 | + if hero:getProperty("wakeL") < cfg.star then return 5 end | ||
| 1236 | + | ||
| 1237 | + local itemCfg = csvdb["itemCsv"][cfgId] | ||
| 1238 | + if not itemCfg then return 6 end | ||
| 1239 | + if itemCfg.quality ~= hero:getRare() then return 6 end | ||
| 1240 | + | ||
| 1241 | + local sparkList = hero:getProperty("spark") or {} | ||
| 1242 | + local oldSparkInfo = sparkList[idx] or {} | ||
| 1243 | + sparkList[idx] = spark:data() | ||
| 1244 | + hero:updateProperty({field="spark", value=sparkList}) | ||
| 1245 | + | ||
| 1246 | + role:delSparks({sparkId}, {log = {desc = "changeSpark"}}) | ||
| 1247 | + local oldId = oldSparkInfo["cfg_id"] or 0 | ||
| 1248 | + local oldLevel = oldSparkInfo["level"] or 0 | ||
| 1249 | + local oldSparkSet = csvdb["sparkCsv"][oldId] | ||
| 1250 | + local reward = {} | ||
| 1251 | + if oldSparkSet then | ||
| 1252 | + local oldSparkCfg = oldSparkSet[oldLevel] | ||
| 1253 | + if oldSparkSet then | ||
| 1254 | + reward = oldSparkCfg.back:toNumMap() | ||
| 1255 | + end | ||
| 1256 | + end | ||
| 1257 | + | ||
| 1258 | + SendPacket(actionCodes.Hero_changeSparkRpc, MsgPack.pack({reward = reward})) | ||
| 1259 | + return true | ||
| 1260 | +end | ||
| 1261 | + | ||
| 1196 | return _M | 1262 | return _M | 
src/actions/RadioAction.lua
| @@ -95,8 +95,9 @@ function _M.startQuestRpc(agent, data) | @@ -95,8 +95,9 @@ function _M.startQuestRpc(agent, data) | ||
| 95 | return 5 | 95 | return 5 | 
| 96 | end | 96 | end | 
| 97 | -- start quest, set finish time | 97 | -- start quest, set finish time | 
| 98 | + local timeSub = role:getBnousCrusade(config.time) | ||
| 98 | local taskData = {} | 99 | local taskData = {} | 
| 99 | - taskData["time"] = skynet.timex() + config.time | 100 | + taskData["time"] = skynet.timex() + config.time + timeSub | 
| 100 | taskData["heros"] = heros | 101 | taskData["heros"] = heros | 
| 101 | radioTask[id] = taskData | 102 | radioTask[id] = taskData | 
| 102 | role:updateProperty({field="radioTask", value=radioTask, notNotify=true}) | 103 | role:updateProperty({field="radioTask", value=radioTask, notNotify=true}) | 
src/actions/RoleAction.lua
| @@ -16,6 +16,7 @@ local httpc = require("http.httpc") | @@ -16,6 +16,7 @@ local httpc = require("http.httpc") | ||
| 16 | 16 | ||
| 17 | local WAVE_HERO_NUMS = 150 | 17 | local WAVE_HERO_NUMS = 150 | 
| 18 | local WAVE_RUNE_NUMS = 150 | 18 | local WAVE_RUNE_NUMS = 150 | 
| 19 | +local WAVE_SPARK_NUMS = 150 | ||
| 19 | 20 | ||
| 20 | local function validName(name) | 21 | local function validName(name) | 
| 21 | name = string.upper(name) | 22 | name = string.upper(name) | 
| @@ -159,6 +160,7 @@ function _M.loginRpc( agent, data ) | @@ -159,6 +160,7 @@ function _M.loginRpc( agent, data ) | ||
| 159 | role:changeStructVersion() -- 数据结构 版本更新 | 160 | role:changeStructVersion() -- 数据结构 版本更新 | 
| 160 | role:getAdvData(true) -- 清掉不合格的数据 | 161 | role:getAdvData(true) -- 清掉不合格的数据 | 
| 161 | role:advEndlessSeasonCheck(true) -- 冒险赛季更新检查 | 162 | role:advEndlessSeasonCheck(true) -- 冒险赛季更新检查 | 
| 163 | + role:checkSeaportTrade() -- 检查海港贸易季活动 | ||
| 162 | 164 | ||
| 163 | -- 跨天登陆事件 | 165 | -- 跨天登陆事件 | 
| 164 | local resetMode = role:updateTimeReset(now) | 166 | local resetMode = role:updateTimeReset(now) | 
| @@ -203,6 +205,16 @@ function _M.loginRpc( agent, data ) | @@ -203,6 +205,16 @@ function _M.loginRpc( agent, data ) | ||
| 203 | table_insert(modules, "runeBag") | 205 | table_insert(modules, "runeBag") | 
| 204 | end | 206 | end | 
| 205 | 207 | ||
| 208 | + local sparkIds = {} | ||
| 209 | + for id ,_ in pairs(role.sparkBag) do | ||
| 210 | + table.insert(sparkIds, id) | ||
| 211 | + end | ||
| 212 | + local sparkWave = math.ceil(#sparkIds / WAVE_SPARK_NUMS) | ||
| 213 | + if #sparkIds <= 50 then | ||
| 214 | + sparkWave = 0 | ||
| 215 | + table_insert(modules, "sparkBag") | ||
| 216 | + end | ||
| 217 | + | ||
| 206 | for _, name in ipairs(modules) do | 218 | for _, name in ipairs(modules) do | 
| 207 | response[name] = {} | 219 | response[name] = {} | 
| 208 | for id, unit in pairs(role[name]) do | 220 | for id, unit in pairs(role[name]) do | 
| @@ -210,12 +222,29 @@ function _M.loginRpc( agent, data ) | @@ -210,12 +222,29 @@ function _M.loginRpc( agent, data ) | ||
| 210 | end | 222 | end | 
| 211 | end | 223 | end | 
| 212 | 224 | ||
| 213 | - response.wave = 1 + heroWave + runeWave + 1 | 225 | + response.wave = 1 + heroWave + runeWave + sparkWave + 1 | 
| 214 | 226 | ||
| 215 | SendPacket(actionCodes.Role_loginRpc, MsgPack.pack(response)) | 227 | SendPacket(actionCodes.Role_loginRpc, MsgPack.pack(response)) | 
| 216 | 228 | ||
| 217 | local curWave = 1 | 229 | local curWave = 1 | 
| 218 | 230 | ||
| 231 | + local sparkIndex = 1 | ||
| 232 | + for index = curWave + 1, curWave + sparkWave do | ||
| 233 | + local sparkResponse = {sparkBag = {}} | ||
| 234 | + for i = sparkIndex, sparkIndex + WAVE_SPARK_NUMS do | ||
| 235 | + local sparkId = sparkIds[i] | ||
| 236 | + if not sparkId then | ||
| 237 | + break | ||
| 238 | + end | ||
| 239 | + local spark = role.sparkBag[sparkId] | ||
| 240 | + table.insert(sparkResponse.sparkBag, spark:data()) | ||
| 241 | + sparkIndex = sparkIndex + 1 | ||
| 242 | + end | ||
| 243 | + sparkResponse.sparkWave = index | ||
| 244 | + SendPacket(actionCodes.Role_loginRpc, MsgPack.pack(sparkResponse)) | ||
| 245 | + end | ||
| 246 | + curWave = curWave + sparkWave | ||
| 247 | + | ||
| 219 | local runeIndex = 1 | 248 | local runeIndex = 1 | 
| 220 | for index = curWave + 1, curWave + runeWave do | 249 | for index = curWave + 1, curWave + runeWave do | 
| 221 | local runeResponse = {runeBag = {}} | 250 | local runeResponse = {runeBag = {}} | 
| @@ -745,6 +774,7 @@ function _M.openSpeedUpBoxRpc(agent, data) | @@ -745,6 +774,7 @@ function _M.openSpeedUpBoxRpc(agent, data) | ||
| 745 | for k , v in pairs(gfood) do | 774 | for k , v in pairs(gfood) do | 
| 746 | local itemId = v.id | 775 | local itemId = v.id | 
| 747 | local speed = globalCsv.diner_get_food_speed[csvdb["itemCsv"][itemId].quality] * buildingData.speed / 100 | 776 | local speed = globalCsv.diner_get_food_speed[csvdb["itemCsv"][itemId].quality] * buildingData.speed / 100 | 
| 777 | + speed = speed + role:getBnousDiner(1,speed) | ||
| 748 | reward[itemId] = (reward[itemId] or 0) + math.floor((time / speed) * count) | 778 | reward[itemId] = (reward[itemId] or 0) + math.floor((time / speed) * count) | 
| 749 | end | 779 | end | 
| 750 | else | 780 | else | 
| @@ -0,0 +1,306 @@ | @@ -0,0 +1,306 @@ | ||
| 1 | +local ipairs = ipairs | ||
| 2 | +local table = table | ||
| 3 | +local math = math | ||
| 4 | +local redisproxy = redisproxy | ||
| 5 | +local MsgPack = MsgPack | ||
| 6 | + | ||
| 7 | +local _M = {} | ||
| 8 | + | ||
| 9 | +function _M.getServerProcessRpc(agent, data) | ||
| 10 | + local role = agent.role | ||
| 11 | + local result = role:getSeaportServerProgress() | ||
| 12 | + | ||
| 13 | + SendPacket(actionCodes.Seaport_getServerProcessRpc, MsgPack.pack(result)) | ||
| 14 | + return true | ||
| 15 | +end | ||
| 16 | + | ||
| 17 | +function _M.donateRpc(agent, data) | ||
| 18 | + local role = agent.role | ||
| 19 | + local msg = MsgPack.unpack(data) | ||
| 20 | + | ||
| 21 | + local phase = msg.phase or 0 | ||
| 22 | + local id = msg.id or 0 | ||
| 23 | + local itemId = msg.itemId or 0 | ||
| 24 | + local itemCount = msg.count or 0 | ||
| 25 | + | ||
| 26 | + if itemId == 0 or itemCount == 0 then return 0 end | ||
| 27 | + if role:getItemCount(itemId) < itemCount then return 1 end | ||
| 28 | + local DonateCsv = csvdb["seaport_purchaseCsv"] | ||
| 29 | + if not DonateCsv[phase] or not DonateCsv[phase][id] then return 2 end | ||
| 30 | + | ||
| 31 | + local ddata = DonateCsv[phase][id] | ||
| 32 | + local needs = ddata.need_item:toArray(true,"=") | ||
| 33 | + if itemId ~= needs[1] then return 3 end | ||
| 34 | + if itemCount % needs[2] ~= 0 then return 4 end | ||
| 35 | + | ||
| 36 | + local group = itemCount / needs[2] | ||
| 37 | + local rewards = ddata.award:toNumMap() | ||
| 38 | + | ||
| 39 | + for id, value in pairs(rewards) do | ||
| 40 | + rewards[id] = value * group | ||
| 41 | + end | ||
| 42 | + | ||
| 43 | + if phase == 1 then | ||
| 44 | + local old = tonumber(redisproxy:hget(SEAPORT_TRADE_TASK_1,id)) or 0 | ||
| 45 | + local need = ddata.need_num - old | ||
| 46 | + if need >= itemCount then | ||
| 47 | + redisproxy:hincrby(SEAPORT_TRADE_TASK_1,id,itemCount) | ||
| 48 | + else | ||
| 49 | + redisproxy:hincrby(SEAPORT_TRADE_TASK_1,id,need) | ||
| 50 | + for _, temp in pairs(DonateCsv[2]) do | ||
| 51 | + local items = temp.need_item:toArray(true,"=") | ||
| 52 | + if items[1] == itemId then | ||
| 53 | + redisproxy:hincrby(SEAPORT_TRADE_TASK_2,temp.id,itemCount - need) | ||
| 54 | + break | ||
| 55 | + end | ||
| 56 | + end | ||
| 57 | + end | ||
| 58 | + else | ||
| 59 | + redisproxy:hincrby(SEAPORT_TRADE_TASK_2,id,itemCount) | ||
| 60 | + end | ||
| 61 | + | ||
| 62 | + role:costItems({[itemId] = itemCount}, {log = {desc = "seaportDonate", int1 = phase, int2 = id}}) | ||
| 63 | + local reward, change = role:award(rewards, {log = {desc = "seaportDonate", int1 = ddata.phase, int2 = ddata.id}}) | ||
| 64 | + | ||
| 65 | + role:mylog("role_action", {desc = "seaportDonate", int1 = itemId, int2 = itemCount}) | ||
| 66 | + | ||
| 67 | + SendPacket(actionCodes.Seaport_donateRpc, MsgPack.pack(role:packReward(reward, change))) | ||
| 68 | + return true | ||
| 69 | +end | ||
| 70 | + | ||
| 71 | +function _M.donateRewardRpc(agent, data) | ||
| 72 | + local role = agent.role | ||
| 73 | + local msg = MsgPack.unpack(data) | ||
| 74 | + | ||
| 75 | + local id = msg.id | ||
| 76 | + local dataCsv = csvdb["seaport_purchaseCsv"] | ||
| 77 | + if not dataCsv[id] then return 0 end | ||
| 78 | + | ||
| 79 | + local seaport = role:getProperty("seaport") or {} | ||
| 80 | + local donate = seaport.donate or {} | ||
| 81 | + if donate[id] then return 3 end | ||
| 82 | + | ||
| 83 | + local data = dataCsv[id][1] | ||
| 84 | + | ||
| 85 | + local result = role:getSeaportServerProgress() | ||
| 86 | + if not result[id] then return 1 end | ||
| 87 | + | ||
| 88 | + for _, tempData in ipairs(dataCsv[id]) do | ||
| 89 | + if tempData.need_num > (result[id][tempData.id] or 0) then | ||
| 90 | + return 2 | ||
| 91 | + end | ||
| 92 | + end | ||
| 93 | + | ||
| 94 | + donate[id] = 1 | ||
| 95 | + seaport.donate = donate | ||
| 96 | + | ||
| 97 | + local reward, change = role:award(data.phase_award, {log = {desc = "seaportReward", int1 = data.phase, int2 = data.id}}) | ||
| 98 | + | ||
| 99 | + role:updateProperty({field = "seaport", value = seaport}) | ||
| 100 | + SendPacket(actionCodes.Seaport_donateRewardRpc, MsgPack.pack(role:packReward(reward, change))) | ||
| 101 | + return true | ||
| 102 | +end | ||
| 103 | + | ||
| 104 | +-- 获取英雄大成功率 | ||
| 105 | +local function getHeroCoef(hero, condition) | ||
| 106 | + -- 基础概率 | ||
| 107 | + local rareMap = {[HeroQuality.N] = 10, [HeroQuality.R] = 10, [HeroQuality.SR] = 15, [HeroQuality.SSR] = 20} | ||
| 108 | + local rare = hero:getRare() | ||
| 109 | + local result = 0 | ||
| 110 | + for _, it in ipairs(condition:toTableArray(true)) do | ||
| 111 | + local type = it[1] | ||
| 112 | + local value = it[2] | ||
| 113 | + local add = it[3] | ||
| 114 | + if type == 1 then -- 种族加成 | ||
| 115 | + if hero:getCamp() == value then | ||
| 116 | + result = result + add | ||
| 117 | + end | ||
| 118 | + elseif type == 2 then -- 定位加成 | ||
| 119 | + if hero:getPosition() == value then | ||
| 120 | + result = result + add | ||
| 121 | + end | ||
| 122 | + end | ||
| 123 | + end | ||
| 124 | + | ||
| 125 | + return result + (rareMap[rare] or 0) | ||
| 126 | +end | ||
| 127 | + | ||
| 128 | +function _M.taskRpc(agent, data) | ||
| 129 | + local role = agent.role | ||
| 130 | + local msg = MsgPack.unpack(data) | ||
| 131 | + | ||
| 132 | + local oper = msg.oper or 0 | ||
| 133 | + local team = msg.team or "" | ||
| 134 | + local taskId = msg.id or 0 | ||
| 135 | + local level = msg.level or 0 | ||
| 136 | + | ||
| 137 | + if oper == 0 then return 0 end | ||
| 138 | + local TaskCsv = csvdb["seaport_taskCsv"] | ||
| 139 | + if not TaskCsv[taskId] or not TaskCsv[taskId][level] then return 1 end | ||
| 140 | + | ||
| 141 | + local reward, change = {}, {} | ||
| 142 | + local heroFaithMap = {} | ||
| 143 | + local seaport = role:getProperty("seaport") | ||
| 144 | + | ||
| 145 | + local data = TaskCsv[taskId][level] | ||
| 146 | + if data.phase == 2 then | ||
| 147 | + local openTime = tonumber(redisproxy:hget("autoincrement_set", "seaportTime0")) or 0 | ||
| 148 | + local nowTime = skynet.timex() | ||
| 149 | + if nowTime < (openTime + 86400) or nowTime > (openTime + 172800) then return 9 end | ||
| 150 | + end | ||
| 151 | + | ||
| 152 | + if oper == 1 then -- 开始委托 | ||
| 153 | + if team == "" then return 3 end | ||
| 154 | + local conditions = data.condition:toTableArray(true) | ||
| 155 | + local heros = team:toArray(true,"=") | ||
| 156 | + if not next(heros) then return 8 end | ||
| 157 | + local UnitCsv = csvdb["unitCsv"] | ||
| 158 | + for _, conds in pairs(conditions) do | ||
| 159 | + local count = 0 | ||
| 160 | + for _, heroId in pairs(heros) do | ||
| 161 | + local hero = role.heros[heroId] | ||
| 162 | + if not hero then return 8 end | ||
| 163 | + | ||
| 164 | + if conds[1] == 1 then | ||
| 165 | + if hero:getProperty("level") >= conds[2] then | ||
| 166 | + count = count + 1 | ||
| 167 | + end | ||
| 168 | + elseif conds[1] == 2 then | ||
| 169 | + if UnitCsv[hero:getProperty("type")].rare >= conds[2] then | ||
| 170 | + count = count + 1 | ||
| 171 | + end | ||
| 172 | + elseif conds[1] == 3 then | ||
| 173 | + count = count + 1 | ||
| 174 | + end | ||
| 175 | + end | ||
| 176 | + if count < conds[#conds] then | ||
| 177 | + return 4 | ||
| 178 | + end | ||
| 179 | + end | ||
| 180 | + | ||
| 181 | + local collect = seaport.collect or {} | ||
| 182 | + collect[taskId] = {} | ||
| 183 | + collect[taskId].time = skynet.timex() | ||
| 184 | + collect[taskId].level = level | ||
| 185 | + collect[taskId].team = team | ||
| 186 | + | ||
| 187 | + seaport.collect = collect | ||
| 188 | + elseif oper == 2 then -- 领取委托奖励 | ||
| 189 | + local collects = seaport.collect or {} | ||
| 190 | + local collect = collects[taskId] or {} | ||
| 191 | + if not next(collects) or not next(collect) then | ||
| 192 | + return 5 | ||
| 193 | + end | ||
| 194 | + local quick = msg.quick | ||
| 195 | + local endTime = data.time + collect.time | ||
| 196 | + local remainT = endTime - skynet.timex() | ||
| 197 | + if not quick and remainT > 0 then return 6 end | ||
| 198 | + | ||
| 199 | + if quick and remainT > 0 then | ||
| 200 | + local cost = math.ceil(remainT / 3600) * globalCsv.seaport_task_quick | ||
| 201 | + if not role:checkItemEnough({[ItemId.Diamond] = cost}) then return 8 end | ||
| 202 | + role:costItems({[ItemId.Diamond] = cost}, {log = {desc = "seaportTask", int1 = taskId, int2 = level}}) | ||
| 203 | + end | ||
| 204 | + | ||
| 205 | + local carbonCsv = csvdb["idle_battleCsv"] | ||
| 206 | + local expCarbonId = role:getProperty("hangInfo").expCarbonId | ||
| 207 | + if not carbonCsv[expCarbonId] then return 7 end | ||
| 208 | + | ||
| 209 | + local totalCoef = 0 | ||
| 210 | + for _, heroId in ipairs(collect.team:toArray(true,"=")) do | ||
| 211 | + local hero = role.heros[heroId] | ||
| 212 | + if hero then | ||
| 213 | + totalCoef = totalCoef + getHeroCoef(hero, data.success) | ||
| 214 | + hero:addHeroFaith(data.trust) | ||
| 215 | + heroFaithMap[heroId] = hero:getProperty("faith") | ||
| 216 | + end | ||
| 217 | + end | ||
| 218 | + | ||
| 219 | + local bigSuccess = false | ||
| 220 | + local result = math.randomInt(0, 100) | ||
| 221 | + if result < totalCoef then | ||
| 222 | + bigSuccess = true | ||
| 223 | + end | ||
| 224 | + | ||
| 225 | + local money = math.ceil(carbonCsv[expCarbonId].money / 5 * data.time * data.money_clear) | ||
| 226 | + local exp = math.ceil(carbonCsv[expCarbonId].exp / 5 * data.time * data.exp_clear) | ||
| 227 | + local itemReward = data.item_clear_special:toNumMap() | ||
| 228 | + itemReward[ItemId.Gold] = (itemReward[ItemId.Gold] or 0) + money | ||
| 229 | + itemReward[ItemId.Exp] = (itemReward[ItemId.Exp] or 0) + exp | ||
| 230 | + | ||
| 231 | + if bigSuccess then | ||
| 232 | + for key, value in pairs(itemReward) do | ||
| 233 | + itemReward[key] = math.ceil(1.5 * value) | ||
| 234 | + end | ||
| 235 | + end | ||
| 236 | + | ||
| 237 | + reward, change = role:award(itemReward, {log = {desc = "seaportTask", int1 = taskId, int2 = level}}) | ||
| 238 | + | ||
| 239 | + seaport.collect[taskId] = nil | ||
| 240 | + else | ||
| 241 | + return 0 | ||
| 242 | + end | ||
| 243 | + | ||
| 244 | + role:updateProperty({field = "seaport", value = seaport}) | ||
| 245 | + | ||
| 246 | + local result = role:packReward(reward, change) | ||
| 247 | + result["heroFaith"] = heroFaithMap | ||
| 248 | + | ||
| 249 | + SendPacket(actionCodes.Seaport_taskRpc, MsgPack.pack(result)) | ||
| 250 | + return true | ||
| 251 | +end | ||
| 252 | + | ||
| 253 | +function _M.shopRpc(agent, data) | ||
| 254 | + local role = agent.role | ||
| 255 | + local msg = MsgPack.unpack(data) | ||
| 256 | + local id = msg.id or 0 | ||
| 257 | + local count = msg.count or 1 | ||
| 258 | + | ||
| 259 | + local shopCsv = {} | ||
| 260 | + local dataSet = csvdb["shop_normalCsv"] | ||
| 261 | + for _, datat in pairs(dataSet) do | ||
| 262 | + if datat.shop == 5 then | ||
| 263 | + shopCsv[datat.id] = datat | ||
| 264 | + end | ||
| 265 | + end | ||
| 266 | + local sdata = shopCsv[id] | ||
| 267 | + | ||
| 268 | + if not sdata then return 2 end | ||
| 269 | + | ||
| 270 | + local seaport = role:getProperty("seaport") | ||
| 271 | + local shop = seaport.shop or {} | ||
| 272 | + | ||
| 273 | + if (shop[id] or 0) >= sdata.limit then return 1 end | ||
| 274 | + | ||
| 275 | + | ||
| 276 | + | ||
| 277 | + | ||
| 278 | + | ||
| 279 | + if role:getItemCount(sdata.icon) < sdata.cost * count then return 3 end | ||
| 280 | + | ||
| 281 | + role:costItems({[sdata.icon] = sdata.cost * count}, {log = {desc = "seaportShop", int1 = id, int2 = count}}) | ||
| 282 | + | ||
| 283 | + local itemReward = sdata.gift:toNumMap() | ||
| 284 | + for itemId, value in pairs(itemReward) do | ||
| 285 | + itemReward[itemId] = value * count | ||
| 286 | + end | ||
| 287 | + | ||
| 288 | + local reward, change = role:award(itemReward, {log = {desc = "seaportShop", int1 = id, int2 = count}}) | ||
| 289 | + | ||
| 290 | + shop[id] = (shop[id] or 0) + count | ||
| 291 | + seaport.shop = shop | ||
| 292 | + | ||
| 293 | + role:updateProperty({field = "seaport", value = seaport}) | ||
| 294 | + | ||
| 295 | + SendPacket(actionCodes.Seaport_shopRpc, MsgPack.pack(role:packReward(reward, change))) | ||
| 296 | + return true | ||
| 297 | +end | ||
| 298 | + | ||
| 299 | +function _M.resetRpc(agent, data) | ||
| 300 | + local role = agent.role | ||
| 301 | + role:checkSeaportTrade() | ||
| 302 | + SendPacket(actionCodes.Seaport_resetRpc, MsgPack.pack("")) | ||
| 303 | + return true | ||
| 304 | +end | ||
| 305 | + | ||
| 306 | +return _M | 
src/actions/TowerAction.lua
| @@ -23,14 +23,32 @@ function _M.startBattleRpc(agent, data) | @@ -23,14 +23,32 @@ function _M.startBattleRpc(agent, data) | ||
| 23 | local role = agent.role | 23 | local role = agent.role | 
| 24 | local msg = MsgPack.unpack(data) | 24 | local msg = MsgPack.unpack(data) | 
| 25 | local id = msg.id | 25 | local id = msg.id | 
| 26 | - | ||
| 27 | - if not role:isFuncUnlock(FuncUnlock.Tower) then return end | 26 | + local towerType = math.floor(id / 10000) | 
| 27 | + | ||
| 28 | + if not id or towerType < 0 or towerType > 3 then return 0 end | ||
| 29 | + if not role:isFuncUnlock(FuncUnlock.Tower) then return 1 end | ||
| 28 | 30 | ||
| 29 | local towerInfo = role:getProperty("towerInfo") | 31 | local towerInfo = role:getProperty("towerInfo") | 
| 30 | 32 | ||
| 31 | - if towerInfo.l ~= id then return end -- 层数不对 | 33 | + if towerType == 0 and (towerInfo.l or 1) ~= id then return 2 end -- 层数不对 | 
| 34 | + if towerType == 1 and ((towerInfo.l1 or 10001) ~= id or (towerInfo.l or 1) <= globalCsv.tower_open[towerType]) then return 2 end -- 层数不对 | ||
| 35 | + if towerType == 2 and ((towerInfo.l2 or 20001) ~= id or (towerInfo.l or 1) <= globalCsv.tower_open[towerType]) then return 2 end -- 层数不对 | ||
| 36 | + if towerType == 3 and ((towerInfo.l3 or 30001) ~= id or (towerInfo.l or 1) <= globalCsv.tower_open[towerType]) then return 2 end -- 层数不对 | ||
| 37 | + | ||
| 38 | + if not csvdb["tower_battleCsv"][id] then return 4 end | ||
| 39 | + | ||
| 40 | + local teams = role:getTowerTeamFormat(towerType + 1) | ||
| 41 | + if not next(teams) then return 5 end | ||
| 42 | + | ||
| 43 | + if towerType ~= 0 then | ||
| 44 | + for _, heroId in pairs(teams.heros) do | ||
| 45 | + local hero = role.heros[heroId] | ||
| 46 | + if not hero then return 6 end | ||
| 47 | + local unit = csvdb["unitCsv"][hero:getProperty("type")] | ||
| 48 | + if unit.camp ~= towerType then return 7 end | ||
| 49 | + end | ||
| 50 | + end | ||
| 32 | 51 | ||
| 33 | - if not csvdb["tower_battleCsv"][id] then return end | ||
| 34 | local curCount, nextTime = getUpdateTime(towerInfo.c, towerInfo.t) | 52 | local curCount, nextTime = getUpdateTime(towerInfo.c, towerInfo.t) | 
| 35 | --if curCount < 1 then return end -- 没有次数返回 | 53 | --if curCount < 1 then return end -- 没有次数返回 | 
| 36 | 54 | ||
| @@ -57,18 +75,24 @@ function _M.endBattleRpc(agent, data) | @@ -57,18 +75,24 @@ function _M.endBattleRpc(agent, data) | ||
| 57 | local key = msg.key | 75 | local key = msg.key | 
| 58 | local passTime = msg.passTime | 76 | local passTime = msg.passTime | 
| 59 | 77 | ||
| 78 | + local curTower = csvdb["tower_battleCsv"][id] | ||
| 79 | + if not curTower then return 2 end | ||
| 80 | + | ||
| 60 | local towerInfo = role:getProperty("towerInfo") | 81 | local towerInfo = role:getProperty("towerInfo") | 
| 61 | - if towerInfo.l ~= id or not towerInfo.k or towerInfo.k ~= key then | 82 | + local towerType = math.floor(id / 10000) | 
| 83 | + local towerLevel = {[0] = (towerInfo.l or 1), [1] = (towerInfo.l1 or 10001), [2] = (towerInfo.l2 or 20001), [3] = (towerInfo.l3 or 30001)} | ||
| 84 | + local curLevel = towerLevel[towerType] | ||
| 85 | + | ||
| 86 | + if curLevel ~= id or not towerInfo.k or towerInfo.k ~= key then | ||
| 62 | SendPacket(actionCodes.Tower_endBattleRpc, MsgPack.pack({errorCode = 1})) | 87 | SendPacket(actionCodes.Tower_endBattleRpc, MsgPack.pack({errorCode = 1})) | 
| 63 | return true | 88 | return true | 
| 64 | end | 89 | end | 
| 65 | - local curTower = csvdb["tower_battleCsv"][id] | ||
| 66 | - if not curTower then return 2 end | ||
| 67 | 90 | ||
| 68 | -- 防作弊 | 91 | -- 防作弊 | 
| 69 | if not role:checkBattleCheat("tower", { | 92 | if not role:checkBattleCheat("tower", { | 
| 70 | isWin = msg.starNum and msg.starNum > 0, | 93 | isWin = msg.starNum and msg.starNum > 0, | 
| 71 | - info = msg.info | 94 | + info = msg.info, | 
| 95 | + tower = towerType + 1 | ||
| 72 | }) then | 96 | }) then | 
| 73 | SendPacket(actionCodes.Tower_endBattleRpc, MsgPack.pack({errorCode = 1})) | 97 | SendPacket(actionCodes.Tower_endBattleRpc, MsgPack.pack({errorCode = 1})) | 
| 74 | return true | 98 | return true | 
| @@ -81,11 +105,23 @@ function _M.endBattleRpc(agent, data) | @@ -81,11 +105,23 @@ function _M.endBattleRpc(agent, data) | ||
| 81 | if msg.starNum and msg.starNum > 0 then --win | 105 | if msg.starNum and msg.starNum > 0 then --win | 
| 82 | curCount = math.min(curCount + 1, globalCsv.tower_count_limit) -- 返还次数 | 106 | curCount = math.min(curCount + 1, globalCsv.tower_count_limit) -- 返还次数 | 
| 83 | --排行榜 | 107 | --排行榜 | 
| 84 | - role:setTowerRank(towerInfo.l) | 108 | + role:setTowerRank(curLevel % 10000, towerType + 1) | 
| 85 | 109 | ||
| 86 | - towerInfo.l = towerInfo.l + 1 | 110 | + curLevel = curLevel + 1 | 
| 87 | reward, change = role:award(curTower.reward, {log = {desc = "towerBattle", int1 = id}}) | 111 | reward, change = role:award(curTower.reward, {log = {desc = "towerBattle", int1 = id}}) | 
| 88 | - role:checkTaskEnter("TowerPass", {level = towerInfo.l - 1}) | 112 | + if towerType == 0 then | 
| 113 | + role:checkTaskEnter("TowerPass", {level = towerInfo.l}) | ||
| 114 | + end | ||
| 115 | + end | ||
| 116 | + | ||
| 117 | + if towerType == 0 then | ||
| 118 | + towerInfo.l = curLevel | ||
| 119 | + elseif towerType == 1 then | ||
| 120 | + towerInfo.l1 = curLevel | ||
| 121 | + elseif towerType == 2 then | ||
| 122 | + towerInfo.l2 = curLevel | ||
| 123 | + elseif towerType == 3 then | ||
| 124 | + towerInfo.l3 = curLevel | ||
| 89 | end | 125 | end | 
| 90 | 126 | ||
| 91 | towerInfo.c = curCount | 127 | towerInfo.c = curCount | 
| @@ -93,8 +129,9 @@ function _M.endBattleRpc(agent, data) | @@ -93,8 +129,9 @@ function _M.endBattleRpc(agent, data) | ||
| 93 | towerInfo.k = nil | 129 | towerInfo.k = nil | 
| 94 | role:updateProperty({field = "towerInfo", value = towerInfo}) | 130 | role:updateProperty({field = "towerInfo", value = towerInfo}) | 
| 95 | 131 | ||
| 96 | - | ||
| 97 | - local rank = redisproxy:ZREVRANK(RANK_TOWER, role:getProperty("id")) | 132 | + local RankTower = {[0] = RANK_TOWER,[1] = RANK_TOWER1,[2] = RANK_TOWER2,[3] = RANK_TOWER3} | 
| 133 | + local rankName = RankTower[towerType] | ||
| 134 | + local rank = redisproxy:ZREVRANK(rankName, role:getProperty("id")) | ||
| 98 | if not rank then | 135 | if not rank then | 
| 99 | rank = -1 | 136 | rank = -1 | 
| 100 | else | 137 | else | 
| @@ -106,6 +143,7 @@ function _M.endBattleRpc(agent, data) | @@ -106,6 +143,7 @@ function _M.endBattleRpc(agent, data) | ||
| 106 | info = msg.info, | 143 | info = msg.info, | 
| 107 | reward = reward, | 144 | reward = reward, | 
| 108 | rank = rank, | 145 | rank = rank, | 
| 146 | + tower = towerType + 1 | ||
| 109 | }) | 147 | }) | 
| 110 | role:mylog("tower_action", {desc = "endBattle", short1 = msg.starNum > 0 and 1 or 0, int1 = id}) | 148 | role:mylog("tower_action", {desc = "endBattle", short1 = msg.starNum > 0 and 1 or 0, int1 = id}) | 
| 111 | 149 | ||
| @@ -143,7 +181,9 @@ end | @@ -143,7 +181,9 @@ end | ||
| 143 | 181 | ||
| 144 | function _M.rankRpc(agent , data) | 182 | function _M.rankRpc(agent , data) | 
| 145 | local role = agent.role | 183 | local role = agent.role | 
| 146 | - SendPacket(actionCodes.Tower_rankRpc, MsgPack.pack(role:getTowerRank())) | 184 | + local msg = MsgPack.unpack(data) | 
| 185 | + local towerType = msg.tower or 1 | ||
| 186 | + SendPacket(actionCodes.Tower_rankRpc, MsgPack.pack(role:getTowerRank(towerType))) | ||
| 147 | return true | 187 | return true | 
| 148 | end | 188 | end | 
| 149 | 189 | ||
| @@ -151,7 +191,43 @@ function _M.rankInfoRpc(agent , data) | @@ -151,7 +191,43 @@ function _M.rankInfoRpc(agent , data) | ||
| 151 | local role = agent.role | 191 | local role = agent.role | 
| 152 | local msg = MsgPack.unpack(data) | 192 | local msg = MsgPack.unpack(data) | 
| 153 | local roleId = msg.roleId | 193 | local roleId = msg.roleId | 
| 154 | - SendPacket(actionCodes.Tower_rankInfoRpc, MsgPack.pack({format = role:getTowerRankOneInfo(roleId)})) | 194 | + local towerType = msg.tower or 1 | 
| 195 | + SendPacket(actionCodes.Tower_rankInfoRpc, MsgPack.pack({format = role:getTowerRankOneInfo(roleId, towerType)})) | ||
| 196 | + return true | ||
| 197 | +end | ||
| 198 | + | ||
| 199 | +function _M.activeTowerBonusRpc(agent, data) | ||
| 200 | + local role = agent.role | ||
| 201 | + local msg = MsgPack.unpack(data) | ||
| 202 | + local tType = msg.tower | ||
| 203 | + local id = msg.id | ||
| 204 | + | ||
| 205 | + local bnousCsv = csvdb["tower_battle_additionCsv"] | ||
| 206 | + | ||
| 207 | + if not tType or not id or not bnousCsv[tType] then return 0 end | ||
| 208 | + local bnousData = bnousCsv[tType][id] | ||
| 209 | + if not bnousData then return 1 end | ||
| 210 | + | ||
| 211 | + local towerInfo = role:getProperty("towerInfo") | ||
| 212 | + local towerBnous = role:getProperty("towerBnous") | ||
| 213 | + | ||
| 214 | + if towerBnous[tType] and towerBnous[tType][id] then return 2 end | ||
| 215 | + local towerLevel = {[1] = (towerInfo.l or 1), [2] = (towerInfo.l1 or 10001), [3] = (towerInfo.l2 or 20001), [4] = (towerInfo.l3 or 30001)} | ||
| 216 | + local curLevel = towerLevel[tType] | ||
| 217 | + | ||
| 218 | + if tType ~= 1 then | ||
| 219 | + if curLevel <= globalCsv.tower_open[tType - 1] then return 4 end | ||
| 220 | + end | ||
| 221 | + | ||
| 222 | + if (curLevel % 10000) <= bnousData.floor then return 3 end | ||
| 223 | + | ||
| 224 | + if not towerBnous[tType] then | ||
| 225 | + towerBnous[tType] = {} | ||
| 226 | + end | ||
| 227 | + towerBnous[tType][id] = 1 | ||
| 228 | + role:updateProperty({field = "towerBnous", value = towerBnous}) | ||
| 229 | + role:getTowerBnousActive(true) | ||
| 230 | + SendPacket(actionCodes.Tower_activeTowerBonusRpc, '') | ||
| 155 | return true | 231 | return true | 
| 156 | end | 232 | end | 
| 157 | 233 | 
src/adv/AdvBlock.lua
| @@ -215,7 +215,9 @@ function Block:randomEvent() | @@ -215,7 +215,9 @@ function Block:randomEvent() | ||
| 215 | randomFunc[AdvEventType.Trap] = function() | 215 | randomFunc[AdvEventType.Trap] = function() | 
| 216 | local data = csvdb["event_trapCsv"][self.event.id] | 216 | local data = csvdb["event_trapCsv"][self.event.id] | 
| 217 | -- 因为一些神器效果 提前触发被动 | 217 | -- 因为一些神器效果 提前触发被动 | 
| 218 | - adv.battle.player:triggerPassive(Passive.CLICK_TRAP) | 218 | + if not data.classify:sismember(1, " ") then | 
| 219 | + adv.battle.player:triggerPassive(Passive.CLICK_TRAP) | ||
| 220 | + end | ||
| 219 | 221 | ||
| 220 | local buffs = data.effect:toArray(true, "=") | 222 | local buffs = data.effect:toArray(true, "=") | 
| 221 | 223 | 
src/adv/AdvBuff.lua
| @@ -704,11 +704,13 @@ function Buff:overlay(releaser, data, layer) | @@ -704,11 +704,13 @@ function Buff:overlay(releaser, data, layer) | ||
| 704 | 704 | ||
| 705 | self.release = releaser or self.release | 705 | self.release = releaser or self.release | 
| 706 | -- 叠加层数 | 706 | -- 叠加层数 | 
| 707 | + local oldLayer = self.layer | ||
| 707 | self.layer = self.layer + layer | 708 | self.layer = self.layer + layer | 
| 708 | if maxLayer ~= 0 then | 709 | if maxLayer ~= 0 then | 
| 709 | self.layer = math.min(maxLayer, self.layer) | 710 | self.layer = math.min(maxLayer, self.layer) | 
| 710 | end | 711 | end | 
| 711 | - if self._overlay then | 712 | + | 
| 713 | + if oldLayer ~= self.layer and self._overlay then | ||
| 712 | self:_overlay() | 714 | self:_overlay() | 
| 713 | end | 715 | end | 
| 714 | 716 | 
src/adv/AdvPassive.lua
| @@ -565,6 +565,16 @@ end | @@ -565,6 +565,16 @@ end | ||
| 565 | 565 | ||
| 566 | -- 在指定地点召唤event项目 | 566 | -- 在指定地点召唤event项目 | 
| 567 | function Passive:effect12(eventType, triggerPms, eventId, count, stage) | 567 | function Passive:effect12(eventType, triggerPms, eventId, count, stage) | 
| 568 | + if eventType == AdvEventType.Monster then | ||
| 569 | + for _, buff in ipairs(self.owner.battle.player.buffs) do | ||
| 570 | + if not buff.isDel and buff:getType() == buff.Buff_NO_PASSIVE_MONSTER then | ||
| 571 | + local effect = buff:effect() | ||
| 572 | + if effect == 0 or effect == eventId then | ||
| 573 | + return | ||
| 574 | + end | ||
| 575 | + end | ||
| 576 | + end | ||
| 577 | + end | ||
| 568 | local change = self.owner.battle.adv:getCurMap():layEventToStage(eventType, eventId, count, stage) | 578 | local change = self.owner.battle.adv:getCurMap():layEventToStage(eventType, eventId, count, stage) | 
| 569 | for _, one in ipairs(change) do | 579 | for _, one in ipairs(change) do | 
| 570 | self.owner.battle.adv:backBlockChange(one[1].roomId, one[2].blockId) | 580 | self.owner.battle.adv:backBlockChange(one[1].roomId, one[2].blockId) | 
src/models/Activity.lua
| @@ -489,7 +489,7 @@ activityFunc[Activity.ActivityType.CalendaTask] = { | @@ -489,7 +489,7 @@ activityFunc[Activity.ActivityType.CalendaTask] = { | ||
| 489 | role:checkTaskEnter("RoleLevelUp", {level = rLevel}) | 489 | role:checkTaskEnter("RoleLevelUp", {level = rLevel}) | 
| 490 | 490 | ||
| 491 | local towerInfo = role:getProperty("towerInfo") | 491 | local towerInfo = role:getProperty("towerInfo") | 
| 492 | - role:checkTaskEnter("TowerPass", {level = towerInfo.l}) | 492 | + role:checkTaskEnter("TowerPass", {count = towerInfo.l, type = 1}) | 
| 493 | --"PvpWin" | 493 | --"PvpWin" | 
| 494 | --role:checkTaskEnter("HangPass", {id = 0}) | 494 | --role:checkTaskEnter("HangPass", {id = 0}) | 
| 495 | role:checkCalendaTask(true, 15, 3) | 495 | role:checkCalendaTask(true, 15, 3) | 
| @@ -557,7 +557,7 @@ activityFunc[Activity.ActivityType.BattleCommandTask] = { | @@ -557,7 +557,7 @@ activityFunc[Activity.ActivityType.BattleCommandTask] = { | ||
| 557 | role:checkTaskEnter("RoleLevelUp", {level = rLevel}) | 557 | role:checkTaskEnter("RoleLevelUp", {level = rLevel}) | 
| 558 | 558 | ||
| 559 | local towerInfo = role:getProperty("towerInfo") | 559 | local towerInfo = role:getProperty("towerInfo") | 
| 560 | - role:checkTaskEnter("TowerPass", {level = towerInfo.l}) | 560 | + role:checkTaskEnter("TowerPass", {count = towerInfo.l, type = 1}) | 
| 561 | --"PvpWin" | 561 | --"PvpWin" | 
| 562 | --role:checkTaskEnter("HangPass", {id = 0}) | 562 | --role:checkTaskEnter("HangPass", {id = 0}) | 
| 563 | role:checkCalendaTask(true, 15, 3) | 563 | role:checkCalendaTask(true, 15, 3) | 
| @@ -1039,6 +1039,14 @@ activityFunc[Activity.ActivityType.BattleCommand] = { | @@ -1039,6 +1039,14 @@ activityFunc[Activity.ActivityType.BattleCommand] = { | ||
| 1039 | ["init"] = function (self, actType, isCrossDay, notify, actId) | 1039 | ["init"] = function (self, actType, isCrossDay, notify, actId) | 
| 1040 | local data = {unlock = 0, freeR = "", payR = "", lvl = 0, sum = 0, week = 0} | 1040 | local data = {unlock = 0, freeR = "", payR = "", lvl = 0, sum = 0, week = 0} | 
| 1041 | self:updateActData(actType, data, not notify) | 1041 | self:updateActData(actType, data, not notify) | 
| 1042 | + | ||
| 1043 | + local rechargeRecord = self.owner.storeData:getProperty("payR") | ||
| 1044 | + for id, cfg in pairs(csvdb["shop_rechargeCsv"]) do | ||
| 1045 | + if cfg.shop == 2 and cfg.type == CardType.ActBattleCommandCard then | ||
| 1046 | + rechargeRecord[id] = nil | ||
| 1047 | + end | ||
| 1048 | + end | ||
| 1049 | + self.owner.storeData:updateProperty({field="payR", value=rechargeRecord}) | ||
| 1042 | end, | 1050 | end, | 
| 1043 | ["check"] = function(self, actType, notify, id, count) -- 检查 itemid, count | 1051 | ["check"] = function(self, actType, notify, id, count) -- 检查 itemid, count | 
| 1044 | local isOpen, actId = self:isOpen(actType) | 1052 | local isOpen, actId = self:isOpen(actType) | 
| @@ -1082,6 +1090,15 @@ activityFunc[Activity.ActivityType.BattleCommand] = { | @@ -1082,6 +1090,15 @@ activityFunc[Activity.ActivityType.BattleCommand] = { | ||
| 1082 | actData["week"] = 0 | 1090 | actData["week"] = 0 | 
| 1083 | self:updateActData(actType, actData, true) | 1091 | self:updateActData(actType, actData, true) | 
| 1084 | end, | 1092 | end, | 
| 1093 | + ["close"] = function (self, actType, notify, actId) | ||
| 1094 | + local rechargeRecord = self.owner.storeData:getProperty("payR") | ||
| 1095 | + for id, cfg in pairs(csvdb["shop_rechargeCsv"]) do | ||
| 1096 | + if cfg.shop == 2 and cfg.type == CardType.ActBattleCommandCard then | ||
| 1097 | + rechargeRecord[id] = nil | ||
| 1098 | + end | ||
| 1099 | + end | ||
| 1100 | + self.owner.storeData:updateProperty({field="payR", value=rechargeRecord}) | ||
| 1101 | + end, | ||
| 1085 | } | 1102 | } | 
| 1086 | 1103 | ||
| 1087 | 1104 | 
src/models/Diner.lua
| @@ -179,8 +179,13 @@ function Diner:checkDinerTask(typ, count, param1, param2, notNotify) | @@ -179,8 +179,13 @@ function Diner:checkDinerTask(typ, count, param1, param2, notNotify) | ||
| 179 | return dirty | 179 | return dirty | 
| 180 | end | 180 | end | 
| 181 | 181 | ||
| 182 | -function Diner:calSellReward(sell, delta, dishData) | 182 | +function Diner:calSellReward(sell, delta, dishData, isExpedite) | 
| 183 | local reward = sell.reward or "" | 183 | local reward = sell.reward or "" | 
| 184 | + | ||
| 185 | + if isExpedite then | ||
| 186 | + reward = "" | ||
| 187 | + end | ||
| 188 | + | ||
| 184 | local popular = 0 | 189 | local popular = 0 | 
| 185 | if delta <= 0 then | 190 | if delta <= 0 then | 
| 186 | return reward, popular | 191 | return reward, popular | 
| @@ -225,10 +230,16 @@ function Diner:calSellReward(sell, delta, dishData) | @@ -225,10 +230,16 @@ function Diner:calSellReward(sell, delta, dishData) | ||
| 225 | end | 230 | end | 
| 226 | upValue[-1] = (upValue[-1] or 0) + collectAdd | 231 | upValue[-1] = (upValue[-1] or 0) + collectAdd | 
| 227 | 232 | ||
| 233 | + -- 电波塔加成 | ||
| 234 | + local goldCount = self.owner:getBnousDiner(4,addReward[ItemId.Gold]) | ||
| 235 | + | ||
| 228 | for id, count in pairs(addReward) do | 236 | for id, count in pairs(addReward) do | 
| 229 | addReward[id] = math.floor(count * (1 + (upValue[id] or 0) / 100)) | 237 | addReward[id] = math.floor(count * (1 + (upValue[id] or 0) / 100)) | 
| 230 | reward = reward:incrv(id, addReward[id]) | 238 | reward = reward:incrv(id, addReward[id]) | 
| 231 | end | 239 | end | 
| 240 | + | ||
| 241 | + reward = reward:incrv(ItemId.Gold, goldCount) | ||
| 242 | + | ||
| 232 | popular = math.floor(popular * (1 + (upValue[-1] or 0) / 100)) | 243 | popular = math.floor(popular * (1 + (upValue[-1] or 0) / 100)) | 
| 233 | 244 | ||
| 234 | return reward, popular | 245 | return reward, popular | 
| @@ -245,7 +256,7 @@ function Diner:updateSell(slot, calOnly) | @@ -245,7 +256,7 @@ function Diner:updateSell(slot, calOnly) | ||
| 245 | local deltaTime = 0 | 256 | local deltaTime = 0 | 
| 246 | local deltaCount = 0 | 257 | local deltaCount = 0 | 
| 247 | local timePass = skynet.timex() - sell.time | 258 | local timePass = skynet.timex() - sell.time | 
| 248 | - local sellTime = dishData.sell_time | 259 | + local sellTime = dishData.sell_time + self.owner:getBnousDiner(3, dishData.sell_time) | 
| 249 | 260 | ||
| 250 | deltaCount = math.floor(timePass / sellTime) | 261 | deltaCount = math.floor(timePass / sellTime) | 
| 251 | if deltaCount < sell.count then | 262 | if deltaCount < sell.count then | 
| @@ -284,11 +295,11 @@ function Diner:expediteSell(slot) | @@ -284,11 +295,11 @@ function Diner:expediteSell(slot) | ||
| 284 | local dishData = csvdb["diner_dishCsv"][sell.dish][sell.level] | 295 | local dishData = csvdb["diner_dishCsv"][sell.dish][sell.level] | 
| 285 | local expediteCount = 0 | 296 | local expediteCount = 0 | 
| 286 | local expediteTime = globalCsv.diner_sell_expediteTime | 297 | local expediteTime = globalCsv.diner_sell_expediteTime | 
| 287 | - local sellTime = dishData.sell_time | 298 | + local sellTime = dishData.sell_time + self.owner:getBnousDiner(3,dishData.sell_time) | 
| 288 | expediteCount = math.floor(expediteTime / sellTime) | 299 | expediteCount = math.floor(expediteTime / sellTime) | 
| 289 | expediteCount = math.min(expediteCount, sell.count) | 300 | expediteCount = math.min(expediteCount, sell.count) | 
| 290 | local lastCount = sell.count - expediteCount | 301 | local lastCount = sell.count - expediteCount | 
| 291 | - local reward, popular = self:calSellReward(sell, expediteCount, dishData) | 302 | + local reward, popular = self:calSellReward(sell, expediteCount, dishData, true) | 
| 292 | local deltaTime = math.floor(expediteTime - sellTime * expediteCount) | 303 | local deltaTime = math.floor(expediteTime - sellTime * expediteCount) | 
| 293 | if expediteCount > 0 then | 304 | if expediteCount > 0 then | 
| 294 | sells[slot].time = sell.time - deltaTime | 305 | sells[slot].time = sell.time - deltaTime | 
src/models/Hero.lua
| @@ -16,6 +16,7 @@ Hero.schema = { | @@ -16,6 +16,7 @@ Hero.schema = { | ||
| 16 | equip = {"string",""}, --装备 type=level | 16 | equip = {"string",""}, --装备 type=level | 
| 17 | rune = {"string",""}, --零件 type=id | 17 | rune = {"string",""}, --零件 type=id | 
| 18 | faith = {"number", 0}, -- 信赖 | 18 | faith = {"number", 0}, -- 信赖 | 
| 19 | + spark = {"table", {}}, -- 火花属性 | ||
| 19 | } | 20 | } | 
| 20 | 21 | ||
| 21 | function Hero:ctor( properties ) | 22 | function Hero:ctor( properties ) | 
| @@ -47,7 +48,7 @@ end | @@ -47,7 +48,7 @@ end | ||
| 47 | function Hero:updateProperties(params, notNotify) | 48 | function Hero:updateProperties(params, notNotify) | 
| 48 | self:setProperties(params) | 49 | self:setProperties(params) | 
| 49 | 50 | ||
| 50 | - local check = {level = true, breakL = true, wakeL = true, talent = true, loveL = true, equip = true, rune = true} | 51 | + local check = {level = true, breakL = true, wakeL = true, talent = true, loveL = true, equip = true, rune = true, spark = true} | 
| 51 | local datas = {} | 52 | local datas = {} | 
| 52 | local updateBV = false | 53 | local updateBV = false | 
| 53 | for k , v in pairs(params) do | 54 | for k , v in pairs(params) do | 
| @@ -78,7 +79,7 @@ function Hero:updateProperty(params) | @@ -78,7 +79,7 @@ function Hero:updateProperty(params) | ||
| 78 | local datas = {} | 79 | local datas = {} | 
| 79 | table.insert(datas, {key = params.field, newValue = self:getProperty(params.field)}) | 80 | table.insert(datas, {key = params.field, newValue = self:getProperty(params.field)}) | 
| 80 | 81 | ||
| 81 | - local check = {level = true, breakL = true, wakeL = true, talent = true, loveL = true, equip = true, rune = true} | 82 | + local check = {level = true, breakL = true, wakeL = true, talent = true, loveL = true, equip = true, rune = true, spark = true} | 
| 82 | if check[params.field] then | 83 | if check[params.field] then | 
| 83 | local orginValue = self:getProperty("battleV") | 84 | local orginValue = self:getProperty("battleV") | 
| 84 | local curValue = self:saveBattleValue() | 85 | local curValue = self:saveBattleValue() | 
| @@ -103,7 +104,8 @@ function Hero:data() | @@ -103,7 +104,8 @@ function Hero:data() | ||
| 103 | -- loveL = self:getProperty("loveL"), | 104 | -- loveL = self:getProperty("loveL"), | 
| 104 | equip = self:getProperty("equip"), | 105 | equip = self:getProperty("equip"), | 
| 105 | rune = self:getProperty("rune"), | 106 | rune = self:getProperty("rune"), | 
| 106 | - faith = self:getProperty("faith") | 107 | + faith = self:getProperty("faith"), | 
| 108 | + spark = self:getProperty("spark"), | ||
| 107 | } | 109 | } | 
| 108 | end | 110 | end | 
| 109 | 111 | 
src/models/HeroPlugin.lua
| @@ -121,11 +121,13 @@ function HeroPlugin.bind(Hero) | @@ -121,11 +121,13 @@ function HeroPlugin.bind(Hero) | ||
| 121 | local attrs = self:getBaseAttrs() | 121 | local attrs = self:getBaseAttrs() | 
| 122 | -- 装备零件 | 122 | -- 装备零件 | 
| 123 | local equipAttrs = self:getRuneEquipAttrs() | 123 | local equipAttrs = self:getRuneEquipAttrs() | 
| 124 | + local sparkAttrs = self:getSparkAttrs() | ||
| 124 | 125 | ||
| 125 | for _, attName in pairs(AttsEnumEx) do | 126 | for _, attName in pairs(AttsEnumEx) do | 
| 126 | attrs[attName] = attrs[attName] or 0 | 127 | attrs[attName] = attrs[attName] or 0 | 
| 127 | attrs[attName] = attrs[attName] + addAttr(attrs[attName], equipAttrs.percent[attName], 1, attName) | 128 | attrs[attName] = attrs[attName] + addAttr(attrs[attName], equipAttrs.percent[attName], 1, attName) | 
| 128 | attrs[attName] = attrs[attName] + addAttr(attrs[attName], equipAttrs.value[attName], 0, attName) | 129 | attrs[attName] = attrs[attName] + addAttr(attrs[attName], equipAttrs.value[attName], 0, attName) | 
| 130 | + attrs[attName] = attrs[attName] + addAttr(attrs[attName], sparkAttrs[attName], 0, attName) | ||
| 129 | end | 131 | end | 
| 130 | 132 | ||
| 131 | -- 羁绊加成 | 133 | -- 羁绊加成 | 
| @@ -225,6 +227,19 @@ function HeroPlugin.bind(Hero) | @@ -225,6 +227,19 @@ function HeroPlugin.bind(Hero) | ||
| 225 | return attrs | 227 | return attrs | 
| 226 | end | 228 | end | 
| 227 | 229 | ||
| 230 | + function Hero:getSparkAttrs() | ||
| 231 | + local attrs = {} | ||
| 232 | + for _, attName in pairs(AttsEnumEx) do | ||
| 233 | + attrs[attName] = 0 | ||
| 234 | + end | ||
| 235 | + for _, data in pairs(self:getProperty("spark") or {}) do | ||
| 236 | + for k, v in pairs(data.attrs) do | ||
| 237 | + attrs[AttsEnumEx[k]] = attrs[AttsEnumEx[k]] + v | ||
| 238 | + end | ||
| 239 | + end | ||
| 240 | + return attrs | ||
| 241 | + end | ||
| 242 | + | ||
| 228 | 243 | ||
| 229 | -- 战斗力(当前属性)= POWER[(生命 + 防御 * 7 + 闪避 * 4)*(攻击*4 + 命中 * 2)*(1 + 暴击几率/100 * 暴击伤害/100)* 攻击速度 / 60000 ,0.8 ] | 244 | -- 战斗力(当前属性)= POWER[(生命 + 防御 * 7 + 闪避 * 4)*(攻击*4 + 命中 * 2)*(1 + 暴击几率/100 * 暴击伤害/100)* 攻击速度 / 60000 ,0.8 ] | 
| 230 | -- function Hero:getBattleValue(activeRelation) -- isReal包括队伍加成 | 245 | -- function Hero:getBattleValue(activeRelation) -- isReal包括队伍加成 | 
src/models/Role.lua
| @@ -25,6 +25,7 @@ function Role:ctor( properties ) | @@ -25,6 +25,7 @@ function Role:ctor( properties ) | ||
| 25 | self.storeData = nil | 25 | self.storeData = nil | 
| 26 | self.heros = {} | 26 | self.heros = {} | 
| 27 | self.runeBag = {} | 27 | self.runeBag = {} | 
| 28 | + self.sparkBag = {} | ||
| 28 | self.advData = nil | 29 | self.advData = nil | 
| 29 | self.activity = nil | 30 | self.activity = nil | 
| 30 | self._pushToken = nil | 31 | self._pushToken = nil | 
| @@ -115,6 +116,7 @@ Role.schema = { | @@ -115,6 +116,7 @@ Role.schema = { | ||
| 115 | hangTeams = {"table", {}}, -- pve自选编队 | 116 | hangTeams = {"table", {}}, -- pve自选编队 | 
| 116 | teamIndex = {"table", {}}, -- 各个系统使用的编队索引 type->index 见TeamSystemType | 117 | teamIndex = {"table", {}}, -- 各个系统使用的编队索引 type->index 见TeamSystemType | 
| 117 | advTeams = {"table", {}}, -- 拾荒自选编队 | 118 | advTeams = {"table", {}}, -- 拾荒自选编队 | 
| 119 | + towerTeams = {"table", {}}, -- 四个电波塔的队伍 | ||
| 118 | 120 | ||
| 119 | bonusStar = {"table", {}}, -- 奖励关卡 通关星星 {[id] = 1} 三个二进制位 表示三个星 从低到高 (1 << 0) (1 << 1) (1 << 2) 满星 (1 << 3) - 1 | 121 | bonusStar = {"table", {}}, -- 奖励关卡 通关星星 {[id] = 1} 三个二进制位 表示三个星 从低到高 (1 << 0) (1 << 1) (1 << 2) 满星 (1 << 3) - 1 | 
| 120 | 122 | ||
| @@ -146,7 +148,8 @@ Role.schema = { | @@ -146,7 +148,8 @@ Role.schema = { | ||
| 146 | 148 | ||
| 147 | boxL = {"table", {}}, -- boxList 正开启的箱子 -- {[1] = {id = 1010, gem = 101, time = 1313}} | 149 | boxL = {"table", {}}, -- boxList 正开启的箱子 -- {[1] = {id = 1010, gem = 101, time = 1313}} | 
| 148 | 150 | ||
| 149 | - towerInfo = {"table", {c = globalCsv.tower_count_limit, l = 1}}, -- 当天爬塔消耗的次数 -- {t = time, c = count, l = layer, k = battleKey} | 151 | + towerInfo = {"table", {c = globalCsv.tower_count_limit, l = 1, l1 = 10001, l2 = 20001, l3 = 30001}}, -- 当天爬塔消耗的次数 -- {t = time, c = count, l = layer, k = battleKey} | 
| 152 | + towerBnous = {"table", {}}, -- 电波塔加成 {[1] = {[1] = 1, [2] = 1}, [2] = {}, [3] = {}, [4] = {}} | ||
| 150 | 153 | ||
| 151 | spTask = {"table", {}}, -- 特殊任务 -- {id = status} | 154 | spTask = {"table", {}}, -- 特殊任务 -- {id = status} | 
| 152 | 155 | ||
| @@ -186,6 +189,10 @@ Role.schema = { | @@ -186,6 +189,10 @@ Role.schema = { | ||
| 186 | calTask = {"table", {}}, -- 英雄令活动 日历任务活动 | 189 | calTask = {"table", {}}, -- 英雄令活动 日历任务活动 | 
| 187 | bcTask = {"table", {}}, -- 英雄令活动 日历任务活动 临时使用 | 190 | bcTask = {"table", {}}, -- 英雄令活动 日历任务活动 临时使用 | 
| 188 | radioTask = {"table", {}}, -- 电台任务 {id = {time=end_ts,heros=heros}} 表crusadeCsv | 191 | radioTask = {"table", {}}, -- 电台任务 {id = {time=end_ts,heros=heros}} 表crusadeCsv | 
| 192 | + | ||
| 193 | + seaport = {"table", {}}, -- 海岛贸易季 {time = 1234567890, donate = {}, collect = {[1] = {team = "1=2=3", time = 1234567890}}, shop = {}} | ||
| 194 | + | ||
| 195 | + returner = {"table", {}}, -- 回归者 {time = 12334233423, [1] = 1, [2] = 2, status = {[1] = 1}} | ||
| 189 | } | 196 | } | 
| 190 | 197 | ||
| 191 | 198 | ||
| @@ -368,6 +375,7 @@ function Role:data() | @@ -368,6 +375,7 @@ function Role:data() | ||
| 368 | hangTeams = self:getProperty("hangTeams"), | 375 | hangTeams = self:getProperty("hangTeams"), | 
| 369 | teamIndex = self:getProperty("teamIndex"), | 376 | teamIndex = self:getProperty("teamIndex"), | 
| 370 | advTeams = self:getProperty("advTeams"), | 377 | advTeams = self:getProperty("advTeams"), | 
| 378 | + towerTeams = self:getProperty("towerTeams"), | ||
| 371 | 379 | ||
| 372 | bonusStar = self:getProperty("bonusStar"), | 380 | bonusStar = self:getProperty("bonusStar"), | 
| 373 | 381 | ||
| @@ -385,6 +393,7 @@ function Role:data() | @@ -385,6 +393,7 @@ function Role:data() | ||
| 385 | equips = self:getProperty("equips"), | 393 | equips = self:getProperty("equips"), | 
| 386 | boxL = self:getProperty("boxL"), | 394 | boxL = self:getProperty("boxL"), | 
| 387 | towerInfo = self:getProperty("towerInfo"), | 395 | towerInfo = self:getProperty("towerInfo"), | 
| 396 | + towerBnous = self:getProperty("towerBnous"), | ||
| 388 | spTask = self:getProperty("spTask"), | 397 | spTask = self:getProperty("spTask"), | 
| 389 | dTask = self:getProperty("dTask"), | 398 | dTask = self:getProperty("dTask"), | 
| 390 | wTask = self:getProperty("wTask"), | 399 | wTask = self:getProperty("wTask"), | 
| @@ -414,6 +423,9 @@ function Role:data() | @@ -414,6 +423,9 @@ function Role:data() | ||
| 414 | calTask = self:getProperty("calTask"), | 423 | calTask = self:getProperty("calTask"), | 
| 415 | bcTask = self:getProperty("bcTask"), | 424 | bcTask = self:getProperty("bcTask"), | 
| 416 | radioTask = self:getProperty("radioTask"), | 425 | radioTask = self:getProperty("radioTask"), | 
| 426 | + | ||
| 427 | + seaport = self:getProperty("seaport"), | ||
| 428 | + returner = self:getProperty("returner"), | ||
| 417 | } | 429 | } | 
| 418 | end | 430 | end | 
| 419 | 431 | 
src/models/RoleBattle.lua
| @@ -104,7 +104,7 @@ function Role:checkBattleCheat(battleType, params) | @@ -104,7 +104,7 @@ function Role:checkBattleCheat(battleType, params) | ||
| 104 | -- enemyServer = packBattleEnemyCommon(carbonData) | 104 | -- enemyServer = packBattleEnemyCommon(carbonData) | 
| 105 | end | 105 | end | 
| 106 | cheat["tower"] = function() | 106 | cheat["tower"] = function() | 
| 107 | - local team = self:getTeamBattleInfo(self:getTeamFormatByType(TeamSystemType.Tower)) | 107 | + local team = self:getTeamBattleInfo(self:getTowerTeamFormat(params.tower)) | 
| 108 | for slot, hero in pairs(team.heros) do | 108 | for slot, hero in pairs(team.heros) do | 
| 109 | local temp = {} | 109 | local temp = {} | 
| 110 | for arr, _ in pairs(checkCheatAttrs) do | 110 | for arr, _ in pairs(checkCheatAttrs) do | 
| @@ -198,7 +198,7 @@ function Role:checkBattle(battleType, params) | @@ -198,7 +198,7 @@ function Role:checkBattle(battleType, params) | ||
| 198 | end | 198 | end | 
| 199 | end, | 199 | end, | 
| 200 | tower = function() | 200 | tower = function() | 
| 201 | - local towerF = self:getTeamFormatByType(TeamSystemType.Tower) | 201 | + local towerF = self:getTowerTeamFormat(params.tower) | 
| 202 | for slot, hero in pairs(self:getTeamHerosInfo(towerF).heros) do | 202 | for slot, hero in pairs(self:getTeamHerosInfo(towerF).heros) do | 
| 203 | selflist[slot] = hero.type | 203 | selflist[slot] = hero.type | 
| 204 | end | 204 | end | 
src/models/RoleLog.lua
| @@ -57,6 +57,7 @@ local ItemReason = { | @@ -57,6 +57,7 @@ local ItemReason = { | ||
| 57 | actBuyBpLevel = 141, -- 购买活动战令等级 | 57 | actBuyBpLevel = 141, -- 购买活动战令等级 | 
| 58 | newSign = 142,-- 新的活动签到 | 58 | newSign = 142,-- 新的活动签到 | 
| 59 | advLevelStage = 143, -- 拾荒活动阶段奖励 | 59 | advLevelStage = 143, -- 拾荒活动阶段奖励 | 
| 60 | + towerBnous = 144, -- 爬塔到一定层数对某些功能的奖励 | ||
| 60 | 61 | ||
| 61 | 62 | ||
| 62 | advHang = 301, -- 拾荒挂机 | 63 | advHang = 301, -- 拾荒挂机 | 
| @@ -126,6 +127,9 @@ local ItemReason = { | @@ -126,6 +127,9 @@ local ItemReason = { | ||
| 126 | refer = 1210, -- 穿戴 | 127 | refer = 1210, -- 穿戴 | 
| 127 | itemCompose = 1211, -- 天赋道具合成 | 128 | itemCompose = 1211, -- 天赋道具合成 | 
| 128 | radioQuest = 1212, -- 电台任务奖励 | 129 | radioQuest = 1212, -- 电台任务奖励 | 
| 130 | + changeSpark = 1213, -- 穿戴火花 | ||
| 131 | + sparkLvlUp = 1214, -- 火花强化 | ||
| 132 | + sparkQualityUp = 1215, -- 火花升华 | ||
| 129 | 133 | ||
| 130 | -- pvp | 134 | -- pvp | 
| 131 | pvpCHead = 1301, -- pvp 跨服竞技场头像 | 135 | pvpCHead = 1301, -- pvp 跨服竞技场头像 | 
| @@ -134,6 +138,13 @@ local ItemReason = { | @@ -134,6 +138,13 @@ local ItemReason = { | ||
| 134 | --adv | 138 | --adv | 
| 135 | chooseEvent = 1351, -- 冒险选择 | 139 | chooseEvent = 1351, -- 冒险选择 | 
| 136 | clickTrader = 1352, -- 冒险商店 | 140 | clickTrader = 1352, -- 冒险商店 | 
| 141 | + | ||
| 142 | + seaportDonate = 1400, -- 贸易港捐赠 | ||
| 143 | + seaportShop = 1401, -- 贸易港商店兑换 | ||
| 144 | + seaportReward = 1402, -- 贸易港阶段奖励 | ||
| 145 | + seaportTask = 1403, -- 贸易港任务奖励 | ||
| 146 | + | ||
| 147 | + returner = 1410, -- 回归者奖励 | ||
| 137 | } | 148 | } | 
| 138 | 149 | ||
| 139 | 150 | ||
| @@ -616,6 +627,8 @@ local LogType = { | @@ -616,6 +627,8 @@ local LogType = { | ||
| 616 | in_adv = "common", | 627 | in_adv = "common", | 
| 617 | out_adv = "common", | 628 | out_adv = "common", | 
| 618 | in_artifact = "common", | 629 | in_artifact = "common", | 
| 630 | + in_spark = "common", | ||
| 631 | + out_spark = "common", | ||
| 619 | 632 | ||
| 620 | mail_action = "common", | 633 | mail_action = "common", | 
| 621 | role_action = "common", | 634 | role_action = "common", | 
| @@ -628,6 +641,7 @@ local LogType = { | @@ -628,6 +641,7 @@ local LogType = { | ||
| 628 | tower_action = "common", | 641 | tower_action = "common", | 
| 629 | gm_action = "common", | 642 | gm_action = "common", | 
| 630 | act_action = "common", | 643 | act_action = "common", | 
| 644 | + spark_action = "common", | ||
| 631 | } | 645 | } | 
| 632 | 646 | ||
| 633 | -- 如要修改 要提前修改 _template mapping -- 对应 mapping 为 gamelog-* | 647 | -- 如要修改 要提前修改 _template mapping -- 对应 mapping 为 gamelog-* | 
src/models/RolePlugin.lua
| @@ -12,6 +12,7 @@ function RolePlugin.bind(Role) | @@ -12,6 +12,7 @@ function RolePlugin.bind(Role) | ||
| 12 | self:loadDiner() | 12 | self:loadDiner() | 
| 13 | self:loadActivity() | 13 | self:loadActivity() | 
| 14 | self:loadStoreInfo() | 14 | self:loadStoreInfo() | 
| 15 | + self:loadSparks() | ||
| 15 | end | 16 | end | 
| 16 | 17 | ||
| 17 | function Role:reloadWhenLogin() | 18 | function Role:reloadWhenLogin() | 
| @@ -96,6 +97,11 @@ function RolePlugin.bind(Role) | @@ -96,6 +97,11 @@ function RolePlugin.bind(Role) | ||
| 96 | self:addRune({type = typ,id = itemId, notNotify = pms.notNotify, log = pms.log}) | 97 | self:addRune({type = typ,id = itemId, notNotify = pms.notNotify, log = pms.log}) | 
| 97 | end | 98 | end | 
| 98 | end, | 99 | end, | 
| 100 | + [ItemType.Spark] = function() | ||
| 101 | + for _= 1, count do | ||
| 102 | + self:addSpark({id = itemId, notNotify = pms.notNotify, log = pms.log}) | ||
| 103 | + end | ||
| 104 | + end, | ||
| 99 | [ItemType.AdvItem] = function() --冒险道具不会进入 玩家仓库 | 105 | [ItemType.AdvItem] = function() --冒险道具不会进入 玩家仓库 | 
| 100 | count = 0 | 106 | count = 0 | 
| 101 | end, | 107 | end, | 
| @@ -134,6 +140,12 @@ function RolePlugin.bind(Role) | @@ -134,6 +140,12 @@ function RolePlugin.bind(Role) | ||
| 134 | [ItemType.Potion] = function () | 140 | [ItemType.Potion] = function () | 
| 135 | self:addPotion({id = itemId, count = count, notNotify = pms.notNotify, log = pms.log}) | 141 | self:addPotion({id = itemId, count = count, notNotify = pms.notNotify, log = pms.log}) | 
| 136 | end, | 142 | end, | 
| 143 | + [ItemType.BossTicket] = function () | ||
| 144 | + if not self.activity:isOpen("ChallengeLevel") then return end | ||
| 145 | + local actData = self.activity:getActData("ChallengeLevel") | ||
| 146 | + actData["ticket"] = (actData["ticket"] or 0) + count | ||
| 147 | + self.activity:updateActData("ChallengeLevel", actData) | ||
| 148 | + end, | ||
| 137 | } | 149 | } | 
| 138 | 150 | ||
| 139 | if count > 0 then | 151 | if count > 0 then | 
| @@ -303,7 +315,6 @@ function RolePlugin.bind(Role) | @@ -303,7 +315,6 @@ function RolePlugin.bind(Role) | ||
| 303 | end | 315 | end | 
| 304 | 316 | ||
| 305 | function Role:addPotion(params) | 317 | function Role:addPotion(params) | 
| 306 | - dump(params) | ||
| 307 | local pId = globalCsv.adv_item_potion[params.id] | 318 | local pId = globalCsv.adv_item_potion[params.id] | 
| 308 | local potionBag = self:getProperty("potionBag") | 319 | local potionBag = self:getProperty("potionBag") | 
| 309 | local origin = potionBag[pId] or 0 | 320 | local origin = potionBag[pId] or 0 | 
| @@ -743,6 +754,23 @@ function RolePlugin.bind(Role) | @@ -743,6 +754,23 @@ function RolePlugin.bind(Role) | ||
| 743 | end | 754 | end | 
| 744 | end | 755 | end | 
| 745 | 756 | ||
| 757 | + function Role:loadSparks() | ||
| 758 | + local roleId = self:getProperty("id") | ||
| 759 | + local sparkIds = redisproxy:smembers(string.format(R_SPARKIDS, roleId)) | ||
| 760 | + local redret = redisproxy:pipelining(function (red) | ||
| 761 | + for _, sparkId in ipairs(sparkIds) do | ||
| 762 | + red:hgetall(string.format(R_SPARK, roleId, sparkId)) | ||
| 763 | + end | ||
| 764 | + end) | ||
| 765 | + for index, sparkId in ipairs(sparkIds) do | ||
| 766 | + local spark = require("models.Spark").new({key = string.format(R_SPARK, roleId, sparkId)}) | ||
| 767 | + if spark:load(table.array2Table(redret[index])) then | ||
| 768 | + spark.owner = self | ||
| 769 | + self.sparkBag[tonumber(sparkId)] = spark | ||
| 770 | + end | ||
| 771 | + end | ||
| 772 | + end | ||
| 773 | + | ||
| 746 | -- 0 为操作成功 | 774 | -- 0 为操作成功 | 
| 747 | function Role:addRune(params) | 775 | function Role:addRune(params) | 
| 748 | if params.type and params.id then | 776 | if params.type and params.id then | 
| @@ -797,6 +825,101 @@ function RolePlugin.bind(Role) | @@ -797,6 +825,101 @@ function RolePlugin.bind(Role) | ||
| 797 | end | 825 | end | 
| 798 | end | 826 | end | 
| 799 | 827 | ||
| 828 | + -- 0 为操作成功 | ||
| 829 | + function Role:addSpark(params) | ||
| 830 | + if params.id then | ||
| 831 | + local set = csvdb["sparkCsv"][params.id] | ||
| 832 | + if not set then return 2 end | ||
| 833 | + local data = set[0] | ||
| 834 | + if not data then return 3 end | ||
| 835 | + | ||
| 836 | + local roleId = self:getProperty("id") | ||
| 837 | + local sparkUid = tonum(redisproxy:hincrby(string.format(R_INCR, roleId), "spark", 1)) | ||
| 838 | + | ||
| 839 | + redisproxy:sadd(string.format(R_SPARKIDS, roleId), sparkUid) | ||
| 840 | + | ||
| 841 | + local sparkInfo = { | ||
| 842 | + key = string.format(R_SPARK, roleId, sparkUid), | ||
| 843 | + id = sparkUid, | ||
| 844 | + cfg_id = params.id, | ||
| 845 | + } | ||
| 846 | + | ||
| 847 | + local newSpark = require("models.Spark").new(sparkInfo) | ||
| 848 | + newSpark:create() | ||
| 849 | + newSpark:addAttr(data.attr:toNumMap()) | ||
| 850 | + newSpark.owner = self | ||
| 851 | + self.sparkBag[sparkUid] = newSpark | ||
| 852 | + if not params.notNotify then | ||
| 853 | + local response = {} | ||
| 854 | + table.insert(response, newSpark:data()) | ||
| 855 | + dump(response) | ||
| 856 | + SendPacket(actionCodes.Role_loadSparks, MsgPack.pack(response)) | ||
| 857 | + end | ||
| 858 | + --self:checkTaskEnter("AddRune", {id = params.id, type = params.type, rarity = data.rarity}, params.notNotify) | ||
| 859 | + | ||
| 860 | + self:logItems(params.id, 0, 1, params.log) | ||
| 861 | + if params.log then | ||
| 862 | + local log = clone(params.log) | ||
| 863 | + if log["cint1"] or log["cint2"] or log["cint3"] then | ||
| 864 | + print("addRune error log have cint1 or cint2 or cint3 ", debug.traceback()) | ||
| 865 | + end | ||
| 866 | + | ||
| 867 | + log["cint1"] = sparkUid | ||
| 868 | + log["cint2"] = params.cfg_id | ||
| 869 | + | ||
| 870 | + self:mylog("in_spark", log) | ||
| 871 | + else | ||
| 872 | + print("addSpark no log ", debug.traceback()) | ||
| 873 | + end | ||
| 874 | + | ||
| 875 | + return 0, newSpark | ||
| 876 | + else | ||
| 877 | + return 1 | ||
| 878 | + end | ||
| 879 | + end | ||
| 880 | + | ||
| 881 | + function Role:delSparks(sparkIds, params) -- 批量删除 {id, } | ||
| 882 | + params = params or {} | ||
| 883 | + local roleId = self:getProperty('id') | ||
| 884 | + local bDel = {} | ||
| 885 | + for _, sparkId in pairs(sparkIds) do | ||
| 886 | + local spark = self.sparkBag[sparkId] | ||
| 887 | + if spark then | ||
| 888 | + | ||
| 889 | + self:logItems(spark:getProperty("id"), 1, 0, params.log) | ||
| 890 | + if params.log then | ||
| 891 | + local log = clone(params.log) | ||
| 892 | + if log["cint1"] or log["cint2"] then | ||
| 893 | + print("delSpark error log have cint1 or cint2 ", debug.traceback()) | ||
| 894 | + end | ||
| 895 | + | ||
| 896 | + log["cint1"] = sparkId | ||
| 897 | + log["cint2"] = spark:getProperty("cfg_id") | ||
| 898 | + | ||
| 899 | + self:mylog("out_spark", log) | ||
| 900 | + else | ||
| 901 | + print("delSparks no log ", debug.traceback()) | ||
| 902 | + end | ||
| 903 | + | ||
| 904 | + self.sparkBag[sparkId] = nil | ||
| 905 | + table.insert(bDel, sparkId) | ||
| 906 | + end | ||
| 907 | + end | ||
| 908 | + | ||
| 909 | + redisproxy:pipelining(function (red) | ||
| 910 | + for _, sparkId in pairs(bDel) do | ||
| 911 | + red:del(string.format(R_SPARK, roleId, sparkId)) | ||
| 912 | + red:srem(string.format(R_SPARKIDS, roleId), sparkId) | ||
| 913 | + end | ||
| 914 | + end) | ||
| 915 | + local response = {} | ||
| 916 | + for _, sparkId in pairs(bDel) do | ||
| 917 | + table.insert(response, {id = sparkId, bDel = true}) | ||
| 918 | + end | ||
| 919 | + | ||
| 920 | + SendPacket(actionCodes.Role_loadSparks, MsgPack.pack(response)) | ||
| 921 | + end | ||
| 922 | + | ||
| 800 | function Role:delRunes(runeIds, params) -- 批量删除 {id, } | 923 | function Role:delRunes(runeIds, params) -- 批量删除 {id, } | 
| 801 | params = params or {} | 924 | params = params or {} | 
| 802 | local roleId = self:getProperty('id') | 925 | local roleId = self:getProperty('id') | 
| @@ -1203,6 +1326,167 @@ function RolePlugin.bind(Role) | @@ -1203,6 +1326,167 @@ function RolePlugin.bind(Role) | ||
| 1203 | end | 1326 | end | 
| 1204 | end | 1327 | end | 
| 1205 | 1328 | ||
| 1329 | + -- 结算上期海港贸易季 | ||
| 1330 | + function Role:checkSeaportTrade() | ||
| 1331 | + local openTime0 = tonum(redisproxy:hget("autoincrement_set", "seaportTime0") or 0) | ||
| 1332 | + local openTime1 = tonum(redisproxy:hget("autoincrement_set", "seaportTime1") or 0) | ||
| 1333 | + local openTime2 = tonum(redisproxy:hget("autoincrement_set", "seaportTime2") or 0) | ||
| 1334 | + local seaport = self:getProperty("seaport") or {} | ||
| 1335 | + local oldTime = seaport.time or 0 | ||
| 1336 | + local update = false | ||
| 1337 | + | ||
| 1338 | + local function getReward(reset) | ||
| 1339 | + -- 全服捐赠奖励 | ||
| 1340 | + local donate = seaport.donate or {} | ||
| 1341 | + if not reset and (not donate[1] or not donate[2]) then | ||
| 1342 | + local result = self:getSeaportServerProgress() | ||
| 1343 | + local seaportCsv = csvdb["seaport_purchaseCsv"] | ||
| 1344 | + for idx, set in ipairs(seaportCsv) do | ||
| 1345 | + local done = true | ||
| 1346 | + for id, data in ipairs(set) do | ||
| 1347 | + if donate[id] or not result[idx] or not result[idx][id] or result[idx][id] < data.need_num then | ||
| 1348 | + done = false | ||
| 1349 | + break | ||
| 1350 | + end | ||
| 1351 | + end | ||
| 1352 | + if done then | ||
| 1353 | + update = true | ||
| 1354 | + self:award(set[1].phase_award, {log = {desc = "seaportReward", int1 = set[1].phase, int2 = set[1].id}}) | ||
| 1355 | + donate[idx] = 1 | ||
| 1356 | + end | ||
| 1357 | + end | ||
| 1358 | + seaport.donate = donate | ||
| 1359 | + end | ||
| 1360 | + | ||
| 1361 | + -- 委托任务的奖励 | ||
| 1362 | + local collect = seaport.collect or {} | ||
| 1363 | + if next(collect) then | ||
| 1364 | + local function getHeroCoef(hero, condition) | ||
| 1365 | + -- 基础概率 | ||
| 1366 | + local rareMap = {[HeroQuality.N] = 10, [HeroQuality.R] = 10, [HeroQuality.SR] = 15, [HeroQuality.SSR] = 20} | ||
| 1367 | + local rare = hero:getRare() | ||
| 1368 | + local result = 0 | ||
| 1369 | + for _, it in ipairs(condition:toTableArray(true)) do | ||
| 1370 | + local type = it[1] | ||
| 1371 | + local value = it[2] | ||
| 1372 | + local add = it[3] | ||
| 1373 | + if type == 1 then -- 种族加成 | ||
| 1374 | + if hero:getCamp() == value then | ||
| 1375 | + result = result + add | ||
| 1376 | + end | ||
| 1377 | + elseif type == 2 then -- 定位加成 | ||
| 1378 | + if hero:getPosition() == value then | ||
| 1379 | + result = result + add | ||
| 1380 | + end | ||
| 1381 | + end | ||
| 1382 | + end | ||
| 1383 | + | ||
| 1384 | + return result + (rareMap[rare] or 0) | ||
| 1385 | + end | ||
| 1386 | + | ||
| 1387 | + local carbonCsv = csvdb["idle_battleCsv"] | ||
| 1388 | + local expCarbonId = self:getProperty("hangInfo").expCarbonId | ||
| 1389 | + local taskCsv = csvdb["seaport_taskCsv"] | ||
| 1390 | + local endTime = openTime0 + 86400 * 2 | ||
| 1391 | + for slot, set in pairs(taskCsv) do | ||
| 1392 | + if collect[slot] then | ||
| 1393 | + update = true | ||
| 1394 | + local level = collect[slot].level | ||
| 1395 | + local data = set[level] | ||
| 1396 | + local teams = collect[slot].team | ||
| 1397 | + local time = collect[slot].time | ||
| 1398 | + if time + data.time <= endTime then | ||
| 1399 | + if not carbonCsv[expCarbonId] then break end | ||
| 1400 | + | ||
| 1401 | + local totalCoef = 0 | ||
| 1402 | + for _, heroId in ipairs(teams:toArray(true,"=")) do | ||
| 1403 | + local hero = self.heros[heroId] | ||
| 1404 | + if hero then | ||
| 1405 | + totalCoef = totalCoef + getHeroCoef(hero, data.success) | ||
| 1406 | + hero:addHeroFaith(data.trust) | ||
| 1407 | + end | ||
| 1408 | + end | ||
| 1409 | + | ||
| 1410 | + local bigSuccess = false | ||
| 1411 | + local result = math.randomInt(0, 100) | ||
| 1412 | + if result < totalCoef then | ||
| 1413 | + bigSuccess = true | ||
| 1414 | + end | ||
| 1415 | + | ||
| 1416 | + local money = math.ceil(carbonCsv[expCarbonId].money / 5 * data.time * data.money_clear) | ||
| 1417 | + local exp = math.ceil(carbonCsv[expCarbonId].exp / 5 * data.time * data.exp_clear) | ||
| 1418 | + local itemReward = data.item_clear_special:toNumMap() | ||
| 1419 | + itemReward[ItemId.Gold] = (itemReward[ItemId.Gold] or 0) + money | ||
| 1420 | + itemReward[ItemId.Exp] = (itemReward[ItemId.Exp] or 0) + exp | ||
| 1421 | + | ||
| 1422 | + if bigSuccess then | ||
| 1423 | + for key, value in pairs(itemReward) do | ||
| 1424 | + itemReward[key] = math.ceil(1.5 * value) | ||
| 1425 | + end | ||
| 1426 | + end | ||
| 1427 | + self:award(itemReward, {log = {desc = "seaportTask", int1 = slot, int2 = level}}) | ||
| 1428 | + end | ||
| 1429 | + end | ||
| 1430 | + end | ||
| 1431 | + end | ||
| 1432 | + seaport.collect = {} | ||
| 1433 | + | ||
| 1434 | + if update or reset then | ||
| 1435 | + if reset then | ||
| 1436 | + seaport = { | ||
| 1437 | + time = openTime0, | ||
| 1438 | + shop = {}, | ||
| 1439 | + collect = {}, | ||
| 1440 | + donate = {} | ||
| 1441 | + } | ||
| 1442 | + end | ||
| 1443 | + self:updateProperty({field = "seaport", value = seaport}) | ||
| 1444 | + end | ||
| 1445 | + end | ||
| 1446 | + | ||
| 1447 | + if oldTime == openTime0 then | ||
| 1448 | + if openTime1 == 1 or openTime2 == 1 then | ||
| 1449 | + return | ||
| 1450 | + end | ||
| 1451 | + getReward() | ||
| 1452 | + else | ||
| 1453 | + getReward(true) | ||
| 1454 | + end | ||
| 1455 | + end | ||
| 1456 | + | ||
| 1457 | + -- 检查回归者 | ||
| 1458 | + function Role:checkReturner() | ||
| 1459 | + local returner = self:getProperty("returner") or {} | ||
| 1460 | + if next(returner) then return end | ||
| 1461 | + | ||
| 1462 | + local now = specTime({hour = 4}) | ||
| 1463 | + returner.time = now | ||
| 1464 | + | ||
| 1465 | + self:updateProperty({field = "returner", value = returner}) | ||
| 1466 | + end | ||
| 1467 | + | ||
| 1468 | + function Role:getSeaportServerProgress() | ||
| 1469 | + local result = {} | ||
| 1470 | + | ||
| 1471 | + local dataCsv = csvdb["seaport_purchaseCsv"] | ||
| 1472 | + local rediskey = {SEAPORT_TRADE_TASK_1,SEAPORT_TRADE_TASK_2} | ||
| 1473 | + for idx, set in ipairs(dataCsv) do | ||
| 1474 | + local temp = {} | ||
| 1475 | + temp = redisproxy:pipelining(function (red) | ||
| 1476 | + for id, data in ipairs(set) do | ||
| 1477 | + red:hget(rediskey[idx], id) | ||
| 1478 | + end | ||
| 1479 | + end) | ||
| 1480 | + result[idx] = {} | ||
| 1481 | + for i,v in pairs(temp) do | ||
| 1482 | + if v then | ||
| 1483 | + result[idx][i] = tonumber(v) | ||
| 1484 | + end | ||
| 1485 | + end | ||
| 1486 | + end | ||
| 1487 | + return result | ||
| 1488 | + end | ||
| 1489 | + | ||
| 1206 | -- 获得激活的冒险效果 | 1490 | -- 获得激活的冒险效果 | 
| 1207 | function Role:getAdvActiveSupportEffect() | 1491 | function Role:getAdvActiveSupportEffect() | 
| 1208 | local effect = {} | 1492 | local effect = {} | 
| @@ -1270,11 +1554,21 @@ function RolePlugin.bind(Role) | @@ -1270,11 +1554,21 @@ function RolePlugin.bind(Role) | ||
| 1270 | end | 1554 | end | 
| 1271 | 1555 | ||
| 1272 | local StdTowerRankTime = toUnixtime("2019010100") | 1556 | local StdTowerRankTime = toUnixtime("2019010100") | 
| 1273 | - function Role:setTowerRank(level) | 1557 | + local TowerRankInfo = { | 
| 1558 | + [1] = {rank = RANK_TOWER, rankInfo = RANK_TOWER_INFO}, | ||
| 1559 | + [2] = {rank = RANK_TOWER1, rankInfo = RANK_TOWER1_INFO}, | ||
| 1560 | + [3] = {rank = RANK_TOWER2, rankInfo = RANK_TOWER2_INFO}, | ||
| 1561 | + [4] = {rank = RANK_TOWER3, rankInfo = RANK_TOWER3_INFO}, | ||
| 1562 | + } | ||
| 1563 | + function Role:setTowerRank(level,tType) | ||
| 1564 | + tType = tType or 1 | ||
| 1274 | local now = skynet.timex() | 1565 | local now = skynet.timex() | 
| 1275 | local ct = math.ceil((now - StdTowerRankTime) / 86400) --按天计算 365 * 27 < 10000 可以维持 27 年 | 1566 | local ct = math.ceil((now - StdTowerRankTime) / 86400) --按天计算 365 * 27 < 10000 可以维持 27 年 | 
| 1276 | local ct = 10000 - ct -- 越早的排名越靠前 | 1567 | local ct = 10000 - ct -- 越早的排名越靠前 | 
| 1277 | - local towerTeam = self:getTeamFormatByType(TeamSystemType.Tower) | 1568 | + | 
| 1569 | + | ||
| 1570 | + local info = TowerRankInfo[tType] | ||
| 1571 | + local towerTeam = self:getTowerTeamFormat(tostring(tType)) | ||
| 1278 | local battleV = self:getTeamBattleValue(towerTeam.heros) | 1572 | local battleV = self:getTeamBattleValue(towerTeam.heros) | 
| 1279 | local score = (level * 10000 + ct) * 10000000 + battleV | 1573 | local score = (level * 10000 + ct) * 10000000 + battleV | 
| 1280 | 1574 | ||
| @@ -1288,21 +1582,23 @@ function RolePlugin.bind(Role) | @@ -1288,21 +1582,23 @@ function RolePlugin.bind(Role) | ||
| 1288 | } | 1582 | } | 
| 1289 | local roleId = self:getProperty("id") | 1583 | local roleId = self:getProperty("id") | 
| 1290 | redisproxy:pipelining(function (red) | 1584 | redisproxy:pipelining(function (red) | 
| 1291 | - red:zadd(RANK_TOWER, score, roleId) --更新分数 | ||
| 1292 | - red:hset(RANK_TOWER_INFO, roleId, MsgPack.pack(curInfo)) | 1585 | + red:zadd(info.rank, score, roleId) --更新分数 | 
| 1586 | + red:hset(info.rankInfo, roleId, MsgPack.pack(curInfo)) | ||
| 1293 | end) | 1587 | end) | 
| 1294 | end | 1588 | end | 
| 1295 | 1589 | ||
| 1296 | - function Role:getTowerRank() | 1590 | + function Role:getTowerRank(tType) | 
| 1591 | + tType = tType or 1 | ||
| 1592 | + local info = TowerRankInfo[tType] | ||
| 1297 | local list = {} | 1593 | local list = {} | 
| 1298 | - local ids = redisproxy:zrevrange(RANK_TOWER, 0 , 99) | 1594 | + local ids = redisproxy:zrevrange(info.rank, 0 , 99) | 
| 1299 | local redret = {} | 1595 | local redret = {} | 
| 1300 | if ids and next(ids) then | 1596 | if ids and next(ids) then | 
| 1301 | redret = redisproxy:pipelining(function (red) | 1597 | redret = redisproxy:pipelining(function (red) | 
| 1302 | for i = 1, #ids do | 1598 | for i = 1, #ids do | 
| 1303 | local roleId = ids[i] | 1599 | local roleId = ids[i] | 
| 1304 | table.insert(list, {roleId = tonumber(roleId)}) | 1600 | table.insert(list, {roleId = tonumber(roleId)}) | 
| 1305 | - red:hget(RANK_TOWER_INFO, roleId) | 1601 | + red:hget(info.rankInfo, roleId) | 
| 1306 | end | 1602 | end | 
| 1307 | end) | 1603 | end) | 
| 1308 | end | 1604 | end | 
| @@ -1311,7 +1607,7 @@ function RolePlugin.bind(Role) | @@ -1311,7 +1607,7 @@ function RolePlugin.bind(Role) | ||
| 1311 | player.format = nil | 1607 | player.format = nil | 
| 1312 | list[i].player = player | 1608 | list[i].player = player | 
| 1313 | end | 1609 | end | 
| 1314 | - local rank = redisproxy:ZREVRANK(RANK_TOWER, self:getProperty("id")) | 1610 | + local rank = redisproxy:ZREVRANK(info.rank, self:getProperty("id")) | 
| 1315 | if not rank then | 1611 | if not rank then | 
| 1316 | rank = -1 | 1612 | rank = -1 | 
| 1317 | else | 1613 | else | 
| @@ -1320,8 +1616,10 @@ function RolePlugin.bind(Role) | @@ -1320,8 +1616,10 @@ function RolePlugin.bind(Role) | ||
| 1320 | return {list = list, rank = rank} | 1616 | return {list = list, rank = rank} | 
| 1321 | end | 1617 | end | 
| 1322 | 1618 | ||
| 1323 | - function Role:getTowerRankOneInfo(roleId) | ||
| 1324 | - local data = redisproxy:hget(RANK_TOWER_INFO, roleId) | 1619 | + function Role:getTowerRankOneInfo(roleId,tType) | 
| 1620 | + tType = tType or 1 | ||
| 1621 | + local info = TowerRankInfo[tType] | ||
| 1622 | + local data = redisproxy:hget(info.rankInfo, roleId) | ||
| 1325 | if data then | 1623 | if data then | 
| 1326 | local player = MsgPack.unpack(data) | 1624 | local player = MsgPack.unpack(data) | 
| 1327 | return player.format | 1625 | return player.format | 
| @@ -1541,6 +1839,19 @@ function RolePlugin.bind(Role) | @@ -1541,6 +1839,19 @@ function RolePlugin.bind(Role) | ||
| 1541 | }) | 1839 | }) | 
| 1542 | end | 1840 | end | 
| 1543 | 1841 | ||
| 1842 | + -- 设置电波塔阵容 | ||
| 1843 | + function Role:getTowerTeamFormat(teamIdx) | ||
| 1844 | + local teams = self:getProperty("towerTeams") or {} | ||
| 1845 | + local team = teams[tostring(teamIdx)] or {} | ||
| 1846 | + return team | ||
| 1847 | + end | ||
| 1848 | + | ||
| 1849 | + function Role:setTowerTeamFormat(teamIdx, team) | ||
| 1850 | + local teams = self:getProperty("towerTeams") or {} | ||
| 1851 | + teams[tostring(teamIdx)] = team | ||
| 1852 | + self:updateProperty({field = "towerTeams", value = teams, notNotify = false}) | ||
| 1853 | + end | ||
| 1854 | + | ||
| 1544 | -- update | 1855 | -- update | 
| 1545 | function Role:onRecoverTimer(now) | 1856 | function Role:onRecoverTimer(now) | 
| 1546 | self:updateTimeReset(now, true) | 1857 | self:updateTimeReset(now, true) | 
| @@ -2146,6 +2457,110 @@ function RolePlugin.bind(Role) | @@ -2146,6 +2457,110 @@ function RolePlugin.bind(Role) | ||
| 2146 | return hero:getProperty("faith") | 2457 | return hero:getProperty("faith") | 
| 2147 | end | 2458 | end | 
| 2148 | 2459 | ||
| 2460 | + function Role:getTowerBnousActive(update) | ||
| 2461 | + if not update and self.towerBnousActive then | ||
| 2462 | + return self.towerBnousActive | ||
| 2463 | + end | ||
| 2464 | + local towerInfo = self:getProperty("towerInfo") | ||
| 2465 | + local towerLevel = {towerInfo.l or 1, towerInfo.l1 or 10001, towerInfo.l2 or 20001, towerInfo.l3 or 30001} | ||
| 2466 | + local towerBnous = self:getProperty("towerBnous") | ||
| 2467 | + local bnousCsv = csvdb["tower_battle_additionCsv"] | ||
| 2468 | + self.towerBnousActive = {} | ||
| 2469 | + | ||
| 2470 | + for towerIdx, Set in pairs(towerBnous) do | ||
| 2471 | + for id, _ in pairs(Set) do | ||
| 2472 | + local data = bnousCsv[towerIdx][id] | ||
| 2473 | + if data then | ||
| 2474 | + local effects = data.effect:toTableArraySec() | ||
| 2475 | + for _, effect in pairs(effects) do | ||
| 2476 | + local pm1, pm2, pm3, pm4 = tonumber(effect[1]), tonumber(effect[2]), tonumber(effect[3]), tonumber(effect[4]) | ||
| 2477 | + if not self.towerBnousActive[pm1] then | ||
| 2478 | + self.towerBnousActive[pm1] = {} | ||
| 2479 | + end | ||
| 2480 | + if pm1 == SystemBnousType.TowerBuff then | ||
| 2481 | + if not self.towerBnousActive[pm1][pm2] then | ||
| 2482 | + self.towerBnousActive[pm1][pm2] = {} | ||
| 2483 | + end | ||
| 2484 | + table.insert(self.towerBnousActive[pm1][pm2],pm3) | ||
| 2485 | + elseif pm1 == SystemBnousType.Adv then | ||
| 2486 | + if not self.towerBnousActive[pm1][pm4] then | ||
| 2487 | + self.towerBnousActive[pm1][pm4] = {} | ||
| 2488 | + end | ||
| 2489 | + self.towerBnousActive[pm1][pm4][pm2] = (self.towerBnousActive[pm1][pm4][pm2] or 0) + pm3 | ||
| 2490 | + elseif pm1 == SystemBnousType.HangTime then | ||
| 2491 | + if type(self.towerBnousActive[pm1]) == "table" then | ||
| 2492 | + self.towerBnousActive[pm1] = 0 | ||
| 2493 | + end | ||
| 2494 | + self.towerBnousActive[pm1] = self.towerBnousActive[pm1] + pm2 | ||
| 2495 | + else | ||
| 2496 | + self.towerBnousActive[pm1][pm2] = (self.towerBnousActive[pm1][pm2] or 0) + pm3 | ||
| 2497 | + end | ||
| 2498 | + end | ||
| 2499 | + end | ||
| 2500 | + end | ||
| 2501 | + end | ||
| 2502 | + | ||
| 2503 | + return self.towerBnousActive | ||
| 2504 | + end | ||
| 2505 | + | ||
| 2506 | + function Role:getDeltaValue(result, value) | ||
| 2507 | + if not result then return 0 end | ||
| 2508 | + local delta = 0 | ||
| 2509 | + if result[1] and value then | ||
| 2510 | + delta = math.floor(value * result[1] / 100) | ||
| 2511 | + end | ||
| 2512 | + if result[0] then | ||
| 2513 | + delta = delta + result[0] | ||
| 2514 | + end | ||
| 2515 | + return delta | ||
| 2516 | + end | ||
| 2517 | + | ||
| 2518 | + function Role:getBnousBattleBuff() | ||
| 2519 | + local towerBnous = self:getTowerBnousActive() | ||
| 2520 | + return towerBnous[SystemBnousType.TowerBuff] | ||
| 2521 | + end | ||
| 2522 | + | ||
| 2523 | + function Role:getBnousCrusade(value) | ||
| 2524 | + local towerBnous = self:getTowerBnousActive() | ||
| 2525 | + return self:getDeltaValue(towerBnous[SystemBnousType.CrusadeTask], value) | ||
| 2526 | + end | ||
| 2527 | + | ||
| 2528 | + function Role:getBnousDiner(type, value) | ||
| 2529 | + local towerBnous = self:getTowerBnousActive() | ||
| 2530 | + type = type or 1 | ||
| 2531 | + local result | ||
| 2532 | + if type == 1 then | ||
| 2533 | + result = towerBnous[SystemBnousType.DinerGet] | ||
| 2534 | + elseif type == 2 then | ||
| 2535 | + result = towerBnous[SystemBnousType.DinerLimit] | ||
| 2536 | + elseif type == 3 then | ||
| 2537 | + result = towerBnous[SystemBnousType.DinerSell] | ||
| 2538 | + elseif type == 4 then | ||
| 2539 | + result = towerBnous[SystemBnousType.DinerPrice] | ||
| 2540 | + end | ||
| 2541 | + return self:getDeltaValue(result, value) | ||
| 2542 | + end | ||
| 2543 | + | ||
| 2544 | + function Role:getBnousAdv() | ||
| 2545 | + local towerBnous = self:getTowerBnousActive() | ||
| 2546 | + return towerBnous[SystemBnousType.Adv] or {} | ||
| 2547 | + end | ||
| 2548 | + | ||
| 2549 | + function Role:getBnousHangTime() | ||
| 2550 | + local towerBnous = self:getTowerBnousActive() | ||
| 2551 | + return towerBnous[SystemBnousType.HangTime] or 0 | ||
| 2552 | + end | ||
| 2553 | + | ||
| 2554 | + function Role:getBnousPvpTicket() | ||
| 2555 | + local towerBnous = self:getTowerBnousActive() | ||
| 2556 | + return towerBnous[SystemBnousType.PvpTicket] or {} | ||
| 2557 | + end | ||
| 2558 | + | ||
| 2559 | + function Role:getBnousSweep() | ||
| 2560 | + local towerBnous = self:getTowerBnousActive() | ||
| 2561 | + return towerBnous[SystemBnousType.SweepReward] or {} | ||
| 2562 | + end | ||
| 2563 | + | ||
| 2149 | end | 2564 | end | 
| 2150 | 2565 | ||
| 2151 | return RolePlugin | 2566 | return RolePlugin | 
| 2152 | \ No newline at end of file | 2567 | \ No newline at end of file | 
src/models/RoleTask.lua
| @@ -109,6 +109,7 @@ local TaskType = { | @@ -109,6 +109,7 @@ local TaskType = { | ||
| 109 | CostDiamond = 909, -- 消耗钻石 | 109 | CostDiamond = 909, -- 消耗钻石 | 
| 110 | WeekTask = 910, -- 完成每周活跃任务 | 110 | WeekTask = 910, -- 完成每周活跃任务 | 
| 111 | ActBattlePass = 911, -- 活动关卡通关 -- chapterId | 111 | ActBattlePass = 911, -- 活动关卡通关 -- chapterId | 
| 112 | + Appoint = 912, -- 触发限时礼包,指定id | ||
| 112 | 113 | ||
| 113 | --功能未实现 todo | 114 | --功能未实现 todo | 
| 114 | AdvShop = 1002, -- 冒险商城 | 115 | AdvShop = 1002, -- 冒险商城 | 
| @@ -249,6 +250,7 @@ local ActivityListener = { | @@ -249,6 +250,7 @@ local ActivityListener = { | ||
| 249 | [TaskType.Pay] = {{Activity.ActivityType.PayBack, f("twd")}}, | 250 | [TaskType.Pay] = {{Activity.ActivityType.PayBack, f("twd")}}, | 
| 250 | [TaskType.AdvMineKill] = {{Activity.ActivityType.Crisis, 1}}, | 251 | [TaskType.AdvMineKill] = {{Activity.ActivityType.Crisis, 1}}, | 
| 251 | [TaskType.AdvMineLayer] = {{Activity.ActivityType.Crisis, 2}}, | 252 | [TaskType.AdvMineLayer] = {{Activity.ActivityType.Crisis, 2}}, | 
| 253 | + [TaskType.AdvCostPower] = {{Activity.ActivityType.Crisis, 3, f("count")}}, | ||
| 252 | [TaskType.DailyTask] = {{Activity.ActivityType.CommonSignIn, f("pre"), f("cur")}}, | 254 | [TaskType.DailyTask] = {{Activity.ActivityType.CommonSignIn, f("pre"), f("cur")}}, | 
| 253 | [TaskType.AddItem] = {{Activity.ActivityType.BattleCommand, f("id"), f("count")}}, | 255 | [TaskType.AddItem] = {{Activity.ActivityType.BattleCommand, f("id"), f("count")}}, | 
| 254 | } | 256 | } | 
| @@ -263,6 +265,7 @@ local StoreListener = { | @@ -263,6 +265,7 @@ local StoreListener = { | ||
| 263 | [TaskType.AdvPassFirst] = {{TriggerEventType.AdvPass, f("id")}}, | 265 | [TaskType.AdvPassFirst] = {{TriggerEventType.AdvPass, f("id")}}, | 
| 264 | [TaskType.AddHero] = {{TriggerEventType.AddNewHero, f("heroType")}, {TriggerEventType.SSRCount, f("ssrCount")}}, | 266 | [TaskType.AddHero] = {{TriggerEventType.AddNewHero, f("heroType")}, {TriggerEventType.SSRCount, f("ssrCount")}}, | 
| 265 | [TaskType.DrawHeroLimitPack] = {{TriggerEventType.DrawHeroCnt, f("count")}}, | 267 | [TaskType.DrawHeroLimitPack] = {{TriggerEventType.DrawHeroCnt, f("count")}}, | 
| 268 | + [TaskType.Appoint] = {{TriggerEventType.Appoint, f("id")}}, | ||
| 266 | } | 269 | } | 
| 267 | } | 270 | } | 
| 268 | 271 | ||
| @@ -318,6 +321,11 @@ local BattleCommandTaskListener = { | @@ -318,6 +321,11 @@ local BattleCommandTaskListener = { | ||
| 318 | listen = CalendaTaskListener["listen"] | 321 | listen = CalendaTaskListener["listen"] | 
| 319 | } | 322 | } | 
| 320 | 323 | ||
| 324 | +local ReturnerTask = { | ||
| 325 | + func = "checkReturnerTask", | ||
| 326 | + listen = CalendaTaskListener["listen"] | ||
| 327 | +} | ||
| 328 | + | ||
| 321 | local TaskListeners = { | 329 | local TaskListeners = { | 
| 322 | StoryListener, | 330 | StoryListener, | 
| 323 | CommonListener, | 331 | CommonListener, | 
| @@ -327,6 +335,7 @@ local TaskListeners = { | @@ -327,6 +335,7 @@ local TaskListeners = { | ||
| 327 | StoreListener, | 335 | StoreListener, | 
| 328 | CalendaTaskListener, | 336 | CalendaTaskListener, | 
| 329 | BattleCommandTaskListener, | 337 | BattleCommandTaskListener, | 
| 338 | + ReturnerTask, | ||
| 330 | } | 339 | } | 
| 331 | 340 | ||
| 332 | local RoleTask = {} | 341 | local RoleTask = {} | 
| @@ -824,6 +833,15 @@ function RoleTask.bind(Role) | @@ -824,6 +833,15 @@ function RoleTask.bind(Role) | ||
| 824 | self:checkActTask(notNotify, keyName, actData, mainType, subType, param1, param2) | 833 | self:checkActTask(notNotify, keyName, actData, mainType, subType, param1, param2) | 
| 825 | end | 834 | end | 
| 826 | 835 | ||
| 836 | + function Role:checkReturnerTask(notNotify, mainType, subType, param1, param2) | ||
| 837 | + -- print("check returner task", mainType, subType, param1, param2) | ||
| 838 | + local returner = self:getProperty("returner") or {} | ||
| 839 | + if not returner.time then return end | ||
| 840 | + local actData = csvdb["activity_ctrlCsv"][76] | ||
| 841 | + local keyName = "returner" | ||
| 842 | + self:checkActTask(notNotify, keyName, actData, mainType, subType, param1, param2) | ||
| 843 | + end | ||
| 844 | + | ||
| 827 | end | 845 | end | 
| 828 | 846 | ||
| 829 | return RoleTask | 847 | return RoleTask | 
src/models/RoleTimeReset.lua
| @@ -28,6 +28,11 @@ ResetFunc["CrossDay"] = function(self, notify, response, now) | @@ -28,6 +28,11 @@ ResetFunc["CrossDay"] = function(self, notify, response, now) | ||
| 28 | self.storeData:resetStoreReored(3) --商店跨月重置 time_reset表关联id | 28 | self.storeData:resetStoreReored(3) --商店跨月重置 time_reset表关联id | 
| 29 | end | 29 | end | 
| 30 | 30 | ||
| 31 | + -- 检查回归者 | ||
| 32 | + if ltime ~= 0 and (now - ltime) >= 86400 * globalCsv.returner_time then | ||
| 33 | + self:checkReturner() | ||
| 34 | + end | ||
| 35 | + | ||
| 31 | response.dTask = {} | 36 | response.dTask = {} | 
| 32 | response.advSup = self:getProperty("advSup") | 37 | response.advSup = self:getProperty("advSup") | 
| 33 | self:log("onLogin") | 38 | self:log("onLogin") | 
| @@ -48,6 +53,12 @@ ResetFunc["CrossWeek"] = function(self, notify, response) | @@ -48,6 +53,12 @@ ResetFunc["CrossWeek"] = function(self, notify, response) | ||
| 48 | response.dinerS = {} | 53 | response.dinerS = {} | 
| 49 | 54 | ||
| 50 | self.activity:refreshWeekData(notify) | 55 | self.activity:refreshWeekData(notify) | 
| 56 | + | ||
| 57 | + -- 跨周送一些道具 | ||
| 58 | + local BnousReward = self:getBnousPvpTicket() | ||
| 59 | + if next(BnousReward) then | ||
| 60 | + local reward, change = self:award(BnousReward, {log = {desc = "towerBnous"}}) | ||
| 61 | + end | ||
| 51 | end | 62 | end | 
| 52 | 63 | ||
| 53 | 64 | 
| @@ -0,0 +1,78 @@ | @@ -0,0 +1,78 @@ | ||
| 1 | +local Spark = class("Spark", require("shared.ModelBase")) | ||
| 2 | +Spark.schema = { | ||
| 3 | + id = {"number"}, -- 唯一自增id | ||
| 4 | + cfg_id = {"number"}, | ||
| 5 | + level = {"number", 0}, -- 等级 | ||
| 6 | + attrs = {"table", {}} -- 基础属性值 id=value | ||
| 7 | +} | ||
| 8 | + | ||
| 9 | +function Spark:ctor( properties ) | ||
| 10 | + Spark.super.ctor(self, properties) | ||
| 11 | +end | ||
| 12 | + | ||
| 13 | +function Spark:notifyUpdateProperty(field, newValue, oldValue) | ||
| 14 | + local datas = { | ||
| 15 | + id = self:getProperty("id"), | ||
| 16 | + datas = { | ||
| 17 | + { | ||
| 18 | + key = field, | ||
| 19 | + newValue = newValue, | ||
| 20 | + oldValue = oldValue, | ||
| 21 | + } | ||
| 22 | + } | ||
| 23 | + } | ||
| 24 | + self:notifyUpdateProperties(datas) | ||
| 25 | +end | ||
| 26 | + | ||
| 27 | +function Spark:mylog(contents) | ||
| 28 | + contents = contents or {} | ||
| 29 | + if contents["cint1"] or contents["cint2"] then | ||
| 30 | + print("sparkLog error log have cint1 or cint2 ", debug.traceback()) | ||
| 31 | + end | ||
| 32 | + contents["cint1"] = self:getProperty("id") | ||
| 33 | + contents["cint2"] = self:getProperty("cfg_id") | ||
| 34 | + | ||
| 35 | + self.owner:mylog("spark_action", contents) | ||
| 36 | +end | ||
| 37 | + | ||
| 38 | +function Spark:notifyUpdateProperties(params) | ||
| 39 | + local updateData = { | ||
| 40 | + id = self:getProperty("id"), | ||
| 41 | + datas = params | ||
| 42 | + } | ||
| 43 | + SendPacket(actionCodes.Role_updateSpark, MsgPack.pack(updateData)) | ||
| 44 | +end | ||
| 45 | + | ||
| 46 | +function Spark:updateProperty(params) | ||
| 47 | + if not params.field or (not params.delta and not params.value) then | ||
| 48 | + return | ||
| 49 | + end | ||
| 50 | + if params.delta then | ||
| 51 | + self:incrProperty(params.field, params.delta) | ||
| 52 | + elseif params.value then | ||
| 53 | + self:setProperty(params.field, params.value) | ||
| 54 | + end | ||
| 55 | + local datas = {} | ||
| 56 | + table.insert(datas, {key = params.field, newValue = self:getProperty(params.field)}) | ||
| 57 | + | ||
| 58 | + self:notifyUpdateProperties(datas) | ||
| 59 | +end | ||
| 60 | + | ||
| 61 | +function Spark:addAttr(attrs) | ||
| 62 | + local curAttrs = clone(self:getProperty("attrs")) | ||
| 63 | + for k, v in pairs(attrs) do | ||
| 64 | + curAttrs[k] = (curAttrs[k] or 0) + v | ||
| 65 | + end | ||
| 66 | + self:updateProperty({field = "attrs", value = curAttrs}) | ||
| 67 | +end | ||
| 68 | + | ||
| 69 | +function Spark:data() | ||
| 70 | + return { | ||
| 71 | + id = self:getProperty("id"), | ||
| 72 | + cfg_id = self:getProperty("cfg_id"), | ||
| 73 | + level = self:getProperty("level"), | ||
| 74 | + attrs = self:getProperty("attrs"), | ||
| 75 | + } | ||
| 76 | +end | ||
| 77 | + | ||
| 78 | +return Spark | ||
| 0 | \ No newline at end of file | 79 | \ No newline at end of file | 
src/models/Store.lua
| @@ -3,7 +3,29 @@ | @@ -3,7 +3,29 @@ | ||
| 3 | local Store = class("Store", require("shared.ModelBase")) | 3 | local Store = class("Store", require("shared.ModelBase")) | 
| 4 | 4 | ||
| 5 | function Store:ctor(properties) | 5 | function Store:ctor(properties) | 
| 6 | - Store.super.ctor(self, properties) | 6 | + Store.super.ctor(self, properties) | 
| 7 | +end | ||
| 8 | + | ||
| 9 | +function Store:onLoad() | ||
| 10 | + local monEx = self:getProperty("monthCardEx") | ||
| 11 | + local smonEx = self:getProperty("smonthCardEx") | ||
| 12 | + local monId = self:getProperty("monthCardId") | ||
| 13 | + local smonId = self:getProperty("smonthCardId") | ||
| 14 | + local timeNow = skynet.timex() | ||
| 15 | + local flag = false | ||
| 16 | + if monEx > timeNow and monId == 0 then | ||
| 17 | + self:updateProperty({field = "monthCardId", value = 101}) | ||
| 18 | + self:updateProperty({field = "getMailT1", value = 0}) | ||
| 19 | + flag = true | ||
| 20 | + end | ||
| 21 | + if smonEx > timeNow and smonId == 0 then | ||
| 22 | + self:updateProperty({field = "smonthCardId", value = 102}) | ||
| 23 | + self:updateProperty({field = "getMailT2", value = 0}) | ||
| 24 | + flag = true | ||
| 25 | + end | ||
| 26 | + if flag then | ||
| 27 | + self:sendMonthCardEmail() | ||
| 28 | + end | ||
| 7 | end | 29 | end | 
| 8 | 30 | ||
| 9 | ActGoodsType = { | 31 | ActGoodsType = { | 
| @@ -17,7 +39,9 @@ Store.schema = { | @@ -17,7 +39,9 @@ Store.schema = { | ||
| 17 | growFundR = {"string", ""}, -- 成长基金领取记录 | 39 | growFundR = {"string", ""}, -- 成长基金领取记录 | 
| 18 | 40 | ||
| 19 | monthCardEx = {"number", 0}, -- 月卡过期时间戳 | 41 | monthCardEx = {"number", 0}, -- 月卡过期时间戳 | 
| 42 | + monthCardId = {"number", 0}, -- 月卡id | ||
| 20 | smonthCardEx = {"number", 0}, -- 超级月卡过期时间戳 | 43 | smonthCardEx = {"number", 0}, -- 超级月卡过期时间戳 | 
| 44 | + smonthCardId = {"number", 0}, -- 超级月卡id | ||
| 21 | 45 | ||
| 22 | battleCard = {"number", 0}, -- 赛季卡 | 46 | battleCard = {"number", 0}, -- 赛季卡 | 
| 23 | battleFR = {"string", ""}, -- 免费赛季卡领取记录 | 47 | battleFR = {"string", ""}, -- 免费赛季卡领取记录 | 
| @@ -51,7 +75,7 @@ function Store:updateProperty(params) | @@ -51,7 +75,7 @@ function Store:updateProperty(params) | ||
| 51 | return | 75 | return | 
| 52 | end | 76 | end | 
| 53 | local newValue = self:getProperty(params.field) | 77 | local newValue = self:getProperty(params.field) | 
| 54 | - if not params.notNotify then | 78 | + if not params.notNotify then | 
| 55 | self:notifyUpdateProperty(params.field, newValue, oldValue) | 79 | self:notifyUpdateProperty(params.field, newValue, oldValue) | 
| 56 | end | 80 | end | 
| 57 | end | 81 | end | 
| @@ -77,13 +101,16 @@ end | @@ -77,13 +101,16 @@ end | ||
| 77 | -- 发送月卡邮件 | 101 | -- 发送月卡邮件 | 
| 78 | function Store:sendMonthCardEmail() | 102 | function Store:sendMonthCardEmail() | 
| 79 | local timeNow = skynet.timex() | 103 | local timeNow = skynet.timex() | 
| 80 | - local tabs = {{ex="monthCardEx", t="getMailT1", mail=MailId.MonthCard, alert=MailId.MonthCardEx}, | ||
| 81 | - {ex="smonthCardEx", t="getMailT2", mail=MailId.SuperMonthCard, alert=MailId.SuperMonthCardEx}} | 104 | + | 
| 105 | + local tabs = {{ex="monthCardEx", t="getMailT1", id= self:getProperty("monthCardId")}, | ||
| 106 | + {ex="smonthCardEx", t="getMailT2", id=self:getProperty("smonthCardId")}} | ||
| 82 | for _, v in ipairs(tabs) do | 107 | for _, v in ipairs(tabs) do | 
| 83 | local ex = self:getProperty(v.ex) | 108 | local ex = self:getProperty(v.ex) | 
| 84 | local ts = self:getProperty(v.t) or 0 | 109 | local ts = self:getProperty(v.t) or 0 | 
| 85 | - local mailId = v.mail | ||
| 86 | - local alertId = v.alert | 110 | + local cfg = csvdb["shop_cardCsv"][v.id] or {} | 
| 111 | + | ||
| 112 | + local mailId = cfg.email | ||
| 113 | + local alertId = cfg.email_2 | ||
| 87 | local alertTs = dayLater(ex) - DAY_SEC | 114 | local alertTs = dayLater(ex) - DAY_SEC | 
| 88 | if ex > timeNow then | 115 | if ex > timeNow then | 
| 89 | local cnt = 0 | 116 | local cnt = 0 | 
| @@ -184,24 +211,66 @@ function Store:getHangDropCoef() | @@ -184,24 +211,66 @@ function Store:getHangDropCoef() | ||
| 184 | return (1 + globalCsv.hang_drop_exp_coef) or 1, (1 + globalCsv.hang_drop_item_coef) or 1 | 211 | return (1 + globalCsv.hang_drop_exp_coef) or 1, (1 + globalCsv.hang_drop_item_coef) or 1 | 
| 185 | end | 212 | end | 
| 186 | 213 | ||
| 214 | +function Store:getCurMonthCardLvl(isSuper) | ||
| 215 | + local id = 0 | ||
| 216 | + if isSuper then | ||
| 217 | + id = self:getProperty("smonthCardId") or 0 | ||
| 218 | + else | ||
| 219 | + id = self:getProperty("monthCardId") or 0 | ||
| 220 | + end | ||
| 221 | + local cfg = csvdb["shop_cardCsv"][id] | ||
| 222 | + if not cfg then return 0 end | ||
| 223 | + | ||
| 224 | + return cfg.level or 0 | ||
| 225 | +end | ||
| 187 | 226 | ||
| 188 | -- 购买通行证 | 227 | -- 购买通行证 | 
| 189 | function Store:onBuyCard(type, duration, id, actid) | 228 | function Store:onBuyCard(type, duration, id, actid) | 
| 190 | local timeNow = skynet.timex() | 229 | local timeNow = skynet.timex() | 
| 191 | if type == CardType.NormalMonthCard then | 230 | if type == CardType.NormalMonthCard then | 
| 192 | if self:isMonthCardExpire() then | 231 | if self:isMonthCardExpire() then | 
| 232 | + self:updateProperty({field = "monthCardId", value = id}) | ||
| 193 | self:updateProperty({field = "monthCardEx", value = timeNow + duration}) | 233 | self:updateProperty({field = "monthCardEx", value = timeNow + duration}) | 
| 194 | else | 234 | else | 
| 195 | self:updateProperty({field = "monthCardEx", value = self:getProperty("monthCardEx") + duration}) | 235 | self:updateProperty({field = "monthCardEx", value = self:getProperty("monthCardEx") + duration}) | 
| 196 | end | 236 | end | 
| 197 | self:sendMonthCardEmail() | 237 | self:sendMonthCardEmail() | 
| 238 | + elseif type == CardType.NormalMonthCardLevelUp then | ||
| 239 | + if self:isMonthCardExpire() then | ||
| 240 | + skynet.error(string.format("month card expired, can not level up,%d,%d",self.owner:getProperty("id"), id)) | ||
| 241 | + else | ||
| 242 | + local cfg = csvdb["shop_cardCsv"][id] | ||
| 243 | + if not cfg then return end | ||
| 244 | + local dif = cfg.level - self:getCurMonthCardLvl(false) | ||
| 245 | + if dif > 1 and dif < 0 then | ||
| 246 | + return | ||
| 247 | + end | ||
| 248 | + self:updateProperty({field = "monthCardId", value = id}) | ||
| 249 | + self:updateProperty({field = "monthCardEx", value = self:getProperty("monthCardEx") + duration}) | ||
| 250 | + end | ||
| 251 | + self:sendMonthCardEmail() | ||
| 198 | elseif type == CardType.SuperMonthCard then | 252 | elseif type == CardType.SuperMonthCard then | 
| 199 | if self:isSuperMonthCardExpire() then | 253 | if self:isSuperMonthCardExpire() then | 
| 254 | + self:updateProperty({field = "smonthCardId", value = id}) | ||
| 200 | self:updateProperty({field = "smonthCardEx", value = timeNow + duration}) | 255 | self:updateProperty({field = "smonthCardEx", value = timeNow + duration}) | 
| 201 | else | 256 | else | 
| 202 | self:updateProperty({field = "smonthCardEx", value = self:getProperty("smonthCardEx") + duration}) | 257 | self:updateProperty({field = "smonthCardEx", value = self:getProperty("smonthCardEx") + duration}) | 
| 203 | end | 258 | end | 
| 204 | self:sendMonthCardEmail() | 259 | self:sendMonthCardEmail() | 
| 260 | + elseif type == CardType.SuperMonthCardLevelUp then | ||
| 261 | + if self:isSuperMonthCardExpire() then | ||
| 262 | + skynet.error(string.format("super month card expired, can not level up,%d,%d",self.owner:getProperty("id"), id)) | ||
| 263 | + else | ||
| 264 | + local cfg = csvdb["shop_cardCsv"][id] | ||
| 265 | + if not cfg then return end | ||
| 266 | + local dif = cfg.level - self:getCurMonthCardLvl(true) | ||
| 267 | + if dif > 1 and dif < 0 then | ||
| 268 | + return | ||
| 269 | + end | ||
| 270 | + self:updateProperty({field = "smonthCardId", value = id}) | ||
| 271 | + self:updateProperty({field = "smonthCardEx", value = self:getProperty("smonthCardEx") + duration}) | ||
| 272 | + end | ||
| 273 | + self:sendMonthCardEmail() | ||
| 205 | elseif type == CardType.PrivilegeCard then | 274 | elseif type == CardType.PrivilegeCard then | 
| 206 | if self:isPrivCardExpire() then | 275 | if self:isPrivCardExpire() then | 
| 207 | self:updateProperty({field = "privCardEx", value = timeNow + duration}) | 276 | self:updateProperty({field = "privCardEx", value = timeNow + duration}) | 
| @@ -253,7 +322,7 @@ function Store:notifyUpdateProperty(field, newValue, oldValue) | @@ -253,7 +322,7 @@ function Store:notifyUpdateProperty(field, newValue, oldValue) | ||
| 253 | key = field, | 322 | key = field, | 
| 254 | newValue = newValue, | 323 | newValue = newValue, | 
| 255 | oldValue = oldValue, | 324 | oldValue = oldValue, | 
| 256 | - } | 325 | + } | 
| 257 | SendPacket(actionCodes.Store_updateproperty, MsgPack.pack(datas)) | 326 | SendPacket(actionCodes.Store_updateproperty, MsgPack.pack(datas)) | 
| 258 | end | 327 | end | 
| 259 | 328 | ||
| @@ -494,6 +563,8 @@ function Store:data() | @@ -494,6 +563,8 @@ function Store:data() | ||
| 494 | actGoodsFlag = self:getProperty("actGoodsFlag"), | 563 | actGoodsFlag = self:getProperty("actGoodsFlag"), | 
| 495 | bpInfo = self:getProperty("bpInfo"), | 564 | bpInfo = self:getProperty("bpInfo"), | 
| 496 | totalRR = self:getProperty("totalRR"), | 565 | totalRR = self:getProperty("totalRR"), | 
| 566 | + monthCardId = self:getProperty("monthCardId"), | ||
| 567 | + smonthCardId = self:getProperty("smonthCardId"), | ||
| 497 | } | 568 | } | 
| 498 | end | 569 | end | 
| 499 | 570 | 
src/services/globald.lua
| @@ -153,7 +153,36 @@ local function check_battle_act_close() | @@ -153,7 +153,36 @@ local function check_battle_act_close() | ||
| 153 | skynet.timeout(CHECK_BATTLE_ACT_CLOSE_INTERVAL, check_battle_act_close) | 153 | skynet.timeout(CHECK_BATTLE_ACT_CLOSE_INTERVAL, check_battle_act_close) | 
| 154 | end | 154 | end | 
| 155 | 155 | ||
| 156 | +-- @desc: 检查海港贸易开启、关闭 | ||
| 157 | +local function check_trade_seaport_status() | ||
| 158 | + local nowTime = skynet.timex() | ||
| 159 | + local nextTime = dayLater(nowTime) | ||
| 160 | + local interval = 100 * (nextTime - nowTime + 1) | ||
| 161 | + | ||
| 162 | + local curTm = os.date("*t", nowTime) | ||
| 163 | + if curTm.wday == 7 and curTm.hour >= 4 then -- 周六 | ||
| 164 | + local oldTime = tonumber(redisproxy:hget("autoincrement_set", "seaportTime0")) or 0 | ||
| 165 | + local cur4Time = specTime({hour = 4},nowTime) | ||
| 166 | + if cur4Time ~= oldTime then | ||
| 167 | + redisproxy:hset("autoincrement_set", "seaportTime0", cur4Time) | ||
| 168 | + redisproxy:hset("autoincrement_set", "seaportTime1", 1) | ||
| 169 | + redisproxy:del(SEAPORT_TRADE_TASK_1) | ||
| 170 | + redisproxy:del(SEAPORT_TRADE_TASK_2) | ||
| 171 | + end | ||
| 172 | + end | ||
| 173 | + if curTm.wday == 1 and curTm.hour >= 4 then -- 周日 | ||
| 174 | + if (tonumber(redisproxy:hget("autoincrement_set", "seaportTime1")) or 0) == 1 then | ||
| 175 | + redisproxy:hset("autoincrement_set", "seaportTime2", 1) | ||
| 176 | + end | ||
| 177 | + end | ||
| 178 | + if curTm.wday == 2 and curTm.hour >= 4 then -- 周一 | ||
| 179 | + -- redisproxy:hset("autoincrement_set", "seaportTime0", 0) | ||
| 180 | + redisproxy:hset("autoincrement_set", "seaportTime1", 0) | ||
| 181 | + redisproxy:hset("autoincrement_set", "seaportTime2", 0) | ||
| 182 | + end | ||
| 156 | 183 | ||
| 184 | + skynet.timeout(interval, check_trade_seaport_status) | ||
| 185 | +end | ||
| 157 | 186 | ||
| 158 | local CMD = {} | 187 | local CMD = {} | 
| 159 | 188 | ||
| @@ -178,6 +207,7 @@ end | @@ -178,6 +207,7 @@ end | ||
| 178 | function CMD.start() | 207 | function CMD.start() | 
| 179 | check_mail_queue() | 208 | check_mail_queue() | 
| 180 | --check_battle_act_close() | 209 | --check_battle_act_close() | 
| 210 | + check_trade_seaport_status() | ||
| 181 | end | 211 | end | 
| 182 | 212 | ||
| 183 | local function __init__() | 213 | local function __init__() | 
src/shared/ModelBase.lua
| @@ -178,7 +178,7 @@ function ModelBase:loadProperties(properties) | @@ -178,7 +178,7 @@ function ModelBase:loadProperties(properties) | ||
| 178 | properties[field] = MsgPack.unpack(properties[field]) | 178 | properties[field] = MsgPack.unpack(properties[field]) | 
| 179 | end | 179 | end | 
| 180 | 180 | ||
| 181 | - local val = properties[field] or def | 181 | + local val = properties[field] or clone(def) | 
| 182 | if val ~= nil then | 182 | if val ~= nil then | 
| 183 | if typ == "number" then val = tonumber(val) end | 183 | if typ == "number" then val = tonumber(val) end | 
| 184 | assert(type(val) == typ, | 184 | assert(type(val) == typ, |