Commit a952123e2fbb6a0dfa83745ace465c169febfc31
Merge branch 'develop' into bugfix
* develop: (79 commits) 世界Boss 增加行动点 物资危机bug 物资危机 冒险bug 宝藏怪活动 世界boss翻牌奖励 活动卡池保底单独记录 充值 天赋升级写日志报错 活动剧情解锁 充值重复 bug 下一关提前 battle Bug 奖励副本 新机制 活动礼包购买记录活动过期清理 挑战活动打完再扣门票 heros 增加 supports 挑战关卡活动打完再扣门票 关卡挑战活动奖励错误bug 修改活动boss关卡三星条件 ...
Showing
57 changed files
with
2417 additions
and
569 deletions
Show diff stats
config/nodenames.lua
robot/robot.conf
1 | root = "./" | 1 | root = "./" |
2 | -thread = 8 | 2 | +thread = 4 |
3 | logger = nil | 3 | logger = nil |
4 | harbor = 0 | 4 | harbor = 0 |
5 | -start = "start" -- main script | 5 | +start = "robot_main" -- main script |
6 | bootstrap = "snlua bootstrap" -- The service for bootstrap | 6 | bootstrap = "snlua bootstrap" -- The service for bootstrap |
7 | 7 | ||
8 | lua_path = root .."skynet/lualib/?.lua;"..root.."robot/?.lua;"..root.."src/?.lua" | 8 | lua_path = root .."skynet/lualib/?.lua;"..root.."robot/?.lua;"..root.."src/?.lua" |
robot/robot.lua
@@ -16,6 +16,7 @@ local eventListener = {} | @@ -16,6 +16,7 @@ local eventListener = {} | ||
16 | 16 | ||
17 | local ignoreListener = { | 17 | local ignoreListener = { |
18 | ["Role.updateProperty"] = function(data) | 18 | ["Role.updateProperty"] = function(data) |
19 | + if not client.role then return end | ||
19 | local msg = MsgPack.unpack(data) | 20 | local msg = MsgPack.unpack(data) |
20 | for _, one in pairs(msg) do | 21 | for _, one in pairs(msg) do |
21 | client.role[one.key] = one.newValue | 22 | client.role[one.key] = one.newValue |
@@ -80,7 +81,7 @@ function triggerListener(listener, data) | @@ -80,7 +81,7 @@ function triggerListener(listener, data) | ||
80 | ignoreListener[listener](data) | 81 | ignoreListener[listener](data) |
81 | end | 82 | end |
82 | else | 83 | else |
83 | - log(listener .. " no handle!!!") | 84 | + -- log(listener .. " no handle!!!") |
84 | end | 85 | end |
85 | end | 86 | end |
86 | 87 | ||
@@ -103,8 +104,8 @@ function sendServer(actionCode, bin) | @@ -103,8 +104,8 @@ function sendServer(actionCode, bin) | ||
103 | end | 104 | end |
104 | 105 | ||
105 | function requestServer(actionCode, bin, callback, isKeep) | 106 | function requestServer(actionCode, bin, callback, isKeep) |
106 | - sendServer(actionCode, bin) | ||
107 | addListener(actionCode, callback, isKeep) | 107 | addListener(actionCode, callback, isKeep) |
108 | + sendServer(actionCode, bin) | ||
108 | end | 109 | end |
109 | 110 | ||
110 | local function heartBeat() | 111 | local function heartBeat() |
@@ -120,7 +121,7 @@ local function startUnit(unit) | @@ -120,7 +121,7 @@ local function startUnit(unit) | ||
120 | 121 | ||
121 | local ok, unitTest = pcall(require, "unitTest." .. unit) | 122 | local ok, unitTest = pcall(require, "unitTest." .. unit) |
122 | if not ok then | 123 | if not ok then |
123 | - print("unitTest load error : " .. unitTest) | 124 | + log("unitTest load error : " .. unitTest) |
124 | end | 125 | end |
125 | 126 | ||
126 | unitTest.new(client):startTest() | 127 | unitTest.new(client):startTest() |
@@ -130,6 +131,8 @@ end | @@ -130,6 +131,8 @@ end | ||
130 | -- 登录成功开始任务 | 131 | -- 登录成功开始任务 |
131 | function CMD.task() | 132 | function CMD.task() |
132 | heartBeat() | 133 | heartBeat() |
134 | + -- 20 秒后开始执行任务 错开登录 | ||
135 | + skynet.sleep(math.randomInt(2000, 3000)) | ||
133 | startUnit() | 136 | startUnit() |
134 | end | 137 | end |
135 | 138 | ||
@@ -142,7 +145,7 @@ function CMD.start(fd, id) | @@ -142,7 +145,7 @@ function CMD.start(fd, id) | ||
142 | client.uname = uname | 145 | client.uname = uname |
143 | local status, body = httpc.get(config.http, "/login?" .. httpGetFormatData({token = uname, device = "test", channel = "develop"})) | 146 | local status, body = httpc.get(config.http, "/login?" .. httpGetFormatData({token = uname, device = "test", channel = "develop"})) |
144 | if tonumber(status) ~= 200 then | 147 | if tonumber(status) ~= 200 then |
145 | - print("http get error", uname, body) | 148 | + log("http get error", uname, body) |
146 | return | 149 | return |
147 | end | 150 | end |
148 | local servInfo = json.decode(body) | 151 | local servInfo = json.decode(body) |
@@ -170,7 +173,7 @@ skynet.register_protocol { | @@ -170,7 +173,7 @@ skynet.register_protocol { | ||
170 | dispatch = function(session, address, cmd, data) | 173 | dispatch = function(session, address, cmd, data) |
171 | local actionName = actionHandlers[cmd] | 174 | local actionName = actionHandlers[cmd] |
172 | if not actionName then | 175 | if not actionName then |
173 | - print("actionName not exist", actionName) | 176 | + log("actionName not exist", actionName) |
174 | return | 177 | return |
175 | end | 178 | end |
176 | 179 |
robot/robot_config.lua
@@ -10,7 +10,7 @@ end | @@ -10,7 +10,7 @@ end | ||
10 | 10 | ||
11 | 11 | ||
12 | return { | 12 | return { |
13 | - http = "http://106.13.60.20:9090", -- 登录服 | 13 | + http = "http://192.168.0.199:9090", -- 登录服 |
14 | host = "127.0.0.1", --服务器地址 | 14 | host = "127.0.0.1", --服务器地址 |
15 | port = 12001, -- 服务器端口 | 15 | port = 12001, -- 服务器端口 |
16 | 16 | ||
@@ -20,15 +20,15 @@ return { | @@ -20,15 +20,15 @@ return { | ||
20 | max = 200, -- 最大玩家数 必须大于 online 数 | 20 | max = 200, -- 最大玩家数 必须大于 online 数 |
21 | online_time = {10 * 60, 20 * 60}, -- 在线时间控制 秒 | 21 | online_time = {10 * 60, 20 * 60}, -- 在线时间控制 秒 |
22 | 22 | ||
23 | - uname_prefix = "robot", --机器名称前缀 | 23 | + uname_prefix = "robothehe", --机器名称前缀 |
24 | 24 | ||
25 | 25 | ||
26 | -- 机器上线后的行为 | 26 | -- 机器上线后的行为 |
27 | units = { | 27 | units = { |
28 | chat = {weight = 100}, -- 聊天 | 28 | chat = {weight = 100}, -- 聊天 |
29 | item = {weight = 100}, -- 物品操作 | 29 | item = {weight = 100}, -- 物品操作 |
30 | - hero = {weight = 500}, -- 英雄 | ||
31 | - hang = {weight = 1000}, -- 挂机战斗 | 30 | + hero = {weight = 500}, -- 英雄 |
31 | + hang = {weight = 1000}, -- 挂机战斗 | ||
32 | tower = {weight = 500}, -- 爬塔 | 32 | tower = {weight = 500}, -- 爬塔 |
33 | car = {weight = 100}, -- 爬塔 | 33 | car = {weight = 100}, -- 爬塔 |
34 | pvp = {weight = 500}, -- pvp | 34 | pvp = {weight = 500}, -- pvp |
@@ -0,0 +1,21 @@ | @@ -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 | \ No newline at end of file | 22 | \ No newline at end of file |
@@ -0,0 +1,46 @@ | @@ -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,32 +5,37 @@ local config = require "robot_config" | ||
5 | local skynet = require "skynet" | 5 | local skynet = require "skynet" |
6 | local netpack = require "skynet.netpack" | 6 | local netpack = require "skynet.netpack" |
7 | local socketdriver = require "skynet.socketdriver" | 7 | local socketdriver = require "skynet.socketdriver" |
8 | +local deque = require "deque" | ||
8 | local string_format = string.format | 9 | local string_format = string.format |
9 | 10 | ||
11 | +local poold, pooldObj, onlineCount, startId, endId, inpre | ||
12 | +local factory | ||
13 | + | ||
10 | local queue = {} | 14 | local queue = {} |
11 | local fd2serv = {} | 15 | local fd2serv = {} |
12 | local id2fd = {} | 16 | local id2fd = {} |
13 | local MSG = {} | 17 | local MSG = {} |
14 | -local id_max = 0 -- robot id | 18 | +local id_max |
15 | 19 | ||
16 | 20 | ||
17 | function MSG.open( ... ) | 21 | function MSG.open( ... ) |
18 | - print("open", ...) | 22 | + log("open", ...) |
19 | end | 23 | end |
20 | 24 | ||
21 | function MSG.close(fd) | 25 | function MSG.close(fd) |
22 | if fd2serv[fd] and not fd2serv[fd].closing then | 26 | if fd2serv[fd] and not fd2serv[fd].closing then |
23 | fd2serv[fd].closing = true | 27 | fd2serv[fd].closing = true |
24 | skynet.call(fd2serv[fd].agent, "lua", "exit") | 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 | id2fd[fd2serv[fd].id] = nil | 32 | id2fd[fd2serv[fd].id] = nil |
28 | fd2serv[fd] = nil | 33 | fd2serv[fd] = nil |
29 | end | 34 | end |
30 | end | 35 | end |
31 | 36 | ||
32 | function MSG.error(fd, msg) | 37 | function MSG.error(fd, msg) |
33 | - print("MSG.error", fd, msg) | 38 | + log("MSG.error", fd, msg) |
34 | MSG.close(fd) | 39 | MSG.close(fd) |
35 | end | 40 | end |
36 | 41 | ||
@@ -72,13 +77,14 @@ skynet.register_protocol { | @@ -72,13 +77,14 @@ skynet.register_protocol { | ||
72 | } | 77 | } |
73 | 78 | ||
74 | local function add_robot() | 79 | local function add_robot() |
75 | - local robot = skynet.newservice("robot") | 80 | + local time = skynet.time() |
81 | + local robot = factory:pop() | ||
76 | local fd = socketdriver.connect(config.host, config.port) | 82 | local fd = socketdriver.connect(config.host, config.port) |
77 | socketdriver.start(fd) | 83 | socketdriver.start(fd) |
78 | local id | 84 | local id |
79 | - if id_max >= config.max then | 85 | + if id_max >= endId then |
80 | while true do | 86 | while true do |
81 | - id = math.randomInt(1, config.max) | 87 | + id = math.randomInt(startId, endId) |
82 | if not id2fd[id] then | 88 | if not id2fd[id] then |
83 | break | 89 | break |
84 | end | 90 | end |
@@ -89,9 +95,8 @@ local function add_robot() | @@ -89,9 +95,8 @@ local function add_robot() | ||
89 | end | 95 | end |
90 | fd2serv[fd] = {agent = robot, id = id} | 96 | fd2serv[fd] = {agent = robot, id = id} |
91 | id2fd[id] = fd | 97 | id2fd[id] = fd |
92 | - pcall(skynet.call, robot, "lua", "start", fd, id) | 98 | + pcall(skynet.call, robot, "lua", "start", fd, id, prefix) |
93 | log(string_format("login %s", fd2serv[fd].id)) | 99 | log(string_format("login %s", fd2serv[fd].id)) |
94 | - | ||
95 | -- 定时下线 | 100 | -- 定时下线 |
96 | skynet.timeout(math.randomInt(config.online_time[1], config.online_time[2]) * 100, function() | 101 | skynet.timeout(math.randomInt(config.online_time[1], config.online_time[2]) * 100, function() |
97 | MSG.close(fd) | 102 | MSG.close(fd) |
@@ -106,8 +111,8 @@ local function online() | @@ -106,8 +111,8 @@ local function online() | ||
106 | end | 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 | add_robot() | 116 | add_robot() |
112 | end | 117 | end |
113 | end | 118 | end |
@@ -116,11 +121,18 @@ local function online() | @@ -116,11 +121,18 @@ local function online() | ||
116 | skynet.timeout(100, online) | 121 | skynet.timeout(100, online) |
117 | end | 122 | end |
118 | 123 | ||
119 | -local function start() | 124 | +local function start(pooldp, pooldObj, onlineCountp, startIdp, endIdp, inprep) |
120 | log("start testing ...") | 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 | add_robot() | 136 | add_robot() |
125 | end | 137 | end |
126 | skynet.sleep(100) | 138 | skynet.sleep(100) |
@@ -131,5 +143,10 @@ local function start() | @@ -131,5 +143,10 @@ local function start() | ||
131 | end | 143 | end |
132 | 144 | ||
133 | skynet.start(function() | 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 | end) | 152 | end) |
136 | \ No newline at end of file | 153 | \ No newline at end of file |
robot/unitTest/adv.lua
@@ -8,6 +8,8 @@ local _M = class("hang", require("unitTest.unitTest")) | @@ -8,6 +8,8 @@ local _M = class("hang", require("unitTest.unitTest")) | ||
8 | 8 | ||
9 | function _M:start() | 9 | function _M:start() |
10 | sendServer(actionCodes.Gm_clientRequest, MsgPack.pack({cmd = "fb", pm1 = 10606})) | 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 | self:task() | 13 | self:task() |
12 | end | 14 | end |
13 | 15 | ||
@@ -24,8 +26,8 @@ function _M:task() | @@ -24,8 +26,8 @@ function _M:task() | ||
24 | end | 26 | end |
25 | 27 | ||
26 | function _M:startAdv() | 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 | requestServer(actionCodes.Adv_exitAdvRpc, '') | 31 | requestServer(actionCodes.Adv_exitAdvRpc, '') |
30 | end | 32 | end |
31 | 33 |
robot/unitTest/hero.lua
@@ -35,8 +35,8 @@ function _M:drawHero10() | @@ -35,8 +35,8 @@ function _M:drawHero10() | ||
35 | end | 35 | end |
36 | 36 | ||
37 | function _M:createHeroRandom() | 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 | end | 40 | end |
41 | 41 | ||
42 | 42 |
robot/unitTest/item.lua
@@ -14,7 +14,7 @@ end | @@ -14,7 +14,7 @@ end | ||
14 | local taskMap = { | 14 | local taskMap = { |
15 | saleItem = {100}, | 15 | saleItem = {100}, |
16 | openItem = {100}, | 16 | openItem = {100}, |
17 | - openTimeBox = {100}, | 17 | + -- openTimeBox = {100}, |
18 | } | 18 | } |
19 | 19 | ||
20 | function _M:task() | 20 | function _M:task() |
@@ -31,8 +31,8 @@ end | @@ -31,8 +31,8 @@ end | ||
31 | 31 | ||
32 | 32 | ||
33 | function _M:openItem() | 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 | end | 36 | end |
37 | 37 | ||
38 | function _M:openTimeBox() | 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 | XXTEA_KEY = "699D448D6D24f7F941E9F6E99F823E18" | 10 | XXTEA_KEY = "699D448D6D24f7F941E9F6E99F823E18" |
2 | RESET_TIME = 4 | 11 | RESET_TIME = 4 |
3 | 12 | ||
@@ -127,6 +136,7 @@ ItemId = { | @@ -127,6 +136,7 @@ ItemId = { | ||
127 | AdvKey = 80, -- 冒险钥匙 | 136 | AdvKey = 80, -- 冒险钥匙 |
128 | BoxKey = 60, -- 拆解工具 | 137 | BoxKey = 60, -- 拆解工具 |
129 | AdvPower = 4701, -- 拾荒体力 | 138 | AdvPower = 4701, -- 拾荒体力 |
139 | + CrisisScore = 8010, -- 积分 | ||
130 | } | 140 | } |
131 | 141 | ||
132 | TimeReset = { | 142 | TimeReset = { |
@@ -214,6 +224,7 @@ AdvBackEventType = { | @@ -214,6 +224,7 @@ AdvBackEventType = { | ||
214 | Level = 25, -- 升级 | 224 | Level = 25, -- 升级 |
215 | LinkChooseOver = 26, -- 连锁事件结束 | 225 | LinkChooseOver = 26, -- 连锁事件结束 |
216 | BuffEffect = 27, -- buff 效果 | 226 | BuffEffect = 27, -- buff 效果 |
227 | + PassiveEffect = 28, -- 被动 效果 | ||
217 | } | 228 | } |
218 | 229 | ||
219 | AdvScoreType = { | 230 | AdvScoreType = { |
@@ -282,6 +293,10 @@ CardType = { | @@ -282,6 +293,10 @@ CardType = { | ||
282 | BattlePassCard = 7, -- 探索指令 | 293 | BattlePassCard = 7, -- 探索指令 |
283 | } | 294 | } |
284 | 295 | ||
296 | +ShopPackType = { | ||
297 | + ActShopPack = 5, -- 活动礼包 | ||
298 | +} | ||
299 | + | ||
285 | HeroQuality = { | 300 | HeroQuality = { |
286 | N = 1, | 301 | N = 1, |
287 | R = 2, | 302 | R = 2, |
@@ -304,6 +319,7 @@ MailId = { | @@ -304,6 +319,7 @@ MailId = { | ||
304 | ActDrawCardReward = 222, | 319 | ActDrawCardReward = 222, |
305 | ActAdvDrawReward = 223, | 320 | ActAdvDrawReward = 223, |
306 | ActOpenBoxReward = 224, | 321 | ActOpenBoxReward = 224, |
322 | + ActItemRecycle = 225, | ||
307 | 323 | ||
308 | PaySignAward = 241, | 324 | PaySignAward = 241, |
309 | PayBackAward = 242, | 325 | PayBackAward = 242, |
src/ProtocolCode.lua
@@ -50,6 +50,7 @@ actionCodes = { | @@ -50,6 +50,7 @@ actionCodes = { | ||
50 | Role_useSelectItemRpc = 134, -- 使用多选一礼包 | 50 | Role_useSelectItemRpc = 134, -- 使用多选一礼包 |
51 | Role_broadGetSSR = 135, -- 全服广播 获得ssr英雄 | 51 | Role_broadGetSSR = 135, -- 全服广播 获得ssr英雄 |
52 | Role_renameTeamRpc = 136, -- 编队改名 | 52 | Role_renameTeamRpc = 136, -- 编队改名 |
53 | + Role_accuseRpc = 137, -- 举报 | ||
53 | 54 | ||
54 | Adv_startAdvRpc = 151, | 55 | Adv_startAdvRpc = 151, |
55 | Adv_startHangRpc = 152, | 56 | Adv_startHangRpc = 152, |
@@ -100,6 +101,7 @@ actionCodes = { | @@ -100,6 +101,7 @@ actionCodes = { | ||
100 | Hero_changeCrown = 223, | 101 | Hero_changeCrown = 223, |
101 | Hero_drawHeroExtraRewardNtf = 224, | 102 | Hero_drawHeroExtraRewardNtf = 224, |
102 | Hero_itemComposeRpc = 225, | 103 | Hero_itemComposeRpc = 225, |
104 | + Hero_setWishPoolRpc = 226, | ||
103 | 105 | ||
104 | Hang_startRpc = 251, | 106 | Hang_startRpc = 251, |
105 | Hang_checkRpc = 252, | 107 | Hang_checkRpc = 252, |
@@ -202,6 +204,7 @@ actionCodes = { | @@ -202,6 +204,7 @@ actionCodes = { | ||
202 | Store_getGrowFundRewardRpc = 561, --成长助力奖励 | 204 | Store_getGrowFundRewardRpc = 561, --成长助力奖励 |
203 | Store_getBattlePassRewardRpc = 562, --赛季卡奖励 | 205 | Store_getBattlePassRewardRpc = 562, --赛季卡奖励 |
204 | Store_getExploreCommandRewardRpc = 563, --探索指令 | 206 | Store_getExploreCommandRewardRpc = 563, --探索指令 |
207 | + Store_getTotalRechargeAwardRpc = 564, -- 累计充值 | ||
205 | 208 | ||
206 | 209 | ||
207 | Email_listRpc = 600, | 210 | Email_listRpc = 600, |
@@ -217,9 +220,19 @@ actionCodes = { | @@ -217,9 +220,19 @@ actionCodes = { | ||
217 | Activity_actPaySignRewardNtf = 654, | 220 | Activity_actPaySignRewardNtf = 654, |
218 | Activity_actCalendaTaskRpc = 655, | 221 | Activity_actCalendaTaskRpc = 655, |
219 | Activity_actPaySignRpc = 656, | 222 | Activity_actPaySignRpc = 656, |
223 | + Activity_exchangeRpc = 657, | ||
224 | + Activity_gachakonRpc = 658, | ||
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, | ||
220 | 232 | ||
221 | Radio_startQuestRpc = 700, | 233 | Radio_startQuestRpc = 700, |
222 | Radio_finishQuestRpc = 701, | 234 | Radio_finishQuestRpc = 701, |
235 | + Radio_cancelQuestRpc = 702, | ||
223 | } | 236 | } |
224 | 237 | ||
225 | rpcResponseBegin = 10000 | 238 | rpcResponseBegin = 10000 |
src/RedisKeys.lua
@@ -15,6 +15,12 @@ R_STORE = "role:%d:store" -- 商店 | @@ -15,6 +15,12 @@ R_STORE = "role:%d:store" -- 商店 | ||
15 | R_ORDERS = "role:%d:orders" -- 订单 | 15 | R_ORDERS = "role:%d:orders" -- 订单 |
16 | R_ORDER = "order:%d:%d" | 16 | R_ORDER = "order:%d:%d" |
17 | 17 | ||
18 | +-- 通用排行榜 | ||
19 | +RANK_COMMON = "rank:common:" | ||
20 | +RANK_TYPE = { | ||
21 | + ActBattleBoss = "act_battle_boss", | ||
22 | + ActCrisis = "crisis", | ||
23 | +} | ||
18 | 24 | ||
19 | -- rank | 25 | -- rank |
20 | RANK_TOWER = "rank:tower" | 26 | RANK_TOWER = "rank:tower" |
src/actions/ActivityAction.lua
@@ -263,4 +263,599 @@ function _M.actCalendaTaskRpc(agent, data) | @@ -263,4 +263,599 @@ function _M.actCalendaTaskRpc(agent, data) | ||
263 | return true | 263 | return true |
264 | end | 264 | end |
265 | 265 | ||
266 | +function _M.exchangeRpc(agent, data) | ||
267 | + local role = agent.role | ||
268 | + local msg = MsgPack.unpack(data) | ||
269 | + local actid = msg.actid | ||
270 | + local id = msg.id | ||
271 | + local count = msg.count | ||
272 | + if not role.activity:isOpenById(actid, "Exchange") then return 1 end | ||
273 | + | ||
274 | + local exchangeCfg = csvdb["activity_exchangeCsv"][actid] | ||
275 | + if not exchangeCfg then return 2 end | ||
276 | + if not exchangeCfg[id] then return 3 end | ||
277 | + local curData = role.activity:getActData("Exchange") or {} | ||
278 | + local exchangeData = curData[actid] or {} | ||
279 | + local curCount = exchangeData[id] or 0 | ||
280 | + local actCfg = exchangeCfg[id] | ||
281 | + local limitArr = actCfg.limit:toArray(true, "=") | ||
282 | + if curCount + count > limitArr[2] then return 4 end | ||
283 | + | ||
284 | + local costs = actCfg.goods:toNumMap() | ||
285 | + for k,v in pairs(costs) do | ||
286 | + costs[k] = v * count | ||
287 | + end | ||
288 | + if not role:checkItemEnough(costs) then return 5 end | ||
289 | + role:costItems(costs, {log = {desc = "actExchange", int1 = actid, int2 = id}}) | ||
290 | + | ||
291 | + curCount = curCount + count | ||
292 | + exchangeData[id] = curCount | ||
293 | + curData[actid] = exchangeData | ||
294 | + role.activity:updateActData("Exchange", curData) | ||
295 | + | ||
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}}) | ||
302 | + | ||
303 | + | ||
304 | + SendPacket(actionCodes.Activity_exchangeRpc, MsgPack.pack(role:packReward(reward, change))) | ||
305 | + return true | ||
306 | +end | ||
307 | + | ||
308 | +function _M.gachakonRpc(agent, data) | ||
309 | + local role = agent.role | ||
310 | + local msg = MsgPack.unpack(data) | ||
311 | + local actid = msg.actid | ||
312 | + local count = msg.count | ||
313 | + | ||
314 | + if count > 10 then return end | ||
315 | + | ||
316 | + if not role.activity:isOpenById(actid, "Gachakon") then return 1 end | ||
317 | + | ||
318 | + local actCtrlData = csvdb["activity_ctrlCsv"][actid] | ||
319 | + if not actCtrlData then return 2 end | ||
320 | + local cost = actCtrlData.condition2:toNumMap() | ||
321 | + | ||
322 | + local actCfg = csvdb["activity_capsuleToysCsv"][actid] | ||
323 | + if not actCfg then return 3 end | ||
324 | + | ||
325 | + local gachakonInfo = role.activity:getActData("Gachakon") or {} | ||
326 | + local award = {} | ||
327 | + local remain = 0 | ||
328 | + local showAward = {} | ||
329 | + for i = 1, count do | ||
330 | + local tmpCfg = clone(actCfg) | ||
331 | + remain = 0 | ||
332 | + for id, cfg in pairs(tmpCfg) do | ||
333 | + local num = gachakonInfo[id] or 0 | ||
334 | + num = cfg.amount >= num and cfg.amount - num or 0 | ||
335 | + cfg.weight = cfg.weight * num | ||
336 | + if cfg.weight > 0 then | ||
337 | + remain = remain + num | ||
338 | + end | ||
339 | + --print("num ".. num, id, cfg.weight, cfg.amount) | ||
340 | + end | ||
341 | + if remain == 0 then | ||
342 | + break | ||
343 | + end | ||
344 | + local id = math.randWeight(tmpCfg, "weight") | ||
345 | + if not id then return 4 end | ||
346 | + gachakonInfo[id] = (gachakonInfo[id] or 0) + 1 | ||
347 | + local curAward = tmpCfg[id].award:toNumMap() | ||
348 | + table.insert(showAward, curAward) | ||
349 | + for k, v in pairs(curAward) do | ||
350 | + award[k] = (award[k] or 0) + v | ||
351 | + end | ||
352 | + end | ||
353 | + | ||
354 | + for k, v in pairs(cost) do | ||
355 | + cost[k] = v * count | ||
356 | + end | ||
357 | + | ||
358 | + if not role:checkItemEnough(cost) then return 5 end | ||
359 | + | ||
360 | + role:costItems(cost, {log = {desc = "actGachakon", int1 = actid, int2 = count}}) | ||
361 | + | ||
362 | + local reward, change = role:award(award, {log = {desc = "actGachakon", int1 = actid, int2 = count}}) | ||
363 | + --print("-----------", remain, count) | ||
364 | + if remain <= 1 then | ||
365 | + gachakonInfo = {} | ||
366 | + end | ||
367 | + role.activity:updateActData("Gachakon", gachakonInfo) | ||
368 | + | ||
369 | + SendPacket(actionCodes.Activity_gachakonRpc, MsgPack.pack(showAward)) | ||
370 | + return true | ||
371 | +end | ||
372 | + | ||
373 | +function _M.hangDropRpc(agent, data) | ||
374 | + local role = agent.role | ||
375 | + local msg = MsgPack.unpack(data) | ||
376 | + local actid = msg.actid | ||
377 | + if not role.activity:isOpenById(actid, "HangDrop") then return 1 end | ||
378 | + | ||
379 | + local actCfg = csvdb["activity_putCsv"][actid] | ||
380 | + if not actCfg then return 2 end | ||
381 | + | ||
382 | + local award, period = "", 0 | ||
383 | + for i = 1, #actCfg do | ||
384 | + local cfg = actCfg[i] | ||
385 | + if not cfg then | ||
386 | + break | ||
387 | + end | ||
388 | + if cfg.condition ~= "" then | ||
389 | + local arr = cfg.condition:toArray(true, "=") | ||
390 | + local type = arr[1] | ||
391 | + if type == 1 then | ||
392 | + local actId = arr[2] | ||
393 | + local carbonId = arr[3] | ||
394 | + if not role.activity:isOpenById(actId, "ChallengeLevel") then return 3 end | ||
395 | + local clInfo = role.activity:getActData("ChallengeLevel") or {} | ||
396 | + if not clInfo[carbonId] then | ||
397 | + break | ||
398 | + end | ||
399 | + end | ||
400 | + end | ||
401 | + award = cfg.reward | ||
402 | + period = cfg.period * 60 | ||
403 | + end | ||
404 | + local actData = role.activity:getActData("HangDrop") or 0 | ||
405 | + local timeNow = skynet.timex() | ||
406 | + if period == 0 or award == "" then | ||
407 | + return 4 | ||
408 | + end | ||
409 | + local num = math.floor((timeNow - actData)/ period) | ||
410 | + num = num > 8 and 8 or num | ||
411 | + if num == 0 then | ||
412 | + return 5 | ||
413 | + end | ||
414 | + local reward, change = {}, nil | ||
415 | + for id, value in pairs(award:toNumMap()) do | ||
416 | + reward[id] = value * num | ||
417 | + end | ||
418 | + | ||
419 | + reward, change = role:award(reward, {log = {desc = "actHangDrop", int1 = actid, int2 = num}}) | ||
420 | + | ||
421 | + if num < 8 then | ||
422 | + actData = actData + num * period | ||
423 | + else | ||
424 | + actData = timeNow | ||
425 | + end | ||
426 | + | ||
427 | + role.activity:updateActData("HangDrop", actData) | ||
428 | + | ||
429 | + SendPacket(actionCodes.Activity_hangDropRpc, MsgPack.pack(role:packReward(reward, change))) | ||
430 | + | ||
431 | + return true | ||
432 | +end | ||
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 | + if battleCfg.worldBoss_award ~= 0 and msg.point then | ||
707 | + battleInfo["bossP"] = (battleInfo["bossP"] or 0) + msg.point | ||
708 | + end | ||
709 | + | ||
710 | + reward, change = role:award(reward, {log = {desc = "actBattle", int1 = actid, int2 = newStarNum}}) | ||
711 | + | ||
712 | + SendPacket(actionCodes.Activity_endBattleRpc, MsgPack.pack({ | ||
713 | + reward = reward, | ||
714 | + change = change | ||
715 | + })) | ||
716 | + | ||
717 | + return true | ||
718 | +end | ||
719 | + | ||
720 | +function _M.battleRankRpc(agent, data) | ||
721 | + local role = agent.role | ||
722 | + local msg = MsgPack.unpack(data) | ||
723 | + local actid = msg.actid | ||
724 | + local cfg = csvdb["activity_ctrlCsv"][actid] | ||
725 | + if not cfg then return 1 end | ||
726 | + if not role.activity:isOpen(cfg.showType) then return 2 end | ||
727 | + local actTypeToRank = { | ||
728 | + [role.activity.ActivityType.ChallengeLevel] = RANK_TYPE.ActBattleBoss, | ||
729 | + [role.activity.ActivityType.Crisis] = RANK_TYPE.ActCrisis, | ||
730 | + } | ||
731 | + if not actTypeToRank[cfg.showType] then return end | ||
732 | + local rankInfo = role:getRankInfoCommon(actTypeToRank[cfg.showType]) | ||
733 | + SendPacket(actionCodes.Activity_battleRankRpc, MsgPack.pack(rankInfo)) | ||
734 | + return true | ||
735 | +end | ||
736 | + | ||
737 | +function _M.battleMilestoneRpc(agent, data) | ||
738 | + local role = agent.role | ||
739 | + local msg = MsgPack.unpack(data) | ||
740 | + local actid = msg.actid | ||
741 | + local id = msg.id | ||
742 | + local index = msg.index | ||
743 | + | ||
744 | + if not role.activity:isOpenById(actid, "ChallengeLevel") then return 1 end | ||
745 | + | ||
746 | + local actCfg = csvdb["activity_mileageCsv"][actid] | ||
747 | + if not actCfg then return 3 end | ||
748 | + | ||
749 | + local mileCfg = actCfg[index] | ||
750 | + if not mileCfg then return 4 end | ||
751 | + | ||
752 | + local actData = role.activity:getActData("ChallengeLevel") or {} | ||
753 | + local battleInfo = actData[id] or {} | ||
754 | + local val = 0 | ||
755 | + if mileCfg.type == 1 then | ||
756 | + val = battleInfo["sum"] or 0 | ||
757 | + elseif mileCfg.type == 2 then | ||
758 | + val = battleInfo["top"] or 0 | ||
759 | + end | ||
760 | + | ||
761 | + local record = battleInfo["r"] or "" | ||
762 | + local flag = string.char(string.getbit(record, index)) | ||
763 | + if flag == "1" then return 5 end | ||
764 | + if mileCfg.condition > val then return 6 end | ||
765 | + | ||
766 | + battleInfo["r"] = string.setbit(record, index) | ||
767 | + actData[id] = battleInfo | ||
768 | + role.activity:updateActData("ChallengeLevel", actData) | ||
769 | + | ||
770 | + local award = mileCfg.reward:toNumMap() | ||
771 | + local reward, change = role:award(award, {log = {desc = "actMilestone", int1 = actid, int2 = index}}) | ||
772 | + SendPacket(actionCodes.Activity_battleMilestoneRpc, MsgPack.pack(role:packReward(reward, change))) | ||
773 | + | ||
774 | + return true | ||
775 | +end | ||
776 | + | ||
777 | +function _M.crisisMilestoneRpc(agent, data) | ||
778 | + local role = agent.role | ||
779 | + local msg = MsgPack.unpack(data) | ||
780 | + local actid = msg.actid | ||
781 | + local id = msg.id | ||
782 | + if not role.activity:isOpenById(actid, "Crisis") then return 1 end | ||
783 | + local actCfg = csvdb["activity_mileageCsv"][actid] | ||
784 | + if not actCfg then return 3 end | ||
785 | + | ||
786 | + local curCsv = actCfg[id] | ||
787 | + if not curCsv then return 4 end | ||
788 | + | ||
789 | + if role:getItemCount(ItemId.CrisisScore) < curCsv.condition then | ||
790 | + return 5 | ||
791 | + end | ||
792 | + | ||
793 | + local actData = role.activity:getActData("Crisis") or {} | ||
794 | + actData.score = actData.score or {} | ||
795 | + if actData.score[id] then | ||
796 | + return 6 | ||
797 | + end | ||
798 | + actData.score[id] = -1 | ||
799 | + role.activity:updateActData("Crisis", actData) | ||
800 | + | ||
801 | + local reward, change = role:award(curCsv.reward, {log = {desc = "actMilecrisis", int1 = actid}}) | ||
802 | + SendPacket(actionCodes.Activity_crisisMilestoneRpc, MsgPack.pack(role:packReward(reward, change))) | ||
803 | + return true | ||
804 | +end | ||
805 | + | ||
806 | + | ||
807 | +function _M.bossRewardRpc(agent, data) | ||
808 | + local role = agent.role | ||
809 | + local msg = MsgPack.unpack(data) | ||
810 | + local actid = msg.actid | ||
811 | + local id = msg.id | ||
812 | + local index = msg.index | ||
813 | + | ||
814 | + if not role.activity:isOpenById(actid, "ChallengeLevel") then return 1 end | ||
815 | + | ||
816 | + local actCfg = csvdb["activity_battleCsv"][actid] | ||
817 | + if not actCfg then return 2 end | ||
818 | + | ||
819 | + local battleCfg = actCfg[id] | ||
820 | + if not battleCfg then return 3 end | ||
821 | + | ||
822 | + if battleCfg.worldBoss_award == 0 then return 4 end | ||
823 | + | ||
824 | + actCfg = csvdb["activity_wordboss_awardCsv"][battleCfg.worldBoss_award] | ||
825 | + if not actCfg then return 5 end | ||
826 | + local awardCfg = actCfg[index] | ||
827 | + if not awardCfg then return 6 end | ||
828 | + | ||
829 | + local preList = awardCfg.condition1:toArray(true, "=") | ||
830 | + | ||
831 | + local actData = role.activity:getActData("ChallengeLevel") or {} | ||
832 | + local battleInfo = actData[id] or {} | ||
833 | + local bossPoint = battleInfo["bossP"] or 0 | ||
834 | + if bossPoint < 1 then return 7 end | ||
835 | + | ||
836 | + local bossRecord = battleInfo["bossR"] or "" | ||
837 | + local ok = false | ||
838 | + if #preList == 0 then | ||
839 | + ok = true | ||
840 | + else | ||
841 | + for _, i in ipairs(preList) do | ||
842 | + local flag = string.char(string.getbit(bossRecord, i)) | ||
843 | + if flag == "1" then | ||
844 | + ok = true | ||
845 | + break | ||
846 | + end | ||
847 | + end | ||
848 | + end | ||
849 | + if not ok then return 8 end | ||
850 | + | ||
851 | + battleInfo["bossR"] = string.setbit(bossRecord, index) | ||
852 | + actData[id] = battleInfo | ||
853 | + role.activity:updateActData("ChallengeLevel", actData) | ||
854 | + | ||
855 | + local award = awardCfg.reward:toNumMap() | ||
856 | + local reward, change = role:award(award, {log = {desc = "worldBossReward", int1 = actid, int2 = index}}) | ||
857 | + SendPacket(actionCodes.Activity_bossRewardRpc, MsgPack.pack(role:packReward(reward, change))) | ||
858 | + return true | ||
859 | +end | ||
860 | + | ||
266 | return _M | 861 | return _M |
267 | \ No newline at end of file | 862 | \ No newline at end of file |
src/actions/AdvAction.lua
@@ -746,7 +746,7 @@ function _M.endBattleRpc(agent, data) | @@ -746,7 +746,7 @@ function _M.endBattleRpc(agent, data) | ||
746 | end | 746 | end |
747 | end | 747 | end |
748 | adv:mylog({desc = "endBattle"}) | 748 | adv:mylog({desc = "endBattle"}) |
749 | - local status = adv:clickBlock(roomId, blockId, {player = player, bySkill = bySkill}) | 749 | + local status = adv:clickBlock(roomId, blockId, {player = player, enemy = msg.enemy, bySkill = bySkill}) |
750 | 750 | ||
751 | if not status then return end | 751 | if not status then return end |
752 | SendPacket(actionCodes.Adv_endBattleRpc, MsgPack.pack({events = adv:popBackEvents()})) | 752 | SendPacket(actionCodes.Adv_endBattleRpc, MsgPack.pack({events = adv:popBackEvents()})) |
src/actions/DinerAction.lua
@@ -598,6 +598,7 @@ function _M.updateTaskRpc( agent, data ) | @@ -598,6 +598,7 @@ function _M.updateTaskRpc( agent, data ) | ||
598 | restaurant_order_status = cmd, -- 订单任务状态,接受:0, 拒绝:1, 完成:2 | 598 | restaurant_order_status = cmd, -- 订单任务状态,接受:0, 拒绝:1, 完成:2 |
599 | restaurant_order_rwd = reward or {}, -- 订单完成奖励,json格式记录,{"itemid1":123,"itemid2":12,……….} | 599 | restaurant_order_rwd = reward or {}, -- 订单完成奖励,json格式记录,{"itemid1":123,"itemid2":12,……….} |
600 | restaurant_order_lv = taskData.rarity, -- 订单品质等级,普通:0, 稀有:1, 顶级:2, 豪华:3 | 600 | restaurant_order_lv = taskData.rarity, -- 订单品质等级,普通:0, 稀有:1, 顶级:2, 豪华:3 |
601 | + restaurant_order_type = 1, -- 订单任务类型,0:特殊顾客,1:特别订单 | ||
601 | }) | 602 | }) |
602 | 603 | ||
603 | role.dinerData:updateProperty({field = "order", value = json.encode(orders)}) | 604 | role.dinerData:updateProperty({field = "order", value = json.encode(orders)}) |
@@ -896,6 +897,14 @@ function _M.entrustRpc(agent , data) | @@ -896,6 +897,14 @@ function _M.entrustRpc(agent , data) | ||
896 | 897 | ||
897 | reward, change = role:award(curData.reward, {log = {desc = "dinerEntrus", int1 = entrustId}}) | 898 | reward, change = role:award(curData.reward, {log = {desc = "dinerEntrus", int1 = entrustId}}) |
898 | table.remove(entrust, 1) | 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 | elseif ctype == 2 then -- 放弃 | 908 | elseif ctype == 2 then -- 放弃 |
900 | table.remove(entrust, 1) | 909 | table.remove(entrust, 1) |
901 | else | 910 | else |
src/actions/EmailAction.lua
@@ -121,7 +121,7 @@ function _M.drawAttachRpc(agent, data) | @@ -121,7 +121,7 @@ function _M.drawAttachRpc(agent, data) | ||
121 | local attachments = getEmailAttachments(email) | 121 | local attachments = getEmailAttachments(email) |
122 | if attachments == "" then return end | 122 | if attachments == "" then return end |
123 | 123 | ||
124 | - local reward, change = role:award(attachments, {log = {desc = "draw_attach", int1 = emailId}}) | 124 | + local reward, change = role:award(attachments, {log = {desc = "draw_attach", int1 = id}}) |
125 | email:setProperty("status", 2) | 125 | email:setProperty("status", 2) |
126 | email:log(role, 2) | 126 | email:log(role, 2) |
127 | SendPacket(actionCodes.Email_drawAttachRpc, MsgPack.pack({reward = reward, change = change})) | 127 | SendPacket(actionCodes.Email_drawAttachRpc, MsgPack.pack({reward = reward, change = change})) |
src/actions/GmAction.lua
@@ -502,6 +502,11 @@ function _M.guide(role, pms) | @@ -502,6 +502,11 @@ function _M.guide(role, pms) | ||
502 | end | 502 | end |
503 | end | 503 | end |
504 | end | 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 | role:updateProperty({field = "funcGuide", value = str}) | 510 | role:updateProperty({field = "funcGuide", value = str}) |
506 | role:mylog("gm_action", {desc = "sguide", key1 = pms.sender}) | 511 | role:mylog("gm_action", {desc = "sguide", key1 = pms.sender}) |
507 | 512 | ||
@@ -524,6 +529,16 @@ function _M.guide(role, pms) | @@ -524,6 +529,16 @@ function _M.guide(role, pms) | ||
524 | return "成功" | 529 | return "成功" |
525 | end | 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 | function _M.helpRpc(agent, data) | 542 | function _M.helpRpc(agent, data) |
528 | SendPacket(actionCodes.Gm_helpRpc, MsgPack.pack({help = helpDes})) | 543 | SendPacket(actionCodes.Gm_helpRpc, MsgPack.pack({help = helpDes})) |
529 | return true | 544 | return true |
@@ -533,7 +548,9 @@ function _M.test(role, pms) | @@ -533,7 +548,9 @@ function _M.test(role, pms) | ||
533 | local id = tonum(pms.pm1, 0) | 548 | local id = tonum(pms.pm1, 0) |
534 | --local hero = require ("actions.HeroAction") | 549 | --local hero = require ("actions.HeroAction") |
535 | --hero.unlockPoolRpc({role = role}, MsgPack.pack({type = id})) | 550 | --hero.unlockPoolRpc({role = role}, MsgPack.pack({type = id})) |
536 | - print(role:getPaybackReward(0, 10000)) | 551 | + |
552 | + --role:sendMail(13, nil, "1=2", {111}) | ||
553 | + dump(redisproxy:zrevrange("rank:tower", 0 , 10, "WITHSCORES")) | ||
537 | return "成功" | 554 | return "成功" |
538 | end | 555 | end |
539 | 556 |
src/actions/HangAction.lua
@@ -498,46 +498,49 @@ function _M.buyBonusCountRpc(agent, data) | @@ -498,46 +498,49 @@ function _M.buyBonusCountRpc(agent, data) | ||
498 | return true | 498 | return true |
499 | end | 499 | end |
500 | 500 | ||
501 | -local function bonusWinReward(role, bonusData, bwin, count) | 501 | +local function bonusWinReward(role, bonusData, rewardType, count) |
502 | count = count or 1 | 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 | end | 508 | end |
527 | end | 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 | for k, v in pairs(bonusData.perfect_reward:toNumMap()) do | 512 | for k, v in pairs(bonusData.perfect_reward:toNumMap()) do |
535 | reward[k] = (reward[k] or 0) + v | 513 | reward[k] = (reward[k] or 0) + v |
536 | end | 514 | end |
537 | end | 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 | end | 544 | end |
542 | 545 | ||
543 | function _M.startBonusBattleRpc(agent, data) | 546 | function _M.startBonusBattleRpc(agent, data) |
@@ -559,23 +562,24 @@ function _M.startBonusBattleRpc(agent, data) | @@ -559,23 +562,24 @@ function _M.startBonusBattleRpc(agent, data) | ||
559 | if not bonusData then return 3 end | 562 | if not bonusData then return 3 end |
560 | if not role:checkHangPass(bonusData.unlock) then return 4 end | 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 | local bonusStar = role:getProperty("bonusStar") | 566 | local bonusStar = role:getProperty("bonusStar") |
576 | if bonusStar[id] and bonusStar[id] >= (1 << #bonusData.sweep_condition:toTableArray(true)) - 1 then | 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 | SendPacket(actionCodes.Hang_startBonusBattleRpc, MsgPack.pack({reward = reward, change = change})) | 583 | SendPacket(actionCodes.Hang_startBonusBattleRpc, MsgPack.pack({reward = reward, change = change})) |
580 | else | 584 | else |
581 | local bTeam = role:getTeamFormatByType(TeamSystemType.BonusBattle) | 585 | local bTeam = role:getTeamFormatByType(TeamSystemType.BonusBattle) |
@@ -605,15 +609,16 @@ function _M.endBonusBattleRpc(agent, data) | @@ -605,15 +609,16 @@ function _M.endBonusBattleRpc(agent, data) | ||
605 | end | 609 | end |
606 | local bonusData = csvdb["bonus_battleCsv"][id] | 610 | local bonusData = csvdb["bonus_battleCsv"][id] |
607 | 611 | ||
608 | - local reward, change | 612 | + local reward, change = {} |
609 | 613 | ||
610 | local bonusStar = role:getProperty("bonusStar") | 614 | local bonusStar = role:getProperty("bonusStar") |
615 | + local oldStar = bonusStar[id] or 0 | ||
611 | local curStar = 0 | 616 | local curStar = 0 |
612 | if starNum and starNum > 0 then | 617 | if starNum and starNum > 0 then |
613 | -- 胜利扣除次数 | 618 | -- 胜利扣除次数 |
614 | 619 | ||
615 | local bTeam = role:getTeamFormatByType(TeamSystemType.BonusBattle) | 620 | local bTeam = role:getTeamFormatByType(TeamSystemType.BonusBattle) |
616 | - local herosInfo = role:getTeamHerosInfo(bTeam.heros) | 621 | + local herosInfo = role:getTeamHerosInfo(bTeam).heros |
617 | 622 | ||
618 | local check = {} | 623 | local check = {} |
619 | -- 1 通关 | 624 | -- 1 通关 |
@@ -632,7 +637,7 @@ function _M.endBonusBattleRpc(agent, data) | @@ -632,7 +637,7 @@ function _M.endBonusBattleRpc(agent, data) | ||
632 | check[4] = function(_, cond) | 637 | check[4] = function(_, cond) |
633 | local count = 0 | 638 | local count = 0 |
634 | for _, one in pairs(herosInfo) do | 639 | for _, one in pairs(herosInfo) do |
635 | - local heroData = csv["unitCsv"][one.type] | 640 | + local heroData = csvdb["unitCsv"][one.type] |
636 | if heroData.camp == cond then | 641 | if heroData.camp == cond then |
637 | count = count + 1 | 642 | count = count + 1 |
638 | end | 643 | end |
@@ -643,7 +648,7 @@ function _M.endBonusBattleRpc(agent, data) | @@ -643,7 +648,7 @@ function _M.endBonusBattleRpc(agent, data) | ||
643 | check[5] = function(_, cond) | 648 | check[5] = function(_, cond) |
644 | local count = 0 | 649 | local count = 0 |
645 | for _, one in pairs(herosInfo) do | 650 | for _, one in pairs(herosInfo) do |
646 | - local heroData = csv["unitCsv"][one.type] | 651 | + local heroData = csvdb["unitCsv"][one.type] |
647 | if heroData.job == cond then | 652 | if heroData.job == cond then |
648 | count = count + 1 | 653 | count = count + 1 |
649 | end | 654 | end |
@@ -671,12 +676,23 @@ function _M.endBonusBattleRpc(agent, data) | @@ -671,12 +676,23 @@ function _M.endBonusBattleRpc(agent, data) | ||
671 | end | 676 | end |
672 | end | 677 | end |
673 | local status | 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 | else | 692 | else |
677 | - curStar = 0 | 693 | + curStar = oldStar |
678 | end | 694 | end |
679 | - if curStar ~= bonusStar[id] then | 695 | + if curStar ~= oldStar then |
680 | bonusStar[id] = curStar | 696 | bonusStar[id] = curStar |
681 | role:updateProperty({field = "bonusStar", value = bonusStar}) | 697 | role:updateProperty({field = "bonusStar", value = bonusStar}) |
682 | end | 698 | end |
src/actions/HeroAction.lua
@@ -146,7 +146,9 @@ function _M.talentRpc(agent, data) | @@ -146,7 +146,9 @@ function _M.talentRpc(agent, data) | ||
146 | local talent = hero:getProperty("talent") | 146 | local talent = hero:getProperty("talent") |
147 | local heroCfgId = hero:getProperty("type") | 147 | local heroCfgId = hero:getProperty("type") |
148 | local curStage = talent:getv(0, 1) | 148 | local curStage = talent:getv(0, 1) |
149 | + local oldStage = curStage | ||
149 | local curLevel = talent:getv(1, 1) | 150 | local curLevel = talent:getv(1, 1) |
151 | + local oldLevel = curLevel | ||
150 | local curData = csvdb["unit_talent_"..heroCfgId.."Csv"][curStage] | 152 | local curData = csvdb["unit_talent_"..heroCfgId.."Csv"][curStage] |
151 | if not curData then return 1 end | 153 | if not curData then return 1 end |
152 | local oldSkillLv = hero:getSkillLevel(1) | 154 | local oldSkillLv = hero:getSkillLevel(1) |
@@ -174,13 +176,16 @@ function _M.talentRpc(agent, data) | @@ -174,13 +176,16 @@ function _M.talentRpc(agent, data) | ||
174 | 176 | ||
175 | hero:updateProperty({field = "talent", value = talent}) | 177 | hero:updateProperty({field = "talent", value = talent}) |
176 | 178 | ||
179 | + | ||
177 | role:log("hero_talent", { | 180 | role:log("hero_talent", { |
178 | hero_id = hero:getProperty("type"), --英雄ID | 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 | hero:mylog({desc = "talent", int1 = talent:getv(0, 1), int2 = talent:getv(1, 1)}) | 189 | hero:mylog({desc = "talent", int1 = talent:getv(0, 1), int2 = talent:getv(1, 1)}) |
185 | 190 | ||
186 | SendPacket(actionCodes.Hero_talentRpc, '') | 191 | SendPacket(actionCodes.Hero_talentRpc, '') |
@@ -447,7 +452,6 @@ function _M.referEquipsRpc(agent, data) | @@ -447,7 +452,6 @@ function _M.referEquipsRpc(agent, data) | ||
447 | end | 452 | end |
448 | end | 453 | end |
449 | 454 | ||
450 | - local oldAttr = hero:getTotalAttrs() | ||
451 | local oldBattleV = hero:getProperty("battleV") | 455 | local oldBattleV = hero:getProperty("battleV") |
452 | local wear = {} | 456 | local wear = {} |
453 | 457 | ||
@@ -477,18 +481,14 @@ function _M.referEquipsRpc(agent, data) | @@ -477,18 +481,14 @@ function _M.referEquipsRpc(agent, data) | ||
477 | -- 更新角色 | 481 | -- 更新角色 |
478 | hero:updateProperty({field = "equip", value = curEquip}) | 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 | for typ, data in pairs(wear) do | 484 | for typ, data in pairs(wear) do |
485 | role:log("equip_wear", { | 485 | role:log("equip_wear", { |
486 | hero_id = hero:getProperty("type"), --英雄ID | 486 | hero_id = hero:getProperty("type"), --英雄ID |
487 | equip_id = data.id, --装备ID | 487 | equip_id = data.id, --装备ID |
488 | equip_wear_action = data.act, --装备操作类型:装备:0,卸载:1 | 488 | equip_wear_action = data.act, --装备操作类型:装备:0,卸载:1 |
489 | equip_wear_part = typ, --装备部位,记录部位ID | 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 | equip_wear_mode = isAuto and 0 or 1, --用以区分自动装备还是手动装备,自动记录为0,手动记录为1 | 492 | equip_wear_mode = isAuto and 0 or 1, --用以区分自动装备还是手动装备,自动记录为0,手动记录为1 |
493 | }) | 493 | }) |
494 | end | 494 | end |
@@ -585,16 +585,16 @@ function _M.createHeroRandomRpc(agent, data) | @@ -585,16 +585,16 @@ function _M.createHeroRandomRpc(agent, data) | ||
585 | local itemData = csvdb["itemCsv"][itemId] | 585 | local itemData = csvdb["itemCsv"][itemId] |
586 | if not itemData or itemData.type ~= ItemType.HeroFCommon then return end | 586 | if not itemData or itemData.type ~= ItemType.HeroFCommon then return end |
587 | local cost = globalCsv.unit_fragment_cost[itemData.quality] | 587 | local cost = globalCsv.unit_fragment_cost[itemData.quality] |
588 | - if not cost or role:getItemCount(itemId) < cost then return end | 588 | + if not cost or role:getItemCount(itemId) < cost then return 1 end |
589 | 589 | ||
590 | local randomData = csvdb["item_randomCsv"][tonumber(itemData.use_effect)] | 590 | local randomData = csvdb["item_randomCsv"][tonumber(itemData.use_effect)] |
591 | - if not randomData then return end | 591 | + if not randomData then return 2 end |
592 | 592 | ||
593 | local temp = randomData.gift1:randWeight(true) | 593 | local temp = randomData.gift1:randWeight(true) |
594 | - if not temp or not next(temp) then return end | 594 | + if not temp or not next(temp) then return 3 end |
595 | 595 | ||
596 | role:costItems({[itemId] = cost}, {log = {desc = "createHeroRandom"}}) | 596 | role:costItems({[itemId] = cost}, {log = {desc = "createHeroRandom"}}) |
597 | - local reward, change = role:award({[temp[1] + ItemStartId.Hero] = 1}, {log = {desc = "createHeroRandom"}}) | 597 | + local reward, change = role:award({[temp[1]] = 1}, {log = {desc = "createHeroRandom"}}) |
598 | 598 | ||
599 | 599 | ||
600 | SendPacket(actionCodes.Hero_createHeroRandomRpc, MsgPack.pack(role:packReward(reward, change))) | 600 | SendPacket(actionCodes.Hero_createHeroRandomRpc, MsgPack.pack(role:packReward(reward, change))) |
@@ -604,7 +604,6 @@ end | @@ -604,7 +604,6 @@ end | ||
604 | function _M.getResetRewardRpc(agent, data) | 604 | function _M.getResetRewardRpc(agent, data) |
605 | local role = agent.role | 605 | local role = agent.role |
606 | local msg = MsgPack.unpack(data) | 606 | local msg = MsgPack.unpack(data) |
607 | - local pay = msg.pay | ||
608 | 607 | ||
609 | local hero = role.heros[msg.id] | 608 | local hero = role.heros[msg.id] |
610 | if not hero then return end | 609 | if not hero then return end |
@@ -617,12 +616,30 @@ function _M.getResetRewardRpc(agent, data) | @@ -617,12 +616,30 @@ function _M.getResetRewardRpc(agent, data) | ||
617 | local tmpLevel = level | 616 | local tmpLevel = level |
618 | if level <= 1 and talent == "" then return end | 617 | if level <= 1 and talent == "" then return end |
619 | 618 | ||
619 | + local pay = true | ||
620 | if level <= 60 then | 620 | if level <= 60 then |
621 | pay = false | 621 | pay = false |
622 | end | 622 | end |
623 | 623 | ||
624 | - if pay and not role:costDiamond({count = globalCsv.unit_heroBack_cost or 200, log = {desc = "resetHero", int1 = msg.id}}) then | ||
625 | - return 1 | 624 | + if pay then |
625 | + local costArr = globalCsv.unit_heroBack_cost:toArray(true, "=") | ||
626 | + local itemCount = role:getItemCount(costArr[1]) | ||
627 | + local totalCost = {} | ||
628 | + if itemCount >= costArr[2] then | ||
629 | + totalCost[costArr[1]] = costArr[2] | ||
630 | + else | ||
631 | + local diamond = (costArr[2] - itemCount) * costArr[3] | ||
632 | + if role:getItemCount(ItemId.Diamond) < diamond then | ||
633 | + return 1 | ||
634 | + end | ||
635 | + totalCost[costArr[1]] = itemCount | ||
636 | + totalCost[ItemId.Diamond] = diamond | ||
637 | + end | ||
638 | + | ||
639 | + --if pay and not role:costDiamond({count = globalCsv.unit_heroBack_cost or 200, log = {desc = "resetHero", int1 = msg.id}}) then | ||
640 | + -- return 1 | ||
641 | + --end | ||
642 | + role:costItems(totalCost, {log = {desc = "resetHero", int1 = msg.id}}) | ||
626 | end | 643 | end |
627 | 644 | ||
628 | local reward = {} | 645 | local reward = {} |
@@ -677,10 +694,10 @@ function _M.getResetRewardRpc(agent, data) | @@ -677,10 +694,10 @@ function _M.getResetRewardRpc(agent, data) | ||
677 | }) | 694 | }) |
678 | hero:mylog({desc = "resetHero"}) | 695 | hero:mylog({desc = "resetHero"}) |
679 | 696 | ||
680 | - local coef = globalCsv.unit_back_discount | ||
681 | - coef = (pay or tmpLevel <= 60) and 1 or coef | 697 | + --local coef = globalCsv.unit_back_discount |
698 | + --coef = (pay or tmpLevel <= 60) and 1 or coef | ||
682 | for itemId, count in pairs(reward) do | 699 | for itemId, count in pairs(reward) do |
683 | - reward[itemId] = math.floor(count * coef) | 700 | + reward[itemId] = count |
684 | end | 701 | end |
685 | local change | 702 | local change |
686 | reward, change = role:award(reward, {log = {desc = "resetHero", int1 = msg.id, int2 = hero:getProperty("type")}}) | 703 | reward, change = role:award(reward, {log = {desc = "resetHero", int1 = msg.id, int2 = hero:getProperty("type")}}) |
@@ -697,13 +714,26 @@ end | @@ -697,13 +714,26 @@ end | ||
697 | function _M.drawHeroRpc(agent, data) | 714 | function _M.drawHeroRpc(agent, data) |
698 | local role = agent.role | 715 | local role = agent.role |
699 | local msg = MsgPack.unpack(data) | 716 | local msg = MsgPack.unpack(data) |
717 | + local actid = msg.actid | ||
700 | 718 | ||
701 | if not role:isFuncUnlock(FuncUnlock.GetHero) then return 1 end | 719 | if not role:isFuncUnlock(FuncUnlock.GetHero) then return 1 end |
702 | - local btype = msg.pool -- 1 2 3 卡池类型 | 720 | + local btype = msg.pool -- 1 2 3 4 5 卡池类型 4新手卡池 5心愿卡池 |
703 | local subType = msg.subType or 1-- 定向卡池需要传 子类型 | 721 | local subType = msg.subType or 1-- 定向卡池需要传 子类型 |
704 | local drawType = msg.type -- 1 单抽 2 十连 | 722 | local drawType = msg.type -- 1 单抽 2 十连 |
705 | if btype ~= 1 then | 723 | if btype ~= 1 then |
706 | subType = 1 | 724 | subType = 1 |
725 | + if btype == 4 and role:getProperty("newerDraw") >= 10 then | ||
726 | + subType = 2 | ||
727 | + end | ||
728 | + end | ||
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 | ||
707 | end | 737 | end |
708 | 738 | ||
709 | if btype == 1 then | 739 | if btype == 1 then |
@@ -711,6 +741,18 @@ function _M.drawHeroRpc(agent, data) | @@ -711,6 +741,18 @@ function _M.drawHeroRpc(agent, data) | ||
711 | if not role.activity:isOpen("RaceDraw") then | 741 | if not role.activity:isOpen("RaceDraw") then |
712 | return | 742 | return |
713 | end | 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 | ||
714 | end | 756 | end |
715 | 757 | ||
716 | local buildTypeData = csvdb["build_typeCsv"][btype] | 758 | local buildTypeData = csvdb["build_typeCsv"][btype] |
@@ -724,23 +766,32 @@ function _M.drawHeroRpc(agent, data) | @@ -724,23 +766,32 @@ function _M.drawHeroRpc(agent, data) | ||
724 | 766 | ||
725 | -- 计算抽卡消耗品 | 767 | -- 计算抽卡消耗品 |
726 | local cost = {} | 768 | local cost = {} |
727 | - local lastCount = drawCount[drawType] | ||
728 | - for _, costType in ipairs({"draw_card", "draw_coin"}) do | 769 | + if buildTypeData["draw_coin_1"] == "" then |
770 | + return 11 | ||
771 | + end | ||
772 | + local diamondCost = buildTypeData["draw_coin_1"]:toArray(true, "=") | ||
773 | + | ||
774 | + local isEnough = true | ||
775 | + for _, costType in ipairs({"draw_card_"}) do | ||
776 | + costType = costType..drawCount[drawType] | ||
729 | if buildTypeData[costType] ~= "" then | 777 | if buildTypeData[costType] ~= "" then |
730 | local curCost = buildTypeData[costType]:toArray(true, "=") | 778 | local curCost = buildTypeData[costType]:toArray(true, "=") |
731 | local hadCount = role:getItemCount(curCost[1]) | 779 | local hadCount = role:getItemCount(curCost[1]) |
732 | - local curCount = math.floor(hadCount / curCost[2]) | ||
733 | - if curCount >= lastCount then | ||
734 | - cost[curCost[1]] = curCost[2] * lastCount | ||
735 | - lastCount = 0 | 780 | + if hadCount >= curCost[2] then |
781 | + cost[curCost[1]] = curCost[2] | ||
736 | break | 782 | break |
737 | - elseif curCount > 0 then | ||
738 | - cost[curCost[1]] = curCost[2] * curCount | ||
739 | - lastCount = lastCount - curCount | 783 | + else |
784 | + cost[curCost[1]] = hadCount | ||
785 | + diamondCost[2] = (curCost[2] - hadCount) * diamondCost[2] | ||
786 | + if not role:checkItemEnough({[diamondCost[1]]=diamondCost[2]}) then | ||
787 | + isEnough = false | ||
788 | + break | ||
789 | + end | ||
790 | + cost[diamondCost[1]] = diamondCost[2] | ||
740 | end | 791 | end |
741 | end | 792 | end |
742 | end | 793 | end |
743 | - if lastCount > 0 then -- 钱不够 | 794 | + if isEnough == false then -- 钱不够 |
744 | return 4 | 795 | return 4 |
745 | end | 796 | end |
746 | 797 | ||
@@ -803,6 +854,9 @@ function _M.drawHeroRpc(agent, data) | @@ -803,6 +854,9 @@ function _M.drawHeroRpc(agent, data) | ||
803 | --print(poolId, rand_v, weight, up_pool, values[1]) | 854 | --print(poolId, rand_v, weight, up_pool, values[1]) |
804 | if rand_v < weight and up_pool then | 855 | if rand_v < weight and up_pool then |
805 | up_pool = up_pool:toArray(true, "=") | 856 | up_pool = up_pool:toArray(true, "=") |
857 | + if btype == 5 then -- 爱心卡池,使用玩家设置的备选池子 | ||
858 | + up_pool = role:getProperty("wishPool") | ||
859 | + end | ||
806 | for k, v in ipairs(up_pool) do | 860 | for k, v in ipairs(up_pool) do |
807 | resultPool[v] = {1} | 861 | resultPool[v] = {1} |
808 | end | 862 | end |
@@ -868,8 +922,14 @@ function _M.drawHeroRpc(agent, data) | @@ -868,8 +922,14 @@ function _M.drawHeroRpc(agent, data) | ||
868 | end | 922 | end |
869 | end | 923 | end |
870 | 924 | ||
871 | - if itemData.quality >= HeroQuality.SR then | ||
872 | - floorHeroCount = 0 | 925 | + if btype == 4 and role:getProperty("newerDraw") == 0 then -- 新手卡池 |
926 | + if itemData.quality == HeroQuality.SSR then | ||
927 | + floorHeroCount = 0 | ||
928 | + end | ||
929 | + else | ||
930 | + if itemData.quality >= HeroQuality.SR then | ||
931 | + floorHeroCount = 0 | ||
932 | + end | ||
873 | end | 933 | end |
874 | 934 | ||
875 | if role:isHaveHero(itemData.id - ItemStartId.Hero) then | 935 | if role:isHaveHero(itemData.id - ItemStartId.Hero) then |
@@ -892,6 +952,11 @@ function _M.drawHeroRpc(agent, data) | @@ -892,6 +952,11 @@ function _M.drawHeroRpc(agent, data) | ||
892 | role:setProperty("floorHero", floorHero) | 952 | role:setProperty("floorHero", floorHero) |
893 | end | 953 | end |
894 | 954 | ||
955 | + if btype == 4 then | ||
956 | + local newCount = role:getProperty("newerDraw") | ||
957 | + role:updateProperty({field="newerDraw", value = newCount + drawCount[drawType]}) | ||
958 | + end | ||
959 | + | ||
895 | role:checkTaskEnter("DrawHero", {pool = btype, count = drawCount[drawType]}) | 960 | role:checkTaskEnter("DrawHero", {pool = btype, count = drawCount[drawType]}) |
896 | if ssrCount > 0 then | 961 | if ssrCount > 0 then |
897 | role:checkTaskEnter("DrawSSR", {count = ssrCount}) | 962 | role:checkTaskEnter("DrawSSR", {count = ssrCount}) |
@@ -904,16 +969,21 @@ function _M.drawHeroRpc(agent, data) | @@ -904,16 +969,21 @@ function _M.drawHeroRpc(agent, data) | ||
904 | gacha_up = 0, -- 卡池UP角色 | 969 | gacha_up = 0, -- 卡池UP角色 |
905 | gacha_times = drawCount[drawType], -- 抽卡次数 | 970 | gacha_times = drawCount[drawType], -- 抽卡次数 |
906 | gacha_reward = logReward, -- 抽卡结果,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"} | 971 | gacha_reward = logReward, -- 抽卡结果,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"} |
907 | - currency = cost, -- 购买道具消耗的货币 | 972 | + gacha_cost = cost, -- 购买道具消耗的货币 |
908 | gacha_cnt = floorHeroCount, | 973 | gacha_cnt = floorHeroCount, |
909 | }) | 974 | }) |
910 | SendPacket(actionCodes.Hero_drawHeroRpc, MsgPack.pack({reward = reward})) -- 这个 reward 是数组 | 975 | SendPacket(actionCodes.Hero_drawHeroRpc, MsgPack.pack({reward = reward})) -- 这个 reward 是数组 |
911 | 976 | ||
912 | - if btype == 1 or btype == 2 then | 977 | + local feedbackId = buildTypeData["can_feedback"] or 0 |
978 | + if feedbackId ~= 0 then | ||
913 | -- 达到一定次数,给响应奖励 | 979 | -- 达到一定次数,给响应奖励 |
914 | local oldVal = role:getProperty("repayHero") or 0 | 980 | local oldVal = role:getProperty("repayHero") or 0 |
981 | + if actid then | ||
982 | + local actData = role.activity:getActData("ActHeroPool") | ||
983 | + oldVal = actData[btype] or 0 | ||
984 | + end | ||
915 | local newVal = oldVal + drawCount[drawType] | 985 | local newVal = oldVal + drawCount[drawType] |
916 | - local drawCardReward, val = role:getDrawCardExtraReward(oldVal, newVal) | 986 | + local drawCardReward, val = role:getDrawCardExtraReward(feedbackId, oldVal, newVal) |
917 | -- 空字符穿代表直接给英雄 走以前repayHeroRpc | 987 | -- 空字符穿代表直接给英雄 走以前repayHeroRpc |
918 | if drawCardReward == "" then | 988 | if drawCardReward == "" then |
919 | local repayHeroMaxCount = role:getProperty("repayMaxC") or 0 | 989 | local repayHeroMaxCount = role:getProperty("repayMaxC") or 0 |
@@ -927,7 +997,7 @@ function _M.drawHeroRpc(agent, data) | @@ -927,7 +997,7 @@ function _M.drawHeroRpc(agent, data) | ||
927 | else | 997 | else |
928 | local giftHeroSet = {} | 998 | local giftHeroSet = {} |
929 | for gid, cfg in pairs(csvdb["build_giftCsv"]) do | 999 | for gid, cfg in pairs(csvdb["build_giftCsv"]) do |
930 | - if cfg["pool_1"] ~= 0 and not role:isHaveHero(gid - ItemStartId.Hero) then | 1000 | + if cfg["pool_"..feedbackId] ~= 0 and not role:isHaveHero(gid - ItemStartId.Hero) then |
931 | giftHeroSet[gid] = {1} | 1001 | giftHeroSet[gid] = {1} |
932 | end | 1002 | end |
933 | end | 1003 | end |
@@ -956,7 +1026,13 @@ function _M.drawHeroRpc(agent, data) | @@ -956,7 +1026,13 @@ function _M.drawHeroRpc(agent, data) | ||
956 | r, change = role:award(drawCardReward, {log = {desc = "drawHeroExtraReward", int1 = oldVal, int2 = newVal}}) | 1026 | r, change = role:award(drawCardReward, {log = {desc = "drawHeroExtraReward", int1 = oldVal, int2 = newVal}}) |
957 | SendPacket(actionCodes.Hero_drawHeroExtraRewardNtf, MsgPack.pack(role:packReward(r, change))) | 1027 | SendPacket(actionCodes.Hero_drawHeroExtraRewardNtf, MsgPack.pack(role:packReward(r, change))) |
958 | end | 1028 | end |
959 | - role:updateProperty({field = "repayHero", value = val}) | 1029 | + if not actid then |
1030 | + role:updateProperty({field = "repayHero", value = val}) | ||
1031 | + else | ||
1032 | + local actData = role.activity:getActData("ActHeroPool") | ||
1033 | + actData[btype] = val | ||
1034 | + role.activity:updateActData("ActHeroPool", actData) | ||
1035 | + end | ||
960 | end | 1036 | end |
961 | return true | 1037 | return true |
962 | end | 1038 | end |
@@ -1049,6 +1125,9 @@ function _M.itemComposeRpc(agent, data) | @@ -1049,6 +1125,9 @@ function _M.itemComposeRpc(agent, data) | ||
1049 | if not config then return 2 end | 1125 | if not config then return 2 end |
1050 | 1126 | ||
1051 | local cost = config.cost:toNumMap() | 1127 | local cost = config.cost:toNumMap() |
1128 | + for k, v in pairs(cost) do | ||
1129 | + cost[k] = v * count | ||
1130 | + end | ||
1052 | if not role:checkItemEnough(cost) then return 2 end | 1131 | if not role:checkItemEnough(cost) then return 2 end |
1053 | role:costItems(cost, {log = {desc = "itemCompose", int1 = itemId, int2 = count}}) | 1132 | role:costItems(cost, {log = {desc = "itemCompose", int1 = itemId, int2 = count}}) |
1054 | role:award({[itemId] = count}, {log = {desc = "itemCompose"}}) | 1133 | role:award({[itemId] = count}, {log = {desc = "itemCompose"}}) |
@@ -1057,4 +1136,32 @@ function _M.itemComposeRpc(agent, data) | @@ -1057,4 +1136,32 @@ function _M.itemComposeRpc(agent, data) | ||
1057 | return true | 1136 | return true |
1058 | end | 1137 | end |
1059 | 1138 | ||
1139 | +function _M.setWishPoolRpc(agent, data) | ||
1140 | + local role = agent.role | ||
1141 | + local msg = MsgPack.unpack(data) | ||
1142 | + | ||
1143 | + local heros = msg.heros | ||
1144 | + if #heros > 3 then return 1 end | ||
1145 | + | ||
1146 | + for _, heroId in pairs(heros) do | ||
1147 | + local cfg = csvdb["build_poolCsv"][heroId] | ||
1148 | + if not cfg then return 2 end | ||
1149 | + | ||
1150 | + local buildTypeData = csvdb["build_typeCsv"][5] | ||
1151 | + if not buildTypeData then return 3 end | ||
1152 | + local poolMap = buildTypeData["pool"]:toNumMap() | ||
1153 | + local poolId = poolMap[1] | ||
1154 | + if not poolId then return 4 end | ||
1155 | + | ||
1156 | + if cfg["pool_"..poolId] == 0 then | ||
1157 | + return 5 | ||
1158 | + end | ||
1159 | + end | ||
1160 | + | ||
1161 | + role:updateProperty({field="wishPool", value = heros}) | ||
1162 | + | ||
1163 | + SendPacket(actionCodes.Hero_setWishPoolRpc, "") | ||
1164 | + return true | ||
1165 | +end | ||
1166 | + | ||
1060 | return _M | 1167 | return _M |
src/actions/HttpAction.lua
@@ -187,6 +187,9 @@ function _M.online(query) | @@ -187,6 +187,9 @@ function _M.online(query) | ||
187 | return count | 187 | return count |
188 | end | 188 | end |
189 | 189 | ||
190 | +function _M.dbqlen(query) | ||
191 | + return skynet.call(redisd, "debug", "INFO") | ||
192 | +end | ||
190 | 193 | ||
191 | function _M.account_init(query, body) | 194 | function _M.account_init(query, body) |
192 | if not query.id or not body or body == "" then return "指令不存在" end | 195 | if not query.id or not body or body == "" then return "指令不存在" end |
src/actions/PvpAction.lua
@@ -23,6 +23,7 @@ local _revengeRecord = {} -- 复仇对单人1分钟间隔 | @@ -23,6 +23,7 @@ local _revengeRecord = {} -- 复仇对单人1分钟间隔 | ||
23 | local RevengeWaitTime = 60 | 23 | local RevengeWaitTime = 60 |
24 | 24 | ||
25 | function _M.formatCommonRpc(agent , data) | 25 | function _M.formatCommonRpc(agent , data) |
26 | + if true then return end | ||
26 | local role = agent.role | 27 | local role = agent.role |
27 | local roleId = role:getProperty("id") | 28 | local roleId = role:getProperty("id") |
28 | local msg = MsgPack.unpack(data) | 29 | local msg = MsgPack.unpack(data) |
@@ -63,7 +64,8 @@ function _M.formatHighRpc(agent , data) | @@ -63,7 +64,8 @@ function _M.formatHighRpc(agent , data) | ||
63 | local role = agent.role | 64 | local role = agent.role |
64 | local roleId = role:getProperty("id") | 65 | local roleId = role:getProperty("id") |
65 | local msg = MsgPack.unpack(data) | 66 | local msg = MsgPack.unpack(data) |
66 | - | 67 | + |
68 | + if not role:isCrossServerPvpPlayer() then return end | ||
67 | local pvpTH = {} | 69 | local pvpTH = {} |
68 | local had = {} -- 上阵的角色 | 70 | local had = {} -- 上阵的角色 |
69 | local supportHad = {} | 71 | local supportHad = {} |
@@ -133,7 +135,7 @@ local function getMatchInfo(role, pvpList, battleCache, dbKey, infoFuncName, inf | @@ -133,7 +135,7 @@ local function getMatchInfo(role, pvpList, battleCache, dbKey, infoFuncName, inf | ||
133 | if k == "battleInfo" then | 135 | if k == "battleInfo" then |
134 | battleCache[curInfo.roleId] = v | 136 | battleCache[curInfo.roleId] = v |
135 | else | 137 | else |
136 | - if (k == "heros" or k == "battleV") and infoCache then | 138 | + if (k == "team" or k == "battleV") and infoCache then |
137 | infoCache[curInfo.roleId] = infoCache[curInfo.roleId] or {} | 139 | infoCache[curInfo.roleId] = infoCache[curInfo.roleId] or {} |
138 | infoCache[curInfo.roleId][k] = v | 140 | infoCache[curInfo.roleId][k] = v |
139 | end | 141 | end |
@@ -169,7 +171,7 @@ function _M.infoRpc(agent, data) | @@ -169,7 +171,7 @@ function _M.infoRpc(agent, data) | ||
169 | 171 | ||
170 | local pvpMC = role:getProperty("pvpMC") | 172 | local pvpMC = role:getProperty("pvpMC") |
171 | if not next(pvpMC) then --没有分配过对手 | 173 | if not next(pvpMC) then --没有分配过对手 |
172 | - role:refreshPvpMatchC(score) | 174 | + role:refreshPvpMatchC(score, -1) |
173 | pvpMC = role:getProperty("pvpMC") | 175 | pvpMC = role:getProperty("pvpMC") |
174 | end | 176 | end |
175 | if not next(pvpMC) then return end | 177 | if not next(pvpMC) then return end |
@@ -189,7 +191,7 @@ function _M.infoRpc(agent, data) | @@ -189,7 +191,7 @@ function _M.infoRpc(agent, data) | ||
189 | 191 | ||
190 | local pvpMH = role:getProperty("pvpMH") | 192 | local pvpMH = role:getProperty("pvpMH") |
191 | if not next(pvpMH) then --没有分配过对手 | 193 | if not next(pvpMH) then --没有分配过对手 |
192 | - role:refreshPvpMatchH(score) | 194 | + role:refreshPvpMatchH(score, -1) |
193 | pvpMH = role:getProperty("pvpMH") | 195 | pvpMH = role:getProperty("pvpMH") |
194 | end | 196 | end |
195 | if not next(pvpMH) then return end | 197 | if not next(pvpMH) then return end |
@@ -255,8 +257,38 @@ function _M.startBattleRpc(agent, data) | @@ -255,8 +257,38 @@ function _M.startBattleRpc(agent, data) | ||
255 | local idx = msg.idx | 257 | local idx = msg.idx |
256 | local revenge = msg.revenge | 258 | local revenge = msg.revenge |
257 | 259 | ||
258 | - local pvpTC = role:getProperty("pvpTC") | ||
259 | - if not pvpTC.heros or not next(pvpTC.heros) then return 1 end | 260 | + -- local pvpTC = role:getProperty("pvpTC") |
261 | + -- if not pvpTC.heros or not next(pvpTC.heros) then return 1 end | ||
262 | + | ||
263 | + local team = msg.team | ||
264 | + if not team then return end | ||
265 | + | ||
266 | + for slot, heroId in pairs(team.heros or {}) do | ||
267 | + if not role.heros[heroId] then | ||
268 | + return | ||
269 | + end | ||
270 | + end | ||
271 | + if not team.heros or not next(team.heros) then | ||
272 | + return | ||
273 | + end | ||
274 | + local supports = {} | ||
275 | + for slot, support in pairs(team.supports) do | ||
276 | + if slot ~= 1 and slot ~= 2 then return end | ||
277 | + local level = role.dinerData:getProperty("dishTree"):getv(support, 0) | ||
278 | + if level <= 0 then return end | ||
279 | + supports[slot] = support | ||
280 | + end | ||
281 | + | ||
282 | + local pvpTC = {} | ||
283 | + pvpTC.heros = {} | ||
284 | + for slot, heroId in pairs(team.heros) do | ||
285 | + pvpTC.heros[slot] = heroId | ||
286 | + end | ||
287 | + pvpTC.leader = team.leader | ||
288 | + pvpTC.supports = supports | ||
289 | + if team.tactics and globalCsv.tactics_skill_passive_cell[team.tactics] then | ||
290 | + pvpTC.tactics = team.tactics | ||
291 | + end | ||
260 | 292 | ||
261 | local matchInfo, result, key, wait | 293 | local matchInfo, result, key, wait |
262 | 294 | ||
@@ -299,7 +331,7 @@ function _M.startBattleRpc(agent, data) | @@ -299,7 +331,7 @@ function _M.startBattleRpc(agent, data) | ||
299 | end | 331 | end |
300 | 332 | ||
301 | key = tostring(math.random()) | 333 | key = tostring(math.random()) |
302 | - _pvpStartBattleCacheC = {idx = idx, key = key, revenge = revenge} | 334 | + _pvpStartBattleCacheC = {idx = idx, key = key, revenge = revenge, pvpTC = pvpTC} |
303 | 335 | ||
304 | role:checkTaskEnter("PvpBattle") | 336 | role:checkTaskEnter("PvpBattle") |
305 | 337 | ||
@@ -342,7 +374,15 @@ function _M.endBattleRpc(agent, data) | @@ -342,7 +374,15 @@ function _M.endBattleRpc(agent, data) | ||
342 | 374 | ||
343 | local temp = string.randWeight(csvdb["player_expCsv"][role:getProperty("level")].pvpBonus, true) | 375 | local temp = string.randWeight(csvdb["player_expCsv"][role:getProperty("level")].pvpBonus, true) |
344 | local reward, change = role:award({[temp[1]] = temp[2]}, {log = {desc = "pvpBattleC"}}) | 376 | local reward, change = role:award({[temp[1]] = temp[2]}, {log = {desc = "pvpBattleC"}}) |
345 | - local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = role:changePvpScoreCommon(match.t == 1 and match.id or -1, isWin) | 377 | + local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = 0, 0, 0, 0, -1, -1 |
378 | + -- 失败了没再排行榜 不计入 | ||
379 | + if isWin or (not isWin and role:isInPvpRank(RANK_PVP_COMMON)) then | ||
380 | + myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank= role:changePvpScoreCommon(match.t == 1 and match.id or -1, isWin) | ||
381 | + end | ||
382 | + if isWin then | ||
383 | + -- 记录编队 | ||
384 | + role:savePvpCTeam(_pvpStartBattleCacheC.pvpTC) | ||
385 | + end | ||
346 | 386 | ||
347 | -- 请求上传录像 | 387 | -- 请求上传录像 |
348 | local params = { | 388 | local params = { |
@@ -433,8 +473,8 @@ function _M.startBattleHRpc(agent, data) | @@ -433,8 +473,8 @@ function _M.startBattleHRpc(agent, data) | ||
433 | local revenge = msg.revenge | 473 | local revenge = msg.revenge |
434 | if not role:isTimeResetOpen(TimeReset.PvpHight) then return end | 474 | if not role:isTimeResetOpen(TimeReset.PvpHight) then return end |
435 | 475 | ||
436 | - local pvpTH = role:getProperty("pvpTH") | ||
437 | - if not next(pvpTH) then return 1 end | 476 | + -- local pvpTH = role:getProperty("pvpTH") |
477 | + -- if not next(pvpTH) then return 1 end | ||
438 | 478 | ||
439 | -- 检查并记录玩家队伍 | 479 | -- 检查并记录玩家队伍 |
440 | local pvpTH = {} | 480 | local pvpTH = {} |
@@ -472,7 +512,6 @@ function _M.startBattleHRpc(agent, data) | @@ -472,7 +512,6 @@ function _M.startBattleHRpc(agent, data) | ||
472 | curTeam.tactics = team.tactics | 512 | curTeam.tactics = team.tactics |
473 | end | 513 | end |
474 | 514 | ||
475 | - | ||
476 | table.insert(pvpTH, curTeam) | 515 | table.insert(pvpTH, curTeam) |
477 | end | 516 | end |
478 | 517 | ||
@@ -644,9 +683,18 @@ function _M.endBattleHRpc(agent, data) | @@ -644,9 +683,18 @@ function _M.endBattleHRpc(agent, data) | ||
644 | -- 战斗结束了发奖 | 683 | -- 战斗结束了发奖 |
645 | local temp = string.randWeight(csvdb["player_expCsv"][role:getProperty("level")].pvpgroupBonus, true) | 684 | local temp = string.randWeight(csvdb["player_expCsv"][role:getProperty("level")].pvpgroupBonus, true) |
646 | local reward, change = role:award({[temp[1]] = temp[2]}, {log = {desc = "pvpBattleH"}}) | 685 | local reward, change = role:award({[temp[1]] = temp[2]}, {log = {desc = "pvpBattleH"}}) |
647 | - local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = 0, 0, 0, 0, 0, 0 | ||
648 | - if role:isTimeResetOpen(TimeReset.PvpHight) then | ||
649 | - myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = role:changePvpScoreHigh(match.t == 1 and match.id or -1, isWin) | 686 | + |
687 | + | ||
688 | + local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = 0, 0, 0, 0, -1, -1 | ||
689 | + -- 失败了没再排行榜 不计入 | ||
690 | + if role:isTimeResetOpen(TimeReset.PvpHight) then | ||
691 | + if isWin or (not isWin and role:isInPvpRank(RANK_PVP_HIGHT)) then | ||
692 | + myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = role:changePvpScoreHigh(match.t == 1 and match.id or -1, isWin) | ||
693 | + end | ||
694 | + -- 记录编队 | ||
695 | + if isWin then | ||
696 | + role:savePvpHTeam(_pvpStartBattleCacheH.pvpTH) | ||
697 | + end | ||
650 | end | 698 | end |
651 | 699 | ||
652 | -- 加入战斗记录 | 700 | -- 加入战斗记录 |
@@ -657,12 +705,12 @@ function _M.endBattleHRpc(agent, data) | @@ -657,12 +705,12 @@ function _M.endBattleHRpc(agent, data) | ||
657 | info.winId = info.isWin and roleId or match.id | 705 | info.winId = info.isWin and roleId or match.id |
658 | info.isWin = nil | 706 | info.isWin = nil |
659 | selfTeam[_idx] = { | 707 | selfTeam[_idx] = { |
660 | - heros = role:getTeamHerosInfo(_pvpStartBattleCacheH.pvpTH[_idx].heros), | 708 | + team = role:getTeamHerosInfo(_pvpStartBattleCacheH.pvpTH[_idx]), |
661 | battleV = role:getTeamBattleValue(_pvpStartBattleCacheH.pvpTH[_idx].heros) | 709 | battleV = role:getTeamBattleValue(_pvpStartBattleCacheH.pvpTH[_idx].heros) |
662 | } | 710 | } |
663 | if match.t == 1 and _pvpStartBattleCacheH.enemyT then | 711 | if match.t == 1 and _pvpStartBattleCacheH.enemyT then |
664 | enemyTeam[_idx] = { | 712 | enemyTeam[_idx] = { |
665 | - heros = _pvpStartBattleCacheH.enemyT["heros"][_idx], | 713 | + team = _pvpStartBattleCacheH.enemyT["team"][_idx], |
666 | battleV = _pvpStartBattleCacheH.enemyT["battleV"][_idx] | 714 | battleV = _pvpStartBattleCacheH.enemyT["battleV"][_idx] |
667 | } | 715 | } |
668 | end | 716 | end |
@@ -735,6 +783,7 @@ function _M.endBattleHRpc(agent, data) | @@ -735,6 +783,7 @@ function _M.endBattleHRpc(agent, data) | ||
735 | myRank = myRank, | 783 | myRank = myRank, |
736 | oldMyRank = oldMyRank, | 784 | oldMyRank = oldMyRank, |
737 | video = video, | 785 | video = video, |
786 | + headers = headers, | ||
738 | isWin = isWin, | 787 | isWin = isWin, |
739 | })) | 788 | })) |
740 | return true | 789 | return true |
src/actions/RadioAction.lua
@@ -69,7 +69,7 @@ function _M.startQuestRpc(agent, data) | @@ -69,7 +69,7 @@ function _M.startQuestRpc(agent, data) | ||
69 | needHeroCnt = it[2] | 69 | needHeroCnt = it[2] |
70 | end | 70 | end |
71 | end | 71 | end |
72 | - for _, heroId in ipairs(heros) do | 72 | + for _, heroId in pairs(heros) do |
73 | local hero = role.heros[heroId] | 73 | local hero = role.heros[heroId] |
74 | if hero then | 74 | if hero then |
75 | needHeroCnt = needHeroCnt - 1 | 75 | needHeroCnt = needHeroCnt - 1 |
@@ -122,7 +122,7 @@ function _M.finishQuestRpc(agent, data) | @@ -122,7 +122,7 @@ function _M.finishQuestRpc(agent, data) | ||
122 | -- get heros | 122 | -- get heros |
123 | local totalCoef = 0 | 123 | local totalCoef = 0 |
124 | local exp = config.time / 60 | 124 | local exp = config.time / 60 |
125 | - heroFaithMap = {} | 125 | + local heroFaithMap = {} |
126 | for _, heroId in ipairs(task.heros) do | 126 | for _, heroId in ipairs(task.heros) do |
127 | local hero = role.heros[heroId] | 127 | local hero = role.heros[heroId] |
128 | if hero then | 128 | if hero then |
@@ -158,8 +158,44 @@ function _M.finishQuestRpc(agent, data) | @@ -158,8 +158,44 @@ function _M.finishQuestRpc(agent, data) | ||
158 | msg["big"] = bigSuccess | 158 | msg["big"] = bigSuccess |
159 | msg["id"] = id | 159 | msg["id"] = id |
160 | msg["heroFaith"] = heroFaithMap | 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 | return true | 182 | return true |
163 | end | 183 | end |
164 | 184 | ||
185 | +function _M.cancelQuestRpc(agent, data) | ||
186 | + local role = agent.role | ||
187 | + local msg = MsgPack.unpack(data) | ||
188 | + local id = msg.id | ||
189 | + -- check finish time | ||
190 | + local radioTask = role:getProperty("radioTask") | ||
191 | + local task = radioTask[id] | ||
192 | + if not task then return 1 end | ||
193 | + if skynet.timex() > task.time then return 2 end | ||
194 | + radioTask[id] = nil | ||
195 | + role:updateProperty({field="radioTask", value=radioTask, notNotify = true}) | ||
196 | + | ||
197 | + SendPacket(actionCodes.Radio_cancelQuestRpc, MsgPack.pack({id = id})) | ||
198 | + return true | ||
199 | +end | ||
200 | + | ||
165 | return _M | 201 | return _M |
166 | \ No newline at end of file | 202 | \ No newline at end of file |
src/actions/RoleAction.lua
@@ -724,11 +724,12 @@ function _M.unLockStoryBookRpc(agent, data) | @@ -724,11 +724,12 @@ function _M.unLockStoryBookRpc(agent, data) | ||
724 | local storyStatus = role:getProperty("storyB") | 724 | local storyStatus = role:getProperty("storyB") |
725 | if storyStatus[storyId] and storyStatus[storyId].s then return end --不需要解锁 | 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 | storyStatus[storyId] = storyStatus[storyId] or {} | 735 | storyStatus[storyId] = storyStatus[storyId] or {} |
@@ -807,6 +808,12 @@ function _M.taskActiveRpc(agent, data) | @@ -807,6 +808,12 @@ function _M.taskActiveRpc(agent, data) | ||
807 | { type = roleField[taskType], field = {"at", taskId}, value = -1 } | 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 | SendPacket(actionCodes.Role_taskActiveRpc, MsgPack.pack(role:packReward(reward, change))) | 817 | SendPacket(actionCodes.Role_taskActiveRpc, MsgPack.pack(role:packReward(reward, change))) |
811 | return true | 818 | return true |
812 | end | 819 | end |
@@ -1279,4 +1286,16 @@ function _M.renameTeamRpc(agent, data) | @@ -1279,4 +1286,16 @@ function _M.renameTeamRpc(agent, data) | ||
1279 | return true | 1286 | return true |
1280 | end | 1287 | end |
1281 | 1288 | ||
1289 | +function _M.accuseRpc(agent, data) | ||
1290 | + local role = agent.role | ||
1291 | + local msg = MsgPack.unpack(data) | ||
1292 | + local targetId = msg.targetId | ||
1293 | + local atype = msg.type | ||
1294 | + local note = msg.note | ||
1295 | + | ||
1296 | + role:mylog("role_action", {desc = "accuse", int1 = targetId, short1 = atype, text1 = note}) | ||
1297 | + SendPacket(actionCodes.Role_accuseRpc, "") | ||
1298 | + return true | ||
1299 | +end | ||
1300 | + | ||
1282 | return _M | 1301 | return _M |
1283 | \ No newline at end of file | 1302 | \ No newline at end of file |
src/actions/StoreAction.lua
@@ -13,6 +13,9 @@ function _M.rechargeRpc(agent , data) | @@ -13,6 +13,9 @@ function _M.rechargeRpc(agent , data) | ||
13 | 13 | ||
14 | --创建订单号 | 14 | --创建订单号 |
15 | local partnerOrderId = role:getPurchaseOrder(id) | 15 | local partnerOrderId = role:getPurchaseOrder(id) |
16 | + if partnerOrderId == "" then | ||
17 | + return 1 | ||
18 | + end | ||
16 | SendPacket(actionCodes.Store_rechargeRpc, MsgPack.pack({ order = partnerOrderId })) | 19 | SendPacket(actionCodes.Store_rechargeRpc, MsgPack.pack({ order = partnerOrderId })) |
17 | 20 | ||
18 | 21 | ||
@@ -396,4 +399,30 @@ function _M.getExploreCommandRewardRpc(agent, data) | @@ -396,4 +399,30 @@ function _M.getExploreCommandRewardRpc(agent, data) | ||
396 | return true | 399 | return true |
397 | end | 400 | end |
398 | 401 | ||
402 | +-- 累充奖励 | ||
403 | +function _M.getTotalRechargeAwardRpc(agent, data) | ||
404 | + local role = agent.role | ||
405 | + local msg = MsgPack.unpack(data) | ||
406 | + local index = msg.index -- 领取的索引id | ||
407 | + local totalTwd = role:getProperty("twdC") | ||
408 | + local totalRechargeRecord = role.storeData:getProperty("totalRR") | ||
409 | + local flag = string.char(string.getbit(totalRechargeRecord, index)) | ||
410 | + if flag == "1" then return 1 end | ||
411 | + local cfg = csvdb["activity_payRebateCsv"][index] | ||
412 | + if not cfg then return 2 end | ||
413 | + if cfg.twd > totalTwd then return 3 end | ||
414 | + | ||
415 | + totalRechargeRecord = string.setbit(totalRechargeRecord, index) | ||
416 | + role.storeData:updateProperty({field = "totalRR", value = totalRechargeRecord}) | ||
417 | + local main = cfg.main_reward:toNumMap() | ||
418 | + local sub = cfg.sub_reward:toNumMap() | ||
419 | + for k, v in pairs(sub) do | ||
420 | + main[k] = (main[k] or 0) + v | ||
421 | + end | ||
422 | + | ||
423 | + local reward, change = role:award(main, {log = {desc = "totalRecharge", int1 = index}}) | ||
424 | + SendPacket(actionCodes.Store_getTotalRechargeAwardRpc, MsgPack.pack(role:packReward(reward, change))) | ||
425 | + return true | ||
426 | +end | ||
427 | + | ||
399 | return _M | 428 | return _M |
400 | \ No newline at end of file | 429 | \ No newline at end of file |
src/adv/Adv.lua
@@ -58,7 +58,7 @@ function Adv:initByInfo(advInfo) | @@ -58,7 +58,7 @@ function Adv:initByInfo(advInfo) | ||
58 | self.maps[id] = AdvMap.new(self, id, map) | 58 | self.maps[id] = AdvMap.new(self, id, map) |
59 | end | 59 | end |
60 | 60 | ||
61 | - self:initBattle() | 61 | + self:initBattle(advInfo) |
62 | end | 62 | end |
63 | -- 找出level 是否存在中继层 | 63 | -- 找出level 是否存在中继层 |
64 | function Adv:isHaveRelay(level, chapterId) | 64 | function Adv:isHaveRelay(level, chapterId) |
@@ -149,25 +149,15 @@ function Adv:initByChapter(params) | @@ -149,25 +149,15 @@ function Adv:initByChapter(params) | ||
149 | self.maps = {} | 149 | self.maps = {} |
150 | self.maps[1] = AdvMap.new(self, 1, mapId, isEnter, isNewRelay) | 150 | self.maps[1] = AdvMap.new(self, 1, mapId, isEnter, isNewRelay) |
151 | 151 | ||
152 | - self:initBattle(true) | 152 | + self:initBattle(nil, isToNext) |
153 | 153 | ||
154 | self:initLayerTask() | 154 | self:initLayerTask() |
155 | 155 | ||
156 | - -- 支援效果生效一些 | ||
157 | - self:activeSomeSupport() | 156 | + |
158 | 157 | ||
159 | self:checkTask(Adv.TaskType.Arrive) | 158 | self:checkTask(Adv.TaskType.Arrive) |
160 | self:checkAdvUnlock(1, self.level) | 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 | if relayData and isEnter then | 162 | if relayData and isEnter then |
173 | self:awardRelay(relayData, notNotify) | 163 | self:awardRelay(relayData, notNotify) |
@@ -456,8 +446,20 @@ function Adv:clearAdvUnlockCache() | @@ -456,8 +446,20 @@ function Adv:clearAdvUnlockCache() | ||
456 | self.cacheUnlock = {} | 446 | self.cacheUnlock = {} |
457 | end | 447 | end |
458 | 448 | ||
459 | -function Adv:initBattle(notDb) | 449 | +function Adv:initBattle(info, isToNext) |
460 | self.battle = require("adv.AdvBattle").new(self) | 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 | for _, passiveC in ipairs(self.cachePassiveEvent or {}) do | 463 | for _, passiveC in ipairs(self.cachePassiveEvent or {}) do |
462 | self.battle:triggerPassive(passiveC[1], passiveC[2]) | 464 | self.battle:triggerPassive(passiveC[1], passiveC[2]) |
463 | end | 465 | end |
@@ -468,13 +470,15 @@ function Adv:initBattle(notDb) | @@ -468,13 +470,15 @@ function Adv:initBattle(notDb) | ||
468 | map:initBattleAfter() | 470 | map:initBattleAfter() |
469 | end | 471 | end |
470 | --下层 | 472 | --下层 |
471 | - if notDb and self.level ~= 1 then | 473 | + if not info and isToNext then |
472 | self.battle.player:attrChangeCondBuffCheck(1) | 474 | self.battle.player:attrChangeCondBuffCheck(1) |
473 | end | 475 | end |
474 | 476 | ||
475 | -- 初始化 | 477 | -- 初始化 |
476 | - if notDb then | 478 | + if not info then |
477 | self.battle:newBattle() | 479 | self.battle:newBattle() |
480 | + else | ||
481 | + self.battle:loadBattle(info) | ||
478 | end | 482 | end |
479 | end | 483 | end |
480 | 484 | ||
@@ -818,7 +822,7 @@ function Adv:over(success, rewardRatio, overType) | @@ -818,7 +822,7 @@ function Adv:over(success, rewardRatio, overType) | ||
818 | lv = self.owner:getProperty("level"), | 822 | lv = self.owner:getProperty("level"), |
819 | batteV = self.owner:getTeamBattleValue(team.heros), | 823 | batteV = self.owner:getTeamBattleValue(team.heros), |
820 | chapter = self.chapterId, | 824 | chapter = self.chapterId, |
821 | - format = self.owner:getTeamHerosInfo(team.heros), | 825 | + format = self.owner:getTeamHerosInfo(team).heros, |
822 | } | 826 | } |
823 | redisproxy:pipelining(function (red) | 827 | redisproxy:pipelining(function (red) |
824 | red:zadd(self.owner:getAdvRankKey(), score, roleId) --更新分数 | 828 | red:zadd(self.owner:getAdvRankKey(), score, roleId) --更新分数 |
@@ -1092,10 +1096,10 @@ local function clickOut(self, room, block, params, isExit) | @@ -1092,10 +1096,10 @@ local function clickOut(self, room, block, params, isExit) | ||
1092 | end | 1096 | end |
1093 | 1097 | ||
1094 | if #self.mapStack > 1 then -- 处于夹层中 | 1098 | if #self.mapStack > 1 then -- 处于夹层中 |
1099 | + self:backLayer(-1) | ||
1095 | local oldMapIdx = self:getCurMapIdx() | 1100 | local oldMapIdx = self:getCurMapIdx() |
1096 | table.remove(self.mapStack) --退出夹层 | 1101 | table.remove(self.mapStack) --退出夹层 |
1097 | self.battle:iLayerChange(oldMapIdx) | 1102 | self.battle:iLayerChange(oldMapIdx) |
1098 | - self:backLayer(-1) | ||
1099 | else --处于底层 | 1103 | else --处于底层 |
1100 | 1104 | ||
1101 | local advPass = self.owner:getProperty("advPass") | 1105 | local advPass = self.owner:getProperty("advPass") |
@@ -1127,8 +1131,8 @@ local function clickOut(self, room, block, params, isExit) | @@ -1127,8 +1131,8 @@ local function clickOut(self, room, block, params, isExit) | ||
1127 | if curFloorData then | 1131 | if curFloorData then |
1128 | self:award({[ItemId.AdvPoint] = curFloorData.exp}, {log = {desc = "passReward", int1 = self.chapterId, int2 = self.level}}, {}) | 1132 | self:award({[ItemId.AdvPoint] = curFloorData.exp}, {log = {desc = "passReward", int1 = self.chapterId, int2 = self.level}}, {}) |
1129 | end | 1133 | end |
1134 | + self:backNext() --下一关 | ||
1130 | local isHaveRelay = self:isHaveRelay(self.level) | 1135 | local isHaveRelay = self:isHaveRelay(self.level) |
1131 | - | ||
1132 | if isHaveRelay and not self.isRelay then | 1136 | if isHaveRelay and not self.isRelay then |
1133 | self:initByChapter({ | 1137 | self:initByChapter({ |
1134 | chapterId = self.chapterId, | 1138 | chapterId = self.chapterId, |
@@ -1146,7 +1150,6 @@ local function clickOut(self, room, block, params, isExit) | @@ -1146,7 +1150,6 @@ local function clickOut(self, room, block, params, isExit) | ||
1146 | notNotify = true, | 1150 | notNotify = true, |
1147 | }) | 1151 | }) |
1148 | end | 1152 | end |
1149 | - self:backNext() --下一关 | ||
1150 | end | 1153 | end |
1151 | 1154 | ||
1152 | end | 1155 | end |
@@ -1386,19 +1389,31 @@ local function chooseCommon(self, room, block, chooseData, choose, tag) | @@ -1386,19 +1389,31 @@ local function chooseCommon(self, room, block, chooseData, choose, tag) | ||
1386 | [14] = function() -- 指定地块召唤 指定类型的id | 1389 | [14] = function() -- 指定地块召唤 指定类型的id |
1387 | local change = self:getCurMap():layEventToStage(effect[2], effect[3], effect[4], effect[5]) | 1390 | local change = self:getCurMap():layEventToStage(effect[2], effect[3], effect[4], effect[5]) |
1388 | for _, one in ipairs(change) do | 1391 | for _, one in ipairs(change) do |
1389 | - self:backBlockChange(one[1].roomId, one[2].blockId) | 1392 | + if one[1].roomId == room.roomId and one[2].blockId == block.blockId then |
1393 | + clearBlock = false | ||
1394 | + else | ||
1395 | + self:backBlockChange(one[1].roomId, one[2].blockId) | ||
1396 | + end | ||
1390 | end | 1397 | end |
1391 | end, | 1398 | end, |
1392 | [15] = function() -- 移除指定事件 | 1399 | [15] = function() -- 移除指定事件 |
1393 | local change = self:getCurMap():clearEventById(effect[2], effect[3], effect[4]) | 1400 | local change = self:getCurMap():clearEventById(effect[2], effect[3], effect[4]) |
1394 | for _, one in ipairs(change) do | 1401 | for _, one in ipairs(change) do |
1395 | - self:backBlockChange(one[1].roomId, one[2].blockId) | 1402 | + if one[1].roomId == room.roomId and one[2].blockId == block.blockId then |
1403 | + clearBlock = false | ||
1404 | + else | ||
1405 | + self:backBlockChange(one[1].roomId, one[2].blockId) | ||
1406 | + end | ||
1396 | end | 1407 | end |
1397 | end, | 1408 | end, |
1398 | [16] = function() -- 指定事件转移 | 1409 | [16] = function() -- 指定事件转移 |
1399 | local change = self:getCurMap():eventChangeToOther(effect[2], effect[3], effect[4], effect[5], effect[6]) | 1410 | local change = self:getCurMap():eventChangeToOther(effect[2], effect[3], effect[4], effect[5], effect[6]) |
1400 | for _, one in ipairs(change) do | 1411 | for _, one in ipairs(change) do |
1401 | - self:backBlockChange(one[1].roomId, one[2].blockId) | 1412 | + if one[1].roomId == room.roomId and one[2].blockId == block.blockId then |
1413 | + clearBlock = false | ||
1414 | + else | ||
1415 | + self:backBlockChange(one[1].roomId, one[2].blockId) | ||
1416 | + end | ||
1402 | end | 1417 | end |
1403 | end, | 1418 | end, |
1404 | } | 1419 | } |
@@ -1524,6 +1539,25 @@ local function clickBuild(self, room, block, params) | @@ -1524,6 +1539,25 @@ local function clickBuild(self, room, block, params) | ||
1524 | local status, clearBlock = chooseCommon(self, room, block, chooseData, choose, "build") | 1539 | local status, clearBlock = chooseCommon(self, room, block, chooseData, choose, "build") |
1525 | if not status then return end | 1540 | if not status then return end |
1526 | 1541 | ||
1542 | + local isMine = false -- 是不是宝藏怪 | ||
1543 | + for _, mid in ipairs(globalCsv.adv_egg_treasureLayer_id) do | ||
1544 | + if mid == oldId then | ||
1545 | + isMine = true | ||
1546 | + break | ||
1547 | + end | ||
1548 | + end | ||
1549 | + if isMine then | ||
1550 | + local advMine = self.owner:getProperty("advMine") | ||
1551 | + advMine[2] = advMine[2] or {} | ||
1552 | + local mineCo2 = advMine[2].co or {} | ||
1553 | + if chooseData.limit ~= 0 then | ||
1554 | + mineCo2[oldId] = (mineCo2[oldId] or 0) + 1 | ||
1555 | + end | ||
1556 | + advMine[2].co = mineCo2 | ||
1557 | + self.owner:setProperty("advMine", advMine) | ||
1558 | + self.owner:checkTaskEnter("AdvMineLayer") | ||
1559 | + end | ||
1560 | + | ||
1527 | self:checkTask(Adv.TaskType.Build, 1, oldId) | 1561 | self:checkTask(Adv.TaskType.Build, 1, oldId) |
1528 | self:checkAchievement(Adv.AchievType.Build, 1, oldId) | 1562 | self:checkAchievement(Adv.AchievType.Build, 1, oldId) |
1529 | self:checkAchievement(Adv.AchievType.BuildBySelect, 1, oldId, choose) | 1563 | self:checkAchievement(Adv.AchievType.BuildBySelect, 1, oldId, choose) |
@@ -1572,6 +1606,7 @@ end | @@ -1572,6 +1606,7 @@ end | ||
1572 | 1606 | ||
1573 | local function clickLayer(self, room, block, params) | 1607 | local function clickLayer(self, room, block, params) |
1574 | local oldMapIdx = self:getCurMapIdx() | 1608 | local oldMapIdx = self:getCurMapIdx() |
1609 | + self:backLayer(1) | ||
1575 | if block.event.mapIdx then | 1610 | if block.event.mapIdx then |
1576 | table.insert(self.mapStack, block.event.mapIdx) --进入夹层 | 1611 | table.insert(self.mapStack, block.event.mapIdx) --进入夹层 |
1577 | else | 1612 | else |
@@ -1588,7 +1623,6 @@ local function clickLayer(self, room, block, params) | @@ -1588,7 +1623,6 @@ local function clickLayer(self, room, block, params) | ||
1588 | self:checkAchievement(Adv.AchievType.EnterILayer, 1, mapId) | 1623 | self:checkAchievement(Adv.AchievType.EnterILayer, 1, mapId) |
1589 | end | 1624 | end |
1590 | self.battle:iLayerChange(oldMapIdx) | 1625 | self.battle:iLayerChange(oldMapIdx) |
1591 | - self:backLayer(1) | ||
1592 | return true | 1626 | return true |
1593 | end | 1627 | end |
1594 | 1628 | ||
@@ -1951,73 +1985,144 @@ function Adv:enemyDead(enemy, escape) | @@ -1951,73 +1985,144 @@ function Adv:enemyDead(enemy, escape) | ||
1951 | -- self:backDead(enemyId, changeV) | 1985 | -- self:backDead(enemyId, changeV) |
1952 | self:backDead(enemyId) | 1986 | self:backDead(enemyId) |
1953 | 1987 | ||
1954 | - local toClick = enemy:hadBuff(Buff.CHANGE_DROP_TO_CLICK) | ||
1955 | - if toClick then | ||
1956 | - toClick = toClick:effect() | 1988 | + local isMine = false -- 是不是宝藏怪 |
1989 | + for _, mid in ipairs(globalCsv.adv_egg_treasureMonster_id) do | ||
1990 | + if mid == enemyId then | ||
1991 | + isMine = true | ||
1992 | + break | ||
1993 | + end | ||
1957 | end | 1994 | end |
1958 | 1995 | ||
1959 | - local changItem = enemy:hadBuff(Buff.CHANGE_DROP) | ||
1960 | - if changItem then | ||
1961 | - changItem = table.pack(changItem:effect()) | ||
1962 | - end | 1996 | + if isMine then |
1997 | + local advMine = self.owner:getProperty("advMine") | ||
1998 | + advMine[1] = advMine[1] or {} | ||
1999 | + advMine[2] = advMine[2] or {} | ||
2000 | + local mineCo = advMine[1].co or {} | ||
2001 | + local mineCo2 = advMine[2].co or {} | ||
2002 | + local mineCh = advMine[2].ch or globalCsv.adv_egg_treasureLayer_showup | ||
2003 | + if monsterData.limit ~= 0 then | ||
2004 | + mineCo[enemyId] = (mineCo[enemyId] or 0) + 1 | ||
2005 | + end | ||
1963 | 2006 | ||
1964 | - local addMult = 0 | ||
1965 | - local dropBuff = enemy:hadBuff(Buff.DROP_BUFF_BY_ENEMY) -- 根据敌人数量变化个数 | ||
1966 | - if dropBuff then | ||
1967 | - local team = enemy:getTeam(1, true) | ||
1968 | - addMult = addMult + 0.2 * #team | ||
1969 | - end | 2007 | + local had = false |
2008 | + if math.randomInt(1, 100) <= mineCh then -- 刷出来了 | ||
2009 | + local mpool = {} | ||
2010 | + for _, mid in ipairs(globalCsv.adv_egg_treasureLayer_id) do | ||
2011 | + local layer = csvdb["event_buildingCsv"][mid] | ||
2012 | + if (not mineCo2[mid] or layer.limit == 0 or mineCo2[mid] < layer.limit) and layer.showup > 0 then | ||
2013 | + mpool[mid] = {layer.showup} | ||
2014 | + end | ||
2015 | + end | ||
2016 | + if next(mpool) then | ||
2017 | + local cId = math.randWeight(mpool, 1) | ||
2018 | + block:updateEvent({ | ||
2019 | + etype = AdvEventType.Build, | ||
2020 | + id = cId | ||
2021 | + }) | ||
2022 | + had = true | ||
2023 | + end | ||
2024 | + end | ||
2025 | + if had then | ||
2026 | + mineCh = nil | ||
2027 | + else | ||
2028 | + block:clear() | ||
2029 | + mineCh = math.min(mineCh + globalCsv.adv_egg_treasureLayer_showup_add, 100) | ||
2030 | + end | ||
1970 | 2031 | ||
1971 | - local dropIds = monsterData.dropid:toArray(true, "=") | ||
1972 | - local drops = {} | ||
1973 | - local cCcount = 0 -- 需要改变为click 的个数 | ||
1974 | - for _, dropId in ipairs(dropIds) do | ||
1975 | - local dropData = csvdb["event_dropCsv"][dropId] | ||
1976 | - if dropData then | ||
1977 | - local cur = dropData["range"]:randWeight(true) | ||
1978 | - if cur and cur[1] ~= 0 then | ||
1979 | - if toClick then | ||
1980 | - cCcount = cCcount + 1 | ||
1981 | - else | ||
1982 | - local item = changItem and changItem or cur | ||
1983 | - item[2] = math.floor(item[2] * (1 + addMult)) | ||
1984 | - drops[#drops + 1] = item | 2032 | + local drops = {} |
2033 | + for _, dropId in ipairs(monsterData.dropid:toArray(true, "=")) do | ||
2034 | + local dropData = csvdb["event_dropCsv"][dropId] | ||
2035 | + if dropData then | ||
2036 | + local cur = dropData["range"]:randWeight(true) | ||
2037 | + if cur and cur[1] ~= 0 then | ||
2038 | + drops[#drops + 1] = cur | ||
1985 | end | 2039 | end |
1986 | end | 2040 | end |
1987 | end | 2041 | end |
1988 | - end | ||
1989 | - -- 这些奖励可能会有被动加成 | ||
1990 | - self.battle.player:triggerPassive(Passive.BATTLE_WIN, {drops = drops}) | 2042 | + local blocks = self:getCurMap():getEmptyBlocks(roomId, blockId, #drops) |
2043 | + for _i, cblock in ipairs(blocks) do | ||
2044 | + cblock:updateEvent({ | ||
2045 | + etype = AdvEventType.Drop, | ||
2046 | + item = drops[_i] | ||
2047 | + }) | ||
2048 | + if cblock ~= block then | ||
2049 | + self:backBlockChange(cblock.room.roomId, cblock.blockId) | ||
2050 | + end | ||
2051 | + end | ||
2052 | + advMine[1].co = mineCo | ||
2053 | + advMine[2].co = mineCo2 | ||
2054 | + advMine[2].ch = mineCh | ||
2055 | + self.owner:setProperty("advMine", advMine) | ||
2056 | + self.owner:checkTaskEnter("AdvMineKill") | ||
2057 | + else | ||
2058 | + local toClick = enemy:hadBuff(Buff.CHANGE_DROP_TO_CLICK) | ||
2059 | + if toClick then | ||
2060 | + toClick = toClick:effect() | ||
2061 | + end | ||
1991 | 2062 | ||
1992 | - -- 自身带的掉落是不会被改变的 也不会被加成 | ||
1993 | - if block.event.item and block.event.item[1] ~= 0 then | ||
1994 | - table.insert(drops, 1, block.event.item) | ||
1995 | - end | 2063 | + local changItem = enemy:hadBuff(Buff.CHANGE_DROP) |
2064 | + if changItem then | ||
2065 | + changItem = table.pack(changItem:effect()) | ||
2066 | + end | ||
1996 | 2067 | ||
1997 | - -- 清空当前的格子 | ||
1998 | - block:clear() | 2068 | + local addMult = 0 |
2069 | + local dropBuff = enemy:hadBuff(Buff.DROP_BUFF_BY_ENEMY) -- 根据敌人数量变化个数 | ||
2070 | + if dropBuff then | ||
2071 | + local team = enemy:getTeam(1, true) | ||
2072 | + addMult = addMult + 0.2 * #team | ||
2073 | + end | ||
1999 | 2074 | ||
2000 | - -- 掉落走一波 | ||
2001 | - local blocks = self:getCurMap():getEmptyBlocks(roomId, blockId, #drops) | ||
2002 | - for _i, cblock in ipairs(blocks) do | ||
2003 | - cblock:updateEvent({ | ||
2004 | - etype = AdvEventType.Drop, | ||
2005 | - item = drops[_i] | ||
2006 | - }) | ||
2007 | - if cblock ~= block then | ||
2008 | - self:backBlockChange(cblock.room.roomId, cblock.blockId) | 2075 | + local dropIds = monsterData.dropid:toArray(true, "=") |
2076 | + local drops = {} | ||
2077 | + local cCcount = 0 -- 需要改变为click 的个数 | ||
2078 | + for _, dropId in ipairs(dropIds) do | ||
2079 | + local dropData = csvdb["event_dropCsv"][dropId] | ||
2080 | + if dropData then | ||
2081 | + local cur = dropData["range"]:randWeight(true) | ||
2082 | + if cur and cur[1] ~= 0 then | ||
2083 | + if toClick then | ||
2084 | + cCcount = cCcount + 1 | ||
2085 | + else | ||
2086 | + local item = changItem and changItem or cur | ||
2087 | + item[2] = math.floor(item[2] * (1 + addMult)) | ||
2088 | + drops[#drops + 1] = item | ||
2089 | + end | ||
2090 | + end | ||
2091 | + end | ||
2009 | end | 2092 | end |
2010 | - end | 2093 | + -- 这些奖励可能会有被动加成 |
2094 | + self.battle.player:triggerPassive(Passive.BATTLE_WIN, {drops = drops}) | ||
2011 | 2095 | ||
2012 | - -- 转换的click走一波 | ||
2013 | - local blocks = self:getCurMap():getEmptyBlocks(roomId, blockId, cCcount) | ||
2014 | - for _i, cblock in ipairs(blocks) do | ||
2015 | - cblock:updateEvent({ | ||
2016 | - etype = AdvEventType.Click, | ||
2017 | - id = clickId | ||
2018 | - }) | ||
2019 | - if cblock ~= block then | ||
2020 | - self:backBlockChange(cblock.room.roomId, cblock.blockId) | 2096 | + -- 自身带的掉落是不会被改变的 也不会被加成 |
2097 | + if block.event.item and block.event.item[1] ~= 0 then | ||
2098 | + table.insert(drops, 1, block.event.item) | ||
2099 | + end | ||
2100 | + | ||
2101 | + -- 清空当前的格子 | ||
2102 | + block:clear() | ||
2103 | + | ||
2104 | + -- 掉落走一波 | ||
2105 | + local blocks = self:getCurMap():getEmptyBlocks(roomId, blockId, #drops) | ||
2106 | + for _i, cblock in ipairs(blocks) do | ||
2107 | + cblock:updateEvent({ | ||
2108 | + etype = AdvEventType.Drop, | ||
2109 | + item = drops[_i] | ||
2110 | + }) | ||
2111 | + if cblock ~= block then | ||
2112 | + self:backBlockChange(cblock.room.roomId, cblock.blockId) | ||
2113 | + end | ||
2114 | + end | ||
2115 | + | ||
2116 | + -- 转换的click走一波 | ||
2117 | + local blocks = self:getCurMap():getEmptyBlocks(roomId, blockId, cCcount) | ||
2118 | + for _i, cblock in ipairs(blocks) do | ||
2119 | + cblock:updateEvent({ | ||
2120 | + etype = AdvEventType.Click, | ||
2121 | + id = clickId | ||
2122 | + }) | ||
2123 | + if cblock ~= block then | ||
2124 | + self:backBlockChange(cblock.room.roomId, cblock.blockId) | ||
2125 | + end | ||
2021 | end | 2126 | end |
2022 | end | 2127 | end |
2023 | 2128 |
src/adv/AdvBattle.lua
@@ -316,8 +316,19 @@ function Battle:afterRound() | @@ -316,8 +316,19 @@ function Battle:afterRound() | ||
316 | build:afterRound("buffAfter") | 316 | build:afterRound("buffAfter") |
317 | end | 317 | end |
318 | 318 | ||
319 | + self.player:triggerPassive(Passive.AFTER_ROUND) | ||
320 | + | ||
321 | + self:checkAura() | ||
322 | + | ||
323 | + self:clearRound() | ||
319 | 324 | ||
325 | + if self.player.isDead then | ||
326 | + self.adv:over(false, nil, -2) | ||
327 | + end | ||
328 | +end | ||
320 | 329 | ||
330 | +function Battle:clearRound() | ||
331 | + local mapIdx = self.adv:getCurMapIdx() | ||
321 | self.player:clearRound() | 332 | self.player:clearRound() |
322 | for _, enemy in ipairs(self.enemys[mapIdx]) do | 333 | for _, enemy in ipairs(self.enemys[mapIdx]) do |
323 | enemy:clearRound() | 334 | enemy:clearRound() |
@@ -347,14 +358,6 @@ function Battle:afterRound() | @@ -347,14 +358,6 @@ function Battle:afterRound() | ||
347 | build:clear() | 358 | build:clear() |
348 | end | 359 | end |
349 | end | 360 | end |
350 | - | ||
351 | - self.player:triggerPassive(Passive.AFTER_ROUND) | ||
352 | - | ||
353 | - self:checkAura() | ||
354 | - | ||
355 | - if self.player.isDead then | ||
356 | - self.adv:over(false, nil, -2) | ||
357 | - end | ||
358 | end | 361 | end |
359 | 362 | ||
360 | 363 | ||
@@ -363,18 +366,32 @@ function Battle:battleBegin(roomId, blockId, params) | @@ -363,18 +366,32 @@ function Battle:battleBegin(roomId, blockId, params) | ||
363 | if not enemy then return end | 366 | if not enemy then return end |
364 | local player = params.player | 367 | local player = params.player |
365 | if not player then return end | 368 | if not player then return end |
369 | + local penemy = params.enemy or {hp = 0} | ||
370 | + if player.hp ~= 0 then | ||
371 | + if penemy.hp <= 0 then | ||
372 | + enemy:kill() | ||
373 | + self.adv.owner:checkTaskEnter("AdvBattleWin", {id = self.adv.chapterId}) | ||
374 | + else | ||
375 | + -- 处理一下怪物 | ||
376 | + if penemy.hp > enemy.hp then | ||
377 | + enemy:recover(penemy.hp - enemy.hp) | ||
378 | + else | ||
379 | + enemy:hurt(math.max(0, math.ceil(enemy.hp - penemy.hp)), self.player, {hurtType = 5}) --战斗血量只会变少 | ||
380 | + end | ||
381 | + if penemy.escape and penemy.escape == 0 then | ||
382 | + enemy.isDead = 1 | ||
383 | + end | ||
384 | + end | ||
385 | + end | ||
366 | -- 玩家没死就是怪死了 | 386 | -- 玩家没死就是怪死了 |
367 | if player.hp > 0 then | 387 | if player.hp > 0 then |
368 | - enemy:kill() | ||
369 | self.player:effectBattleBuff() | 388 | self.player:effectBattleBuff() |
370 | - | ||
371 | - self.adv.owner:checkTaskEnter("AdvBattleWin", {id = self.adv.chapterId}) | ||
372 | if params.bySkill then | 389 | if params.bySkill then |
373 | self.player:triggerPassive(Passive.SKILL_KILL) | 390 | self.player:triggerPassive(Passive.SKILL_KILL) |
374 | end | 391 | end |
375 | end | 392 | end |
376 | if player.hp > self.player.hp then | 393 | if player.hp > self.player.hp then |
377 | - self.player:recover(player.hp - self.player.hp, player) | 394 | + self.player:recover(player.hp - self.player.hp) |
378 | else | 395 | else |
379 | self.player:hurt(math.max(0, math.ceil(self.player.hp - player.hp)), enemy, {hurtType = 5}) --战斗血量只会变少 | 396 | self.player:hurt(math.max(0, math.ceil(self.player.hp - player.hp)), enemy, {hurtType = 5}) --战斗血量只会变少 |
380 | end | 397 | end |
@@ -429,7 +446,7 @@ function Battle:initMapEffect(ilayer) | @@ -429,7 +446,7 @@ function Battle:initMapEffect(ilayer) | ||
429 | end | 446 | end |
430 | 447 | ||
431 | for _, buff in ipairs(buffs[1] or {}) do | 448 | for _, buff in ipairs(buffs[1] or {}) do |
432 | - self.palyer:addBuff(buff) | 449 | + self.player:addBuff(buff) |
433 | end | 450 | end |
434 | 451 | ||
435 | for _, buff in ipairs(buffs[2] or {}) do | 452 | for _, buff in ipairs(buffs[2] or {}) do |
@@ -446,16 +463,18 @@ function Battle:iLayerChange(oldMapIdx) | @@ -446,16 +463,18 @@ function Battle:iLayerChange(oldMapIdx) | ||
446 | local playerBuffs = self:checkDiffAuraBuff(self:getAurasByMap(oldMapIdx), auras) | 463 | local playerBuffs = self:checkDiffAuraBuff(self:getAurasByMap(oldMapIdx), auras) |
447 | local enemyBuffs = self:checkDiffAuraBuff(self:getAurasByMap(), auras) | 464 | local enemyBuffs = self:checkDiffAuraBuff(self:getAurasByMap(), auras) |
448 | self.player:checkAuraBuff(playerBuffs) | 465 | self.player:checkAuraBuff(playerBuffs) |
449 | - for _, enemy in pairs(self.player:getTeam(2)) do | 466 | + for _, enemy in ipairs(self.enemys[self.adv:getCurMapIdx()]) do |
450 | enemy:checkAuraBuff(enemyBuffs) | 467 | enemy:checkAuraBuff(enemyBuffs) |
451 | end | 468 | end |
452 | self:setMapAuras(auras) | 469 | self:setMapAuras(auras) |
470 | + self:clearRound() | ||
453 | end | 471 | end |
454 | 472 | ||
455 | -- 新的 关卡 关闭旧的战斗模块 清理 玩家身上的光环效果 | 473 | -- 新的 关卡 关闭旧的战斗模块 清理 玩家身上的光环效果 |
456 | function Battle:overBattle() | 474 | function Battle:overBattle() |
457 | local buffs = self:checkDiffAuraBuff(self:getAurasByMap(), {}) | 475 | local buffs = self:checkDiffAuraBuff(self:getAurasByMap(), {}) |
458 | self.player:checkAuraBuff(buffs) | 476 | self.player:checkAuraBuff(buffs) |
477 | + self:clearRound() | ||
459 | self.adv.owner:getProperty("advTeam").player = self.player:getDB() -- 临时缓存住 battle 的player | 478 | self.adv.owner:getProperty("advTeam").player = self.player:getDB() -- 临时缓存住 battle 的player |
460 | end | 479 | end |
461 | 480 | ||
@@ -463,9 +482,17 @@ end | @@ -463,9 +482,17 @@ end | ||
463 | function Battle:newBattle() | 482 | function Battle:newBattle() |
464 | local auras = self:getActiveAuras() | 483 | local auras = self:getActiveAuras() |
465 | local buffs = self:checkDiffAuraBuff({}, auras) | 484 | local buffs = self:checkDiffAuraBuff({}, auras) |
485 | + self.player:checkAuraBuff(buffs) | ||
486 | + for _, enemy in ipairs(self.enemys[self.adv:getCurMapIdx()]) do | ||
487 | + enemy:checkAuraBuff(buffs) | ||
488 | + end | ||
466 | self:setMapAuras(auras) | 489 | self:setMapAuras(auras) |
467 | end | 490 | end |
468 | 491 | ||
492 | +function Battle:loadBattle(info) | ||
493 | + self.auras = info.auras or {} | ||
494 | +end | ||
495 | + | ||
469 | -- 过了回合 检查光环 | 496 | -- 过了回合 检查光环 |
470 | function Battle:checkAura() | 497 | function Battle:checkAura() |
471 | local auras = self:getActiveAuras() | 498 | local auras = self:getActiveAuras() |
src/adv/AdvBlock.lua
@@ -332,7 +332,9 @@ end | @@ -332,7 +332,9 @@ end | ||
332 | function Block:getObstacle() | 332 | function Block:getObstacle() |
333 | if self:isMonster() then | 333 | if self:isMonster() then |
334 | local enemy = self.room.map.adv.battle:getEnemy(self.room.roomId, self.blockId) | 334 | local enemy = self.room.map.adv.battle:getEnemy(self.room.roomId, self.blockId) |
335 | - return enemy:getObstacle() | 335 | + if enemy then |
336 | + return enemy:getObstacle() | ||
337 | + end | ||
336 | end | 338 | end |
337 | local data = self:getEventData() | 339 | local data = self:getEventData() |
338 | if not data then return 0 end | 340 | if not data then return 0 end |
src/adv/AdvBuff.lua
@@ -35,7 +35,7 @@ Buff.Buff_NO_PASSIVE_MONSTER = 31 -- 地图被动刷新不出来怪物 | @@ -35,7 +35,7 @@ Buff.Buff_NO_PASSIVE_MONSTER = 31 -- 地图被动刷新不出来怪物 | ||
35 | Buff.SNEAK = 32 --潜行 | 35 | Buff.SNEAK = 32 --潜行 |
36 | Buff.DROP_BUFF_BY_ENEMY = 33 -- 怪物掉落加成 -- 怪物使用 | 36 | Buff.DROP_BUFF_BY_ENEMY = 33 -- 怪物掉落加成 -- 怪物使用 |
37 | Buff.GET_PASSIVE = 34 -- 获得 passive -- 结束失效 | 37 | Buff.GET_PASSIVE = 34 -- 获得 passive -- 结束失效 |
38 | -Buff.OBSTACLE_CHANGE = 35 -- 看守类型改变 -- 怪物使用 0 - 1 | 38 | +Buff.OBSTACLE_CHANGE = 35 -- 看守类型改变 -- 怪物使用 2 - 1 |
39 | Buff.DISABLE_AURA = 36 -- 禁用光环 | 39 | Buff.DISABLE_AURA = 36 -- 禁用光环 |
40 | Buff.GET_AURA = 37 -- 获得光环 | 40 | Buff.GET_AURA = 37 -- 获得光环 |
41 | 41 | ||
@@ -489,6 +489,8 @@ function Buff:createAfter(layer) | @@ -489,6 +489,8 @@ function Buff:createAfter(layer) | ||
489 | if self._init then | 489 | if self._init then |
490 | self:_init() | 490 | self:_init() |
491 | end | 491 | end |
492 | + self:pushBackEffect(1) | ||
493 | + buglog("Buff", "who: %s create buffId: %s", self.owner.monsterId, self.id) | ||
492 | end | 494 | end |
493 | 495 | ||
494 | function Buff:initByDB(data) | 496 | function Buff:initByDB(data) |
@@ -620,11 +622,20 @@ function Buff:canEffect(...) | @@ -620,11 +622,20 @@ function Buff:canEffect(...) | ||
620 | return self:_canEffect(...) | 622 | return self:_canEffect(...) |
621 | end | 623 | end |
622 | 624 | ||
625 | +function Buff:pushBackEffect(etype) | ||
626 | + local shows = self.buffData.show:toTableArray(true) | ||
627 | + for _, one in ipairs(shows) do | ||
628 | + if one[1] == etype then | ||
629 | + self.owner.battle.adv:pushBackEvent(AdvBackEventType.BuffEffect, {etype = etype, id = self.id, blockId = self.owner.blockId, roomId = self.owner.roomId}) | ||
630 | + break | ||
631 | + end | ||
632 | + end | ||
633 | +end | ||
634 | + | ||
623 | function Buff:effect() | 635 | function Buff:effect() |
636 | + buglog("Buff", "who: %s effect buffId: %s", self.owner.monsterId, self.id) | ||
624 | self:decCount() | 637 | self:decCount() |
625 | - if self.buffData.show:sismember(2, " ") then | ||
626 | - self.owner.battle.adv:pushBackEvent(AdvBackEventType.BuffEffect, {etype = 2}) | ||
627 | - end | 638 | + self:pushBackEffect(2) |
628 | if self._effectValue then | 639 | if self._effectValue then |
629 | return self:_effectValue() | 640 | return self:_effectValue() |
630 | end | 641 | end |
@@ -646,6 +657,7 @@ function Buff:endBuff() | @@ -646,6 +657,7 @@ function Buff:endBuff() | ||
646 | if self._endBuff then | 657 | if self._endBuff then |
647 | self:_endBuff() | 658 | self:_endBuff() |
648 | end | 659 | end |
660 | + buglog("Buff", "who: %s endBuff buffId: %s", self.owner.monsterId, self.id) | ||
649 | end | 661 | end |
650 | 662 | ||
651 | function Buff:getType() | 663 | function Buff:getType() |
@@ -698,6 +710,9 @@ function Buff:overlay(releaser, data, layer) | @@ -698,6 +710,9 @@ function Buff:overlay(releaser, data, layer) | ||
698 | if self._overlay then | 710 | if self._overlay then |
699 | self:_overlay() | 711 | self:_overlay() |
700 | end | 712 | end |
713 | + | ||
714 | + self:pushBackEffect(1) | ||
715 | + buglog("Buff", "who: %s overlay buffId: %s", self.owner.monsterId, self.id) | ||
701 | end | 716 | end |
702 | end | 717 | end |
703 | 718 |
src/adv/AdvMap.lua
@@ -13,12 +13,12 @@ local createMap, getEventLib | @@ -13,12 +13,12 @@ local createMap, getEventLib | ||
13 | function Map:ctor(adv, mapIdx, mapInfo, isEnter, isNewRelay) | 13 | function Map:ctor(adv, mapIdx, mapInfo, isEnter, isNewRelay) |
14 | self.adv = adv | 14 | self.adv = adv |
15 | local isNew = type(mapInfo) == "number" | 15 | local isNew = type(mapInfo) == "number" |
16 | + self.mapIdx = mapIdx | ||
16 | if isNew then -- mapInfo 传入 id | 17 | if isNew then -- mapInfo 传入 id |
17 | mapInfo = createMap(self, mapInfo, isEnter, isNewRelay) -- 生成地图 | 18 | mapInfo = createMap(self, mapInfo, isEnter, isNewRelay) -- 生成地图 |
18 | end | 19 | end |
19 | if not mapInfo then return end | 20 | if not mapInfo then return end |
20 | 21 | ||
21 | - self.mapIdx = mapIdx | ||
22 | self.mapId = mapInfo.mapId | 22 | self.mapId = mapInfo.mapId |
23 | self.isShow = mapInfo.isShow -- 是否全部展示 -- 客户端用 | 23 | self.isShow = mapInfo.isShow -- 是否全部展示 -- 客户端用 |
24 | self.rooms = {} | 24 | self.rooms = {} |
@@ -258,7 +258,7 @@ function Map:openBlock(roomId, blockId, isPlayer, ignoreBack) | @@ -258,7 +258,7 @@ function Map:openBlock(roomId, blockId, isPlayer, ignoreBack) | ||
258 | if isPlayer then | 258 | if isPlayer then |
259 | self.adv.battle:triggerPassive(Passive.OPEN_BLOCK, {roomId = roomId, blockId = blockId}) | 259 | self.adv.battle:triggerPassive(Passive.OPEN_BLOCK, {roomId = roomId, blockId = blockId}) |
260 | self.adv.owner:checkTaskEnter("AdvOpenBlock") | 260 | self.adv.owner:checkTaskEnter("AdvOpenBlock") |
261 | - | 261 | + self.adv.battle.player:changeSp(1) -- 翻开格子 sp 加1 |
262 | -- 潜行检查 | 262 | -- 潜行检查 |
263 | local sneakBuff = self.adv.battle.player:hadBuff(Buff.SNEAK) | 263 | local sneakBuff = self.adv.battle.player:hadBuff(Buff.SNEAK) |
264 | if sneakBuff then | 264 | if sneakBuff then |
@@ -313,13 +313,13 @@ function Map:openBlocksIsMonsterByRoom(roomId, count, isPlayer, ignoreBack) | @@ -313,13 +313,13 @@ function Map:openBlocksIsMonsterByRoom(roomId, count, isPlayer, ignoreBack) | ||
313 | end | 313 | end |
314 | end | 314 | end |
315 | 315 | ||
316 | - if not count or count == -1 or count >= len(allBlock) then | 316 | + if not count or count == -1 or count >= #allBlock then |
317 | for _, blockId in ipairs(allBlock) do | 317 | for _, blockId in ipairs(allBlock) do |
318 | openBlock(blockId) | 318 | openBlock(blockId) |
319 | end | 319 | end |
320 | else | 320 | else |
321 | for i = 1, count do | 321 | for i = 1, count do |
322 | - local idx = math.randomInt(1, len(allBlock)) | 322 | + local idx = math.randomInt(1, #allBlock) |
323 | openBlock(allBlock[idx]) | 323 | openBlock(allBlock[idx]) |
324 | table.remove(allBlock, idx) | 324 | table.remove(allBlock, idx) |
325 | end | 325 | end |
@@ -349,8 +349,8 @@ function Map:getDistance(froomId, fblockId, troomId, tblockId) | @@ -349,8 +349,8 @@ function Map:getDistance(froomId, fblockId, troomId, tblockId) | ||
349 | local room1 = self.rooms[froomId] | 349 | local room1 = self.rooms[froomId] |
350 | local room2 = self.rooms[troomId] | 350 | local room2 = self.rooms[troomId] |
351 | if room1 and room2 then | 351 | if room1 and room2 then |
352 | - local block1 = room1[fblockId] | ||
353 | - local block2 = room2[tblockId] | 352 | + local block1 = room1.blocks[fblockId] |
353 | + local block2 = room2.blocks[tblockId] | ||
354 | if block1 and block2 then | 354 | if block1 and block2 then |
355 | local c1, r1 = room1:tranLtoG(block1.col, block1.row) | 355 | local c1, r1 = room1:tranLtoG(block1.col, block1.row) |
356 | local c2, r2 = room2:tranLtoG(block2.col, block2.row) | 356 | local c2, r2 = room2:tranLtoG(block2.col, block2.row) |
@@ -811,6 +811,48 @@ createMap = function(self, mapId, isEnter, isNewRelay) | @@ -811,6 +811,48 @@ createMap = function(self, mapId, isEnter, isNewRelay) | ||
811 | end | 811 | end |
812 | end | 812 | end |
813 | end | 813 | end |
814 | + -- 宝藏怪刷新 | ||
815 | + if self.mapIdx == 1 and not self.adv.isRelay and self.adv.chapterId ~= 100 then | ||
816 | + for idx = #(stagePool["global"][AdvCodeRandomStage] or {}), 1, -1 do | ||
817 | + local c = stagePool["global"][AdvCodeRandomStage][idx] -- {room = roomId, block = blockId} | ||
818 | + if mapInfo.rooms[c["room"]]["event"][c["block"]] then -- 存在 | ||
819 | + table.remove(stagePool["global"][AdvCodeRandomStage], idx) | ||
820 | + end | ||
821 | + end | ||
822 | + local ln = #(stagePool["global"][AdvCodeRandomStage] or {}) | ||
823 | + local advMine = self.adv.owner:getProperty("advMine") | ||
824 | + advMine[1] = advMine[1] or {} | ||
825 | + local mineCh = advMine[1].ch or globalCsv.adv_egg_treasureMonster_showup | ||
826 | + local mineCo = advMine[1].co or {} | ||
827 | + local had = false | ||
828 | + if ln > 0 then | ||
829 | + if math.randomInt(1, 100) <= mineCh then -- 刷出来了 | ||
830 | + local mpool = {} | ||
831 | + for _, mid in ipairs(globalCsv.adv_egg_treasureMonster_id) do | ||
832 | + local monster = csvdb["event_monsterCsv"][mid] | ||
833 | + if (not mineCo[mid] or monster.limit == 0 or mineCo[mid] < monster.limit) and monster.showup > 0 then | ||
834 | + mpool[mid] = {monster.showup} | ||
835 | + end | ||
836 | + end | ||
837 | + if next(mpool) then | ||
838 | + local idx = math.randomInt(1, ln) | ||
839 | + local cur = stagePool["global"][AdvCodeRandomStage][idx] | ||
840 | + giveEvent(cur["room"], cur["block"], AdvEventType.Monster, math.randWeight(mpool, 1)) | ||
841 | + table.remove(stagePool["global"][AdvCodeRandomStage], idx) | ||
842 | + ln = ln - 1 | ||
843 | + had = true | ||
844 | + end | ||
845 | + end | ||
846 | + end | ||
847 | + if had then | ||
848 | + mineCh = nil | ||
849 | + else | ||
850 | + mineCh = math.min(mineCh + globalCsv.adv_egg_treasureMonster_showup_add, 100) | ||
851 | + end | ||
852 | + advMine[1].ch = mineCh | ||
853 | + self.adv.owner:setProperty("advMine", advMine) | ||
854 | + end | ||
855 | + | ||
814 | 856 | ||
815 | if mapCsvData.clearType == 1 and not haveBoss then | 857 | if mapCsvData.clearType == 1 and not haveBoss then |
816 | if not next(monsterEvents) then | 858 | if not next(monsterEvents) then |
src/adv/AdvPassive.lua
@@ -9,6 +9,7 @@ Filter.BUFF_BY_ID = 6 -- 指定id的buff | @@ -9,6 +9,7 @@ Filter.BUFF_BY_ID = 6 -- 指定id的buff | ||
9 | Filter.CAMP = 7 -- 玩家是指定阵营 | 9 | Filter.CAMP = 7 -- 玩家是指定阵营 |
10 | Filter.RANGE = 8 -- 筛选范围 (触发是地块) | 10 | Filter.RANGE = 8 -- 筛选范围 (触发是地块) |
11 | Filter.CLASSIFY = 9 -- 标签 | 11 | Filter.CLASSIFY = 9 -- 标签 |
12 | +Filter.NO_BUFF_BY_ID = 10 -- 没有指定id的buff | ||
12 | 13 | ||
13 | local FilterFactory = {} | 14 | local FilterFactory = {} |
14 | FilterFactory[Filter.HP_UP_WITH_EQUAL] = function (_Filter) | 15 | FilterFactory[Filter.HP_UP_WITH_EQUAL] = function (_Filter) |
@@ -47,23 +48,27 @@ FilterFactory[Filter.CAMP] = function (_Filter) | @@ -47,23 +48,27 @@ FilterFactory[Filter.CAMP] = function (_Filter) | ||
47 | return role:getHerosCamp(role:getProperty("advTeam").heros) == self.value | 48 | return role:getHerosCamp(role:getProperty("advTeam").heros) == self.value |
48 | end | 49 | end |
49 | end | 50 | end |
50 | - | ||
51 | FilterFactory[Filter.RANGE] = function (_Filter) | 51 | FilterFactory[Filter.RANGE] = function (_Filter) |
52 | _Filter._execute = function (self, target, params) | 52 | _Filter._execute = function (self, target, params) |
53 | - if self.owner.blockId and self.owner.roomId and params.blockId and params.roomId then | 53 | + if params and self.owner.blockId and self.owner.roomId and params.blockId and params.roomId then |
54 | local distance = self.owner.battle.adv:getCurMap():getDistance(self.owner.roomId, self.owner.blockId, params.roomId, params.blockId) | 54 | local distance = self.owner.battle.adv:getCurMap():getDistance(self.owner.roomId, self.owner.blockId, params.roomId, params.blockId) |
55 | return distance ~= -1 and distance <= self.value | 55 | return distance ~= -1 and distance <= self.value |
56 | end | 56 | end |
57 | return false | 57 | return false |
58 | end | 58 | end |
59 | end | 59 | end |
60 | - | ||
61 | FilterFactory[Filter.CLASSIFY] = function (_Filter) | 60 | FilterFactory[Filter.CLASSIFY] = function (_Filter) |
62 | _Filter._execute = function (self, target) | 61 | _Filter._execute = function (self, target) |
63 | return target.isClassify and target:isClassify(self.value) | 62 | return target.isClassify and target:isClassify(self.value) |
64 | end | 63 | end |
65 | end | 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 | function Filter:ctor(params) | 72 | function Filter:ctor(params) |
68 | self.owner = params.owner | 73 | self.owner = params.owner |
69 | self.skill = params.skill | 74 | self.skill = params.skill |
@@ -87,6 +92,9 @@ function Filter:getTarget(params) | @@ -87,6 +92,9 @@ function Filter:getTarget(params) | ||
87 | if self.oType == 2 and params.releaser then | 92 | if self.oType == 2 and params.releaser then |
88 | target = params.releaser | 93 | target = params.releaser |
89 | end | 94 | end |
95 | + if self.oType == 3 then | ||
96 | + target = self.owner.battle.player | ||
97 | + end | ||
90 | return target | 98 | return target |
91 | end | 99 | end |
92 | 100 | ||
@@ -95,9 +103,8 @@ function Filter:execute(params) | @@ -95,9 +103,8 @@ function Filter:execute(params) | ||
95 | if not target then | 103 | if not target then |
96 | return | 104 | return |
97 | end | 105 | end |
98 | - if self:_execute(target) then | ||
99 | - return self:_execute(target, params) | ||
100 | - end | 106 | + |
107 | + return self:_execute(target, params) | ||
101 | end | 108 | end |
102 | 109 | ||
103 | -->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | 110 | -->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |
@@ -203,7 +210,7 @@ PassiveCondFactory[Passive.PLAYER_BUFF] = PassiveCondFactory[Passive.GET_BUFF] | @@ -203,7 +210,7 @@ PassiveCondFactory[Passive.PLAYER_BUFF] = PassiveCondFactory[Passive.GET_BUFF] | ||
203 | 210 | ||
204 | PassiveCondFactory[Passive.PLAYER_BUFF_CLASSIFY] = function(_Passive) | 211 | PassiveCondFactory[Passive.PLAYER_BUFF_CLASSIFY] = function(_Passive) |
205 | _Passive._trigger = function(self, params) | 212 | _Passive._trigger = function(self, params) |
206 | - if params.classify:sismember(self.passiveData.value) then | 213 | + if params.classify:sismember(self.passiveData.value, " ") then |
207 | return true | 214 | return true |
208 | end | 215 | end |
209 | end | 216 | end |
@@ -340,6 +347,7 @@ function Passive:canEffect(effType, effValue) | @@ -340,6 +347,7 @@ function Passive:canEffect(effType, effValue) | ||
340 | end | 347 | end |
341 | 348 | ||
342 | function Passive:effect(triggerPms) | 349 | function Passive:effect(triggerPms) |
350 | + local hadEffect = false | ||
343 | for _, effect in ipairs(self.effects) do | 351 | for _, effect in ipairs(self.effects) do |
344 | local effType = effect[1] | 352 | local effType = effect[1] |
345 | local effValue = effect[2] | 353 | local effValue = effect[2] |
@@ -348,10 +356,14 @@ function Passive:effect(triggerPms) | @@ -348,10 +356,14 @@ function Passive:effect(triggerPms) | ||
348 | table.insert(otherPms, effect[i]) | 356 | table.insert(otherPms, effect[i]) |
349 | end | 357 | end |
350 | if self:canEffect(effType, effValue) then | 358 | if self:canEffect(effType, effValue) then |
359 | + hadEffect = true | ||
351 | self["effect" .. effType](self, effValue, triggerPms, table.unpack(otherPms)) | 360 | self["effect" .. effType](self, effValue, triggerPms, table.unpack(otherPms)) |
352 | end | 361 | end |
353 | end | 362 | end |
354 | - | 363 | + if hadEffect then |
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) | ||
366 | + end | ||
355 | if self.count > 0 then | 367 | if self.count > 0 then |
356 | self.count = self.count < 999 and self.count - 1 or self.count | 368 | self.count = self.count < 999 and self.count - 1 or self.count |
357 | self.round = self.passiveData.round | 369 | self.round = self.passiveData.round |
@@ -401,6 +413,8 @@ function Passive:trigger(condType, params) --触发检查 | @@ -401,6 +413,8 @@ function Passive:trigger(condType, params) --触发检查 | ||
401 | params = params or {} | 413 | params = params or {} |
402 | if self.isDel or self.owner.isDead then return end | 414 | if self.isDel or self.owner.isDead then return end |
403 | if self:getCondType() ~= condType then return end | 415 | if self:getCondType() ~= condType then return end |
416 | + | ||
417 | + buglog("Passive", "who: %s trigger id: %s", self.owner.monsterId, self.id) | ||
404 | if not self:canTrigger() then return end | 418 | if not self:canTrigger() then return end |
405 | if self._trigger then | 419 | if self._trigger then |
406 | if not self:_trigger(params) then return end --检查 | 420 | if not self:_trigger(params) then return end --检查 |
@@ -597,5 +611,9 @@ function Passive:effect16(value, triggerPms, changeType) | @@ -597,5 +611,9 @@ function Passive:effect16(value, triggerPms, changeType) | ||
597 | self.owner.battle.adv:blockDropChange(changeType, blocks) | 611 | self.owner.battle.adv:blockDropChange(changeType, blocks) |
598 | end | 612 | end |
599 | 613 | ||
614 | +--17=玩家获得buff | ||
615 | +function Passive:effect17(value, triggerPms) | ||
616 | + self.owner.battle.player:addBuff(value, self.owner) | ||
617 | +end | ||
600 | 618 | ||
601 | return Passive | 619 | return Passive |
602 | \ No newline at end of file | 620 | \ No newline at end of file |
src/adv/AdvPlayer.lua
@@ -144,7 +144,7 @@ function BaseObject:getDisablePassiveCount() | @@ -144,7 +144,7 @@ function BaseObject:getDisablePassiveCount() | ||
144 | end | 144 | end |
145 | 145 | ||
146 | function BaseObject:getDisableAuraCount() | 146 | function BaseObject:getDisableAuraCount() |
147 | - local count | 147 | + local count = 0 |
148 | for _, buff in ipairs(self.buffs) do | 148 | for _, buff in ipairs(self.buffs) do |
149 | if not buff:isHide() and buff:getType() == Buff.DISABLE_AURA then | 149 | if not buff:isHide() and buff:getType() == Buff.DISABLE_AURA then |
150 | if buff:effect() == 0 then | 150 | if buff:effect() == 0 then |
@@ -662,7 +662,7 @@ end | @@ -662,7 +662,7 @@ end | ||
662 | 662 | ||
663 | function Enemy:getObstacle() | 663 | function Enemy:getObstacle() |
664 | local obstacle = csvdb["event_monsterCsv"][self.monsterId].obstacle | 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 | obstacle = 1 | 666 | obstacle = 1 |
667 | end | 667 | end |
668 | return obstacle | 668 | return obstacle |
@@ -699,7 +699,7 @@ function Enemy:checkAuraBuff(buffs) | @@ -699,7 +699,7 @@ function Enemy:checkAuraBuff(buffs) | ||
699 | if buff then | 699 | if buff then |
700 | buff:uncover(info.exist and -info.count or -1, true) | 700 | buff:uncover(info.exist and -info.count or -1, true) |
701 | end | 701 | end |
702 | - elseif count > 0 then | 702 | + elseif info.count > 0 then |
703 | self:addBuff(buffId, nil, info.count) | 703 | self:addBuff(buffId, nil, info.count) |
704 | end | 704 | end |
705 | end | 705 | end |
@@ -847,10 +847,6 @@ function Player:addBuff(buffId, releaser) | @@ -847,10 +847,6 @@ function Player:addBuff(buffId, releaser) | ||
847 | self.battle.adv:checkAchievement(self.battle.adv.AchievType.GetBuff, 1, buffId) | 847 | self.battle.adv:checkAchievement(self.battle.adv.AchievType.GetBuff, 1, buffId) |
848 | self.battle.adv:pushBackEvent(AdvBackEventType.Buff, {buffId = buffId}) | 848 | self.battle.adv:pushBackEvent(AdvBackEventType.Buff, {buffId = buffId}) |
849 | self.battle:triggerPassive(Passive.PLAYER_BUFF, {buffId = buffId}) | 849 | self.battle:triggerPassive(Passive.PLAYER_BUFF, {buffId = buffId}) |
850 | - local buffData = csvdb["adv_map_buffCsv"][buffId] | ||
851 | - if buffData and buffData.show:sismember(1, " ") then | ||
852 | - self.battle.adv:pushBackEvent(AdvBackEventType.BuffEffect, {etype = 1}) | ||
853 | - end | ||
854 | end | 850 | end |
855 | return status | 851 | return status |
856 | end | 852 | end |
src/agent.lua
@@ -356,11 +356,6 @@ skynet.start(function() | @@ -356,11 +356,6 @@ skynet.start(function() | ||
356 | return info | 356 | return info |
357 | end) | 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 | cs = queue() | 359 | cs = queue() |
365 | 360 | ||
366 | pvpd = skynet.localname(".pvpcross") | 361 | pvpd = skynet.localname(".pvpcross") |
src/main.lua
@@ -2,23 +2,41 @@ local skynet = require "skynet" | @@ -2,23 +2,41 @@ local skynet = require "skynet" | ||
2 | 2 | ||
3 | local max_client = tonumber(skynet.getenv("max_client")) | 3 | local max_client = tonumber(skynet.getenv("max_client")) |
4 | local max_queue = tonumber(skynet.getenv("max_queue")) | 4 | 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 | skynet.start(function() | 8 | skynet.start(function() |
7 | print("Server start") | 9 | print("Server start") |
8 | skynet.newservice("debug_console", tonumber(skynet.getenv("debug_port"))) | 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 | local httpd = skynet.newservice("services/httpweb", tonumber(skynet.getenv("httpweb_port"))) | 32 | local httpd = skynet.newservice("services/httpweb", tonumber(skynet.getenv("httpweb_port"))) |
11 | local watchdog = skynet.newservice("services/watchdog", max_client) | 33 | local watchdog = skynet.newservice("services/watchdog", max_client) |
12 | 34 | ||
35 | + | ||
13 | skynet.call(watchdog, "lua", "start", { | 36 | skynet.call(watchdog, "lua", "start", { |
14 | port = tonumber(skynet.getenv("server_port")), | 37 | port = tonumber(skynet.getenv("server_port")), |
15 | maxclient = max_client + max_queue + 10, | 38 | maxclient = max_client + max_queue + 10, |
16 | httpd = httpd, | 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 | skynet.exit() | 42 | skynet.exit() |
src/models/Activity.lua
@@ -19,8 +19,18 @@ Activity.ActivityType = { | @@ -19,8 +19,18 @@ Activity.ActivityType = { | ||
19 | AdvDraw = 13, --拾荒抽周 资助 | 19 | AdvDraw = 13, --拾荒抽周 资助 |
20 | OpenBox = 14, --拆解周 时钟箱 | 20 | OpenBox = 14, --拆解周 时钟箱 |
21 | RaceDraw = 16, -- 定向招募活动 | 21 | RaceDraw = 16, -- 定向招募活动 |
22 | -} | ||
23 | 22 | ||
23 | + ChallengeLevel = 17, -- 挑战关卡活动 | ||
24 | + Exchange = 18, -- 兑换活动 | ||
25 | + HangDrop = 19, -- 挂机掉落活动 | ||
26 | + Gachakon = 20, -- 扭蛋活动 | ||
27 | + | ||
28 | + WishHeroPool = 23, -- 心愿卡池 | ||
29 | + ActHeroPool = 24, -- 活动卡池 | ||
30 | + ActShopGoods = 25, -- 活动商品 | ||
31 | + | ||
32 | + Crisis = 26, -- 宝藏怪活动 | ||
33 | +} | ||
24 | 34 | ||
25 | local function checkActivityType(activityType) | 35 | local function checkActivityType(activityType) |
26 | if type(activityType) == "string" then | 36 | if type(activityType) == "string" then |
@@ -36,6 +46,13 @@ function Activity:ctor(properties) | @@ -36,6 +46,13 @@ function Activity:ctor(properties) | ||
36 | self._isOpen = {} | 46 | self._isOpen = {} |
37 | end | 47 | end |
38 | 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 | + | ||
39 | 56 | ||
40 | Activity.schema = { | 57 | Activity.schema = { |
41 | actime = {"table", {}}, -- 最近检查某项活动的开始时间 {id = time} | 58 | actime = {"table", {}}, -- 最近检查某项活动的开始时间 {id = time} |
@@ -48,6 +65,14 @@ Activity.schema = { | @@ -48,6 +65,14 @@ Activity.schema = { | ||
48 | act12 = {"table", {}}, -- {0 = 抽卡次数, 1=1, 2=1} 抽卡周活动 1表示领取过该档位的奖励 | 65 | act12 = {"table", {}}, -- {0 = 抽卡次数, 1=1, 2=1} 抽卡周活动 1表示领取过该档位的奖励 |
49 | act13 = {"table", {}}, -- {0 = 拾荒消耗远古金币数量, 1=1, 2=1} 拾荒周活动 1表示领取过该档位的奖励 | 66 | act13 = {"table", {}}, -- {0 = 拾荒消耗远古金币数量, 1=1, 2=1} 拾荒周活动 1表示领取过该档位的奖励 |
50 | act14 = {"table", {}}, -- {0 = 拆解数量, 1=1, 2=1} 拆解周活动 1表示领取过该档位的奖励 | 67 | act14 = {"table", {}}, -- {0 = 拆解数量, 1=1, 2=1} 拆解周活动 1表示领取过该档位的奖励 |
68 | + | ||
69 | + act17 = {"table", {}}, -- {id=关卡星数, totalDmg=Boss总伤害} | ||
70 | + act18 = {"table", {}, true}, -- {id=兑换数量} | ||
71 | + act19 = {"number", 0}, -- {挂机信息} | ||
72 | + act20 = {"table", {}}, -- {id=扭蛋抽出数量} | ||
73 | + | ||
74 | + act24 = {"table", {}, true}, -- 活动卡池 {id=repaynum} | ||
75 | + act26 = {"table", {}}, -- {task = {id = count}, socre = {id = status}} | ||
51 | } | 76 | } |
52 | 77 | ||
53 | function Activity:data() | 78 | function Activity:data() |
@@ -61,6 +86,12 @@ function Activity:data() | @@ -61,6 +86,12 @@ function Activity:data() | ||
61 | act12 = self:getProperty("act12"), | 86 | act12 = self:getProperty("act12"), |
62 | act13 = self:getProperty("act13"), | 87 | act13 = self:getProperty("act13"), |
63 | act14 = self:getProperty("act14"), | 88 | act14 = self:getProperty("act14"), |
89 | + | ||
90 | + act17 = self:getProperty("act17"), | ||
91 | + act18 = self:getProperty("act18"), | ||
92 | + act19 = self:getProperty("act19"), | ||
93 | + act20 = self:getProperty("act20"), | ||
94 | + act26 = self:getProperty("act26"), | ||
64 | } | 95 | } |
65 | end | 96 | end |
66 | 97 | ||
@@ -138,6 +169,15 @@ function Activity:isOpen(activityType) | @@ -138,6 +169,15 @@ function Activity:isOpen(activityType) | ||
138 | return false | 169 | return false |
139 | end | 170 | end |
140 | 171 | ||
172 | +function Activity:isOpenById(id, activityType) | ||
173 | + activityType = checkActivityType(activityType) | ||
174 | + local cfg = csvdb["activity_ctrlCsv"][id] | ||
175 | + if not cfg then return false end | ||
176 | + if activityType ~= 0 and cfg.showType ~= activityType then return false end | ||
177 | + | ||
178 | + return self._isOpen[id] | ||
179 | +end | ||
180 | + | ||
141 | function Activity:getActData(actType) | 181 | function Activity:getActData(actType) |
142 | actType = checkActivityType(actType) | 182 | actType = checkActivityType(actType) |
143 | return self:getProperty("act" .. actType) | 183 | return self:getProperty("act" .. actType) |
@@ -160,6 +200,7 @@ function Activity:checkActivityStatus(now, isCrossDay, notify) | @@ -160,6 +200,7 @@ function Activity:checkActivityStatus(now, isCrossDay, notify) | ||
160 | 200 | ||
161 | if isOpen then | 201 | if isOpen then |
162 | if actime[actId] and actime[actId] == startTime then -- 还是之前的状态 开放中 | 202 | if actime[actId] and actime[actId] == startTime then -- 还是之前的状态 开放中 |
203 | + self:onLoginActivity(actId) | ||
163 | else -- 重置 | 204 | else -- 重置 |
164 | actime[actId] = startTime | 205 | actime[actId] = startTime |
165 | self:closeActivity(actId, notify, true) | 206 | self:closeActivity(actId, notify, true) |
@@ -400,7 +441,8 @@ activityFunc[Activity.ActivityType.CalendaTask] = { | @@ -400,7 +441,8 @@ activityFunc[Activity.ActivityType.CalendaTask] = { | ||
400 | local towerInfo = role:getProperty("towerInfo") | 441 | local towerInfo = role:getProperty("towerInfo") |
401 | role:checkTaskEnter("TowerPass", {level = towerInfo.l}) | 442 | role:checkTaskEnter("TowerPass", {level = towerInfo.l}) |
402 | --"PvpWin" | 443 | --"PvpWin" |
403 | - role:checkTaskEnter("HangPass", {}) | 444 | + --role:checkTaskEnter("HangPass", {id = 0}) |
445 | + role:checkCalendaTask(true, 15, 3) | ||
404 | role:checkTaskEnter("HeroStarCollect", {}) | 446 | role:checkTaskEnter("HeroStarCollect", {}) |
405 | role:checkTaskEnter("RuneQualityCollect", {}) | 447 | role:checkTaskEnter("RuneQualityCollect", {}) |
406 | 448 | ||
@@ -409,12 +451,101 @@ activityFunc[Activity.ActivityType.CalendaTask] = { | @@ -409,12 +451,101 @@ activityFunc[Activity.ActivityType.CalendaTask] = { | ||
409 | -- end, | 451 | -- end, |
410 | } | 452 | } |
411 | 453 | ||
454 | +-- 兑换 | ||
455 | +activityFunc[Activity.ActivityType.Exchange] = { | ||
456 | + ["init"] = function(self, actType, isCrossDay, notify, actId) | ||
457 | + local actData = self:getActData(actType) or {} | ||
458 | + actData[actId] = {} | ||
459 | + self:updateActData(actType, actData, not notify) | ||
460 | + end, | ||
461 | + ["crossDay"] = function(self, actType, notify, actId) | ||
462 | + local actData = self:getActData(actType) or {} | ||
463 | + local lastTs = actData["ts"] or 0 | ||
464 | + local timeNow = skynet.timex() | ||
465 | + local cfg = csvdb["activity_ctrlCsv"][actId] | ||
466 | + if not cfg then return end | ||
467 | + local refreshTimes = cfg.condition2:toArray(false, "=") | ||
468 | + for i = 1, #refreshTimes do | ||
469 | + local rt = toUnixtime(refreshTimes[1]..string_format("%02x", RESET_TIME)) | ||
470 | + if timeNow >= rt and rt > lastTs then | ||
471 | + lastTs = rt | ||
472 | + actData = {} | ||
473 | + end | ||
474 | + end | ||
475 | + if next(actData) then | ||
476 | + actData["ts"] = lastTs | ||
477 | + self:updateActData(actType, actData, not notify) | ||
478 | + end | ||
479 | + end, | ||
480 | + ["close"] = function(self, actType, notify, actId) | ||
481 | + local actData = self:getActData(actType) or {} | ||
482 | + actData[actId] = nil | ||
483 | + self:updateActData(actType, actData, not notify) | ||
484 | + end, | ||
485 | +} | ||
486 | + | ||
487 | +-- 扭蛋机 | ||
488 | +activityFunc[Activity.ActivityType.Gachakon] = { | ||
489 | + ["init"] = function(self, actType, isCrossDay, notify, actId) | ||
490 | + self:updateActData(actType, {}, not notify) | ||
491 | + end, | ||
492 | + ["crossDay"] = function(self, actType, notify) | ||
493 | + self:updateActData(actType, {}, not notify) | ||
494 | + end, | ||
495 | +} | ||
496 | + | ||
497 | +-- 活动卡池 | ||
498 | +activityFunc[Activity.ActivityType.ActHeroPool] = { | ||
499 | + ["init"] = function(self, actType, isCrossDay, notify, actId) | ||
500 | + end, | ||
501 | + ["close"] = function(self, actType, notify, actId) | ||
502 | + local actData = self:getActData(actType) | ||
503 | + local cfg = csvdb["activity_ctrlCsv"][actId] | ||
504 | + if not cfg then return end | ||
505 | + actData[cfg.condition] = nil | ||
506 | + self:updateActData(actType, actData, not notify) | ||
507 | + end, | ||
508 | +} | ||
509 | + | ||
510 | +-- 挂机掉落 | ||
511 | +activityFunc[Activity.ActivityType.HangDrop] = { | ||
512 | + ["init"] = function(self, actType, isCrossDay, notify, actId) | ||
513 | + local actime = self:getProperty("actime") | ||
514 | + local ctime = self.owner:getProperty("ctime") | ||
515 | + local startTime = math.max(actime[actId], ctime) | ||
516 | + local actData = self:getActData(actType) or 0 | ||
517 | + local cfg = csvdb["activity_putCsv"][actId] | ||
518 | + if not cfg then return end | ||
519 | + actData = startTime | ||
520 | + self:updateActData(actType, actData, not notify) | ||
521 | + end | ||
522 | +} | ||
523 | + | ||
524 | +--ChallengeLevel | ||
525 | +activityFunc[Activity.ActivityType.ChallengeLevel] = { | ||
526 | + ["init"] = function(self, actType, isCrossDay, notify, actId) | ||
527 | + self:getBattleTicket(actId) | ||
528 | + end, | ||
529 | + ["login"] = function(self, actType, actId) | ||
530 | + self:getBattleTicket(actId) | ||
531 | + end | ||
532 | +} | ||
533 | + | ||
534 | +function Activity:onLoginActivity(actId) | ||
535 | + local actData = csvdb["activity_ctrlCsv"][actId] | ||
536 | + if not actData then return end | ||
537 | + local actType = actData.showType | ||
538 | + if activityFunc[actType] and activityFunc[actType]['login'] then | ||
539 | + activityFunc[actType]["login"](self, actType, actId) | ||
540 | + end | ||
541 | +end | ||
542 | + | ||
412 | function Activity:initActivity(actId, isCrossDay, notify) | 543 | function Activity:initActivity(actId, isCrossDay, notify) |
413 | local actData = csvdb["activity_ctrlCsv"][actId] | 544 | local actData = csvdb["activity_ctrlCsv"][actId] |
414 | if not actData then return end | 545 | if not actData then return end |
415 | local actType = actData.showType | 546 | local actType = actData.showType |
416 | - if activityFunc[actType] and activityFunc[actType]['close'] then | ||
417 | - activityFunc[actType]["init"](self, actType, isCrossDay, notify) | 547 | + if activityFunc[actType] and activityFunc[actType]['init'] then |
548 | + activityFunc[actType]["init"](self, actType, isCrossDay, notify, actId) | ||
418 | end | 549 | end |
419 | end | 550 | end |
420 | 551 | ||
@@ -423,10 +554,13 @@ function Activity:closeActivity(actId, notify, notUpdateAct) | @@ -423,10 +554,13 @@ function Activity:closeActivity(actId, notify, notUpdateAct) | ||
423 | if not actData then return end | 554 | if not actData then return end |
424 | local actType = actData.showType | 555 | local actType = actData.showType |
425 | if activityFunc[actType] and activityFunc[actType]['close'] then | 556 | if activityFunc[actType] and activityFunc[actType]['close'] then |
426 | - activityFunc[actType]["close"](self, actType, notify) | 557 | + activityFunc[actType]["close"](self, actType, notify, actId) |
558 | + self:recycleActItem(actId) | ||
427 | end | 559 | end |
428 | if Activity.schema["act".. actType] then | 560 | if Activity.schema["act".. actType] then |
429 | - self:updateActData(actType, Activity.schema["act" .. actType][2], not notify or notUpdateAct) | 561 | + if not Activity.schema["act" .. actType][3] then |
562 | + self:updateActData(actType, Activity.schema["act" .. actType][2], not notify or notUpdateAct) | ||
563 | + end | ||
430 | end | 564 | end |
431 | end | 565 | end |
432 | 566 | ||
@@ -436,7 +570,7 @@ function Activity:refreshDailyData(notify) | @@ -436,7 +570,7 @@ function Activity:refreshDailyData(notify) | ||
436 | if status and actData then | 570 | if status and actData then |
437 | local actType = actData.showType | 571 | local actType = actData.showType |
438 | if activityFunc[actType] and activityFunc[actType]['crossDay'] then | 572 | if activityFunc[actType] and activityFunc[actType]['crossDay'] then |
439 | - activityFunc[actType]["crossDay"](self, actType, notify) | 573 | + activityFunc[actType]["crossDay"](self, actType, notify, actId) |
440 | end | 574 | end |
441 | end | 575 | end |
442 | end | 576 | end |
@@ -453,8 +587,8 @@ end | @@ -453,8 +587,8 @@ end | ||
453 | -- 获取此次挂机掉落翻倍时长 | 587 | -- 获取此次挂机掉落翻倍时长 |
454 | function Activity:getActHangDoubleTime(lastTs, nowTs) | 588 | function Activity:getActHangDoubleTime(lastTs, nowTs) |
455 | local type = "DoubleDrop" | 589 | local type = "DoubleDrop" |
456 | - local actId = checkActivityType(type) | ||
457 | - local isOpen = self:isOpen(type) | 590 | + --local actId = checkActivityType(type) |
591 | + local isOpen, actId = self:isOpen(type) | ||
458 | local openTs = self:getProperty("actime")[actId] or 0 | 592 | local openTs = self:getProperty("actime")[actId] or 0 |
459 | local timeNow = skynet.timex() | 593 | local timeNow = skynet.timex() |
460 | lastTs = math.max(lastTs, openTs) | 594 | lastTs = math.max(lastTs, openTs) |
@@ -529,5 +663,121 @@ function Activity:getPaySignReward() | @@ -529,5 +663,121 @@ function Activity:getPaySignReward() | ||
529 | --SendPacket(actionCodes.Activity_actPaySignRpc, MsgPack.pack(role:packReward(reward, change))) | 663 | --SendPacket(actionCodes.Activity_actPaySignRpc, MsgPack.pack(role:packReward(reward, change))) |
530 | end | 664 | end |
531 | 665 | ||
666 | +-- 回收活动道具 | ||
667 | +function Activity:recycleActItem(actId) | ||
668 | + local role = self.owner | ||
669 | + local actCfg = csvdb["activity_ctrlCsv"][actId] | ||
670 | + if not actCfg then return end | ||
671 | + local gift = {} | ||
672 | + local costs = {} | ||
673 | + for _, arr in ipairs(actCfg.recycle:toTableArray(true)) do | ||
674 | + local fromId, toId, toNum = arr[1], arr[2], arr[3] | ||
675 | + local itemCount = role:getItemCount(fromId) | ||
676 | + if itemCount > 0 then | ||
677 | + costs[fromId] = (costs[fromId] or 0) + itemCount | ||
678 | + gift[toId] = toNum * itemCount | ||
679 | + end | ||
680 | + end | ||
681 | + if next(costs) then | ||
682 | + local itemStr = "" | ||
683 | + for k, v in pairs(costs) do | ||
684 | + if itemStr ~= "" then | ||
685 | + itemStr = itemStr .. " " | ||
686 | + end | ||
687 | + itemStr = itemStr .. k .. "=" .. v | ||
688 | + end | ||
689 | + role:costItems(costs, {log = {desc = "actRecycle"}}) | ||
690 | + role:sendMail(actCfg.recycle_email, nil, gift, {itemStr}) | ||
691 | + end | ||
692 | +end | ||
693 | + | ||
694 | +-- 活动挑战关卡计算门票 | ||
695 | +function Activity:getBattleTicket(actId) | ||
696 | + local role = self.owner | ||
697 | + local createTs = role:getProperty("ctime") | ||
698 | + local actCfg = csvdb["activity_ctrlCsv"][actId] | ||
699 | + if not actCfg then return 0 end | ||
700 | + | ||
701 | + local actStartTime = 0 | ||
702 | + local openTimes = actCfg.time:toArray(false, "=") | ||
703 | + actStartTime = toUnixtime(openTimes[1]..string_format("%02x", RESET_TIME)) | ||
704 | + local actData = self:getActData("ChallengeLevel") or {} | ||
705 | + local startTs = actData["ts"] or math.max(actStartTime, createTs) | ||
706 | + local timeNow = skynet.timex() | ||
707 | + local modify = false | ||
708 | + local arr = actCfg.condition2:toArray(true, "=") | ||
709 | + | ||
710 | + local ticketId, init, limit, duration = arr[1] or 0, arr[2] or 0, arr[3] or 0, arr[4] or 10000 | ||
711 | + | ||
712 | + local count = actData["ticket"] or init | ||
713 | + local add = math.max(math.floor((timeNow - startTs) / (duration * 60)), 0) | ||
714 | + | ||
715 | + local newCount= math.min(count + add, limit) | ||
716 | + if newCount ~= count or newCount >= limit then | ||
717 | + modify = true | ||
718 | + end | ||
719 | + add = newCount - count | ||
720 | + | ||
721 | + if modify or not next(actData) then | ||
722 | + actData["ticket"] = newCount | ||
723 | + actData["ts"] = newCount >= limit and timeNow or (startTs + add * duration * 60) | ||
724 | + self:updateActData("ChallengeLevel", actData) | ||
725 | + end | ||
726 | +end | ||
727 | + | ||
728 | +activityFunc[Activity.ActivityType.ActShopGoods] = { | ||
729 | + ["init"] = function(self, actType, isCrossDay, notify, actId) | ||
730 | + end, | ||
731 | + ["close"] = function(self, actType, notify) | ||
732 | + local rechargeRecord = self.owner.storeData:getProperty("payR") | ||
733 | + for id, cfg in pairs(csvdb["shop_rechargeCsv"]) do | ||
734 | + if cfg.shop == 3 and cfg.type == ShopPackType.ActShopPack then | ||
735 | + rechargeRecord[id] = nil | ||
736 | + end | ||
737 | + end | ||
738 | + self.owner.storeData:updateProperty({field="payR", value=rechargeRecord}) | ||
739 | + end, | ||
740 | +} | ||
741 | + | ||
742 | + | ||
743 | + | ||
744 | +activityFunc[Activity.ActivityType.Crisis] = { | ||
745 | + ["check"] = function(self, actType, notify, atype, count) -- 检查 | ||
746 | + count = count or 1 | ||
747 | + local isOpen, actId = self:isOpen(actType) | ||
748 | + local actData = self:getActData(actType) or {} | ||
749 | + actData.task = actData.task or {} | ||
750 | + local change = false | ||
751 | + local actCsv = csvdb["activity_crisisCsv"][actId] | ||
752 | + for id, actSet in pairs(actCsv) do | ||
753 | + if actSet.type == atype then | ||
754 | + local status = actData.task[id] or 0 | ||
755 | + status = status + count | ||
756 | + if status >= actSet.condition1 then | ||
757 | + local reward | ||
758 | + if actSet.loop == 1 then | ||
759 | + local rcount = math.floor(status / actSet.condition1) | ||
760 | + local reward = actSet.reward:toNumMap() | ||
761 | + for itemId, itemC in pairs(reward) do | ||
762 | + reward[itemId] = itemC * rcount | ||
763 | + end | ||
764 | + status = status % actSet.condition1 | ||
765 | + else | ||
766 | + reward = actSet.reward | ||
767 | + status = -1 | ||
768 | + end | ||
769 | + self.owner:award(reward, {log = {desc = "activity_crisis"}, notNotify = not notify}) | ||
770 | + end | ||
771 | + actData.task[id] = status | ||
772 | + change = true | ||
773 | + end | ||
774 | + end | ||
775 | + if change then | ||
776 | + -- 更新下排行榜 | ||
777 | + self.owner:updateRankCommon(RANK_TYPE.ActCrisis, self.owner:getItemCount(ItemId.CrisisScore)) | ||
778 | + self:updateActData(actType, actData) | ||
779 | + end | ||
780 | + end, | ||
781 | +} | ||
532 | 782 | ||
533 | return Activity | 783 | return Activity |
src/models/Email.lua
@@ -48,10 +48,10 @@ function Email:data() | @@ -48,10 +48,10 @@ function Email:data() | ||
48 | 48 | ||
49 | if emailData then | 49 | if emailData then |
50 | -- 如果内容是直接插入到数据库 | 50 | -- 如果内容是直接插入到数据库 |
51 | - if content == "" and emailData.body ~= "" then | ||
52 | - content = io.readfile("src/" .. emailData.body) or "" | ||
53 | - content = content:format(table.unpack(contentPms)) | ||
54 | - end | 51 | + --if content == "" and emailData.body ~= "" then |
52 | + -- content = io.readfile("src/" .. emailData.body) or "" | ||
53 | + -- content = content:format(table.unpack(contentPms)) | ||
54 | + --end | ||
55 | 55 | ||
56 | if title == "" and emailData.title ~= "" then | 56 | if title == "" and emailData.title ~= "" then |
57 | title = emailData.title | 57 | title = emailData.title |
@@ -67,12 +67,14 @@ function Email:data() | @@ -67,12 +67,14 @@ function Email:data() | ||
67 | end | 67 | end |
68 | 68 | ||
69 | return { | 69 | return { |
70 | + cfgId = emailId, | ||
70 | id = self:getProperty("id"), | 71 | id = self:getProperty("id"), |
71 | status = self:getProperty("status"), | 72 | status = self:getProperty("status"), |
72 | createtime = self:getProperty("createtime"), | 73 | createtime = self:getProperty("createtime"), |
73 | title = title, | 74 | title = title, |
74 | stitle = stitle, | 75 | stitle = stitle, |
75 | content = content, | 76 | content = content, |
77 | + contentPms = contentPms, | ||
76 | attachments = attachments, | 78 | attachments = attachments, |
77 | } | 79 | } |
78 | end | 80 | end |
src/models/HeroPlugin.lua
@@ -126,11 +126,11 @@ function HeroPlugin.bind(Hero) | @@ -126,11 +126,11 @@ function HeroPlugin.bind(Hero) | ||
126 | end | 126 | end |
127 | 127 | ||
128 | -- 羁绊加成 | 128 | -- 羁绊加成 |
129 | - if params.activeRelation then | ||
130 | - for k, attName in pairs(AttsEnumEx) do | ||
131 | - attrs[attName] = attrs[attName] + addAttr(attrs[attName], params.activeRelation[attName], 1, attName) | ||
132 | - end | ||
133 | - end | 129 | + -- if params.activeRelation then |
130 | + -- for k, attName in pairs(AttsEnumEx) do | ||
131 | + -- attrs[attName] = attrs[attName] + addAttr(attrs[attName], params.activeRelation[attName], 1, attName) | ||
132 | + -- end | ||
133 | + -- end | ||
134 | return attrs | 134 | return attrs |
135 | end | 135 | end |
136 | 136 | ||
@@ -224,8 +224,10 @@ function HeroPlugin.bind(Hero) | @@ -224,8 +224,10 @@ function HeroPlugin.bind(Hero) | ||
224 | 224 | ||
225 | 225 | ||
226 | -- 战斗力(当前属性)= POWER[(生命 + 防御 * 7 + 闪避 * 4)*(攻击*4 + 命中 * 2)*(1 + 暴击几率/100 * 暴击伤害/100)* 攻击速度 / 60000 ,0.8 ] | 226 | -- 战斗力(当前属性)= POWER[(生命 + 防御 * 7 + 闪避 * 4)*(攻击*4 + 命中 * 2)*(1 + 暴击几率/100 * 暴击伤害/100)* 攻击速度 / 60000 ,0.8 ] |
227 | - function Hero:getBattleValue(activeRelation) -- isReal包括队伍加成 | ||
228 | - local attrs = self:getTotalAttrs({activeRelation = activeRelation}) | 227 | + -- function Hero:getBattleValue(activeRelation) -- isReal包括队伍加成 |
228 | + function Hero:getBattleValue() -- isReal包括队伍加成 | ||
229 | + -- local attrs = self:getTotalAttrs({activeRelation = activeRelation}) | ||
230 | + local attrs = self:getTotalAttrs() | ||
229 | local battleValue = ((attrs["hp"] + attrs["def"] * 7 + attrs["miss"] * 4) * (attrs["atk"] * 4 + attrs["hit"] * 2) * (1 + attrs["crit"]/100 * attrs["critHurt"]/100) * attrs["atkSpeed"] / 600000) ^ 0.8 | 231 | local battleValue = ((attrs["hp"] + attrs["def"] * 7 + attrs["miss"] * 4) * (attrs["atk"] * 4 + attrs["hit"] * 2) * (1 + attrs["crit"]/100 * attrs["critHurt"]/100) * attrs["atkSpeed"] / 600000) ^ 0.8 |
230 | return math.floor(battleValue) | 232 | return math.floor(battleValue) |
231 | end | 233 | end |
src/models/Role.lua
@@ -99,7 +99,8 @@ Role.schema = { | @@ -99,7 +99,8 @@ Role.schema = { | ||
99 | advLimit = {"table", {}}, -- 冒险事件每次的limit | 99 | advLimit = {"table", {}}, -- 冒险事件每次的limit |
100 | advC = {"number", 0}, -- 冒险次数(消耗体力) | 100 | advC = {"number", 0}, -- 冒险次数(消耗体力) |
101 | advCT = {"number", 0}, -- 冒险次数 上次恢复时间 | 101 | advCT = {"number", 0}, -- 冒险次数 上次恢复时间 |
102 | - | 102 | + advMine = {"table", {}}, -- -- {1 = {ch = 0, co = {id = count}}, 2 = {ch = 0, co = {id = count}}} 宝藏怪刷出概率 1 宝藏怪 2 宝藏洞 ch 概率 co 不同id 次数记录 |
103 | + | ||
103 | --挂机相关 | 104 | --挂机相关 |
104 | hangPass = {"table", {}}, -- 挂机通过的最大关卡 | 105 | hangPass = {"table", {}}, -- 挂机通过的最大关卡 |
105 | hangGift = {"table", {}}, -- 挂机奖励 {id = 1} | 106 | hangGift = {"table", {}}, -- 挂机奖励 {id = 1} |
@@ -167,7 +168,8 @@ Role.schema = { | @@ -167,7 +168,8 @@ Role.schema = { | ||
167 | repayMaxC = {"number", 0}, -- 招募保底英雄领取次数 100一次 | 168 | repayMaxC = {"number", 0}, -- 招募保底英雄领取次数 100一次 |
168 | floorHero = {"table", {}}, -- 招募保底 -- {[poolId] = count} | 169 | floorHero = {"table", {}}, -- 招募保底 -- {[poolId] = count} |
169 | ssrUp = {"table", {}}, -- ssr up -- {[poolId] = count} | 170 | ssrUp = {"table", {}}, -- ssr up -- {[poolId] = count} |
170 | - newerDraw = {"table", {}}, -- 新手池子 {N, 1} 抽了多少次, 是否出了ssr | 171 | + newerDraw = {"number", 0}, -- 新手池子抽卡次数 |
172 | + wishPool = {"table", {}}, -- 心愿池子 | ||
171 | 173 | ||
172 | sudoku = {"table", {}}, -- 九宫格 {[-1] = 1, task = {[1] = {}, [2] = {}}}} -- [-1] 阶段 如果为 -1 关闭(都做完了), task 当前阶段任务进度, reward 连串奖励领取情况 | 174 | sudoku = {"table", {}}, -- 九宫格 {[-1] = 1, task = {[1] = {}, [2] = {}}}} -- [-1] 阶段 如果为 -1 关闭(都做完了), task 当前阶段任务进度, reward 连串奖励领取情况 |
173 | sign = {"table", {}}, -- 签到记录 {[1] = 20181029} | 175 | sign = {"table", {}}, -- 签到记录 {[1] = 20181029} |
@@ -394,6 +396,7 @@ function Role:data() | @@ -394,6 +396,7 @@ function Role:data() | ||
394 | repayHero = self:getProperty("repayHero"), | 396 | repayHero = self:getProperty("repayHero"), |
395 | newerDraw = self:getProperty("newerDraw"), | 397 | newerDraw = self:getProperty("newerDraw"), |
396 | floorHero = self:getProperty("floorHero"), | 398 | floorHero = self:getProperty("floorHero"), |
399 | + wishPool = self:getProperty("wishPool"), | ||
397 | 400 | ||
398 | sudoku = self:getProperty("sudoku"), | 401 | sudoku = self:getProperty("sudoku"), |
399 | sign = self:getProperty("sign"), | 402 | sign = self:getProperty("sign"), |
src/models/RoleBattle.lua
@@ -16,6 +16,7 @@ local BattleType = { | @@ -16,6 +16,7 @@ local BattleType = { | ||
16 | bonus = 300, | 16 | bonus = 300, |
17 | pvpc = 500, | 17 | pvpc = 500, |
18 | pvph = 501, | 18 | pvph = 501, |
19 | + act_battle = 502, | ||
19 | } | 20 | } |
20 | 21 | ||
21 | RoleBattle.bind = function (Role) | 22 | RoleBattle.bind = function (Role) |
@@ -43,7 +44,7 @@ function Role:checkBattle(battleType, params) | @@ -43,7 +44,7 @@ function Role:checkBattle(battleType, params) | ||
43 | 44 | ||
44 | local fixData = { | 45 | local fixData = { |
45 | hang = function() | 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 | selflist[slot] = hero.type | 48 | selflist[slot] = hero.type |
48 | end | 49 | end |
49 | heroscore = self:getProperty("hangTBV") | 50 | heroscore = self:getProperty("hangTBV") |
@@ -58,7 +59,7 @@ function Role:checkBattle(battleType, params) | @@ -58,7 +59,7 @@ function Role:checkBattle(battleType, params) | ||
58 | end, | 59 | end, |
59 | tower = function() | 60 | tower = function() |
60 | local towerF = self:getTeamFormatByType(TeamSystemType.Tower) | 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 | selflist[slot] = hero.type | 63 | selflist[slot] = hero.type |
63 | end | 64 | end |
64 | heroscore = self:getTeamBattleValue(towerF.heros) | 65 | heroscore = self:getTeamBattleValue(towerF.heros) |
@@ -73,7 +74,7 @@ function Role:checkBattle(battleType, params) | @@ -73,7 +74,7 @@ function Role:checkBattle(battleType, params) | ||
73 | end, | 74 | end, |
74 | bonus = function() | 75 | bonus = function() |
75 | local bTeam = self:getTeamFormatByType(TeamSystemType.BonusBattle) | 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 | selflist[slot] = hero.type | 78 | selflist[slot] = hero.type |
78 | end | 79 | end |
79 | heroscore = self:getTeamBattleValue(bTeam.heros) | 80 | heroscore = self:getTeamBattleValue(bTeam.heros) |
@@ -86,8 +87,22 @@ function Role:checkBattle(battleType, params) | @@ -86,8 +87,22 @@ function Role:checkBattle(battleType, params) | ||
86 | enemylist[#enemylist + 1] = one["unitType"] | 87 | enemylist[#enemylist + 1] = one["unitType"] |
87 | end | 88 | end |
88 | end, | 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 | pvpc = function() | 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 | selflist[slot] = hero.type | 106 | selflist[slot] = hero.type |
92 | end | 107 | end |
93 | heroscore = self:getProperty("pvpTBVC") | 108 | heroscore = self:getProperty("pvpTBVC") |
@@ -109,7 +124,7 @@ function Role:checkBattle(battleType, params) | @@ -109,7 +124,7 @@ function Role:checkBattle(battleType, params) | ||
109 | pvph = function() | 124 | pvph = function() |
110 | for idx, team in pairs(self:getProperty("pvpTSH")) do | 125 | for idx, team in pairs(self:getProperty("pvpTSH")) do |
111 | selflist[idx] = selflist[idx] or {} | 126 | selflist[idx] = selflist[idx] or {} |
112 | - for slot, hero in pairs(team) do | 127 | + for slot, hero in pairs(team.heros) do |
113 | selflist[idx][slot] = hero.type | 128 | selflist[idx][slot] = hero.type |
114 | end | 129 | end |
115 | end | 130 | end |
@@ -163,7 +178,7 @@ function Role:checkBattle(battleType, params) | @@ -163,7 +178,7 @@ function Role:checkBattle(battleType, params) | ||
163 | mission_starttime = clientInfo.start or 0, -- 战斗开始时间,格式 unixtime 秒级 | 178 | mission_starttime = clientInfo.start or 0, -- 战斗开始时间,格式 unixtime 秒级 |
164 | mission_roundtime = clientInfo.atime or 0, -- 对局时长(秒) | 179 | mission_roundtime = clientInfo.atime or 0, -- 对局时长(秒) |
165 | mission_result = params.isWin and 1 or 2, -- 战斗结果(0-无效,1-胜利,2-失败) | 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 | mission_restriction = 0, -- 周期内参与限制(0表示没有上限) | 182 | mission_restriction = 0, -- 周期内参与限制(0表示没有上限) |
168 | mission_difficulty = 0, -- 关卡困难度,无难度区分的话填写0 | 183 | mission_difficulty = 0, -- 关卡困难度,无难度区分的话填写0 |
169 | mission_strength = 1, -- 消耗的体力或次数 | 184 | mission_strength = 1, -- 消耗的体力或次数 |
src/models/RoleCross.lua
@@ -19,8 +19,8 @@ RoleCross.bind = function (Role) | @@ -19,8 +19,8 @@ RoleCross.bind = function (Role) | ||
19 | -- 好友详细队伍信息 | 19 | -- 好友详细队伍信息 |
20 | function Role:friendInfo() | 20 | function Role:friendInfo() |
21 | local info = self:friendSInfo() | 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 | return info | 24 | return info |
25 | end | 25 | end |
26 | 26 | ||
@@ -36,7 +36,7 @@ RoleCross.bind = function (Role) | @@ -36,7 +36,7 @@ RoleCross.bind = function (Role) | ||
36 | level = self:getProperty("level"), | 36 | level = self:getProperty("level"), |
37 | headId = self:getProperty("headId"), | 37 | headId = self:getProperty("headId"), |
38 | battleV = self:getProperty("pvpTBVC"), | 38 | battleV = self:getProperty("pvpTBVC"), |
39 | - heros = self:getProperty("pvpTSC"), | 39 | + team = self:getProperty("pvpTSC"), |
40 | battleInfo = self:getProperty("pvpTBC") | 40 | battleInfo = self:getProperty("pvpTBC") |
41 | } | 41 | } |
42 | return info | 42 | return info |
@@ -49,7 +49,7 @@ RoleCross.bind = function (Role) | @@ -49,7 +49,7 @@ RoleCross.bind = function (Role) | ||
49 | level = self:getProperty("level"), | 49 | level = self:getProperty("level"), |
50 | headId = self:getProperty("headId"), | 50 | headId = self:getProperty("headId"), |
51 | battleV = self:getProperty("pvpTBVH"), | 51 | battleV = self:getProperty("pvpTBVH"), |
52 | - heros = self:getProperty("pvpTSH"), | 52 | + team = self:getProperty("pvpTSH"), |
53 | battleInfo = self:getProperty("pvpTBH") | 53 | battleInfo = self:getProperty("pvpTBH") |
54 | } | 54 | } |
55 | return info | 55 | return info |
@@ -281,7 +281,7 @@ function CMD.friendInfo(roleId) | @@ -281,7 +281,7 @@ function CMD.friendInfo(roleId) | ||
281 | headId = info.headId, | 281 | headId = info.headId, |
282 | ltime = info.ltime, | 282 | ltime = info.ltime, |
283 | battleV = info.pvpTBVC ~= 0 and info.pvpTBVC or info.hangTBV, | 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 | end | 286 | end |
287 | 287 | ||
@@ -297,7 +297,7 @@ function CMD.pvpCInfo(roleId) | @@ -297,7 +297,7 @@ function CMD.pvpCInfo(roleId) | ||
297 | level = info.level, | 297 | level = info.level, |
298 | headId = info.headId, | 298 | headId = info.headId, |
299 | battleV = info.pvpTBVC, | 299 | battleV = info.pvpTBVC, |
300 | - heros = info.pvpTSC, | 300 | + team = info.pvpTSC, |
301 | battleInfo = info.pvpTBC | 301 | battleInfo = info.pvpTBC |
302 | } | 302 | } |
303 | end | 303 | end |
@@ -309,7 +309,7 @@ function CMD.pvpHInfo(roleId) | @@ -309,7 +309,7 @@ function CMD.pvpHInfo(roleId) | ||
309 | level = info.level, | 309 | level = info.level, |
310 | headId = info.headId, | 310 | headId = info.headId, |
311 | battleV = info.pvpTBVH, | 311 | battleV = info.pvpTBVH, |
312 | - heros = info.pvpTSH, | 312 | + team = info.pvpTSH, |
313 | battleInfo = info.pvpTBH | 313 | battleInfo = info.pvpTBH |
314 | } | 314 | } |
315 | end | 315 | end |
src/models/RoleLog.lua
1 | local serverId = skynet.getenv("servId") | 1 | local serverId = skynet.getenv("servId") |
2 | local server_id = (skynet.getenv("serverType") or "localtest") .. "_" .. serverId | 2 | local server_id = (skynet.getenv("serverType") or "localtest") .. "_" .. serverId |
3 | +local logproxy = require "shared.logproxy" | ||
3 | 4 | ||
4 | --[[ | 5 | --[[ |
5 | 100 购买/兑换行为 | 6 | 100 购买/兑换行为 |
@@ -42,6 +43,14 @@ local ItemReason = { | @@ -42,6 +43,14 @@ local ItemReason = { | ||
42 | freeGift = 127, -- 免费礼包 | 43 | freeGift = 127, -- 免费礼包 |
43 | exploreCommand = 128, -- 探索指令 | 44 | exploreCommand = 128, -- 探索指令 |
44 | drawHeroExtraReward = 129, -- 抽卡阶段奖励 | 45 | drawHeroExtraReward = 129, -- 抽卡阶段奖励 |
46 | + actRecycle = 130, -- 活动道具回收 | ||
47 | + actExchange = 131, -- 兑换活动 | ||
48 | + actGachakon = 132, -- 扭蛋活动 | ||
49 | + totalRecharge = 133, -- 累计充值奖励 | ||
50 | + actHangDrop = 134, -- 掉落活动奖励 | ||
51 | + actBattle = 135, -- 活动关卡 | ||
52 | + actMilestone = 136, -- 活动关卡boss伤害里程碑 | ||
53 | + worldBossReward = 137, -- 世界boss翻牌奖励 | ||
45 | 54 | ||
46 | 55 | ||
47 | advHang = 301, -- 拾荒挂机 | 56 | advHang = 301, -- 拾荒挂机 |
@@ -82,6 +91,7 @@ local ItemReason = { | @@ -82,6 +91,7 @@ local ItemReason = { | ||
82 | actSign = 1007, -- 活动签到 | 91 | actSign = 1007, -- 活动签到 |
83 | actPaySign = 1008, -- 活动付费签到 | 92 | actPaySign = 1008, -- 活动付费签到 |
84 | calendaTask = 1009, -- 英雄帖 | 93 | calendaTask = 1009, -- 英雄帖 |
94 | + actMilecrisis = 1010, -- 物资危机 | ||
85 | 95 | ||
86 | -- 餐厅 | 96 | -- 餐厅 |
87 | greenHourse = 1101, -- 食材获得 | 97 | greenHourse = 1101, -- 食材获得 |
@@ -244,13 +254,6 @@ local MethodType = { | @@ -244,13 +254,6 @@ local MethodType = { | ||
244 | hero_break_result = "json", -- 英雄突破效果,可记录效果ID,或json格式记录提升效果,{攻击:20,闪避:20,……..} | 254 | hero_break_result = "json", -- 英雄突破效果,可记录效果ID,或json格式记录提升效果,{攻击:20,闪避:20,……..} |
245 | hero_break_level = true, -- 英雄突破后等级上限 | 255 | hero_break_level = true, -- 英雄突破后等级上限 |
246 | }, | 256 | }, |
247 | - hero_talent = { --英雄天赋升级 | ||
248 | - hero_id = true, -- 英雄ID | ||
249 | - hero_talent_cost = "json", -- 英雄天赋升级消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...} | ||
250 | - hero_talent_levelbef = true, -- 英雄技能升级前等级 | ||
251 | - hero_talent_level = true, -- 英雄技能升级后等级 | ||
252 | - hero_talent_id = true, -- 天赋id | ||
253 | - }, | ||
254 | hero_jewel = { --英雄铭文 | 257 | hero_jewel = { --英雄铭文 |
255 | hero_id = true, -- 英雄ID | 258 | hero_id = true, -- 英雄ID |
256 | hero_jewel_sequence = "ucode", -- 铭文装备编号,用以关联一次装备时产生的多条日志 | 259 | hero_jewel_sequence = "ucode", -- 铭文装备编号,用以关联一次装备时产生的多条日志 |
@@ -280,7 +283,7 @@ local MethodType = { | @@ -280,7 +283,7 @@ local MethodType = { | ||
280 | gacha_up = true, -- 卡池UP角色 | 283 | gacha_up = true, -- 卡池UP角色 |
281 | gacha_times = true, -- 抽卡次数 | 284 | gacha_times = true, -- 抽卡次数 |
282 | gacha_reward = "json", -- 抽卡结果,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"} | 285 | gacha_reward = "json", -- 抽卡结果,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"} |
283 | - currency = "json", -- 消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...} | 286 | + gacha_cost = "json", -- 消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...} |
284 | gacha_cnt = true, -- 保底计数 | 287 | gacha_cnt = true, -- 保底计数 |
285 | }, | 288 | }, |
286 | equip_wear = { --装备穿戴与卸载 | 289 | equip_wear = { --装备穿戴与卸载 |
@@ -288,8 +291,8 @@ local MethodType = { | @@ -288,8 +291,8 @@ local MethodType = { | ||
288 | equip_id = true, --装备ID | 291 | equip_id = true, --装备ID |
289 | equip_wear_action = true, --装备操作类型:装备:0,卸载:1 | 292 | equip_wear_action = true, --装备操作类型:装备:0,卸载:1 |
290 | equip_wear_part = true, --装备部位,记录部位ID | 293 | equip_wear_part = true, --装备部位,记录部位ID |
291 | - equip_wear_result = "json", --装备操作后结果,记录属性变化,json格式记录,{“aa”:1234,"bb":4567} | ||
292 | - equip_wear_change = "json", --装备操作变化值,记录属性变化,记录正负值,json格式记录,{“aa”:1234,"bb":-45} | 294 | + equip_wear_scorebef = true, --装备前英雄评分 |
295 | + equip_wear_score = true, --装备后英雄评分 | ||
293 | equip_wear_mode = true, --用以区分自动装备还是手动装备,自动记录为0,手动记录为1 | 296 | equip_wear_mode = true, --用以区分自动装备还是手动装备,自动记录为0,手动记录为1 |
294 | equip_wear_seqid = "ucode", --自动穿戴时记录的系列ID,用以关联一次性装备时候产生的多条记录 | 297 | equip_wear_seqid = "ucode", --自动穿戴时记录的系列ID,用以关联一次性装备时候产生的多条记录 |
295 | }, | 298 | }, |
@@ -406,6 +409,7 @@ local MethodType = { | @@ -406,6 +409,7 @@ local MethodType = { | ||
406 | restaurant_order_status = true, -- 订单任务状态,接受:0, 拒绝:1, 完成:2 | 409 | restaurant_order_status = true, -- 订单任务状态,接受:0, 拒绝:1, 完成:2 |
407 | restaurant_order_rwd = "json", -- 订单完成奖励,json格式记录,{"itemid1":123,"itemid2":12,……….} | 410 | restaurant_order_rwd = "json", -- 订单完成奖励,json格式记录,{"itemid1":123,"itemid2":12,……….} |
408 | restaurant_order_lv = true, -- 订单品质等级,普通:0, 稀有:1, 顶级:2, 豪华:3 | 411 | restaurant_order_lv = true, -- 订单品质等级,普通:0, 稀有:1, 顶级:2, 豪华:3 |
412 | + restaurant_order_type = true, -- 订单任务类型,0:特殊顾客,1:特别订单 | ||
409 | }, | 413 | }, |
410 | restaurant_collect = { --餐厅顾客图谱 | 414 | restaurant_collect = { --餐厅顾客图谱 |
411 | restaurant_collect_id = true, -- 图谱收集ID | 415 | restaurant_collect_id = true, -- 图谱收集ID |
@@ -497,6 +501,27 @@ local MethodType = { | @@ -497,6 +501,27 @@ local MethodType = { | ||
497 | mission_pick_fund_beflv = true, -- 资助前资助等级 | 501 | mission_pick_fund_beflv = true, -- 资助前资助等级 |
498 | mission_pick_fund_aftlv = true, -- 资助后资助等级 | 502 | mission_pick_fund_aftlv = true, -- 资助后资助等级 |
499 | }, | 503 | }, |
504 | + function_open = { -- 功能开启日志 | ||
505 | + function_id = true, --功能ID | ||
506 | + }, | ||
507 | + punitive_action = { -- 讨伐行动 --TODO | ||
508 | + mission_id = true, --关卡ID | ||
509 | + mission_herolist = true, -- 英雄ID,排序以玩家出战设置为准,示例:[111, 222, 333, 444, 555] | ||
510 | + mission_success_rate = true, -- 大成功几率 | ||
511 | + mission_reward = true, -- 获得奖励,建议使用json格式记录。示例:{ itemid1: 1, itemid2: 3, itemid3: 5} | ||
512 | + mission_result = true, -- 战斗结果(0-无效,1-胜利,2-失败) | ||
513 | + mission_roundtime = true, -- 完成耗时(秒) | ||
514 | + }, | ||
515 | + hero_talent = { --英雄精进(原英雄天赋升级) TODO | ||
516 | + hero_id = true, --英雄ID | ||
517 | + hero_talent_stagebef = true, --英雄精进升级前停留阶段 | ||
518 | + hero_talent_stage = true, --英雄精进升级后停留阶段 | ||
519 | + hero_talent_cost = "json", --英雄精进升级消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,….} | ||
520 | + hero_talent_subid = true, --升级属性ID,生命、攻击、防御、命中、闪避分别对应(0,1,2,3,4) | ||
521 | + hero_talent_sublevel = true, --升级属性等级,如生命升级从1到2,则记录2 | ||
522 | + }, | ||
523 | + | ||
524 | + | ||
500 | } | 525 | } |
501 | 526 | ||
502 | local function printError(info) | 527 | local function printError(info) |
@@ -758,8 +783,7 @@ function RoleLog.bind(Role) | @@ -758,8 +783,7 @@ function RoleLog.bind(Role) | ||
758 | end | 783 | end |
759 | end | 784 | end |
760 | end | 785 | end |
761 | - if not logd then return end | ||
762 | - pcall(skynet.send, logd, "lua", "log", doc, "bi") | 786 | + logproxy:log(doc, "bi") |
763 | end | 787 | end |
764 | 788 | ||
765 | function Role:logItems(itemId, before, after, log) | 789 | function Role:logItems(itemId, before, after, log) |
@@ -818,8 +842,7 @@ function RoleLog.bind(Role) | @@ -818,8 +842,7 @@ function RoleLog.bind(Role) | ||
818 | end | 842 | end |
819 | end | 843 | end |
820 | doc["@type"] = logType | 844 | doc["@type"] = logType |
821 | - if not logd then return end | ||
822 | - pcall(skynet.send, logd, "lua", "log", doc, "log") | 845 | + logproxy:log(doc, "log") |
823 | end | 846 | end |
824 | 847 | ||
825 | 848 |
src/models/RolePlugin.lua
@@ -102,6 +102,35 @@ function RolePlugin.bind(Role) | @@ -102,6 +102,35 @@ function RolePlugin.bind(Role) | ||
102 | [ItemType.FuncOpen] = function() | 102 | [ItemType.FuncOpen] = function() |
103 | self:funcOpen(itemId, count, pms) | 103 | self:funcOpen(itemId, count, pms) |
104 | end, | 104 | end, |
105 | + [ItemType.HeroFCommon] = function() | ||
106 | + if itemData.use_type == 2 then | ||
107 | + local randomData = csvdb["item_randomCsv"][tonumber(itemData.use_effect)] | ||
108 | + for _i = 1, count do | ||
109 | + for i = 1, 10 do | ||
110 | + local num = randomData["num" .. i] | ||
111 | + local gift = randomData["gift" .. i] | ||
112 | + if num and gift and num > 0 and gift ~= "" then | ||
113 | + local pool = {} | ||
114 | + for _, temp in ipairs(gift:toArray()) do | ||
115 | + table.insert(pool, temp:toArray(true, "=")) | ||
116 | + end | ||
117 | + local needCount = math.min(#pool, num) | ||
118 | + for j = 1, needCount do | ||
119 | + local idx = math.randWeight(pool, 3) | ||
120 | + change[pool[idx][1]] = (change[pool[idx][1]] or 0) + pool[idx][2] | ||
121 | + table.remove(pool, idx) | ||
122 | + end | ||
123 | + end | ||
124 | + end | ||
125 | + end | ||
126 | + change[0] = nil | ||
127 | + count = 0 | ||
128 | + else | ||
129 | + pms.itemId = itemId | ||
130 | + pms.count = count | ||
131 | + self:addItem(pms) | ||
132 | + end | ||
133 | + end, | ||
105 | } | 134 | } |
106 | -- 对数量筛查 | 135 | -- 对数量筛查 |
107 | count = checkItemCount(self, itemId, count) | 136 | count = checkItemCount(self, itemId, count) |
@@ -806,50 +835,50 @@ function RolePlugin.bind(Role) | @@ -806,50 +835,50 @@ function RolePlugin.bind(Role) | ||
806 | SendPacket(actionCodes.Sys_maintainNotice, MsgPack.pack({ body = text, iskey = not isNotKey})) | 835 | SendPacket(actionCodes.Sys_maintainNotice, MsgPack.pack({ body = text, iskey = not isNotKey})) |
807 | end | 836 | end |
808 | 837 | ||
809 | - function Role:getHeroActiveRelationData(heros) | ||
810 | - local relations = {} | ||
811 | - for _, id in pairs(heros or {}) do | ||
812 | - local hero = self.heros[id] | ||
813 | - if hero then | ||
814 | - local camp = csvdb["unitCsv"][hero:getProperty("type")].camp | ||
815 | - relations[camp] = (relations[camp] or 0) + 1 | ||
816 | - end | ||
817 | - end | ||
818 | - local curData = csvdb["unit_relationCsv"][0] | ||
819 | - if not next(relations) then return curData end | 838 | + -- function Role:getHeroActiveRelationData(heros) |
839 | + -- local relations = {} | ||
840 | + -- for _, id in pairs(heros or {}) do | ||
841 | + -- local hero = self.heros[id] | ||
842 | + -- if hero then | ||
843 | + -- local camp = csvdb["unitCsv"][hero:getProperty("type")].camp | ||
844 | + -- relations[camp] = (relations[camp] or 0) + 1 | ||
845 | + -- end | ||
846 | + -- end | ||
847 | + -- local curData = csvdb["unit_relationCsv"][0] | ||
848 | + -- if not next(relations) then return curData end | ||
820 | 849 | ||
821 | - for _, data in ipairs(csvdb["unit_relationCsv"]) do | ||
822 | - local had = {} | ||
823 | - local isDone = true | ||
824 | - for _, count in pairs(data.relation:toArray(true, "=")) do | ||
825 | - local find = false | ||
826 | - for camp, _count in pairs(relations) do | ||
827 | - if count == _count and not had[camp] then | ||
828 | - had[camp] = true | ||
829 | - find = true | ||
830 | - break | ||
831 | - end | ||
832 | - end | ||
833 | - if not find then | ||
834 | - isDone = false | ||
835 | - break | ||
836 | - end | ||
837 | - end | ||
838 | - if isDone then | ||
839 | - curData = data | ||
840 | - end | ||
841 | - end | ||
842 | - return curData | ||
843 | - end | ||
844 | - | ||
845 | - function Role:getHeroActiveRelation(heros) | ||
846 | - local data = self:getHeroActiveRelationData(heros) | ||
847 | - local result = {} | ||
848 | - for attr, value in pairs(data.effect:toNumMap()) do | ||
849 | - result[AttsEnumEx[attr]] = (result[AttsEnumEx[attr]] or 0) + value | ||
850 | - end | ||
851 | - return result | ||
852 | - end | 850 | + -- for _, data in ipairs(csvdb["unit_relationCsv"]) do |
851 | + -- local had = {} | ||
852 | + -- local isDone = true | ||
853 | + -- for _, count in pairs(data.relation:toArray(true, "=")) do | ||
854 | + -- local find = false | ||
855 | + -- for camp, _count in pairs(relations) do | ||
856 | + -- if count == _count and not had[camp] then | ||
857 | + -- had[camp] = true | ||
858 | + -- find = true | ||
859 | + -- break | ||
860 | + -- end | ||
861 | + -- end | ||
862 | + -- if not find then | ||
863 | + -- isDone = false | ||
864 | + -- break | ||
865 | + -- end | ||
866 | + -- end | ||
867 | + -- if isDone then | ||
868 | + -- curData = data | ||
869 | + -- end | ||
870 | + -- end | ||
871 | + -- return curData | ||
872 | + -- end | ||
873 | + | ||
874 | + -- function Role:getHeroActiveRelation(heros) | ||
875 | + -- local data = self:getHeroActiveRelationData(heros) | ||
876 | + -- local result = {} | ||
877 | + -- for attr, value in pairs(data.effect:toNumMap()) do | ||
878 | + -- result[AttsEnumEx[attr]] = (result[AttsEnumEx[attr]] or 0) + value | ||
879 | + -- end | ||
880 | + -- return result | ||
881 | + -- end | ||
853 | 882 | ||
854 | function Role:getHerosCamp(heros) | 883 | function Role:getHerosCamp(heros) |
855 | local had = {} | 884 | local had = {} |
@@ -870,14 +899,16 @@ function RolePlugin.bind(Role) | @@ -870,14 +899,16 @@ function RolePlugin.bind(Role) | ||
870 | return curCamp | 899 | return curCamp |
871 | end | 900 | end |
872 | 901 | ||
873 | - function Role:getRealBattleValue(heros, activeRelation) -- 获取队伍战斗力 羁绊加成 | 902 | + -- function Role:getRealBattleValue(heros, activeRelation) -- 获取队伍战斗力 羁绊加成 |
903 | + function Role:getRealBattleValue(heros) -- 获取队伍战斗力 羁绊加成 | ||
874 | heros = heros or {} | 904 | heros = heros or {} |
875 | - local activeRelation = activeRelation or self:getHeroActiveRelation(heros) | 905 | + -- local activeRelation = activeRelation or self:getHeroActiveRelation(heros) |
876 | local battleValue = 0 | 906 | local battleValue = 0 |
877 | for _, id in pairs(heros) do | 907 | for _, id in pairs(heros) do |
878 | local hero = self.heros[id] | 908 | local hero = self.heros[id] |
879 | if hero then | 909 | if hero then |
880 | - battleValue = battleValue + hero:getBattleValue(activeRelation) | 910 | + -- battleValue = battleValue + hero:getBattleValue(activeRelation) |
911 | + battleValue = battleValue + hero:getBattleValue() | ||
881 | end | 912 | end |
882 | end | 913 | end |
883 | return battleValue | 914 | return battleValue |
@@ -983,6 +1014,7 @@ function RolePlugin.bind(Role) | @@ -983,6 +1014,7 @@ function RolePlugin.bind(Role) | ||
983 | 1014 | ||
984 | if csvdb["itemCsv"][func] and csvdb["itemCsv"][func].type == ItemType.FuncOpen then | 1015 | if csvdb["itemCsv"][func] and csvdb["itemCsv"][func].type == ItemType.FuncOpen then |
985 | local unlockData = csvdb["unlockCsv"][func] | 1016 | local unlockData = csvdb["unlockCsv"][func] |
1017 | + self:log("function_open", {function_id = func}) | ||
986 | if unlockData.type == 4 then -- 解锁神器 | 1018 | if unlockData.type == 4 then -- 解锁神器 |
987 | if self:getProperty("advAFOpen")[unlockData.value1] ~= 1 then | 1019 | if self:getProperty("advAFOpen")[unlockData.value1] ~= 1 then |
988 | self:changeUpdates({{type = "advAFOpen", field = unlockData.value1, value = 1}}) | 1020 | self:changeUpdates({{type = "advAFOpen", field = unlockData.value1, value = 1}}) |
@@ -1145,7 +1177,7 @@ function RolePlugin.bind(Role) | @@ -1145,7 +1177,7 @@ function RolePlugin.bind(Role) | ||
1145 | lv = self:getProperty("level"), | 1177 | lv = self:getProperty("level"), |
1146 | batteV = battleV, | 1178 | batteV = battleV, |
1147 | level = level, | 1179 | level = level, |
1148 | - format = self:getTeamHerosInfo(towerTeam.heros), | 1180 | + format = self:getTeamHerosInfo(towerTeam).heros, |
1149 | } | 1181 | } |
1150 | local roleId = self:getProperty("id") | 1182 | local roleId = self:getProperty("id") |
1151 | redisproxy:pipelining(function (red) | 1183 | redisproxy:pipelining(function (red) |
@@ -1263,7 +1295,7 @@ function RolePlugin.bind(Role) | @@ -1263,7 +1295,7 @@ function RolePlugin.bind(Role) | ||
1263 | 1295 | ||
1264 | function Role:getTeamBattleInfo(team) | 1296 | function Role:getTeamBattleInfo(team) |
1265 | local teamInfo = {heros = {}, supports = {}} | 1297 | local teamInfo = {heros = {}, supports = {}} |
1266 | - local activeRelation = self:getHeroActiveRelation(team.heros) | 1298 | + -- local activeRelation = self:getHeroActiveRelation(team.heros) |
1267 | 1299 | ||
1268 | for slot, id in pairs(team.heros or {}) do | 1300 | for slot, id in pairs(team.heros or {}) do |
1269 | local info = {} | 1301 | local info = {} |
@@ -1271,7 +1303,8 @@ function RolePlugin.bind(Role) | @@ -1271,7 +1303,8 @@ function RolePlugin.bind(Role) | ||
1271 | if not hero then | 1303 | if not hero then |
1272 | print("error heroid " .. id) | 1304 | print("error heroid " .. id) |
1273 | end | 1305 | end |
1274 | - local attrs = hero:getTotalAttrs({activeRelation = activeRelation}) | 1306 | + -- local attrs = hero:getTotalAttrs({activeRelation = activeRelation}) |
1307 | + local attrs = hero:getTotalAttrs() | ||
1275 | for k, v in pairs(AttsEnumEx) do | 1308 | for k, v in pairs(AttsEnumEx) do |
1276 | info[v] = (attrs[v] or 0) | 1309 | info[v] = (attrs[v] or 0) |
1277 | end | 1310 | end |
@@ -1292,9 +1325,10 @@ function RolePlugin.bind(Role) | @@ -1292,9 +1325,10 @@ function RolePlugin.bind(Role) | ||
1292 | return teamInfo | 1325 | return teamInfo |
1293 | end | 1326 | end |
1294 | 1327 | ||
1295 | - function Role:getTeamHerosInfo(heroIds) | 1328 | + function Role:getTeamHerosInfo(team) |
1329 | + local format = {} | ||
1296 | local heros = {} | 1330 | local heros = {} |
1297 | - for slot, heroId in pairs(heroIds or {}) do | 1331 | + for slot, heroId in pairs(team.heros or {}) do |
1298 | local hero = self.heros[heroId] | 1332 | local hero = self.heros[heroId] |
1299 | heros[slot] = { | 1333 | heros[slot] = { |
1300 | type = hero:getProperty("type"), | 1334 | type = hero:getProperty("type"), |
@@ -1302,7 +1336,10 @@ function RolePlugin.bind(Role) | @@ -1302,7 +1336,10 @@ function RolePlugin.bind(Role) | ||
1302 | wakeL = hero:getProperty("wakeL"), | 1336 | wakeL = hero:getProperty("wakeL"), |
1303 | } | 1337 | } |
1304 | end | 1338 | end |
1305 | - return heros | 1339 | + format.heros = heros |
1340 | + format.supports = team.supports or {} | ||
1341 | + format.tactics = team.tactics or {} | ||
1342 | + return format | ||
1306 | end | 1343 | end |
1307 | 1344 | ||
1308 | function Role:getTeamBattleValue(heros) | 1345 | function Role:getTeamBattleValue(heros) |
@@ -1320,7 +1357,7 @@ function RolePlugin.bind(Role) | @@ -1320,7 +1357,7 @@ function RolePlugin.bind(Role) | ||
1320 | if not team then return end | 1357 | if not team then return end |
1321 | 1358 | ||
1322 | self:setProperties({ | 1359 | self:setProperties({ |
1323 | - hangTS = self:getTeamHerosInfo(team.heros), | 1360 | + hangTS = self:getTeamHerosInfo(team), |
1324 | hangTB = self:getTeamBattleInfo(team), | 1361 | hangTB = self:getTeamBattleInfo(team), |
1325 | hangTBV = self:getTeamBattleValue(team.heros), | 1362 | hangTBV = self:getTeamBattleValue(team.heros), |
1326 | }) | 1363 | }) |
@@ -1368,7 +1405,7 @@ function RolePlugin.bind(Role) | @@ -1368,7 +1405,7 @@ function RolePlugin.bind(Role) | ||
1368 | self:updateProperty({field = "pvpTC", value = team}) | 1405 | self:updateProperty({field = "pvpTC", value = team}) |
1369 | end | 1406 | end |
1370 | self:setProperties({ | 1407 | self:setProperties({ |
1371 | - pvpTSC = self:getTeamHerosInfo(team.heros), | 1408 | + pvpTSC = self:getTeamHerosInfo(team), |
1372 | pvpTBC = self:getTeamBattleInfo(team), | 1409 | pvpTBC = self:getTeamBattleInfo(team), |
1373 | pvpTBVC = self:getTeamBattleValue(team.heros), | 1410 | pvpTBVC = self:getTeamBattleValue(team.heros), |
1374 | }) | 1411 | }) |
@@ -1384,7 +1421,7 @@ function RolePlugin.bind(Role) | @@ -1384,7 +1421,7 @@ function RolePlugin.bind(Role) | ||
1384 | local pvpTSH, pvpTBH, pvpTBVH = {}, {}, {} | 1421 | local pvpTSH, pvpTBH, pvpTBVH = {}, {}, {} |
1385 | for i = 1, 3 do | 1422 | for i = 1, 3 do |
1386 | if team[i] then | 1423 | if team[i] then |
1387 | - pvpTSH[i] = self:getTeamHerosInfo(team[i].heros) | 1424 | + pvpTSH[i] = self:getTeamHerosInfo(team[i]) |
1388 | pvpTBH[i] = self:getTeamBattleInfo(team[i]) | 1425 | pvpTBH[i] = self:getTeamBattleInfo(team[i]) |
1389 | pvpTBVH[i] = self:getTeamBattleValue(team[i].heros) | 1426 | pvpTBVH[i] = self:getTeamBattleValue(team[i].heros) |
1390 | end | 1427 | end |
@@ -1543,10 +1580,17 @@ function RolePlugin.bind(Role) | @@ -1543,10 +1580,17 @@ function RolePlugin.bind(Role) | ||
1543 | return "" | 1580 | return "" |
1544 | end | 1581 | end |
1545 | local limit = rechargeData.limit | 1582 | local limit = rechargeData.limit |
1546 | - local rechargeRecord = self:getProperty("payR") or {} | 1583 | + local rechargeRecord = self.storeData:getProperty("payR") or {} |
1547 | if limit ~= 0 and limit <= (rechargeRecord[rechargeId] or 0) then | 1584 | if limit ~= 0 and limit <= (rechargeRecord[rechargeId] or 0) then |
1548 | return "" | 1585 | return "" |
1549 | - end | 1586 | + end |
1587 | + | ||
1588 | + --判断是否是活动商品 | ||
1589 | + if rechargeData.activity_id ~= 0 then | ||
1590 | + local actCfg = csvdb["activity_ctrlCsv"][rechargeData.activity_id] | ||
1591 | + if not actCfg then return "" end | ||
1592 | + if not self.activity:isOpenById(rechargeData.activity_id, "ActShopGoods") then return "" end | ||
1593 | + end | ||
1550 | 1594 | ||
1551 | local orderId = redisproxy:hget(string.format(R_ORDERS, roleId), rechargeId) | 1595 | local orderId = redisproxy:hget(string.format(R_ORDERS, roleId), rechargeId) |
1552 | if orderId then | 1596 | if orderId then |
@@ -1564,6 +1608,7 @@ function RolePlugin.bind(Role) | @@ -1564,6 +1608,7 @@ function RolePlugin.bind(Role) | ||
1564 | key = orderKey, | 1608 | key = orderKey, |
1565 | order = partnerOrderId, | 1609 | order = partnerOrderId, |
1566 | rechargeId = rechargeId, | 1610 | rechargeId = rechargeId, |
1611 | + createTime = skynet.timex(), | ||
1567 | }) | 1612 | }) |
1568 | order:create() | 1613 | order:create() |
1569 | -- 正在进行中的订单 缓存 | 1614 | -- 正在进行中的订单 缓存 |
@@ -1607,7 +1652,7 @@ function RolePlugin.bind(Role) | @@ -1607,7 +1652,7 @@ function RolePlugin.bind(Role) | ||
1607 | -- 开始下单 | 1652 | -- 开始下单 |
1608 | if status == "success" then | 1653 | if status == "success" then |
1609 | elseif status == "fail" then | 1654 | elseif status == "fail" then |
1610 | - redisproxy:hdel(string.format(R_ORDERS, roleId), rechargeId) | 1655 | + -- redisproxy:hdel(string.format(R_ORDERS, roleId), rechargeId) |
1611 | elseif status == "finsh" then | 1656 | elseif status == "finsh" then |
1612 | orderObject:setProperty("finishTime", skynet.time()) | 1657 | orderObject:setProperty("finishTime", skynet.time()) |
1613 | redisproxy:hdel(string.format(R_ORDERS, roleId), rechargeId) | 1658 | redisproxy:hdel(string.format(R_ORDERS, roleId), rechargeId) |
@@ -1792,10 +1837,10 @@ function RolePlugin.bind(Role) | @@ -1792,10 +1837,10 @@ function RolePlugin.bind(Role) | ||
1792 | end | 1837 | end |
1793 | 1838 | ||
1794 | -- 抽卡阶段奖励 | 1839 | -- 抽卡阶段奖励 |
1795 | - function Role:getDrawCardExtraReward(oldVal, newVal) | 1840 | + function Role:getDrawCardExtraReward(feedbackId, oldVal, newVal) |
1796 | local reward = nil | 1841 | local reward = nil |
1797 | local maxCount = 0 | 1842 | local maxCount = 0 |
1798 | - for k, v in pairs(csvdb["build_extraRewardCsv"]) do | 1843 | + for k, v in pairs(csvdb["build_extraRewardCsv"][feedbackId]) do |
1799 | if oldVal < k and newVal >= k then | 1844 | if oldVal < k and newVal >= k then |
1800 | reward = v["reward"] or "" | 1845 | reward = v["reward"] or "" |
1801 | end | 1846 | end |
@@ -1897,6 +1942,53 @@ function RolePlugin.bind(Role) | @@ -1897,6 +1942,53 @@ function RolePlugin.bind(Role) | ||
1897 | end | 1942 | end |
1898 | deleteNotify({pattern = pattern}) | 1943 | deleteNotify({pattern = pattern}) |
1899 | end | 1944 | end |
1945 | + | ||
1946 | + local CommonRankTime = toUnixtime("2019010100") | ||
1947 | + local CommonCoef1 = 10000 | ||
1948 | + local CommonCoef2 = 10000 | ||
1949 | + function Role:updateRankCommon(rankType, rankVal, reserve) | ||
1950 | + if not rankType then return end | ||
1951 | + reserve = reserve or 0 | ||
1952 | + local now = skynet.timex() | ||
1953 | + local ct = math.ceil((now - CommonRankTime) / 86400) --按天计算 365 * 27 < 10000 可以维持 27 年 | ||
1954 | + ct = 10000 - ct -- 越早的排名越靠前 | ||
1955 | + local score = (rankVal * CommonCoef1 + ct) * CommonCoef2 + reserve | ||
1956 | + | ||
1957 | + local roleId = self:getProperty("id") | ||
1958 | + redisproxy:pipelining(function (red) | ||
1959 | + red:zadd(RANK_COMMON..rankType, score, roleId) --更新分数 | ||
1960 | + end) | ||
1961 | + end | ||
1962 | + | ||
1963 | + function Role:getRankInfoCommon(rankType) | ||
1964 | + if not rankType then return end | ||
1965 | + local list = {} | ||
1966 | + local rankKey = RANK_COMMON .. rankType | ||
1967 | + local ids = redisproxy:zrevrange(rankKey, 0 , 99, "WITHSCORES") | ||
1968 | + for i = 1, #ids, 2 do | ||
1969 | + local roleId = tonumber(ids[i]) | ||
1970 | + local rankVal = tonumber(ids[i + 1]) | ||
1971 | + rankVal = math.floor(math.floor(rankVal / CommonCoef2) / CommonCoef1) | ||
1972 | + table.insert(list, {roleId = roleId, player = rankVal}) | ||
1973 | + end | ||
1974 | + | ||
1975 | + for _, v in ipairs(list) do | ||
1976 | + local _, curInfo = rpcRole(v.roleId, "friendSInfo") | ||
1977 | + curInfo.ltime = nil | ||
1978 | + curInfo.rankVal = v.player | ||
1979 | + v.player = curInfo | ||
1980 | + end | ||
1981 | + | ||
1982 | + local rank = redisproxy:ZREVRANK(rankKey, self:getProperty("id")) | ||
1983 | + if not rank then | ||
1984 | + rank = -1 | ||
1985 | + else | ||
1986 | + rank = rank + 1 | ||
1987 | + end | ||
1988 | + return {list = list, rank = rank} | ||
1989 | + end | ||
1990 | + | ||
1991 | + | ||
1900 | end | 1992 | end |
1901 | 1993 | ||
1902 | return RolePlugin | 1994 | return RolePlugin |
1903 | \ No newline at end of file | 1995 | \ No newline at end of file |
src/models/RolePvp.lua
@@ -6,7 +6,12 @@ RolePvp.bind = function (Role) | @@ -6,7 +6,12 @@ RolePvp.bind = function (Role) | ||
6 | local PVP_RANK_TIME_SORT_STD = 1924876800 -- 2030-12-31 00:00:00 | 6 | local PVP_RANK_TIME_SORT_STD = 1924876800 -- 2030-12-31 00:00:00 |
7 | local PVP_RANK_TIME_SORT_PLACE = 1000000 -- 时间戳占据 6位数 | 7 | local PVP_RANK_TIME_SORT_PLACE = 1000000 -- 时间戳占据 6位数 |
8 | local PVP_RANK_TIME_SORT_PRECISION = 360 -- 时间精度 每6分钟忽略差异 | 8 | local PVP_RANK_TIME_SORT_PRECISION = 360 -- 时间精度 每6分钟忽略差异 |
9 | -local PVP_RANK_ROBOT_SCORE = globalCsv.pvp_base_score -- 机器人积分 | 9 | +local PVP_RANK_BASE_SCORE = globalCsv.pvp_base_score -- 初始积分 |
10 | + | ||
11 | +-- 匹配规则改为以排名来匹配 | ||
12 | +local PVP_GET_ROBOT_SCORE = 2400 -- 2400分以下低档位匹配机器人 | ||
13 | +local PRE_RANGE_COUNT = 20 -- 每个档位人数 | ||
14 | +local NEED_MATCH = 3 --匹配到多少人 | ||
10 | 15 | ||
11 | 16 | ||
12 | function Role:unpackPvpScore(score) | 17 | function Role:unpackPvpScore(score) |
@@ -34,7 +39,7 @@ function Role:changePvpScore(rankKey, changeScoreCallback, matchId) | @@ -34,7 +39,7 @@ function Role:changePvpScore(rankKey, changeScoreCallback, matchId) | ||
34 | end) | 39 | end) |
35 | local myScore = self:unpackPvpScore(redret[1]) | 40 | local myScore = self:unpackPvpScore(redret[1]) |
36 | local oldMyRank = tonumber(redret[2] or -2) + 1 | 41 | local oldMyRank = tonumber(redret[2] or -2) + 1 |
37 | - local matchScore = PVP_RANK_ROBOT_SCORE | 42 | + local matchScore = PVP_RANK_BASE_SCORE |
38 | if isPlayer then | 43 | if isPlayer then |
39 | matchScore = self:unpackPvpScore(redret[3]) | 44 | matchScore = self:unpackPvpScore(redret[3]) |
40 | end | 45 | end |
@@ -68,7 +73,7 @@ function Role:changePvpScoreCommon(matchId, isWin) | @@ -68,7 +73,7 @@ function Role:changePvpScoreCommon(matchId, isWin) | ||
68 | if isWin then | 73 | if isWin then |
69 | local scoreChange = math.ceil(60 / (1 + 10 ^ ((myScore - matchScore) / 400))) | 74 | local scoreChange = math.ceil(60 / (1 + 10 ^ ((myScore - matchScore) / 400))) |
70 | myScore = myScore + scoreChange | 75 | myScore = myScore + scoreChange |
71 | - matchScore = matchScore - scoreChange | 76 | + matchScore = matchScore - math.ceil(scoreChange / 3) -- 防守方失败时,扣分减为原来的1/3 |
72 | else | 77 | else |
73 | local scoreChange = math.ceil(60 / (1 + 10 ^ ((matchScore - myScore) / 400))) | 78 | local scoreChange = math.ceil(60 / (1 + 10 ^ ((matchScore - myScore) / 400))) |
74 | myScore = myScore - scoreChange | 79 | myScore = myScore - scoreChange |
@@ -78,7 +83,7 @@ function Role:changePvpScoreCommon(matchId, isWin) | @@ -78,7 +83,7 @@ function Role:changePvpScoreCommon(matchId, isWin) | ||
78 | end | 83 | end |
79 | 84 | ||
80 | local result = self:changePvpScore(RANK_PVP_COMMON, changeScoreCallback, matchId) | 85 | local result = self:changePvpScore(RANK_PVP_COMMON, changeScoreCallback, matchId) |
81 | - self:refreshPvpMatchC(result[1]) | 86 | + self:refreshPvpMatchC(result[1], result[5]) |
82 | return table.unpack(result) | 87 | return table.unpack(result) |
83 | end | 88 | end |
84 | 89 | ||
@@ -134,7 +139,7 @@ function Role:changePvpScoreHigh(matchId, isWin) | @@ -134,7 +139,7 @@ function Role:changePvpScoreHigh(matchId, isWin) | ||
134 | if isWin then | 139 | if isWin then |
135 | local scoreChange = math.ceil(50 / (1 + 10 ^ ((myScore - matchScore) / 1000))) | 140 | local scoreChange = math.ceil(50 / (1 + 10 ^ ((myScore - matchScore) / 1000))) |
136 | myScore = myScore + scoreChange | 141 | myScore = myScore + scoreChange |
137 | - matchScore = matchScore - scoreChange | 142 | + matchScore = matchScore - math.ceil(scoreChange / 3) -- 防守方失败时,扣分减为原来的1/3 |
138 | else | 143 | else |
139 | local scoreChange = math.ceil(50 / (1 + 10 ^ ((matchScore - myScore) / 1000))) | 144 | local scoreChange = math.ceil(50 / (1 + 10 ^ ((matchScore - myScore) / 1000))) |
140 | myScore = myScore - scoreChange | 145 | myScore = myScore - scoreChange |
@@ -162,85 +167,50 @@ function Role:changePvpScoreHigh(matchId, isWin) | @@ -162,85 +167,50 @@ function Role:changePvpScoreHigh(matchId, isWin) | ||
162 | }) | 167 | }) |
163 | end | 168 | end |
164 | 169 | ||
165 | - self:refreshPvpMatchH(result[1]) | 170 | + self:refreshPvpMatchH(result[1], result[5]) |
166 | return table.unpack(result) | 171 | return table.unpack(result) |
167 | end | 172 | end |
168 | 173 | ||
169 | -function Role:refreshPvpMatch(score, rankKey) | 174 | +function Role:isInPvpRank(rankKey) |
175 | + local Fields = { | ||
176 | + [RANK_PVP_COMMON] = "pvpMC", | ||
177 | + [RANK_PVP_HIGHT] = "pvpMH", | ||
178 | + } | ||
179 | + local dbKey = self:getPvpDBKey(rankKey) | ||
180 | + local roleId = self:getProperty("id") | ||
181 | + if redisproxy:zscore(dbKey, roleId) then | ||
182 | + return true | ||
183 | + end | ||
184 | + return false | ||
185 | +end | ||
170 | 186 | ||
187 | +-- 新的匹配规则 | ||
188 | +function Role:refreshPvpMatch(score, rank, rankKey) | ||
171 | local Fields = { | 189 | local Fields = { |
172 | [RANK_PVP_COMMON] = "pvpMC", | 190 | [RANK_PVP_COMMON] = "pvpMC", |
173 | [RANK_PVP_HIGHT] = "pvpMH", | 191 | [RANK_PVP_HIGHT] = "pvpMH", |
174 | } | 192 | } |
175 | local RobotCsvs = { | 193 | local RobotCsvs = { |
176 | [RANK_PVP_COMMON] = "pvp_robotCsv", | 194 | [RANK_PVP_COMMON] = "pvp_robotCsv", |
177 | - [RANK_PVP_HIGHT] = "pvp_robotCsv", | 195 | + [RANK_PVP_HIGHT] = "pvp_robot_groupCsv", |
178 | } | 196 | } |
197 | + | ||
179 | local mField = Fields[rankKey] | 198 | local mField = Fields[rankKey] |
180 | local robotCsv = RobotCsvs[rankKey] | 199 | local robotCsv = RobotCsvs[rankKey] |
181 | - local dbKey = self:getPvpDBKey(rankKey) | ||
182 | 200 | ||
201 | + local dbKey = self:getPvpDBKey(rankKey) | ||
183 | local roleId = self:getProperty("id") | 202 | local roleId = self:getProperty("id") |
184 | - score = score or self:unpackPvpScore(redisproxy:zscore(dbKey, roleId)) | ||
185 | - | ||
186 | - local function getPlayers(levels) | 203 | + if not score and not rank then |
187 | local redret = redisproxy:pipelining(function(red) | 204 | local redret = redisproxy:pipelining(function(red) |
188 | - for _, level in ipairs(levels) do | ||
189 | - local low, high = table.unpack(level) | ||
190 | - red:zadd(dbKey, low * PVP_RANK_TIME_SORT_PLACE, "std_temp1") | ||
191 | - red:zadd(dbKey, high * PVP_RANK_TIME_SORT_PLACE + PVP_RANK_TIME_SORT_PLACE - 1, "std_temp2") | ||
192 | - red:ZREVRANK(dbKey, "std_temp1") | ||
193 | - red:ZREVRANK(dbKey, "std_temp2") | ||
194 | - end | ||
195 | - red:zrem(dbKey, "std_temp1", "std_temp2") | 205 | + red:zscore(dbKey, roleId) |
206 | + red:zrevrank(dbKey, roleId) | ||
196 | end) | 207 | end) |
197 | - | ||
198 | - local PreGetCount = 7 | ||
199 | - local redret = redisproxy:pipelining(function(red) | ||
200 | - for idx, level in ipairs(levels) do | ||
201 | - local rank1 = tonumber(redret[(idx - 1) * 4 + 3]) | ||
202 | - local rank2 = tonumber(redret[(idx - 1) * 4 + 4]) | ||
203 | - if rank1 - rank2 > PreGetCount then | ||
204 | - rank2 = math.randomInt(rank2, rank1 - PreGetCount + 1) | ||
205 | - rank1 = rank2 + PreGetCount - 1 | ||
206 | - end | ||
207 | - red:ZREVRANGE(dbKey, rank2, rank1) | ||
208 | - end | ||
209 | - end) | ||
210 | - return redret | ||
211 | - end | ||
212 | - | ||
213 | - local findIdx = #globalCsv.pvp_division | ||
214 | - for idx, limit in ipairs(globalCsv.pvp_division) do | ||
215 | - if score < limit then | ||
216 | - findIdx = idx - 1 | ||
217 | - break | ||
218 | - end | 208 | + score = self:unpackPvpScore(redret[1]) |
209 | + rank = tonumber(redret[2] or -2) + 1 | ||
219 | end | 210 | end |
220 | - local levels = { | ||
221 | - {}, {}, {} | ||
222 | - } | ||
223 | - if globalCsv.pvp_division[findIdx + 1] then | ||
224 | - levels[1] = {globalCsv.pvp_division[findIdx + 1], (globalCsv.pvp_division[findIdx + 2] or 100000000) - 1} | ||
225 | - end | ||
226 | - levels[2] = {globalCsv.pvp_division[findIdx], (globalCsv.pvp_division[findIdx + 1] or 100000000) - 1} | ||
227 | - if globalCsv.pvp_division[findIdx - 1] then | ||
228 | - levels[3] = {globalCsv.pvp_division[findIdx - 1], globalCsv.pvp_division[findIdx] - 1} | ||
229 | - end | ||
230 | - local redirect = {} | ||
231 | - for i = #levels , 1, -1 do | ||
232 | - if not next(levels[i]) then | ||
233 | - table.remove(levels, i) | ||
234 | - redirect[i] = -1 | ||
235 | - for _, v in pairs(redirect) do | ||
236 | - redirect[_] = v - 1 | ||
237 | - end | ||
238 | - else | ||
239 | - redirect[i] = i | ||
240 | - end | ||
241 | - end | ||
242 | - | ||
243 | - local result = getPlayers(levels) | 211 | + score = score or self:unpackPvpScore(redisproxy:zscore(dbKey, roleId)) |
212 | + rank = rank or tonumber(redisproxy:zrevrank(dbKey, roleId) or -2) + 1 | ||
213 | + | ||
244 | local match = self:getProperty(mField) | 214 | local match = self:getProperty(mField) |
245 | local hadPlayer = {[roleId] = 1} | 215 | local hadPlayer = {[roleId] = 1} |
246 | local hadRobot = {} | 216 | local hadRobot = {} |
@@ -252,97 +222,260 @@ function Role:refreshPvpMatch(score, rankKey) | @@ -252,97 +222,260 @@ function Role:refreshPvpMatch(score, rankKey) | ||
252 | end | 222 | end |
253 | end | 223 | end |
254 | 224 | ||
255 | - for _, temp in pairs(result) do | ||
256 | - for i = #temp, 1, -1 do | ||
257 | - local id = tonumber(temp[i]) | ||
258 | - if hadPlayer[id] then | ||
259 | - table.remove(temp, i) | ||
260 | - else | ||
261 | - temp[i] = id | ||
262 | - hadPlayer[id] = 1 | ||
263 | - end | 225 | + local tempMatch = {} |
226 | + local needRobot = 0 | ||
227 | + -- -1 没有上榜 | ||
228 | + if rank == -1 then | ||
229 | + needRobot = NEED_MATCH | ||
230 | + else | ||
231 | + local need = PRE_RANGE_COUNT * NEED_MATCH | ||
232 | + local low, heigh = math.floor(rank - need / 2 - 1), math.floor(rank + need / 2 - 1) | ||
233 | + if low < 0 then | ||
234 | + low = 0 | ||
264 | end | 235 | end |
265 | - end | ||
266 | - -- 增加第几个 | ||
267 | - local function getPlayer(idx) | ||
268 | - for i = idx, 3 do | ||
269 | - if redirect[i] ~= -1 then | ||
270 | - local curR = result[redirect[i]] or {} | ||
271 | - if next(curR) then | ||
272 | - local curIdx = math.randomInt(1, #curR) | ||
273 | - local objId = curR[curIdx] | ||
274 | - table.remove(curR, curIdx) | ||
275 | - return objId | ||
276 | - end | 236 | + local rangeIds = redisproxy:ZREVRANGE(dbKey, low, heigh) |
237 | + local lastRangeIds = {} | ||
238 | + for idx, one in ipairs(rangeIds) do | ||
239 | + local cid = tonumber(one) | ||
240 | + if not hadPlayer[cid] then | ||
241 | + lastRangeIds[#lastRangeIds + 1] = cid | ||
277 | end | 242 | end |
278 | end | 243 | end |
279 | - end | ||
280 | - | ||
281 | - local tempMatch = {} | ||
282 | - local curCount = 0 | ||
283 | - for i = 1, 3 do | ||
284 | - local objId = getPlayer(i) | ||
285 | - if objId then | ||
286 | - tempMatch[i] = {t = 1, id = objId} | ||
287 | - curCount = curCount + 1 | 244 | + if score < PVP_GET_ROBOT_SCORE then |
245 | + needRobot = 1 | ||
288 | end | 246 | end |
289 | - end | ||
290 | - | ||
291 | - -- 正常的玩家不够了 低一档继续 | ||
292 | - if curCount < 3 then | ||
293 | - local level = nil | ||
294 | - if globalCsv.pvp_division[findIdx - 2] then | ||
295 | - level = {globalCsv.pvp_division[findIdx - 2], globalCsv.pvp_division[findIdx - 1] - 1} | 247 | + local len = #lastRangeIds |
248 | + if len < NEED_MATCH then | ||
249 | + needRobot = NEED_MATCH - len | ||
296 | end | 250 | end |
297 | - if level then | ||
298 | - local result = getPlayers({level})[1] or {} | ||
299 | - for i = #result, 1, -1 do | ||
300 | - local id = tonumber(result[i]) | ||
301 | - if hadPlayer[id] then | ||
302 | - table.remove(result, i) | ||
303 | - else | ||
304 | - result[i] = id | ||
305 | - hadPlayer[id] = 1 | ||
306 | - end | 251 | + local needPlayer = NEED_MATCH - needRobot |
252 | + if needPlayer > 0 then | ||
253 | + local pre = math.floor(len / needPlayer) | ||
254 | + for i = 1, needPlayer do | ||
255 | + local idx = math.randomInt((i - 1) * pre + 1, i * pre) | ||
256 | + tempMatch[#tempMatch + 1] = {t = 1, id = lastRangeIds[idx]} | ||
307 | end | 257 | end |
258 | + end | ||
308 | 259 | ||
309 | - if next(result) then | ||
310 | - for i = curCount + 1, 3 do | ||
311 | - local curIdx = math.randomInt(1, #result) | ||
312 | - local objId = result[curIdx] | ||
313 | - table.remove(result, curIdx) | ||
314 | - tempMatch[i] = {t = 1, id = objId} | ||
315 | - curCount = curCount + 1 | ||
316 | - if not next(result) then | ||
317 | - break | ||
318 | - end | ||
319 | - end | 260 | + end |
261 | + if needRobot > 0 then | ||
262 | + local RobotPoolCount = 20 | ||
263 | + local max = #csvdb[robotCsv] | ||
264 | + local min = 1 | ||
265 | + local mid | ||
266 | + while min <= max do | ||
267 | + mid = math.floor((min + max) / 2) | ||
268 | + local tempPt = csvdb[robotCsv][mid].pt | ||
269 | + if score == tempPt then | ||
270 | + break | ||
271 | + elseif score > tempPt then | ||
272 | + min = mid + 1 | ||
273 | + elseif score < tempPt then | ||
274 | + max = mid - 1 | ||
320 | end | 275 | end |
321 | end | 276 | end |
322 | - end | ||
323 | - | ||
324 | - -- 增加机器人 | ||
325 | - if curCount < 3 then | ||
326 | - for i = curCount + 1, 3 do | ||
327 | - while true do | ||
328 | - local id = math.randomInt(1, #csvdb[robotCsv]) | ||
329 | - if not hadRobot[id] then | ||
330 | - hadRobot[id] = 1 | ||
331 | - tempMatch[i] = {t = 2, id = id} | ||
332 | - break | ||
333 | - end | 277 | + assert(mid, "pvp no robot " .. robotCsv) |
278 | + local low = mid - RobotPoolCount / 2 | ||
279 | + local heigh = mid + RobotPoolCount / 2 | ||
280 | + if low < 1 then | ||
281 | + heigh = heigh + (1 - low) | ||
282 | + low = 1 | ||
283 | + end | ||
284 | + if heigh > #csvdb[robotCsv] then | ||
285 | + heigh = #csvdb[robotCsv] | ||
286 | + end | ||
287 | + local pools = {} | ||
288 | + for i = low, heigh do | ||
289 | + if not hadRobot[i] then | ||
290 | + pools[#pools + 1] = i | ||
334 | end | 291 | end |
335 | end | 292 | end |
293 | + local pre = math.floor(#pools / needRobot) | ||
294 | + for i = 1, needRobot do | ||
295 | + local idx = math.randomInt((i - 1) * pre + 1, i * pre) | ||
296 | + tempMatch[#tempMatch + 1] = {t = 2, id = pools[idx]} | ||
297 | + end | ||
336 | end | 298 | end |
337 | self:setProperty(mField, tempMatch) | 299 | self:setProperty(mField, tempMatch) |
338 | end | 300 | end |
339 | 301 | ||
340 | -function Role:refreshPvpMatchC(score) | ||
341 | - self:refreshPvpMatch(score, RANK_PVP_COMMON) | 302 | +-- function Role:refreshPvpMatch(score, rank, rankKey) |
303 | + | ||
304 | +-- local Fields = { | ||
305 | +-- [RANK_PVP_COMMON] = "pvpMC", | ||
306 | +-- [RANK_PVP_HIGHT] = "pvpMH", | ||
307 | +-- } | ||
308 | +-- local RobotCsvs = { | ||
309 | +-- [RANK_PVP_COMMON] = "pvp_robotCsv", | ||
310 | +-- [RANK_PVP_HIGHT] = "pvp_robotCsv", | ||
311 | +-- } | ||
312 | +-- local mField = Fields[rankKey] | ||
313 | +-- local robotCsv = RobotCsvs[rankKey] | ||
314 | +-- local dbKey = self:getPvpDBKey(rankKey) | ||
315 | + | ||
316 | +-- local roleId = self:getProperty("id") | ||
317 | +-- score = score or self:unpackPvpScore(redisproxy:zscore(dbKey, roleId)) | ||
318 | + | ||
319 | +-- local function getPlayers(levels) | ||
320 | +-- local redret = redisproxy:pipelining(function(red) | ||
321 | +-- for _, level in ipairs(levels) do | ||
322 | +-- local low, high = table.unpack(level) | ||
323 | +-- red:zadd(dbKey, low * PVP_RANK_TIME_SORT_PLACE, "std_temp1") | ||
324 | +-- red:zadd(dbKey, high * PVP_RANK_TIME_SORT_PLACE + PVP_RANK_TIME_SORT_PLACE - 1, "std_temp2") | ||
325 | +-- red:ZREVRANK(dbKey, "std_temp1") | ||
326 | +-- red:ZREVRANK(dbKey, "std_temp2") | ||
327 | +-- end | ||
328 | +-- red:zrem(dbKey, "std_temp1", "std_temp2") | ||
329 | +-- end) | ||
330 | + | ||
331 | +-- local PreGetCount = 7 | ||
332 | +-- local redret = redisproxy:pipelining(function(red) | ||
333 | +-- for idx, level in ipairs(levels) do | ||
334 | +-- local rank1 = tonumber(redret[(idx - 1) * 4 + 3]) | ||
335 | +-- local rank2 = tonumber(redret[(idx - 1) * 4 + 4]) | ||
336 | +-- if rank1 - rank2 > PreGetCount then | ||
337 | +-- rank2 = math.randomInt(rank2, rank1 - PreGetCount + 1) | ||
338 | +-- rank1 = rank2 + PreGetCount - 1 | ||
339 | +-- end | ||
340 | +-- red:ZREVRANGE(dbKey, rank2, rank1) | ||
341 | +-- end | ||
342 | +-- end) | ||
343 | +-- return redret | ||
344 | +-- end | ||
345 | + | ||
346 | +-- local findIdx = #globalCsv.pvp_division | ||
347 | +-- for idx, limit in ipairs(globalCsv.pvp_division) do | ||
348 | +-- if score < limit then | ||
349 | +-- findIdx = idx - 1 | ||
350 | +-- break | ||
351 | +-- end | ||
352 | +-- end | ||
353 | +-- local levels = { | ||
354 | +-- {}, {}, {} | ||
355 | +-- } | ||
356 | +-- if globalCsv.pvp_division[findIdx + 1] then | ||
357 | +-- levels[1] = {globalCsv.pvp_division[findIdx + 1], (globalCsv.pvp_division[findIdx + 2] or 100000000) - 1} | ||
358 | +-- end | ||
359 | +-- levels[2] = {globalCsv.pvp_division[findIdx], (globalCsv.pvp_division[findIdx + 1] or 100000000) - 1} | ||
360 | +-- if globalCsv.pvp_division[findIdx - 1] then | ||
361 | +-- levels[3] = {globalCsv.pvp_division[findIdx - 1], globalCsv.pvp_division[findIdx] - 1} | ||
362 | +-- end | ||
363 | +-- local redirect = {} | ||
364 | +-- for i = #levels , 1, -1 do | ||
365 | +-- if not next(levels[i]) then | ||
366 | +-- table.remove(levels, i) | ||
367 | +-- redirect[i] = -1 | ||
368 | +-- for _, v in pairs(redirect) do | ||
369 | +-- redirect[_] = v - 1 | ||
370 | +-- end | ||
371 | +-- else | ||
372 | +-- redirect[i] = i | ||
373 | +-- end | ||
374 | +-- end | ||
375 | + | ||
376 | +-- local result = getPlayers(levels) | ||
377 | +-- local match = self:getProperty(mField) | ||
378 | +-- local hadPlayer = {[roleId] = 1} | ||
379 | +-- local hadRobot = {} | ||
380 | +-- for _, one in pairs(match) do | ||
381 | +-- if one.t == 1 then | ||
382 | +-- hadPlayer[one.id] = 1 | ||
383 | +-- elseif one.t == 2 then | ||
384 | +-- hadRobot[one.id] = 1 | ||
385 | +-- end | ||
386 | +-- end | ||
387 | + | ||
388 | +-- for _, temp in pairs(result) do | ||
389 | +-- for i = #temp, 1, -1 do | ||
390 | +-- local id = tonumber(temp[i]) | ||
391 | +-- if hadPlayer[id] then | ||
392 | +-- table.remove(temp, i) | ||
393 | +-- else | ||
394 | +-- temp[i] = id | ||
395 | +-- hadPlayer[id] = 1 | ||
396 | +-- end | ||
397 | +-- end | ||
398 | +-- end | ||
399 | +-- -- 增加第几个 | ||
400 | +-- local function getPlayer(idx) | ||
401 | +-- for i = idx, 3 do | ||
402 | +-- if redirect[i] ~= -1 then | ||
403 | +-- local curR = result[redirect[i]] or {} | ||
404 | +-- if next(curR) then | ||
405 | +-- local curIdx = math.randomInt(1, #curR) | ||
406 | +-- local objId = curR[curIdx] | ||
407 | +-- table.remove(curR, curIdx) | ||
408 | +-- return objId | ||
409 | +-- end | ||
410 | +-- end | ||
411 | +-- end | ||
412 | +-- end | ||
413 | + | ||
414 | +-- local tempMatch = {} | ||
415 | +-- local curCount = 0 | ||
416 | +-- for i = 1, 3 do | ||
417 | +-- local objId = getPlayer(i) | ||
418 | +-- if objId then | ||
419 | +-- tempMatch[i] = {t = 1, id = objId} | ||
420 | +-- curCount = curCount + 1 | ||
421 | +-- end | ||
422 | +-- end | ||
423 | + | ||
424 | +-- -- 正常的玩家不够了 低一档继续 | ||
425 | +-- if curCount < 3 then | ||
426 | +-- local level = nil | ||
427 | +-- if globalCsv.pvp_division[findIdx - 2] then | ||
428 | +-- level = {globalCsv.pvp_division[findIdx - 2], globalCsv.pvp_division[findIdx - 1] - 1} | ||
429 | +-- end | ||
430 | +-- if level then | ||
431 | +-- local result = getPlayers({level})[1] or {} | ||
432 | +-- for i = #result, 1, -1 do | ||
433 | +-- local id = tonumber(result[i]) | ||
434 | +-- if hadPlayer[id] then | ||
435 | +-- table.remove(result, i) | ||
436 | +-- else | ||
437 | +-- result[i] = id | ||
438 | +-- hadPlayer[id] = 1 | ||
439 | +-- end | ||
440 | +-- end | ||
441 | + | ||
442 | +-- if next(result) then | ||
443 | +-- for i = curCount + 1, 3 do | ||
444 | +-- local curIdx = math.randomInt(1, #result) | ||
445 | +-- local objId = result[curIdx] | ||
446 | +-- table.remove(result, curIdx) | ||
447 | +-- tempMatch[i] = {t = 1, id = objId} | ||
448 | +-- curCount = curCount + 1 | ||
449 | +-- if not next(result) then | ||
450 | +-- break | ||
451 | +-- end | ||
452 | +-- end | ||
453 | +-- end | ||
454 | +-- end | ||
455 | +-- end | ||
456 | + | ||
457 | +-- -- 增加机器人 | ||
458 | +-- if curCount < 3 then | ||
459 | +-- for i = curCount + 1, 3 do | ||
460 | +-- while true do | ||
461 | +-- local id = math.randomInt(1, #csvdb[robotCsv]) | ||
462 | +-- if not hadRobot[id] then | ||
463 | +-- hadRobot[id] = 1 | ||
464 | +-- tempMatch[i] = {t = 2, id = id} | ||
465 | +-- break | ||
466 | +-- end | ||
467 | +-- end | ||
468 | +-- end | ||
469 | +-- end | ||
470 | +-- self:setProperty(mField, tempMatch) | ||
471 | +-- end | ||
472 | + | ||
473 | +function Role:refreshPvpMatchC(score, rank) | ||
474 | + self:refreshPvpMatch(score, rank, RANK_PVP_COMMON) | ||
342 | end | 475 | end |
343 | 476 | ||
344 | -function Role:refreshPvpMatchH(score) | ||
345 | - self:refreshPvpMatch(score, RANK_PVP_HIGHT) | 477 | +function Role:refreshPvpMatchH(score, rank) |
478 | + self:refreshPvpMatch(score, rank, RANK_PVP_HIGHT) | ||
346 | end | 479 | end |
347 | 480 | ||
348 | function Role:getPvpDBKey(ptype) | 481 | function Role:getPvpDBKey(ptype) |
src/models/RoleTask.lua
@@ -48,6 +48,8 @@ local TaskType = { | @@ -48,6 +48,8 @@ local TaskType = { | ||
48 | AdvScore = 410, -- 冒险分数 - score | 48 | AdvScore = 410, -- 冒险分数 - score |
49 | AdvDraw = 411, -- 冒险资助 - count ptype | 49 | AdvDraw = 411, -- 冒险资助 - count ptype |
50 | AdvHang = 412, -- 代理拾荒次数 | 50 | AdvHang = 412, -- 代理拾荒次数 |
51 | + AdvMineKill = 413, -- 宝藏怪击杀 | ||
52 | + AdvMineLayer = 414, -- 宝藏洞激活 | ||
51 | 53 | ||
52 | --爬塔相关 | 54 | --爬塔相关 |
53 | TowerPass = 501, -- 爬塔通关 - level | 55 | TowerPass = 501, -- 爬塔通关 - level |
@@ -218,6 +220,7 @@ local SudokuListener = { | @@ -218,6 +220,7 @@ local SudokuListener = { | ||
218 | } | 220 | } |
219 | 221 | ||
220 | local Activity = require("models.Activity") | 222 | local Activity = require("models.Activity") |
223 | + | ||
221 | local ActivityListener = { | 224 | local ActivityListener = { |
222 | func = "checkActivityTask", | 225 | func = "checkActivityTask", |
223 | listen = { | 226 | listen = { |
@@ -226,6 +229,8 @@ local ActivityListener = { | @@ -226,6 +229,8 @@ local ActivityListener = { | ||
226 | [TaskType.AdvDraw] = {{Activity.ActivityType.AdvDraw, f("count")}}, | 229 | [TaskType.AdvDraw] = {{Activity.ActivityType.AdvDraw, f("count")}}, |
227 | [TaskType.OpenBox] = {{Activity.ActivityType.OpenBox, f("count")}}, | 230 | [TaskType.OpenBox] = {{Activity.ActivityType.OpenBox, f("count")}}, |
228 | [TaskType.Pay] = {{Activity.ActivityType.PayBack, f("twd")}}, | 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,7 +271,6 @@ local CalendaTaskListener = { | ||
266 | } | 271 | } |
267 | } | 272 | } |
268 | 273 | ||
269 | - | ||
270 | local TaskListeners = { | 274 | local TaskListeners = { |
271 | StoryListener, | 275 | StoryListener, |
272 | CommonListener, | 276 | CommonListener, |
@@ -358,11 +362,22 @@ function RoleTask.bind(Role) | @@ -358,11 +362,22 @@ function RoleTask.bind(Role) | ||
358 | return true | 362 | return true |
359 | end | 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 | local checkstoryStatusFunc = { | 375 | local checkstoryStatusFunc = { |
362 | [1] = checkStoryStatusByHang, | 376 | [1] = checkStoryStatusByHang, |
363 | [2] = checkStoryStatusByLove, | 377 | [2] = checkStoryStatusByLove, |
364 | [3] = checkStoryStatusByMultStar, | 378 | [3] = checkStoryStatusByMultStar, |
365 | [4] = checkStoryStatusByAdv, | 379 | [4] = checkStoryStatusByAdv, |
380 | + [5] = checkStoryStatusByActBattle, | ||
366 | } | 381 | } |
367 | 382 | ||
368 | function Role:checkStoryStatus(notNotify, stype, cond1, cond2, cond3) | 383 | function Role:checkStoryStatus(notNotify, stype, cond1, cond2, cond3) |
src/models/RoleTimeReset.lua
@@ -17,6 +17,11 @@ ResetFunc["CrossDay"] = function(self, notify, response, now) | @@ -17,6 +17,11 @@ ResetFunc["CrossDay"] = function(self, notify, response, now) | ||
17 | self:advRandomSupportEffect(not notify) | 17 | self:advRandomSupportEffect(not notify) |
18 | 18 | ||
19 | self:checkExpireItem(not notify) | 19 | self:checkExpireItem(not notify) |
20 | + local advMine = self:getProperty("advMine") | ||
21 | + if advMine[1] then | ||
22 | + advMine[1].co = nil | ||
23 | + end | ||
24 | + self:setProperty("advMine", advMine) | ||
20 | 25 | ||
21 | response.dTask = {} | 26 | response.dTask = {} |
22 | response.advSup = self:getProperty("advSup") | 27 | response.advSup = self:getProperty("advSup") |
@@ -24,10 +29,16 @@ ResetFunc["CrossDay"] = function(self, notify, response, now) | @@ -24,10 +29,16 @@ ResetFunc["CrossDay"] = function(self, notify, response, now) | ||
24 | end | 29 | end |
25 | 30 | ||
26 | ResetFunc["CrossWeek"] = function(self, notify, response) | 31 | ResetFunc["CrossWeek"] = function(self, notify, response) |
32 | + local advMine = self:getProperty("advMine") | ||
33 | + if advMine[2] then | ||
34 | + advMine[2].co = nil | ||
35 | + end | ||
27 | self:setProperties({ | 36 | self:setProperties({ |
28 | wTask = {}, | 37 | wTask = {}, |
29 | dinerS = {}, | 38 | dinerS = {}, |
39 | + advMine = advMine, | ||
30 | }) | 40 | }) |
41 | + | ||
31 | response.wTask = {} | 42 | response.wTask = {} |
32 | response.dinerS = {} | 43 | response.dinerS = {} |
33 | end | 44 | end |
src/models/Store.lua
@@ -33,6 +33,8 @@ Store.schema = { | @@ -33,6 +33,8 @@ Store.schema = { | ||
33 | actGoodsFlag = {"table", {}}, -- ActGoodsType 1购买,0未购买 | 33 | actGoodsFlag = {"table", {}}, -- ActGoodsType 1购买,0未购买 |
34 | 34 | ||
35 | bpInfo = {"table", {}}, -- battle pass 探索指令 1={flag=0 为1表示买了,br=""付费领取记录, fr=""免费领取记录},2,3,4 | 35 | bpInfo = {"table", {}}, -- battle pass 探索指令 1={flag=0 为1表示买了,br=""付费领取记录, fr=""免费领取记录},2,3,4 |
36 | + | ||
37 | + totalRR = {"string", ""}, -- 累计充值奖励领取记录 | ||
36 | } | 38 | } |
37 | 39 | ||
38 | function Store:updateProperty(params) | 40 | function Store:updateProperty(params) |
@@ -296,6 +298,8 @@ function Store:resetStoreReored(resetId) | @@ -296,6 +298,8 @@ function Store:resetStoreReored(resetId) | ||
296 | end | 298 | end |
297 | end | 299 | end |
298 | end | 300 | end |
301 | + else | ||
302 | + payRecord[k] = nil | ||
299 | end | 303 | end |
300 | end | 304 | end |
301 | self:updateProperty({field = "payR", value = payRecord}) | 305 | self:updateProperty({field = "payR", value = payRecord}) |
@@ -305,6 +309,8 @@ function Store:resetStoreReored(resetId) | @@ -305,6 +309,8 @@ function Store:resetStoreReored(resetId) | ||
305 | if config.resetTime == resetId then | 309 | if config.resetTime == resetId then |
306 | buyRecord[k] = nil | 310 | buyRecord[k] = nil |
307 | end | 311 | end |
312 | + else | ||
313 | + buyRecord[k] = nil | ||
308 | end | 314 | end |
309 | end | 315 | end |
310 | self:updateProperty({field = "buyR", value = buyRecord}) | 316 | self:updateProperty({field = "buyR", value = buyRecord}) |
@@ -464,6 +470,7 @@ function Store:data() | @@ -464,6 +470,7 @@ function Store:data() | ||
464 | --packTrigger = self:getProperty("packTrigger"), | 470 | --packTrigger = self:getProperty("packTrigger"), |
465 | actGoodsFlag = self:getProperty("actGoodsFlag"), | 471 | actGoodsFlag = self:getProperty("actGoodsFlag"), |
466 | bpInfo = self:getProperty("bpInfo"), | 472 | bpInfo = self:getProperty("bpInfo"), |
473 | + totalRR = self:getProperty("totalRR"), | ||
467 | } | 474 | } |
468 | end | 475 | end |
469 | 476 |
src/services/agent_ctrl.lua
@@ -6,6 +6,7 @@ local xxtea = require "xxtea" | @@ -6,6 +6,7 @@ local xxtea = require "xxtea" | ||
6 | local deque = require "deque" | 6 | local deque = require "deque" |
7 | local datacenter = require "skynet.datacenter" | 7 | local datacenter = require "skynet.datacenter" |
8 | local agent_queued = require "services.agent_queued" | 8 | local agent_queued = require "services.agent_queued" |
9 | +local logproxy = require "shared.logproxy" | ||
9 | 10 | ||
10 | local pcall = pcall | 11 | local pcall = pcall |
11 | local string_format = string.format | 12 | local string_format = string.format |
@@ -139,11 +140,11 @@ function _M:check_agent_status() | @@ -139,11 +140,11 @@ function _M:check_agent_status() | ||
139 | end | 140 | end |
140 | end | 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 | next_log_time = now + 60 | 144 | next_log_time = now + 60 |
144 | local count = table_nums(self.u2f) | 145 | local count = table_nums(self.u2f) |
145 | datacenter.set("onlineCount", count) | 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 | end | 148 | end |
148 | end | 149 | end |
149 | 150 |
src/services/dbseed.lua
@@ -34,8 +34,6 @@ local steps = { | @@ -34,8 +34,6 @@ local steps = { | ||
34 | } | 34 | } |
35 | 35 | ||
36 | skynet.start(function () | 36 | skynet.start(function () |
37 | - redisd = skynet.localname(".redis") | ||
38 | - | ||
39 | redisproxy = require("shared.redisproxy") | 37 | redisproxy = require("shared.redisproxy") |
40 | 38 | ||
41 | local new = redisproxy:hsetnx("autoincrement_set", "server_start", os.date("%Y%m%d", skynet.timex())) == 1 | 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,6 +7,7 @@ require "shared.init" | ||
7 | require "utils.init" | 7 | require "utils.init" |
8 | require "RedisKeys" | 8 | require "RedisKeys" |
9 | require "skynet.manager" | 9 | require "skynet.manager" |
10 | +require "GlobalVar" | ||
10 | 11 | ||
11 | 12 | ||
12 | local ipairs = ipairs | 13 | local ipairs = ipairs |
@@ -16,6 +17,7 @@ local string_format = string.format | @@ -16,6 +17,7 @@ local string_format = string.format | ||
16 | 17 | ||
17 | 18 | ||
18 | local CHECK_MAIL_STATUS_INTERVAL = 100 * 60 | 19 | local CHECK_MAIL_STATUS_INTERVAL = 100 * 60 |
20 | +local CHECK_BATTLE_ACT_CLOSE_INTERVAL = 100 * 1 | ||
19 | local function mailQuene() | 21 | local function mailQuene() |
20 | local delayEmail = tonum(redisproxy:hget("autoincrement_set", "delay_email")) | 22 | local delayEmail = tonum(redisproxy:hget("autoincrement_set", "delay_email")) |
21 | if delayEmail == 0 then | 23 | if delayEmail == 0 then |
@@ -91,6 +93,64 @@ local function check_mail_queue() | @@ -91,6 +93,64 @@ local function check_mail_queue() | ||
91 | skynet.timeout(CHECK_MAIL_STATUS_INTERVAL, check_mail_queue) | 93 | skynet.timeout(CHECK_MAIL_STATUS_INTERVAL, check_mail_queue) |
92 | end | 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 | local CMD = {} | 156 | local CMD = {} |
@@ -115,6 +175,7 @@ end | @@ -115,6 +175,7 @@ end | ||
115 | 175 | ||
116 | function CMD.start() | 176 | function CMD.start() |
117 | check_mail_queue() | 177 | check_mail_queue() |
178 | + check_battle_act_close() | ||
118 | end | 179 | end |
119 | 180 | ||
120 | local function __init__() | 181 | local function __init__() |
@@ -129,7 +190,6 @@ local function __init__() | @@ -129,7 +190,6 @@ local function __init__() | ||
129 | end | 190 | end |
130 | end | 191 | end |
131 | end) | 192 | end) |
132 | - redisd = skynet.localname(".redis") | ||
133 | skynet.register(".globald") | 193 | skynet.register(".globald") |
134 | 194 | ||
135 | end | 195 | end |
src/services/httpweb.lua
@@ -53,12 +53,8 @@ end | @@ -53,12 +53,8 @@ end | ||
53 | local CMD = require "actions.HttpAction" | 53 | local CMD = require "actions.HttpAction" |
54 | 54 | ||
55 | local function start() | 55 | local function start() |
56 | - redisd = skynet.localname(".redis") | ||
57 | globalCsv = csvdb["GlobalDefineCsv"] | 56 | globalCsv = csvdb["GlobalDefineCsv"] |
58 | 57 | ||
59 | - if tonumber(skynet.getenv "logd") == 1 then | ||
60 | - logd = skynet.localname(".log") | ||
61 | - end | ||
62 | 58 | ||
63 | local listen_socket = socket.listen("0.0.0.0", port) | 59 | local listen_socket = socket.listen("0.0.0.0", port) |
64 | print("Listen web port " .. port) | 60 | print("Listen web port " .. port) |
@@ -77,11 +73,11 @@ local function start() | @@ -77,11 +73,11 @@ local function start() | ||
77 | return | 73 | return |
78 | end | 74 | end |
79 | local query = urllib.parse_query(query) | 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 | local content = CMD[cmd](query, body) | 81 | local content = CMD[cmd](query, body) |
86 | if not content then | 82 | if not content then |
87 | code = 404 | 83 | code = 404 |
src/services/logd.lua
@@ -2,12 +2,12 @@ local skynet = require "skynet" | @@ -2,12 +2,12 @@ local skynet = require "skynet" | ||
2 | local queue = require "skynet.queue" | 2 | local queue = require "skynet.queue" |
3 | local bson = require "bson" | 3 | local bson = require "bson" |
4 | local socketdriver = require "skynet.socketdriver" | 4 | local socketdriver = require "skynet.socketdriver" |
5 | - | ||
6 | local serverId = tonumber(skynet.getenv("servId")) | 5 | local serverId = tonumber(skynet.getenv("servId")) |
7 | 6 | ||
8 | require "shared.init" | 7 | require "shared.init" |
9 | require "skynet.manager" | 8 | require "skynet.manager" |
10 | 9 | ||
10 | +local logdIdx = ... | ||
11 | local table_insert = table.insert | 11 | local table_insert = table.insert |
12 | local pairs = pairs | 12 | local pairs = pairs |
13 | local ipairs = ipairs | 13 | local ipairs = ipairs |
@@ -15,6 +15,7 @@ local string_format = string.format | @@ -15,6 +15,7 @@ local string_format = string.format | ||
15 | 15 | ||
16 | local logId = 0 | 16 | local logId = 0 |
17 | local CMD, cs = {} | 17 | local CMD, cs = {} |
18 | +local prefix = "wasteland" .. logdIdx .. "S" .. serverId .. "C" | ||
18 | 19 | ||
19 | local logHandle = { | 20 | local logHandle = { |
20 | bi = { | 21 | bi = { |
@@ -33,7 +34,7 @@ local logHandle = { | @@ -33,7 +34,7 @@ local logHandle = { | ||
33 | doc["game_name"] = "wasteland" | 34 | doc["game_name"] = "wasteland" |
34 | doc["env"] = "cb" | 35 | doc["env"] = "cb" |
35 | doc["game_name_type"] = "guaji" | 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 | logId = (logId + 1) % 10000000 | 38 | logId = (logId + 1) % 10000000 |
38 | end | 39 | end |
39 | }, | 40 | }, |
@@ -135,7 +136,7 @@ local function __init__() | @@ -135,7 +136,7 @@ local function __init__() | ||
135 | end) | 136 | end) |
136 | cs = queue() | 137 | cs = queue() |
137 | 138 | ||
138 | - skynet.register(".log") | 139 | + skynet.register(".logd" .. logdIdx) |
139 | end | 140 | end |
140 | 141 | ||
141 | skynet.start(__init__) | 142 | skynet.start(__init__) |
src/services/pvpd.lua
@@ -289,7 +289,6 @@ end | @@ -289,7 +289,6 @@ end | ||
289 | 289 | ||
290 | ------------------------------------------------------ | 290 | ------------------------------------------------------ |
291 | function CMD.start() | 291 | function CMD.start() |
292 | - redisd = skynet.localname(".redis") | ||
293 | globalCsv = csvdb["GlobalDefineCsv"] | 292 | globalCsv = csvdb["GlobalDefineCsv"] |
294 | 293 | ||
295 | pvpInfo = require("models.Pvpd").new({key = "cross:pvpInfo"}) | 294 | pvpInfo = require("models.Pvpd").new({key = "cross:pvpInfo"}) |
src/services/redisd.lua
@@ -3,7 +3,7 @@ require "skynet.manager" | @@ -3,7 +3,7 @@ require "skynet.manager" | ||
3 | local redis = require "skynet.db.redis" | 3 | local redis = require "skynet.db.redis" |
4 | 4 | ||
5 | local db | 5 | local db |
6 | - | 6 | +local idx = ... |
7 | local command = {} | 7 | local command = {} |
8 | 8 | ||
9 | function command.open(conf) | 9 | function command.open(conf) |
@@ -25,7 +25,7 @@ skynet.start(function() | @@ -25,7 +25,7 @@ skynet.start(function() | ||
25 | end | 25 | end |
26 | end) | 26 | end) |
27 | skynet.info_func(function() | 27 | skynet.info_func(function() |
28 | - skynet.ret(skynet.pack(skynet.call(skynet.self(), "debug", "STAT"))) | 28 | + return skynet.stat("mqlen") |
29 | end) | 29 | end) |
30 | - skynet.register ".redis" | 30 | + skynet.register(".redis" .. idx) |
31 | end) | 31 | end) |
32 | \ No newline at end of file | 32 | \ No newline at end of file |
src/services/watchdog.lua
1 | local skynet = require "skynet" | 1 | local skynet = require "skynet" |
2 | require "skynet.manager" | 2 | require "skynet.manager" |
3 | -local redisproxy = require "shared.redisproxy" | ||
4 | local socket = require "skynet.socket" | 3 | local socket = require "skynet.socket" |
5 | local netpack = require "skynet.netpack" | 4 | local netpack = require "skynet.netpack" |
6 | local datacenter = require "skynet.datacenter" | 5 | local datacenter = require "skynet.datacenter" |
@@ -47,7 +46,7 @@ function SOCKET.data(fd, msg) | @@ -47,7 +46,7 @@ function SOCKET.data(fd, msg) | ||
47 | end | 46 | end |
48 | end | 47 | end |
49 | 48 | ||
50 | -local use_logd = tonumber(skynet.getenv "logd") | 49 | + |
51 | 50 | ||
52 | -- @desc: agent状态定时检测 | 51 | -- @desc: agent状态定时检测 |
53 | function check_agent_status() | 52 | function check_agent_status() |
@@ -65,11 +64,7 @@ end | @@ -65,11 +64,7 @@ end | ||
65 | 64 | ||
66 | function CMD.start(conf) | 65 | function CMD.start(conf) |
67 | skynet.call(gate_serv, "lua", "open" , conf) | 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 | skynet.call(pvpd, "lua", "start") | 68 | skynet.call(pvpd, "lua", "start") |
74 | -- 开启agent状态检测定时器 | 69 | -- 开启agent状态检测定时器 |
75 | check_agent_status() | 70 | check_agent_status() |
@@ -110,17 +105,11 @@ skynet.start(function() | @@ -110,17 +105,11 @@ skynet.start(function() | ||
110 | end | 105 | end |
111 | end) | 106 | end) |
112 | skynet.register ".watchdog" | 107 | skynet.register ".watchdog" |
113 | - -- 数据库服务 | ||
114 | - redisd = skynet.newservice("services/redisd") | ||
115 | 108 | ||
116 | -- 提前加载好 | 109 | -- 提前加载好 |
117 | csvdata.init() | 110 | csvdata.init() |
118 | print("launch csvdatad ...") | 111 | print("launch csvdatad ...") |
119 | 112 | ||
120 | - -- 日志服务 | ||
121 | - if use_logd == 1 then | ||
122 | - logd = skynet.newservice("services/logd") | ||
123 | - end | ||
124 | -- pvp 服务 | 113 | -- pvp 服务 |
125 | pvpd = skynet.newservice("services/pvpd") | 114 | pvpd = skynet.newservice("services/pvpd") |
126 | cluster.register("pvpd", pvpd) | 115 | cluster.register("pvpd", pvpd) |
@@ -0,0 +1,23 @@ | @@ -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 | \ No newline at end of file | 24 | \ No newline at end of file |
src/shared/redisproxy.lua
1 | local skynet = require "skynet" | 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 | local table_insert = table.insert | 11 | local table_insert = table.insert |
5 | 12 | ||
6 | local redisproxy = {} | 13 | local redisproxy = {} |
7 | 14 | ||
8 | - | ||
9 | local isUsePika = false | 15 | local isUsePika = false |
10 | 16 | ||
11 | 17 |