Commit c1af832968a93dddcad1376e20a2dc634b070a2b
Merge branch 'develop' into tr/publish
Showing
47 changed files
with
1201 additions
and
236 deletions
Show diff stats
robot/robot.conf
1 | 1 | root = "./" |
2 | -thread = 8 | |
2 | +thread = 4 | |
3 | 3 | logger = nil |
4 | 4 | harbor = 0 |
5 | -start = "start" -- main script | |
5 | +start = "robot_main" -- main script | |
6 | 6 | bootstrap = "snlua bootstrap" -- The service for bootstrap |
7 | 7 | |
8 | 8 | lua_path = root .."skynet/lualib/?.lua;"..root.."robot/?.lua;"..root.."src/?.lua" | ... | ... |
robot/robot.lua
... | ... | @@ -16,6 +16,7 @@ local eventListener = {} |
16 | 16 | |
17 | 17 | local ignoreListener = { |
18 | 18 | ["Role.updateProperty"] = function(data) |
19 | + if not client.role then return end | |
19 | 20 | local msg = MsgPack.unpack(data) |
20 | 21 | for _, one in pairs(msg) do |
21 | 22 | client.role[one.key] = one.newValue |
... | ... | @@ -80,7 +81,7 @@ function triggerListener(listener, data) |
80 | 81 | ignoreListener[listener](data) |
81 | 82 | end |
82 | 83 | else |
83 | - log(listener .. " no handle!!!") | |
84 | + -- log(listener .. " no handle!!!") | |
84 | 85 | end |
85 | 86 | end |
86 | 87 | |
... | ... | @@ -103,8 +104,8 @@ function sendServer(actionCode, bin) |
103 | 104 | end |
104 | 105 | |
105 | 106 | function requestServer(actionCode, bin, callback, isKeep) |
106 | - sendServer(actionCode, bin) | |
107 | 107 | addListener(actionCode, callback, isKeep) |
108 | + sendServer(actionCode, bin) | |
108 | 109 | end |
109 | 110 | |
110 | 111 | local function heartBeat() |
... | ... | @@ -120,7 +121,7 @@ local function startUnit(unit) |
120 | 121 | |
121 | 122 | local ok, unitTest = pcall(require, "unitTest." .. unit) |
122 | 123 | if not ok then |
123 | - print("unitTest load error : " .. unitTest) | |
124 | + log("unitTest load error : " .. unitTest) | |
124 | 125 | end |
125 | 126 | |
126 | 127 | unitTest.new(client):startTest() |
... | ... | @@ -130,6 +131,8 @@ end |
130 | 131 | -- 登录成功开始任务 |
131 | 132 | function CMD.task() |
132 | 133 | heartBeat() |
134 | + -- 20 秒后开始执行任务 错开登录 | |
135 | + skynet.sleep(math.randomInt(2000, 3000)) | |
133 | 136 | startUnit() |
134 | 137 | end |
135 | 138 | |
... | ... | @@ -142,7 +145,7 @@ function CMD.start(fd, id) |
142 | 145 | client.uname = uname |
143 | 146 | local status, body = httpc.get(config.http, "/login?" .. httpGetFormatData({token = uname, device = "test", channel = "develop"})) |
144 | 147 | if tonumber(status) ~= 200 then |
145 | - print("http get error", uname, body) | |
148 | + log("http get error", uname, body) | |
146 | 149 | return |
147 | 150 | end |
148 | 151 | local servInfo = json.decode(body) |
... | ... | @@ -170,7 +173,7 @@ skynet.register_protocol { |
170 | 173 | dispatch = function(session, address, cmd, data) |
171 | 174 | local actionName = actionHandlers[cmd] |
172 | 175 | if not actionName then |
173 | - print("actionName not exist", actionName) | |
176 | + log("actionName not exist", actionName) | |
174 | 177 | return |
175 | 178 | end |
176 | 179 | ... | ... |
robot/robot_config.lua
... | ... | @@ -10,7 +10,7 @@ end |
10 | 10 | |
11 | 11 | |
12 | 12 | return { |
13 | - http = "http://106.13.60.20:9090", -- 登录服 | |
13 | + http = "http://192.168.0.199:9090", -- 登录服 | |
14 | 14 | host = "127.0.0.1", --服务器地址 |
15 | 15 | port = 12001, -- 服务器端口 |
16 | 16 | |
... | ... | @@ -20,15 +20,15 @@ return { |
20 | 20 | max = 200, -- 最大玩家数 必须大于 online 数 |
21 | 21 | online_time = {10 * 60, 20 * 60}, -- 在线时间控制 秒 |
22 | 22 | |
23 | - uname_prefix = "robot", --机器名称前缀 | |
23 | + uname_prefix = "robothehe", --机器名称前缀 | |
24 | 24 | |
25 | 25 | |
26 | 26 | -- 机器上线后的行为 |
27 | 27 | units = { |
28 | 28 | chat = {weight = 100}, -- 聊天 |
29 | 29 | item = {weight = 100}, -- 物品操作 |
30 | - hero = {weight = 500}, -- 英雄 | |
31 | - hang = {weight = 1000}, -- 挂机战斗 | |
30 | + hero = {weight = 500}, -- 英雄 | |
31 | + hang = {weight = 1000}, -- 挂机战斗 | |
32 | 32 | tower = {weight = 500}, -- 爬塔 |
33 | 33 | car = {weight = 100}, -- 爬塔 |
34 | 34 | pvp = {weight = 500}, -- pvp | ... | ... |
... | ... | @@ -0,0 +1,21 @@ |
1 | +local skynet = require "skynet" | |
2 | +local config = require "robot_config" | |
3 | + | |
4 | +local preOnlineCount = 10 | |
5 | + | |
6 | + | |
7 | +skynet.start(function() | |
8 | + local need = math.ceil(config.online / preOnlineCount) | |
9 | + local inpre = math.ceil(config.inpre / need) | |
10 | + local idRange = math.ceil(config.max / need) | |
11 | + local curId = 1 | |
12 | + local poold = skynet.newservice("robot_pool") | |
13 | + local pooldObj = skynet.call(poold, "lua", "start", config.online + preOnlineCount) | |
14 | + | |
15 | + for i = 1, need do | |
16 | + local start = skynet.newservice("start") | |
17 | + skynet.send(start, "lua", "start", poold, pooldObj, preOnlineCount, curId, curId + idRange - 1, inpre) | |
18 | + curId = curId + idRange | |
19 | + end | |
20 | + skynet.exit() | |
21 | +end) | |
0 | 22 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,46 @@ |
1 | +--[[ | |
2 | + deque 为了减少锁竞争,尽量保证 a服务 push;b服务 pop | |
3 | +]] | |
4 | +local skynet = require "skynet" | |
5 | +local deque = require "deque" | |
6 | + | |
7 | +local CMD = {} | |
8 | +local factory | |
9 | + | |
10 | +local PRE_FEED_COUNT = 5 | |
11 | +local dead = 0 | |
12 | +-- agent死亡,通知poold补充,当累计到5个agent时,马上生成5个agent放入poold中 | |
13 | +-- 当然这里也可以写得更复杂,参考redis落地规则 | |
14 | +function CMD.feed() | |
15 | + dead = dead + 1 | |
16 | + if dead == PRE_FEED_COUNT then | |
17 | + dead = 0 | |
18 | + for i=1, PRE_FEED_COUNT do | |
19 | + factory:push(skynet.newservice("robot")) | |
20 | + end | |
21 | + end | |
22 | +end | |
23 | + | |
24 | +-- 系统启动,生成count个agent放入双端队列中 | |
25 | +function CMD.start(count) | |
26 | + factory, addr = deque.new(count) | |
27 | + | |
28 | + for i = 1, count do | |
29 | + factory:push(skynet.newservice("robot")) | |
30 | + end | |
31 | + | |
32 | + return addr | |
33 | +end | |
34 | + | |
35 | +local function __init__() | |
36 | + skynet.dispatch("lua", function (_, _, command, ...) | |
37 | + local f = CMD[command] | |
38 | + if command == "start" then | |
39 | + skynet.ret(skynet.pack(f(...))) | |
40 | + return | |
41 | + end | |
42 | + f(...) | |
43 | + end) | |
44 | +end | |
45 | + | |
46 | +skynet.start(__init__) | ... | ... |
robot/start.lua
... | ... | @@ -5,32 +5,37 @@ local config = require "robot_config" |
5 | 5 | local skynet = require "skynet" |
6 | 6 | local netpack = require "skynet.netpack" |
7 | 7 | local socketdriver = require "skynet.socketdriver" |
8 | +local deque = require "deque" | |
8 | 9 | local string_format = string.format |
9 | 10 | |
11 | +local poold, pooldObj, onlineCount, startId, endId, inpre | |
12 | +local factory | |
13 | + | |
10 | 14 | local queue = {} |
11 | 15 | local fd2serv = {} |
12 | 16 | local id2fd = {} |
13 | 17 | local MSG = {} |
14 | -local id_max = 0 -- robot id | |
18 | +local id_max | |
15 | 19 | |
16 | 20 | |
17 | 21 | function MSG.open( ... ) |
18 | - print("open", ...) | |
22 | + log("open", ...) | |
19 | 23 | end |
20 | 24 | |
21 | 25 | function MSG.close(fd) |
22 | 26 | if fd2serv[fd] and not fd2serv[fd].closing then |
23 | 27 | fd2serv[fd].closing = true |
24 | 28 | skynet.call(fd2serv[fd].agent, "lua", "exit") |
25 | - log(string_format("logout %s", fd2serv[fd].id)) | |
29 | + pcall(skynet.send, poold, "lua", "feed") | |
26 | 30 | |
31 | + log(string_format("logout %s", fd2serv[fd].id)) | |
27 | 32 | id2fd[fd2serv[fd].id] = nil |
28 | 33 | fd2serv[fd] = nil |
29 | 34 | end |
30 | 35 | end |
31 | 36 | |
32 | 37 | function MSG.error(fd, msg) |
33 | - print("MSG.error", fd, msg) | |
38 | + log("MSG.error", fd, msg) | |
34 | 39 | MSG.close(fd) |
35 | 40 | end |
36 | 41 | |
... | ... | @@ -72,13 +77,14 @@ skynet.register_protocol { |
72 | 77 | } |
73 | 78 | |
74 | 79 | local function add_robot() |
75 | - local robot = skynet.newservice("robot") | |
80 | + local time = skynet.time() | |
81 | + local robot = factory:pop() | |
76 | 82 | local fd = socketdriver.connect(config.host, config.port) |
77 | 83 | socketdriver.start(fd) |
78 | 84 | local id |
79 | - if id_max >= config.max then | |
85 | + if id_max >= endId then | |
80 | 86 | while true do |
81 | - id = math.randomInt(1, config.max) | |
87 | + id = math.randomInt(startId, endId) | |
82 | 88 | if not id2fd[id] then |
83 | 89 | break |
84 | 90 | end |
... | ... | @@ -89,9 +95,8 @@ local function add_robot() |
89 | 95 | end |
90 | 96 | fd2serv[fd] = {agent = robot, id = id} |
91 | 97 | id2fd[id] = fd |
92 | - pcall(skynet.call, robot, "lua", "start", fd, id) | |
98 | + pcall(skynet.call, robot, "lua", "start", fd, id, prefix) | |
93 | 99 | log(string_format("login %s", fd2serv[fd].id)) |
94 | - | |
95 | 100 | -- 定时下线 |
96 | 101 | skynet.timeout(math.randomInt(config.online_time[1], config.online_time[2]) * 100, function() |
97 | 102 | MSG.close(fd) |
... | ... | @@ -106,8 +111,8 @@ local function online() |
106 | 111 | end |
107 | 112 | |
108 | 113 | -- 及时补充人数 |
109 | - if curCount < config.online then | |
110 | - for i = curCount + 1, config.online do | |
114 | + if curCount < onlineCount then | |
115 | + for i = curCount + 1, onlineCount do | |
111 | 116 | add_robot() |
112 | 117 | end |
113 | 118 | end |
... | ... | @@ -116,11 +121,18 @@ local function online() |
116 | 121 | skynet.timeout(100, online) |
117 | 122 | end |
118 | 123 | |
119 | -local function start() | |
124 | +local function start(pooldp, pooldObj, onlineCountp, startIdp, endIdp, inprep) | |
120 | 125 | log("start testing ...") |
121 | 126 | |
122 | - for i = 1, config.online, config.inpre do | |
123 | - for j = 1, config.inpre do | |
127 | + factory = deque.clone(pooldObj) | |
128 | + poold, onlineCount, startId, endId, inpre = pooldp, onlineCountp, startIdp, endIdp, inprep | |
129 | + id_max = startId - 1 | |
130 | + | |
131 | + for i = 1, onlineCount, inpre do | |
132 | + for j = 1, inpre do | |
133 | + if i + j - 1 > onlineCount then | |
134 | + break | |
135 | + end | |
124 | 136 | add_robot() |
125 | 137 | end |
126 | 138 | skynet.sleep(100) |
... | ... | @@ -131,5 +143,10 @@ local function start() |
131 | 143 | end |
132 | 144 | |
133 | 145 | skynet.start(function() |
134 | - skynet.fork(start) | |
146 | + skynet.dispatch("lua", function (_, _, command, ...) | |
147 | + if command == "start" then | |
148 | + start(...) | |
149 | + return | |
150 | + end | |
151 | + end) | |
135 | 152 | end) |
136 | 153 | \ No newline at end of file | ... | ... |
robot/unitTest/adv.lua
... | ... | @@ -8,6 +8,8 @@ local _M = class("hang", require("unitTest.unitTest")) |
8 | 8 | |
9 | 9 | function _M:start() |
10 | 10 | sendServer(actionCodes.Gm_clientRequest, MsgPack.pack({cmd = "fb", pm1 = 10606})) |
11 | + requestServer(actionCodes.Adv_roleFormatRpc, MsgPack.pack({index = 1, title = "hehe", leader = 1, leader2 = 2, heros = {[1] = 1, [2] = 2}})) | |
12 | + requestServer(actionCodes.Adv_selectTeamRpc, MsgPack.pack({index = 1})) | |
11 | 13 | self:task() |
12 | 14 | end |
13 | 15 | |
... | ... | @@ -24,8 +26,8 @@ function _M:task() |
24 | 26 | end |
25 | 27 | |
26 | 28 | function _M:startAdv() |
27 | - sendServer(actionCodes.Gm_clientRequest, MsgPack.pack({cmd = "advf", pm1 = 10606})) | |
28 | - requestServer(actionCodes.Adv_startAdvRpc, MsgPack.pack({chapterId = 101, format = {leader = 1, leader2 = 2, heros = {[1] = 1, [2] = 2}}})) | |
29 | + sendServer(actionCodes.Gm_clientRequest, MsgPack.pack({cmd = "advf"})) | |
30 | + requestServer(actionCodes.Adv_startAdvRpc, MsgPack.pack({chapterId = 101})) | |
29 | 31 | requestServer(actionCodes.Adv_exitAdvRpc, '') |
30 | 32 | end |
31 | 33 | ... | ... |
robot/unitTest/hero.lua
... | ... | @@ -35,8 +35,8 @@ function _M:drawHero10() |
35 | 35 | end |
36 | 36 | |
37 | 37 | function _M:createHeroRandom() |
38 | - sendServer(actionCodes.Gm_clientRequest, MsgPack.pack({cmd = "get", pm1 = 703, pm2 = 20})) | |
39 | - requestServer(actionCodes.Hero_createHeroRandomRpc, MsgPack.pack({itemId = 703})) | |
38 | + sendServer(actionCodes.Gm_clientRequest, MsgPack.pack({cmd = "get", pm1 = 722, pm2 = 40})) | |
39 | + requestServer(actionCodes.Hero_createHeroRandomRpc, MsgPack.pack({itemId = 722})) | |
40 | 40 | end |
41 | 41 | |
42 | 42 | ... | ... |
robot/unitTest/item.lua
... | ... | @@ -14,7 +14,7 @@ end |
14 | 14 | local taskMap = { |
15 | 15 | saleItem = {100}, |
16 | 16 | openItem = {100}, |
17 | - openTimeBox = {100}, | |
17 | + -- openTimeBox = {100}, | |
18 | 18 | } |
19 | 19 | |
20 | 20 | function _M:task() |
... | ... | @@ -31,8 +31,8 @@ end |
31 | 31 | |
32 | 32 | |
33 | 33 | function _M:openItem() |
34 | - sendServer(actionCodes.Gm_clientRequest, MsgPack.pack({cmd = "get", pm1 = 701, pm2 = 20})) | |
35 | - requestServer(actionCodes.Role_openItemRpc, MsgPack.pack({itemId = 701, count = 1})) | |
34 | + sendServer(actionCodes.Gm_clientRequest, MsgPack.pack({cmd = "get", pm1 = 831, pm2 = 1})) | |
35 | + requestServer(actionCodes.Role_openItemRpc, MsgPack.pack({itemId = 831, count = 1})) | |
36 | 36 | end |
37 | 37 | |
38 | 38 | function _M:openTimeBox() | ... | ... |
src/GlobalVar.lua
1 | +BUG_LOG = false | |
2 | + | |
3 | +function buglog(tag, advstr, ...) | |
4 | + if BUG_LOG then | |
5 | + print(string.format("[%s] %s", tag, string.format(advstr, ...))) | |
6 | + end | |
7 | +end | |
8 | + | |
9 | + | |
1 | 10 | XXTEA_KEY = "699D448D6D24f7F941E9F6E99F823E18" |
2 | 11 | RESET_TIME = 4 |
3 | 12 | |
... | ... | @@ -127,6 +136,7 @@ ItemId = { |
127 | 136 | AdvKey = 80, -- 冒险钥匙 |
128 | 137 | BoxKey = 60, -- 拆解工具 |
129 | 138 | AdvPower = 4701, -- 拾荒体力 |
139 | + CrisisScore = 8010, -- 积分 | |
130 | 140 | } |
131 | 141 | |
132 | 142 | TimeReset = { |
... | ... | @@ -283,6 +293,10 @@ CardType = { |
283 | 293 | BattlePassCard = 7, -- 探索指令 |
284 | 294 | } |
285 | 295 | |
296 | +ShopPackType = { | |
297 | + ActShopPack = 5, -- 活动礼包 | |
298 | +} | |
299 | + | |
286 | 300 | HeroQuality = { |
287 | 301 | N = 1, |
288 | 302 | R = 2, | ... | ... |
src/ProtocolCode.lua
... | ... | @@ -223,6 +223,12 @@ actionCodes = { |
223 | 223 | Activity_exchangeRpc = 657, |
224 | 224 | Activity_gachakonRpc = 658, |
225 | 225 | Activity_hangDropRpc = 659, |
226 | + Activity_startBattleRpc = 660, | |
227 | + Activity_endBattleRpc = 661, | |
228 | + Activity_battleRankRpc = 662, | |
229 | + Activity_battleMilestoneRpc = 663, | |
230 | + Activity_bossRewardRpc = 664, | |
231 | + Activity_crisisMilestoneRpc = 665, | |
226 | 232 | |
227 | 233 | Radio_startQuestRpc = 700, |
228 | 234 | Radio_finishQuestRpc = 701, | ... | ... |
src/RedisKeys.lua
... | ... | @@ -15,6 +15,12 @@ R_STORE = "role:%d:store" -- 商店 |
15 | 15 | R_ORDERS = "role:%d:orders" -- 订单 |
16 | 16 | R_ORDER = "order:%d:%d" |
17 | 17 | |
18 | +-- 通用排行榜 | |
19 | +RANK_COMMON = "rank:common:" | |
20 | +RANK_TYPE = { | |
21 | + ActBattleBoss = "act_battle_boss", | |
22 | + ActCrisis = "crisis", | |
23 | +} | |
18 | 24 | |
19 | 25 | -- rank |
20 | 26 | RANK_TOWER = "rank:tower" | ... | ... |
src/actions/ActivityAction.lua
... | ... | @@ -268,7 +268,8 @@ function _M.exchangeRpc(agent, data) |
268 | 268 | local msg = MsgPack.unpack(data) |
269 | 269 | local actid = msg.actid |
270 | 270 | local id = msg.id |
271 | - if not role.activity:isOpenById(actid) then return 1 end | |
271 | + local count = msg.count | |
272 | + if not role.activity:isOpenById(actid, "Exchange") then return 1 end | |
272 | 273 | |
273 | 274 | local exchangeCfg = csvdb["activity_exchangeCsv"][actid] |
274 | 275 | if not exchangeCfg then return 2 end |
... | ... | @@ -278,18 +279,26 @@ function _M.exchangeRpc(agent, data) |
278 | 279 | local curCount = exchangeData[id] or 0 |
279 | 280 | local actCfg = exchangeCfg[id] |
280 | 281 | local limitArr = actCfg.limit:toArray(true, "=") |
281 | - if curCount >= limitArr[2] then return 4 end | |
282 | + if curCount + count > limitArr[2] then return 4 end | |
282 | 283 | |
283 | 284 | local costs = actCfg.goods:toNumMap() |
285 | + for k,v in pairs(costs) do | |
286 | + costs[k] = v * count | |
287 | + end | |
284 | 288 | if not role:checkItemEnough(costs) then return 5 end |
285 | 289 | role:costItems(costs, {log = {desc = "actExchange", int1 = actid, int2 = id}}) |
286 | 290 | |
287 | - curCount = curCount + 1 | |
291 | + curCount = curCount + count | |
288 | 292 | exchangeData[id] = curCount |
289 | 293 | curData[actid] = exchangeData |
290 | 294 | role.activity:updateActData("Exchange", curData) |
291 | 295 | |
292 | - local reward, change = role:award(actCfg.award, {log = {desc = "actExchange", int1 = actid, int2 = id}}) | |
296 | + local award = actCfg.award:toNumMap() | |
297 | + for k,v in pairs(award) do | |
298 | + award[k] = v * count | |
299 | + end | |
300 | + | |
301 | + local reward, change = role:award(award, {log = {desc = "actExchange", int1 = actid, int2 = id}}) | |
293 | 302 | |
294 | 303 | |
295 | 304 | SendPacket(actionCodes.Activity_exchangeRpc, MsgPack.pack(role:packReward(reward, change))) |
... | ... | @@ -304,7 +313,7 @@ function _M.gachakonRpc(agent, data) |
304 | 313 | |
305 | 314 | if count > 10 then return end |
306 | 315 | |
307 | - if not role.activity:isOpenById(actid) then return 1 end | |
316 | + if not role.activity:isOpenById(actid, "Gachakon") then return 1 end | |
308 | 317 | |
309 | 318 | local actCtrlData = csvdb["activity_ctrlCsv"][actid] |
310 | 319 | if not actCtrlData then return 2 end |
... | ... | @@ -316,10 +325,10 @@ function _M.gachakonRpc(agent, data) |
316 | 325 | local gachakonInfo = role.activity:getActData("Gachakon") or {} |
317 | 326 | local award = {} |
318 | 327 | local remain = 0 |
328 | + local showAward = {} | |
319 | 329 | for i = 1, count do |
320 | 330 | local tmpCfg = clone(actCfg) |
321 | 331 | remain = 0 |
322 | - print("-----------------, ", i) | |
323 | 332 | for id, cfg in pairs(tmpCfg) do |
324 | 333 | local num = gachakonInfo[id] or 0 |
325 | 334 | num = cfg.amount >= num and cfg.amount - num or 0 |
... | ... | @@ -327,7 +336,7 @@ function _M.gachakonRpc(agent, data) |
327 | 336 | if cfg.weight > 0 then |
328 | 337 | remain = remain + num |
329 | 338 | end |
330 | - print("num ".. num, id, cfg.weight, cfg.amount) | |
339 | + --print("num ".. num, id, cfg.weight, cfg.amount) | |
331 | 340 | end |
332 | 341 | if remain == 0 then |
333 | 342 | break |
... | ... | @@ -336,6 +345,7 @@ function _M.gachakonRpc(agent, data) |
336 | 345 | if not id then return 4 end |
337 | 346 | gachakonInfo[id] = (gachakonInfo[id] or 0) + 1 |
338 | 347 | local curAward = tmpCfg[id].award:toNumMap() |
348 | + table.insert(showAward, curAward) | |
339 | 349 | for k, v in pairs(curAward) do |
340 | 350 | award[k] = (award[k] or 0) + v |
341 | 351 | end |
... | ... | @@ -350,13 +360,13 @@ function _M.gachakonRpc(agent, data) |
350 | 360 | role:costItems(cost, {log = {desc = "actGachakon", int1 = actid, int2 = count}}) |
351 | 361 | |
352 | 362 | local reward, change = role:award(award, {log = {desc = "actGachakon", int1 = actid, int2 = count}}) |
353 | - if remain <= count then | |
363 | + --print("-----------", remain, count) | |
364 | + if remain <= 1 then | |
354 | 365 | gachakonInfo = {} |
355 | - print("hahaha") | |
356 | 366 | end |
357 | 367 | role.activity:updateActData("Gachakon", gachakonInfo) |
358 | 368 | |
359 | - SendPacket(actionCodes.Activity_gachakonRpc, MsgPack.pack(role:packReward(reward, change))) | |
369 | + SendPacket(actionCodes.Activity_gachakonRpc, MsgPack.pack(showAward)) | |
360 | 370 | return true |
361 | 371 | end |
362 | 372 | |
... | ... | @@ -364,7 +374,7 @@ function _M.hangDropRpc(agent, data) |
364 | 374 | local role = agent.role |
365 | 375 | local msg = MsgPack.unpack(data) |
366 | 376 | local actid = msg.actid |
367 | - if not role.activity:isOpenById(actid) then return 1 end | |
377 | + if not role.activity:isOpenById(actid, "HangDrop") then return 1 end | |
368 | 378 | |
369 | 379 | local actCfg = csvdb["activity_putCsv"][actid] |
370 | 380 | if not actCfg then return 2 end |
... | ... | @@ -381,7 +391,7 @@ function _M.hangDropRpc(agent, data) |
381 | 391 | if type == 1 then |
382 | 392 | local actId = arr[2] |
383 | 393 | local carbonId = arr[3] |
384 | - if not role.activity:isOpenById(actid) then return 3 end | |
394 | + if not role.activity:isOpenById(actId, "ChallengeLevel") then return 3 end | |
385 | 395 | local clInfo = role.activity:getActData("ChallengeLevel") or {} |
386 | 396 | if not clInfo[carbonId] then |
387 | 397 | break |
... | ... | @@ -408,11 +418,409 @@ function _M.hangDropRpc(agent, data) |
408 | 418 | |
409 | 419 | reward, change = role:award(reward, {log = {desc = "actHangDrop", int1 = actid, int2 = num}}) |
410 | 420 | |
411 | - role.activity:updateActData("HangDrop", timeNow) | |
421 | + if num < 8 then | |
422 | + actData = actData + num * period | |
423 | + else | |
424 | + actData = timeNow | |
425 | + end | |
426 | + | |
427 | + role.activity:updateActData("HangDrop", actData) | |
412 | 428 | |
413 | 429 | SendPacket(actionCodes.Activity_hangDropRpc, MsgPack.pack(role:packReward(reward, change))) |
414 | 430 | |
415 | 431 | return true |
416 | 432 | end |
417 | 433 | |
434 | +local function getStarCount(cfg, data) | |
435 | + local count = 0 | |
436 | + for i = 0, #(cfg.sweep_condition:toTableArray(true)) do | |
437 | + if (1 << i & data) > 0 then | |
438 | + count = count + 1 | |
439 | + end | |
440 | + end | |
441 | + | |
442 | + return count | |
443 | +end | |
444 | + | |
445 | +function _M.startBattleRpc(agent, data) | |
446 | + local role = agent.role | |
447 | + local msg = MsgPack.unpack(data) | |
448 | + local actid = msg.actid | |
449 | + local id = msg.id | |
450 | + local count = msg.count | |
451 | + if not role.activity:isOpenById(actid, "ChallengeLevel") then return 1 end | |
452 | + | |
453 | + local actCfg = csvdb["activity_battleCsv"][actid] | |
454 | + if not actCfg then return 2 end | |
455 | + | |
456 | + local battleCfg = actCfg[id] | |
457 | + if not battleCfg then return 3 end | |
458 | + | |
459 | + local actData = role.activity:getActData("ChallengeLevel") or {} | |
460 | + | |
461 | + local preArr = battleCfg.prepose:toArray(true, "=") | |
462 | + for _, v in ipairs(preArr) do | |
463 | + local battleInfo = actData[v] | |
464 | + if not battleInfo then | |
465 | + return 4 | |
466 | + end | |
467 | + local star = battleInfo["star"] or 0 | |
468 | + if star <= 0 then | |
469 | + return 4 | |
470 | + end | |
471 | + end | |
472 | + -- check cost | |
473 | + local changeFlag = false | |
474 | + local ticket = actData["ticket"] | |
475 | + local num = 0 -- cost num | |
476 | + if battleCfg.type ~= "" then | |
477 | + role.activity:getBattleTicket(actid) | |
478 | + num = battleCfg.type:toArray(true, "=")[3] | |
479 | + if count and count > 0 then | |
480 | + if battleCfg.rank == 0 then | |
481 | + return 7 | |
482 | + end | |
483 | + local bi = actData[id] | |
484 | + if not bi then return 8 end | |
485 | + local star = bi["star"] or 0 | |
486 | + if star < 1 then | |
487 | + return 9 | |
488 | + end | |
489 | + num = num * count | |
490 | + end | |
491 | + if ticket < num then | |
492 | + return 6 | |
493 | + end | |
494 | + changeFlag = true | |
495 | + end | |
496 | + -- 解锁活动剧情 | |
497 | + role:checkStoryStatus(false, 5, id) | |
498 | + | |
499 | + if not count then | |
500 | + role.__actBattleCache = { | |
501 | + key = tostring(math.random()), | |
502 | + actid = actid, | |
503 | + id = id, | |
504 | + } | |
505 | + SendPacket(actionCodes.Activity_startBattleRpc, MsgPack.pack({key = role.__actBattleCache.key})) | |
506 | + else | |
507 | + if count <= 0 then | |
508 | + return | |
509 | + end | |
510 | + if battleCfg.rank == 0 then | |
511 | + return 7 | |
512 | + end | |
513 | + local bi = actData[id] | |
514 | + local star = bi["star"] | |
515 | + local award = battleCfg.item_clear:toNumMap() | |
516 | + if getStarCount(battleCfg, star) == 3 then | |
517 | + local aw = battleCfg.perfect_reward:toNumMap() | |
518 | + for k, v in pairs(aw) do | |
519 | + award[k] = (award[k] or 0) + v | |
520 | + end | |
521 | + end | |
522 | + for k, v in pairs(award) do | |
523 | + award[k] = v * count | |
524 | + end | |
525 | + local reward, change = role:award(award, {log = {desc = "actBattle", int1 = actid, int2 = count or 0}}) | |
526 | + SendPacket(actionCodes.Activity_startBattleRpc, MsgPack.pack(role:packReward(reward, change))) | |
527 | + | |
528 | + bi["sum"] = bi["sum"] + bi["top"] | |
529 | + actData["ticket"] = ticket - num | |
530 | + actData[id] = bi | |
531 | + changeFlag = true | |
532 | + | |
533 | + local rankVal = 0 | |
534 | + if battleCfg.rank == 1 then | |
535 | + rankVal = bi["sum"] | |
536 | + elseif battleCfg.rank == 2 then | |
537 | + rankVal = bi["top"] | |
538 | + end | |
539 | + role:updateRankCommon(RANK_TYPE.ActBattleBoss, rankVal) | |
540 | + end | |
541 | + if changeFlag then | |
542 | + role.activity:updateActData("ChallengeLevel", actData) | |
543 | + end | |
544 | + | |
545 | + return true | |
546 | +end | |
547 | + | |
548 | +function _M.endBattleRpc(agent, data) | |
549 | + local role = agent.role | |
550 | + local msg = MsgPack.unpack(data) | |
551 | + local actid = msg.actid | |
552 | + local id = msg.id | |
553 | + local key = msg.key | |
554 | + local isWin = msg.isWin | |
555 | + local heros = msg.heros | |
556 | + local support = msg.support | |
557 | + if not role.activity:isOpenById(actid, "ChallengeLevel") then return 1 end | |
558 | + | |
559 | + if not role.__actBattleCache then return 2 end | |
560 | + | |
561 | + if role.__actBattleCache.id ~= id or role.__actBattleCache.key ~= key and role.__actBattleCache.actid ~= actid then | |
562 | + SendPacket(actionCodes.Activity_endBattleRpc, MsgPack.pack({errorCode = 1})) | |
563 | + end | |
564 | + | |
565 | + local actCfg = csvdb["activity_battleCsv"][actid] | |
566 | + if not actCfg then return 3 end | |
567 | + | |
568 | + local battleCfg = actCfg[id] | |
569 | + if not battleCfg then return 4 end | |
570 | + | |
571 | + local actData = role.activity:getActData("ChallengeLevel") or {} | |
572 | + | |
573 | + -- 总输出 | |
574 | + local dmg = 0 | |
575 | + for k, v in pairs(msg.info.damage) do | |
576 | + if k % 100 == 2 then | |
577 | + dmg = dmg + v | |
578 | + end | |
579 | + end | |
580 | + | |
581 | + local reward, change = {}, nil | |
582 | + | |
583 | + local battleInfo = actData[id] or {} | |
584 | + local curStar = 0 | |
585 | + if isWin then | |
586 | + local herosInfo = msg.heros | |
587 | + | |
588 | + local check = {} | |
589 | + -- 1 通关 | |
590 | + check[1] = function(_) | |
591 | + return true | |
592 | + end | |
593 | + -- 2 阵亡人数 <= N | |
594 | + check[2] = function(_, cond) | |
595 | + return msg.info.dead and msg.info.dead <= cond | |
596 | + end | |
597 | + -- 3 全员存活 | |
598 | + check[3] = function(_) | |
599 | + return msg.info.dead and msg.info.dead == 0 | |
600 | + end | |
601 | + -- 4 指定种族 >= N | |
602 | + check[4] = function(_, cond) | |
603 | + local count = 0 | |
604 | + for _, one in pairs(herosInfo) do | |
605 | + local heroData = csvdb["unitCsv"][one.type] | |
606 | + if heroData.camp == cond then | |
607 | + count = count + 1 | |
608 | + end | |
609 | + end | |
610 | + return count >= cond | |
611 | + end | |
612 | + -- 5 指定职业 >= N | |
613 | + check[5] = function(_, cond) | |
614 | + local count = 0 | |
615 | + for _, one in pairs(herosInfo) do | |
616 | + local heroData = csvdb["unitCsv"][one.type] | |
617 | + if heroData.job == cond then | |
618 | + count = count + 1 | |
619 | + end | |
620 | + end | |
621 | + return count >= cond | |
622 | + end | |
623 | + -- 6 含有指定角色 | |
624 | + check[6] = function(_, cond) | |
625 | + for _, one in pairs(herosInfo) do | |
626 | + if one.type == cond then | |
627 | + return true | |
628 | + end | |
629 | + end | |
630 | + return false | |
631 | + end | |
632 | + -- 7 通关耗时 <= X 秒 msg.info.atime | |
633 | + check[7] = function(_, cond) | |
634 | + return msg.info.atime and msg.info.atime <= cond | |
635 | + end | |
636 | + -- 8 总输出值 msg.info.atime | |
637 | + check[8] = function(_, cond) | |
638 | + return dmg >= cond | |
639 | + end | |
640 | + curStar = 0 | |
641 | + local sweepConds = battleCfg.sweep_condition:toTableArray(true) | |
642 | + for i, cond in ipairs(sweepConds) do | |
643 | + if check[cond[1]] and check[cond[1]](table.unpack(cond)) then | |
644 | + curStar = curStar + (1 << (i - 1)) | |
645 | + end | |
646 | + end | |
647 | + else | |
648 | + curStar = 0 | |
649 | + if battleCfg.rank ~= 0 then | |
650 | + curStar = 1 | |
651 | + end | |
652 | + end | |
653 | + local oldStarNum = getStarCount(battleCfg, battleInfo["star"] or 0) | |
654 | + local newStarNum = getStarCount(battleCfg, curStar) | |
655 | + if newStarNum > oldStarNum then | |
656 | + battleInfo["star"] = curStar | |
657 | + end | |
658 | + | |
659 | + if battleCfg.rank ~= 0 then | |
660 | + -- 消耗门票 | |
661 | + role.activity:getBattleTicket(actid) | |
662 | + local num = battleCfg.type:toArray(true, "=")[3] | |
663 | + actData["ticket"] = math.max(actData["ticket"] - num, 0) | |
664 | + | |
665 | + -- 更新排行榜 最高伤害 | |
666 | + battleInfo["top"] = math.max(battleInfo["top"] or 0, dmg) | |
667 | + battleInfo["sum"] = (battleInfo["sum"] or 0) + dmg | |
668 | + local rankVal = 0 | |
669 | + if battleCfg.rank == 1 then | |
670 | + rankVal = battleInfo["sum"] | |
671 | + elseif battleCfg.rank == 2 then | |
672 | + rankVal = battleInfo["top"] | |
673 | + end | |
674 | + if rankVal > 0 then | |
675 | + role:updateRankCommon(RANK_TYPE.ActBattleBoss, rankVal) | |
676 | + end | |
677 | + end | |
678 | + actData[id] = battleInfo | |
679 | + role.activity:updateActData("ChallengeLevel", actData) | |
680 | + | |
681 | + if (oldStarNum == 0 and newStarNum > 0) or battleCfg.rank ~= 0 then | |
682 | + reward = battleCfg.item_clear:toNumMap() | |
683 | + end | |
684 | + if (oldStarNum < 3 and newStarNum == 3) or (battleCfg.rank ~= 0 and newStarNum == 3) then | |
685 | + local aw = battleCfg.perfect_reward:toNumMap() | |
686 | + for k, v in pairs(aw) do | |
687 | + reward[k] = (reward[k] or 0) + v | |
688 | + end | |
689 | + end | |
690 | + | |
691 | + role:checkBattle("act_battle", { | |
692 | + cfg = battleCfg, | |
693 | + star = newStarNum, | |
694 | + isWin = isWin, | |
695 | + info = msg.info, | |
696 | + reward = reward, | |
697 | + heros = heros, | |
698 | + supports = support, | |
699 | + }) | |
700 | + | |
701 | + -- 解锁活动剧情 | |
702 | + if newStarNum >= 3 then | |
703 | + role:checkStoryStatus(false, 5, id) | |
704 | + end | |
705 | + | |
706 | + reward, change = role:award(reward, {log = {desc = "actBattle", int1 = actid, int2 = newStarNum}}) | |
707 | + | |
708 | + SendPacket(actionCodes.Activity_endBattleRpc, MsgPack.pack({ | |
709 | + reward = reward, | |
710 | + change = change | |
711 | + })) | |
712 | + | |
713 | + return true | |
714 | +end | |
715 | + | |
716 | +function _M.battleRankRpc(agent, data) | |
717 | + local role = agent.role | |
718 | + local msg = MsgPack.unpack(data) | |
719 | + local actid = msg.actid | |
720 | + local cfg = csvdb["activity_ctrlCsv"][actid] | |
721 | + if not cfg then return 1 end | |
722 | + if not role.activity:isOpen(cfg.showType) then return 2 end | |
723 | + local actTypeToRank = { | |
724 | + [role.activity.ActivityType.ChallengeLevel] = RANK_TYPE.ActBattleBoss, | |
725 | + [role.activity.ActivityType.Crisis] = RANK_TYPE.ActCrisis, | |
726 | + } | |
727 | + if not actTypeToRank[cfg.showType] then return end | |
728 | + local rankInfo = role:getRankInfoCommon(actTypeToRank[cfg.showType]) | |
729 | + SendPacket(actionCodes.Activity_battleRankRpc, MsgPack.pack(rankInfo)) | |
730 | + return true | |
731 | +end | |
732 | + | |
733 | +function _M.battleMilestoneRpc(agent, data) | |
734 | + local role = agent.role | |
735 | + local msg = MsgPack.unpack(data) | |
736 | + local actid = msg.actid | |
737 | + local id = msg.id | |
738 | + local index = msg.index | |
739 | + | |
740 | + if not role.activity:isOpenById(actid, "ChallengeLevel") then return 1 end | |
741 | + | |
742 | + local actCfg = csvdb["activity_mileageCsv"][actid] | |
743 | + if not actCfg then return 3 end | |
744 | + | |
745 | + local mileCfg = actCfg[index] | |
746 | + if not mileCfg then return 4 end | |
747 | + | |
748 | + local actData = role.activity:getActData("ChallengeLevel") or {} | |
749 | + local battleInfo = actData[id] or {} | |
750 | + local val = 0 | |
751 | + if mileCfg.type == 1 then | |
752 | + val = battleInfo["sum"] or 0 | |
753 | + elseif mileCfg.type == 2 then | |
754 | + val = battleInfo["top"] or 0 | |
755 | + end | |
756 | + | |
757 | + local record = battleInfo["r"] or "" | |
758 | + local flag = string.char(string.getbit(record, index)) | |
759 | + if flag == "1" then return 5 end | |
760 | + if mileCfg.condition > val then return 6 end | |
761 | + | |
762 | + battleInfo["r"] = string.setbit(record, index) | |
763 | + actData[id] = battleInfo | |
764 | + role.activity:updateActData("ChallengeLevel", actData) | |
765 | + | |
766 | + local award = mileCfg.reward:toNumMap() | |
767 | + local reward, change = role:award(award, {log = {desc = "actMilestone", int1 = actid, int2 = index}}) | |
768 | + SendPacket(actionCodes.Activity_battleMilestoneRpc, MsgPack.pack(role:packReward(reward, change))) | |
769 | + | |
770 | + return true | |
771 | +end | |
772 | + | |
773 | +function _M.crisisMilestoneRpc(agent, data) | |
774 | + local role = agent.role | |
775 | + local msg = MsgPack.unpack(data) | |
776 | + local actid = msg.actid | |
777 | + local id = msg.id | |
778 | + if not role.activity:isOpenById(actid, "Crisis") then return 1 end | |
779 | + local actCfg = csvdb["activity_mileageCsv"][actid] | |
780 | + if not actCfg then return 3 end | |
781 | + | |
782 | + local curCsv = actCfg[id] | |
783 | + if not curCsv then return 4 end | |
784 | + | |
785 | + if role:getItemCount(ItemId.CrisisScore) < curCsv.condition then | |
786 | + return 5 | |
787 | + end | |
788 | + | |
789 | + local actData = role.activity:getActData("Crisis") or {} | |
790 | + actData.score = actData.score or {} | |
791 | + if actData.score[id] then | |
792 | + return 6 | |
793 | + end | |
794 | + actData.score[id] = -1 | |
795 | + role.activity:updateActData("Crisis", actData) | |
796 | + | |
797 | + local reward, change = role:award(curCsv.reward, {log = {desc = "actMilecrisis", int1 = actid}}) | |
798 | + SendPacket(actionCodes.Activity_crisisMilestoneRpc, MsgPack.pack(role:packReward(reward, change))) | |
799 | + return true | |
800 | +end | |
801 | + | |
802 | + | |
803 | +function _M.bossRewardRpc(agent, data) | |
804 | + local role = agent.role | |
805 | + local msg = MsgPack.unpack(data) | |
806 | + local actid = msg.actid | |
807 | + local id = msg.id | |
808 | + local index = msg.index | |
809 | + | |
810 | + if not role.activity:isOpenById(actid, "ChallengeLevel") then return 1 end | |
811 | + | |
812 | + local actCfg = csvdb["activity_battleCsv"][actid] | |
813 | + if not actCfg then return 2 end | |
814 | + | |
815 | + local battleCfg = actCfg[id] | |
816 | + if not battleCfg then return 3 end | |
817 | + | |
818 | + if battleCfg.boss_reward_id == 0 then return 4 end | |
819 | + | |
820 | + --local award = mileCfg.reward:toNumMap() | |
821 | + --local reward, change = role:award(award, {log = {desc = "actMilestone", int1 = actid, int2 = index}}) | |
822 | + --SendPacket(actionCodes.Activity_battleMilestoneRpc, MsgPack.pack(role:packReward(reward, change))) | |
823 | + return true | |
824 | +end | |
825 | + | |
418 | 826 | return _M |
419 | 827 | \ No newline at end of file | ... | ... |
src/actions/DinerAction.lua
... | ... | @@ -598,6 +598,7 @@ function _M.updateTaskRpc( agent, data ) |
598 | 598 | restaurant_order_status = cmd, -- 订单任务状态,接受:0, 拒绝:1, 完成:2 |
599 | 599 | restaurant_order_rwd = reward or {}, -- 订单完成奖励,json格式记录,{"itemid1":123,"itemid2":12,……….} |
600 | 600 | restaurant_order_lv = taskData.rarity, -- 订单品质等级,普通:0, 稀有:1, 顶级:2, 豪华:3 |
601 | + restaurant_order_type = 1, -- 订单任务类型,0:特殊顾客,1:特别订单 | |
601 | 602 | }) |
602 | 603 | |
603 | 604 | role.dinerData:updateProperty({field = "order", value = json.encode(orders)}) |
... | ... | @@ -896,6 +897,14 @@ function _M.entrustRpc(agent , data) |
896 | 897 | |
897 | 898 | reward, change = role:award(curData.reward, {log = {desc = "dinerEntrus", int1 = entrustId}}) |
898 | 899 | table.remove(entrust, 1) |
900 | + | |
901 | + role:log("restaurant_order", { | |
902 | + restaurant_order_id = entrustId, -- 订单任务ID | |
903 | + restaurant_order_status = 2, -- 订单任务状态,接受:0, 拒绝:1, 完成:2 | |
904 | + restaurant_order_rwd = reward or {}, -- 订单完成奖励,json格式记录,{"itemid1":123,"itemid2":12,……….} | |
905 | + restaurant_order_lv = curData.type, -- 订单品质等级,普通:0, 稀有:1, 顶级:2, 豪华:3 | |
906 | + restaurant_order_type = 0, -- 订单任务类型,0:特殊顾客,1:特别订单 | |
907 | + }) | |
899 | 908 | elseif ctype == 2 then -- 放弃 |
900 | 909 | table.remove(entrust, 1) |
901 | 910 | else | ... | ... |
src/actions/GmAction.lua
... | ... | @@ -502,6 +502,11 @@ function _M.guide(role, pms) |
502 | 502 | end |
503 | 503 | end |
504 | 504 | end |
505 | + for _, data in pairs(csvdb["guide_unlockCsv"]) do | |
506 | + if data.type == 0 or data.type == 3 then | |
507 | + str = str:setv(data.id,1) | |
508 | + end | |
509 | + end | |
505 | 510 | role:updateProperty({field = "funcGuide", value = str}) |
506 | 511 | role:mylog("gm_action", {desc = "sguide", key1 = pms.sender}) |
507 | 512 | |
... | ... | @@ -524,6 +529,16 @@ function _M.guide(role, pms) |
524 | 529 | return "成功" |
525 | 530 | end |
526 | 531 | |
532 | +table.insert(helpDes, {"挑战关卡次数", "actbattle"}) | |
533 | +function _M.actbattle(role, pms) | |
534 | + if not role.activity:isOpen("ChallengeLevel") then return end | |
535 | + local actData = role.activity:getActData("ChallengeLevel") | |
536 | + actData["ticket"] = 100 | |
537 | + role.activity:updateActData("ChallengeLevel", actData) | |
538 | + | |
539 | + return "成功" | |
540 | +end | |
541 | + | |
527 | 542 | function _M.helpRpc(agent, data) |
528 | 543 | SendPacket(actionCodes.Gm_helpRpc, MsgPack.pack({help = helpDes})) |
529 | 544 | return true |
... | ... | @@ -535,6 +550,7 @@ function _M.test(role, pms) |
535 | 550 | --hero.unlockPoolRpc({role = role}, MsgPack.pack({type = id})) |
536 | 551 | |
537 | 552 | --role:sendMail(13, nil, "1=2", {111}) |
553 | + dump(redisproxy:zrevrange("rank:tower", 0 , 10, "WITHSCORES")) | |
538 | 554 | return "成功" |
539 | 555 | end |
540 | 556 | ... | ... |
src/actions/HangAction.lua
... | ... | @@ -498,46 +498,49 @@ function _M.buyBonusCountRpc(agent, data) |
498 | 498 | return true |
499 | 499 | end |
500 | 500 | |
501 | -local function bonusWinReward(role, bonusData, bwin, count) | |
501 | +local function bonusWinReward(role, bonusData, rewardType, count) | |
502 | 502 | count = count or 1 |
503 | - local open, actId = role.activity:isOpen("BonusDouble") | |
504 | - local actData = csvdb["activity_ctrlCsv"][actId] | |
505 | - local extraCnt = role.storeData:getBonusExtraFightCount() | |
506 | - | |
507 | - local coef = 1 | |
508 | - if open and actData then | |
509 | - coef = tonumber(actData.condition2) | |
510 | - end | |
511 | - local bonusC = role.dailyData:getProperty("bonusC") | |
512 | - bonusC[bonusData.type] = bonusC[bonusData.type] or {c = 0, b = 0} | |
513 | - if globalCsv.bonus_daily_count * coef + extraCnt - bonusC[bonusData.type]["c"] < count then return false, 1 end | |
514 | - bonusC[bonusData.type]["c"] = bonusC[bonusData.type]["c"] + count | |
515 | - role.dailyData:updateProperty({field = "bonusC", value = bonusC}) | |
516 | 503 | |
517 | - local reward, change | |
518 | - reward = bonusData.reward:toNumMap() | |
519 | - for itemId, c in pairs(reward) do | |
520 | - reward[itemId] = c * count | |
521 | - end | |
522 | - for i = 1, count do | |
523 | - local chance = bonusData.chance:randWeight(true) | |
524 | - if chance[1] ~= 0 then | |
525 | - reward[chance[1]] = (reward[chance[1]] or 0) + chance[2] | |
504 | + local reward, change = {} | |
505 | + if rewardType == 1 or rewardType == 4 then | |
506 | + for k, v in pairs(bonusData.clear_reward:toNumMap()) do | |
507 | + reward[k] = (reward[k] or 0) + v | |
526 | 508 | end |
527 | 509 | end |
528 | 510 | |
529 | - for k, v in pairs(reward) do | |
530 | - reward[k] = v * (coef > 1 and actData.condition or 1) | |
531 | - end | |
532 | - | |
533 | - if bwin then -- 满星 额外奖励 | |
511 | + if rewardType == 2 or rewardType == 4 then | |
534 | 512 | for k, v in pairs(bonusData.perfect_reward:toNumMap()) do |
535 | 513 | reward[k] = (reward[k] or 0) + v |
536 | 514 | end |
537 | 515 | end |
538 | - reward, change = role:award(reward, {log = {desc = "bonusBattle", int1 = id}}) | |
539 | - role:checkTaskEnter("BonusPass", {id = id, count = count}) | |
540 | - return true, reward, change | |
516 | + | |
517 | + if rewardType == 3 then | |
518 | + local open, actId = role.activity:isOpen("BonusDouble") | |
519 | + local actData | |
520 | + if open then | |
521 | + actData = csvdb["activity_ctrlCsv"][actId] | |
522 | + end | |
523 | + | |
524 | + reward = bonusData.reward:toNumMap() | |
525 | + for itemId, c in pairs(reward) do | |
526 | + reward[itemId] = c * count | |
527 | + end | |
528 | + for i = 1, count do | |
529 | + local chance = bonusData.chance:randWeight(true) | |
530 | + if chance[1] ~= 0 then | |
531 | + reward[chance[1]] = (reward[chance[1]] or 0) + chance[2] | |
532 | + end | |
533 | + end | |
534 | + if open and actData then | |
535 | + for k, v in pairs(reward) do | |
536 | + reward[k] = v * (actData.condition > 1 and actData.condition or 1) | |
537 | + end | |
538 | + end | |
539 | + end | |
540 | + | |
541 | + reward, change = role:award(reward, {log = {desc = "bonusBattle", int1 = bonusData.id}}) | |
542 | + role:checkTaskEnter("BonusPass", {id = bonusData.id, count = count}) | |
543 | + return reward, change | |
541 | 544 | end |
542 | 545 | |
543 | 546 | function _M.startBonusBattleRpc(agent, data) |
... | ... | @@ -559,23 +562,24 @@ function _M.startBonusBattleRpc(agent, data) |
559 | 562 | if not bonusData then return 3 end |
560 | 563 | if not role:checkHangPass(bonusData.unlock) then return 4 end |
561 | 564 | |
562 | - local bonusC = role.dailyData:getProperty("bonusC") | |
563 | - bonusC[bonusData.type] = bonusC[bonusData.type] or {c = 0, b = 0} | |
564 | - | |
565 | - local actData = csvdb["activity_ctrlCsv"][actId] | |
566 | - | |
567 | - local extraCnt = role.storeData:getBonusExtraFightCount() | |
568 | - local coef = 1 | |
569 | - if open and actData then | |
570 | - coef = tonumber(actData.condition2) | |
571 | - end | |
572 | - | |
573 | - if math.illegalNum(count, 1, globalCsv.bonus_daily_count * coef + extraCnt - bonusC[bonusData.type]["c"]) then return 7 end | |
574 | 565 | |
575 | 566 | local bonusStar = role:getProperty("bonusStar") |
576 | 567 | if bonusStar[id] and bonusStar[id] >= (1 << #bonusData.sweep_condition:toTableArray(true)) - 1 then |
577 | - local status, reward, change = bonusWinReward(role, bonusData, nil, count) | |
578 | - if not status then return 10 * (reward or 0) end | |
568 | + local bonusC = role.dailyData:getProperty("bonusC") | |
569 | + bonusC[bonusData.type] = bonusC[bonusData.type] or {c = 0, b = 0} | |
570 | + | |
571 | + local actData = csvdb["activity_ctrlCsv"][actId] | |
572 | + local extraCnt = role.storeData:getBonusExtraFightCount() | |
573 | + local coef = 1 | |
574 | + if open and actData then | |
575 | + coef = tonumber(actData.condition2) | |
576 | + end | |
577 | + if math.illegalNum(count, 1, globalCsv.bonus_daily_count * coef + extraCnt - bonusC[bonusData.type]["c"]) then return 7 end | |
578 | + | |
579 | + bonusC[bonusData.type]["c"] = bonusC[bonusData.type]["c"] + count | |
580 | + role.dailyData:updateProperty({field = "bonusC", value = bonusC}) | |
581 | + | |
582 | + local reward, change = bonusWinReward(role, bonusData, 3, count) | |
579 | 583 | SendPacket(actionCodes.Hang_startBonusBattleRpc, MsgPack.pack({reward = reward, change = change})) |
580 | 584 | else |
581 | 585 | local bTeam = role:getTeamFormatByType(TeamSystemType.BonusBattle) |
... | ... | @@ -605,15 +609,16 @@ function _M.endBonusBattleRpc(agent, data) |
605 | 609 | end |
606 | 610 | local bonusData = csvdb["bonus_battleCsv"][id] |
607 | 611 | |
608 | - local reward, change | |
612 | + local reward, change = {} | |
609 | 613 | |
610 | 614 | local bonusStar = role:getProperty("bonusStar") |
615 | + local oldStar = bonusStar[id] or 0 | |
611 | 616 | local curStar = 0 |
612 | 617 | if starNum and starNum > 0 then |
613 | 618 | -- 胜利扣除次数 |
614 | 619 | |
615 | 620 | local bTeam = role:getTeamFormatByType(TeamSystemType.BonusBattle) |
616 | - local herosInfo = role:getTeamHerosInfo(bTeam.heros) | |
621 | + local herosInfo = role:getTeamHerosInfo(bTeam).heros | |
617 | 622 | |
618 | 623 | local check = {} |
619 | 624 | -- 1 通关 |
... | ... | @@ -632,7 +637,7 @@ function _M.endBonusBattleRpc(agent, data) |
632 | 637 | check[4] = function(_, cond) |
633 | 638 | local count = 0 |
634 | 639 | for _, one in pairs(herosInfo) do |
635 | - local heroData = csv["unitCsv"][one.type] | |
640 | + local heroData = csvdb["unitCsv"][one.type] | |
636 | 641 | if heroData.camp == cond then |
637 | 642 | count = count + 1 |
638 | 643 | end |
... | ... | @@ -643,7 +648,7 @@ function _M.endBonusBattleRpc(agent, data) |
643 | 648 | check[5] = function(_, cond) |
644 | 649 | local count = 0 |
645 | 650 | for _, one in pairs(herosInfo) do |
646 | - local heroData = csv["unitCsv"][one.type] | |
651 | + local heroData = csvdb["unitCsv"][one.type] | |
647 | 652 | if heroData.job == cond then |
648 | 653 | count = count + 1 |
649 | 654 | end |
... | ... | @@ -671,12 +676,23 @@ function _M.endBonusBattleRpc(agent, data) |
671 | 676 | end |
672 | 677 | end |
673 | 678 | local status |
674 | - status, reward, change = bonusWinReward(role, bonusData, curStar >= (1 << #sweepConds) - 1) | |
675 | - if not status then return 10 + (reward or 0) end | |
679 | + local rewardType = 0 | |
680 | + if curStar >= (1 << #sweepConds) - 1 then -- 满星 | |
681 | + rewardType = 2 | |
682 | + if oldStar == 0 then --通关 | |
683 | + rewardType = 4 | |
684 | + end | |
685 | + elseif oldStar == 0 then --通关 | |
686 | + rewardType = 1 | |
687 | + end | |
688 | + | |
689 | + if rewardType ~= 0 then | |
690 | + reward, change = bonusWinReward(role, bonusData, rewardType) | |
691 | + end | |
676 | 692 | else |
677 | - curStar = 0 | |
693 | + curStar = oldStar | |
678 | 694 | end |
679 | - if curStar ~= bonusStar[id] then | |
695 | + if curStar ~= oldStar then | |
680 | 696 | bonusStar[id] = curStar |
681 | 697 | role:updateProperty({field = "bonusStar", value = bonusStar}) |
682 | 698 | end | ... | ... |
src/actions/HeroAction.lua
... | ... | @@ -146,7 +146,9 @@ function _M.talentRpc(agent, data) |
146 | 146 | local talent = hero:getProperty("talent") |
147 | 147 | local heroCfgId = hero:getProperty("type") |
148 | 148 | local curStage = talent:getv(0, 1) |
149 | + local oldStage = curStage | |
149 | 150 | local curLevel = talent:getv(1, 1) |
151 | + local oldLevel = curLevel | |
150 | 152 | local curData = csvdb["unit_talent_"..heroCfgId.."Csv"][curStage] |
151 | 153 | if not curData then return 1 end |
152 | 154 | local oldSkillLv = hero:getSkillLevel(1) |
... | ... | @@ -174,13 +176,16 @@ function _M.talentRpc(agent, data) |
174 | 176 | |
175 | 177 | hero:updateProperty({field = "talent", value = talent}) |
176 | 178 | |
179 | + | |
177 | 180 | role:log("hero_talent", { |
178 | 181 | hero_id = hero:getProperty("type"), --英雄ID |
179 | - hero_talent_id = curStage, --天赋ID | |
180 | - hero_talent_cost = cost, -- 英雄天赋升级消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...} | |
181 | - hero_talent_levelbef = oldSkillLv, -- 英雄技能升级前等级 | |
182 | - hero_talent_level = hero:getSkillLevel(1), -- 英雄技能升级后等级 | |
182 | + hero_talent_stagebef = oldStage, --英雄精进升级前停留阶段 | |
183 | + hero_talent_stage = curStage, --英雄精进升级后停留阶段 | |
184 | + hero_talent_cost = cost, --英雄精进升级消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,….} | |
185 | + hero_talent_subid = curData[oldLevel].effect, --升级属性ID,生命、攻击、防御、命中、闪避分别对应(0,1,2,3,4) | |
186 | + hero_talent_sublevel = curData[oldLevel].level, --升级属性等级,如生命升级从1到2,则记录2 | |
183 | 187 | }) |
188 | + | |
184 | 189 | hero:mylog({desc = "talent", int1 = talent:getv(0, 1), int2 = talent:getv(1, 1)}) |
185 | 190 | |
186 | 191 | SendPacket(actionCodes.Hero_talentRpc, '') |
... | ... | @@ -447,7 +452,6 @@ function _M.referEquipsRpc(agent, data) |
447 | 452 | end |
448 | 453 | end |
449 | 454 | |
450 | - local oldAttr = hero:getTotalAttrs() | |
451 | 455 | local oldBattleV = hero:getProperty("battleV") |
452 | 456 | local wear = {} |
453 | 457 | |
... | ... | @@ -477,18 +481,14 @@ function _M.referEquipsRpc(agent, data) |
477 | 481 | -- 更新角色 |
478 | 482 | hero:updateProperty({field = "equip", value = curEquip}) |
479 | 483 | |
480 | - role:finishGuide(23) | |
481 | - | |
482 | - local curAttr = hero:getTotalAttrs() | |
483 | - local attrChange = getChangeAttrJson(oldAttr, curAttr) | |
484 | 484 | for typ, data in pairs(wear) do |
485 | 485 | role:log("equip_wear", { |
486 | 486 | hero_id = hero:getProperty("type"), --英雄ID |
487 | 487 | equip_id = data.id, --装备ID |
488 | 488 | equip_wear_action = data.act, --装备操作类型:装备:0,卸载:1 |
489 | 489 | equip_wear_part = typ, --装备部位,记录部位ID |
490 | - equip_wear_result = curAttr, --装备操作后结果,记录属性变化,json格式记录,{“aa”:1234,"bb":4567} | |
491 | - equip_wear_change = attrChange, --装备操作变化值,记录属性变化,记录正负值,json格式记录,{“aa”:1234,"bb":-45} | |
490 | + equip_wear_scorebef = oldBattleV, --装备前英雄评分 | |
491 | + equip_wear_score = hero:getProperty("battleV"), --装备后英雄评分 | |
492 | 492 | equip_wear_mode = isAuto and 0 or 1, --用以区分自动装备还是手动装备,自动记录为0,手动记录为1 |
493 | 493 | }) |
494 | 494 | end |
... | ... | @@ -714,6 +714,7 @@ end |
714 | 714 | function _M.drawHeroRpc(agent, data) |
715 | 715 | local role = agent.role |
716 | 716 | local msg = MsgPack.unpack(data) |
717 | + local actid = msg.actid | |
717 | 718 | |
718 | 719 | if not role:isFuncUnlock(FuncUnlock.GetHero) then return 1 end |
719 | 720 | local btype = msg.pool -- 1 2 3 4 5 卡池类型 4新手卡池 5心愿卡池 |
... | ... | @@ -726,11 +727,32 @@ function _M.drawHeroRpc(agent, data) |
726 | 727 | end |
727 | 728 | end |
728 | 729 | |
730 | + -- 活动卡池 | |
731 | + if actid then | |
732 | + if not role.activity:isOpenById(actid, "ActHeroPool") then return end | |
733 | + local cfg = csvdb["activity_ctrlCsv"][actid] | |
734 | + if not cfg then return end | |
735 | + | |
736 | + btype = cfg.condition | |
737 | + end | |
738 | + | |
729 | 739 | if btype == 1 then |
730 | 740 | -- 判断定向卡池活动开启 |
731 | 741 | if not role.activity:isOpen("RaceDraw") then |
732 | 742 | return |
733 | 743 | end |
744 | + elseif btype == 2 then | |
745 | + if role:getProperty("newerGuide") ~= "8=1" then | |
746 | + -- 判断普通卡池 | |
747 | + if role.activity:isOpen("WishHeroPool") then | |
748 | + return | |
749 | + end | |
750 | + end | |
751 | + elseif btype == 5 then | |
752 | + -- 判断心愿单卡池 | |
753 | + if not role.activity:isOpen("WishHeroPool") then | |
754 | + return | |
755 | + end | |
734 | 756 | end |
735 | 757 | |
736 | 758 | local buildTypeData = csvdb["build_typeCsv"][btype] |
... | ... | @@ -947,12 +969,12 @@ function _M.drawHeroRpc(agent, data) |
947 | 969 | gacha_up = 0, -- 卡池UP角色 |
948 | 970 | gacha_times = drawCount[drawType], -- 抽卡次数 |
949 | 971 | gacha_reward = logReward, -- 抽卡结果,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"} |
950 | - currency = cost, -- 购买道具消耗的货币 | |
972 | + gacha_cost = cost, -- 购买道具消耗的货币 | |
951 | 973 | gacha_cnt = floorHeroCount, |
952 | 974 | }) |
953 | 975 | SendPacket(actionCodes.Hero_drawHeroRpc, MsgPack.pack({reward = reward})) -- 这个 reward 是数组 |
954 | 976 | |
955 | - if btype == 1 or btype == 2 then | |
977 | + if (buildTypeData["can_feedback"] or 0) == 1 then | |
956 | 978 | -- 达到一定次数,给响应奖励 |
957 | 979 | local oldVal = role:getProperty("repayHero") or 0 |
958 | 980 | local newVal = oldVal + drawCount[drawType] |
... | ... | @@ -1092,6 +1114,9 @@ function _M.itemComposeRpc(agent, data) |
1092 | 1114 | if not config then return 2 end |
1093 | 1115 | |
1094 | 1116 | local cost = config.cost:toNumMap() |
1117 | + for k, v in pairs(cost) do | |
1118 | + cost[k] = v * count | |
1119 | + end | |
1095 | 1120 | if not role:checkItemEnough(cost) then return 2 end |
1096 | 1121 | role:costItems(cost, {log = {desc = "itemCompose", int1 = itemId, int2 = count}}) |
1097 | 1122 | role:award({[itemId] = count}, {log = {desc = "itemCompose"}}) | ... | ... |
src/actions/HttpAction.lua
... | ... | @@ -187,6 +187,9 @@ function _M.online(query) |
187 | 187 | return count |
188 | 188 | end |
189 | 189 | |
190 | +function _M.dbqlen(query) | |
191 | + return skynet.call(redisd, "debug", "INFO") | |
192 | +end | |
190 | 193 | |
191 | 194 | function _M.account_init(query, body) |
192 | 195 | if not query.id or not body or body == "" then return "指令不存在" end | ... | ... |
src/actions/PvpAction.lua
... | ... | @@ -135,7 +135,7 @@ local function getMatchInfo(role, pvpList, battleCache, dbKey, infoFuncName, inf |
135 | 135 | if k == "battleInfo" then |
136 | 136 | battleCache[curInfo.roleId] = v |
137 | 137 | else |
138 | - if (k == "heros" or k == "battleV") and infoCache then | |
138 | + if (k == "team" or k == "battleV") and infoCache then | |
139 | 139 | infoCache[curInfo.roleId] = infoCache[curInfo.roleId] or {} |
140 | 140 | infoCache[curInfo.roleId][k] = v |
141 | 141 | end |
... | ... | @@ -705,12 +705,12 @@ function _M.endBattleHRpc(agent, data) |
705 | 705 | info.winId = info.isWin and roleId or match.id |
706 | 706 | info.isWin = nil |
707 | 707 | selfTeam[_idx] = { |
708 | - heros = role:getTeamHerosInfo(_pvpStartBattleCacheH.pvpTH[_idx].heros), | |
708 | + team = role:getTeamHerosInfo(_pvpStartBattleCacheH.pvpTH[_idx]), | |
709 | 709 | battleV = role:getTeamBattleValue(_pvpStartBattleCacheH.pvpTH[_idx].heros) |
710 | 710 | } |
711 | 711 | if match.t == 1 and _pvpStartBattleCacheH.enemyT then |
712 | 712 | enemyTeam[_idx] = { |
713 | - heros = _pvpStartBattleCacheH.enemyT["heros"][_idx], | |
713 | + team = _pvpStartBattleCacheH.enemyT["team"][_idx], | |
714 | 714 | battleV = _pvpStartBattleCacheH.enemyT["battleV"][_idx] |
715 | 715 | } |
716 | 716 | end | ... | ... |
src/actions/RadioAction.lua
... | ... | @@ -69,7 +69,7 @@ function _M.startQuestRpc(agent, data) |
69 | 69 | needHeroCnt = it[2] |
70 | 70 | end |
71 | 71 | end |
72 | - for _, heroId in ipairs(heros) do | |
72 | + for _, heroId in pairs(heros) do | |
73 | 73 | local hero = role.heros[heroId] |
74 | 74 | if hero then |
75 | 75 | needHeroCnt = needHeroCnt - 1 |
... | ... | @@ -158,7 +158,27 @@ function _M.finishQuestRpc(agent, data) |
158 | 158 | msg["big"] = bigSuccess |
159 | 159 | msg["id"] = id |
160 | 160 | msg["heroFaith"] = heroFaithMap |
161 | - SendPacket(actionCodes.Radio_finishQuestRpc, MsgPack.pack(msg)) | |
161 | + SendPacket(actionCodes.Radio_finishQuestRpc, MsgPack.pack(msg)) | |
162 | + | |
163 | + | |
164 | + local herolist = {} | |
165 | + for _, heroId in ipairs(task.heros) do | |
166 | + local hero = role.heros[heroId] | |
167 | + if hero then | |
168 | + table.insert(herolist, hero:getProperty("type")) | |
169 | + end | |
170 | + end | |
171 | + | |
172 | + -- 讨伐行动 | |
173 | + role:log("punitive_action", { | |
174 | + mission_id = id, --关卡ID | |
175 | + mission_herolist = herolist, -- 英雄ID,排序以玩家出战设置为准,示例:[111, 222, 333, 444, 555] | |
176 | + mission_success_rate = totalCoef, -- 大成功几率 | |
177 | + mission_reward = r, -- 获得奖励,建议使用json格式记录。示例:{ itemid1: 1, itemid2: 3, itemid3: 5} | |
178 | + mission_result = 1, -- 战斗结果(0-无效,1-胜利,2-失败) | |
179 | + mission_roundtime = config.time, -- 完成耗时(秒) | |
180 | + }) | |
181 | + | |
162 | 182 | return true |
163 | 183 | end |
164 | 184 | ... | ... |
src/actions/RoleAction.lua
... | ... | @@ -724,11 +724,12 @@ function _M.unLockStoryBookRpc(agent, data) |
724 | 724 | local storyStatus = role:getProperty("storyB") |
725 | 725 | if storyStatus[storyId] and storyStatus[storyId].s then return end --不需要解锁 |
726 | 726 | |
727 | - local cost = storyBookData.lockItem:toNumMap() | |
728 | - if not cost or not next(cost) then return end | |
729 | - if not role:checkItemEnough(cost) then return end -- 消耗品不足 | |
730 | - | |
731 | - role:costItems(cost, {log = {desc = "unlockStory", int1 = storyId}}) | |
727 | + if storyBookData.lockItem ~= "free" then | |
728 | + local cost = storyBookData.lockItem:toNumMap() | |
729 | + if not cost or not next(cost) then return end | |
730 | + if not role:checkItemEnough(cost) then return end -- 消耗品不足 | |
731 | + role:costItems(cost, {log = {desc = "unlockStory", int1 = storyId}}) | |
732 | + end | |
732 | 733 | |
733 | 734 | -- 解锁 |
734 | 735 | storyStatus[storyId] = storyStatus[storyId] or {} |
... | ... | @@ -807,6 +808,12 @@ function _M.taskActiveRpc(agent, data) |
807 | 808 | { type = roleField[taskType], field = {"at", taskId}, value = -1 } |
808 | 809 | }) |
809 | 810 | |
811 | + role:log("task_reward", { | |
812 | + task_reward_id = taskId * 100 + taskType, --任务奖励ID | |
813 | + task_reward_type = 3, --任务奖励类型,见 任务奖励类型枚举表 | |
814 | + task_reward_detail = reward, --任务奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} | |
815 | + }) | |
816 | + | |
810 | 817 | SendPacket(actionCodes.Role_taskActiveRpc, MsgPack.pack(role:packReward(reward, change))) |
811 | 818 | return true |
812 | 819 | end | ... | ... |
src/adv/Adv.lua
... | ... | @@ -149,25 +149,15 @@ function Adv:initByChapter(params) |
149 | 149 | self.maps = {} |
150 | 150 | self.maps[1] = AdvMap.new(self, 1, mapId, isEnter, isNewRelay) |
151 | 151 | |
152 | - self:initBattle(nil) | |
152 | + self:initBattle(nil, isToNext) | |
153 | 153 | |
154 | 154 | self:initLayerTask() |
155 | 155 | |
156 | - -- 支援效果生效一些 | |
157 | - self:activeSomeSupport() | |
156 | + | |
158 | 157 | |
159 | 158 | self:checkTask(Adv.TaskType.Arrive) |
160 | 159 | self:checkAdvUnlock(1, self.level) |
161 | 160 | |
162 | - if isToNext then | |
163 | - self.battle.player:afterLayer() -- 玩家的buff 清理一下 | |
164 | - end | |
165 | - | |
166 | - -- 不是中继层 加上 层 和 地图的buff和被动 | |
167 | - if not self.isRelay then | |
168 | - self.battle:initMapEffect() | |
169 | - end | |
170 | - | |
171 | 161 | -- 中继进入奖励 |
172 | 162 | if relayData and isEnter then |
173 | 163 | self:awardRelay(relayData, notNotify) |
... | ... | @@ -456,8 +446,20 @@ function Adv:clearAdvUnlockCache() |
456 | 446 | self.cacheUnlock = {} |
457 | 447 | end |
458 | 448 | |
459 | -function Adv:initBattle(info) | |
449 | +function Adv:initBattle(info, isToNext) | |
460 | 450 | self.battle = require("adv.AdvBattle").new(self) |
451 | + -- 支援效果生效一些 | |
452 | + self:activeSomeSupport() | |
453 | + | |
454 | + -- 不是中继层 加上 层 和 地图的buff和被动 | |
455 | + if not self.isRelay then | |
456 | + self.battle:initMapEffect() | |
457 | + end | |
458 | + | |
459 | + if isToNext then | |
460 | + self.battle.player:afterLayer() -- 玩家的buff 清理一下 | |
461 | + end | |
462 | + | |
461 | 463 | for _, passiveC in ipairs(self.cachePassiveEvent or {}) do |
462 | 464 | self.battle:triggerPassive(passiveC[1], passiveC[2]) |
463 | 465 | end |
... | ... | @@ -468,7 +470,7 @@ function Adv:initBattle(info) |
468 | 470 | map:initBattleAfter() |
469 | 471 | end |
470 | 472 | --下层 |
471 | - if not info and self.level ~= 1 then | |
473 | + if not info and isToNext then | |
472 | 474 | self.battle.player:attrChangeCondBuffCheck(1) |
473 | 475 | end |
474 | 476 | |
... | ... | @@ -820,7 +822,7 @@ function Adv:over(success, rewardRatio, overType) |
820 | 822 | lv = self.owner:getProperty("level"), |
821 | 823 | batteV = self.owner:getTeamBattleValue(team.heros), |
822 | 824 | chapter = self.chapterId, |
823 | - format = self.owner:getTeamHerosInfo(team.heros), | |
825 | + format = self.owner:getTeamHerosInfo(team).heros, | |
824 | 826 | } |
825 | 827 | redisproxy:pipelining(function (red) |
826 | 828 | red:zadd(self.owner:getAdvRankKey(), score, roleId) --更新分数 |
... | ... | @@ -1094,10 +1096,10 @@ local function clickOut(self, room, block, params, isExit) |
1094 | 1096 | end |
1095 | 1097 | |
1096 | 1098 | if #self.mapStack > 1 then -- 处于夹层中 |
1099 | + self:backLayer(-1) | |
1097 | 1100 | local oldMapIdx = self:getCurMapIdx() |
1098 | 1101 | table.remove(self.mapStack) --退出夹层 |
1099 | 1102 | self.battle:iLayerChange(oldMapIdx) |
1100 | - self:backLayer(-1) | |
1101 | 1103 | else --处于底层 |
1102 | 1104 | |
1103 | 1105 | local advPass = self.owner:getProperty("advPass") |
... | ... | @@ -1129,8 +1131,8 @@ local function clickOut(self, room, block, params, isExit) |
1129 | 1131 | if curFloorData then |
1130 | 1132 | self:award({[ItemId.AdvPoint] = curFloorData.exp}, {log = {desc = "passReward", int1 = self.chapterId, int2 = self.level}}, {}) |
1131 | 1133 | end |
1134 | + self:backNext() --下一关 | |
1132 | 1135 | local isHaveRelay = self:isHaveRelay(self.level) |
1133 | - | |
1134 | 1136 | if isHaveRelay and not self.isRelay then |
1135 | 1137 | self:initByChapter({ |
1136 | 1138 | chapterId = self.chapterId, |
... | ... | @@ -1148,7 +1150,6 @@ local function clickOut(self, room, block, params, isExit) |
1148 | 1150 | notNotify = true, |
1149 | 1151 | }) |
1150 | 1152 | end |
1151 | - self:backNext() --下一关 | |
1152 | 1153 | end |
1153 | 1154 | |
1154 | 1155 | end |
... | ... | @@ -1554,6 +1555,7 @@ local function clickBuild(self, room, block, params) |
1554 | 1555 | end |
1555 | 1556 | advMine[2].co = mineCo2 |
1556 | 1557 | self.owner:setProperty("advMine", advMine) |
1558 | + self.owner:checkTaskEnter("AdvMineLayer") | |
1557 | 1559 | end |
1558 | 1560 | |
1559 | 1561 | self:checkTask(Adv.TaskType.Build, 1, oldId) |
... | ... | @@ -1604,6 +1606,7 @@ end |
1604 | 1606 | |
1605 | 1607 | local function clickLayer(self, room, block, params) |
1606 | 1608 | local oldMapIdx = self:getCurMapIdx() |
1609 | + self:backLayer(1) | |
1607 | 1610 | if block.event.mapIdx then |
1608 | 1611 | table.insert(self.mapStack, block.event.mapIdx) --进入夹层 |
1609 | 1612 | else |
... | ... | @@ -1620,7 +1623,6 @@ local function clickLayer(self, room, block, params) |
1620 | 1623 | self:checkAchievement(Adv.AchievType.EnterILayer, 1, mapId) |
1621 | 1624 | end |
1622 | 1625 | self.battle:iLayerChange(oldMapIdx) |
1623 | - self:backLayer(1) | |
1624 | 1626 | return true |
1625 | 1627 | end |
1626 | 1628 | |
... | ... | @@ -2051,6 +2053,7 @@ function Adv:enemyDead(enemy, escape) |
2051 | 2053 | advMine[2].co = mineCo2 |
2052 | 2054 | advMine[2].ch = mineCh |
2053 | 2055 | self.owner:setProperty("advMine", advMine) |
2056 | + self.owner:checkTaskEnter("AdvMineKill") | |
2054 | 2057 | else |
2055 | 2058 | local toClick = enemy:hadBuff(Buff.CHANGE_DROP_TO_CLICK) |
2056 | 2059 | if toClick then | ... | ... |
src/adv/AdvBuff.lua
... | ... | @@ -35,7 +35,7 @@ Buff.Buff_NO_PASSIVE_MONSTER = 31 -- 地图被动刷新不出来怪物 |
35 | 35 | Buff.SNEAK = 32 --潜行 |
36 | 36 | Buff.DROP_BUFF_BY_ENEMY = 33 -- 怪物掉落加成 -- 怪物使用 |
37 | 37 | Buff.GET_PASSIVE = 34 -- 获得 passive -- 结束失效 |
38 | -Buff.OBSTACLE_CHANGE = 35 -- 看守类型改变 -- 怪物使用 0 - 1 | |
38 | +Buff.OBSTACLE_CHANGE = 35 -- 看守类型改变 -- 怪物使用 2 - 1 | |
39 | 39 | Buff.DISABLE_AURA = 36 -- 禁用光环 |
40 | 40 | Buff.GET_AURA = 37 -- 获得光环 |
41 | 41 | |
... | ... | @@ -490,6 +490,7 @@ function Buff:createAfter(layer) |
490 | 490 | self:_init() |
491 | 491 | end |
492 | 492 | self:pushBackEffect(1) |
493 | + buglog("Buff", "who: %s create buffId: %s", self.owner.monsterId, self.id) | |
493 | 494 | end |
494 | 495 | |
495 | 496 | function Buff:initByDB(data) |
... | ... | @@ -632,6 +633,7 @@ function Buff:pushBackEffect(etype) |
632 | 633 | end |
633 | 634 | |
634 | 635 | function Buff:effect() |
636 | + buglog("Buff", "who: %s effect buffId: %s", self.owner.monsterId, self.id) | |
635 | 637 | self:decCount() |
636 | 638 | self:pushBackEffect(2) |
637 | 639 | if self._effectValue then |
... | ... | @@ -655,6 +657,7 @@ function Buff:endBuff() |
655 | 657 | if self._endBuff then |
656 | 658 | self:_endBuff() |
657 | 659 | end |
660 | + buglog("Buff", "who: %s endBuff buffId: %s", self.owner.monsterId, self.id) | |
658 | 661 | end |
659 | 662 | |
660 | 663 | function Buff:getType() |
... | ... | @@ -709,6 +712,7 @@ function Buff:overlay(releaser, data, layer) |
709 | 712 | end |
710 | 713 | |
711 | 714 | self:pushBackEffect(1) |
715 | + buglog("Buff", "who: %s overlay buffId: %s", self.owner.monsterId, self.id) | |
712 | 716 | end |
713 | 717 | end |
714 | 718 | ... | ... |
src/adv/AdvMap.lua
... | ... | @@ -812,7 +812,7 @@ createMap = function(self, mapId, isEnter, isNewRelay) |
812 | 812 | end |
813 | 813 | end |
814 | 814 | -- 宝藏怪刷新 |
815 | - if self.mapIdx == 1 and not self.adv.isRelay then | |
815 | + if self.mapIdx == 1 and not self.adv.isRelay and self.adv.chapterId ~= 100 then | |
816 | 816 | for idx = #(stagePool["global"][AdvCodeRandomStage] or {}), 1, -1 do |
817 | 817 | local c = stagePool["global"][AdvCodeRandomStage][idx] -- {room = roomId, block = blockId} |
818 | 818 | if mapInfo.rooms[c["room"]]["event"][c["block"]] then -- 存在 | ... | ... |
src/adv/AdvPassive.lua
... | ... | @@ -9,6 +9,7 @@ Filter.BUFF_BY_ID = 6 -- 指定id的buff |
9 | 9 | Filter.CAMP = 7 -- 玩家是指定阵营 |
10 | 10 | Filter.RANGE = 8 -- 筛选范围 (触发是地块) |
11 | 11 | Filter.CLASSIFY = 9 -- 标签 |
12 | +Filter.NO_BUFF_BY_ID = 10 -- 没有指定id的buff | |
12 | 13 | |
13 | 14 | local FilterFactory = {} |
14 | 15 | FilterFactory[Filter.HP_UP_WITH_EQUAL] = function (_Filter) |
... | ... | @@ -47,7 +48,6 @@ FilterFactory[Filter.CAMP] = function (_Filter) |
47 | 48 | return role:getHerosCamp(role:getProperty("advTeam").heros) == self.value |
48 | 49 | end |
49 | 50 | end |
50 | - | |
51 | 51 | FilterFactory[Filter.RANGE] = function (_Filter) |
52 | 52 | _Filter._execute = function (self, target, params) |
53 | 53 | if params and self.owner.blockId and self.owner.roomId and params.blockId and params.roomId then |
... | ... | @@ -57,13 +57,18 @@ FilterFactory[Filter.RANGE] = function (_Filter) |
57 | 57 | return false |
58 | 58 | end |
59 | 59 | end |
60 | - | |
61 | 60 | FilterFactory[Filter.CLASSIFY] = function (_Filter) |
62 | 61 | _Filter._execute = function (self, target) |
63 | 62 | return target.isClassify and target:isClassify(self.value) |
64 | 63 | end |
65 | 64 | end |
66 | 65 | |
66 | +FilterFactory[Filter.NO_BUFF_BY_ID] = function (_Filter) | |
67 | + _Filter._execute = function (self, target) | |
68 | + return not target:hadBuffById(self.value) | |
69 | + end | |
70 | +end | |
71 | + | |
67 | 72 | function Filter:ctor(params) |
68 | 73 | self.owner = params.owner |
69 | 74 | self.skill = params.skill |
... | ... | @@ -87,6 +92,9 @@ function Filter:getTarget(params) |
87 | 92 | if self.oType == 2 and params.releaser then |
88 | 93 | target = params.releaser |
89 | 94 | end |
95 | + if self.oType == 3 then | |
96 | + target = self.owner.battle.player | |
97 | + end | |
90 | 98 | return target |
91 | 99 | end |
92 | 100 | |
... | ... | @@ -354,6 +362,7 @@ function Passive:effect(triggerPms) |
354 | 362 | end |
355 | 363 | if hadEffect then |
356 | 364 | self.owner.battle.adv:pushBackEvent(AdvBackEventType.PassiveEffect, {id = self.id, level = self.level, roomId = self.owner.roomId, blockId = self.owner.blockId}) |
365 | + buglog("Passive", "who: %s effect id: %s", self.owner.monsterId, self.id) | |
357 | 366 | end |
358 | 367 | if self.count > 0 then |
359 | 368 | self.count = self.count < 999 and self.count - 1 or self.count |
... | ... | @@ -404,6 +413,8 @@ function Passive:trigger(condType, params) --触发检查 |
404 | 413 | params = params or {} |
405 | 414 | if self.isDel or self.owner.isDead then return end |
406 | 415 | if self:getCondType() ~= condType then return end |
416 | + | |
417 | + buglog("Passive", "who: %s trigger id: %s", self.owner.monsterId, self.id) | |
407 | 418 | if not self:canTrigger() then return end |
408 | 419 | if self._trigger then |
409 | 420 | if not self:_trigger(params) then return end --检查 |
... | ... | @@ -600,5 +611,9 @@ function Passive:effect16(value, triggerPms, changeType) |
600 | 611 | self.owner.battle.adv:blockDropChange(changeType, blocks) |
601 | 612 | end |
602 | 613 | |
614 | +--17=玩家获得buff | |
615 | +function Passive:effect17(value, triggerPms) | |
616 | + self.owner.battle.player:addBuff(value, self.owner) | |
617 | +end | |
603 | 618 | |
604 | 619 | return Passive |
605 | 620 | \ No newline at end of file | ... | ... |
src/adv/AdvPlayer.lua
... | ... | @@ -662,7 +662,7 @@ end |
662 | 662 | |
663 | 663 | function Enemy:getObstacle() |
664 | 664 | local obstacle = csvdb["event_monsterCsv"][self.monsterId].obstacle |
665 | - if obstacle == 0 and self:hadBuff(Buff.OBSTACLE_CHANGE) then | |
665 | + if obstacle == 2 and self:hadBuff(Buff.OBSTACLE_CHANGE) then | |
666 | 666 | obstacle = 1 |
667 | 667 | end |
668 | 668 | return obstacle | ... | ... |
src/agent.lua
... | ... | @@ -356,11 +356,6 @@ skynet.start(function() |
356 | 356 | return info |
357 | 357 | end) |
358 | 358 | |
359 | - redisd = skynet.localname(".redis") | |
360 | - if tonumber(skynet.getenv "logd") == 1 then | |
361 | - logd = skynet.localname(".log") | |
362 | - end | |
363 | - | |
364 | 359 | cs = queue() |
365 | 360 | |
366 | 361 | pvpd = skynet.localname(".pvpcross") | ... | ... |
src/main.lua
... | ... | @@ -2,23 +2,41 @@ local skynet = require "skynet" |
2 | 2 | |
3 | 3 | local max_client = tonumber(skynet.getenv("max_client")) |
4 | 4 | local max_queue = tonumber(skynet.getenv("max_queue")) |
5 | +local work_count = tonumber(skynet.getenv("thread")) | |
6 | +local use_logd = tonumber(skynet.getenv("logd")) | |
5 | 7 | |
6 | 8 | skynet.start(function() |
7 | 9 | print("Server start") |
8 | 10 | skynet.newservice("debug_console", tonumber(skynet.getenv("debug_port"))) |
9 | 11 | |
12 | + | |
13 | + -- 启动redis | |
14 | + for i = 1, work_count do | |
15 | + local redisd = skynet.newservice("services/redisd", i) | |
16 | + skynet.call(redisd, "lua", "open", { | |
17 | + redishost = skynet.getenv("redis_host"), | |
18 | + redisport = tonumber(skynet.getenv("redis_port")), | |
19 | + redisdb = tonumber(skynet.getenv("redis_db")), | |
20 | + auth = skynet.getenv("redis_auth") | |
21 | + }) | |
22 | + end | |
23 | + | |
24 | + --启动log | |
25 | + if use_logd == 1 then | |
26 | + for i = 1, work_count * 2 do | |
27 | + local logd = skynet.newservice("services/logd", i) | |
28 | + skynet.call(logd, "lua", "open") | |
29 | + end | |
30 | + end | |
31 | + | |
10 | 32 | local httpd = skynet.newservice("services/httpweb", tonumber(skynet.getenv("httpweb_port"))) |
11 | 33 | local watchdog = skynet.newservice("services/watchdog", max_client) |
12 | 34 | |
35 | + | |
13 | 36 | skynet.call(watchdog, "lua", "start", { |
14 | 37 | port = tonumber(skynet.getenv("server_port")), |
15 | 38 | maxclient = max_client + max_queue + 10, |
16 | 39 | httpd = httpd, |
17 | - | |
18 | - redishost = skynet.getenv("redis_host"), | |
19 | - redisport = tonumber(skynet.getenv("redis_port")), | |
20 | - redisdb = tonumber(skynet.getenv("redis_db")), | |
21 | - auth = skynet.getenv("redis_auth"), | |
22 | 40 | }) |
23 | 41 | |
24 | 42 | skynet.exit() | ... | ... |
src/models/Activity.lua
... | ... | @@ -24,8 +24,13 @@ Activity.ActivityType = { |
24 | 24 | Exchange = 18, -- 兑换活动 |
25 | 25 | HangDrop = 19, -- 挂机掉落活动 |
26 | 26 | Gachakon = 20, -- 扭蛋活动 |
27 | -} | |
28 | 27 | |
28 | + WishHeroPool = 23, -- 心愿卡池 | |
29 | + ActHeroPool = 24, -- 活动卡池 | |
30 | + ActShopGoods = 25, -- 活动商品 | |
31 | + | |
32 | + Crisis = 26, -- 宝藏怪活动 | |
33 | +} | |
29 | 34 | |
30 | 35 | local function checkActivityType(activityType) |
31 | 36 | if type(activityType) == "string" then |
... | ... | @@ -41,6 +46,13 @@ function Activity:ctor(properties) |
41 | 46 | self._isOpen = {} |
42 | 47 | end |
43 | 48 | |
49 | +function Activity:getType(actType) | |
50 | + if type(actType) == "string" then | |
51 | + actType = Activity.ActivityType[actType] | |
52 | + end | |
53 | + return actType or 0 | |
54 | +end | |
55 | + | |
44 | 56 | |
45 | 57 | Activity.schema = { |
46 | 58 | actime = {"table", {}}, -- 最近检查某项活动的开始时间 {id = time} |
... | ... | @@ -58,6 +70,8 @@ Activity.schema = { |
58 | 70 | act18 = {"table", {}, true}, -- {id=兑换数量} |
59 | 71 | act19 = {"number", 0}, -- {挂机信息} |
60 | 72 | act20 = {"table", {}}, -- {id=扭蛋抽出数量} |
73 | + | |
74 | + act26 = {"table", {}}, -- {task = {id = count}, socre = {id = status}} | |
61 | 75 | } |
62 | 76 | |
63 | 77 | function Activity:data() |
... | ... | @@ -76,6 +90,7 @@ function Activity:data() |
76 | 90 | act18 = self:getProperty("act18"), |
77 | 91 | act19 = self:getProperty("act19"), |
78 | 92 | act20 = self:getProperty("act20"), |
93 | + act26 = self:getProperty("act26"), | |
79 | 94 | } |
80 | 95 | end |
81 | 96 | |
... | ... | @@ -153,7 +168,12 @@ function Activity:isOpen(activityType) |
153 | 168 | return false |
154 | 169 | end |
155 | 170 | |
156 | -function Activity:isOpenById(id) | |
171 | +function Activity:isOpenById(id, activityType) | |
172 | + activityType = checkActivityType(activityType) | |
173 | + local cfg = csvdb["activity_ctrlCsv"][id] | |
174 | + if not cfg then return false end | |
175 | + if activityType ~= 0 and cfg.showType ~= activityType then return false end | |
176 | + | |
157 | 177 | return self._isOpen[id] |
158 | 178 | end |
159 | 179 | |
... | ... | @@ -179,6 +199,7 @@ function Activity:checkActivityStatus(now, isCrossDay, notify) |
179 | 199 | |
180 | 200 | if isOpen then |
181 | 201 | if actime[actId] and actime[actId] == startTime then -- 还是之前的状态 开放中 |
202 | + self:onLoginActivity(actId) | |
182 | 203 | else -- 重置 |
183 | 204 | actime[actId] = startTime |
184 | 205 | self:closeActivity(actId, notify, true) |
... | ... | @@ -419,7 +440,8 @@ activityFunc[Activity.ActivityType.CalendaTask] = { |
419 | 440 | local towerInfo = role:getProperty("towerInfo") |
420 | 441 | role:checkTaskEnter("TowerPass", {level = towerInfo.l}) |
421 | 442 | --"PvpWin" |
422 | - role:checkTaskEnter("HangPass", {}) | |
443 | + --role:checkTaskEnter("HangPass", {id = 0}) | |
444 | + role:checkCalendaTask(true, 15, 3) | |
423 | 445 | role:checkTaskEnter("HeroStarCollect", {}) |
424 | 446 | role:checkTaskEnter("RuneQualityCollect", {}) |
425 | 447 | |
... | ... | @@ -475,7 +497,8 @@ activityFunc[Activity.ActivityType.Gachakon] = { |
475 | 497 | activityFunc[Activity.ActivityType.HangDrop] = { |
476 | 498 | ["init"] = function(self, actType, isCrossDay, notify, actId) |
477 | 499 | local actime = self:getProperty("actime") |
478 | - local startTime = actime[actId] | |
500 | + local ctime = self.owner:getProperty("ctime") | |
501 | + local startTime = math.max(actime[actId], ctime) | |
479 | 502 | local actData = self:getActData(actType) or 0 |
480 | 503 | local cfg = csvdb["activity_putCsv"][actId] |
481 | 504 | if not cfg then return end |
... | ... | @@ -484,11 +507,30 @@ activityFunc[Activity.ActivityType.HangDrop] = { |
484 | 507 | end |
485 | 508 | } |
486 | 509 | |
510 | +--ChallengeLevel | |
511 | +activityFunc[Activity.ActivityType.ChallengeLevel] = { | |
512 | + ["init"] = function(self, actType, isCrossDay, notify, actId) | |
513 | + self:getBattleTicket(actId) | |
514 | + end, | |
515 | + ["login"] = function(self, actType, actId) | |
516 | + self:getBattleTicket(actId) | |
517 | + end | |
518 | +} | |
519 | + | |
520 | +function Activity:onLoginActivity(actId) | |
521 | + local actData = csvdb["activity_ctrlCsv"][actId] | |
522 | + if not actData then return end | |
523 | + local actType = actData.showType | |
524 | + if activityFunc[actType] and activityFunc[actType]['login'] then | |
525 | + activityFunc[actType]["login"](self, actType, actId) | |
526 | + end | |
527 | +end | |
528 | + | |
487 | 529 | function Activity:initActivity(actId, isCrossDay, notify) |
488 | 530 | local actData = csvdb["activity_ctrlCsv"][actId] |
489 | 531 | if not actData then return end |
490 | 532 | local actType = actData.showType |
491 | - if activityFunc[actType] and activityFunc[actType]['close'] then | |
533 | + if activityFunc[actType] and activityFunc[actType]['init'] then | |
492 | 534 | activityFunc[actType]["init"](self, actType, isCrossDay, notify, actId) |
493 | 535 | end |
494 | 536 | end |
... | ... | @@ -633,5 +675,93 @@ function Activity:recycleActItem(actId) |
633 | 675 | end |
634 | 676 | end |
635 | 677 | |
678 | +-- 活动挑战关卡计算门票 | |
679 | +function Activity:getBattleTicket(actId) | |
680 | + local role = self.owner | |
681 | + local createTs = role:getProperty("ctime") | |
682 | + local actCfg = csvdb["activity_ctrlCsv"][actId] | |
683 | + if not actCfg then return 0 end | |
684 | + | |
685 | + local actStartTime = 0 | |
686 | + local openTimes = actCfg.time:toArray(false, "=") | |
687 | + actStartTime = toUnixtime(openTimes[1]..string_format("%02x", RESET_TIME)) | |
688 | + local actData = self:getActData("ChallengeLevel") or {} | |
689 | + local startTs = actData["ts"] or math.max(actStartTime, createTs) | |
690 | + local timeNow = skynet.timex() | |
691 | + local modify = false | |
692 | + local arr = actCfg.condition2:toArray(true, "=") | |
693 | + | |
694 | + local ticketId, init, limit, duration = arr[1] or 0, arr[2] or 0, arr[3] or 0, arr[4] or 10000 | |
695 | + | |
696 | + local count = actData["ticket"] or init | |
697 | + local add = math.max(math.floor((timeNow - startTs) / (duration * 60)), 0) | |
698 | + | |
699 | + local newCount= math.min(count + add, limit) | |
700 | + if newCount ~= count or newCount >= limit then | |
701 | + modify = true | |
702 | + end | |
703 | + add = newCount - count | |
704 | + | |
705 | + if modify or not next(actData) then | |
706 | + actData["ticket"] = newCount | |
707 | + actData["ts"] = newCount >= limit and timeNow or (startTs + add * duration * 60) | |
708 | + self:updateActData("ChallengeLevel", actData) | |
709 | + end | |
710 | +end | |
711 | + | |
712 | +activityFunc[Activity.ActivityType.ActShopGoods] = { | |
713 | + ["init"] = function(self, actType, isCrossDay, notify, actId) | |
714 | + end, | |
715 | + ["close"] = function(self, actType, notify) | |
716 | + local rechargeRecord = self.owner.storeData:getProperty("payR") | |
717 | + for id, cfg in pairs(csvdb["shop_rechargeCsv"]) do | |
718 | + if cfg.shop == 3 and cfg.type == ShopPackType.ActShopPack then | |
719 | + rechargeRecord[id] = nil | |
720 | + end | |
721 | + end | |
722 | + self.owner.storeData:updateProperty({field="payR", value=rechargeRecord}) | |
723 | + end, | |
724 | +} | |
725 | + | |
726 | + | |
727 | + | |
728 | +activityFunc[Activity.ActivityType.Crisis] = { | |
729 | + ["check"] = function(self, actType, notify, atype, count) -- 检查 | |
730 | + count = count or 1 | |
731 | + local isOpen, actId = self:isOpen(actType) | |
732 | + local actData = self:getActData(actType) or {} | |
733 | + actData.task = actData.task or {} | |
734 | + local change = false | |
735 | + local actCsv = csvdb["activity_crisisCsv"][actId] | |
736 | + for id, actSet in pairs(actCsv) do | |
737 | + if actSet.type == atype then | |
738 | + local status = actData.task[id] or 0 | |
739 | + status = status + count | |
740 | + if status >= actSet.condition1 then | |
741 | + local reward | |
742 | + if actSet.loop == 1 then | |
743 | + local rcount = math.floor(status / actSet.condition1) | |
744 | + local reward = actSet.reward:toNumMap() | |
745 | + for itemId, itemC in pairs(reward) do | |
746 | + reward[itemId] = itemC * rcount | |
747 | + end | |
748 | + status = status % actSet.condition1 | |
749 | + else | |
750 | + reward = actSet.reward | |
751 | + status = -1 | |
752 | + end | |
753 | + self.owner:award(reward, {log = {desc = "activity_crisis"}, notNotify = not notify}) | |
754 | + end | |
755 | + actData.task[id] = status | |
756 | + change = true | |
757 | + end | |
758 | + end | |
759 | + if change then | |
760 | + -- 更新下排行榜 | |
761 | + self.owner:updateRankCommon(RANK_TYPE.ActCrisis, self.owner:getItemCount(ItemId.CrisisScore)) | |
762 | + self:updateActData(actType, actData) | |
763 | + end | |
764 | + end, | |
765 | +} | |
636 | 766 | |
637 | 767 | return Activity | ... | ... |
src/models/RoleBattle.lua
... | ... | @@ -16,6 +16,7 @@ local BattleType = { |
16 | 16 | bonus = 300, |
17 | 17 | pvpc = 500, |
18 | 18 | pvph = 501, |
19 | + act_battle = 502, | |
19 | 20 | } |
20 | 21 | |
21 | 22 | RoleBattle.bind = function (Role) |
... | ... | @@ -43,7 +44,7 @@ function Role:checkBattle(battleType, params) |
43 | 44 | |
44 | 45 | local fixData = { |
45 | 46 | hang = function() |
46 | - for slot, hero in pairs(self:getProperty("hangTS")) do | |
47 | + for slot, hero in pairs(self:getProperty("hangTS").heros) do | |
47 | 48 | selflist[slot] = hero.type |
48 | 49 | end |
49 | 50 | heroscore = self:getProperty("hangTBV") |
... | ... | @@ -58,7 +59,7 @@ function Role:checkBattle(battleType, params) |
58 | 59 | end, |
59 | 60 | tower = function() |
60 | 61 | local towerF = self:getTeamFormatByType(TeamSystemType.Tower) |
61 | - for slot, hero in pairs(self:getTeamHerosInfo(towerF.heros)) do | |
62 | + for slot, hero in pairs(self:getTeamHerosInfo(towerF).heros) do | |
62 | 63 | selflist[slot] = hero.type |
63 | 64 | end |
64 | 65 | heroscore = self:getTeamBattleValue(towerF.heros) |
... | ... | @@ -73,7 +74,7 @@ function Role:checkBattle(battleType, params) |
73 | 74 | end, |
74 | 75 | bonus = function() |
75 | 76 | local bTeam = self:getTeamFormatByType(TeamSystemType.BonusBattle) |
76 | - for slot, hero in pairs(self:getTeamHerosInfo(bTeam.heros)) do | |
77 | + for slot, hero in pairs(self:getTeamHerosInfo(bTeam).heros) do | |
77 | 78 | selflist[slot] = hero.type |
78 | 79 | end |
79 | 80 | heroscore = self:getTeamBattleValue(bTeam.heros) |
... | ... | @@ -86,8 +87,22 @@ function Role:checkBattle(battleType, params) |
86 | 87 | enemylist[#enemylist + 1] = one["unitType"] |
87 | 88 | end |
88 | 89 | end, |
90 | + act_battle = function() | |
91 | + for slot, hero in pairs(self:getTeamHerosInfo(params).heros) do | |
92 | + selflist[slot] = hero.type | |
93 | + end | |
94 | + heroscore = self:getTeamBattleValue(params.heros) | |
95 | + for slot , one in pairs(params.supports) do | |
96 | + teamskill[one[1]] = one[2] | |
97 | + end | |
98 | + local carbonData = params.cfg | |
99 | + local monsterData = csvdb[carbonData.monster:match("/([^/]*)$") .. "Csv"] | |
100 | + for slot, one in pairs(monsterData[1]) do | |
101 | + enemylist[#enemylist + 1] = one["unitType"] | |
102 | + end | |
103 | + end, | |
89 | 104 | pvpc = function() |
90 | - for slot, hero in pairs(self:getProperty("pvpTSC")) do | |
105 | + for slot, hero in pairs(self:getProperty("pvpTSC").heros) do | |
91 | 106 | selflist[slot] = hero.type |
92 | 107 | end |
93 | 108 | heroscore = self:getProperty("pvpTBVC") |
... | ... | @@ -109,7 +124,7 @@ function Role:checkBattle(battleType, params) |
109 | 124 | pvph = function() |
110 | 125 | for idx, team in pairs(self:getProperty("pvpTSH")) do |
111 | 126 | selflist[idx] = selflist[idx] or {} |
112 | - for slot, hero in pairs(team) do | |
127 | + for slot, hero in pairs(team.heros) do | |
113 | 128 | selflist[idx][slot] = hero.type |
114 | 129 | end |
115 | 130 | end |
... | ... | @@ -163,7 +178,7 @@ function Role:checkBattle(battleType, params) |
163 | 178 | mission_starttime = clientInfo.start or 0, -- 战斗开始时间,格式 unixtime 秒级 |
164 | 179 | mission_roundtime = clientInfo.atime or 0, -- 对局时长(秒) |
165 | 180 | mission_result = params.isWin and 1 or 2, -- 战斗结果(0-无效,1-胜利,2-失败) |
166 | - mission_star = 0, -- 战斗完成星数,无星级的话填写0 | |
181 | + mission_star = params.star or 0, -- 战斗完成星数,无星级的话填写0 | |
167 | 182 | mission_restriction = 0, -- 周期内参与限制(0表示没有上限) |
168 | 183 | mission_difficulty = 0, -- 关卡困难度,无难度区分的话填写0 |
169 | 184 | mission_strength = 1, -- 消耗的体力或次数 | ... | ... |
src/models/RoleCross.lua
... | ... | @@ -19,8 +19,8 @@ RoleCross.bind = function (Role) |
19 | 19 | -- 好友详细队伍信息 |
20 | 20 | function Role:friendInfo() |
21 | 21 | local info = self:friendSInfo() |
22 | - local heros = self:getProperty("pvpTBVC") ~= 0 and self:getProperty("pvpTSC") or self:getProperty("hangTS") | |
23 | - info.heros = heros | |
22 | + local team = self:getProperty("pvpTBVC") ~= 0 and self:getProperty("pvpTSC") or self:getProperty("hangTS") | |
23 | + info.team = team | |
24 | 24 | return info |
25 | 25 | end |
26 | 26 | |
... | ... | @@ -36,7 +36,7 @@ RoleCross.bind = function (Role) |
36 | 36 | level = self:getProperty("level"), |
37 | 37 | headId = self:getProperty("headId"), |
38 | 38 | battleV = self:getProperty("pvpTBVC"), |
39 | - heros = self:getProperty("pvpTSC"), | |
39 | + team = self:getProperty("pvpTSC"), | |
40 | 40 | battleInfo = self:getProperty("pvpTBC") |
41 | 41 | } |
42 | 42 | return info |
... | ... | @@ -49,7 +49,7 @@ RoleCross.bind = function (Role) |
49 | 49 | level = self:getProperty("level"), |
50 | 50 | headId = self:getProperty("headId"), |
51 | 51 | battleV = self:getProperty("pvpTBVH"), |
52 | - heros = self:getProperty("pvpTSH"), | |
52 | + team = self:getProperty("pvpTSH"), | |
53 | 53 | battleInfo = self:getProperty("pvpTBH") |
54 | 54 | } |
55 | 55 | return info |
... | ... | @@ -281,7 +281,7 @@ function CMD.friendInfo(roleId) |
281 | 281 | headId = info.headId, |
282 | 282 | ltime = info.ltime, |
283 | 283 | battleV = info.pvpTBVC ~= 0 and info.pvpTBVC or info.hangTBV, |
284 | - heros = info.pvpTBVC ~= 0 and info.pvpTSC or info.hangTS | |
284 | + team = info.pvpTBVC ~= 0 and info.pvpTSC or info.hangTS | |
285 | 285 | } |
286 | 286 | end |
287 | 287 | |
... | ... | @@ -297,7 +297,7 @@ function CMD.pvpCInfo(roleId) |
297 | 297 | level = info.level, |
298 | 298 | headId = info.headId, |
299 | 299 | battleV = info.pvpTBVC, |
300 | - heros = info.pvpTSC, | |
300 | + team = info.pvpTSC, | |
301 | 301 | battleInfo = info.pvpTBC |
302 | 302 | } |
303 | 303 | end |
... | ... | @@ -309,7 +309,7 @@ function CMD.pvpHInfo(roleId) |
309 | 309 | level = info.level, |
310 | 310 | headId = info.headId, |
311 | 311 | battleV = info.pvpTBVH, |
312 | - heros = info.pvpTSH, | |
312 | + team = info.pvpTSH, | |
313 | 313 | battleInfo = info.pvpTBH |
314 | 314 | } |
315 | 315 | end | ... | ... |
src/models/RoleLog.lua
1 | 1 | local serverId = skynet.getenv("servId") |
2 | 2 | local server_id = (skynet.getenv("serverType") or "localtest") .. "_" .. serverId |
3 | +local logproxy = require "shared.logproxy" | |
3 | 4 | |
4 | 5 | --[[ |
5 | 6 | 100 购买/兑换行为 |
... | ... | @@ -47,6 +48,8 @@ local ItemReason = { |
47 | 48 | actGachakon = 132, -- 扭蛋活动 |
48 | 49 | totalRecharge = 133, -- 累计充值奖励 |
49 | 50 | actHangDrop = 134, -- 掉落活动奖励 |
51 | + actBattle = 135, -- 活动关卡 | |
52 | + actMilestone = 136, -- 活动关卡boss伤害里程碑 | |
50 | 53 | |
51 | 54 | |
52 | 55 | advHang = 301, -- 拾荒挂机 |
... | ... | @@ -87,6 +90,7 @@ local ItemReason = { |
87 | 90 | actSign = 1007, -- 活动签到 |
88 | 91 | actPaySign = 1008, -- 活动付费签到 |
89 | 92 | calendaTask = 1009, -- 英雄帖 |
93 | + actMilecrisis = 1010, -- 物资危机 | |
90 | 94 | |
91 | 95 | -- 餐厅 |
92 | 96 | greenHourse = 1101, -- 食材获得 |
... | ... | @@ -249,13 +253,6 @@ local MethodType = { |
249 | 253 | hero_break_result = "json", -- 英雄突破效果,可记录效果ID,或json格式记录提升效果,{攻击:20,闪避:20,……..} |
250 | 254 | hero_break_level = true, -- 英雄突破后等级上限 |
251 | 255 | }, |
252 | - hero_talent = { --英雄天赋升级 | |
253 | - hero_id = true, -- 英雄ID | |
254 | - hero_talent_cost = "json", -- 英雄天赋升级消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...} | |
255 | - hero_talent_levelbef = true, -- 英雄技能升级前等级 | |
256 | - hero_talent_level = true, -- 英雄技能升级后等级 | |
257 | - hero_talent_id = true, -- 天赋id | |
258 | - }, | |
259 | 256 | hero_jewel = { --英雄铭文 |
260 | 257 | hero_id = true, -- 英雄ID |
261 | 258 | hero_jewel_sequence = "ucode", -- 铭文装备编号,用以关联一次装备时产生的多条日志 |
... | ... | @@ -285,7 +282,7 @@ local MethodType = { |
285 | 282 | gacha_up = true, -- 卡池UP角色 |
286 | 283 | gacha_times = true, -- 抽卡次数 |
287 | 284 | gacha_reward = "json", -- 抽卡结果,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"} |
288 | - currency = "json", -- 消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...} | |
285 | + gacha_cost = "json", -- 消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...} | |
289 | 286 | gacha_cnt = true, -- 保底计数 |
290 | 287 | }, |
291 | 288 | equip_wear = { --装备穿戴与卸载 |
... | ... | @@ -293,8 +290,8 @@ local MethodType = { |
293 | 290 | equip_id = true, --装备ID |
294 | 291 | equip_wear_action = true, --装备操作类型:装备:0,卸载:1 |
295 | 292 | equip_wear_part = true, --装备部位,记录部位ID |
296 | - equip_wear_result = "json", --装备操作后结果,记录属性变化,json格式记录,{“aa”:1234,"bb":4567} | |
297 | - equip_wear_change = "json", --装备操作变化值,记录属性变化,记录正负值,json格式记录,{“aa”:1234,"bb":-45} | |
293 | + equip_wear_scorebef = true, --装备前英雄评分 | |
294 | + equip_wear_score = true, --装备后英雄评分 | |
298 | 295 | equip_wear_mode = true, --用以区分自动装备还是手动装备,自动记录为0,手动记录为1 |
299 | 296 | equip_wear_seqid = "ucode", --自动穿戴时记录的系列ID,用以关联一次性装备时候产生的多条记录 |
300 | 297 | }, |
... | ... | @@ -411,6 +408,7 @@ local MethodType = { |
411 | 408 | restaurant_order_status = true, -- 订单任务状态,接受:0, 拒绝:1, 完成:2 |
412 | 409 | restaurant_order_rwd = "json", -- 订单完成奖励,json格式记录,{"itemid1":123,"itemid2":12,……….} |
413 | 410 | restaurant_order_lv = true, -- 订单品质等级,普通:0, 稀有:1, 顶级:2, 豪华:3 |
411 | + restaurant_order_type = true, -- 订单任务类型,0:特殊顾客,1:特别订单 | |
414 | 412 | }, |
415 | 413 | restaurant_collect = { --餐厅顾客图谱 |
416 | 414 | restaurant_collect_id = true, -- 图谱收集ID |
... | ... | @@ -502,6 +500,27 @@ local MethodType = { |
502 | 500 | mission_pick_fund_beflv = true, -- 资助前资助等级 |
503 | 501 | mission_pick_fund_aftlv = true, -- 资助后资助等级 |
504 | 502 | }, |
503 | + function_open = { -- 功能开启日志 | |
504 | + function_id = true, --功能ID | |
505 | + }, | |
506 | + punitive_action = { -- 讨伐行动 --TODO | |
507 | + mission_id = true, --关卡ID | |
508 | + mission_herolist = true, -- 英雄ID,排序以玩家出战设置为准,示例:[111, 222, 333, 444, 555] | |
509 | + mission_success_rate = true, -- 大成功几率 | |
510 | + mission_reward = true, -- 获得奖励,建议使用json格式记录。示例:{ itemid1: 1, itemid2: 3, itemid3: 5} | |
511 | + mission_result = true, -- 战斗结果(0-无效,1-胜利,2-失败) | |
512 | + mission_roundtime = true, -- 完成耗时(秒) | |
513 | + }, | |
514 | + hero_talent = { --英雄精进(原英雄天赋升级) TODO | |
515 | + hero_id = true, --英雄ID | |
516 | + hero_talent_stagebef = true, --英雄精进升级前停留阶段 | |
517 | + hero_talent_stage = true, --英雄精进升级后停留阶段 | |
518 | + hero_talent_cost = "json", --英雄精进升级消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,….} | |
519 | + hero_talent_subid = true, --升级属性ID,生命、攻击、防御、命中、闪避分别对应(0,1,2,3,4) | |
520 | + hero_talent_sublevel = true, --升级属性等级,如生命升级从1到2,则记录2 | |
521 | + }, | |
522 | + | |
523 | + | |
505 | 524 | } |
506 | 525 | |
507 | 526 | local function printError(info) |
... | ... | @@ -763,8 +782,7 @@ function RoleLog.bind(Role) |
763 | 782 | end |
764 | 783 | end |
765 | 784 | end |
766 | - if not logd then return end | |
767 | - pcall(skynet.send, logd, "lua", "log", doc, "bi") | |
785 | + logproxy:log(doc, "bi") | |
768 | 786 | end |
769 | 787 | |
770 | 788 | function Role:logItems(itemId, before, after, log) |
... | ... | @@ -823,8 +841,7 @@ function RoleLog.bind(Role) |
823 | 841 | end |
824 | 842 | end |
825 | 843 | doc["@type"] = logType |
826 | - if not logd then return end | |
827 | - pcall(skynet.send, logd, "lua", "log", doc, "log") | |
844 | + logproxy:log(doc, "log") | |
828 | 845 | end |
829 | 846 | |
830 | 847 | ... | ... |
src/models/RolePlugin.lua
... | ... | @@ -1014,6 +1014,7 @@ function RolePlugin.bind(Role) |
1014 | 1014 | |
1015 | 1015 | if csvdb["itemCsv"][func] and csvdb["itemCsv"][func].type == ItemType.FuncOpen then |
1016 | 1016 | local unlockData = csvdb["unlockCsv"][func] |
1017 | + self:log("function_open", {function_id = func}) | |
1017 | 1018 | if unlockData.type == 4 then -- 解锁神器 |
1018 | 1019 | if self:getProperty("advAFOpen")[unlockData.value1] ~= 1 then |
1019 | 1020 | self:changeUpdates({{type = "advAFOpen", field = unlockData.value1, value = 1}}) |
... | ... | @@ -1176,7 +1177,7 @@ function RolePlugin.bind(Role) |
1176 | 1177 | lv = self:getProperty("level"), |
1177 | 1178 | batteV = battleV, |
1178 | 1179 | level = level, |
1179 | - format = self:getTeamHerosInfo(towerTeam.heros), | |
1180 | + format = self:getTeamHerosInfo(towerTeam).heros, | |
1180 | 1181 | } |
1181 | 1182 | local roleId = self:getProperty("id") |
1182 | 1183 | redisproxy:pipelining(function (red) |
... | ... | @@ -1324,9 +1325,10 @@ function RolePlugin.bind(Role) |
1324 | 1325 | return teamInfo |
1325 | 1326 | end |
1326 | 1327 | |
1327 | - function Role:getTeamHerosInfo(heroIds) | |
1328 | + function Role:getTeamHerosInfo(team) | |
1329 | + local format = {} | |
1328 | 1330 | local heros = {} |
1329 | - for slot, heroId in pairs(heroIds or {}) do | |
1331 | + for slot, heroId in pairs(team.heros or {}) do | |
1330 | 1332 | local hero = self.heros[heroId] |
1331 | 1333 | heros[slot] = { |
1332 | 1334 | type = hero:getProperty("type"), |
... | ... | @@ -1334,7 +1336,10 @@ function RolePlugin.bind(Role) |
1334 | 1336 | wakeL = hero:getProperty("wakeL"), |
1335 | 1337 | } |
1336 | 1338 | end |
1337 | - return heros | |
1339 | + format.heros = heros | |
1340 | + format.supports = team.supports or {} | |
1341 | + format.tactics = team.tactics or {} | |
1342 | + return format | |
1338 | 1343 | end |
1339 | 1344 | |
1340 | 1345 | function Role:getTeamBattleValue(heros) |
... | ... | @@ -1352,7 +1357,7 @@ function RolePlugin.bind(Role) |
1352 | 1357 | if not team then return end |
1353 | 1358 | |
1354 | 1359 | self:setProperties({ |
1355 | - hangTS = self:getTeamHerosInfo(team.heros), | |
1360 | + hangTS = self:getTeamHerosInfo(team), | |
1356 | 1361 | hangTB = self:getTeamBattleInfo(team), |
1357 | 1362 | hangTBV = self:getTeamBattleValue(team.heros), |
1358 | 1363 | }) |
... | ... | @@ -1400,7 +1405,7 @@ function RolePlugin.bind(Role) |
1400 | 1405 | self:updateProperty({field = "pvpTC", value = team}) |
1401 | 1406 | end |
1402 | 1407 | self:setProperties({ |
1403 | - pvpTSC = self:getTeamHerosInfo(team.heros), | |
1408 | + pvpTSC = self:getTeamHerosInfo(team), | |
1404 | 1409 | pvpTBC = self:getTeamBattleInfo(team), |
1405 | 1410 | pvpTBVC = self:getTeamBattleValue(team.heros), |
1406 | 1411 | }) |
... | ... | @@ -1416,7 +1421,7 @@ function RolePlugin.bind(Role) |
1416 | 1421 | local pvpTSH, pvpTBH, pvpTBVH = {}, {}, {} |
1417 | 1422 | for i = 1, 3 do |
1418 | 1423 | if team[i] then |
1419 | - pvpTSH[i] = self:getTeamHerosInfo(team[i].heros) | |
1424 | + pvpTSH[i] = self:getTeamHerosInfo(team[i]) | |
1420 | 1425 | pvpTBH[i] = self:getTeamBattleInfo(team[i]) |
1421 | 1426 | pvpTBVH[i] = self:getTeamBattleValue(team[i].heros) |
1422 | 1427 | end |
... | ... | @@ -1578,7 +1583,12 @@ function RolePlugin.bind(Role) |
1578 | 1583 | local rechargeRecord = self:getProperty("payR") or {} |
1579 | 1584 | if limit ~= 0 and limit <= (rechargeRecord[rechargeId] or 0) then |
1580 | 1585 | return "" |
1581 | - end | |
1586 | + end | |
1587 | + | |
1588 | + --判断是否是活动商品 | |
1589 | + local actCfg = csvdb["activity_ctrlCsv"][rechargeData.activity_id] | |
1590 | + if not actCfg then return "" end | |
1591 | + if not self.activity:isOpenById(rechargeData.activity_id, "ActShopGoods") then return "" end | |
1582 | 1592 | |
1583 | 1593 | local orderId = redisproxy:hget(string.format(R_ORDERS, roleId), rechargeId) |
1584 | 1594 | if orderId then |
... | ... | @@ -1596,6 +1606,7 @@ function RolePlugin.bind(Role) |
1596 | 1606 | key = orderKey, |
1597 | 1607 | order = partnerOrderId, |
1598 | 1608 | rechargeId = rechargeId, |
1609 | + createTime = skynet.timex(), | |
1599 | 1610 | }) |
1600 | 1611 | order:create() |
1601 | 1612 | -- 正在进行中的订单 缓存 |
... | ... | @@ -1639,7 +1650,7 @@ function RolePlugin.bind(Role) |
1639 | 1650 | -- 开始下单 |
1640 | 1651 | if status == "success" then |
1641 | 1652 | elseif status == "fail" then |
1642 | - redisproxy:hdel(string.format(R_ORDERS, roleId), rechargeId) | |
1653 | + -- redisproxy:hdel(string.format(R_ORDERS, roleId), rechargeId) | |
1643 | 1654 | elseif status == "finsh" then |
1644 | 1655 | orderObject:setProperty("finishTime", skynet.time()) |
1645 | 1656 | redisproxy:hdel(string.format(R_ORDERS, roleId), rechargeId) |
... | ... | @@ -1929,6 +1940,53 @@ function RolePlugin.bind(Role) |
1929 | 1940 | end |
1930 | 1941 | deleteNotify({pattern = pattern}) |
1931 | 1942 | end |
1943 | + | |
1944 | + local CommonRankTime = toUnixtime("2019010100") | |
1945 | + local CommonCoef1 = 10000 | |
1946 | + local CommonCoef2 = 10000 | |
1947 | + function Role:updateRankCommon(rankType, rankVal, reserve) | |
1948 | + if not rankType then return end | |
1949 | + reserve = reserve or 0 | |
1950 | + local now = skynet.timex() | |
1951 | + local ct = math.ceil((now - CommonRankTime) / 86400) --按天计算 365 * 27 < 10000 可以维持 27 年 | |
1952 | + ct = 10000 - ct -- 越早的排名越靠前 | |
1953 | + local score = (rankVal * CommonCoef1 + ct) * CommonCoef2 + reserve | |
1954 | + | |
1955 | + local roleId = self:getProperty("id") | |
1956 | + redisproxy:pipelining(function (red) | |
1957 | + red:zadd(RANK_COMMON..rankType, score, roleId) --更新分数 | |
1958 | + end) | |
1959 | + end | |
1960 | + | |
1961 | + function Role:getRankInfoCommon(rankType) | |
1962 | + if not rankType then return end | |
1963 | + local list = {} | |
1964 | + local rankKey = RANK_COMMON .. rankType | |
1965 | + local ids = redisproxy:zrevrange(rankKey, 0 , 99, "WITHSCORES") | |
1966 | + for i = 1, #ids, 2 do | |
1967 | + local roleId = tonumber(ids[i]) | |
1968 | + local rankVal = tonumber(ids[i + 1]) | |
1969 | + rankVal = math.floor(math.floor(rankVal / CommonCoef2) / CommonCoef1) | |
1970 | + table.insert(list, {roleId = roleId, player = rankVal}) | |
1971 | + end | |
1972 | + | |
1973 | + for _, v in ipairs(list) do | |
1974 | + local _, curInfo = rpcRole(v.roleId, "friendSInfo") | |
1975 | + curInfo.ltime = nil | |
1976 | + curInfo.rankVal = v.player | |
1977 | + v.player = curInfo | |
1978 | + end | |
1979 | + | |
1980 | + local rank = redisproxy:ZREVRANK(rankKey, self:getProperty("id")) | |
1981 | + if not rank then | |
1982 | + rank = -1 | |
1983 | + else | |
1984 | + rank = rank + 1 | |
1985 | + end | |
1986 | + return {list = list, rank = rank} | |
1987 | + end | |
1988 | + | |
1989 | + | |
1932 | 1990 | end |
1933 | 1991 | |
1934 | 1992 | return RolePlugin |
1935 | 1993 | \ No newline at end of file | ... | ... |
src/models/RolePvp.lua
... | ... | @@ -233,7 +233,6 @@ function Role:refreshPvpMatch(score, rank, rankKey) |
233 | 233 | if low < 0 then |
234 | 234 | low = 0 |
235 | 235 | end |
236 | - print(low, heigh) | |
237 | 236 | local rangeIds = redisproxy:ZREVRANGE(dbKey, low, heigh) |
238 | 237 | local lastRangeIds = {} |
239 | 238 | for idx, one in ipairs(rangeIds) do | ... | ... |
src/models/RoleTask.lua
... | ... | @@ -48,6 +48,8 @@ local TaskType = { |
48 | 48 | AdvScore = 410, -- 冒险分数 - score |
49 | 49 | AdvDraw = 411, -- 冒险资助 - count ptype |
50 | 50 | AdvHang = 412, -- 代理拾荒次数 |
51 | + AdvMineKill = 413, -- 宝藏怪击杀 | |
52 | + AdvMineLayer = 414, -- 宝藏洞激活 | |
51 | 53 | |
52 | 54 | --爬塔相关 |
53 | 55 | TowerPass = 501, -- 爬塔通关 - level |
... | ... | @@ -218,6 +220,7 @@ local SudokuListener = { |
218 | 220 | } |
219 | 221 | |
220 | 222 | local Activity = require("models.Activity") |
223 | + | |
221 | 224 | local ActivityListener = { |
222 | 225 | func = "checkActivityTask", |
223 | 226 | listen = { |
... | ... | @@ -226,6 +229,8 @@ local ActivityListener = { |
226 | 229 | [TaskType.AdvDraw] = {{Activity.ActivityType.AdvDraw, f("count")}}, |
227 | 230 | [TaskType.OpenBox] = {{Activity.ActivityType.OpenBox, f("count")}}, |
228 | 231 | [TaskType.Pay] = {{Activity.ActivityType.PayBack, f("twd")}}, |
232 | + [TaskType.AdvMineKill] = {{Activity.ActivityType.Crisis, 1}}, | |
233 | + [TaskType.AdvMineLayer] = {{Activity.ActivityType.Crisis, 2}}, | |
229 | 234 | } |
230 | 235 | } |
231 | 236 | |
... | ... | @@ -266,7 +271,6 @@ local CalendaTaskListener = { |
266 | 271 | } |
267 | 272 | } |
268 | 273 | |
269 | - | |
270 | 274 | local TaskListeners = { |
271 | 275 | StoryListener, |
272 | 276 | CommonListener, |
... | ... | @@ -358,11 +362,22 @@ function RoleTask.bind(Role) |
358 | 362 | return true |
359 | 363 | end |
360 | 364 | |
365 | + local function checkStoryStatusByActBattle(role, data, status, cond1) -- cond1 carbonId | |
366 | + local actid = data.sort | |
367 | + if not role.activity:isOpenById(actid) then return end | |
368 | + if cond1 and tonumber(data.unlockData) == cond1 then | |
369 | + status.s = 1 | |
370 | + return true | |
371 | + end | |
372 | + return | |
373 | + end | |
374 | + | |
361 | 375 | local checkstoryStatusFunc = { |
362 | 376 | [1] = checkStoryStatusByHang, |
363 | 377 | [2] = checkStoryStatusByLove, |
364 | 378 | [3] = checkStoryStatusByMultStar, |
365 | 379 | [4] = checkStoryStatusByAdv, |
380 | + [5] = checkStoryStatusByActBattle, | |
366 | 381 | } |
367 | 382 | |
368 | 383 | function Role:checkStoryStatus(notNotify, stype, cond1, cond2, cond3) | ... | ... |
src/models/Store.lua
... | ... | @@ -298,6 +298,8 @@ function Store:resetStoreReored(resetId) |
298 | 298 | end |
299 | 299 | end |
300 | 300 | end |
301 | + else | |
302 | + payRecord[k] = nil | |
301 | 303 | end |
302 | 304 | end |
303 | 305 | self:updateProperty({field = "payR", value = payRecord}) |
... | ... | @@ -307,6 +309,8 @@ function Store:resetStoreReored(resetId) |
307 | 309 | if config.resetTime == resetId then |
308 | 310 | buyRecord[k] = nil |
309 | 311 | end |
312 | + else | |
313 | + buyRecord[k] = nil | |
310 | 314 | end |
311 | 315 | end |
312 | 316 | self:updateProperty({field = "buyR", value = buyRecord}) | ... | ... |
src/services/agent_ctrl.lua
... | ... | @@ -6,6 +6,7 @@ local xxtea = require "xxtea" |
6 | 6 | local deque = require "deque" |
7 | 7 | local datacenter = require "skynet.datacenter" |
8 | 8 | local agent_queued = require "services.agent_queued" |
9 | +local logproxy = require "shared.logproxy" | |
9 | 10 | |
10 | 11 | local pcall = pcall |
11 | 12 | local string_format = string.format |
... | ... | @@ -139,11 +140,11 @@ function _M:check_agent_status() |
139 | 140 | end |
140 | 141 | end |
141 | 142 | |
142 | - if now >= next_log_time and now % 60 == 0 and logd then | |
143 | + if now >= next_log_time and now % 60 == 0 then | |
143 | 144 | next_log_time = now + 60 |
144 | 145 | local count = table_nums(self.u2f) |
145 | 146 | datacenter.set("onlineCount", count) |
146 | - pcall(skynet.send, logd, "lua", "log", {["@type"] = "online", count = count}, "log") | |
147 | + logproxy:log({["@type"] = "online", count = count}, "log") | |
147 | 148 | end |
148 | 149 | end |
149 | 150 | ... | ... |
src/services/dbseed.lua
... | ... | @@ -34,8 +34,6 @@ local steps = { |
34 | 34 | } |
35 | 35 | |
36 | 36 | skynet.start(function () |
37 | - redisd = skynet.localname(".redis") | |
38 | - | |
39 | 37 | redisproxy = require("shared.redisproxy") |
40 | 38 | |
41 | 39 | local new = redisproxy:hsetnx("autoincrement_set", "server_start", os.date("%Y%m%d", skynet.timex())) == 1 | ... | ... |
src/services/globald.lua
... | ... | @@ -7,6 +7,7 @@ require "shared.init" |
7 | 7 | require "utils.init" |
8 | 8 | require "RedisKeys" |
9 | 9 | require "skynet.manager" |
10 | +require "GlobalVar" | |
10 | 11 | |
11 | 12 | |
12 | 13 | local ipairs = ipairs |
... | ... | @@ -16,6 +17,7 @@ local string_format = string.format |
16 | 17 | |
17 | 18 | |
18 | 19 | local CHECK_MAIL_STATUS_INTERVAL = 100 * 60 |
20 | +local CHECK_BATTLE_ACT_CLOSE_INTERVAL = 100 * 1 | |
19 | 21 | local function mailQuene() |
20 | 22 | local delayEmail = tonum(redisproxy:hget("autoincrement_set", "delay_email")) |
21 | 23 | if delayEmail == 0 then |
... | ... | @@ -91,6 +93,64 @@ local function check_mail_queue() |
91 | 93 | skynet.timeout(CHECK_MAIL_STATUS_INTERVAL, check_mail_queue) |
92 | 94 | end |
93 | 95 | |
96 | +-- @desc: 检测关卡活动结束 排行榜奖励发放 | |
97 | +local lastCheckBattleActTs = 0 | |
98 | +local function check_battle_act_close() | |
99 | + local csvdb = require "shared.csvdata" | |
100 | + local act = require "models.Activity" | |
101 | + local st = 0 | |
102 | + local et = 0 | |
103 | + local actId = 0 | |
104 | + local timeNow = skynet.timex() | |
105 | + for k, v in pairs(csvdb["activity_ctrlCsv"]) do | |
106 | + if v.showType == act.ActivityType.ChallengeLevel then | |
107 | + local openTimes = v.time:toArray(false, "=") | |
108 | + if openTimes[1] ~= "0" then | |
109 | + st = toUnixtime(openTimes[1]..string_format("%02x", RESET_TIME)) | |
110 | + end | |
111 | + if openTimes[2] ~= "0" then | |
112 | + et = toUnixtime(openTimes[2]..string_format("%02x", RESET_TIME)) | |
113 | + end | |
114 | + actId = k | |
115 | + break | |
116 | + end | |
117 | + end | |
118 | + if st ~= 0 and et ~= 0 and actId ~= 0 then | |
119 | + -- close | |
120 | + if lastCheckBattleActTs < et and timeNow >= et then | |
121 | + -- check rank key exist | |
122 | + local rankKey = RANK_COMMON..RANK_TYPE.ActBattleBoss | |
123 | + local flag = redisproxy:exists(rankKey) | |
124 | + if flag then | |
125 | + local actData = csvdb["activity_groupCsv"][actId] | |
126 | + local lastRank = actData[#actData].rank | |
127 | + | |
128 | + local ids = redisproxy:zrevrange(rankKey, 0 , lastRank - 1) | |
129 | + local rankIndex = 0 | |
130 | + for roleId in pairs(ids) do | |
131 | + rankIndex = rankIndex + 1 | |
132 | + for _, cfg in pairs(actData) do | |
133 | + if rankIndex <= cfg.rank then | |
134 | + redisproxy:insertEmail({ | |
135 | + roleId = roleId, | |
136 | + emailId = cfg.email_1, | |
137 | + attachments = cfg.reward_1, | |
138 | + contentPms = {rankIndex}, | |
139 | + }) | |
140 | + break | |
141 | + end | |
142 | + end | |
143 | + end | |
144 | + | |
145 | + redisproxy:del(rankKey..":bak") | |
146 | + redisproxy:rename(rankKey, rankKey..":bak") | |
147 | + end | |
148 | + end | |
149 | + end | |
150 | + lastCheckBattleActTs = skynet.timex() | |
151 | + skynet.timeout(CHECK_BATTLE_ACT_CLOSE_INTERVAL, check_battle_act_close) | |
152 | +end | |
153 | + | |
94 | 154 | |
95 | 155 | |
96 | 156 | local CMD = {} |
... | ... | @@ -115,6 +175,7 @@ end |
115 | 175 | |
116 | 176 | function CMD.start() |
117 | 177 | check_mail_queue() |
178 | + check_battle_act_close() | |
118 | 179 | end |
119 | 180 | |
120 | 181 | local function __init__() |
... | ... | @@ -129,7 +190,6 @@ local function __init__() |
129 | 190 | end |
130 | 191 | end |
131 | 192 | end) |
132 | - redisd = skynet.localname(".redis") | |
133 | 193 | skynet.register(".globald") |
134 | 194 | |
135 | 195 | end | ... | ... |
src/services/httpweb.lua
... | ... | @@ -53,12 +53,8 @@ end |
53 | 53 | local CMD = require "actions.HttpAction" |
54 | 54 | |
55 | 55 | local function start() |
56 | - redisd = skynet.localname(".redis") | |
57 | 56 | globalCsv = csvdb["GlobalDefineCsv"] |
58 | 57 | |
59 | - if tonumber(skynet.getenv "logd") == 1 then | |
60 | - logd = skynet.localname(".log") | |
61 | - end | |
62 | 58 | |
63 | 59 | local listen_socket = socket.listen("0.0.0.0", port) |
64 | 60 | print("Listen web port " .. port) |
... | ... | @@ -77,11 +73,11 @@ local function start() |
77 | 73 | return |
78 | 74 | end |
79 | 75 | local query = urllib.parse_query(query) |
80 | - if query.key ~= key then | |
81 | - response(id, 404) | |
82 | - socket.close(id) | |
83 | - return | |
84 | - end | |
76 | + -- if query.key ~= key then | |
77 | + -- response(id, 404) | |
78 | + -- socket.close(id) | |
79 | + -- return | |
80 | + -- end | |
85 | 81 | local content = CMD[cmd](query, body) |
86 | 82 | if not content then |
87 | 83 | code = 404 | ... | ... |
src/services/logd.lua
... | ... | @@ -2,12 +2,12 @@ local skynet = require "skynet" |
2 | 2 | local queue = require "skynet.queue" |
3 | 3 | local bson = require "bson" |
4 | 4 | local socketdriver = require "skynet.socketdriver" |
5 | - | |
6 | 5 | local serverId = tonumber(skynet.getenv("servId")) |
7 | 6 | |
8 | 7 | require "shared.init" |
9 | 8 | require "skynet.manager" |
10 | 9 | |
10 | +local logdIdx = ... | |
11 | 11 | local table_insert = table.insert |
12 | 12 | local pairs = pairs |
13 | 13 | local ipairs = ipairs |
... | ... | @@ -15,6 +15,7 @@ local string_format = string.format |
15 | 15 | |
16 | 16 | local logId = 0 |
17 | 17 | local CMD, cs = {} |
18 | +local prefix = "wasteland" .. logdIdx .. "S" .. serverId .. "C" | |
18 | 19 | |
19 | 20 | local logHandle = { |
20 | 21 | bi = { |
... | ... | @@ -33,7 +34,7 @@ local logHandle = { |
33 | 34 | doc["game_name"] = "wasteland" |
34 | 35 | doc["env"] = "cb" |
35 | 36 | doc["game_name_type"] = "guaji" |
36 | - doc["log_id"] = "wastelandC" .. logId .. "S" .. serverId .. "T" .. now | |
37 | + doc["log_id"] = prefix .. logId .. "T" .. now | |
37 | 38 | logId = (logId + 1) % 10000000 |
38 | 39 | end |
39 | 40 | }, |
... | ... | @@ -135,7 +136,7 @@ local function __init__() |
135 | 136 | end) |
136 | 137 | cs = queue() |
137 | 138 | |
138 | - skynet.register(".log") | |
139 | + skynet.register(".logd" .. logdIdx) | |
139 | 140 | end |
140 | 141 | |
141 | 142 | skynet.start(__init__) | ... | ... |
src/services/pvpd.lua
... | ... | @@ -289,7 +289,6 @@ end |
289 | 289 | |
290 | 290 | ------------------------------------------------------ |
291 | 291 | function CMD.start() |
292 | - redisd = skynet.localname(".redis") | |
293 | 292 | globalCsv = csvdb["GlobalDefineCsv"] |
294 | 293 | |
295 | 294 | pvpInfo = require("models.Pvpd").new({key = "cross:pvpInfo"}) | ... | ... |
src/services/redisd.lua
... | ... | @@ -3,7 +3,7 @@ require "skynet.manager" |
3 | 3 | local redis = require "skynet.db.redis" |
4 | 4 | |
5 | 5 | local db |
6 | - | |
6 | +local idx = ... | |
7 | 7 | local command = {} |
8 | 8 | |
9 | 9 | function command.open(conf) |
... | ... | @@ -25,7 +25,7 @@ skynet.start(function() |
25 | 25 | end |
26 | 26 | end) |
27 | 27 | skynet.info_func(function() |
28 | - skynet.ret(skynet.pack(skynet.call(skynet.self(), "debug", "STAT"))) | |
28 | + return skynet.stat("mqlen") | |
29 | 29 | end) |
30 | - skynet.register ".redis" | |
30 | + skynet.register(".redis" .. idx) | |
31 | 31 | end) |
32 | 32 | \ No newline at end of file | ... | ... |
src/services/watchdog.lua
1 | 1 | local skynet = require "skynet" |
2 | 2 | require "skynet.manager" |
3 | -local redisproxy = require "shared.redisproxy" | |
4 | 3 | local socket = require "skynet.socket" |
5 | 4 | local netpack = require "skynet.netpack" |
6 | 5 | local datacenter = require "skynet.datacenter" |
... | ... | @@ -47,7 +46,7 @@ function SOCKET.data(fd, msg) |
47 | 46 | end |
48 | 47 | end |
49 | 48 | |
50 | -local use_logd = tonumber(skynet.getenv "logd") | |
49 | + | |
51 | 50 | |
52 | 51 | -- @desc: agent状态定时检测 |
53 | 52 | function check_agent_status() |
... | ... | @@ -65,11 +64,7 @@ end |
65 | 64 | |
66 | 65 | function CMD.start(conf) |
67 | 66 | skynet.call(gate_serv, "lua", "open" , conf) |
68 | - skynet.call(redisd, "lua", "open", conf) | |
69 | - | |
70 | - if use_logd == 1 then | |
71 | - skynet.call(logd, "lua", "open") | |
72 | - end | |
67 | + | |
73 | 68 | skynet.call(pvpd, "lua", "start") |
74 | 69 | -- 开启agent状态检测定时器 |
75 | 70 | check_agent_status() |
... | ... | @@ -110,17 +105,11 @@ skynet.start(function() |
110 | 105 | end |
111 | 106 | end) |
112 | 107 | skynet.register ".watchdog" |
113 | - -- 数据库服务 | |
114 | - redisd = skynet.newservice("services/redisd") | |
115 | 108 | |
116 | 109 | -- 提前加载好 |
117 | 110 | csvdata.init() |
118 | 111 | print("launch csvdatad ...") |
119 | 112 | |
120 | - -- 日志服务 | |
121 | - if use_logd == 1 then | |
122 | - logd = skynet.newservice("services/logd") | |
123 | - end | |
124 | 113 | -- pvp 服务 |
125 | 114 | pvpd = skynet.newservice("services/pvpd") |
126 | 115 | cluster.register("pvpd", pvpd) | ... | ... |
... | ... | @@ -0,0 +1,23 @@ |
1 | + | |
2 | +local skynet = require "skynet" | |
3 | +local logd_count = tonumber(skynet.getenv("thread")) * 2 | |
4 | +local use_logd = tonumber(skynet.getenv("logd")) | |
5 | + | |
6 | + | |
7 | +local logd | |
8 | +skynet.init(function() | |
9 | + if use_logd then | |
10 | + local idx = math.randomInt(1, logd_count) | |
11 | + logd = skynet.localname(".logd" .. idx) | |
12 | + end | |
13 | +end) | |
14 | + | |
15 | +local logproxy = {} | |
16 | + | |
17 | +function logproxy:log(doc, logTo) | |
18 | + if use_logd and logd then | |
19 | + pcall(skynet.send, logd, "lua", "log", doc, logTo) | |
20 | + end | |
21 | +end | |
22 | + | |
23 | +return logproxy | |
0 | 24 | \ No newline at end of file | ... | ... |
src/shared/redisproxy.lua
1 | 1 | local skynet = require "skynet" |
2 | -local harbor = require "skynet.harbor" | |
2 | +require "utils.init" | |
3 | + | |
4 | +local redisd_count = tonumber(skynet.getenv("thread")) | |
5 | +local redisd | |
6 | +skynet.init(function() | |
7 | + local idx = math.randomInt(1, redisd_count) | |
8 | + redisd = skynet.localname(".redis" .. idx) | |
9 | +end) | |
3 | 10 | |
4 | 11 | local table_insert = table.insert |
5 | 12 | |
6 | 13 | local redisproxy = {} |
7 | 14 | |
8 | - | |
9 | 15 | local isUsePika = false |
10 | 16 | |
11 | 17 | ... | ... |