Commit ce3e592c4fdc78a079b35346ecd1b170770a4e91
Merge branch 'bugfix' into tr/ts
* bugfix: (130 commits) 掉落活动配置最大掉落周期数 拆解周活动跨轮数据异常bug 道具开时钟箱,检查箱子够不够 增加电台任务日志完成类型 空的是nil appid 讨伐电台日志增加 开始结束 log 发现的bug bug 取消抽卡保底的保底次数默认值,因为有些卡池不需要保底 邮件 活动奖励bug cb 返利调整 世界boss 胜利才扣门票,扫荡根据之前的最大值给行动点 任务 付费签到规则改为按登录天数计算进度, 世界boss 解锁条件修改 活动卡池保底出指定英雄 拆解术式充能的时候领取道具,获得个数计算错误 新手卡池限制30抽 ... # Conflicts: # config/nodenames.lua
Showing
58 changed files
with
4095 additions
and
1034 deletions
Show diff stats
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 | ||
@@ -125,7 +134,8 @@ ItemId = { | @@ -125,7 +134,8 @@ ItemId = { | ||
125 | RuneFragment = 24, | 134 | RuneFragment = 24, |
126 | HeroFC = {700, 701, 702, 703}, --通用角色碎片 | 135 | HeroFC = {700, 701, 702, 703}, --通用角色碎片 |
127 | AdvKey = 80, -- 冒险钥匙 | 136 | AdvKey = 80, -- 冒险钥匙 |
128 | - BoxKey = 60, -- 拆解工具 | 137 | + AdvPower = 4701, -- 拾荒体力 |
138 | + CrisisScore = 8010, -- 积分 | ||
129 | } | 139 | } |
130 | 140 | ||
131 | TimeReset = { | 141 | TimeReset = { |
@@ -213,6 +223,7 @@ AdvBackEventType = { | @@ -213,6 +223,7 @@ AdvBackEventType = { | ||
213 | Level = 25, -- 升级 | 223 | Level = 25, -- 升级 |
214 | LinkChooseOver = 26, -- 连锁事件结束 | 224 | LinkChooseOver = 26, -- 连锁事件结束 |
215 | BuffEffect = 27, -- buff 效果 | 225 | BuffEffect = 27, -- buff 效果 |
226 | + PassiveEffect = 28, -- 被动 效果 | ||
216 | } | 227 | } |
217 | 228 | ||
218 | AdvScoreType = { | 229 | AdvScoreType = { |
@@ -281,6 +292,10 @@ CardType = { | @@ -281,6 +292,10 @@ CardType = { | ||
281 | BattlePassCard = 7, -- 探索指令 | 292 | BattlePassCard = 7, -- 探索指令 |
282 | } | 293 | } |
283 | 294 | ||
295 | +ShopPackType = { | ||
296 | + ActShopPack = 5, -- 活动礼包 | ||
297 | +} | ||
298 | + | ||
284 | HeroQuality = { | 299 | HeroQuality = { |
285 | N = 1, | 300 | N = 1, |
286 | R = 2, | 301 | R = 2, |
@@ -303,9 +318,12 @@ MailId = { | @@ -303,9 +318,12 @@ MailId = { | ||
303 | ActDrawCardReward = 222, | 318 | ActDrawCardReward = 222, |
304 | ActAdvDrawReward = 223, | 319 | ActAdvDrawReward = 223, |
305 | ActOpenBoxReward = 224, | 320 | ActOpenBoxReward = 224, |
321 | + ActItemRecycle = 225, | ||
306 | 322 | ||
307 | PaySignAward = 241, | 323 | PaySignAward = 241, |
308 | PayBackAward = 242, | 324 | PayBackAward = 242, |
325 | + CBBackAward = 243, | ||
326 | + CBBackAward2 = 244, | ||
309 | } | 327 | } |
310 | 328 | ||
311 | TriggerEventType = { | 329 | TriggerEventType = { |
@@ -322,4 +340,13 @@ DrawCardType = { | @@ -322,4 +340,13 @@ DrawCardType = { | ||
322 | SpecifyDraw = 1, | 340 | SpecifyDraw = 1, |
323 | NormalDraw = 2, | 341 | NormalDraw = 2, |
324 | FriendDraw = 3 | 342 | FriendDraw = 3 |
343 | +} | ||
344 | + | ||
345 | +-- 阵容系统类型 | ||
346 | +TeamSystemType = { | ||
347 | + Hang = 1, | ||
348 | + BonusBattle = 2, | ||
349 | + Tower = 3, | ||
350 | + Dinner = 4, | ||
351 | + FriendBattle = 5, | ||
325 | } | 352 | } |
326 | \ No newline at end of file | 353 | \ No newline at end of file |
src/ProtocolCode.lua
@@ -49,6 +49,8 @@ actionCodes = { | @@ -49,6 +49,8 @@ actionCodes = { | ||
49 | Role_updateFeedbackInfoRpc = 133, | 49 | Role_updateFeedbackInfoRpc = 133, |
50 | Role_useSelectItemRpc = 134, -- 使用多选一礼包 | 50 | Role_useSelectItemRpc = 134, -- 使用多选一礼包 |
51 | Role_broadGetSSR = 135, -- 全服广播 获得ssr英雄 | 51 | Role_broadGetSSR = 135, -- 全服广播 获得ssr英雄 |
52 | + Role_renameTeamRpc = 136, -- 编队改名 | ||
53 | + Role_accuseRpc = 137, -- 举报 | ||
52 | 54 | ||
53 | Adv_startAdvRpc = 151, | 55 | Adv_startAdvRpc = 151, |
54 | Adv_startHangRpc = 152, | 56 | Adv_startHangRpc = 152, |
@@ -71,6 +73,8 @@ actionCodes = { | @@ -71,6 +73,8 @@ actionCodes = { | ||
71 | Adv_rankRpc = 169, | 73 | Adv_rankRpc = 169, |
72 | Adv_quickHangRpc = 170, | 74 | Adv_quickHangRpc = 170, |
73 | Adv_refreshSupportRpc = 171, | 75 | Adv_refreshSupportRpc = 171, |
76 | + Adv_selectTeamRpc = 172, | ||
77 | + Adv_roleFormatRpc = 173, | ||
74 | 78 | ||
75 | Hero_loadInfos = 201, | 79 | Hero_loadInfos = 201, |
76 | Hero_updateProperty = 202, | 80 | Hero_updateProperty = 202, |
@@ -96,6 +100,8 @@ actionCodes = { | @@ -96,6 +100,8 @@ actionCodes = { | ||
96 | Hero_unlockPoolRpc = 222, | 100 | Hero_unlockPoolRpc = 222, |
97 | Hero_changeCrown = 223, | 101 | Hero_changeCrown = 223, |
98 | Hero_drawHeroExtraRewardNtf = 224, | 102 | Hero_drawHeroExtraRewardNtf = 224, |
103 | + Hero_itemComposeRpc = 225, | ||
104 | + Hero_setWishPoolRpc = 226, | ||
99 | 105 | ||
100 | Hang_startRpc = 251, | 106 | Hang_startRpc = 251, |
101 | Hang_checkRpc = 252, | 107 | Hang_checkRpc = 252, |
@@ -111,6 +117,7 @@ actionCodes = { | @@ -111,6 +117,7 @@ actionCodes = { | ||
111 | Hang_hangGiftRpc = 262, | 117 | Hang_hangGiftRpc = 262, |
112 | Hang_bagFieldRpc = 263, | 118 | Hang_bagFieldRpc = 263, |
113 | Hang_chatLineRpc = 264, | 119 | Hang_chatLineRpc = 264, |
120 | + Hang_selectTeamRpc = 265, | ||
114 | 121 | ||
115 | Diner_updateProperty = 300, | 122 | Diner_updateProperty = 300, |
116 | Diner_addSellRpc = 301, | 123 | Diner_addSellRpc = 301, |
@@ -197,6 +204,7 @@ actionCodes = { | @@ -197,6 +204,7 @@ actionCodes = { | ||
197 | Store_getGrowFundRewardRpc = 561, --成长助力奖励 | 204 | Store_getGrowFundRewardRpc = 561, --成长助力奖励 |
198 | Store_getBattlePassRewardRpc = 562, --赛季卡奖励 | 205 | Store_getBattlePassRewardRpc = 562, --赛季卡奖励 |
199 | Store_getExploreCommandRewardRpc = 563, --探索指令 | 206 | Store_getExploreCommandRewardRpc = 563, --探索指令 |
207 | + Store_getTotalRechargeAwardRpc = 564, -- 累计充值 | ||
200 | 208 | ||
201 | 209 | ||
202 | Email_listRpc = 600, | 210 | Email_listRpc = 600, |
@@ -212,6 +220,19 @@ actionCodes = { | @@ -212,6 +220,19 @@ actionCodes = { | ||
212 | Activity_actPaySignRewardNtf = 654, | 220 | Activity_actPaySignRewardNtf = 654, |
213 | Activity_actCalendaTaskRpc = 655, | 221 | Activity_actCalendaTaskRpc = 655, |
214 | 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, | ||
232 | + | ||
233 | + Radio_startQuestRpc = 700, | ||
234 | + Radio_finishQuestRpc = 701, | ||
235 | + Radio_cancelQuestRpc = 702, | ||
215 | } | 236 | } |
216 | 237 | ||
217 | 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
@@ -192,13 +192,13 @@ function _M.actPaySignRpc(agent, data) | @@ -192,13 +192,13 @@ function _M.actPaySignRpc(agent, data) | ||
192 | local open, actId = role.activity:isOpen("PaySignIn") | 192 | local open, actId = role.activity:isOpen("PaySignIn") |
193 | if not open then return 2 end | 193 | if not open then return 2 end |
194 | 194 | ||
195 | - local diffDay = diffFromTs(ts) + 1 | 195 | + --local diffDay = diffFromTs(ts) + 1 |
196 | 196 | ||
197 | local curData = role.activity:getActData("PaySignIn") | 197 | local curData = role.activity:getActData("PaySignIn") |
198 | if not curData then return 3 end | 198 | if not curData then return 3 end |
199 | local reward, change = {} | 199 | local reward, change = {} |
200 | for day, csvData in ipairs(csvdb["pay_signInCsv"]) do | 200 | for day, csvData in ipairs(csvdb["pay_signInCsv"]) do |
201 | - if day <= diffDay and day == dayIndex then | 201 | + if day <= (curData[0] or 0) and day == dayIndex then |
202 | if not curData[day] then | 202 | if not curData[day] then |
203 | curData[day] = 1 | 203 | curData[day] = 1 |
204 | -- 奖励 | 204 | -- 奖励 |
@@ -263,4 +263,611 @@ function _M.actCalendaTaskRpc(agent, data) | @@ -263,4 +263,611 @@ 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 | + local actCtrlData = csvdb["activity_ctrlCsv"][actid] | ||
379 | + if not actCtrlData then return end | ||
380 | + | ||
381 | + local actCfg = csvdb["activity_putCsv"][actid] | ||
382 | + if not actCfg then return 2 end | ||
383 | + | ||
384 | + local award, period = "", 0 | ||
385 | + for i = 1, #actCfg do | ||
386 | + local cfg = actCfg[i] | ||
387 | + if not cfg then | ||
388 | + break | ||
389 | + end | ||
390 | + if cfg.condition ~= "" then | ||
391 | + local arr = cfg.condition:toArray(true, "=") | ||
392 | + local type = arr[1] | ||
393 | + if type == 1 then | ||
394 | + local actId = arr[2] | ||
395 | + local carbonId = arr[3] | ||
396 | + if not role.activity:isOpenById(actId, "ChallengeLevel") then return 3 end | ||
397 | + local clInfo = role.activity:getActData("ChallengeLevel") or {} | ||
398 | + if not clInfo[carbonId] then | ||
399 | + break | ||
400 | + end | ||
401 | + end | ||
402 | + end | ||
403 | + award = cfg.reward | ||
404 | + period = cfg.period * 60 | ||
405 | + end | ||
406 | + local actData = role.activity:getActData("HangDrop") or 0 | ||
407 | + local timeNow = skynet.timex() | ||
408 | + if period == 0 or award == "" then | ||
409 | + return 4 | ||
410 | + end | ||
411 | + local num = math.floor((timeNow - actData)/ period) | ||
412 | + num = num > actCtrlData.condition and actCtrlData.condition or num | ||
413 | + if num == 0 then | ||
414 | + return 5 | ||
415 | + end | ||
416 | + local reward, change = {}, nil | ||
417 | + for id, value in pairs(award:toNumMap()) do | ||
418 | + reward[id] = value * num | ||
419 | + end | ||
420 | + | ||
421 | + reward, change = role:award(reward, {log = {desc = "actHangDrop", int1 = actid, int2 = num}}) | ||
422 | + | ||
423 | + if num < 8 then | ||
424 | + actData = actData + num * period | ||
425 | + else | ||
426 | + actData = timeNow | ||
427 | + end | ||
428 | + | ||
429 | + role.activity:updateActData("HangDrop", actData) | ||
430 | + | ||
431 | + SendPacket(actionCodes.Activity_hangDropRpc, MsgPack.pack(role:packReward(reward, change))) | ||
432 | + | ||
433 | + return true | ||
434 | +end | ||
435 | + | ||
436 | +local function getStarCount(cfg, data) | ||
437 | + local count = 0 | ||
438 | + for i = 0, #(cfg.sweep_condition:toTableArray(true)) do | ||
439 | + if (1 << i & data) > 0 then | ||
440 | + count = count + 1 | ||
441 | + end | ||
442 | + end | ||
443 | + | ||
444 | + return count | ||
445 | +end | ||
446 | + | ||
447 | +function _M.startBattleRpc(agent, data) | ||
448 | + local role = agent.role | ||
449 | + local msg = MsgPack.unpack(data) | ||
450 | + local actid = msg.actid | ||
451 | + local id = msg.id | ||
452 | + local count = msg.count | ||
453 | + if not role.activity:isOpenById(actid, "ChallengeLevel") then return 1 end | ||
454 | + | ||
455 | + local actCfg = csvdb["activity_battleCsv"][actid] | ||
456 | + if not actCfg then return 2 end | ||
457 | + | ||
458 | + local battleCfg = actCfg[id] | ||
459 | + if not battleCfg then return 3 end | ||
460 | + | ||
461 | + local actData = role.activity:getActData("ChallengeLevel") or {} | ||
462 | + | ||
463 | + local preArr = battleCfg.prepose:toArray(true, "=") | ||
464 | + for _, v in ipairs(preArr) do | ||
465 | + local battleInfo = actData[v] | ||
466 | + if not battleInfo then | ||
467 | + return 4 | ||
468 | + end | ||
469 | + local star = battleInfo["star"] or 0 | ||
470 | + if star <= 0 then | ||
471 | + return 4 | ||
472 | + end | ||
473 | + end | ||
474 | + -- check cost | ||
475 | + local changeFlag = false | ||
476 | + local ticket = actData["ticket"] | ||
477 | + local num = 0 -- cost num | ||
478 | + if battleCfg.type ~= "" then | ||
479 | + role.activity:getBattleTicket(actid) | ||
480 | + num = battleCfg.type:toArray(true, "=")[3] | ||
481 | + if count and count > 0 then | ||
482 | + if battleCfg.rank == 0 then | ||
483 | + return 7 | ||
484 | + end | ||
485 | + local bi = actData[id] | ||
486 | + if not bi then return 8 end | ||
487 | + local star = bi["star"] or 0 | ||
488 | + if star < 1 then | ||
489 | + return 9 | ||
490 | + end | ||
491 | + num = num * count | ||
492 | + end | ||
493 | + if ticket < num then | ||
494 | + return 6 | ||
495 | + end | ||
496 | + changeFlag = true | ||
497 | + end | ||
498 | + -- 解锁活动剧情 | ||
499 | + role:checkStoryStatus(false, 5, id) | ||
500 | + | ||
501 | + if not count then | ||
502 | + role.__actBattleCache = { | ||
503 | + key = tostring(math.random()), | ||
504 | + actid = actid, | ||
505 | + id = id, | ||
506 | + } | ||
507 | + SendPacket(actionCodes.Activity_startBattleRpc, MsgPack.pack({key = role.__actBattleCache.key})) | ||
508 | + else | ||
509 | + if count <= 0 then | ||
510 | + return | ||
511 | + end | ||
512 | + if battleCfg.rank == 0 then | ||
513 | + return 7 | ||
514 | + end | ||
515 | + local bi = actData[id] | ||
516 | + local star = bi["star"] | ||
517 | + local award = battleCfg.item_clear:toNumMap() | ||
518 | + if getStarCount(battleCfg, star) == 3 then | ||
519 | + local aw = battleCfg.perfect_reward:toNumMap() | ||
520 | + for k, v in pairs(aw) do | ||
521 | + award[k] = (award[k] or 0) + v | ||
522 | + end | ||
523 | + end | ||
524 | + for k, v in pairs(award) do | ||
525 | + award[k] = v * count | ||
526 | + end | ||
527 | + local reward, change = role:award(award, {log = {desc = "actBattle", int1 = actid, int2 = count or 0}}) | ||
528 | + SendPacket(actionCodes.Activity_startBattleRpc, MsgPack.pack(role:packReward(reward, change))) | ||
529 | + | ||
530 | + if battleCfg.worldBoss_award ~= 0 and (bi["maxP"] or 0) > 0 then | ||
531 | + bi["bossP"] = (bi["bossP"] or 0) + bi["maxP"] | ||
532 | + end | ||
533 | + | ||
534 | + bi["sum"] = bi["sum"] + bi["top"] | ||
535 | + actData["ticket"] = ticket - num | ||
536 | + actData[id] = bi | ||
537 | + changeFlag = true | ||
538 | + | ||
539 | + local rankVal = 0 | ||
540 | + if battleCfg.rank == 1 then | ||
541 | + rankVal = bi["sum"] | ||
542 | + elseif battleCfg.rank == 2 then | ||
543 | + rankVal = bi["top"] | ||
544 | + end | ||
545 | + role:updateRankCommon(RANK_TYPE.ActBattleBoss, rankVal) | ||
546 | + end | ||
547 | + if changeFlag then | ||
548 | + role.activity:updateActData("ChallengeLevel", actData) | ||
549 | + end | ||
550 | + | ||
551 | + return true | ||
552 | +end | ||
553 | + | ||
554 | +function _M.endBattleRpc(agent, data) | ||
555 | + local role = agent.role | ||
556 | + local msg = MsgPack.unpack(data) | ||
557 | + local actid = msg.actid | ||
558 | + local id = msg.id | ||
559 | + local key = msg.key | ||
560 | + local isWin = msg.isWin | ||
561 | + local heros = msg.heros | ||
562 | + local support = msg.support | ||
563 | + if not role.activity:isOpenById(actid, "ChallengeLevel") then return 1 end | ||
564 | + | ||
565 | + if not role.__actBattleCache then return 2 end | ||
566 | + | ||
567 | + if role.__actBattleCache.id ~= id or role.__actBattleCache.key ~= key and role.__actBattleCache.actid ~= actid then | ||
568 | + SendPacket(actionCodes.Activity_endBattleRpc, MsgPack.pack({errorCode = 1})) | ||
569 | + end | ||
570 | + | ||
571 | + local actCfg = csvdb["activity_battleCsv"][actid] | ||
572 | + if not actCfg then return 3 end | ||
573 | + | ||
574 | + local battleCfg = actCfg[id] | ||
575 | + if not battleCfg then return 4 end | ||
576 | + | ||
577 | + local actData = role.activity:getActData("ChallengeLevel") or {} | ||
578 | + | ||
579 | + -- 总输出 | ||
580 | + local dmg = 0 | ||
581 | + for k, v in pairs(msg.info.damage) do | ||
582 | + if k % 100 == 2 then | ||
583 | + dmg = dmg + v | ||
584 | + end | ||
585 | + end | ||
586 | + | ||
587 | + local reward, change = {}, nil | ||
588 | + | ||
589 | + local battleInfo = actData[id] or {} | ||
590 | + local curStar = 0 | ||
591 | + if isWin then | ||
592 | + local herosInfo = msg.heros | ||
593 | + | ||
594 | + local check = {} | ||
595 | + -- 1 通关 | ||
596 | + check[1] = function(_) | ||
597 | + return true | ||
598 | + end | ||
599 | + -- 2 阵亡人数 <= N | ||
600 | + check[2] = function(_, cond) | ||
601 | + return msg.info.dead and msg.info.dead <= cond | ||
602 | + end | ||
603 | + -- 3 全员存活 | ||
604 | + check[3] = function(_) | ||
605 | + return msg.info.dead and msg.info.dead == 0 | ||
606 | + end | ||
607 | + -- 4 指定种族 >= N | ||
608 | + check[4] = function(_, cond) | ||
609 | + local count = 0 | ||
610 | + for _, one in pairs(herosInfo) do | ||
611 | + local heroData = csvdb["unitCsv"][one.type] | ||
612 | + if heroData.camp == cond then | ||
613 | + count = count + 1 | ||
614 | + end | ||
615 | + end | ||
616 | + return count >= cond | ||
617 | + end | ||
618 | + -- 5 指定职业 >= N | ||
619 | + check[5] = function(_, cond) | ||
620 | + local count = 0 | ||
621 | + for _, one in pairs(herosInfo) do | ||
622 | + local heroData = csvdb["unitCsv"][one.type] | ||
623 | + if heroData.job == cond then | ||
624 | + count = count + 1 | ||
625 | + end | ||
626 | + end | ||
627 | + return count >= cond | ||
628 | + end | ||
629 | + -- 6 含有指定角色 | ||
630 | + check[6] = function(_, cond) | ||
631 | + for _, one in pairs(herosInfo) do | ||
632 | + if one.type == cond then | ||
633 | + return true | ||
634 | + end | ||
635 | + end | ||
636 | + return false | ||
637 | + end | ||
638 | + -- 7 通关耗时 <= X 秒 msg.info.atime | ||
639 | + check[7] = function(_, cond) | ||
640 | + return msg.info.atime and msg.info.atime <= cond | ||
641 | + end | ||
642 | + -- 8 总输出值 msg.info.atime | ||
643 | + check[8] = function(_, cond) | ||
644 | + return dmg >= cond | ||
645 | + end | ||
646 | + curStar = 0 | ||
647 | + local sweepConds = battleCfg.sweep_condition:toTableArray(true) | ||
648 | + for i, cond in ipairs(sweepConds) do | ||
649 | + if check[cond[1]] and check[cond[1]](table.unpack(cond)) then | ||
650 | + curStar = curStar + (1 << (i - 1)) | ||
651 | + end | ||
652 | + end | ||
653 | + else | ||
654 | + curStar = 0 | ||
655 | + if battleCfg.rank ~= 0 then | ||
656 | + curStar = 1 | ||
657 | + end | ||
658 | + end | ||
659 | + local oldStarNum = getStarCount(battleCfg, battleInfo["star"] or 0) | ||
660 | + local newStarNum = getStarCount(battleCfg, curStar) | ||
661 | + if newStarNum > oldStarNum then | ||
662 | + battleInfo["star"] = curStar | ||
663 | + end | ||
664 | + | ||
665 | + if battleCfg.rank ~= 0 and isWin then | ||
666 | + -- 消耗门票 | ||
667 | + role.activity:getBattleTicket(actid) | ||
668 | + local num = battleCfg.type:toArray(true, "=")[3] | ||
669 | + actData["ticket"] = math.max(actData["ticket"] - num, 0) | ||
670 | + | ||
671 | + -- 更新排行榜 最高伤害 | ||
672 | + battleInfo["top"] = math.max(battleInfo["top"] or 0, dmg) | ||
673 | + battleInfo["sum"] = (battleInfo["sum"] or 0) + dmg | ||
674 | + local rankVal = 0 | ||
675 | + if battleCfg.rank == 1 then | ||
676 | + rankVal = battleInfo["sum"] | ||
677 | + elseif battleCfg.rank == 2 then | ||
678 | + rankVal = battleInfo["top"] | ||
679 | + end | ||
680 | + if rankVal > 0 then | ||
681 | + role:updateRankCommon(RANK_TYPE.ActBattleBoss, rankVal) | ||
682 | + end | ||
683 | + end | ||
684 | + | ||
685 | + if (oldStarNum == 0 and newStarNum > 0) or battleCfg.rank ~= 0 then | ||
686 | + reward = battleCfg.item_clear:toNumMap() | ||
687 | + end | ||
688 | + if (oldStarNum < 3 and newStarNum == 3) or (battleCfg.rank ~= 0 and newStarNum == 3) then | ||
689 | + local aw = battleCfg.perfect_reward:toNumMap() | ||
690 | + for k, v in pairs(aw) do | ||
691 | + reward[k] = (reward[k] or 0) + v | ||
692 | + end | ||
693 | + end | ||
694 | + | ||
695 | + role:checkBattle("act_battle", { | ||
696 | + cfg = battleCfg, | ||
697 | + star = newStarNum, | ||
698 | + isWin = isWin, | ||
699 | + info = msg.info, | ||
700 | + reward = reward, | ||
701 | + heros = heros, | ||
702 | + supports = support, | ||
703 | + }) | ||
704 | + | ||
705 | + -- 解锁活动剧情 | ||
706 | + if newStarNum >= 3 then | ||
707 | + role:checkStoryStatus(false, 5, id) | ||
708 | + end | ||
709 | + | ||
710 | + if battleCfg.worldBoss_award ~= 0 and msg.point then | ||
711 | + battleInfo["bossP"] = (battleInfo["bossP"] or 0) + msg.point | ||
712 | + battleInfo["maxP"] = math.max(msg.point, (battleInfo["maxP"] or 0)) | ||
713 | + end | ||
714 | + actData[id] = battleInfo | ||
715 | + role.activity:updateActData("ChallengeLevel", actData) | ||
716 | + | ||
717 | + reward, change = role:award(reward, {log = {desc = "actBattle", int1 = actid, int2 = newStarNum}}) | ||
718 | + | ||
719 | + SendPacket(actionCodes.Activity_endBattleRpc, MsgPack.pack({ | ||
720 | + reward = reward, | ||
721 | + change = change | ||
722 | + })) | ||
723 | + | ||
724 | + return true | ||
725 | +end | ||
726 | + | ||
727 | +function _M.battleRankRpc(agent, data) | ||
728 | + local role = agent.role | ||
729 | + local msg = MsgPack.unpack(data) | ||
730 | + local actid = msg.actid | ||
731 | + local cfg = csvdb["activity_ctrlCsv"][actid] | ||
732 | + if not cfg then return 1 end | ||
733 | + if not role.activity:isOpen(cfg.showType) then return 2 end | ||
734 | + local actTypeToRank = { | ||
735 | + [role.activity.ActivityType.ChallengeLevel] = RANK_TYPE.ActBattleBoss, | ||
736 | + [role.activity.ActivityType.Crisis] = RANK_TYPE.ActCrisis, | ||
737 | + } | ||
738 | + if not actTypeToRank[cfg.showType] then return end | ||
739 | + local rankInfo = role:getRankInfoCommon(actTypeToRank[cfg.showType]) | ||
740 | + SendPacket(actionCodes.Activity_battleRankRpc, MsgPack.pack(rankInfo)) | ||
741 | + return true | ||
742 | +end | ||
743 | + | ||
744 | +function _M.battleMilestoneRpc(agent, data) | ||
745 | + local role = agent.role | ||
746 | + local msg = MsgPack.unpack(data) | ||
747 | + local actid = msg.actid | ||
748 | + local id = msg.id | ||
749 | + local index = msg.index | ||
750 | + | ||
751 | + if not role.activity:isOpenById(actid, "ChallengeLevel") then return 1 end | ||
752 | + | ||
753 | + local actCfg = csvdb["activity_mileageCsv"][actid] | ||
754 | + if not actCfg then return 3 end | ||
755 | + | ||
756 | + local mileCfg = actCfg[index] | ||
757 | + if not mileCfg then return 4 end | ||
758 | + | ||
759 | + local actData = role.activity:getActData("ChallengeLevel") or {} | ||
760 | + local battleInfo = actData[id] or {} | ||
761 | + local val = 0 | ||
762 | + if mileCfg.type == 1 then | ||
763 | + val = battleInfo["sum"] or 0 | ||
764 | + elseif mileCfg.type == 2 then | ||
765 | + val = battleInfo["top"] or 0 | ||
766 | + end | ||
767 | + | ||
768 | + local record = battleInfo["r"] or "" | ||
769 | + local flag = string.char(string.getbit(record, index)) | ||
770 | + if flag == "1" then return 5 end | ||
771 | + if mileCfg.condition > val then return 6 end | ||
772 | + | ||
773 | + battleInfo["r"] = string.setbit(record, index) | ||
774 | + actData[id] = battleInfo | ||
775 | + role.activity:updateActData("ChallengeLevel", actData) | ||
776 | + | ||
777 | + local award = mileCfg.reward:toNumMap() | ||
778 | + local reward, change = role:award(award, {log = {desc = "actMilestone", int1 = actid, int2 = index}}) | ||
779 | + SendPacket(actionCodes.Activity_battleMilestoneRpc, MsgPack.pack(role:packReward(reward, change))) | ||
780 | + | ||
781 | + return true | ||
782 | +end | ||
783 | + | ||
784 | +function _M.crisisMilestoneRpc(agent, data) | ||
785 | + local role = agent.role | ||
786 | + local msg = MsgPack.unpack(data) | ||
787 | + local actid = msg.actid | ||
788 | + local id = msg.id | ||
789 | + if not role.activity:isOpenById(actid, "Crisis") then return 1 end | ||
790 | + local actCfg = csvdb["activity_mileageCsv"][actid] | ||
791 | + if not actCfg then return 3 end | ||
792 | + | ||
793 | + local curCsv = actCfg[id] | ||
794 | + if not curCsv then return 4 end | ||
795 | + | ||
796 | + if role:getItemCount(ItemId.CrisisScore) < curCsv.condition then | ||
797 | + return 5 | ||
798 | + end | ||
799 | + | ||
800 | + local actData = role.activity:getActData("Crisis") or {} | ||
801 | + actData.score = actData.score or {} | ||
802 | + if actData.score[id] then | ||
803 | + return 6 | ||
804 | + end | ||
805 | + actData.score[id] = -1 | ||
806 | + role.activity:updateActData("Crisis", actData) | ||
807 | + | ||
808 | + local reward, change = role:award(curCsv.reward, {log = {desc = "actMilecrisis", int1 = actid}}) | ||
809 | + SendPacket(actionCodes.Activity_crisisMilestoneRpc, MsgPack.pack(role:packReward(reward, change))) | ||
810 | + return true | ||
811 | +end | ||
812 | + | ||
813 | + | ||
814 | +function _M.bossRewardRpc(agent, data) | ||
815 | + local role = agent.role | ||
816 | + local msg = MsgPack.unpack(data) | ||
817 | + local actid = msg.actid | ||
818 | + local id = msg.id | ||
819 | + local index = msg.index | ||
820 | + | ||
821 | + if not role.activity:isOpenById(actid, "ChallengeLevel") then return 1 end | ||
822 | + | ||
823 | + local actCfg = csvdb["activity_battleCsv"][actid] | ||
824 | + if not actCfg then return 2 end | ||
825 | + | ||
826 | + local battleCfg = actCfg[id] | ||
827 | + if not battleCfg then return 3 end | ||
828 | + | ||
829 | + if battleCfg.worldBoss_award == 0 then return 4 end | ||
830 | + | ||
831 | + actCfg = csvdb["activity_wordboss_awardCsv"][battleCfg.worldBoss_award] | ||
832 | + if not actCfg then return 5 end | ||
833 | + local awardCfg = actCfg[index] | ||
834 | + if not awardCfg then return 6 end | ||
835 | + | ||
836 | + local preList = awardCfg.condition1:toArray(true, "=") | ||
837 | + | ||
838 | + local actData = role.activity:getActData("ChallengeLevel") or {} | ||
839 | + local battleInfo = actData[id] or {} | ||
840 | + local bossPoint = battleInfo["bossP"] or 0 | ||
841 | + if bossPoint < 1 then return 7 end | ||
842 | + | ||
843 | + local bossRecord = battleInfo["bossR"] or "" | ||
844 | + local r = string.char(string.getbit(bossRecord, index)) | ||
845 | + if r == "1" then | ||
846 | + return 9 | ||
847 | + end | ||
848 | + local ok = false | ||
849 | + if #preList == 0 then | ||
850 | + ok = true | ||
851 | + else | ||
852 | + for _, i in ipairs(preList) do | ||
853 | + local flag = string.char(string.getbit(bossRecord, i)) | ||
854 | + if flag == "1" then | ||
855 | + ok = true | ||
856 | + break | ||
857 | + end | ||
858 | + end | ||
859 | + end | ||
860 | + if not ok then return 8 end | ||
861 | + | ||
862 | + battleInfo["bossR"] = string.setbit(bossRecord, index) | ||
863 | + battleInfo["bossP"] = bossPoint - 1 | ||
864 | + actData[id] = battleInfo | ||
865 | + role.activity:updateActData("ChallengeLevel", actData) | ||
866 | + | ||
867 | + local award = awardCfg.reward:toNumMap() | ||
868 | + local reward, change = role:award(award, {log = {desc = "worldBossReward", int1 = actid, int2 = index}}) | ||
869 | + SendPacket(actionCodes.Activity_bossRewardRpc, MsgPack.pack(role:packReward(reward, change))) | ||
870 | + return true | ||
871 | +end | ||
872 | + | ||
266 | return _M | 873 | return _M |
267 | \ No newline at end of file | 874 | \ No newline at end of file |
src/actions/AdvAction.lua
@@ -47,6 +47,10 @@ local function checkFormat(role, format, checkAdvTeam) | @@ -47,6 +47,10 @@ local function checkFormat(role, format, checkAdvTeam) | ||
47 | end | 47 | end |
48 | end | 48 | end |
49 | 49 | ||
50 | + if not format then | ||
51 | + format = role:getProperty("advTeam") | ||
52 | + end | ||
53 | + | ||
50 | if checkAdvTeam then | 54 | if checkAdvTeam then |
51 | for _, heroId in pairs(role:getProperty("advTeam").heros or {}) do | 55 | for _, heroId in pairs(role:getProperty("advTeam").heros or {}) do |
52 | hadHero[heroId] = true | 56 | hadHero[heroId] = true |
@@ -83,7 +87,7 @@ function _M.startAdvRpc( agent, data ) | @@ -83,7 +87,7 @@ function _M.startAdvRpc( agent, data ) | ||
83 | local msg = MsgPack.unpack(data) | 87 | local msg = MsgPack.unpack(data) |
84 | local chapterId = msg.chapterId --关卡id | 88 | local chapterId = msg.chapterId --关卡id |
85 | local layer = msg.layer or 1 --选择层数 | 89 | local layer = msg.layer or 1 --选择层数 |
86 | - local format = msg.format --编队 | 90 | + --local format = msg.format --编队 |
87 | local supportIdx = msg.supportIdx --选择的支援效果 | 91 | local supportIdx = msg.supportIdx --选择的支援效果 |
88 | if not role:isFuncUnlock(FuncUnlock.Adv) then return end | 92 | if not role:isFuncUnlock(FuncUnlock.Adv) then return end |
89 | 93 | ||
@@ -127,18 +131,18 @@ function _M.startAdvRpc( agent, data ) | @@ -127,18 +131,18 @@ function _M.startAdvRpc( agent, data ) | ||
127 | end | 131 | end |
128 | end | 132 | end |
129 | 133 | ||
130 | - if not checkFormat(role, format) then return 7 end | ||
131 | - | ||
132 | - local advTeam = role:getProperty("advTeam") | ||
133 | - table.clear(advTeam) | ||
134 | - | ||
135 | - advTeam.heros = {} | ||
136 | - for slot, heroId in pairs(format.heros) do | ||
137 | - advTeam.heros[slot] = heroId | ||
138 | - end | ||
139 | - advTeam.leader = format.leader | ||
140 | - advTeam.leader2 = format.leader2 | ||
141 | - role:updateProperty({field = "advTeam", value = advTeam}) | 134 | + if not checkFormat(role) then return 7 end |
135 | + | ||
136 | + --local advTeam = role:getProperty("advTeam") | ||
137 | + --table.clear(advTeam) | ||
138 | + | ||
139 | + --advTeam.heros = {} | ||
140 | + --for slot, heroId in pairs(format.heros) do | ||
141 | + -- advTeam.heros[slot] = heroId | ||
142 | + --end | ||
143 | + --advTeam.leader = format.leader | ||
144 | + --advTeam.leader2 = format.leader2 | ||
145 | + --role:updateProperty({field = "advTeam", value = advTeam}) | ||
142 | if AdvCommon.isEndless(chapterId) then | 146 | if AdvCommon.isEndless(chapterId) then |
143 | role.dailyData:updateProperty({field = "advElC", delta = 1}) | 147 | role.dailyData:updateProperty({field = "advElC", delta = 1}) |
144 | else | 148 | else |
@@ -243,13 +247,14 @@ function _M.startHangRpc(agent, data) | @@ -243,13 +247,14 @@ function _M.startHangRpc(agent, data) | ||
243 | info.format.heros[slot] = heroId | 247 | info.format.heros[slot] = heroId |
244 | end | 248 | end |
245 | info.time = skynet.timex() + adv_idle_time --挂机时间 | 249 | info.time = skynet.timex() + adv_idle_time --挂机时间 |
250 | + info.duration = adv_idle_time | ||
246 | info.campId = campId | 251 | info.campId = campId |
247 | info.index = index | 252 | info.index = index |
248 | 253 | ||
249 | -- 没有在战斗 用team来挂机了 把team清掉 | 254 | -- 没有在战斗 用team来挂机了 把team清掉 |
250 | - if not role:getAdvData():isRunning() then | ||
251 | - role:updateProperty({field = "advTeam", value = {}}) | ||
252 | - end | 255 | + --if not role:getAdvData():isRunning() then |
256 | + -- role:updateProperty({field = "advTeam", value = {}}) | ||
257 | + --end | ||
253 | role:pushMsg({type = "adv", slot = chapterId, time = adv_idle_time}) | 258 | role:pushMsg({type = "adv", slot = chapterId, time = adv_idle_time}) |
254 | role:changeUpdates({{type = "advHang", field = chapterId, value = info}}) | 259 | role:changeUpdates({{type = "advHang", field = chapterId, value = info}}) |
255 | 260 | ||
@@ -261,6 +266,16 @@ function _M.startHangRpc(agent, data) | @@ -261,6 +266,16 @@ function _M.startHangRpc(agent, data) | ||
261 | return true | 266 | return true |
262 | end | 267 | end |
263 | 268 | ||
269 | +local function addHeroFaith(role, heroId, exp) | ||
270 | + local hero = role.heros[heroId] | ||
271 | + if not hero then | ||
272 | + return | ||
273 | + end | ||
274 | + | ||
275 | + hero:addHeroFaith(exp) | ||
276 | + return hero:getProperty("faith") | ||
277 | +end | ||
278 | + | ||
264 | function _M.quickHangRpc(agent, data) | 279 | function _M.quickHangRpc(agent, data) |
265 | local role = agent.role | 280 | local role = agent.role |
266 | local msg = MsgPack.unpack(data) | 281 | local msg = MsgPack.unpack(data) |
@@ -328,7 +343,7 @@ function _M.endHangRpc(agent, data) | @@ -328,7 +343,7 @@ function _M.endHangRpc(agent, data) | ||
328 | end | 343 | end |
329 | adv_idle_time = adv_idle_time * 60 | 344 | adv_idle_time = adv_idle_time * 60 |
330 | 345 | ||
331 | - local reward, isFull, change | 346 | + local reward, isFull, change, heroFaithMap |
332 | if skynet.timex() >= info.time then | 347 | if skynet.timex() >= info.time then |
333 | -- 最新需求加成取消 | 348 | -- 最新需求加成取消 |
334 | --[[ | 349 | --[[ |
@@ -357,6 +372,14 @@ function _M.endHangRpc(agent, data) | @@ -357,6 +372,14 @@ function _M.endHangRpc(agent, data) | ||
357 | 372 | ||
358 | if not maxCampsite then return end | 373 | if not maxCampsite then return end |
359 | ]] | 374 | ]] |
375 | + -- 增加英雄信赖 | ||
376 | + local exp = info.duration / 60 | ||
377 | + heroFaithMap = {} | ||
378 | + for _, heroId in pairs(info.format.heros) do | ||
379 | + local curFaith = addHeroFaith(role, heroId, exp) | ||
380 | + heroFaithMap[heroId] = curFaith | ||
381 | + end | ||
382 | + | ||
360 | local totalReward = campSiteData.idleReward_1 .. " " .. campSiteData.idleReward_2 | 383 | local totalReward = campSiteData.idleReward_1 .. " " .. campSiteData.idleReward_2 |
361 | 384 | ||
362 | local idleReward = totalReward:toNumMap() | 385 | local idleReward = totalReward:toNumMap() |
@@ -384,7 +407,7 @@ function _M.endHangRpc(agent, data) | @@ -384,7 +407,7 @@ function _M.endHangRpc(agent, data) | ||
384 | 407 | ||
385 | role:checkTaskEnter("AdvHang", {}) | 408 | role:checkTaskEnter("AdvHang", {}) |
386 | 409 | ||
387 | - SendPacket(actionCodes.Adv_endHangRpc, MsgPack.pack({reward = reward, change = change, isFull = isFull})) | 410 | + SendPacket(actionCodes.Adv_endHangRpc, MsgPack.pack({reward = reward, change = change, isFull = isFull, heroFaith = heroFaithMap})) |
388 | return true | 411 | return true |
389 | end | 412 | end |
390 | 413 | ||
@@ -504,25 +527,8 @@ function _M.useItemRpc(agent, data) | @@ -504,25 +527,8 @@ function _M.useItemRpc(agent, data) | ||
504 | adv:cost({[itemId] = count}, {log = {desc = "useItem", int1 = itemId, int2 = count}}) | 527 | adv:cost({[itemId] = count}, {log = {desc = "useItem", int1 = itemId, int2 = count}}) |
505 | adv:backUse({[itemId] = count}) | 528 | adv:backUse({[itemId] = count}) |
506 | end | 529 | end |
507 | - | ||
508 | - if itemId == 5020 then | ||
509 | - role:finishGuide(53) | ||
510 | - end | ||
511 | - adv:checkAchievement(adv.AchievType.UseItem, count, itemId) | ||
512 | - adv:mylog({desc = "useItem", int1 = itemId, int2 = count}) | ||
513 | - | ||
514 | - role:log("mission_pick_use", { | ||
515 | - mission_threadid = adv.chapterId, -- 大地图ID | ||
516 | - mission_threadname = (csvdb["adv_chapterCsv"][adv.chapterId] or {})["chapter"] or "auto", -- 大地图名称 | ||
517 | - mission_id = adv.level, -- 关卡ID | ||
518 | - item_id = itemId, -- 道具ID | ||
519 | - mission_pick_use_num = count, -- 道具使用量 | ||
520 | - mission_sequenceid = adv.logid, -- 本次拾荒ID,用于关联一次拾荒产生多条不同类型的日志 | ||
521 | - }) | ||
522 | - | ||
523 | - for i = 1, count do | ||
524 | - adv:doActive(itemData.effect, target) -- target | ||
525 | - end | 530 | + |
531 | + adv:useItem(itemId, count, target) | ||
526 | 532 | ||
527 | adv:afterRound() | 533 | adv:afterRound() |
528 | adv:saveDB() | 534 | adv:saveDB() |
@@ -740,7 +746,7 @@ function _M.endBattleRpc(agent, data) | @@ -740,7 +746,7 @@ function _M.endBattleRpc(agent, data) | ||
740 | end | 746 | end |
741 | end | 747 | end |
742 | adv:mylog({desc = "endBattle"}) | 748 | adv:mylog({desc = "endBattle"}) |
743 | - local status = adv:clickBlock(roomId, blockId, {player = player, bySkill = bySkill}) | 749 | + local status = adv:clickBlock(roomId, blockId, {player = player, enemy = msg.enemy, bySkill = bySkill}) |
744 | 750 | ||
745 | if not status then return end | 751 | if not status then return end |
746 | SendPacket(actionCodes.Adv_endBattleRpc, MsgPack.pack({events = adv:popBackEvents()})) | 752 | SendPacket(actionCodes.Adv_endBattleRpc, MsgPack.pack({events = adv:popBackEvents()})) |
@@ -950,4 +956,61 @@ function _M.refreshSupportRpc(agent, data) | @@ -950,4 +956,61 @@ function _M.refreshSupportRpc(agent, data) | ||
950 | return true | 956 | return true |
951 | end | 957 | end |
952 | 958 | ||
959 | +function _M.roleFormatRpc(agent , data) | ||
960 | + local role = agent.role | ||
961 | + local msg = MsgPack.unpack(data) | ||
962 | + local index = msg.index -- 阵容索引 | ||
963 | + local title = msg.title -- 阵容名称 | ||
964 | + local team = {} | ||
965 | + for slot, heroId in pairs(msg.heros) do | ||
966 | + if not role.heros[heroId] then | ||
967 | + return 1 | ||
968 | + end | ||
969 | + end | ||
970 | + | ||
971 | + if index > 10 then | ||
972 | + return 2 | ||
973 | + end | ||
974 | + | ||
975 | + team.heros = {} | ||
976 | + for slot, heroId in pairs(msg.heros) do | ||
977 | + team.heros[slot] = heroId | ||
978 | + end | ||
979 | + team.leader = msg.leader | ||
980 | + team.leader2 = msg.leader2 | ||
981 | + team.title = title | ||
982 | + role:setAdvTeamFormat(index, team) | ||
983 | + | ||
984 | + local advTeam = role:getProperty("advTeam") | ||
985 | + local curIndex = advTeam.index | ||
986 | + if curIndex == index then | ||
987 | + table.clear(advTeam) | ||
988 | + | ||
989 | + advTeam.heros = {} | ||
990 | + for slot, heroId in pairs(msg.heros) do | ||
991 | + advTeam.heros[slot] = heroId | ||
992 | + end | ||
993 | + advTeam.leader = msg.leader | ||
994 | + advTeam.leader2 = msg.leader2 | ||
995 | + advTeam.index = index | ||
996 | + role:updateProperty({field = "advTeam", value = advTeam}) | ||
997 | + end | ||
998 | + | ||
999 | + SendPacket(actionCodes.Adv_roleFormatRpc, '') | ||
1000 | + return true | ||
1001 | +end | ||
1002 | + | ||
1003 | +function _M.selectTeamRpc(agent, data) | ||
1004 | + local role = agent.role | ||
1005 | + local msg = MsgPack.unpack(data) | ||
1006 | + local index = msg.index -- 阵容索引 | ||
1007 | + local team = role:getAdvTeamFormat(index) | ||
1008 | + if not next(team) then return end | ||
1009 | + team["index"] = index | ||
1010 | + role:updateProperty({field = "advTeam", value = team}) | ||
1011 | + | ||
1012 | + SendPacket(actionCodes.Adv_selectTeamRpc, '') | ||
1013 | + return true | ||
1014 | +end | ||
1015 | + | ||
953 | return _M | 1016 | return _M |
954 | \ No newline at end of file | 1017 | \ No newline at end of file |
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)}) |
@@ -609,10 +610,10 @@ function _M.refreshTaskRpc( agent, data ) | @@ -609,10 +610,10 @@ function _M.refreshTaskRpc( agent, data ) | ||
609 | local role = agent.role | 610 | local role = agent.role |
610 | local msg = MsgPack.unpack(data) | 611 | local msg = MsgPack.unpack(data) |
611 | 612 | ||
612 | - local cost = {[ItemId.Diamond] = 40} | ||
613 | - if not role:checkItemEnough(cost) then | ||
614 | - return 1 | ||
615 | - end | 613 | + --local cost = {[ItemId.Diamond] = 40} |
614 | + --if not role:checkItemEnough(cost) then | ||
615 | + -- return 1 | ||
616 | + --end | ||
616 | 617 | ||
617 | local orders = json.decode(role.dinerData:getProperty("order")) | 618 | local orders = json.decode(role.dinerData:getProperty("order")) |
618 | 619 | ||
@@ -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
@@ -402,24 +402,23 @@ function _M.advl(role, pms) | @@ -402,24 +402,23 @@ function _M.advl(role, pms) | ||
402 | return "成功" | 402 | return "成功" |
403 | end | 403 | end |
404 | 404 | ||
405 | -table.insert(helpDes, {"冒险内等级增加", "advcl", "经验值"}) | ||
406 | -function _M.advcl(role, pms) | ||
407 | - local exp = tonum(pms.pm1) | ||
408 | - local advData = role:getAdvData() | 405 | +-- table.insert(helpDes, {"冒险内等级增加", "advcl", "经验值"}) |
406 | +-- function _M.advcl(role, pms) | ||
407 | +-- local exp = tonum(pms.pm1) | ||
408 | +-- local advData = role:getAdvData() | ||
409 | 409 | ||
410 | - if not advData.chapterId then | ||
411 | - return "先随便开启一关" | ||
412 | - end | ||
413 | - advData.battle.player:addExp(exp) | ||
414 | - advData:saveDB() | ||
415 | - role:mylog("gm_action", {desc = "advcl", int1 = exp, key1 = pms.sender}) | 410 | +-- if not advData.chapterId then |
411 | +-- return "先随便开启一关" | ||
412 | +-- end | ||
413 | +-- advData.battle.player:addExp(exp) | ||
414 | +-- advData:saveDB() | ||
415 | +-- role:mylog("gm_action", {desc = "advcl", int1 = exp, key1 = pms.sender}) | ||
416 | 416 | ||
417 | - return "成功" | ||
418 | -end | 417 | +-- return "成功" |
418 | +-- end | ||
419 | 419 | ||
420 | table.insert(helpDes, {"挂机清除" , "idlec"}) | 420 | table.insert(helpDes, {"挂机清除" , "idlec"}) |
421 | function _M.idlec(role, pms) | 421 | function _M.idlec(role, pms) |
422 | - role:updateProperty({field = "hangTeam", value = {}}) | ||
423 | role:updateProperty({field = "hangInfo", value = {}}) | 422 | role:updateProperty({field = "hangInfo", value = {}}) |
424 | role:updateProperty({field = "hangBag", value = {}}) | 423 | role:updateProperty({field = "hangBag", value = {}}) |
425 | role:mylog("gm_action", {desc = "idlec", key1 = pms.sender}) | 424 | role:mylog("gm_action", {desc = "idlec", key1 = pms.sender}) |
@@ -503,6 +502,11 @@ function _M.guide(role, pms) | @@ -503,6 +502,11 @@ function _M.guide(role, pms) | ||
503 | end | 502 | end |
504 | end | 503 | end |
505 | 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 | ||
506 | role:updateProperty({field = "funcGuide", value = str}) | 510 | role:updateProperty({field = "funcGuide", value = str}) |
507 | role:mylog("gm_action", {desc = "sguide", key1 = pms.sender}) | 511 | role:mylog("gm_action", {desc = "sguide", key1 = pms.sender}) |
508 | 512 | ||
@@ -525,6 +529,16 @@ function _M.guide(role, pms) | @@ -525,6 +529,16 @@ function _M.guide(role, pms) | ||
525 | return "成功" | 529 | return "成功" |
526 | end | 530 | end |
527 | 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 | + | ||
528 | function _M.helpRpc(agent, data) | 542 | function _M.helpRpc(agent, data) |
529 | SendPacket(actionCodes.Gm_helpRpc, MsgPack.pack({help = helpDes})) | 543 | SendPacket(actionCodes.Gm_helpRpc, MsgPack.pack({help = helpDes})) |
530 | return true | 544 | return true |
@@ -534,7 +548,9 @@ function _M.test(role, pms) | @@ -534,7 +548,9 @@ function _M.test(role, pms) | ||
534 | local id = tonum(pms.pm1, 0) | 548 | local id = tonum(pms.pm1, 0) |
535 | --local hero = require ("actions.HeroAction") | 549 | --local hero = require ("actions.HeroAction") |
536 | --hero.unlockPoolRpc({role = role}, MsgPack.pack({type = id})) | 550 | --hero.unlockPoolRpc({role = role}, MsgPack.pack({type = id})) |
537 | - print(role:getPaybackReward(0, 10000)) | 551 | + |
552 | + --role:sendMail(13, nil, "1=2", {111}) | ||
553 | + dump(redisproxy:zrevrange("rank:tower", 0 , 10, "WITHSCORES")) | ||
538 | return "成功" | 554 | return "成功" |
539 | end | 555 | end |
540 | 556 |
src/actions/HangAction.lua
@@ -269,7 +269,15 @@ function _M.endBattleRpc(agent, data) | @@ -269,7 +269,15 @@ function _M.endBattleRpc(agent, data) | ||
269 | local nextCarbonId = role:getNextCarbonId(carbonId) | 269 | local nextCarbonId = role:getNextCarbonId(carbonId) |
270 | -- 设置挂机关卡 | 270 | -- 设置挂机关卡 |
271 | if isWin then --and (hangInfo.carbonId or 0) < nextCarbonId then | 271 | if isWin then --and (hangInfo.carbonId or 0) < nextCarbonId then |
272 | - hangInfo.expCarbonId = carbonId | 272 | + if not hangInfo.expCarbonId then |
273 | + hangInfo.expCarbonId = carbonId | ||
274 | + else | ||
275 | + local oldCarbonData = csvdb["idle_battleCsv"][hangInfo.expCarbonId] | ||
276 | + local newCarbonData = csvdb["idle_battleCsv"][carbonId] | ||
277 | + if oldCarbonData.money < newCarbonData.money then | ||
278 | + hangInfo.expCarbonId = carbonId | ||
279 | + end | ||
280 | + end | ||
273 | --local cfg = csvdb["idle_battleCsv"][nextCarbonId] | 281 | --local cfg = csvdb["idle_battleCsv"][nextCarbonId] |
274 | --if cfg then | 282 | --if cfg then |
275 | -- hangInfo.bossTime = skynet.timex() + cfg.idle_time | 283 | -- hangInfo.bossTime = skynet.timex() + cfg.idle_time |
@@ -305,7 +313,10 @@ end | @@ -305,7 +313,10 @@ end | ||
305 | function _M.roleFormatRpc(agent , data) | 313 | function _M.roleFormatRpc(agent , data) |
306 | local role = agent.role | 314 | local role = agent.role |
307 | local msg = MsgPack.unpack(data) | 315 | local msg = MsgPack.unpack(data) |
308 | - local hangTeam = role:getProperty("hangTeam") | 316 | + local index = msg.index -- 阵容索引 |
317 | + local title = msg.title -- 阵容名称 | ||
318 | + local tactics = msg.tactics -- 战术 | ||
319 | + local team = {} | ||
309 | for slot, heroId in pairs(msg.heros) do | 320 | for slot, heroId in pairs(msg.heros) do |
310 | if not role.heros[heroId] then | 321 | if not role.heros[heroId] then |
311 | return 1 | 322 | return 1 |
@@ -321,15 +332,27 @@ function _M.roleFormatRpc(agent , data) | @@ -321,15 +332,27 @@ function _M.roleFormatRpc(agent , data) | ||
321 | end | 332 | end |
322 | if not checkLeader(msg.heros, msg.leader) then return 4 end | 333 | if not checkLeader(msg.heros, msg.leader) then return 4 end |
323 | 334 | ||
324 | - table.clear(hangTeam) | ||
325 | - hangTeam.heros = {} | 335 | + if index > 10 then |
336 | + return 5 | ||
337 | + end | ||
338 | + | ||
339 | + if #title > 100 then | ||
340 | + return 6 | ||
341 | + end | ||
342 | + | ||
343 | + team.heros = {} | ||
326 | for slot, heroId in pairs(msg.heros) do | 344 | for slot, heroId in pairs(msg.heros) do |
327 | - hangTeam.heros[slot] = heroId | 345 | + team.heros[slot] = heroId |
328 | end | 346 | end |
329 | - hangTeam.leader = msg.leader | ||
330 | - hangTeam.supports = supports | ||
331 | - role:saveHangTeam(hangTeam) | ||
332 | - role:finishGuide(5) | 347 | + team.leader = msg.leader |
348 | + team.supports = supports | ||
349 | + team.title = title | ||
350 | + if msg.tactics and globalCsv.tactics_skill_passive_cell[msg.tactics] then | ||
351 | + team.tactics = msg.tactics | ||
352 | + end | ||
353 | + | ||
354 | + role:setTeamFormat(index, team) | ||
355 | + | ||
333 | SendPacket(actionCodes.Hang_roleFormatRpc, '') | 356 | SendPacket(actionCodes.Hang_roleFormatRpc, '') |
334 | return true | 357 | return true |
335 | end | 358 | end |
@@ -440,36 +463,6 @@ function _M.quickRpc(agent , data) | @@ -440,36 +463,6 @@ function _M.quickRpc(agent , data) | ||
440 | return true | 463 | return true |
441 | end | 464 | end |
442 | 465 | ||
443 | -function _M.bonusFormatRpc(agent , data) | ||
444 | - local role = agent.role | ||
445 | - local msg = MsgPack.unpack(data) | ||
446 | - local bTeam = role:getProperty("bTeam") | ||
447 | - for slot, heroId in pairs(msg.heros) do | ||
448 | - if not role.heros[heroId] then | ||
449 | - return | ||
450 | - end | ||
451 | - end | ||
452 | - local supports = {} | ||
453 | - for slot, support in pairs(msg.supports) do | ||
454 | - if slot ~= 1 and slot ~= 2 then return end | ||
455 | - local level = role.dinerData:getProperty("dishTree"):getv(support, 0) | ||
456 | - if level <= 0 then return end | ||
457 | - supports[slot] = support | ||
458 | - end | ||
459 | - if not checkLeader(msg.heros, msg.leader) then return end | ||
460 | - | ||
461 | - table.clear(bTeam) | ||
462 | - bTeam.heros = {} | ||
463 | - for slot, heroId in pairs(msg.heros) do | ||
464 | - bTeam.heros[slot] = heroId | ||
465 | - end | ||
466 | - bTeam.leader = msg.leader | ||
467 | - bTeam.supports = supports | ||
468 | - | ||
469 | - role:updateProperty({field = "bTeam", value = bTeam}) | ||
470 | - SendPacket(actionCodes.Hang_bonusFormatRpc, '') | ||
471 | - return true | ||
472 | -end | ||
473 | 466 | ||
474 | function _M.buyBonusCountRpc(agent, data) | 467 | function _M.buyBonusCountRpc(agent, data) |
475 | local role = agent.role | 468 | local role = agent.role |
@@ -505,10 +498,56 @@ function _M.buyBonusCountRpc(agent, data) | @@ -505,10 +498,56 @@ function _M.buyBonusCountRpc(agent, data) | ||
505 | return true | 498 | return true |
506 | end | 499 | end |
507 | 500 | ||
501 | +local function bonusWinReward(role, bonusData, rewardType, count) | ||
502 | + count = count or 1 | ||
503 | + | ||
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 | ||
508 | + end | ||
509 | + end | ||
510 | + | ||
511 | + if rewardType == 2 or rewardType == 4 then | ||
512 | + for k, v in pairs(bonusData.perfect_reward:toNumMap()) do | ||
513 | + reward[k] = (reward[k] or 0) + v | ||
514 | + end | ||
515 | + end | ||
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 | ||
544 | +end | ||
545 | + | ||
508 | function _M.startBonusBattleRpc(agent, data) | 546 | function _M.startBonusBattleRpc(agent, data) |
509 | local role = agent.role | 547 | local role = agent.role |
510 | local msg = MsgPack.unpack(data) | 548 | local msg = MsgPack.unpack(data) |
511 | local id = msg.id | 549 | local id = msg.id |
550 | + local count = msg.count or 1 | ||
512 | 551 | ||
513 | local open, actId = role.activity:isOpen("BonusDouble") | 552 | local open, actId = role.activity:isOpen("BonusDouble") |
514 | 553 | ||
@@ -521,29 +560,37 @@ function _M.startBonusBattleRpc(agent, data) | @@ -521,29 +560,37 @@ function _M.startBonusBattleRpc(agent, data) | ||
521 | end | 560 | end |
522 | 561 | ||
523 | if not bonusData then return 3 end | 562 | if not bonusData then return 3 end |
524 | - if not role:checkHangPass(bonusData.unlock) then return 4 end | ||
525 | - | ||
526 | - if not next(role:getProperty("bTeam")) then return 5 end | 563 | + local bonusStar = role:getProperty("bonusStar") |
527 | 564 | ||
528 | - local bonusC = role.dailyData:getProperty("bonusC") | ||
529 | - bonusC[bonusData.type] = bonusC[bonusData.type] or {c = 0, b = 0} | 565 | + if bonusData.unlock ~= 0 and (not bonusStar[bonusData.unlock] or bonusStar[bonusData.unlock] == 0) then return 4 end |
530 | 566 | ||
531 | - local actData = csvdb["activity_ctrlCsv"][actId] | 567 | + if bonusStar[id] and bonusStar[id] >= (1 << #bonusData.sweep_condition:toTableArray(true)) - 1 then |
568 | + local bonusC = role.dailyData:getProperty("bonusC") | ||
569 | + bonusC[bonusData.type] = bonusC[bonusData.type] or {c = 0, b = 0} | ||
532 | 570 | ||
533 | - local extraCnt = role.storeData:getBonusExtraFightCount() | ||
534 | - local coef = 1 | ||
535 | - if open and actData then | ||
536 | - coef = tonumber(actData.condition2) | ||
537 | - end | 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 | ||
538 | 578 | ||
539 | - if globalCsv.bonus_daily_count * coef + extraCnt - bonusC[bonusData.type]["c"] <= 0 then return 7 end | 579 | + bonusC[bonusData.type]["c"] = bonusC[bonusData.type]["c"] + count |
580 | + role.dailyData:updateProperty({field = "bonusC", value = bonusC}) | ||
540 | 581 | ||
582 | + local reward, change = bonusWinReward(role, bonusData, 3, count) | ||
583 | + SendPacket(actionCodes.Hang_startBonusBattleRpc, MsgPack.pack({reward = reward, change = change})) | ||
584 | + else | ||
585 | + local bTeam = role:getTeamFormatByType(TeamSystemType.BonusBattle) | ||
586 | + if not next(bTeam) then return 5 end | ||
587 | + role.__bonusBattleCache = { | ||
588 | + key = tostring(math.random()), | ||
589 | + id = id, | ||
590 | + } | ||
591 | + SendPacket(actionCodes.Hang_startBonusBattleRpc, MsgPack.pack({key = role.__bonusBattleCache.key})) | ||
592 | + end | ||
541 | 593 | ||
542 | - role.__bonusBattleCache = { | ||
543 | - key = tostring(math.random()), | ||
544 | - id = id, | ||
545 | - } | ||
546 | - SendPacket(actionCodes.Hang_startBonusBattleRpc, MsgPack.pack({key = role.__bonusBattleCache.key})) | ||
547 | return true | 594 | return true |
548 | end | 595 | end |
549 | 596 | ||
@@ -554,14 +601,7 @@ function _M.endBonusBattleRpc(agent, data) | @@ -554,14 +601,7 @@ function _M.endBonusBattleRpc(agent, data) | ||
554 | local key = msg.key | 601 | local key = msg.key |
555 | local starNum = msg.starNum | 602 | local starNum = msg.starNum |
556 | if not role.__bonusBattleCache then return 1 end | 603 | if not role.__bonusBattleCache then return 1 end |
557 | - local open, actId = role.activity:isOpen("BonusDouble") | ||
558 | - local actData = csvdb["activity_ctrlCsv"][actId] | ||
559 | - local extraCnt = role.storeData:getBonusExtraFightCount() | ||
560 | - | ||
561 | - local coef = 1 | ||
562 | - if open and actData then | ||
563 | - coef = tonumber(actData.condition2) | ||
564 | - end | 604 | + |
565 | 605 | ||
566 | if role.__bonusBattleCache.id ~= id or role.__bonusBattleCache.key ~= key then | 606 | if role.__bonusBattleCache.id ~= id or role.__bonusBattleCache.key ~= key then |
567 | SendPacket(actionCodes.Hang_endBonusBattleRpc, MsgPack.pack({errorCode = 1})) | 607 | SendPacket(actionCodes.Hang_endBonusBattleRpc, MsgPack.pack({errorCode = 1})) |
@@ -569,25 +609,92 @@ function _M.endBonusBattleRpc(agent, data) | @@ -569,25 +609,92 @@ function _M.endBonusBattleRpc(agent, data) | ||
569 | end | 609 | end |
570 | local bonusData = csvdb["bonus_battleCsv"][id] | 610 | local bonusData = csvdb["bonus_battleCsv"][id] |
571 | 611 | ||
572 | - local reward, change | 612 | + local reward, change = {} |
613 | + | ||
614 | + local bonusStar = role:getProperty("bonusStar") | ||
615 | + local oldStar = bonusStar[id] or 0 | ||
616 | + local curStar = 0 | ||
573 | if starNum and starNum > 0 then | 617 | if starNum and starNum > 0 then |
574 | -- 胜利扣除次数 | 618 | -- 胜利扣除次数 |
575 | - local bonusC = role.dailyData:getProperty("bonusC") | ||
576 | - bonusC[bonusData.type] = bonusC[bonusData.type] or {c = 0, b = 0} | ||
577 | - if globalCsv.bonus_daily_count * coef + extraCnt - bonusC[bonusData.type]["c"] <= 0 then return 3 end | ||
578 | - bonusC[bonusData.type]["c"] = bonusC[bonusData.type]["c"] + 1 | ||
579 | - role.dailyData:updateProperty({field = "bonusC", value = bonusC}) | ||
580 | - | ||
581 | - reward = bonusData.reward:toNumMap() | ||
582 | - local chance = bonusData.chance:randWeight(true) | ||
583 | - if chance[1] ~= 0 then | ||
584 | - reward[chance[1]] = (reward[chance[1]] or 0) + chance[2] | 619 | + |
620 | + local bTeam = role:getTeamFormatByType(TeamSystemType.BonusBattle) | ||
621 | + local herosInfo = role:getTeamHerosInfo(bTeam).heros | ||
622 | + | ||
623 | + local check = {} | ||
624 | + -- 1 通关 | ||
625 | + check[1] = function(_) | ||
626 | + return true | ||
627 | + end | ||
628 | + -- 2 阵亡人数 <= N | ||
629 | + check[2] = function(_, cond) | ||
630 | + return msg.info.dead and msg.info.dead <= cond | ||
585 | end | 631 | end |
586 | - for k, v in pairs(reward) do | ||
587 | - reward[k] = v * (coef > 1 and actData.condition or 1) | 632 | + -- 3 全员存活 |
633 | + check[3] = function(_) | ||
634 | + return msg.info.dead and msg.info.dead == 0 | ||
588 | end | 635 | end |
589 | - reward, change = role:award(reward, {log = {desc = "bonusBattle", int1 = id}}) | ||
590 | - role:checkTaskEnter("BonusPass", {id = id}) | 636 | + -- 4 指定种族 >= N |
637 | + check[4] = function(_, cond) | ||
638 | + local count = 0 | ||
639 | + for _, one in pairs(herosInfo) do | ||
640 | + local heroData = csvdb["unitCsv"][one.type] | ||
641 | + if heroData.camp == cond then | ||
642 | + count = count + 1 | ||
643 | + end | ||
644 | + end | ||
645 | + return count >= cond | ||
646 | + end | ||
647 | + -- 5 指定职业 >= N | ||
648 | + check[5] = function(_, cond) | ||
649 | + local count = 0 | ||
650 | + for _, one in pairs(herosInfo) do | ||
651 | + local heroData = csvdb["unitCsv"][one.type] | ||
652 | + if heroData.job == cond then | ||
653 | + count = count + 1 | ||
654 | + end | ||
655 | + end | ||
656 | + return count >= cond | ||
657 | + end | ||
658 | + -- 6 含有指定角色 | ||
659 | + check[6] = function(_, cond) | ||
660 | + for _, one in pairs(herosInfo) do | ||
661 | + if one.type == cond then | ||
662 | + return true | ||
663 | + end | ||
664 | + end | ||
665 | + return false | ||
666 | + end | ||
667 | + -- 7 通关耗时 <= X 秒 msg.info.atime | ||
668 | + check[7] = function(_, cond) | ||
669 | + return msg.info.atime and msg.info.atime <= cond | ||
670 | + end | ||
671 | + curStar = 0 | ||
672 | + local sweepConds = bonusData.sweep_condition:toTableArray(true) | ||
673 | + for i, cond in ipairs(sweepConds) do | ||
674 | + if check[cond[1]] and check[cond[1]](table.unpack(cond)) then | ||
675 | + curStar = curStar + (1 << (i - 1)) | ||
676 | + end | ||
677 | + end | ||
678 | + local status | ||
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 | ||
692 | + else | ||
693 | + curStar = oldStar | ||
694 | + end | ||
695 | + if curStar ~= oldStar then | ||
696 | + bonusStar[id] = curStar | ||
697 | + role:updateProperty({field = "bonusStar", value = bonusStar}) | ||
591 | end | 698 | end |
592 | 699 | ||
593 | role:checkBattle("bonus", { | 700 | role:checkBattle("bonus", { |
@@ -666,4 +773,29 @@ function _M.chatLineRpc(agent, data) | @@ -666,4 +773,29 @@ function _M.chatLineRpc(agent, data) | ||
666 | return true | 773 | return true |
667 | end | 774 | end |
668 | 775 | ||
669 | -return _M | ||
670 | \ No newline at end of file | 776 | \ No newline at end of file |
777 | +function _M.selectTeamRpc(agent, data) | ||
778 | + local role = agent.role | ||
779 | + local msg = MsgPack.unpack(data) | ||
780 | + local index = msg.index -- 阵容索引 | ||
781 | + local type = msg.type -- 系统类型 | ||
782 | + | ||
783 | + if index > 10 then | ||
784 | + return 1 | ||
785 | + end | ||
786 | + local team = role:getTeamFormat(index) | ||
787 | + if not next(team) then return 2 end | ||
788 | + | ||
789 | + local teamIndex = role:getProperty("teamIndex") or {} | ||
790 | + teamIndex[type] = index | ||
791 | + role:updateProperty({field = "teamIndex", value = teamIndex}) | ||
792 | + | ||
793 | + if type == TeamSystemType.Hang then | ||
794 | + role:finishGuide(5) | ||
795 | + role:updateHangTeamInfo() | ||
796 | + end | ||
797 | + | ||
798 | + SendPacket(actionCodes.Hang_selectTeamRpc, '') | ||
799 | + return true | ||
800 | +end | ||
801 | + | ||
802 | +return _M |
src/actions/HeroAction.lua
@@ -143,74 +143,50 @@ function _M.talentRpc(agent, data) | @@ -143,74 +143,50 @@ function _M.talentRpc(agent, data) | ||
143 | local hero = role.heros[msg.id] | 143 | local hero = role.heros[msg.id] |
144 | if not hero then return 1 end | 144 | if not hero then return 1 end |
145 | 145 | ||
146 | - local index = msg.index -- 第几个天赋 | ||
147 | - local need = {[0] = 1, [1] = 1, [2] = 1, [3] = 1, [4] = 1} | ||
148 | - if not need[index] then return 2 end | ||
149 | - | ||
150 | local talent = hero:getProperty("talent") | 146 | local talent = hero:getProperty("talent") |
147 | + local heroCfgId = hero:getProperty("type") | ||
151 | local curStage = talent:getv(0, 1) | 148 | local curStage = talent:getv(0, 1) |
152 | - local curData = csvdb["unit_talentCsv"][curStage] | ||
153 | - if not curData then return 4 end | 149 | + local oldStage = curStage |
150 | + local curLevel = talent:getv(1, 1) | ||
151 | + local oldLevel = curLevel | ||
152 | + local curData = csvdb["unit_talent_"..heroCfgId.."Csv"][curStage] | ||
153 | + if not curData then return 1 end | ||
154 | local oldSkillLv = hero:getSkillLevel(1) | 154 | local oldSkillLv = hero:getSkillLevel(1) |
155 | 155 | ||
156 | 156 | ||
157 | local cost = {} | 157 | local cost = {} |
158 | - if index == 0 then | ||
159 | - --是否进阶 | ||
160 | - local max = true | ||
161 | - for i = 1, 4 do | ||
162 | - if talent:getv(i, 0) < #curData then | ||
163 | - max = false | ||
164 | - break | ||
165 | - end | ||
166 | - end | ||
167 | - if max then | ||
168 | - talent = talent:setv(0, curStage + 1) | ||
169 | - for i = 1, 4 do | ||
170 | - talent = talent:setv(i, 0) | ||
171 | - end | ||
172 | - else | ||
173 | - return 12 | ||
174 | - end | 158 | + if curLevel == #curData then |
159 | + talent = talent:setv(0, curStage + 1) | ||
160 | + talent = talent:setv(1, 1) | ||
175 | else | 161 | else |
176 | - | ||
177 | - local level = talent:getv(index, 0) | ||
178 | - if level >= #curData then return 5 end | 162 | + if curLevel > #curData then return 2 end |
179 | 163 | ||
180 | - local talentData = curData[level] | ||
181 | - if not talentData then return end | 164 | + local talentData = curData[curLevel] |
165 | + if not talentData then return 3 end | ||
182 | 166 | ||
183 | - if talentData.lvRequire > hero:getProperty("level") then return 6 end | 167 | + if talentData.lvRequire > hero:getProperty("level") then return 4 end |
184 | 168 | ||
185 | cost = talentData.money:toNumMap() | 169 | cost = talentData.money:toNumMap() |
186 | - local cost2 = talentData.cost:toNumMap() | ||
187 | - for k,v in pairs(cost2) do | ||
188 | - cost[globalCsv.unit_talent_cost[csvdb["unitCsv"][hero:getProperty("type")].camp][k]] = v | ||
189 | - end | ||
190 | - if not role:checkItemEnough(cost) then return 6 end | 170 | + if not role:checkItemEnough(cost) then return 5 end |
191 | role:costItems(cost, {log = {desc = "heroTalent", int1 = msg.id, int2 = hero:getProperty("type")}}) | 171 | role:costItems(cost, {log = {desc = "heroTalent", int1 = msg.id, int2 = hero:getProperty("type")}}) |
192 | - talent = talent:incrv(index, 1) | ||
193 | - | ||
194 | - | ||
195 | - local aheadLevel = 0 | ||
196 | - for i = 1, talent:getv(0, 1) - 1 do | ||
197 | - aheadLevel = aheadLevel + #csvdb["unit_talentCsv"][i] | ||
198 | - end | ||
199 | - aheadLevel = aheadLevel + talent:getv(index, 0) | ||
200 | - | ||
201 | - role:checkTaskEnter("HeroTalent", {heroType = hero:getProperty("type"), alv = aheadLevel}) | 172 | + talent = talent:setv(1, curLevel + 1) |
202 | end | 173 | end |
174 | + curStage = talent:getv(0, 1) | ||
175 | + role:checkTaskEnter("HeroTalent", {heroType = hero:getProperty("type"), alv = curStage}) | ||
203 | 176 | ||
204 | hero:updateProperty({field = "talent", value = talent}) | 177 | hero:updateProperty({field = "talent", value = talent}) |
205 | 178 | ||
179 | + | ||
206 | role:log("hero_talent", { | 180 | role:log("hero_talent", { |
207 | hero_id = hero:getProperty("type"), --英雄ID | 181 | hero_id = hero:getProperty("type"), --英雄ID |
208 | - hero_talent_id = index, --天赋ID | ||
209 | - hero_talent_cost = cost, -- 英雄天赋升级消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...} | ||
210 | - hero_talent_levelbef = oldSkillLv, -- 英雄技能升级前等级 | ||
211 | - 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 | ||
212 | }) | 187 | }) |
213 | - hero:mylog({desc = "talent", int1 = index, int2 = talent:getv(index, 0)}) | 188 | + |
189 | + hero:mylog({desc = "talent", int1 = talent:getv(0, 1), int2 = talent:getv(1, 1)}) | ||
214 | 190 | ||
215 | SendPacket(actionCodes.Hero_talentRpc, '') | 191 | SendPacket(actionCodes.Hero_talentRpc, '') |
216 | return true | 192 | return true |
@@ -476,7 +452,6 @@ function _M.referEquipsRpc(agent, data) | @@ -476,7 +452,6 @@ function _M.referEquipsRpc(agent, data) | ||
476 | end | 452 | end |
477 | end | 453 | end |
478 | 454 | ||
479 | - local oldAttr = hero:getTotalAttrs() | ||
480 | local oldBattleV = hero:getProperty("battleV") | 455 | local oldBattleV = hero:getProperty("battleV") |
481 | local wear = {} | 456 | local wear = {} |
482 | 457 | ||
@@ -506,18 +481,14 @@ function _M.referEquipsRpc(agent, data) | @@ -506,18 +481,14 @@ function _M.referEquipsRpc(agent, data) | ||
506 | -- 更新角色 | 481 | -- 更新角色 |
507 | hero:updateProperty({field = "equip", value = curEquip}) | 482 | hero:updateProperty({field = "equip", value = curEquip}) |
508 | 483 | ||
509 | - role:finishGuide(23) | ||
510 | - | ||
511 | - local curAttr = hero:getTotalAttrs() | ||
512 | - local attrChange = getChangeAttrJson(oldAttr, curAttr) | ||
513 | for typ, data in pairs(wear) do | 484 | for typ, data in pairs(wear) do |
514 | role:log("equip_wear", { | 485 | role:log("equip_wear", { |
515 | hero_id = hero:getProperty("type"), --英雄ID | 486 | hero_id = hero:getProperty("type"), --英雄ID |
516 | equip_id = data.id, --装备ID | 487 | equip_id = data.id, --装备ID |
517 | equip_wear_action = data.act, --装备操作类型:装备:0,卸载:1 | 488 | equip_wear_action = data.act, --装备操作类型:装备:0,卸载:1 |
518 | equip_wear_part = typ, --装备部位,记录部位ID | 489 | equip_wear_part = typ, --装备部位,记录部位ID |
519 | - equip_wear_result = curAttr, --装备操作后结果,记录属性变化,json格式记录,{“aa”:1234,"bb":4567} | ||
520 | - equip_wear_change = attrChange, --装备操作变化值,记录属性变化,记录正负值,json格式记录,{“aa”:1234,"bb":-45} | 490 | + equip_wear_scorebef = oldBattleV, --装备前英雄评分 |
491 | + equip_wear_score = hero:getProperty("battleV"), --装备后英雄评分 | ||
521 | equip_wear_mode = isAuto and 0 or 1, --用以区分自动装备还是手动装备,自动记录为0,手动记录为1 | 492 | equip_wear_mode = isAuto and 0 or 1, --用以区分自动装备还是手动装备,自动记录为0,手动记录为1 |
522 | }) | 493 | }) |
523 | end | 494 | end |
@@ -614,16 +585,16 @@ function _M.createHeroRandomRpc(agent, data) | @@ -614,16 +585,16 @@ function _M.createHeroRandomRpc(agent, data) | ||
614 | local itemData = csvdb["itemCsv"][itemId] | 585 | local itemData = csvdb["itemCsv"][itemId] |
615 | if not itemData or itemData.type ~= ItemType.HeroFCommon then return end | 586 | if not itemData or itemData.type ~= ItemType.HeroFCommon then return end |
616 | local cost = globalCsv.unit_fragment_cost[itemData.quality] | 587 | local cost = globalCsv.unit_fragment_cost[itemData.quality] |
617 | - if not cost or role:getItemCount(itemId) < cost then return end | 588 | + if not cost or role:getItemCount(itemId) < cost then return 1 end |
618 | 589 | ||
619 | local randomData = csvdb["item_randomCsv"][tonumber(itemData.use_effect)] | 590 | local randomData = csvdb["item_randomCsv"][tonumber(itemData.use_effect)] |
620 | - if not randomData then return end | 591 | + if not randomData then return 2 end |
621 | 592 | ||
622 | local temp = randomData.gift1:randWeight(true) | 593 | local temp = randomData.gift1:randWeight(true) |
623 | - if not temp or not next(temp) then return end | 594 | + if not temp or not next(temp) then return 3 end |
624 | 595 | ||
625 | role:costItems({[itemId] = cost}, {log = {desc = "createHeroRandom"}}) | 596 | role:costItems({[itemId] = cost}, {log = {desc = "createHeroRandom"}}) |
626 | - 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"}}) |
627 | 598 | ||
628 | 599 | ||
629 | SendPacket(actionCodes.Hero_createHeroRandomRpc, MsgPack.pack(role:packReward(reward, change))) | 600 | SendPacket(actionCodes.Hero_createHeroRandomRpc, MsgPack.pack(role:packReward(reward, change))) |
@@ -640,9 +611,37 @@ function _M.getResetRewardRpc(agent, data) | @@ -640,9 +611,37 @@ function _M.getResetRewardRpc(agent, data) | ||
640 | local level = hero:getProperty("level") | 611 | local level = hero:getProperty("level") |
641 | local breakL = hero:getProperty("breakL") | 612 | local breakL = hero:getProperty("breakL") |
642 | local talent = hero:getProperty("talent") | 613 | local talent = hero:getProperty("talent") |
614 | + local heroCfgId = hero:getProperty("type") | ||
643 | 615 | ||
616 | + local tmpLevel = level | ||
644 | if level <= 1 and talent == "" then return end | 617 | if level <= 1 and talent == "" then return end |
645 | 618 | ||
619 | + local pay = true | ||
620 | + if level <= 60 then | ||
621 | + pay = false | ||
622 | + end | ||
623 | + | ||
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}}) | ||
643 | + end | ||
644 | + | ||
646 | local reward = {} | 645 | local reward = {} |
647 | while level > 1 do | 646 | while level > 1 do |
648 | local curData = csvdb["unit_expCsv"][level - 1] | 647 | local curData = csvdb["unit_expCsv"][level - 1] |
@@ -659,32 +658,18 @@ function _M.getResetRewardRpc(agent, data) | @@ -659,32 +658,18 @@ function _M.getResetRewardRpc(agent, data) | ||
659 | end | 658 | end |
660 | 659 | ||
661 | local stage = talent:getv(0, 1) | 660 | local stage = talent:getv(0, 1) |
662 | - local tlevel = {talent:getv(1, 0), talent:getv(2, 0), talent:getv(3, 0), talent:getv(4, 0)} | 661 | + local curTalentLvl = talent:getv(1, 1) |
662 | + --local tlevel = {talent:getv(1, 0), talent:getv(2, 0), talent:getv(3, 0), talent:getv(4, 0)} | ||
663 | 663 | ||
664 | - local talentCostIds = globalCsv.unit_talent_cost[csvdb["unitCsv"][hero:getProperty("type")].camp] | ||
665 | while stage > 0 do | 664 | while stage > 0 do |
666 | - local curData = csvdb["unit_talentCsv"][stage] | ||
667 | - for level = math.max(table.unpack(tlevel)), 1, -1 do | ||
668 | - local add = 0 | ||
669 | - for i = 1, 4 do | ||
670 | - if tlevel[i] == level then | ||
671 | - add = add + 1 | ||
672 | - tlevel[i] = tlevel[i] - 1 | ||
673 | - end | ||
674 | - end | ||
675 | - local talentData = curData[level - 1] | 665 | + local curData = csvdb["unit_talent_"..heroCfgId.."Csv"][stage] |
666 | + for lvl = 1, curTalentLvl - 1 do | ||
667 | + local talentData = curData[lvl] | ||
676 | for itemId, count in pairs(talentData.money:toNumMap()) do | 668 | for itemId, count in pairs(talentData.money:toNumMap()) do |
677 | - reward[itemId] = (reward[itemId] or 0) + count * add | ||
678 | - end | ||
679 | - for idx , count in pairs(talentData.cost:toNumMap()) do | ||
680 | - reward[talentCostIds[idx]] = (reward[talentCostIds[idx]] or 0) + count * add | 669 | + reward[itemId] = (reward[itemId] or 0) + count |
681 | end | 670 | end |
682 | end | 671 | end |
683 | stage = stage - 1 | 672 | stage = stage - 1 |
684 | - curData = csvdb["unit_talentCsv"][stage] | ||
685 | - if curData then | ||
686 | - tlevel = {#curData, #curData, #curData, #curData} | ||
687 | - end | ||
688 | end | 673 | end |
689 | 674 | ||
690 | local equip = hero:getProperty("equip") | 675 | local equip = hero:getProperty("equip") |
@@ -708,9 +693,11 @@ function _M.getResetRewardRpc(agent, data) | @@ -708,9 +693,11 @@ function _M.getResetRewardRpc(agent, data) | ||
708 | rune = "", | 693 | rune = "", |
709 | }) | 694 | }) |
710 | hero:mylog({desc = "resetHero"}) | 695 | hero:mylog({desc = "resetHero"}) |
711 | - | 696 | + |
697 | + --local coef = globalCsv.unit_back_discount | ||
698 | + --coef = (pay or tmpLevel <= 60) and 1 or coef | ||
712 | for itemId, count in pairs(reward) do | 699 | for itemId, count in pairs(reward) do |
713 | - reward[itemId] = math.floor(count * globalCsv.unit_back_discount) | 700 | + reward[itemId] = count |
714 | end | 701 | end |
715 | local change | 702 | local change |
716 | 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")}}) |
@@ -727,13 +714,29 @@ end | @@ -727,13 +714,29 @@ end | ||
727 | function _M.drawHeroRpc(agent, data) | 714 | function _M.drawHeroRpc(agent, data) |
728 | local role = agent.role | 715 | local role = agent.role |
729 | local msg = MsgPack.unpack(data) | 716 | local msg = MsgPack.unpack(data) |
717 | + local actid = msg.actid | ||
730 | 718 | ||
731 | if not role:isFuncUnlock(FuncUnlock.GetHero) then return 1 end | 719 | if not role:isFuncUnlock(FuncUnlock.GetHero) then return 1 end |
732 | - local btype = msg.pool -- 1 2 3 卡池类型 | 720 | + local btype = msg.pool -- 1 2 3 4 5 卡池类型 4新手卡池 5心愿卡池 |
733 | local subType = msg.subType or 1-- 定向卡池需要传 子类型 | 721 | local subType = msg.subType or 1-- 定向卡池需要传 子类型 |
734 | local drawType = msg.type -- 1 单抽 2 十连 | 722 | local drawType = msg.type -- 1 单抽 2 十连 |
735 | if btype ~= 1 then | 723 | if btype ~= 1 then |
736 | subType = 1 | 724 | subType = 1 |
725 | + if btype == 4 and role:getProperty("newerDraw") >= 10 then | ||
726 | + subType = 2 | ||
727 | + if(role:getProperty("newerDraw") >= 30) then | ||
728 | + return 30 | ||
729 | + end | ||
730 | + end | ||
731 | + end | ||
732 | + | ||
733 | + -- 另开活动卡池 | ||
734 | + if actid then | ||
735 | + if not role.activity:isOpenById(actid, "ActHeroPool") then return end | ||
736 | + local cfg = csvdb["activity_ctrlCsv"][actid] | ||
737 | + if not cfg then return end | ||
738 | + | ||
739 | + btype = cfg.condition | ||
737 | end | 740 | end |
738 | 741 | ||
739 | if btype == 1 then | 742 | if btype == 1 then |
@@ -741,6 +744,18 @@ function _M.drawHeroRpc(agent, data) | @@ -741,6 +744,18 @@ function _M.drawHeroRpc(agent, data) | ||
741 | if not role.activity:isOpen("RaceDraw") then | 744 | if not role.activity:isOpen("RaceDraw") then |
742 | return | 745 | return |
743 | end | 746 | end |
747 | + elseif btype == 2 then | ||
748 | + if role:getProperty("newerGuide") ~= "8=1" then | ||
749 | + -- 判断普通卡池 | ||
750 | + if role.activity:isOpen("WishHeroPool") then | ||
751 | + return | ||
752 | + end | ||
753 | + end | ||
754 | + elseif btype == 5 then | ||
755 | + -- 判断心愿单卡池 | ||
756 | + if not role.activity:isOpen("WishHeroPool") then | ||
757 | + return | ||
758 | + end | ||
744 | end | 759 | end |
745 | 760 | ||
746 | local buildTypeData = csvdb["build_typeCsv"][btype] | 761 | local buildTypeData = csvdb["build_typeCsv"][btype] |
@@ -754,23 +769,32 @@ function _M.drawHeroRpc(agent, data) | @@ -754,23 +769,32 @@ function _M.drawHeroRpc(agent, data) | ||
754 | 769 | ||
755 | -- 计算抽卡消耗品 | 770 | -- 计算抽卡消耗品 |
756 | local cost = {} | 771 | local cost = {} |
757 | - local lastCount = drawCount[drawType] | ||
758 | - for _, costType in ipairs({"draw_card", "draw_coin"}) do | 772 | + if buildTypeData["draw_coin_1"] == "" then |
773 | + return 11 | ||
774 | + end | ||
775 | + local diamondCost = buildTypeData["draw_coin_1"]:toArray(true, "=") | ||
776 | + | ||
777 | + local isEnough = true | ||
778 | + for _, costType in ipairs({"draw_card_"}) do | ||
779 | + costType = costType..drawCount[drawType] | ||
759 | if buildTypeData[costType] ~= "" then | 780 | if buildTypeData[costType] ~= "" then |
760 | local curCost = buildTypeData[costType]:toArray(true, "=") | 781 | local curCost = buildTypeData[costType]:toArray(true, "=") |
761 | local hadCount = role:getItemCount(curCost[1]) | 782 | local hadCount = role:getItemCount(curCost[1]) |
762 | - local curCount = math.floor(hadCount / curCost[2]) | ||
763 | - if curCount >= lastCount then | ||
764 | - cost[curCost[1]] = curCost[2] * lastCount | ||
765 | - lastCount = 0 | 783 | + if hadCount >= curCost[2] then |
784 | + cost[curCost[1]] = curCost[2] | ||
766 | break | 785 | break |
767 | - elseif curCount > 0 then | ||
768 | - cost[curCost[1]] = curCost[2] * curCount | ||
769 | - lastCount = lastCount - curCount | 786 | + else |
787 | + cost[curCost[1]] = hadCount | ||
788 | + diamondCost[2] = (curCost[2] - hadCount) * diamondCost[2] | ||
789 | + if not role:checkItemEnough({[diamondCost[1]]=diamondCost[2]}) then | ||
790 | + isEnough = false | ||
791 | + break | ||
792 | + end | ||
793 | + cost[diamondCost[1]] = diamondCost[2] | ||
770 | end | 794 | end |
771 | end | 795 | end |
772 | end | 796 | end |
773 | - if lastCount > 0 then -- 钱不够 | 797 | + if isEnough == false then -- 钱不够 |
774 | return 4 | 798 | return 4 |
775 | end | 799 | end |
776 | 800 | ||
@@ -833,6 +857,9 @@ function _M.drawHeroRpc(agent, data) | @@ -833,6 +857,9 @@ function _M.drawHeroRpc(agent, data) | ||
833 | --print(poolId, rand_v, weight, up_pool, values[1]) | 857 | --print(poolId, rand_v, weight, up_pool, values[1]) |
834 | if rand_v < weight and up_pool then | 858 | if rand_v < weight and up_pool then |
835 | up_pool = up_pool:toArray(true, "=") | 859 | up_pool = up_pool:toArray(true, "=") |
860 | + if btype == 5 then -- 爱心卡池,使用玩家设置的备选池子 | ||
861 | + up_pool = role:getProperty("wishPool") | ||
862 | + end | ||
836 | for k, v in ipairs(up_pool) do | 863 | for k, v in ipairs(up_pool) do |
837 | resultPool[v] = {1} | 864 | resultPool[v] = {1} |
838 | end | 865 | end |
@@ -898,8 +925,14 @@ function _M.drawHeroRpc(agent, data) | @@ -898,8 +925,14 @@ function _M.drawHeroRpc(agent, data) | ||
898 | end | 925 | end |
899 | end | 926 | end |
900 | 927 | ||
901 | - if itemData.quality >= HeroQuality.SR then | ||
902 | - floorHeroCount = 0 | 928 | + if btype == 4 and role:getProperty("newerDraw") == 0 then -- 新手卡池 |
929 | + if itemData.quality == HeroQuality.SSR then | ||
930 | + floorHeroCount = 0 | ||
931 | + end | ||
932 | + else | ||
933 | + if itemData.quality >= HeroQuality.SR then | ||
934 | + floorHeroCount = 0 | ||
935 | + end | ||
903 | end | 936 | end |
904 | 937 | ||
905 | if role:isHaveHero(itemData.id - ItemStartId.Hero) then | 938 | if role:isHaveHero(itemData.id - ItemStartId.Hero) then |
@@ -922,6 +955,11 @@ function _M.drawHeroRpc(agent, data) | @@ -922,6 +955,11 @@ function _M.drawHeroRpc(agent, data) | ||
922 | role:setProperty("floorHero", floorHero) | 955 | role:setProperty("floorHero", floorHero) |
923 | end | 956 | end |
924 | 957 | ||
958 | + if btype == 4 then | ||
959 | + local newCount = role:getProperty("newerDraw") | ||
960 | + role:updateProperty({field="newerDraw", value = newCount + drawCount[drawType]}) | ||
961 | + end | ||
962 | + | ||
925 | role:checkTaskEnter("DrawHero", {pool = btype, count = drawCount[drawType]}) | 963 | role:checkTaskEnter("DrawHero", {pool = btype, count = drawCount[drawType]}) |
926 | if ssrCount > 0 then | 964 | if ssrCount > 0 then |
927 | role:checkTaskEnter("DrawSSR", {count = ssrCount}) | 965 | role:checkTaskEnter("DrawSSR", {count = ssrCount}) |
@@ -934,16 +972,21 @@ function _M.drawHeroRpc(agent, data) | @@ -934,16 +972,21 @@ function _M.drawHeroRpc(agent, data) | ||
934 | gacha_up = 0, -- 卡池UP角色 | 972 | gacha_up = 0, -- 卡池UP角色 |
935 | gacha_times = drawCount[drawType], -- 抽卡次数 | 973 | gacha_times = drawCount[drawType], -- 抽卡次数 |
936 | gacha_reward = logReward, -- 抽卡结果,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"} | 974 | gacha_reward = logReward, -- 抽卡结果,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"} |
937 | - currency = cost, -- 购买道具消耗的货币 | 975 | + gacha_cost = cost, -- 购买道具消耗的货币 |
938 | gacha_cnt = floorHeroCount, | 976 | gacha_cnt = floorHeroCount, |
939 | }) | 977 | }) |
940 | SendPacket(actionCodes.Hero_drawHeroRpc, MsgPack.pack({reward = reward})) -- 这个 reward 是数组 | 978 | SendPacket(actionCodes.Hero_drawHeroRpc, MsgPack.pack({reward = reward})) -- 这个 reward 是数组 |
941 | 979 | ||
942 | - if btype == 1 or btype == 2 then | 980 | + local feedbackId = buildTypeData["can_feedback"] or 0 |
981 | + if feedbackId ~= 0 then | ||
943 | -- 达到一定次数,给响应奖励 | 982 | -- 达到一定次数,给响应奖励 |
944 | local oldVal = role:getProperty("repayHero") or 0 | 983 | local oldVal = role:getProperty("repayHero") or 0 |
984 | + if actid then | ||
985 | + local actData = role.activity:getActData("ActHeroPool") | ||
986 | + oldVal = actData[btype] or 0 | ||
987 | + end | ||
945 | local newVal = oldVal + drawCount[drawType] | 988 | local newVal = oldVal + drawCount[drawType] |
946 | - local drawCardReward, val = role:getDrawCardExtraReward(oldVal, newVal) | 989 | + local drawCardReward, val = role:getDrawCardExtraReward(feedbackId, oldVal, newVal) |
947 | -- 空字符穿代表直接给英雄 走以前repayHeroRpc | 990 | -- 空字符穿代表直接给英雄 走以前repayHeroRpc |
948 | if drawCardReward == "" then | 991 | if drawCardReward == "" then |
949 | local repayHeroMaxCount = role:getProperty("repayMaxC") or 0 | 992 | local repayHeroMaxCount = role:getProperty("repayMaxC") or 0 |
@@ -953,11 +996,11 @@ function _M.drawHeroRpc(agent, data) | @@ -953,11 +996,11 @@ function _M.drawHeroRpc(agent, data) | ||
953 | local even = repayHeroMaxCount % 2 | 996 | local even = repayHeroMaxCount % 2 |
954 | local id = 0 | 997 | local id = 0 |
955 | if even == 1 then | 998 | if even == 1 then |
956 | - id = math.randWeight(csvdb["build_giftCsv"], "pool_1") | 999 | + id = math.randWeight(csvdb["build_giftCsv"], "pool_"..feedbackId) |
957 | else | 1000 | else |
958 | local giftHeroSet = {} | 1001 | local giftHeroSet = {} |
959 | for gid, cfg in pairs(csvdb["build_giftCsv"]) do | 1002 | for gid, cfg in pairs(csvdb["build_giftCsv"]) do |
960 | - if cfg["pool_1"] ~= 0 and not role:isHaveHero(gid - ItemStartId.Hero) then | 1003 | + if cfg["pool_"..feedbackId] ~= 0 and not role:isHaveHero(gid - ItemStartId.Hero) then |
961 | giftHeroSet[gid] = {1} | 1004 | giftHeroSet[gid] = {1} |
962 | end | 1005 | end |
963 | end | 1006 | end |
@@ -966,7 +1009,7 @@ function _M.drawHeroRpc(agent, data) | @@ -966,7 +1009,7 @@ function _M.drawHeroRpc(agent, data) | ||
966 | end | 1009 | end |
967 | end | 1010 | end |
968 | if id == 0 then | 1011 | if id == 0 then |
969 | - id = math.randWeight(csvdb["build_giftCsv"], "pool_1") | 1012 | + id = math.randWeight(csvdb["build_giftCsv"], "pool_"..feedbackId) |
970 | end | 1013 | end |
971 | 1014 | ||
972 | local r,change = {} | 1015 | local r,change = {} |
@@ -986,7 +1029,13 @@ function _M.drawHeroRpc(agent, data) | @@ -986,7 +1029,13 @@ function _M.drawHeroRpc(agent, data) | ||
986 | r, change = role:award(drawCardReward, {log = {desc = "drawHeroExtraReward", int1 = oldVal, int2 = newVal}}) | 1029 | r, change = role:award(drawCardReward, {log = {desc = "drawHeroExtraReward", int1 = oldVal, int2 = newVal}}) |
987 | SendPacket(actionCodes.Hero_drawHeroExtraRewardNtf, MsgPack.pack(role:packReward(r, change))) | 1030 | SendPacket(actionCodes.Hero_drawHeroExtraRewardNtf, MsgPack.pack(role:packReward(r, change))) |
988 | end | 1031 | end |
989 | - role:updateProperty({field = "repayHero", value = val}) | 1032 | + if not actid then |
1033 | + role:updateProperty({field = "repayHero", value = val}) | ||
1034 | + else | ||
1035 | + local actData = role.activity:getActData("ActHeroPool") | ||
1036 | + actData[btype] = val | ||
1037 | + role.activity:updateActData("ActHeroPool", actData) | ||
1038 | + end | ||
990 | end | 1039 | end |
991 | return true | 1040 | return true |
992 | end | 1041 | end |
@@ -1068,4 +1117,54 @@ function _M.changeCrown(agent, data) | @@ -1068,4 +1117,54 @@ function _M.changeCrown(agent, data) | ||
1068 | return true | 1117 | return true |
1069 | end | 1118 | end |
1070 | 1119 | ||
1120 | +function _M.itemComposeRpc(agent, data) | ||
1121 | + local role = agent.role | ||
1122 | + local msg = MsgPack.unpack(data) | ||
1123 | + | ||
1124 | + local itemId = msg.id | ||
1125 | + local count = msg.count | ||
1126 | + if not csvdb["itemCsv"][itemId] then return 1 end | ||
1127 | + local config = csvdb["item_processCsv"][itemId] | ||
1128 | + if not config then return 2 end | ||
1129 | + | ||
1130 | + local cost = config.cost:toNumMap() | ||
1131 | + for k, v in pairs(cost) do | ||
1132 | + cost[k] = v * count | ||
1133 | + end | ||
1134 | + if not role:checkItemEnough(cost) then return 2 end | ||
1135 | + role:costItems(cost, {log = {desc = "itemCompose", int1 = itemId, int2 = count}}) | ||
1136 | + role:award({[itemId] = count}, {log = {desc = "itemCompose"}}) | ||
1137 | + | ||
1138 | + SendPacket(actionCodes.Hero_itemComposeRpc, "") | ||
1139 | + return true | ||
1140 | +end | ||
1141 | + | ||
1142 | +function _M.setWishPoolRpc(agent, data) | ||
1143 | + local role = agent.role | ||
1144 | + local msg = MsgPack.unpack(data) | ||
1145 | + | ||
1146 | + local heros = msg.heros | ||
1147 | + if #heros > 3 then return 1 end | ||
1148 | + | ||
1149 | + for _, heroId in pairs(heros) do | ||
1150 | + local cfg = csvdb["build_poolCsv"][heroId] | ||
1151 | + if not cfg then return 2 end | ||
1152 | + | ||
1153 | + local buildTypeData = csvdb["build_typeCsv"][5] | ||
1154 | + if not buildTypeData then return 3 end | ||
1155 | + local poolMap = buildTypeData["pool"]:toNumMap() | ||
1156 | + local poolId = poolMap[1] | ||
1157 | + if not poolId then return 4 end | ||
1158 | + | ||
1159 | + if cfg["pool_"..poolId] == 0 then | ||
1160 | + return 5 | ||
1161 | + end | ||
1162 | + end | ||
1163 | + | ||
1164 | + role:updateProperty({field="wishPool", value = heros}) | ||
1165 | + | ||
1166 | + SendPacket(actionCodes.Hero_setWishPoolRpc, "") | ||
1167 | + return true | ||
1168 | +end | ||
1169 | + | ||
1071 | return _M | 1170 | 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) |
@@ -50,6 +51,9 @@ function _M.formatCommonRpc(agent , data) | @@ -50,6 +51,9 @@ function _M.formatCommonRpc(agent , data) | ||
50 | end | 51 | end |
51 | pvpTC.leader = msg.leader | 52 | pvpTC.leader = msg.leader |
52 | pvpTC.supports = supports | 53 | pvpTC.supports = supports |
54 | + if msg.tactics and globalCsv.tactics_skill_passive_cell[msg.tactics] then | ||
55 | + pvpTC.tactics = msg.tactics | ||
56 | + end | ||
53 | 57 | ||
54 | role:savePvpCTeam(pvpTC) | 58 | role:savePvpCTeam(pvpTC) |
55 | SendPacket(actionCodes.Pvp_formatCommonRpc, '') | 59 | SendPacket(actionCodes.Pvp_formatCommonRpc, '') |
@@ -60,7 +64,8 @@ function _M.formatHighRpc(agent , data) | @@ -60,7 +64,8 @@ function _M.formatHighRpc(agent , data) | ||
60 | local role = agent.role | 64 | local role = agent.role |
61 | local roleId = role:getProperty("id") | 65 | local roleId = role:getProperty("id") |
62 | local msg = MsgPack.unpack(data) | 66 | local msg = MsgPack.unpack(data) |
63 | - | 67 | + |
68 | + if not role:isCrossServerPvpPlayer() then return end | ||
64 | local pvpTH = {} | 69 | local pvpTH = {} |
65 | local had = {} -- 上阵的角色 | 70 | local had = {} -- 上阵的角色 |
66 | local supportHad = {} | 71 | local supportHad = {} |
@@ -92,6 +97,9 @@ function _M.formatHighRpc(agent , data) | @@ -92,6 +97,9 @@ function _M.formatHighRpc(agent , data) | ||
92 | curTeam.heros = team.heros | 97 | curTeam.heros = team.heros |
93 | curTeam.leader = team.leader | 98 | curTeam.leader = team.leader |
94 | curTeam.supports = supports | 99 | curTeam.supports = supports |
100 | + if team.tactics and globalCsv.tactics_skill_passive_cell[team.tactics] then | ||
101 | + curTeam.tactics = team.tactics | ||
102 | + end | ||
95 | 103 | ||
96 | table.insert(pvpTH, curTeam) | 104 | table.insert(pvpTH, curTeam) |
97 | end | 105 | end |
@@ -127,7 +135,7 @@ local function getMatchInfo(role, pvpList, battleCache, dbKey, infoFuncName, inf | @@ -127,7 +135,7 @@ local function getMatchInfo(role, pvpList, battleCache, dbKey, infoFuncName, inf | ||
127 | if k == "battleInfo" then | 135 | if k == "battleInfo" then |
128 | battleCache[curInfo.roleId] = v | 136 | battleCache[curInfo.roleId] = v |
129 | else | 137 | else |
130 | - if (k == "heros" or k == "battleV") and infoCache then | 138 | + if (k == "team" or k == "battleV") and infoCache then |
131 | infoCache[curInfo.roleId] = infoCache[curInfo.roleId] or {} | 139 | infoCache[curInfo.roleId] = infoCache[curInfo.roleId] or {} |
132 | infoCache[curInfo.roleId][k] = v | 140 | infoCache[curInfo.roleId][k] = v |
133 | end | 141 | end |
@@ -163,7 +171,7 @@ function _M.infoRpc(agent, data) | @@ -163,7 +171,7 @@ function _M.infoRpc(agent, data) | ||
163 | 171 | ||
164 | local pvpMC = role:getProperty("pvpMC") | 172 | local pvpMC = role:getProperty("pvpMC") |
165 | if not next(pvpMC) then --没有分配过对手 | 173 | if not next(pvpMC) then --没有分配过对手 |
166 | - role:refreshPvpMatchC(score) | 174 | + role:refreshPvpMatchC(score, -1) |
167 | pvpMC = role:getProperty("pvpMC") | 175 | pvpMC = role:getProperty("pvpMC") |
168 | end | 176 | end |
169 | if not next(pvpMC) then return end | 177 | if not next(pvpMC) then return end |
@@ -183,7 +191,7 @@ function _M.infoRpc(agent, data) | @@ -183,7 +191,7 @@ function _M.infoRpc(agent, data) | ||
183 | 191 | ||
184 | local pvpMH = role:getProperty("pvpMH") | 192 | local pvpMH = role:getProperty("pvpMH") |
185 | if not next(pvpMH) then --没有分配过对手 | 193 | if not next(pvpMH) then --没有分配过对手 |
186 | - role:refreshPvpMatchH(score) | 194 | + role:refreshPvpMatchH(score, -1) |
187 | pvpMH = role:getProperty("pvpMH") | 195 | pvpMH = role:getProperty("pvpMH") |
188 | end | 196 | end |
189 | if not next(pvpMH) then return end | 197 | if not next(pvpMH) then return end |
@@ -249,8 +257,38 @@ function _M.startBattleRpc(agent, data) | @@ -249,8 +257,38 @@ function _M.startBattleRpc(agent, data) | ||
249 | local idx = msg.idx | 257 | local idx = msg.idx |
250 | local revenge = msg.revenge | 258 | local revenge = msg.revenge |
251 | 259 | ||
252 | - local pvpTC = role:getProperty("pvpTC") | ||
253 | - 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 | ||
254 | 292 | ||
255 | local matchInfo, result, key, wait | 293 | local matchInfo, result, key, wait |
256 | 294 | ||
@@ -293,7 +331,7 @@ function _M.startBattleRpc(agent, data) | @@ -293,7 +331,7 @@ function _M.startBattleRpc(agent, data) | ||
293 | end | 331 | end |
294 | 332 | ||
295 | key = tostring(math.random()) | 333 | key = tostring(math.random()) |
296 | - _pvpStartBattleCacheC = {idx = idx, key = key, revenge = revenge} | 334 | + _pvpStartBattleCacheC = {idx = idx, key = key, revenge = revenge, pvpTC = pvpTC} |
297 | 335 | ||
298 | role:checkTaskEnter("PvpBattle") | 336 | role:checkTaskEnter("PvpBattle") |
299 | 337 | ||
@@ -336,7 +374,15 @@ function _M.endBattleRpc(agent, data) | @@ -336,7 +374,15 @@ function _M.endBattleRpc(agent, data) | ||
336 | 374 | ||
337 | 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) |
338 | 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"}}) |
339 | - 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 | ||
340 | 386 | ||
341 | -- 请求上传录像 | 387 | -- 请求上传录像 |
342 | local params = { | 388 | local params = { |
@@ -427,8 +473,8 @@ function _M.startBattleHRpc(agent, data) | @@ -427,8 +473,8 @@ function _M.startBattleHRpc(agent, data) | ||
427 | local revenge = msg.revenge | 473 | local revenge = msg.revenge |
428 | if not role:isTimeResetOpen(TimeReset.PvpHight) then return end | 474 | if not role:isTimeResetOpen(TimeReset.PvpHight) then return end |
429 | 475 | ||
430 | - local pvpTH = role:getProperty("pvpTH") | ||
431 | - if not next(pvpTH) then return 1 end | 476 | + -- local pvpTH = role:getProperty("pvpTH") |
477 | + -- if not next(pvpTH) then return 1 end | ||
432 | 478 | ||
433 | -- 检查并记录玩家队伍 | 479 | -- 检查并记录玩家队伍 |
434 | local pvpTH = {} | 480 | local pvpTH = {} |
@@ -462,6 +508,9 @@ function _M.startBattleHRpc(agent, data) | @@ -462,6 +508,9 @@ function _M.startBattleHRpc(agent, data) | ||
462 | curTeam.heros = team.heros | 508 | curTeam.heros = team.heros |
463 | curTeam.leader = team.leader | 509 | curTeam.leader = team.leader |
464 | curTeam.supports = supports | 510 | curTeam.supports = supports |
511 | + if team.tactics and globalCsv.tactics_skill_passive_cell[team.tactics] then | ||
512 | + curTeam.tactics = team.tactics | ||
513 | + end | ||
465 | 514 | ||
466 | table.insert(pvpTH, curTeam) | 515 | table.insert(pvpTH, curTeam) |
467 | end | 516 | end |
@@ -634,9 +683,18 @@ function _M.endBattleHRpc(agent, data) | @@ -634,9 +683,18 @@ function _M.endBattleHRpc(agent, data) | ||
634 | -- 战斗结束了发奖 | 683 | -- 战斗结束了发奖 |
635 | 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) |
636 | 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"}}) |
637 | - local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = 0, 0, 0, 0, 0, 0 | ||
638 | - if role:isTimeResetOpen(TimeReset.PvpHight) then | ||
639 | - 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 | ||
640 | end | 698 | end |
641 | 699 | ||
642 | -- 加入战斗记录 | 700 | -- 加入战斗记录 |
@@ -647,12 +705,12 @@ function _M.endBattleHRpc(agent, data) | @@ -647,12 +705,12 @@ function _M.endBattleHRpc(agent, data) | ||
647 | info.winId = info.isWin and roleId or match.id | 705 | info.winId = info.isWin and roleId or match.id |
648 | info.isWin = nil | 706 | info.isWin = nil |
649 | selfTeam[_idx] = { | 707 | selfTeam[_idx] = { |
650 | - heros = role:getTeamHerosInfo(_pvpStartBattleCacheH.pvpTH[_idx].heros), | 708 | + team = role:getTeamHerosInfo(_pvpStartBattleCacheH.pvpTH[_idx]), |
651 | battleV = role:getTeamBattleValue(_pvpStartBattleCacheH.pvpTH[_idx].heros) | 709 | battleV = role:getTeamBattleValue(_pvpStartBattleCacheH.pvpTH[_idx].heros) |
652 | } | 710 | } |
653 | if match.t == 1 and _pvpStartBattleCacheH.enemyT then | 711 | if match.t == 1 and _pvpStartBattleCacheH.enemyT then |
654 | enemyTeam[_idx] = { | 712 | enemyTeam[_idx] = { |
655 | - heros = _pvpStartBattleCacheH.enemyT["heros"][_idx], | 713 | + team = _pvpStartBattleCacheH.enemyT["team"][_idx], |
656 | battleV = _pvpStartBattleCacheH.enemyT["battleV"][_idx] | 714 | battleV = _pvpStartBattleCacheH.enemyT["battleV"][_idx] |
657 | } | 715 | } |
658 | end | 716 | end |
@@ -725,6 +783,7 @@ function _M.endBattleHRpc(agent, data) | @@ -725,6 +783,7 @@ function _M.endBattleHRpc(agent, data) | ||
725 | myRank = myRank, | 783 | myRank = myRank, |
726 | oldMyRank = oldMyRank, | 784 | oldMyRank = oldMyRank, |
727 | video = video, | 785 | video = video, |
786 | + headers = headers, | ||
728 | isWin = isWin, | 787 | isWin = isWin, |
729 | })) | 788 | })) |
730 | return true | 789 | return true |
@@ -0,0 +1,221 @@ | @@ -0,0 +1,221 @@ | ||
1 | +local _M = {} | ||
2 | + | ||
3 | +-- 获取英雄大成功率 | ||
4 | +local function getHeroCoef(hero, condition) | ||
5 | + -- 基础概率 | ||
6 | + local rareMap = {[HeroQuality.N] = 10, [HeroQuality.R] = 10, [HeroQuality.SR] = 15, [HeroQuality.SSR] = 20} | ||
7 | + local rare = hero:getRare() | ||
8 | + local result = 0 | ||
9 | + for _, it in ipairs(condition:toTableArray(true)) do | ||
10 | + local type = it[1] | ||
11 | + local value = it[2] | ||
12 | + local add = it[3] | ||
13 | + if type == 1 then -- 种族加成 | ||
14 | + if hero:getCamp() == value then | ||
15 | + result = result + add | ||
16 | + end | ||
17 | + elseif type == 2 then -- 定位加成 | ||
18 | + if hero:getPosition() == value then | ||
19 | + result = result + add | ||
20 | + end | ||
21 | + end | ||
22 | + end | ||
23 | + | ||
24 | + return result + (rareMap[rare] or 0) | ||
25 | +end | ||
26 | + | ||
27 | +local function getQuestMax(role) | ||
28 | + local count = 0 | ||
29 | + for _, carbonId in ipairs(globalCsv.crusade_team_unlock or {}) do | ||
30 | + if role:checkHangPass(carbonId) then | ||
31 | + count = count + 1 | ||
32 | + end | ||
33 | + end | ||
34 | + | ||
35 | + return count + (globalCsv.cursade_team_count_initial or 0) | ||
36 | +end | ||
37 | + | ||
38 | +function _M.startQuestRpc(agent, data) | ||
39 | + local role = agent.role | ||
40 | + local msg = MsgPack.unpack(data) | ||
41 | + local id = msg.id | ||
42 | + local heros = msg.heros | ||
43 | + local result = {} | ||
44 | + local radioTask = role:getProperty("radioTask") | ||
45 | + if table.numbers(radioTask) >= getQuestMax(role) then | ||
46 | + return 1 | ||
47 | + end | ||
48 | + -- check id | ||
49 | + local config = csvdb["crusadeCsv"][id] | ||
50 | + if not config then return 2 end | ||
51 | + if not role:checkHangPass(config.unlock) then return 3 end | ||
52 | + if radioTask[id] then return 4 end | ||
53 | + -- check hero | ||
54 | + --1=指定等级=人数 | ||
55 | + --2=指定稀有度=人数 | ||
56 | + --3=人数 | ||
57 | + local needHeroCnt = 0 | ||
58 | + local lvlMap = {} | ||
59 | + local rareMap = {} | ||
60 | + for _, it in ipairs(config.condition:toTableArray(true)) do | ||
61 | + local type = it[1] | ||
62 | + if type == 1 then | ||
63 | + lvlMap[1] = it[2] | ||
64 | + lvlMap[2] = it[3] | ||
65 | + elseif type == 2 then | ||
66 | + rareMap[1] = it[2] | ||
67 | + rareMap[2] = it[3] | ||
68 | + elseif type == 3 then | ||
69 | + needHeroCnt = it[2] | ||
70 | + end | ||
71 | + end | ||
72 | + for _, heroId in pairs(heros) do | ||
73 | + local hero = role.heros[heroId] | ||
74 | + if hero then | ||
75 | + needHeroCnt = needHeroCnt - 1 | ||
76 | + if next(lvlMap) then | ||
77 | + if hero:getProperty("level") >= lvlMap[1] then | ||
78 | + lvlMap[2] = lvlMap[2] - 1 | ||
79 | + if lvlMap[2] <= 0 then | ||
80 | + lvlMap = {} | ||
81 | + end | ||
82 | + end | ||
83 | + end | ||
84 | + if next(rareMap) then | ||
85 | + if hero:getRare() >= rareMap[1] then | ||
86 | + rareMap[2] = rareMap[2] - 1 | ||
87 | + end | ||
88 | + if rareMap[2] <= 0 then | ||
89 | + rareMap = {} | ||
90 | + end | ||
91 | + end | ||
92 | + end | ||
93 | + end | ||
94 | + if needHeroCnt > 0 or next(rareMap) or next(lvlMap) then | ||
95 | + return 5 | ||
96 | + end | ||
97 | + -- start quest, set finish time | ||
98 | + local taskData = {} | ||
99 | + taskData["time"] = skynet.timex() + config.time | ||
100 | + taskData["heros"] = heros | ||
101 | + radioTask[id] = taskData | ||
102 | + role:updateProperty({field="radioTask", value=radioTask, notNotify=true}) | ||
103 | + | ||
104 | + SendPacket(actionCodes.Radio_startQuestRpc, MsgPack.pack({id=id, task=taskData})) | ||
105 | + | ||
106 | + local herolist = {} | ||
107 | + for _, heroId in ipairs(heros) do | ||
108 | + local hero = role.heros[heroId] | ||
109 | + if hero then | ||
110 | + table.insert(herolist, hero:getProperty("type")) | ||
111 | + end | ||
112 | + end | ||
113 | + | ||
114 | + -- 讨伐行动 | ||
115 | + role:log("punitive_action", { | ||
116 | + mission_id = id, --关卡ID | ||
117 | + mission_herolist = herolist, -- 英雄ID,排序以玩家出战设置为准,示例:[111, 222, 333, 444, 555] | ||
118 | + mission_success_rate = 0, -- 大成功几率 | ||
119 | + mission_reward = {}, -- 获得奖励,建议使用json格式记录。示例:{ itemid1: 1, itemid2: 3, itemid3: 5} | ||
120 | + mission_result = 0, -- 战斗结果(0-无效,1-胜利,2-失败) | ||
121 | + mission_roundtime = 0, -- 完成耗时(秒) | ||
122 | + mission_cleartype = 1, -- 1-开始; 2-完成(领取奖励时) | ||
123 | + }) | ||
124 | + return true | ||
125 | +end | ||
126 | + | ||
127 | +function _M.finishQuestRpc(agent, data) | ||
128 | + local role = agent.role | ||
129 | + local msg = MsgPack.unpack(data) | ||
130 | + local id = msg.id | ||
131 | + -- check finish time | ||
132 | + local radioTask = role:getProperty("radioTask") | ||
133 | + local task = radioTask[id] | ||
134 | + if not task then return 1 end | ||
135 | + if skynet.timex() < task.time then return 2 end | ||
136 | + -- check id | ||
137 | + local config = csvdb["crusadeCsv"][id] | ||
138 | + if not config then return 3 end | ||
139 | + local carbonData = csvdb["idle_battleCsv"][config.unlock] | ||
140 | + if not carbonData then return 4 end | ||
141 | + -- get heros | ||
142 | + local totalCoef = 0 | ||
143 | + local exp = config.time / 60 | ||
144 | + local heroFaithMap = {} | ||
145 | + for _, heroId in ipairs(task.heros) do | ||
146 | + local hero = role.heros[heroId] | ||
147 | + if hero then | ||
148 | + totalCoef = totalCoef + getHeroCoef(hero, config.success) | ||
149 | + -- 增加英雄信赖 | ||
150 | + hero:addHeroFaith(exp) | ||
151 | + heroFaithMap[heroId] = hero:getProperty("faith") | ||
152 | + end | ||
153 | + end | ||
154 | + -- send award | ||
155 | + local bigSuccess = false | ||
156 | + local result = math.randomInt(0, 100) | ||
157 | + if result < totalCoef then | ||
158 | + bigSuccess = true | ||
159 | + end | ||
160 | + local money = math.ceil(carbonData.money / 5) * config.time * config.money_clear | ||
161 | + local exp = math.ceil(carbonData.exp / 5) * config.time * config.exp_clear | ||
162 | + local itemReward = config.item_clear_special:toNumMap() | ||
163 | + itemReward[ItemId.Gold] = (itemReward[ItemId.Gold] or 0) + money | ||
164 | + itemReward[ItemId.Exp] = (itemReward[ItemId.Exp] or 0) + exp | ||
165 | + if bigSuccess then | ||
166 | + for key, value in pairs(itemReward) do | ||
167 | + itemReward[key] = math.ceil(1.5 * value) | ||
168 | + end | ||
169 | + end | ||
170 | + | ||
171 | + local r, change = role:award(itemReward, {log = {desc = "radioQuest", int1 = id}}) | ||
172 | + | ||
173 | + radioTask[id] = nil | ||
174 | + role:updateProperty({field="radioTask", value=radioTask, notNotify = true}) | ||
175 | + | ||
176 | + local msg = role:packReward(r, change) | ||
177 | + msg["big"] = bigSuccess | ||
178 | + msg["id"] = id | ||
179 | + msg["heroFaith"] = heroFaithMap | ||
180 | + SendPacket(actionCodes.Radio_finishQuestRpc, MsgPack.pack(msg)) | ||
181 | + | ||
182 | + | ||
183 | + local herolist = {} | ||
184 | + for _, heroId in ipairs(task.heros) do | ||
185 | + local hero = role.heros[heroId] | ||
186 | + if hero then | ||
187 | + table.insert(herolist, hero:getProperty("type")) | ||
188 | + end | ||
189 | + end | ||
190 | + | ||
191 | + -- 讨伐行动 | ||
192 | + role:log("punitive_action", { | ||
193 | + mission_id = id, --关卡ID | ||
194 | + mission_herolist = herolist, -- 英雄ID,排序以玩家出战设置为准,示例:[111, 222, 333, 444, 555] | ||
195 | + mission_success_rate = totalCoef, -- 大成功几率 | ||
196 | + mission_reward = r, -- 获得奖励,建议使用json格式记录。示例:{ itemid1: 1, itemid2: 3, itemid3: 5} | ||
197 | + mission_result = 1, -- 战斗结果(0-无效,1-胜利,2-失败) | ||
198 | + mission_roundtime = config.time, -- 完成耗时(秒) | ||
199 | + mission_cleartype = 2, -- 1-开始; 2-完成(领取奖励时) | ||
200 | + }) | ||
201 | + | ||
202 | + return true | ||
203 | +end | ||
204 | + | ||
205 | +function _M.cancelQuestRpc(agent, data) | ||
206 | + local role = agent.role | ||
207 | + local msg = MsgPack.unpack(data) | ||
208 | + local id = msg.id | ||
209 | + -- check finish time | ||
210 | + local radioTask = role:getProperty("radioTask") | ||
211 | + local task = radioTask[id] | ||
212 | + if not task then return 1 end | ||
213 | + if skynet.timex() > task.time then return 2 end | ||
214 | + radioTask[id] = nil | ||
215 | + role:updateProperty({field="radioTask", value=radioTask, notNotify = true}) | ||
216 | + | ||
217 | + SendPacket(actionCodes.Radio_cancelQuestRpc, MsgPack.pack({id = id})) | ||
218 | + return true | ||
219 | +end | ||
220 | + | ||
221 | +return _M | ||
0 | \ No newline at end of file | 222 | \ No newline at end of file |
src/actions/RoleAction.lua
@@ -291,7 +291,7 @@ function _M.loginRpc( agent, data ) | @@ -291,7 +291,7 @@ function _M.loginRpc( agent, data ) | ||
291 | 291 | ||
292 | 292 | ||
293 | -- 玩家登陆做的一些操作 | 293 | -- 玩家登陆做的一些操作 |
294 | - role:saveHangTeam() | 294 | + role:updateHangTeamInfo() |
295 | role:savePvpCTeam() | 295 | role:savePvpCTeam() |
296 | role:savePvpHTeam() | 296 | role:savePvpHTeam() |
297 | 297 | ||
@@ -300,6 +300,7 @@ function _M.loginRpc( agent, data ) | @@ -300,6 +300,7 @@ function _M.loginRpc( agent, data ) | ||
300 | if msg.newdevice then | 300 | if msg.newdevice then |
301 | role:mylog("newdevice", {key1 = agent.ip:toArray(false, ":")[1]}) | 301 | role:mylog("newdevice", {key1 = agent.ip:toArray(false, ":")[1]}) |
302 | end | 302 | end |
303 | + | ||
303 | return true | 304 | return true |
304 | end | 305 | end |
305 | 306 | ||
@@ -372,6 +373,38 @@ function _M.createRpc(agent, data) | @@ -372,6 +373,38 @@ function _M.createRpc(agent, data) | ||
372 | end | 373 | end |
373 | 374 | ||
374 | SendPacket(actionCodes.Role_createRpc, MsgPack.pack(response)) | 375 | SendPacket(actionCodes.Role_createRpc, MsgPack.pack(response)) |
376 | + | ||
377 | + -- cb付费返利 | ||
378 | + skynet.timeout(0, function() | ||
379 | + local cbbackd = cluster.query("center", "cbbackd") | ||
380 | + local uid = newRole:getProperty("uid") | ||
381 | + local start = uid:find("_") | ||
382 | + if start then | ||
383 | + uid = uid:sub(start + 1) | ||
384 | + end | ||
385 | + if cbbackd then | ||
386 | + local status, back = pcall(cluster.call, "center", cbbackd, "getCbBack", {uid = uid, id = roleId}) | ||
387 | + if status then | ||
388 | + if back and next(back) and back.reward and next(back.reward) then | ||
389 | + local reward = "" | ||
390 | + for itemId, count in pairs(back.reward) do | ||
391 | + reward = reward:setv(itemId, count) | ||
392 | + end | ||
393 | + if back.reward[70] then | ||
394 | + redisproxy:insertEmail({roleId = roleId, emailId = MailId.CBBackAward2, contentPms = {back.money}, createtime = skynet.timex(), attachments = reward}) | ||
395 | + else | ||
396 | + redisproxy:insertEmail({roleId = roleId, emailId = MailId.CBBackAward, contentPms = {back.money}, createtime = skynet.timex(), attachments = reward}) | ||
397 | + end | ||
398 | + newRole:mylog("cbback", {key1 = uid, int2 = roleId}) | ||
399 | + end | ||
400 | + else | ||
401 | + skynet.error("[ERROR] cbbackd cant call center uid: " .. uid .. " roleId:" .. roleId) | ||
402 | + end | ||
403 | + else | ||
404 | + skynet.error("[ERROR] cbbackd cant call center uid: " .. uid .. " roleId:" .. roleId) | ||
405 | + end | ||
406 | + end) | ||
407 | + | ||
375 | return true | 408 | return true |
376 | end | 409 | end |
377 | 410 | ||
@@ -537,82 +570,132 @@ function _M.openTimeBoxRpc(agent, data) | @@ -537,82 +570,132 @@ function _M.openTimeBoxRpc(agent, data) | ||
537 | local slot = msg.slot -- 位置 1 - 6 | 570 | local slot = msg.slot -- 位置 1 - 6 |
538 | 571 | ||
539 | -- 特权卡时间箱额外栏位 | 572 | -- 特权卡时间箱额外栏位 |
540 | - local privExtraCnt = role.storeData:getTimeBoxSlotExtraCount() | ||
541 | - if oper == 1 then | ||
542 | - if math.illegalNum(slot, 1, role:getFuncLv(FuncOpenType.TimeBoxSlot) + privExtraCnt) then return end | ||
543 | - end | 573 | + -- local privExtraCnt = role.storeData:getTimeBoxSlotExtraCount() |
574 | + -- if oper == 1 then | ||
575 | + -- if math.illegalNum(slot, 1, role:getFuncLv(FuncOpenType.TimeBoxSlot) + privExtraCnt) then return end | ||
576 | + -- end | ||
544 | 577 | ||
545 | local boxL = role:getProperty("boxL") | 578 | local boxL = role:getProperty("boxL") |
546 | - local reward, change = {} | ||
547 | - if oper == 1 then -- 打开 | 579 | + local reward, change |
580 | + if oper == 1 then -- 构建开始(包括切换构建的id) | ||
548 | local itemId = msg.itemId | 581 | local itemId = msg.itemId |
549 | - if role:getItemCount(itemId) < 1 then return end | ||
550 | local itemData = csvdb["itemCsv"][itemId] | 582 | local itemData = csvdb["itemCsv"][itemId] |
551 | - local randomData = csvdb["item_randomCsv"][itemId] | ||
552 | - if not itemData or not randomData or randomData.openTime <= 0 then return end | ||
553 | - | ||
554 | - if boxL[slot] then return end | ||
555 | - role:costItems({[itemId] = 1}, {log = {desc = "openTimeBox"}}) | ||
556 | - boxL[slot] = {id = itemId, time = skynet.timex() + randomData.openTime} | ||
557 | - role:pushMsg({type = "box", slot = slot, time = randomData.openTime}) | ||
558 | - elseif oper == 2 then -- 领取 | 583 | + if not itemData then return 1 end |
584 | + if not boxL[slot] then | ||
585 | + boxL[slot] = {} | ||
586 | + else | ||
587 | + local oldId, process, time = boxL[slot].id, boxL[slot].process, boxL[slot].time | ||
588 | + local unitTime = globalCsv.box_key_time[oldId] * 60 | ||
589 | + local doneCnt = math.floor((process + skynet.timex() - time) / unitTime) | ||
590 | + if doneCnt > 0 then | ||
591 | + reward = role:award({[oldId] = doneCnt}, {log = {desc = "openTimeBox", int1 = slot}}) | ||
592 | + end | ||
593 | + end | ||
594 | + local limit = globalCsv.box_key_max[itemId] or 5 | ||
595 | + if role:getItemCount(itemId) >= limit then return 3 end | ||
596 | + | ||
597 | + boxL[slot] = {id = itemId, process = 0, time = skynet.timex()} | ||
598 | + role:pushMsg({type = "box", slot = slot, time = skynet.timex() + globalCsv.box_productLine_time * 3600}) | ||
599 | + elseif oper == 2 then -- 重置运行时间(可以使用加速) | ||
559 | local quick = msg.quick | 600 | local quick = msg.quick |
560 | - if not boxL[slot] then return end | ||
561 | - local costKey = 0 | ||
562 | - if boxL[slot].time > skynet.timex() then -- 没开完 | ||
563 | - if not quick then return end | 601 | + if not boxL[slot] then return 4 end |
602 | + | ||
603 | + local itemId, process, time = boxL[slot].id, boxL[slot].process, boxL[slot].time | ||
604 | + local nowTime = skynet.timex() | ||
605 | + local stopTime = nowTime | ||
606 | + local itemData = csvdb["itemCsv"][itemId] | ||
607 | + local unitTime = globalCsv.box_key_time[itemId] * 60 | ||
608 | + if quick then | ||
609 | + stopTime = time + globalCsv.box_productLine_time * 3600 | ||
564 | local cost_pre = globalCsv.box_timeOpen_diamond:toArray(true, "=") | 610 | local cost_pre = globalCsv.box_timeOpen_diamond:toArray(true, "=") |
565 | - costKey = math.ceil((boxL[slot].time - skynet.timex()) / (cost_pre[1] * 60)) * cost_pre[2] | ||
566 | - if not role:checkItemEnough({[ItemId.BoxKey] = costKey}) then return end | ||
567 | - role:costItems({[ItemId.BoxKey] = costKey}, {log = {desc = "openTimeBox"}}) | ||
568 | - role:pushCancel({type = "box", slot = slot}) | 611 | + local costKey = math.ceil((stopTime - nowTime) / (cost_pre[1] * 60)) * cost_pre[2] |
612 | + if not role:checkItemEnough({[ItemId.Diamond] = costKey}) then return 5 end | ||
613 | + role:costItems({[ItemId.Diamond] = costKey}, {log = {desc = "openTimeBox", int1 = slot}}) | ||
614 | + else | ||
615 | + stopTime = math.min(nowTime,time + globalCsv.box_productLine_time * 3600) | ||
616 | + end | ||
617 | + role:pushCancel({type = "box", slot = slot}) | ||
618 | + | ||
619 | + local doneCnt = math.floor((process + stopTime - time) / unitTime) | ||
620 | + if doneCnt > 0 then | ||
621 | + reward = role:award({[itemId] = doneCnt}, {log = {desc = "openTimeBox", int1 = slot}}) | ||
622 | + end | ||
623 | + if role:getItemCount(itemId) >= globalCsv.box_key_max[itemId] then | ||
624 | + nowTime = 0 | ||
625 | + end | ||
626 | + | ||
627 | + boxL[slot] = {id = itemId, process = (process + stopTime - time) % unitTime, time = nowTime} | ||
628 | + role:pushMsg({type = "box", slot = slot, time = nowTime + globalCsv.box_productLine_time * 3600}) | ||
629 | + elseif oper == 3 then -- 开箱子 | ||
630 | + local costId = msg.costId | ||
631 | + local costs = (msg.costs or ""):toNumMap() | ||
632 | + if not costId or not csvdb["itemCsv"][costId] or not next(costs) then return 6 end | ||
633 | + | ||
634 | + local costIdData = csvdb["itemCsv"][costId] | ||
635 | + local count = 0 | ||
636 | + for itemId, num in pairs(costs) do | ||
637 | + local itemIdData = csvdb["itemCsv"][itemId] | ||
638 | + if not itemIdData or not csvdb["item_randomCsv"][itemId] or costIdData.quality ~= itemIdData.quality then return 7 end | ||
639 | + count = count + num | ||
569 | end | 640 | end |
570 | - local boxId = boxL[slot].id | ||
571 | - local itemData = csvdb["itemCsv"][boxId] | ||
572 | - local randomData = csvdb["item_randomCsv"][itemData.id] | ||
573 | - local costTime = skynet.timex() - (boxL[slot].time - randomData.openTime) | ||
574 | - -- 随机奖励 | 641 | + |
642 | + if role:getItemCount(costId) < count then return 8 end | ||
643 | + if not role:checkItemEnough(costs) then return 9 end | ||
644 | + | ||
645 | + role:costItems({[costId] = count}, {log = {desc = "openTimeBox"}}) | ||
646 | + | ||
575 | reward = {} | 647 | reward = {} |
576 | - for i = 1, 10 do | ||
577 | - local num = randomData["num" .. i] | ||
578 | - local gift = randomData["gift" .. i] | ||
579 | - if num and gift and num > 0 and gift ~= "" then | ||
580 | - local pool = {} | ||
581 | - for _, temp in ipairs(gift:toArray()) do | ||
582 | - local set = temp:toArray(true, "=") | ||
583 | - table.insert(pool, set) | 648 | + for itemId, value in pairs(costs) do |
649 | + local tempReward = {} | ||
650 | + local randomData = csvdb["item_randomCsv"][itemId] | ||
651 | + local itemData = csvdb["itemCsv"][itemId] | ||
652 | + role:costItems({[itemId] = value}, {log = {desc = "openTimeBox"}}) | ||
653 | + for _ = 1, value do | ||
654 | + for i = 1, 10 do | ||
655 | + local num = randomData["num" .. i] | ||
656 | + local gift = randomData["gift" .. i] | ||
657 | + if num and gift and num > 0 and gift ~= "" then | ||
658 | + local pool = {} | ||
659 | + for _, temp in ipairs(gift:toArray()) do | ||
660 | + local set = temp:toArray(true, "=") | ||
661 | + table.insert(pool, set) | ||
662 | + end | ||
663 | + | ||
664 | + local needCount = math.min(#pool, num) | ||
665 | + for j = 1, needCount do | ||
666 | + local idx = math.randWeight(pool, 3) | ||
667 | + tempReward[pool[idx][1]] = (tempReward[pool[idx][1]] or 0) + pool[idx][2] | ||
668 | + table.remove(pool, idx) | ||
669 | + end | ||
670 | + end | ||
584 | end | 671 | end |
672 | + end | ||
673 | + tempReward[0] = nil | ||
674 | + role:checkTaskEnter("OpenBox", {id = itemId, count=value, quality=itemData.quality}) | ||
675 | + role:log("carriage_dismantle", { | ||
676 | + item_id = itemId, -- 道具id | ||
677 | + item_type = itemData.type, -- 道具类型,具体见枚举表中道具类型枚举表 | ||
678 | + item_level = 0, -- 道具等级 | ||
679 | + item_number = 1, -- 道具变化数量的绝对值 | ||
680 | + carriage_dismantle_type = 1, -- 拆解方式,时间到期:0,钥匙开启:1 | ||
681 | + carriage_dismantle_time = 0, -- 拆解耗时,填写实际耗时 | ||
682 | + carriage_dismantle_cost = value, -- 拆解花费钥匙数量,未使用填写0 | ||
683 | + carriage_dismantle_rwd = tempReward, -- 拆解获得物资,json格式记录,{'itemid1':2,'itemid2':3,…………..} | ||
684 | + }) | ||
585 | 685 | ||
586 | - local needCount = math.min(#pool, num) | ||
587 | - for j = 1, needCount do | ||
588 | - local idx = math.randWeight(pool, 3) | ||
589 | - reward[pool[idx][1]] = (reward[pool[idx][1]] or 0) + pool[idx][2] | ||
590 | - table.remove(pool, idx) | ||
591 | - end | 686 | + for id, num in pairs(tempReward) do |
687 | + reward[id] = (reward[id] or 0) + num | ||
592 | end | 688 | end |
593 | end | 689 | end |
594 | - reward[0] = nil | ||
595 | - | ||
596 | - boxL[slot] = nil | ||
597 | - reward, change = role:award(reward, {log = {desc = "openTimeBox", int1 = boxId}}) | ||
598 | - role:checkTaskEnter("OpenBox", {id = boxId, count=1, quality=itemData.quality}) | ||
599 | - | ||
600 | - role:log("carriage_dismantle", { | ||
601 | - item_id = boxId, -- 道具id | ||
602 | - item_type = itemData.type, -- 道具类型,具体见枚举表中道具类型枚举表 | ||
603 | - item_level = 0, -- 道具等级 | ||
604 | - item_number = 1, -- 道具变化数量的绝对值 | ||
605 | - carriage_dismantle_type = quick and 1 or 0, -- 拆解方式,时间到期:0,钥匙开启:1 | ||
606 | - carriage_dismantle_time = costTime, -- 拆解耗时,填写实际耗时 | ||
607 | - carriage_dismantle_cost = costKey, -- 拆解花费钥匙数量,未使用填写0 | ||
608 | - carriage_dismantle_rwd = reward, -- 拆解获得物资,json格式记录,{'itemid1':2,'itemid2':3,…………..} | ||
609 | - }) | 690 | + reward, change = role:award(reward, {log = {desc = "openTimeBox", int1 = costId}}) |
610 | else | 691 | else |
611 | return | 692 | return |
612 | end | 693 | end |
613 | 694 | ||
614 | - role:setProperty("boxL") --刷新 | ||
615 | - role:changeUpdates({{type = "boxL", field = slot, value = boxL[slot], isOnlyToC = true}}) -- 通知客户端 | 695 | + role:setProperty("boxL",boxL) --刷新 |
696 | + if slot then | ||
697 | + role:changeUpdates({{type = "boxL", field = slot, value = boxL[slot], isOnlyToC = true}}) -- 通知客户端 | ||
698 | + end | ||
616 | SendPacket(actionCodes.Role_openTimeBoxRpc, MsgPack.pack(role:packReward(reward, change))) | 699 | SendPacket(actionCodes.Role_openTimeBoxRpc, MsgPack.pack(role:packReward(reward, change))) |
617 | return true | 700 | return true |
618 | end | 701 | end |
@@ -724,11 +807,12 @@ function _M.unLockStoryBookRpc(agent, data) | @@ -724,11 +807,12 @@ function _M.unLockStoryBookRpc(agent, data) | ||
724 | local storyStatus = role:getProperty("storyB") | 807 | local storyStatus = role:getProperty("storyB") |
725 | if storyStatus[storyId] and storyStatus[storyId].s then return end --不需要解锁 | 808 | if storyStatus[storyId] and storyStatus[storyId].s then return end --不需要解锁 |
726 | 809 | ||
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}}) | 810 | + if storyBookData.lockItem ~= "free" then |
811 | + local cost = storyBookData.lockItem:toNumMap() | ||
812 | + if not cost or not next(cost) then return end | ||
813 | + if not role:checkItemEnough(cost) then return end -- 消耗品不足 | ||
814 | + role:costItems(cost, {log = {desc = "unlockStory", int1 = storyId}}) | ||
815 | + end | ||
732 | 816 | ||
733 | -- 解锁 | 817 | -- 解锁 |
734 | storyStatus[storyId] = storyStatus[storyId] or {} | 818 | storyStatus[storyId] = storyStatus[storyId] or {} |
@@ -807,6 +891,12 @@ function _M.taskActiveRpc(agent, data) | @@ -807,6 +891,12 @@ function _M.taskActiveRpc(agent, data) | ||
807 | { type = roleField[taskType], field = {"at", taskId}, value = -1 } | 891 | { type = roleField[taskType], field = {"at", taskId}, value = -1 } |
808 | }) | 892 | }) |
809 | 893 | ||
894 | + role:log("task_reward", { | ||
895 | + task_reward_id = taskId * 100 + taskType, --任务奖励ID | ||
896 | + task_reward_type = 3, --任务奖励类型,见 任务奖励类型枚举表 | ||
897 | + task_reward_detail = reward, --任务奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} | ||
898 | + }) | ||
899 | + | ||
810 | SendPacket(actionCodes.Role_taskActiveRpc, MsgPack.pack(role:packReward(reward, change))) | 900 | SendPacket(actionCodes.Role_taskActiveRpc, MsgPack.pack(role:packReward(reward, change))) |
811 | return true | 901 | return true |
812 | end | 902 | end |
@@ -1255,4 +1345,40 @@ function _M.useSelectItemRpc(agent, data) | @@ -1255,4 +1345,40 @@ function _M.useSelectItemRpc(agent, data) | ||
1255 | return true | 1345 | return true |
1256 | end | 1346 | end |
1257 | 1347 | ||
1348 | +function _M.renameTeamRpc(agent, data) | ||
1349 | + local role = agent.role | ||
1350 | + local msg = MsgPack.unpack(data) | ||
1351 | + local title = msg.title | ||
1352 | + local index = msg.index | ||
1353 | + local ispve = msg.ispve | ||
1354 | + if ispve then | ||
1355 | + local teams = role:getProperty("hangTeams") | ||
1356 | + local team = role:getTeamFormat(index) | ||
1357 | + team.title = title | ||
1358 | + teams[index] = team | ||
1359 | + role:updateProperty({field = "hangTeams", value = teams, notNotify = false}) | ||
1360 | + else | ||
1361 | + local teams = role:getProperty("advTeams") | ||
1362 | + local team = role:getAdvTeamFormat(index) | ||
1363 | + team.title = title | ||
1364 | + teams[index] = team | ||
1365 | + role:updateProperty({field = "advTeams", value = teams, notNotify = false}) | ||
1366 | + end | ||
1367 | + | ||
1368 | + SendPacket(actionCodes.Role_renameTeamRpc, "") | ||
1369 | + return true | ||
1370 | +end | ||
1371 | + | ||
1372 | +function _M.accuseRpc(agent, data) | ||
1373 | + local role = agent.role | ||
1374 | + local msg = MsgPack.unpack(data) | ||
1375 | + local targetId = msg.targetId | ||
1376 | + local atype = msg.type | ||
1377 | + local note = msg.note | ||
1378 | + | ||
1379 | + role:mylog("role_action", {desc = "accuse", int1 = targetId, short1 = atype, text1 = note}) | ||
1380 | + SendPacket(actionCodes.Role_accuseRpc, "") | ||
1381 | + return true | ||
1382 | +end | ||
1383 | + | ||
1258 | return _M | 1384 | return _M |
1259 | \ No newline at end of file | 1385 | \ No newline at end of file |
src/actions/StoreAction.lua
@@ -14,6 +14,9 @@ function _M.rechargeRpc(agent , data) | @@ -14,6 +14,9 @@ function _M.rechargeRpc(agent , data) | ||
14 | 14 | ||
15 | --创建订单号 | 15 | --创建订单号 |
16 | local partnerOrderId = role:getPurchaseOrder(id) | 16 | local partnerOrderId = role:getPurchaseOrder(id) |
17 | + if partnerOrderId == "" then | ||
18 | + return 1 | ||
19 | + end | ||
17 | SendPacket(actionCodes.Store_rechargeRpc, MsgPack.pack({ order = partnerOrderId })) | 20 | SendPacket(actionCodes.Store_rechargeRpc, MsgPack.pack({ order = partnerOrderId })) |
18 | 21 | ||
19 | 22 | ||
@@ -397,4 +400,30 @@ function _M.getExploreCommandRewardRpc(agent, data) | @@ -397,4 +400,30 @@ function _M.getExploreCommandRewardRpc(agent, data) | ||
397 | return true | 400 | return true |
398 | end | 401 | end |
399 | 402 | ||
403 | +-- 累充奖励 | ||
404 | +function _M.getTotalRechargeAwardRpc(agent, data) | ||
405 | + local role = agent.role | ||
406 | + local msg = MsgPack.unpack(data) | ||
407 | + local index = msg.index -- 领取的索引id | ||
408 | + local totalTwd = role:getProperty("twdC") | ||
409 | + local totalRechargeRecord = role.storeData:getProperty("totalRR") | ||
410 | + local flag = string.char(string.getbit(totalRechargeRecord, index)) | ||
411 | + if flag == "1" then return 1 end | ||
412 | + local cfg = csvdb["activity_payRebateCsv"][index] | ||
413 | + if not cfg then return 2 end | ||
414 | + if cfg.twd > totalTwd then return 3 end | ||
415 | + | ||
416 | + totalRechargeRecord = string.setbit(totalRechargeRecord, index) | ||
417 | + role.storeData:updateProperty({field = "totalRR", value = totalRechargeRecord}) | ||
418 | + local main = cfg.main_reward:toNumMap() | ||
419 | + local sub = cfg.sub_reward:toNumMap() | ||
420 | + for k, v in pairs(sub) do | ||
421 | + main[k] = (main[k] or 0) + v | ||
422 | + end | ||
423 | + | ||
424 | + local reward, change = role:award(main, {log = {desc = "totalRecharge", int1 = index}}) | ||
425 | + SendPacket(actionCodes.Store_getTotalRechargeAwardRpc, MsgPack.pack(role:packReward(reward, change))) | ||
426 | + return true | ||
427 | +end | ||
428 | + | ||
400 | return _M | 429 | return _M |
401 | \ No newline at end of file | 430 | \ No newline at end of file |
src/actions/TowerAction.lua
@@ -8,36 +8,6 @@ local MsgPack = MsgPack | @@ -8,36 +8,6 @@ local MsgPack = MsgPack | ||
8 | local _M = {} | 8 | local _M = {} |
9 | 9 | ||
10 | 10 | ||
11 | -function _M.roleFormatRpc(agent , data) | ||
12 | - local role = agent.role | ||
13 | - local msg = MsgPack.unpack(data) | ||
14 | - local towerTeam = role:getProperty("towerF") | ||
15 | - for slot, heroId in pairs(msg.heros) do | ||
16 | - if not role.heros[heroId] then | ||
17 | - return | ||
18 | - end | ||
19 | - end | ||
20 | - local supports = {} | ||
21 | - for slot, support in pairs(msg.supports) do | ||
22 | - if slot ~= 1 and slot ~= 2 then return end | ||
23 | - local level = role.dinerData:getProperty("dishTree"):getv(support, 0) | ||
24 | - if level <= 0 then return end | ||
25 | - supports[slot] = support | ||
26 | - end | ||
27 | - table.clear(towerTeam) | ||
28 | - towerTeam.heros = {} | ||
29 | - for slot, heroId in pairs(msg.heros) do | ||
30 | - towerTeam.heros[slot] = heroId | ||
31 | - end | ||
32 | - towerTeam.leader = msg.leader | ||
33 | - towerTeam.supports = supports | ||
34 | - | ||
35 | - | ||
36 | - role:updateProperty({field = "towerF", value = towerTeam}) | ||
37 | - SendPacket(actionCodes.Tower_roleFormatRpc, '') | ||
38 | - return true | ||
39 | -end | ||
40 | - | ||
41 | 11 | ||
42 | local function getUpdateTime(lastCount, lastTime) | 12 | local function getUpdateTime(lastCount, lastTime) |
43 | local nextCount, nextTime = lastCount, skynet.timex() | 13 | local nextCount, nextTime = lastCount, skynet.timex() |
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) |
@@ -102,6 +102,9 @@ function Adv:initByChapter(params) | @@ -102,6 +102,9 @@ function Adv:initByChapter(params) | ||
102 | self.cacheUnlock = self.cacheUnlock or {} | 102 | self.cacheUnlock = self.cacheUnlock or {} |
103 | self.shopStatus = self.shopStatus or {} | 103 | self.shopStatus = self.shopStatus or {} |
104 | self.support = self.support or {} | 104 | self.support = self.support or {} |
105 | + if self.battle then | ||
106 | + self.battle:overBattle() | ||
107 | + end | ||
105 | self.battle = nil -- 清掉 老的 battle | 108 | self.battle = nil -- 清掉 老的 battle |
106 | self.logid = self.owner:getActionUcode() | 109 | self.logid = self.owner:getActionUcode() |
107 | 110 | ||
@@ -146,25 +149,15 @@ function Adv:initByChapter(params) | @@ -146,25 +149,15 @@ function Adv:initByChapter(params) | ||
146 | self.maps = {} | 149 | self.maps = {} |
147 | self.maps[1] = AdvMap.new(self, 1, mapId, isEnter, isNewRelay) | 150 | self.maps[1] = AdvMap.new(self, 1, mapId, isEnter, isNewRelay) |
148 | 151 | ||
149 | - self:initBattle(true) | 152 | + self:initBattle(nil, isToNext) |
150 | 153 | ||
151 | self:initLayerTask() | 154 | self:initLayerTask() |
152 | 155 | ||
153 | - -- 支援效果生效一些 | ||
154 | - self:activeSomeSupport() | 156 | + |
155 | 157 | ||
156 | self:checkTask(Adv.TaskType.Arrive) | 158 | self:checkTask(Adv.TaskType.Arrive) |
157 | self:checkAdvUnlock(1, self.level) | 159 | self:checkAdvUnlock(1, self.level) |
158 | 160 | ||
159 | - if isToNext then | ||
160 | - self.battle.player:afterLayer() -- 玩家的buff 清理一下 | ||
161 | - end | ||
162 | - | ||
163 | - -- 不是中继层 加上 层 和 地图的buff和被动 | ||
164 | - if not self.isRelay then | ||
165 | - self.battle:initMapEffect() | ||
166 | - end | ||
167 | - | ||
168 | -- 中继进入奖励 | 161 | -- 中继进入奖励 |
169 | if relayData and isEnter then | 162 | if relayData and isEnter then |
170 | self:awardRelay(relayData, notNotify) | 163 | self:awardRelay(relayData, notNotify) |
@@ -211,7 +204,7 @@ function Adv:saveDB(notNotify) | @@ -211,7 +204,7 @@ function Adv:saveDB(notNotify) | ||
211 | advInfo.logid = self.logid | 204 | advInfo.logid = self.logid |
212 | advInfo.maps = {} | 205 | advInfo.maps = {} |
213 | 206 | ||
214 | - self.battle:saveDB() | 207 | + self.battle:saveDB(advInfo) |
215 | 208 | ||
216 | for id , map in ipairs(self.maps) do | 209 | for id , map in ipairs(self.maps) do |
217 | advInfo.maps[id] = map:getDB() | 210 | advInfo.maps[id] = map:getDB() |
@@ -453,8 +446,20 @@ function Adv:clearAdvUnlockCache() | @@ -453,8 +446,20 @@ function Adv:clearAdvUnlockCache() | ||
453 | self.cacheUnlock = {} | 446 | self.cacheUnlock = {} |
454 | end | 447 | end |
455 | 448 | ||
456 | -function Adv:initBattle(notDb) | 449 | +function Adv:initBattle(info, isToNext) |
457 | 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 | + | ||
458 | for _, passiveC in ipairs(self.cachePassiveEvent or {}) do | 463 | for _, passiveC in ipairs(self.cachePassiveEvent or {}) do |
459 | self.battle:triggerPassive(passiveC[1], passiveC[2]) | 464 | self.battle:triggerPassive(passiveC[1], passiveC[2]) |
460 | end | 465 | end |
@@ -465,9 +470,16 @@ function Adv:initBattle(notDb) | @@ -465,9 +470,16 @@ function Adv:initBattle(notDb) | ||
465 | map:initBattleAfter() | 470 | map:initBattleAfter() |
466 | end | 471 | end |
467 | --下层 | 472 | --下层 |
468 | - if notDb and self.level ~= 1 then | 473 | + if not info and isToNext then |
469 | self.battle.player:attrChangeCondBuffCheck(1) | 474 | self.battle.player:attrChangeCondBuffCheck(1) |
470 | end | 475 | end |
476 | + | ||
477 | + -- 初始化 | ||
478 | + if not info then | ||
479 | + self.battle:newBattle() | ||
480 | + else | ||
481 | + self.battle:loadBattle(info) | ||
482 | + end | ||
471 | end | 483 | end |
472 | 484 | ||
473 | function Adv:triggerPassive(condType, params) | 485 | function Adv:triggerPassive(condType, params) |
@@ -810,7 +822,7 @@ function Adv:over(success, rewardRatio, overType) | @@ -810,7 +822,7 @@ function Adv:over(success, rewardRatio, overType) | ||
810 | lv = self.owner:getProperty("level"), | 822 | lv = self.owner:getProperty("level"), |
811 | batteV = self.owner:getTeamBattleValue(team.heros), | 823 | batteV = self.owner:getTeamBattleValue(team.heros), |
812 | chapter = self.chapterId, | 824 | chapter = self.chapterId, |
813 | - format = self.owner:getTeamHerosInfo(team.heros), | 825 | + format = self.owner:getTeamHerosInfo(team).heros, |
814 | } | 826 | } |
815 | redisproxy:pipelining(function (red) | 827 | redisproxy:pipelining(function (red) |
816 | red:zadd(self.owner:getAdvRankKey(), score, roleId) --更新分数 | 828 | red:zadd(self.owner:getAdvRankKey(), score, roleId) --更新分数 |
@@ -936,7 +948,7 @@ end | @@ -936,7 +948,7 @@ end | ||
936 | 948 | ||
937 | -- log long1 字段被征用!!! | 949 | -- log long1 字段被征用!!! |
938 | -- 在冒险中获得的物品都发放在冒险背包内 | 950 | -- 在冒险中获得的物品都发放在冒险背包内 |
939 | -function Adv:award(gift, params) | 951 | +function Adv:award(gift, params, backRewardParams) |
940 | params = params or {} | 952 | params = params or {} |
941 | local tgift = {} | 953 | local tgift = {} |
942 | if type(gift) == "string" then | 954 | if type(gift) == "string" then |
@@ -948,6 +960,8 @@ function Adv:award(gift, params) | @@ -948,6 +960,8 @@ function Adv:award(gift, params) | ||
948 | end | 960 | end |
949 | local items = self.owner:getProperty("advItems") | 961 | local items = self.owner:getProperty("advItems") |
950 | local oldItems = items | 962 | local oldItems = items |
963 | + | ||
964 | + local autoUse = {} | ||
951 | for itemId, count in pairs(tgift) do | 965 | for itemId, count in pairs(tgift) do |
952 | if count > 0 then | 966 | if count > 0 then |
953 | local buffAdd = self.battle.player:getRewardChange(itemId) | 967 | local buffAdd = self.battle.player:getRewardChange(itemId) |
@@ -956,41 +970,45 @@ function Adv:award(gift, params) | @@ -956,41 +970,45 @@ function Adv:award(gift, params) | ||
956 | self:checkAchievement(Adv.AchievType.GetItem, count, itemId) | 970 | self:checkAchievement(Adv.AchievType.GetItem, count, itemId) |
957 | end | 971 | end |
958 | tgift[itemId] = count | 972 | tgift[itemId] = count |
959 | - local origin = items:getv(itemId, 0) | ||
960 | - local nums = origin + count | ||
961 | - | ||
962 | - if csvdb["adv_artifactCsv"][itemId] then -- 获得神器 | ||
963 | - self:awardArtifact(itemId, params) | ||
964 | - if not self.owner:checkOverGuide(55) then | ||
965 | - self.owner:saveGuide(55,1,true) | ||
966 | - end | 973 | + if globalCsv.adv_auto_useItem[itemId] and count > 0 then |
974 | + autoUse[itemId] = count | ||
967 | else | 975 | else |
968 | - if nums <= 0 then | ||
969 | - items = items:delk(itemId) | ||
970 | - nums = 0 | 976 | + local origin = items:getv(itemId, 0) |
977 | + local nums = origin + count | ||
978 | + | ||
979 | + if csvdb["adv_artifactCsv"][itemId] then -- 获得神器 | ||
980 | + self:awardArtifact(itemId, params) | ||
981 | + if not self.owner:checkOverGuide(55) then | ||
982 | + self.owner:saveGuide(55,1,true) | ||
983 | + end | ||
971 | else | 984 | else |
972 | - items = items:setv(itemId, nums) | ||
973 | - end | 985 | + if nums <= 0 then |
986 | + items = items:delk(itemId) | ||
987 | + nums = 0 | ||
988 | + else | ||
989 | + items = items:setv(itemId, nums) | ||
990 | + end | ||
974 | 991 | ||
975 | - if itemId == 16 and not self.owner:checkOverGuide(51,4) then | ||
976 | - self.owner:saveGuide(51,4) | ||
977 | - end | ||
978 | - if params.log then | ||
979 | - local log = clone(params.log) | ||
980 | - if log["cint1"] or log["cint2"] or log["cint3"] or log["long1"] then | ||
981 | - print("addAdvItem error log have cint1 or cint2 or cint3 ", debug.traceback()) | 992 | + if itemId == 16 and not self.owner:checkOverGuide(51,4) then |
993 | + self.owner:saveGuide(51,4) | ||
982 | end | 994 | end |
983 | - log["cint1"] = itemId | ||
984 | - log["cint2"] = math.abs(count) | ||
985 | - log["cint3"] = self.chapterId | ||
986 | - log["long1"] = self.level | ||
987 | - if count >= 0 then | ||
988 | - self.owner:mylog("in_adv", log) | 995 | + if params.log then |
996 | + local log = clone(params.log) | ||
997 | + if log["cint1"] or log["cint2"] or log["cint3"] or log["long1"] then | ||
998 | + print("addAdvItem error log have cint1 or cint2 or cint3 ", debug.traceback()) | ||
999 | + end | ||
1000 | + log["cint1"] = itemId | ||
1001 | + log["cint2"] = math.abs(count) | ||
1002 | + log["cint3"] = self.chapterId | ||
1003 | + log["long1"] = self.level | ||
1004 | + if count >= 0 then | ||
1005 | + self.owner:mylog("in_adv", log) | ||
1006 | + else | ||
1007 | + self.owner:mylog("out_adv", log) | ||
1008 | + end | ||
989 | else | 1009 | else |
990 | - self.owner:mylog("out_adv", log) | 1010 | + print("addAdvItem no log ", debug.traceback()) |
991 | end | 1011 | end |
992 | - else | ||
993 | - print("addAdvItem no log ", debug.traceback()) | ||
994 | end | 1012 | end |
995 | end | 1013 | end |
996 | end | 1014 | end |
@@ -1001,10 +1019,48 @@ function Adv:award(gift, params) | @@ -1001,10 +1019,48 @@ function Adv:award(gift, params) | ||
1001 | if tgift[ItemId.OldCoin] then | 1019 | if tgift[ItemId.OldCoin] then |
1002 | self.battle.player:attrChangeCondBuffCheck(0) | 1020 | self.battle.player:attrChangeCondBuffCheck(0) |
1003 | end | 1021 | end |
1022 | + | ||
1023 | + if backRewardParams then | ||
1024 | + self:backReward(tgift, backRewardParams) | ||
1025 | + end | ||
1026 | + | ||
1027 | + if next(autoUse) then | ||
1028 | + for itemId, count in pairs(autoUse) do | ||
1029 | + self:useItem(itemId, count) | ||
1030 | + end | ||
1031 | + self:backUse(autoUse, 1) | ||
1032 | + end | ||
1004 | return tgift | 1033 | return tgift |
1005 | end | 1034 | end |
1006 | 1035 | ||
1007 | 1036 | ||
1037 | +function Adv:useItem(itemId, count, target) | ||
1038 | + local itemData = csvdb["adv_itemCsv"][itemId] | ||
1039 | + if not itemData then return end | ||
1040 | + | ||
1041 | + if itemData["function"] == 0 or itemData["function"] == 2 then count = 1 end | ||
1042 | + | ||
1043 | + if itemId == 5020 then | ||
1044 | + self.owner:finishGuide(53) | ||
1045 | + end | ||
1046 | + | ||
1047 | + self:checkAchievement(self.AchievType.UseItem, count, itemId) | ||
1048 | + self:mylog({desc = "useItem", int1 = itemId, int2 = count}) | ||
1049 | + | ||
1050 | + self.owner:log("mission_pick_use", { | ||
1051 | + mission_threadid = self.chapterId, -- 大地图ID | ||
1052 | + mission_threadname = (csvdb["adv_chapterCsv"][self.chapterId] or {})["chapter"] or "auto", -- 大地图名称 | ||
1053 | + mission_id = self.level, -- 关卡ID | ||
1054 | + item_id = itemId, -- 道具ID | ||
1055 | + mission_pick_use_num = count, -- 道具使用量 | ||
1056 | + mission_sequenceid = self.logid, -- 本次拾荒ID,用于关联一次拾荒产生多条不同类型的日志 | ||
1057 | + }) | ||
1058 | + | ||
1059 | + for i = 1, count do | ||
1060 | + self:doActive(itemData.effect, target) -- target | ||
1061 | + end | ||
1062 | +end | ||
1063 | + | ||
1008 | -- 消耗物品 优先冒险背包 --check 只是检查够不够 | 1064 | -- 消耗物品 优先冒险背包 --check 只是检查够不够 |
1009 | function Adv:cost(item, params, check) | 1065 | function Adv:cost(item, params, check) |
1010 | local items = self.owner:getProperty("advItems") | 1066 | local items = self.owner:getProperty("advItems") |
@@ -1040,8 +1096,10 @@ local function clickOut(self, room, block, params, isExit) | @@ -1040,8 +1096,10 @@ local function clickOut(self, room, block, params, isExit) | ||
1040 | end | 1096 | end |
1041 | 1097 | ||
1042 | if #self.mapStack > 1 then -- 处于夹层中 | 1098 | if #self.mapStack > 1 then -- 处于夹层中 |
1043 | - table.remove(self.mapStack) --退出夹层 | ||
1044 | self:backLayer(-1) | 1099 | self:backLayer(-1) |
1100 | + local oldMapIdx = self:getCurMapIdx() | ||
1101 | + table.remove(self.mapStack) --退出夹层 | ||
1102 | + self.battle:iLayerChange(oldMapIdx) | ||
1045 | else --处于底层 | 1103 | else --处于底层 |
1046 | 1104 | ||
1047 | local advPass = self.owner:getProperty("advPass") | 1105 | local advPass = self.owner:getProperty("advPass") |
@@ -1071,11 +1129,10 @@ local function clickOut(self, room, block, params, isExit) | @@ -1071,11 +1129,10 @@ local function clickOut(self, room, block, params, isExit) | ||
1071 | self.battle.player:triggerPassive(Passive.DOWN_LAYER) | 1129 | self.battle.player:triggerPassive(Passive.DOWN_LAYER) |
1072 | 1130 | ||
1073 | if curFloorData then | 1131 | if curFloorData then |
1074 | - self:backReward(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}}, {}) |
1075 | end | 1133 | end |
1134 | + self:backNext() --下一关 | ||
1076 | local isHaveRelay = self:isHaveRelay(self.level) | 1135 | local isHaveRelay = self:isHaveRelay(self.level) |
1077 | - | ||
1078 | - self.owner:getProperty("advTeam").player = self.battle.player:getDB() -- 临时缓存住 battle 的player | ||
1079 | if isHaveRelay and not self.isRelay then | 1136 | if isHaveRelay and not self.isRelay then |
1080 | self:initByChapter({ | 1137 | self:initByChapter({ |
1081 | chapterId = self.chapterId, | 1138 | chapterId = self.chapterId, |
@@ -1093,7 +1150,6 @@ local function clickOut(self, room, block, params, isExit) | @@ -1093,7 +1150,6 @@ local function clickOut(self, room, block, params, isExit) | ||
1093 | notNotify = true, | 1150 | notNotify = true, |
1094 | }) | 1151 | }) |
1095 | end | 1152 | end |
1096 | - self:backNext() --下一关 | ||
1097 | end | 1153 | end |
1098 | 1154 | ||
1099 | end | 1155 | end |
@@ -1255,7 +1311,7 @@ local function chooseCommon(self, room, block, chooseData, choose, tag) | @@ -1255,7 +1311,7 @@ local function chooseCommon(self, room, block, chooseData, choose, tag) | ||
1255 | skynet.error(string.format("[ERROR]: event_dropCsv no id %s in %s id: %s", effect[2], tag, chooseData.id)) | 1311 | skynet.error(string.format("[ERROR]: event_dropCsv no id %s in %s id: %s", effect[2], tag, chooseData.id)) |
1256 | end | 1312 | end |
1257 | end | 1313 | end |
1258 | - self:backReward(self:award(reward, {log = {desc = "chooseEvent", key1 = tag, int1 = chooseData.id}}), {roomId = room.roomId, blockId = block.blockId}) | 1314 | + self:award(reward, {log = {desc = "chooseEvent", key1 = tag, int1 = chooseData.id}}, {roomId = room.roomId, blockId = block.blockId}) |
1259 | end, | 1315 | end, |
1260 | [2] = function() --获得冒险buff | 1316 | [2] = function() --获得冒险buff |
1261 | local layer = effect[3] or 1 | 1317 | local layer = effect[3] or 1 |
@@ -1333,19 +1389,31 @@ local function chooseCommon(self, room, block, chooseData, choose, tag) | @@ -1333,19 +1389,31 @@ local function chooseCommon(self, room, block, chooseData, choose, tag) | ||
1333 | [14] = function() -- 指定地块召唤 指定类型的id | 1389 | [14] = function() -- 指定地块召唤 指定类型的id |
1334 | 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]) |
1335 | for _, one in ipairs(change) do | 1391 | for _, one in ipairs(change) do |
1336 | - 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 | ||
1337 | end | 1397 | end |
1338 | end, | 1398 | end, |
1339 | [15] = function() -- 移除指定事件 | 1399 | [15] = function() -- 移除指定事件 |
1340 | local change = self:getCurMap():clearEventById(effect[2], effect[3], effect[4]) | 1400 | local change = self:getCurMap():clearEventById(effect[2], effect[3], effect[4]) |
1341 | for _, one in ipairs(change) do | 1401 | for _, one in ipairs(change) do |
1342 | - 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 | ||
1343 | end | 1407 | end |
1344 | end, | 1408 | end, |
1345 | [16] = function() -- 指定事件转移 | 1409 | [16] = function() -- 指定事件转移 |
1346 | 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]) |
1347 | for _, one in ipairs(change) do | 1411 | for _, one in ipairs(change) do |
1348 | - 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 | ||
1349 | end | 1417 | end |
1350 | end, | 1418 | end, |
1351 | } | 1419 | } |
@@ -1419,14 +1487,12 @@ local function clickDrop(self, room, block, params) | @@ -1419,14 +1487,12 @@ local function clickDrop(self, room, block, params) | ||
1419 | if not self.battle or not self.battle.player then return end | 1487 | if not self.battle or not self.battle.player then return end |
1420 | self.battle.player:triggerPassive(Passive.CLICK_DROP) | 1488 | self.battle.player:triggerPassive(Passive.CLICK_DROP) |
1421 | 1489 | ||
1422 | - local reward = self:award({[block.event.item[1]] = block.event.item[2]}, {log = {desc = "clickDrop"}}) | ||
1423 | - -- local reward = self:award({[5801] = 1}) | ||
1424 | - -- 获取绷带的引导 | 1490 | + local reward = self:award({[block.event.item[1]] = block.event.item[2]}, {log = {desc = "clickDrop"}}, {roomId = room.roomId, blockId = block.blockId}) |
1491 | + | ||
1425 | if block.event.item[1] == 5020 and not self.owner:checkOverGuide(53,2) then | 1492 | if block.event.item[1] == 5020 and not self.owner:checkOverGuide(53,2) then |
1426 | self.owner:saveGuide(53,2) | 1493 | self.owner:saveGuide(53,2) |
1427 | end | 1494 | end |
1428 | block:clear() | 1495 | block:clear() |
1429 | - self:backReward(reward, {roomId = room.roomId, blockId = block.blockId}) | ||
1430 | return true | 1496 | return true |
1431 | end | 1497 | end |
1432 | 1498 | ||
@@ -1447,7 +1513,7 @@ local function clickTrader(self, room, block, params) | @@ -1447,7 +1513,7 @@ local function clickTrader(self, room, block, params) | ||
1447 | local costCount = math.ceil(goodsData.price * (block.event.shop[buyId][2] or 100) / 100) | 1513 | local costCount = math.ceil(goodsData.price * (block.event.shop[buyId][2] or 100) / 100) |
1448 | if not self:cost({[goodsData.currency] = costCount}, {log = {desc = "clickTrader", int1 = block.event.id}}) then return false, 6 end --不够 | 1514 | if not self:cost({[goodsData.currency] = costCount}, {log = {desc = "clickTrader", int1 = block.event.id}}) then return false, 6 end --不够 |
1449 | self:backCost({[goodsData.currency] = costCount}) | 1515 | self:backCost({[goodsData.currency] = costCount}) |
1450 | - local reward = self:award({[goodsData.item] = goodsData.num}, {log = {desc = "clickTrader", int1 = block.event.id}}) | 1516 | + self:award({[goodsData.item] = goodsData.num}, {log = {desc = "clickTrader", int1 = block.event.id}}, {}) |
1451 | if goodsData.restrict == 1 then | 1517 | if goodsData.restrict == 1 then |
1452 | self.shopStatus[goodsData.goods] = (self.shopStatus[goodsData.goods] or 0) + 1 | 1518 | self.shopStatus[goodsData.goods] = (self.shopStatus[goodsData.goods] or 0) + 1 |
1453 | elseif goodsData.restrict == 2 then | 1519 | elseif goodsData.restrict == 2 then |
@@ -1459,7 +1525,6 @@ local function clickTrader(self, room, block, params) | @@ -1459,7 +1525,6 @@ local function clickTrader(self, room, block, params) | ||
1459 | buyCount = buyCount + 1 | 1525 | buyCount = buyCount + 1 |
1460 | self:checkTask(Adv.TaskType.Shop, 1, block.event.id) | 1526 | self:checkTask(Adv.TaskType.Shop, 1, block.event.id) |
1461 | self:checkAchievement(Adv.AchievType.Shop, 1, block.event.id) | 1527 | self:checkAchievement(Adv.AchievType.Shop, 1, block.event.id) |
1462 | - self:backReward(reward) | ||
1463 | 1528 | ||
1464 | if (traderData.purchasetime ~= 0 and traderData.purchasetime <= buyCount) or #block.event.shop <= buyCount then | 1529 | if (traderData.purchasetime ~= 0 and traderData.purchasetime <= buyCount) or #block.event.shop <= buyCount then |
1465 | block:clear() | 1530 | block:clear() |
@@ -1474,6 +1539,25 @@ local function clickBuild(self, room, block, params) | @@ -1474,6 +1539,25 @@ local function clickBuild(self, room, block, params) | ||
1474 | local status, clearBlock = chooseCommon(self, room, block, chooseData, choose, "build") | 1539 | local status, clearBlock = chooseCommon(self, room, block, chooseData, choose, "build") |
1475 | if not status then return end | 1540 | if not status then return end |
1476 | 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 | + | ||
1477 | self:checkTask(Adv.TaskType.Build, 1, oldId) | 1561 | self:checkTask(Adv.TaskType.Build, 1, oldId) |
1478 | self:checkAchievement(Adv.AchievType.Build, 1, oldId) | 1562 | self:checkAchievement(Adv.AchievType.Build, 1, oldId) |
1479 | self:checkAchievement(Adv.AchievType.BuildBySelect, 1, oldId, choose) | 1563 | self:checkAchievement(Adv.AchievType.BuildBySelect, 1, oldId, choose) |
@@ -1501,7 +1585,7 @@ local function clickClick(self, room, block, params) | @@ -1501,7 +1585,7 @@ local function clickClick(self, room, block, params) | ||
1501 | local item = csvdb["event_dropCsv"][dropId]["range"]:randWeight(true) | 1585 | local item = csvdb["event_dropCsv"][dropId]["range"]:randWeight(true) |
1502 | reward[item[1]] = (reward[item[1]] or 0) + item[2] | 1586 | reward[item[1]] = (reward[item[1]] or 0) + item[2] |
1503 | end | 1587 | end |
1504 | - self:backReward(self:award(reward, {log = {desc = "clickClick", int1 = block.event.id}}), {roomId = room.roomId, blockId = block.blockId}) | 1588 | + self:award(reward, {log = {desc = "clickClick", int1 = block.event.id}}, {roomId = room.roomId, blockId = block.blockId}) |
1505 | end, | 1589 | end, |
1506 | [3] = function() | 1590 | [3] = function() |
1507 | for _, buffId in ipairs(clickData.effect:toArray(true, "=")) do | 1591 | for _, buffId in ipairs(clickData.effect:toArray(true, "=")) do |
@@ -1521,6 +1605,8 @@ local function clickClick(self, room, block, params) | @@ -1521,6 +1605,8 @@ local function clickClick(self, room, block, params) | ||
1521 | end | 1605 | end |
1522 | 1606 | ||
1523 | local function clickLayer(self, room, block, params) | 1607 | local function clickLayer(self, room, block, params) |
1608 | + local oldMapIdx = self:getCurMapIdx() | ||
1609 | + self:backLayer(1) | ||
1524 | if block.event.mapIdx then | 1610 | if block.event.mapIdx then |
1525 | table.insert(self.mapStack, block.event.mapIdx) --进入夹层 | 1611 | table.insert(self.mapStack, block.event.mapIdx) --进入夹层 |
1526 | else | 1612 | else |
@@ -1536,7 +1622,7 @@ local function clickLayer(self, room, block, params) | @@ -1536,7 +1622,7 @@ local function clickLayer(self, room, block, params) | ||
1536 | self.maps[mapIdx]:initBattleAfter() | 1622 | self.maps[mapIdx]:initBattleAfter() |
1537 | self:checkAchievement(Adv.AchievType.EnterILayer, 1, mapId) | 1623 | self:checkAchievement(Adv.AchievType.EnterILayer, 1, mapId) |
1538 | end | 1624 | end |
1539 | - self:backLayer(1) | 1625 | + self.battle:iLayerChange(oldMapIdx) |
1540 | return true | 1626 | return true |
1541 | end | 1627 | end |
1542 | 1628 | ||
@@ -1842,23 +1928,31 @@ end | @@ -1842,23 +1928,31 @@ end | ||
1842 | 1928 | ||
1843 | -- 地图上物品变化 | 1929 | -- 地图上物品变化 |
1844 | function Adv:mapItemChange(ctype) | 1930 | function Adv:mapItemChange(ctype) |
1931 | + local blocks = {} | ||
1932 | + for roomId, room in pairs(self:getCurMap().rooms) do | ||
1933 | + for blockId, block in pairs(room.blocks) do | ||
1934 | + table.insert(blocks, block) | ||
1935 | + end | ||
1936 | + end | ||
1937 | + self:blockDropChange(ctype, blocks) | ||
1938 | +end | ||
1939 | + | ||
1940 | +function Adv:blockDropChange(ctype, blocks) | ||
1845 | local clist = csvdb["transform_itemCsv"][ctype] | 1941 | local clist = csvdb["transform_itemCsv"][ctype] |
1846 | if clist then | 1942 | if clist then |
1847 | - for roomId, room in pairs(self:getCurMap().rooms) do | ||
1848 | - for blockId, block in pairs(room.blocks) do | ||
1849 | - if block:getEventType() == AdvEventType.Drop and block.event.item then | ||
1850 | - local id = block.event.item[1] | ||
1851 | - local count = block.event.item[2] | ||
1852 | - local changeTo = nil | ||
1853 | - if clist[id] then | ||
1854 | - changeTo = {clist[id].toId, math.ceil(count * clist[id].num)} | ||
1855 | - elseif clist[-1] then | ||
1856 | - changeTo = {clist[-1].toId, math.ceil(count * clist[-1].num)} | ||
1857 | - end | ||
1858 | - if changeTo and changeTo[1] ~= 0 and changeTo[2] ~= 0 then | ||
1859 | - block.event.item = changeTo | ||
1860 | - self:backBlockChange(roomId, blockId, ctype) | ||
1861 | - end | 1943 | + for _, block in ipairs(blocks) do |
1944 | + if block:getEventType() == AdvEventType.Drop and block.event.item then | ||
1945 | + local id = block.event.item[1] | ||
1946 | + local count = block.event.item[2] | ||
1947 | + local changeTo = nil | ||
1948 | + if clist[id] then | ||
1949 | + changeTo = {clist[id].toId, math.ceil(count * clist[id].num)} | ||
1950 | + elseif clist[-1] then | ||
1951 | + changeTo = {clist[-1].toId, math.ceil(count * clist[-1].num)} | ||
1952 | + end | ||
1953 | + if changeTo and changeTo[1] ~= 0 and changeTo[2] ~= 0 then | ||
1954 | + block.event.item = changeTo | ||
1955 | + self:backBlockChange(block.room.roomId, block.blockId, ctype) | ||
1862 | end | 1956 | end |
1863 | end | 1957 | end |
1864 | end | 1958 | end |
@@ -1887,76 +1981,148 @@ function Adv:enemyDead(enemy, escape) | @@ -1887,76 +1981,148 @@ function Adv:enemyDead(enemy, escape) | ||
1887 | else | 1981 | else |
1888 | self:scoreChange(AdvScoreType.Kill, monsterData.advScore) | 1982 | self:scoreChange(AdvScoreType.Kill, monsterData.advScore) |
1889 | end | 1983 | end |
1890 | - local changeV = self.battle.player:addExp(monsterData.exp) | ||
1891 | - self:backDead(enemyId, changeV) | ||
1892 | - | ||
1893 | - local toClick = enemy:hadBuff(Buff.CHANGE_DROP_TO_CLICK) | ||
1894 | - if toClick then | ||
1895 | - toClick = toClick:effect() | 1984 | + -- local changeV = self.battle.player:addExp(monsterData.exp) |
1985 | + -- self:backDead(enemyId, changeV) | ||
1986 | + self:backDead(enemyId) | ||
1987 | + | ||
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 | ||
1896 | end | 1994 | end |
1897 | 1995 | ||
1898 | - local changItem = enemy:hadBuff(Buff.CHANGE_DROP) | ||
1899 | - if changItem then | ||
1900 | - changItem = table.pack(changItem:effect()) | ||
1901 | - 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 | ||
1902 | 2006 | ||
1903 | - local addMult = 0 | ||
1904 | - local dropBuff = enemy:hadBuff(Buff.DROP_BUFF_BY_ENEMY) -- 根据敌人数量变化个数 | ||
1905 | - if dropBuff then | ||
1906 | - local team = enemy:getTeam(1, true) | ||
1907 | - addMult = addMult + 0.2 * #team | ||
1908 | - 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 | ||
1909 | 2031 | ||
1910 | - local dropIds = monsterData.dropid:toArray(true, "=") | ||
1911 | - local drops = {} | ||
1912 | - local cCcount = 0 -- 需要改变为click 的个数 | ||
1913 | - for _, dropId in ipairs(dropIds) do | ||
1914 | - local dropData = csvdb["event_dropCsv"][dropId] | ||
1915 | - if dropData then | ||
1916 | - local cur = dropData["range"]:randWeight(true) | ||
1917 | - if cur and cur[1] ~= 0 then | ||
1918 | - if toClick then | ||
1919 | - cCcount = cCcount + 1 | ||
1920 | - else | ||
1921 | - local item = changItem and changItem or cur | ||
1922 | - item[2] = math.floor(item[2] * (1 + addMult)) | ||
1923 | - 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 | ||
1924 | end | 2039 | end |
1925 | end | 2040 | end |
1926 | end | 2041 | end |
1927 | - end | ||
1928 | - -- 这些奖励可能会有被动加成 | ||
1929 | - 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 | ||
1930 | 2062 | ||
1931 | - -- 自身带的掉落是不会被改变的 也不会被加成 | ||
1932 | - if block.event.item and block.event.item[1] ~= 0 then | ||
1933 | - table.insert(drops, 1, block.event.item) | ||
1934 | - end | 2063 | + local changItem = enemy:hadBuff(Buff.CHANGE_DROP) |
2064 | + if changItem then | ||
2065 | + changItem = table.pack(changItem:effect()) | ||
2066 | + end | ||
1935 | 2067 | ||
1936 | - -- 清空当前的格子 | ||
1937 | - 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 | ||
1938 | 2074 | ||
1939 | - -- 掉落走一波 | ||
1940 | - local blocks = self:getCurMap():getEmptyBlocks(roomId, blockId, #drops) | ||
1941 | - for _i, cblock in ipairs(blocks) do | ||
1942 | - cblock:updateEvent({ | ||
1943 | - etype = AdvEventType.Drop, | ||
1944 | - item = drops[_i] | ||
1945 | - }) | ||
1946 | - if cblock ~= block then | ||
1947 | - 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 | ||
1948 | end | 2092 | end |
1949 | - end | 2093 | + -- 这些奖励可能会有被动加成 |
2094 | + self.battle.player:triggerPassive(Passive.BATTLE_WIN, {drops = drops}) | ||
1950 | 2095 | ||
1951 | - -- 转换的click走一波 | ||
1952 | - local blocks = self:getCurMap():getEmptyBlocks(roomId, blockId, cCcount) | ||
1953 | - for _i, cblock in ipairs(blocks) do | ||
1954 | - cblock:updateEvent({ | ||
1955 | - etype = AdvEventType.Click, | ||
1956 | - id = clickId | ||
1957 | - }) | ||
1958 | - if cblock ~= block then | ||
1959 | - 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 | ||
1960 | end | 2126 | end |
1961 | end | 2127 | end |
1962 | 2128 | ||
@@ -1989,10 +2155,13 @@ end | @@ -1989,10 +2155,13 @@ end | ||
1989 | function Adv:pushBackEvent(btype, params) | 2155 | function Adv:pushBackEvent(btype, params) |
1990 | table.insert(self.backEvents, {btype = btype, params = params}) | 2156 | table.insert(self.backEvents, {btype = btype, params = params}) |
1991 | end | 2157 | end |
1992 | - | 2158 | +--[=[ |
2159 | +tag | ||
2160 | +1 自动拾取 | ||
2161 | +--]=] | ||
1993 | function Adv:backReward(items, params) | 2162 | function Adv:backReward(items, params) |
1994 | params = params or {} | 2163 | params = params or {} |
1995 | - self:pushBackEvent(AdvBackEventType.Reward, {items = items, roomId = params.roomId, blockId = params.blockId}) | 2164 | + self:pushBackEvent(AdvBackEventType.Reward, {items = items, roomId = params.roomId, blockId = params.blockId, tag = params.tag}) |
1996 | end | 2165 | end |
1997 | 2166 | ||
1998 | -- if is player enemyId is nil | 2167 | -- if is player enemyId is nil |
@@ -2009,8 +2178,8 @@ function Adv:backBlockChange(roomId, blockId, itemChangeType) | @@ -2009,8 +2178,8 @@ function Adv:backBlockChange(roomId, blockId, itemChangeType) | ||
2009 | self:pushBackEvent(AdvBackEventType.BlockChange, {roomId = roomId, blockId = blockId, itemChangeType = itemChangeType}) | 2178 | self:pushBackEvent(AdvBackEventType.BlockChange, {roomId = roomId, blockId = blockId, itemChangeType = itemChangeType}) |
2010 | end | 2179 | end |
2011 | 2180 | ||
2012 | -function Adv:backDead(enemyId, exp) | ||
2013 | - self:pushBackEvent(AdvBackEventType.Dead, {enemyId = enemyId, exp = exp}) | 2181 | +function Adv:backDead(enemyId) |
2182 | + self:pushBackEvent(AdvBackEventType.Dead, {enemyId = enemyId}) | ||
2014 | end | 2183 | end |
2015 | 2184 | ||
2016 | function Adv:backTrap() | 2185 | function Adv:backTrap() |
@@ -2033,8 +2202,12 @@ function Adv:backCost(items) | @@ -2033,8 +2202,12 @@ function Adv:backCost(items) | ||
2033 | self:pushBackEvent(AdvBackEventType.Cost, {items = items}) | 2202 | self:pushBackEvent(AdvBackEventType.Cost, {items = items}) |
2034 | end | 2203 | end |
2035 | 2204 | ||
2036 | -function Adv:backUse(items) | ||
2037 | - self:pushBackEvent(AdvBackEventType.Use, {items = items}) | 2205 | +--[=[ |
2206 | +tag | ||
2207 | +1 自动使用 | ||
2208 | +--]=] | ||
2209 | +function Adv:backUse(items, tag) | ||
2210 | + self:pushBackEvent(AdvBackEventType.Use, {items = items, tag = tag}) | ||
2038 | end | 2211 | end |
2039 | 2212 | ||
2040 | 2213 | ||
@@ -2044,21 +2217,11 @@ function Adv:scoreChange(scoreType, score) | @@ -2044,21 +2217,11 @@ function Adv:scoreChange(scoreType, score) | ||
2044 | end | 2217 | end |
2045 | 2218 | ||
2046 | function Adv:getScore() | 2219 | function Adv:getScore() |
2047 | - self.score[AdvScoreType.Level] = math.floor(self.score[AdvScoreType.Level] or 0) | ||
2048 | - self.score[AdvScoreType.Task] = math.floor(self.score[AdvScoreType.Task] or 0) | ||
2049 | - self.score[AdvScoreType.Kill] = math.floor(self.score[AdvScoreType.Kill] or 0) | ||
2050 | - self.score[AdvScoreType.KillBoss] = math.floor(self.score[AdvScoreType.KillBoss] or 0) | ||
2051 | - self.score[AdvScoreType.ItemBack] = math.floor(self.score[AdvScoreType.ItemBack] or 0) | ||
2052 | - self.score[AdvScoreType.Event] = math.floor(self.score[AdvScoreType.Event] or 0) | ||
2053 | - self.score[AdvScoreType.Story] = math.floor(self.score[AdvScoreType.Story] or 0) | ||
2054 | - | ||
2055 | - return self.score[AdvScoreType.Level] | ||
2056 | - + self.score[AdvScoreType.Task] | ||
2057 | - + self.score[AdvScoreType.Kill] | ||
2058 | - + self.score[AdvScoreType.KillBoss] | ||
2059 | - + self.score[AdvScoreType.ItemBack] | ||
2060 | - + self.score[AdvScoreType.Event] | ||
2061 | - + self.score[AdvScoreType.Story] | 2220 | + local allScore = 0 |
2221 | + for _, score in pairs(self.score) do | ||
2222 | + allScore = allScore + math.floor(score) | ||
2223 | + end | ||
2224 | + return allScore | ||
2062 | end | 2225 | end |
2063 | 2226 | ||
2064 | function Adv:popBackEvents() | 2227 | function Adv:popBackEvents() |
src/adv/AdvBattle.lua
@@ -8,6 +8,7 @@ function Battle:ctor(adv) | @@ -8,6 +8,7 @@ function Battle:ctor(adv) | ||
8 | self.isNewPlayer = false | 8 | self.isNewPlayer = false |
9 | self.enemys = {} --怪 | 9 | self.enemys = {} --怪 |
10 | self.builds = {} -- 建筑 | 10 | self.builds = {} -- 建筑 |
11 | + self.auras = {} -- 光环 | ||
11 | self.cachePassiveEvent = {} | 12 | self.cachePassiveEvent = {} |
12 | self:initPlayer() | 13 | self:initPlayer() |
13 | self:initEnemys() | 14 | self:initEnemys() |
@@ -67,17 +68,17 @@ function Battle:initPlayer() | @@ -67,17 +68,17 @@ function Battle:initPlayer() | ||
67 | local advAddAttrs = self.adv.owner:getAdvLvAddAttrs() | 68 | local advAddAttrs = self.adv.owner:getAdvLvAddAttrs() |
68 | 69 | ||
69 | player = {} | 70 | player = {} |
70 | - player.level = 1 | ||
71 | - if self.adv.level ~= 1 then | ||
72 | - local relayData = self.adv:isHaveRelay() | ||
73 | - if relayData then | ||
74 | - player.level = relayData.level | ||
75 | - end | ||
76 | - end | ||
77 | - player.exp = 0 | 71 | + -- player.level = 1 |
72 | + -- if self.adv.level ~= 1 then | ||
73 | + -- local relayData = self.adv:isHaveRelay() | ||
74 | + -- if relayData then | ||
75 | + -- player.level = relayData.level | ||
76 | + -- end | ||
77 | + -- end | ||
78 | + -- player.exp = 0 | ||
78 | player.sp = getAdvLvAttrUp(advAddAttrs, "sp", 100) | 79 | player.sp = getAdvLvAttrUp(advAddAttrs, "sp", 100) |
79 | player.spMax = player.sp | 80 | player.spMax = player.sp |
80 | - player.growth = {} | 81 | + -- player.growth = {} |
81 | player.passives = {} | 82 | player.passives = {} |
82 | 83 | ||
83 | for slot, heroId in pairs(advTeam.heros) do | 84 | for slot, heroId in pairs(advTeam.heros) do |
@@ -100,8 +101,8 @@ function Battle:initPlayer() | @@ -100,8 +101,8 @@ function Battle:initPlayer() | ||
100 | player[attrName] = (player[attrName] or 0) + hero[attrName] | 101 | player[attrName] = (player[attrName] or 0) + hero[attrName] |
101 | end | 102 | end |
102 | player[attrName] = getAdvLvAttrUp(advAddAttrs, attrName, player[attrName]) * (globalCsv.adv_battle_attr_ratio[attrName] or 1) | 103 | player[attrName] = getAdvLvAttrUp(advAddAttrs, attrName, player[attrName]) * (globalCsv.adv_battle_attr_ratio[attrName] or 1) |
103 | - player.growth[attrName] = player[attrName] * (globalCsv.adv_battle_attr_growth_ratio[attrName] or 1) | ||
104 | - player[attrName] = player[attrName] + player.growth[attrName] * (player.level - 1) | 104 | + -- player.growth[attrName] = player[attrName] * (globalCsv.adv_battle_attr_growth_ratio[attrName] or 1) |
105 | + -- player[attrName] = player[attrName] + player.growth[attrName] * (player.level - 1) | ||
105 | end | 106 | end |
106 | 107 | ||
107 | player.hpMax = player.hp or 0 | 108 | player.hpMax = player.hp or 0 |
@@ -198,8 +199,10 @@ function Battle:addEnemy(room, block, mapIdx, init) | @@ -198,8 +199,10 @@ function Battle:addEnemy(room, block, mapIdx, init) | ||
198 | end | 199 | end |
199 | 200 | ||
200 | for _, buff in ipairs(buffs) do | 201 | for _, buff in ipairs(buffs) do |
201 | - enemy:addBuff(buff) | 202 | + player:addBuff(buff) |
202 | end | 203 | end |
204 | + -- 新生成的怪 加上 已有的光环buff | ||
205 | + player:checkAuraBuff(self:checkDiffAuraBuff({}, self:getAurasByMap())) | ||
203 | end | 206 | end |
204 | end | 207 | end |
205 | return player | 208 | return player |
@@ -313,8 +316,19 @@ function Battle:afterRound() | @@ -313,8 +316,19 @@ function Battle:afterRound() | ||
313 | build:afterRound("buffAfter") | 316 | build:afterRound("buffAfter") |
314 | end | 317 | end |
315 | 318 | ||
319 | + self.player:triggerPassive(Passive.AFTER_ROUND) | ||
320 | + | ||
321 | + self:checkAura() | ||
316 | 322 | ||
323 | + self:clearRound() | ||
324 | + | ||
325 | + if self.player.isDead then | ||
326 | + self.adv:over(false, nil, -2) | ||
327 | + end | ||
328 | +end | ||
317 | 329 | ||
330 | +function Battle:clearRound() | ||
331 | + local mapIdx = self.adv:getCurMapIdx() | ||
318 | self.player:clearRound() | 332 | self.player:clearRound() |
319 | for _, enemy in ipairs(self.enemys[mapIdx]) do | 333 | for _, enemy in ipairs(self.enemys[mapIdx]) do |
320 | enemy:clearRound() | 334 | enemy:clearRound() |
@@ -344,12 +358,6 @@ function Battle:afterRound() | @@ -344,12 +358,6 @@ function Battle:afterRound() | ||
344 | build:clear() | 358 | build:clear() |
345 | end | 359 | end |
346 | end | 360 | end |
347 | - | ||
348 | - self.player:triggerPassive(Passive.AFTER_ROUND) | ||
349 | - | ||
350 | - if self.player.isDead then | ||
351 | - self.adv:over(false, nil, -2) | ||
352 | - end | ||
353 | end | 361 | end |
354 | 362 | ||
355 | 363 | ||
@@ -358,18 +366,32 @@ function Battle:battleBegin(roomId, blockId, params) | @@ -358,18 +366,32 @@ function Battle:battleBegin(roomId, blockId, params) | ||
358 | if not enemy then return end | 366 | if not enemy then return end |
359 | local player = params.player | 367 | local player = params.player |
360 | 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 | ||
361 | -- 玩家没死就是怪死了 | 386 | -- 玩家没死就是怪死了 |
362 | if player.hp > 0 then | 387 | if player.hp > 0 then |
363 | - enemy:kill() | ||
364 | self.player:effectBattleBuff() | 388 | self.player:effectBattleBuff() |
365 | - | ||
366 | - self.adv.owner:checkTaskEnter("AdvBattleWin", {id = self.adv.chapterId}) | ||
367 | if params.bySkill then | 389 | if params.bySkill then |
368 | self.player:triggerPassive(Passive.SKILL_KILL) | 390 | self.player:triggerPassive(Passive.SKILL_KILL) |
369 | end | 391 | end |
370 | end | 392 | end |
371 | if player.hp > self.player.hp then | 393 | if player.hp > self.player.hp then |
372 | - self.player:recover(player.hp - self.player.hp, player) | 394 | + self.player:recover(player.hp - self.player.hp) |
373 | else | 395 | else |
374 | 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}) --战斗血量只会变少 |
375 | end | 397 | end |
@@ -424,7 +446,7 @@ function Battle:initMapEffect(ilayer) | @@ -424,7 +446,7 @@ function Battle:initMapEffect(ilayer) | ||
424 | end | 446 | end |
425 | 447 | ||
426 | for _, buff in ipairs(buffs[1] or {}) do | 448 | for _, buff in ipairs(buffs[1] or {}) do |
427 | - self.palyer:addBuff(buff) | 449 | + self.player:addBuff(buff) |
428 | end | 450 | end |
429 | 451 | ||
430 | for _, buff in ipairs(buffs[2] or {}) do | 452 | for _, buff in ipairs(buffs[2] or {}) do |
@@ -435,8 +457,126 @@ function Battle:initMapEffect(ilayer) | @@ -435,8 +457,126 @@ function Battle:initMapEffect(ilayer) | ||
435 | end | 457 | end |
436 | 458 | ||
437 | 459 | ||
460 | +-- 夹层 进入退出 接口 清理玩家身上的老光环 添加新的光环 | ||
461 | +function Battle:iLayerChange(oldMapIdx) | ||
462 | + local auras = self:getActiveAuras() | ||
463 | + local playerBuffs = self:checkDiffAuraBuff(self:getAurasByMap(oldMapIdx), auras) | ||
464 | + local enemyBuffs = self:checkDiffAuraBuff(self:getAurasByMap(), auras) | ||
465 | + self.player:checkAuraBuff(playerBuffs) | ||
466 | + for _, enemy in ipairs(self.enemys[self.adv:getCurMapIdx()]) do | ||
467 | + enemy:checkAuraBuff(enemyBuffs) | ||
468 | + end | ||
469 | + self:setMapAuras(auras) | ||
470 | + self:clearRound() | ||
471 | +end | ||
472 | + | ||
473 | +-- 新的 关卡 关闭旧的战斗模块 清理 玩家身上的光环效果 | ||
474 | +function Battle:overBattle() | ||
475 | + local buffs = self:checkDiffAuraBuff(self:getAurasByMap(), {}) | ||
476 | + self.player:checkAuraBuff(buffs) | ||
477 | + self:clearRound() | ||
478 | + self.adv.owner:getProperty("advTeam").player = self.player:getDB() -- 临时缓存住 battle 的player | ||
479 | +end | ||
480 | + | ||
481 | +-- 初始化 新的 关卡 | ||
482 | +function Battle:newBattle() | ||
483 | + local auras = self:getActiveAuras() | ||
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 | ||
489 | + self:setMapAuras(auras) | ||
490 | +end | ||
491 | + | ||
492 | +function Battle:loadBattle(info) | ||
493 | + self.auras = info.auras or {} | ||
494 | +end | ||
495 | + | ||
496 | +-- 过了回合 检查光环 | ||
497 | +function Battle:checkAura() | ||
498 | + local auras = self:getActiveAuras() | ||
499 | + local buffs = self:checkDiffAuraBuff(self:getAurasByMap(), auras) | ||
500 | + self.player:checkAuraBuff(buffs) | ||
501 | + for _, enemy in pairs(self.player:getTeam(2)) do | ||
502 | + enemy:checkAuraBuff(buffs) | ||
503 | + end | ||
504 | + self:setMapAuras(auras) | ||
505 | +end | ||
506 | + | ||
507 | +-- 查找差异buff | ||
508 | +function Battle:checkDiffAuraBuff(oldAuras, newAuras) | ||
509 | + local auras = {} | ||
510 | + for aurasId , count in pairs(oldAuras) do | ||
511 | + auras[aurasId] = -count | ||
512 | + end | ||
513 | + for aurasId , count in pairs(newAuras) do | ||
514 | + auras[aurasId] = (auras[aurasId] or 0) + count | ||
515 | + end | ||
516 | + | ||
517 | + local buffs = {} | ||
518 | + for aurasId , count in pairs(auras) do | ||
519 | + local auraData = csvdb["adv_map_haloCsv"][aurasId] | ||
520 | + if auraData then | ||
521 | + for _, effect in ipairs(auraData.effect:toTableArray(true)) do | ||
522 | + temp = buffs | ||
523 | + for i = 1, #effect do | ||
524 | + temp[effect[i]] = temp[effect[i]] or {} | ||
525 | + temp = temp[effect[i]] | ||
526 | + end | ||
527 | + temp.count = (temp.count or 0) + count | ||
528 | + if newAuras[aurasId] then | ||
529 | + -- 加上 未消失标记 | ||
530 | + temp.exist = true | ||
531 | + end | ||
532 | + end | ||
533 | + end | ||
534 | + end | ||
535 | + return buffs | ||
536 | +end | ||
537 | + | ||
538 | +-- 获取所有生效的 光环 | ||
539 | +function Battle:getActiveAuras() | ||
540 | + local auras = {} | ||
541 | + for _, one in pairs(self.player:getAuras()) do | ||
542 | + auras[one] = (auras[one] or 0) + 1 | ||
543 | + end | ||
544 | + for _, enemy in pairs(self.player:getTeam(2)) do | ||
545 | + for _, one in pairs(enemy:getAuras()) do | ||
546 | + auras[one] = (auras[one] or 0) + 1 | ||
547 | + end | ||
548 | + end | ||
549 | + for _, build in pairs(self:getBuilds()) do | ||
550 | + for _, one in pairs(build:getAuras()) do | ||
551 | + auras[one] = (auras[one] or 0) + 1 | ||
552 | + end | ||
553 | + end | ||
554 | + return auras | ||
555 | +end | ||
556 | + | ||
557 | +function Battle:setMapAuras(auras) | ||
558 | + self.auras[self.adv:getCurMapIdx()] = auras | ||
559 | +end | ||
560 | + | ||
561 | +function Battle:getAurasByMap(mapIdx) | ||
562 | + mapIdx = mapIdx or self.adv:getCurMapIdx() | ||
563 | + local auras = self.auras[mapIdx] or {} | ||
564 | + return auras | ||
565 | +end | ||
566 | + | ||
567 | +function Battle:getBuilds() | ||
568 | + local team = {} | ||
569 | + for _, build in pairs(self.builds[self.adv:getCurMapIdx()]) do | ||
570 | + if not build.isDead and not build.lock then -- 已经翻开的 | ||
571 | + table.insert(team, build) | ||
572 | + end | ||
573 | + end | ||
574 | + return team | ||
575 | +end | ||
576 | + | ||
577 | + | ||
438 | --写入数据 | 578 | --写入数据 |
439 | -function Battle:saveDB() | 579 | +function Battle:saveDB(advInfo) |
440 | for idx, mapEnemys in pairs(self.enemys) do | 580 | for idx, mapEnemys in pairs(self.enemys) do |
441 | for _, enemy in ipairs(mapEnemys) do | 581 | for _, enemy in ipairs(mapEnemys) do |
442 | local block = self.adv:getBlock(enemy.roomId, enemy.blockId, idx) | 582 | local block = self.adv:getBlock(enemy.roomId, enemy.blockId, idx) |
@@ -453,6 +593,7 @@ function Battle:saveDB() | @@ -453,6 +593,7 @@ function Battle:saveDB() | ||
453 | end | 593 | end |
454 | end | 594 | end |
455 | end | 595 | end |
596 | + advInfo.auras = self.auras | ||
456 | end | 597 | end |
457 | 598 | ||
458 | return Battle | 599 | return Battle |
459 | \ No newline at end of file | 600 | \ No newline at end of file |
src/adv/AdvBlock.lua
@@ -48,6 +48,8 @@ function Block:updateEvent(event, isInit) | @@ -48,6 +48,8 @@ function Block:updateEvent(event, isInit) | ||
48 | end | 48 | end |
49 | end | 49 | end |
50 | end | 50 | end |
51 | + local oldet = self:getEventType() | ||
52 | + | ||
51 | self.event = event | 53 | self.event = event |
52 | if not isInit and self.event then | 54 | if not isInit and self.event then |
53 | -- 判断下类型是不是错的 | 55 | -- 判断下类型是不是错的 |
@@ -58,18 +60,49 @@ function Block:updateEvent(event, isInit) | @@ -58,18 +60,49 @@ function Block:updateEvent(event, isInit) | ||
58 | end | 60 | end |
59 | self:randomEvent() | 61 | self:randomEvent() |
60 | end | 62 | end |
63 | + self:quickDrop() | ||
64 | + | ||
65 | + if not isInit and self.isOpen then | ||
66 | + local newet = self:getEventType() | ||
67 | + if oldet ~= newet then | ||
68 | + local em = {} | ||
69 | + if oldet then | ||
70 | + em[oldet] =1 | ||
71 | + end | ||
72 | + if newet then | ||
73 | + em[newet] =1 | ||
74 | + end | ||
75 | + | ||
76 | + local player = self.room.map.adv.battle.player | ||
77 | + player:attrChangeCondBuffCheck(4, em) | ||
78 | + for _, monster in pairs(player:getTeam(2)) do | ||
79 | + monster:attrChangeCondBuffCheck(4, em) | ||
80 | + end | ||
81 | + end | ||
82 | + end | ||
61 | end | 83 | end |
62 | 84 | ||
63 | function Block:clear() | 85 | function Block:clear() |
64 | - if self:getEventType() == AdvEventType.Trap then | 86 | + local et = self:getEventType() |
87 | + if et == AdvEventType.Trap then | ||
65 | self.trapId = self.event.id | 88 | self.trapId = self.event.id |
66 | - elseif self:getEventType() == AdvEventType.Build then | 89 | + elseif et == AdvEventType.Build then |
67 | local build = self.room.map.adv.battle:getBuild(self.room.roomId, self.blockId, self.room.map.mapIdx) | 90 | local build = self.room.map.adv.battle:getBuild(self.room.roomId, self.blockId, self.room.map.mapIdx) |
68 | if build then | 91 | if build then |
69 | build.isDead = true | 92 | build.isDead = true |
70 | end | 93 | end |
71 | end | 94 | end |
72 | self.event = nil | 95 | self.event = nil |
96 | + | ||
97 | + | ||
98 | + if et then | ||
99 | + local em = {[et] = 1} | ||
100 | + local player = self.room.map.adv.battle.player | ||
101 | + player:attrChangeCondBuffCheck(4, em) | ||
102 | + for _, monster in pairs(player:getTeam(2)) do | ||
103 | + monster:attrChangeCondBuffCheck(4, em) | ||
104 | + end | ||
105 | + end | ||
73 | end | 106 | end |
74 | 107 | ||
75 | 108 | ||
@@ -90,8 +123,10 @@ function Block:randomEvent() | @@ -90,8 +123,10 @@ function Block:randomEvent() | ||
90 | enemy:triggerPassive(Passive.BORN_ONCE) | 123 | enemy:triggerPassive(Passive.BORN_ONCE) |
91 | 124 | ||
92 | adv.battle.player:triggerPassive(Passive.OPEN_MONSTER, {trigger = enemy}) | 125 | adv.battle.player:triggerPassive(Passive.OPEN_MONSTER, {trigger = enemy}) |
126 | + adv.battle.player:attrChangeCondBuffCheck(3, enemy:getClassify()) | ||
93 | for _, monster in pairs(adv.battle.player:getTeam(2)) do | 127 | for _, monster in pairs(adv.battle.player:getTeam(2)) do |
94 | - adv.battle.player:triggerPassive(Passive.OPEN_MONSTER, {trigger = enemy}) | 128 | + monster:triggerPassive(Passive.OPEN_MONSTER, {trigger = enemy}) |
129 | + monster:attrChangeCondBuffCheck(3, enemy:getClassify()) | ||
95 | end | 130 | end |
96 | end | 131 | end |
97 | randomFunc[AdvEventType.BOSS] = randomFunc[AdvEventType.Monster] | 132 | randomFunc[AdvEventType.BOSS] = randomFunc[AdvEventType.Monster] |
@@ -208,6 +243,13 @@ function Block:randomEvent() | @@ -208,6 +243,13 @@ function Block:randomEvent() | ||
208 | e:addBuff(buffId) | 243 | e:addBuff(buffId) |
209 | end | 244 | end |
210 | end | 245 | end |
246 | + elseif data.target == 4 then | ||
247 | + local enemys = self.room.map.adv:getCurMap():openBlocksIsMonsterByRoom(self.room.roomId) | ||
248 | + for _, e in ipairs(enemys) do | ||
249 | + for _, buffId in ipairs(buffs) do | ||
250 | + e:addBuff(buffId) | ||
251 | + end | ||
252 | + end | ||
211 | end | 253 | end |
212 | 254 | ||
213 | if data.specialEff ~= "" then | 255 | if data.specialEff ~= "" then |
@@ -263,10 +305,37 @@ function Block:open() | @@ -263,10 +305,37 @@ function Block:open() | ||
263 | local adv = map.adv | 305 | local adv = map.adv |
264 | self.isOpen = true | 306 | self.isOpen = true |
265 | self:randomEvent() | 307 | self:randomEvent() |
308 | + self:quickDrop() | ||
309 | + | ||
310 | + local et = self:getEventType() | ||
311 | + if et then | ||
312 | + local em = {[et] = 1} | ||
313 | + local player = self.room.map.adv.battle.player | ||
314 | + player:attrChangeCondBuffCheck(4, em) | ||
315 | + for _, monster in pairs(player:getTeam(2)) do | ||
316 | + monster:attrChangeCondBuffCheck(4, em) | ||
317 | + end | ||
318 | + end | ||
266 | return true | 319 | return true |
267 | end | 320 | end |
268 | 321 | ||
322 | +function Block:quickDrop() | ||
323 | + if self:getEventType() == AdvEventType.Drop and self.event.item then | ||
324 | + local itemId, count = table.unpack(self.event.item) | ||
325 | + if globalCsv.adv_auto_collect[itemId] then | ||
326 | + self.room.map.adv:award({[itemId] = count}, {log = {desc = "clickDrop"}}, {roomId = self.room.roomId, blockId = self.blockId, tag = 1}) | ||
327 | + self:clear() | ||
328 | + end | ||
329 | + end | ||
330 | +end | ||
331 | + | ||
269 | function Block:getObstacle() | 332 | function Block:getObstacle() |
333 | + if self:isMonster() then | ||
334 | + local enemy = self.room.map.adv.battle:getEnemy(self.room.roomId, self.blockId) | ||
335 | + if enemy then | ||
336 | + return enemy:getObstacle() | ||
337 | + end | ||
338 | + end | ||
270 | local data = self:getEventData() | 339 | local data = self:getEventData() |
271 | if not data then return 0 end | 340 | if not data then return 0 end |
272 | return data.obstacle or 0 | 341 | return data.obstacle or 0 |
src/adv/AdvBuff.lua
@@ -20,7 +20,7 @@ Buff.HP_CHANGE_NOW = 16 -- 生命变化(每回合生效,立刻生效) | @@ -20,7 +20,7 @@ Buff.HP_CHANGE_NOW = 16 -- 生命变化(每回合生效,立刻生效) | ||
20 | Buff.BATTLE_BUFF = 17 -- 切换为战斗中的buff | 20 | Buff.BATTLE_BUFF = 17 -- 切换为战斗中的buff |
21 | Buff.CHANGE_DROP = 18 -- 转换掉落 | 21 | Buff.CHANGE_DROP = 18 -- 转换掉落 |
22 | Buff.BATTLE_PASSIVE = 19 -- 切换为战斗中的被动技 | 22 | Buff.BATTLE_PASSIVE = 19 -- 切换为战斗中的被动技 |
23 | -Buff.EXP_ADD = 20 -- 增加exp(每回合) | 23 | +-- Buff.EXP_ADD = 20 -- 增加exp(每回合) |
24 | Buff.DONT_DEFEND = 21 -- 不看守地板 -- 怪周围点半可点击 | 24 | Buff.DONT_DEFEND = 21 -- 不看守地板 -- 怪周围点半可点击 |
25 | Buff.SHOW_DANGER = 22 -- 扫雷 展示地上怪物和陷阱数量的标记 | 25 | Buff.SHOW_DANGER = 22 -- 扫雷 展示地上怪物和陷阱数量的标记 |
26 | Buff.SHOW_MONSTER_POS = 23 -- 蓝臂章训练场 感知 | 26 | Buff.SHOW_MONSTER_POS = 23 -- 蓝臂章训练场 感知 |
@@ -34,6 +34,10 @@ Buff.Buff_EFFECT_CHANGE = 30 -- 改变 buff 效果 | @@ -34,6 +34,10 @@ Buff.Buff_EFFECT_CHANGE = 30 -- 改变 buff 效果 | ||
34 | Buff.Buff_NO_PASSIVE_MONSTER = 31 -- 地图被动刷新不出来怪物 | 34 | 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 -- 结束失效 | ||
38 | +Buff.OBSTACLE_CHANGE = 35 -- 看守类型改变 -- 怪物使用 2 - 1 | ||
39 | +Buff.DISABLE_AURA = 36 -- 禁用光环 | ||
40 | +Buff.GET_AURA = 37 -- 获得光环 | ||
37 | 41 | ||
38 | 42 | ||
39 | --角色一些属性的变化 | 43 | --角色一些属性的变化 |
@@ -87,13 +91,24 @@ local function commonAttCond(_Buff, attrName) | @@ -87,13 +91,24 @@ local function commonAttCond(_Buff, attrName) | ||
87 | if buff then | 91 | if buff then |
88 | effectCount = buff.layer | 92 | effectCount = buff.layer |
89 | end | 93 | end |
94 | + elseif self.buffData.effectValue4 == 3 then | ||
95 | + local classify = tonumber(self.buffData.effectValue5) -- 怪标签 | ||
96 | + local enemy = self.owner.battle.player:getTeam(2) | ||
97 | + for _, one in pairs(enemy) do | ||
98 | + if one.isClassify and one:isClassify(classify) then | ||
99 | + effectCount = effectCount + 1 | ||
100 | + end | ||
101 | + end | ||
102 | + elseif self.buffData.effectValue4 == 4 then | ||
103 | + local eventType = tonumber(self.buffData.effectValue5) -- event 类型 | ||
104 | + effectCount = #self.owner.battle.adv:getCurMap():getEventTypeAllMap(eventType) | ||
90 | end | 105 | end |
91 | return self.buffData.effectValue2 * effectCount | 106 | return self.buffData.effectValue2 * effectCount |
92 | end | 107 | end |
93 | 108 | ||
94 | _Buff.getEffectBy = function(self) | 109 | _Buff.getEffectBy = function(self) |
95 | local cond = nil | 110 | local cond = nil |
96 | - if self.buffData.effectValue4 == 2 then | 111 | + if self.buffData.effectValue4 == 2 or self.buffData.effectValue4 == 3 or self.buffData.effectValue4 == 4 then |
97 | cond = tonumber(self.buffData.effectValue5) | 112 | cond = tonumber(self.buffData.effectValue5) |
98 | end | 113 | end |
99 | return self.buffData.effectValue4, attrName, cond | 114 | return self.buffData.effectValue4, attrName, cond |
@@ -302,18 +317,30 @@ local BuffFactory = { | @@ -302,18 +317,30 @@ local BuffFactory = { | ||
302 | end | 317 | end |
303 | end, | 318 | end, |
304 | 319 | ||
305 | - [Buff.EXP_ADD] = function(_Buff) | ||
306 | - _Buff._afterRound = function(self) | ||
307 | - local value = self:effect() | ||
308 | - self.owner.battle.player:addExp(value) | 320 | + -- [Buff.EXP_ADD] = function(_Buff) |
321 | + -- _Buff._afterRound = function(self) | ||
322 | + -- local value = self:effect() | ||
323 | + -- self.owner.battle.player:addExp(value) | ||
324 | + -- end | ||
325 | + -- _Buff._effectValue = function(self) | ||
326 | + -- -- 经验值 | ||
327 | + -- return self.buffData.effectValue1 * self.layer | ||
328 | + -- end | ||
329 | + -- end, | ||
330 | + | ||
331 | + [Buff.DISABLE_BUFF] = function(_Buff) | ||
332 | + _Buff._effectValue = function(self) | ||
333 | + return self.buffData.effectValue1 | ||
309 | end | 334 | end |
335 | + end, | ||
336 | + | ||
337 | + [Buff.DISABLE_AURA] = function(_Buff) | ||
310 | _Buff._effectValue = function(self) | 338 | _Buff._effectValue = function(self) |
311 | - -- 经验值 | ||
312 | - return self.buffData.effectValue1 * self.layer | 339 | + return self.buffData.effectValue1 |
313 | end | 340 | end |
314 | end, | 341 | end, |
315 | 342 | ||
316 | - [Buff.DISABLE_BUFF] = function(_Buff) | 343 | + [Buff.GET_AURA] = function(_Buff) |
317 | _Buff._effectValue = function(self) | 344 | _Buff._effectValue = function(self) |
318 | return self.buffData.effectValue1 | 345 | return self.buffData.effectValue1 |
319 | end | 346 | end |
@@ -378,6 +405,14 @@ local BuffFactory = { | @@ -378,6 +405,14 @@ local BuffFactory = { | ||
378 | self.layer = self.buffData.effectValue1 | 405 | self.layer = self.buffData.effectValue1 |
379 | end | 406 | end |
380 | end, | 407 | end, |
408 | + [Buff.GET_PASSIVE] = function( _Buff ) | ||
409 | + _Buff._init = function(self) | ||
410 | + self.owner:addPassive({id = self.buffData.effectValue1}) | ||
411 | + end | ||
412 | + _Buff._endBuff = function(self) | ||
413 | + self.owner:delPassiveById(self.buffData.effectValue1) | ||
414 | + end | ||
415 | + end | ||
381 | } | 416 | } |
382 | 417 | ||
383 | -- 同样的返回 effectValue1, effectValue2 * self.layer 类型的buff | 418 | -- 同样的返回 effectValue1, effectValue2 * self.layer 类型的buff |
@@ -439,10 +474,23 @@ function Buff:initNew(release, data) | @@ -439,10 +474,23 @@ function Buff:initNew(release, data) | ||
439 | end | 474 | end |
440 | end | 475 | end |
441 | 476 | ||
442 | -function Buff:createAfter() | 477 | +function Buff:createAfter(layer) |
478 | + layer = layer or 1 | ||
479 | + local otype, maxLayer = self:getOverlay() | ||
480 | + if otype then | ||
481 | + self.layer = layer | ||
482 | + if maxLayer ~= 0 then | ||
483 | + self.layer = math.min(maxLayer, self.layer) | ||
484 | + end | ||
485 | + else | ||
486 | + self.layer = 1 | ||
487 | + end | ||
488 | + | ||
443 | if self._init then | 489 | if self._init then |
444 | self:_init() | 490 | self:_init() |
445 | end | 491 | end |
492 | + self:pushBackEffect(1) | ||
493 | + buglog("Buff", "who: %s create buffId: %s", self.owner.monsterId, self.id) | ||
446 | end | 494 | end |
447 | 495 | ||
448 | function Buff:initByDB(data) | 496 | function Buff:initByDB(data) |
@@ -574,11 +622,20 @@ function Buff:canEffect(...) | @@ -574,11 +622,20 @@ function Buff:canEffect(...) | ||
574 | return self:_canEffect(...) | 622 | return self:_canEffect(...) |
575 | end | 623 | end |
576 | 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 | + | ||
577 | function Buff:effect() | 635 | function Buff:effect() |
636 | + buglog("Buff", "who: %s effect buffId: %s", self.owner.monsterId, self.id) | ||
578 | self:decCount() | 637 | self:decCount() |
579 | - if self.buffData.show:sismember(2, " ") then | ||
580 | - self.owner.battle.adv:pushBackEvent(AdvBackEventType.BuffEffect, {etype = 2}) | ||
581 | - end | 638 | + self:pushBackEffect(2) |
582 | if self._effectValue then | 639 | if self._effectValue then |
583 | return self:_effectValue() | 640 | return self:_effectValue() |
584 | end | 641 | end |
@@ -600,6 +657,7 @@ function Buff:endBuff() | @@ -600,6 +657,7 @@ function Buff:endBuff() | ||
600 | if self._endBuff then | 657 | if self._endBuff then |
601 | self:_endBuff() | 658 | self:_endBuff() |
602 | end | 659 | end |
660 | + buglog("Buff", "who: %s endBuff buffId: %s", self.owner.monsterId, self.id) | ||
603 | end | 661 | end |
604 | 662 | ||
605 | function Buff:getType() | 663 | function Buff:getType() |
@@ -626,12 +684,13 @@ function Buff:getOverlay() | @@ -626,12 +684,13 @@ function Buff:getOverlay() | ||
626 | end | 684 | end |
627 | 685 | ||
628 | -- 叠加 | 686 | -- 叠加 |
629 | -function Buff:overlay(releaser, data) | 687 | +function Buff:overlay(releaser, data, layer) |
630 | local otype, maxLayer = self:getOverlay() | 688 | local otype, maxLayer = self:getOverlay() |
631 | if self.isDel or not otype then -- 新获得的 (不可叠加相当于新获得的) | 689 | if self.isDel or not otype then -- 新获得的 (不可叠加相当于新获得的) |
632 | - self.isDel = false | ||
633 | self:endBuff() | 690 | self:endBuff() |
691 | + self.isDel = false | ||
634 | self:initNew(releaser, data) | 692 | self:initNew(releaser, data) |
693 | + self:createAfter(layer) | ||
635 | else | 694 | else |
636 | -- 重置回合 次数 | 695 | -- 重置回合 次数 |
637 | self.roundSpace = 0 | 696 | self.roundSpace = 0 |
@@ -644,25 +703,46 @@ function Buff:overlay(releaser, data) | @@ -644,25 +703,46 @@ function Buff:overlay(releaser, data) | ||
644 | 703 | ||
645 | self.release = releaser or self.release | 704 | self.release = releaser or self.release |
646 | -- 叠加层数 | 705 | -- 叠加层数 |
647 | - self.layer = self.layer + 1 | 706 | + self.layer = self.layer + layer |
648 | if maxLayer ~= 0 then | 707 | if maxLayer ~= 0 then |
649 | self.layer = math.min(maxLayer, self.layer) | 708 | self.layer = math.min(maxLayer, self.layer) |
650 | end | 709 | end |
651 | if self._overlay then | 710 | if self._overlay then |
652 | self:_overlay() | 711 | self:_overlay() |
653 | end | 712 | end |
713 | + | ||
714 | + self:pushBackEffect(1) | ||
715 | + buglog("Buff", "who: %s overlay buffId: %s", self.owner.monsterId, self.id) | ||
654 | end | 716 | end |
655 | end | 717 | end |
656 | 718 | ||
657 | -- 扣减层数 | 719 | -- 扣减层数 |
658 | -function Buff:uncover() | ||
659 | - if self.layer <= 1 then | 720 | +function Buff:uncover(layer, isAura) |
721 | + layer = layer or 1 | ||
722 | + local oldLayer = self.layer | ||
723 | + | ||
724 | + self.layer = self.layer - layer | ||
725 | + | ||
726 | + if self.layer <= 0 then | ||
660 | self.isDel = true | 727 | self.isDel = true |
661 | end | 728 | end |
662 | 729 | ||
663 | - self.layer = self.layer - 1 | ||
664 | - if self._uncover then | ||
665 | - self:_uncover() | 730 | + if isAura then |
731 | + if layer == -1 then | ||
732 | + self.layer = 0 | ||
733 | + self.isDel = true | ||
734 | + else | ||
735 | + self.layer = math.max(1, self.layer) | ||
736 | + self.isDel = false | ||
737 | + end | ||
738 | + end | ||
739 | + | ||
740 | + if self.isDel then return end | ||
741 | + | ||
742 | + if oldLayer ~= self.layer then | ||
743 | + if self._uncover then | ||
744 | + self:_uncover() | ||
745 | + end | ||
666 | end | 746 | end |
667 | end | 747 | end |
668 | 748 |
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 = {} |
@@ -256,9 +256,9 @@ function Map:openBlock(roomId, blockId, isPlayer, ignoreBack) | @@ -256,9 +256,9 @@ function Map:openBlock(roomId, blockId, isPlayer, ignoreBack) | ||
256 | 256 | ||
257 | if status then | 257 | if status then |
258 | if isPlayer then | 258 | if isPlayer then |
259 | - self.adv.battle:triggerPassive(Passive.OPEN_BLOCK) | 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 |
@@ -272,8 +272,8 @@ function Map:openBlock(roomId, blockId, isPlayer, ignoreBack) | @@ -272,8 +272,8 @@ function Map:openBlock(roomId, blockId, isPlayer, ignoreBack) | ||
272 | if not ignoreBack then | 272 | if not ignoreBack then |
273 | self.adv:backBlockChange(roomId, blockId) | 273 | self.adv:backBlockChange(roomId, blockId) |
274 | end | 274 | end |
275 | - | ||
276 | end | 275 | end |
276 | + return status | ||
277 | end | 277 | end |
278 | 278 | ||
279 | function Map:openBlocksBySize(roomId, blockId, size, isPlayer, ignoreBack) | 279 | function Map:openBlocksBySize(roomId, blockId, size, isPlayer, ignoreBack) |
@@ -292,6 +292,41 @@ function Map:openBlocksByRoom(roomId, isPlayer, ignoreBack) | @@ -292,6 +292,41 @@ function Map:openBlocksByRoom(roomId, isPlayer, ignoreBack) | ||
292 | end | 292 | end |
293 | end | 293 | end |
294 | 294 | ||
295 | +function Map:openBlocksIsMonsterByRoom(roomId, count, isPlayer, ignoreBack) | ||
296 | + local room = self.rooms[roomId] | ||
297 | + if not room then return end | ||
298 | + | ||
299 | + local allBlock = {} | ||
300 | + for blockId, block in pairs(room.blocks) do | ||
301 | + if block:isMonster() and not block.isOpen then | ||
302 | + table.insert(allBlock, blockId) | ||
303 | + end | ||
304 | + end | ||
305 | + | ||
306 | + local enemys = {} | ||
307 | + local openBlock = function(blockId) | ||
308 | + if self:openBlock(roomId, blockId, isPlayer, ignoreBack) then | ||
309 | + local e = self.adv.battle:getEnemy(roomId, blockId) | ||
310 | + if e then | ||
311 | + table.insert(enemys, e) | ||
312 | + end | ||
313 | + end | ||
314 | + end | ||
315 | + | ||
316 | + if not count or count == -1 or count >= #allBlock then | ||
317 | + for _, blockId in ipairs(allBlock) do | ||
318 | + openBlock(blockId) | ||
319 | + end | ||
320 | + else | ||
321 | + for i = 1, count do | ||
322 | + local idx = math.randomInt(1, #allBlock) | ||
323 | + openBlock(allBlock[idx]) | ||
324 | + table.remove(allBlock, idx) | ||
325 | + end | ||
326 | + end | ||
327 | + return enemys | ||
328 | +end | ||
329 | + | ||
295 | function Map:openAllBlocks(isPlayer, ignoreBack) | 330 | function Map:openAllBlocks(isPlayer, ignoreBack) |
296 | for roomId, room in pairs(self.rooms) do | 331 | for roomId, room in pairs(self.rooms) do |
297 | self:openBlocksByRoom(room.roomId, isPlayer, ignoreBack) | 332 | self:openBlocksByRoom(room.roomId, isPlayer, ignoreBack) |
@@ -309,6 +344,22 @@ function Map:getRBByPos(c, r) | @@ -309,6 +344,22 @@ function Map:getRBByPos(c, r) | ||
309 | end | 344 | end |
310 | end | 345 | end |
311 | 346 | ||
347 | +function Map:getDistance(froomId, fblockId, troomId, tblockId) | ||
348 | + local distance = -1 | ||
349 | + local room1 = self.rooms[froomId] | ||
350 | + local room2 = self.rooms[troomId] | ||
351 | + if room1 and room2 then | ||
352 | + local block1 = room1.blocks[fblockId] | ||
353 | + local block2 = room2.blocks[tblockId] | ||
354 | + if block1 and block2 then | ||
355 | + local c1, r1 = room1:tranLtoG(block1.col, block1.row) | ||
356 | + local c2, r2 = room2:tranLtoG(block2.col, block2.row) | ||
357 | + distance = math.max(math.abs(c1 - c2), math.abs(r1 - r2)) | ||
358 | + end | ||
359 | + end | ||
360 | + return distance | ||
361 | +end | ||
362 | + | ||
312 | function Map:getAroundBlocks(room, block) | 363 | function Map:getAroundBlocks(room, block) |
313 | local blocks = {} | 364 | local blocks = {} |
314 | local range = {1, -1} | 365 | local range = {1, -1} |
@@ -412,6 +463,18 @@ function Map:getEnemysBySize(roomId, blockId, size) | @@ -412,6 +463,18 @@ function Map:getEnemysBySize(roomId, blockId, size) | ||
412 | return enemys | 463 | return enemys |
413 | end | 464 | end |
414 | 465 | ||
466 | +function Map:getEventTypeAllMap(eventType) | ||
467 | + local blocks = {} | ||
468 | + if not eventType then return blocks end | ||
469 | + for roomId, room in pairs(self.rooms) do | ||
470 | + for blockId, block in pairs(room.blocks) do | ||
471 | + if block.isOpen and block:getEventType() == eventType then | ||
472 | + table.insert(blocks, block) | ||
473 | + end | ||
474 | + end | ||
475 | + end | ||
476 | + return blocks | ||
477 | +end | ||
415 | -----------------------------随机地图----------------------------- | 478 | -----------------------------随机地图----------------------------- |
416 | 479 | ||
417 | -- isEnter isNewRelay 区分中继层的类型 --是否是开始进入 是否是第一次进入 | 480 | -- isEnter isNewRelay 区分中继层的类型 --是否是开始进入 是否是第一次进入 |
@@ -748,6 +811,48 @@ createMap = function(self, mapId, isEnter, isNewRelay) | @@ -748,6 +811,48 @@ createMap = function(self, mapId, isEnter, isNewRelay) | ||
748 | end | 811 | end |
749 | end | 812 | end |
750 | 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 | + | ||
751 | 856 | ||
752 | if mapCsvData.clearType == 1 and not haveBoss then | 857 | if mapCsvData.clearType == 1 and not haveBoss then |
753 | if not next(monsterEvents) then | 858 | if not next(monsterEvents) then |
src/adv/AdvPassive.lua
@@ -7,6 +7,9 @@ Filter.HP_LOW = 4 -- 血量<value% | @@ -7,6 +7,9 @@ Filter.HP_LOW = 4 -- 血量<value% | ||
7 | Filter.BUFF_BY_TYPE = 5 -- 指定类型buff | 7 | Filter.BUFF_BY_TYPE = 5 -- 指定类型buff |
8 | Filter.BUFF_BY_ID = 6 -- 指定id的buff | 8 | Filter.BUFF_BY_ID = 6 -- 指定id的buff |
9 | Filter.CAMP = 7 -- 玩家是指定阵营 | 9 | Filter.CAMP = 7 -- 玩家是指定阵营 |
10 | +Filter.RANGE = 8 -- 筛选范围 (触发是地块) | ||
11 | +Filter.CLASSIFY = 9 -- 标签 | ||
12 | +Filter.NO_BUFF_BY_ID = 10 -- 没有指定id的buff | ||
10 | 13 | ||
11 | local FilterFactory = {} | 14 | local FilterFactory = {} |
12 | FilterFactory[Filter.HP_UP_WITH_EQUAL] = function (_Filter) | 15 | FilterFactory[Filter.HP_UP_WITH_EQUAL] = function (_Filter) |
@@ -45,7 +48,26 @@ FilterFactory[Filter.CAMP] = function (_Filter) | @@ -45,7 +48,26 @@ FilterFactory[Filter.CAMP] = function (_Filter) | ||
45 | return role:getHerosCamp(role:getProperty("advTeam").heros) == self.value | 48 | return role:getHerosCamp(role:getProperty("advTeam").heros) == self.value |
46 | end | 49 | end |
47 | end | 50 | end |
51 | +FilterFactory[Filter.RANGE] = function (_Filter) | ||
52 | + _Filter._execute = function (self, target, params) | ||
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) | ||
55 | + return distance ~= -1 and distance <= self.value | ||
56 | + end | ||
57 | + return false | ||
58 | + end | ||
59 | +end | ||
60 | +FilterFactory[Filter.CLASSIFY] = function (_Filter) | ||
61 | + _Filter._execute = function (self, target) | ||
62 | + return target.isClassify and target:isClassify(self.value) | ||
63 | + end | ||
64 | +end | ||
48 | 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 | ||
49 | 71 | ||
50 | function Filter:ctor(params) | 72 | function Filter:ctor(params) |
51 | self.owner = params.owner | 73 | self.owner = params.owner |
@@ -70,6 +92,9 @@ function Filter:getTarget(params) | @@ -70,6 +92,9 @@ function Filter:getTarget(params) | ||
70 | if self.oType == 2 and params.releaser then | 92 | if self.oType == 2 and params.releaser then |
71 | target = params.releaser | 93 | target = params.releaser |
72 | end | 94 | end |
95 | + if self.oType == 3 then | ||
96 | + target = self.owner.battle.player | ||
97 | + end | ||
73 | return target | 98 | return target |
74 | end | 99 | end |
75 | 100 | ||
@@ -78,9 +103,8 @@ function Filter:execute(params) | @@ -78,9 +103,8 @@ function Filter:execute(params) | ||
78 | if not target then | 103 | if not target then |
79 | return | 104 | return |
80 | end | 105 | end |
81 | - if self:_execute(target) then | ||
82 | - return self:_execute(target) | ||
83 | - end | 106 | + |
107 | + return self:_execute(target, params) | ||
84 | end | 108 | end |
85 | 109 | ||
86 | -->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | 110 | -->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |
@@ -120,6 +144,7 @@ Passive.GET_BUFF = 28 --获得指定buff | @@ -120,6 +144,7 @@ Passive.GET_BUFF = 28 --获得指定buff | ||
120 | Passive.OPEN_BLOCK = 29 --翻开格子 | 144 | Passive.OPEN_BLOCK = 29 --翻开格子 |
121 | Passive.OPEN_MONSTER = 30 --翻开怪物 | 145 | Passive.OPEN_MONSTER = 30 --翻开怪物 |
122 | Passive.PLAYER_BUFF = 31 --玩家获得buff | 146 | Passive.PLAYER_BUFF = 31 --玩家获得buff |
147 | + | ||
123 | Passive.PLAYER_BUFF_CLASSIFY = 35 -- 获得指定标签的buff | 148 | Passive.PLAYER_BUFF_CLASSIFY = 35 -- 获得指定标签的buff |
124 | 149 | ||
125 | -- 不同的开启条件 | 150 | -- 不同的开启条件 |
@@ -185,7 +210,7 @@ PassiveCondFactory[Passive.PLAYER_BUFF] = PassiveCondFactory[Passive.GET_BUFF] | @@ -185,7 +210,7 @@ PassiveCondFactory[Passive.PLAYER_BUFF] = PassiveCondFactory[Passive.GET_BUFF] | ||
185 | 210 | ||
186 | PassiveCondFactory[Passive.PLAYER_BUFF_CLASSIFY] = function(_Passive) | 211 | PassiveCondFactory[Passive.PLAYER_BUFF_CLASSIFY] = function(_Passive) |
187 | _Passive._trigger = function(self, params) | 212 | _Passive._trigger = function(self, params) |
188 | - if params.classify:sismember(self.passiveData.value) then | 213 | + if params.classify:sismember(self.passiveData.value, " ") then |
189 | return true | 214 | return true |
190 | end | 215 | end |
191 | end | 216 | end |
@@ -322,6 +347,7 @@ function Passive:canEffect(effType, effValue) | @@ -322,6 +347,7 @@ function Passive:canEffect(effType, effValue) | ||
322 | end | 347 | end |
323 | 348 | ||
324 | function Passive:effect(triggerPms) | 349 | function Passive:effect(triggerPms) |
350 | + local hadEffect = false | ||
325 | for _, effect in ipairs(self.effects) do | 351 | for _, effect in ipairs(self.effects) do |
326 | local effType = effect[1] | 352 | local effType = effect[1] |
327 | local effValue = effect[2] | 353 | local effValue = effect[2] |
@@ -330,10 +356,14 @@ function Passive:effect(triggerPms) | @@ -330,10 +356,14 @@ function Passive:effect(triggerPms) | ||
330 | table.insert(otherPms, effect[i]) | 356 | table.insert(otherPms, effect[i]) |
331 | end | 357 | end |
332 | if self:canEffect(effType, effValue) then | 358 | if self:canEffect(effType, effValue) then |
359 | + hadEffect = true | ||
333 | self["effect" .. effType](self, effValue, triggerPms, table.unpack(otherPms)) | 360 | self["effect" .. effType](self, effValue, triggerPms, table.unpack(otherPms)) |
334 | end | 361 | end |
335 | end | 362 | end |
336 | - | 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 | ||
337 | if self.count > 0 then | 367 | if self.count > 0 then |
338 | 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 |
339 | self.round = self.passiveData.round | 369 | self.round = self.passiveData.round |
@@ -383,6 +413,8 @@ function Passive:trigger(condType, params) --触发检查 | @@ -383,6 +413,8 @@ function Passive:trigger(condType, params) --触发检查 | ||
383 | params = params or {} | 413 | params = params or {} |
384 | if self.isDel or self.owner.isDead then return end | 414 | if self.isDel or self.owner.isDead then return end |
385 | 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) | ||
386 | if not self:canTrigger() then return end | 418 | if not self:canTrigger() then return end |
387 | if self._trigger then | 419 | if self._trigger then |
388 | if not self:_trigger(params) then return end --检查 | 420 | if not self:_trigger(params) then return end --检查 |
@@ -442,6 +474,7 @@ end | @@ -442,6 +474,7 @@ end | ||
442 | 474 | ||
443 | --3=翻开自己所在格子 | 475 | --3=翻开自己所在格子 |
444 | function Passive:effect3(value) | 476 | function Passive:effect3(value) |
477 | + if not self.owner.roomId or not self.owner.blockId then return end | ||
445 | if value == 0 then | 478 | if value == 0 then |
446 | self.owner.battle.adv:getCurMap():openBlock(self.owner.roomId, self.owner.blockId) | 479 | self.owner.battle.adv:getCurMap():openBlock(self.owner.roomId, self.owner.blockId) |
447 | elseif value > 0 then | 480 | elseif value > 0 then |
@@ -494,7 +527,7 @@ function Passive:effect8(dropId) | @@ -494,7 +527,7 @@ function Passive:effect8(dropId) | ||
494 | skynet.error(string.format("CSVDATA Error adv_map_passive %s effect 8 not id %s in event_drop", self.id, dropId)) | 527 | skynet.error(string.format("CSVDATA Error adv_map_passive %s effect 8 not id %s in event_drop", self.id, dropId)) |
495 | end | 528 | end |
496 | local item = dropData["range"]:randWeight(true) | 529 | local item = dropData["range"]:randWeight(true) |
497 | - self.owner.battle.adv:backReward(self.owner.battle.adv:award({[item[1]] = item[2]}, {log = {desc = "passive", int1 = self.id}}), {roomId = self.owner.roomId, blockId = self.owner.blockId}) | 530 | + self.owner.battle.adv:award({[item[1]] = item[2]}, {log = {desc = "passive", int1 = self.id}}, {roomId = self.owner.roomId, blockId = self.owner.blockId}) |
498 | 531 | ||
499 | end | 532 | end |
500 | 533 | ||
@@ -509,7 +542,7 @@ function Passive:effect9(itemId, triggerPms, ratio, max) | @@ -509,7 +542,7 @@ function Passive:effect9(itemId, triggerPms, ratio, max) | ||
509 | return | 542 | return |
510 | end | 543 | end |
511 | if not cond then return end | 544 | if not cond then return end |
512 | - self.owner.battle.adv:backReward(self.owner.battle.adv:award({[itemId] = math.floor(math.max(0, math.min(max, cond / ratio)))}, {log = {desc = "passive", int1 = self.id}}), {roomId = self.owner.roomId, blockId = self.owner.blockId}) | 545 | + self.owner.battle.adv:award({[itemId] = math.floor(math.max(0, math.min(max, cond / ratio)))}, {log = {desc = "passive", int1 = self.id}}, {roomId = self.owner.roomId, blockId = self.owner.blockId}) |
513 | end | 546 | end |
514 | 547 | ||
515 | --10=战斗额外掉落次数 | 548 | --10=战斗额外掉落次数 |
@@ -561,5 +594,26 @@ function Passive:effect14(value, triggerPms, enemyId) | @@ -561,5 +594,26 @@ function Passive:effect14(value, triggerPms, enemyId) | ||
561 | end | 594 | end |
562 | end | 595 | end |
563 | 596 | ||
597 | +--15=翻开房间内的count 个怪 并且增加一个buff | ||
598 | +function Passive:effect15(count, triggerPms, buffId) | ||
599 | + local roomId = self.owner.roomId | ||
600 | + if not roomId then return end | ||
601 | + local enemys = self.owner.battle.adv:getCurMap():openBlocksIsMonsterByRoom(roomId, count) | ||
602 | + for _, e in ipairs(enemys) do | ||
603 | + e:addBuff(buffId) | ||
604 | + end | ||
605 | +end | ||
606 | + | ||
607 | +--16=转变 value 范围内的掉落物 为 id count | ||
608 | +function Passive:effect16(value, triggerPms, changeType) | ||
609 | + if not self.owner.roomId or not self.owner.blockId then return end | ||
610 | + local blocks = self.owner.battle.adv:getCurMap():getBlocksBySize(self.owner.roomId, self.owner.blockId, value) | ||
611 | + self.owner.battle.adv:blockDropChange(changeType, blocks) | ||
612 | +end | ||
613 | + | ||
614 | +--17=玩家获得buff | ||
615 | +function Passive:effect17(value, triggerPms) | ||
616 | + self.owner.battle.player:addBuff(value, self.owner) | ||
617 | +end | ||
564 | 618 | ||
565 | return Passive | 619 | return Passive |
566 | \ No newline at end of file | 620 | \ No newline at end of file |
src/adv/AdvPlayer.lua
@@ -90,6 +90,12 @@ end | @@ -90,6 +90,12 @@ end | ||
90 | function BaseObject:clear() | 90 | function BaseObject:clear() |
91 | self.buffs = {} | 91 | self.buffs = {} |
92 | self.passives = {} | 92 | self.passives = {} |
93 | + if self:is("Enemy") then | ||
94 | + self.battle.player:attrChangeCondBuffCheck(3, self:getClassify()) | ||
95 | + for _, monster in pairs(self.battle.player:getTeam(2)) do | ||
96 | + monster:attrChangeCondBuffCheck(3, self:getClassify()) | ||
97 | + end | ||
98 | + end | ||
93 | end | 99 | end |
94 | 100 | ||
95 | function BaseObject:addPassive(params) | 101 | function BaseObject:addPassive(params) |
@@ -137,7 +143,21 @@ function BaseObject:getDisablePassiveCount() | @@ -137,7 +143,21 @@ function BaseObject:getDisablePassiveCount() | ||
137 | return count | 143 | return count |
138 | end | 144 | end |
139 | 145 | ||
140 | -function BaseObject:addBuff(buffId, releaser) | 146 | +function BaseObject:getDisableAuraCount() |
147 | + local count = 0 | ||
148 | + for _, buff in ipairs(self.buffs) do | ||
149 | + if not buff:isHide() and buff:getType() == Buff.DISABLE_AURA then | ||
150 | + if buff:effect() == 0 then | ||
151 | + return 0 | ||
152 | + end | ||
153 | + count = (count or 0) + buff:effect() | ||
154 | + end | ||
155 | + end | ||
156 | + return count | ||
157 | +end | ||
158 | + | ||
159 | +function BaseObject:addBuff(buffId, releaser, layer) | ||
160 | + layer = layer or 1 | ||
141 | local buffData = csvdb["adv_map_buffCsv"][buffId] | 161 | local buffData = csvdb["adv_map_buffCsv"][buffId] |
142 | if not buffData then return end | 162 | if not buffData then return end |
143 | for _, buff in ipairs(self.buffs) do | 163 | for _, buff in ipairs(self.buffs) do |
@@ -151,7 +171,7 @@ function BaseObject:addBuff(buffId, releaser) | @@ -151,7 +171,7 @@ function BaseObject:addBuff(buffId, releaser) | ||
151 | local oldBuff = self:getBuffById(buffId) | 171 | local oldBuff = self:getBuffById(buffId) |
152 | if oldBuff then | 172 | if oldBuff then |
153 | if not oldBuff:checkKeep() then return end | 173 | if not oldBuff:checkKeep() then return end |
154 | - oldBuff:overlay(releaser, {}) -- 叠加 | 174 | + oldBuff:overlay(releaser, {}, layer) -- 叠加 |
155 | else | 175 | else |
156 | -- 不能保持的buff 也加不上去 | 176 | -- 不能保持的buff 也加不上去 |
157 | if not Buff.checkKeep({ | 177 | if not Buff.checkKeep({ |
@@ -161,10 +181,11 @@ function BaseObject:addBuff(buffId, releaser) | @@ -161,10 +181,11 @@ function BaseObject:addBuff(buffId, releaser) | ||
161 | }) then return end | 181 | }) then return end |
162 | local buff = Buff.create(self, releaser, {id = buffId}) | 182 | local buff = Buff.create(self, releaser, {id = buffId}) |
163 | table.insert(self.buffs, buff) | 183 | table.insert(self.buffs, buff) |
164 | - buff:createAfter() | 184 | + buff:createAfter(layer) |
165 | end | 185 | end |
166 | self:triggerPassive(Passive.GET_BUFF, {trigger = releaser, buffId = buffId}) | 186 | self:triggerPassive(Passive.GET_BUFF, {trigger = releaser, buffId = buffId}) |
167 | self:triggerPassive(Passive.PLAYER_BUFF_CLASSIFY, {trigger = releaser, classify = buffData.classify}) | 187 | self:triggerPassive(Passive.PLAYER_BUFF_CLASSIFY, {trigger = releaser, classify = buffData.classify}) |
188 | + self:attrChangeCondBuffCheck(2, buffId) | ||
168 | return true | 189 | return true |
169 | end | 190 | end |
170 | 191 | ||
@@ -217,6 +238,44 @@ end | @@ -217,6 +238,44 @@ end | ||
217 | function BaseObject:reSetSpMax() | 238 | function BaseObject:reSetSpMax() |
218 | end | 239 | end |
219 | 240 | ||
241 | +function BaseObject:checkAuraBuff(buffs) | ||
242 | +end | ||
243 | + | ||
244 | +function BaseObject:getAuras() | ||
245 | + local disable = self:getDisableAuraCount() | ||
246 | + local auras = {} | ||
247 | + local function addAura(one) | ||
248 | + if disable > 0 then | ||
249 | + disable = disable - 1 | ||
250 | + else | ||
251 | + table.insert(auras, one) | ||
252 | + end | ||
253 | + end | ||
254 | + if self:is("Enemy") then | ||
255 | + local halo = csvdb["event_monsterCsv"][self.monsterId].halo | ||
256 | + if halo then | ||
257 | + for _, one in ipairs(halo:toArray(true, "=")) do | ||
258 | + addAura(one) | ||
259 | + end | ||
260 | + end | ||
261 | + elseif self:is("Build") then | ||
262 | + local halo = csvdb["event_buildingCsv"][self.id].halo | ||
263 | + if halo then | ||
264 | + for _, one in ipairs(halo:toArray(true, "=")) do | ||
265 | + addAura(one) | ||
266 | + end | ||
267 | + end | ||
268 | + end | ||
269 | + | ||
270 | + for _, buff in ipairs(self.buffs) do | ||
271 | + if not buff:isHide() and buff:getType() == Buff.GET_AURA then | ||
272 | + addAura(buff:effect()) | ||
273 | + end | ||
274 | + end | ||
275 | + | ||
276 | + return auras | ||
277 | +end | ||
278 | + | ||
220 | 279 | ||
221 | -- 通用的buff 效果汇总 -- 0 固定 1百分比 两种分类 | 280 | -- 通用的buff 效果汇总 -- 0 固定 1百分比 两种分类 |
222 | function BaseObject:getCommonBuffEffect(bType, otherCond) | 281 | function BaseObject:getCommonBuffEffect(bType, otherCond) |
@@ -417,7 +476,7 @@ function BaseObject:hurt(value, releaser, params) | @@ -417,7 +476,7 @@ function BaseObject:hurt(value, releaser, params) | ||
417 | if self.hp == 0 then | 476 | if self.hp == 0 then |
418 | self:triggerPassive(Passive.SELF_DEAD) | 477 | self:triggerPassive(Passive.SELF_DEAD) |
419 | for _, team in ipairs(self:getTeam(1, true)) do | 478 | for _, team in ipairs(self:getTeam(1, true)) do |
420 | - team:triggerPassive(Passive.TEAM_DEAD) | 479 | + team:triggerPassive(Passive.TEAM_DEAD, {trigger = self}) |
421 | end | 480 | end |
422 | 481 | ||
423 | if (params.hurtType == 6 or params.hurtType == 2) and self ~= self.battle.player then | 482 | if (params.hurtType == 6 or params.hurtType == 2) and self ~= self.battle.player then |
@@ -505,6 +564,50 @@ function BaseObject:getTeam(nType, noSelf, mapIdx, includeLock) | @@ -505,6 +564,50 @@ function BaseObject:getTeam(nType, noSelf, mapIdx, includeLock) | ||
505 | return team | 564 | return team |
506 | end | 565 | end |
507 | 566 | ||
567 | +function BaseObject:attrChangeCondBuffCheck(etype, cond) | ||
568 | + local effect = {} | ||
569 | + if etype == 3 then | ||
570 | + if type(cond) ~= "string" then | ||
571 | + return | ||
572 | + end | ||
573 | + local temp = cond:toArray(true, " ") | ||
574 | + cond = {} | ||
575 | + for _, one in pairs(temp) do | ||
576 | + cond[one] = 1 | ||
577 | + end | ||
578 | + elseif etype == 4 then | ||
579 | + if not cond then | ||
580 | + cond = {} | ||
581 | + end | ||
582 | + if type(cond) == "number" then | ||
583 | + cond = {[cond] = 1} | ||
584 | + end | ||
585 | + end | ||
586 | + for _, buff in ipairs(self.buffs) do | ||
587 | + if not buff:isHide() and (buff:getType() == Buff.ATTR_CHANGE_COND) then | ||
588 | + local _et, _attr, _co = buff:getEffectBy() | ||
589 | + if etype == _et then | ||
590 | + if etype == 3 or etype == 4 then | ||
591 | + if cond[_co] then | ||
592 | + effect[_attr] = 1 | ||
593 | + end | ||
594 | + else | ||
595 | + if (not _co or _co == cond) then | ||
596 | + effect[_attr] = 1 | ||
597 | + end | ||
598 | + end | ||
599 | + end | ||
600 | + end | ||
601 | + end | ||
602 | + for attrName, _ in pairs(effect) do | ||
603 | + if attrName == "hp" then | ||
604 | + self:reSetHpMax() | ||
605 | + else | ||
606 | + self:reSetAttr(attrName) | ||
607 | + end | ||
608 | + end | ||
609 | +end | ||
610 | + | ||
508 | function BaseObject:getDB() | 611 | function BaseObject:getDB() |
509 | local db = {} | 612 | local db = {} |
510 | db.hp = self.hp | 613 | db.hp = self.hp |
@@ -557,6 +660,51 @@ function Enemy:isEnemy() | @@ -557,6 +660,51 @@ function Enemy:isEnemy() | ||
557 | return true | 660 | return true |
558 | end | 661 | end |
559 | 662 | ||
663 | +function Enemy:getObstacle() | ||
664 | + local obstacle = csvdb["event_monsterCsv"][self.monsterId].obstacle | ||
665 | + if obstacle == 2 and self:hadBuff(Buff.OBSTACLE_CHANGE) then | ||
666 | + obstacle = 1 | ||
667 | + end | ||
668 | + return obstacle | ||
669 | +end | ||
670 | + | ||
671 | +function Enemy:isClassify(check) | ||
672 | + local classify = self:getClassify() | ||
673 | + return classify and classify:sismember(check, " ") | ||
674 | +end | ||
675 | + | ||
676 | +function Enemy:getClassify() | ||
677 | + return csvdb["event_monsterCsv"][self.monsterId].classify | ||
678 | +end | ||
679 | + | ||
680 | +-- 0=所有 1=怪物 2=玩家 | ||
681 | +function Enemy:checkAuraBuff(buffs) | ||
682 | + local needBuffs = {} | ||
683 | + | ||
684 | + for buffId, info in pairs(buffs[0] or {}) do | ||
685 | + needBuffs[buffId] = needBuffs[buffId] or {} | ||
686 | + needBuffs[buffId].count = (needBuffs[buffId].count or 0) + info.count | ||
687 | + needBuffs[buffId].exist = info.exist | ||
688 | + end | ||
689 | + | ||
690 | + for buffId, info in pairs(buffs[1] or {}) do | ||
691 | + needBuffs[buffId] = needBuffs[buffId] or {} | ||
692 | + needBuffs[buffId].count = (needBuffs[buffId].count or 0) + info.count | ||
693 | + needBuffs[buffId].exist = info.exist | ||
694 | + end | ||
695 | + | ||
696 | + for buffId, info in pairs(needBuffs) do | ||
697 | + if info.count < 0 then | ||
698 | + local buff = self:getBuffById(buffId) | ||
699 | + if buff then | ||
700 | + buff:uncover(info.exist and -info.count or -1, true) | ||
701 | + end | ||
702 | + elseif info.count > 0 then | ||
703 | + self:addBuff(buffId, nil, info.count) | ||
704 | + end | ||
705 | + end | ||
706 | +end | ||
707 | + | ||
560 | function Enemy:kill() | 708 | function Enemy:kill() |
561 | self:hurt(self.hp, self.battle.player, {hurtType = 5}) | 709 | self:hurt(self.hp, self.battle.player, {hurtType = 5}) |
562 | end | 710 | end |
@@ -569,44 +717,44 @@ end | @@ -569,44 +717,44 @@ end | ||
569 | 717 | ||
570 | function Player:initData(data) | 718 | function Player:initData(data) |
571 | Player.super.initData(self, data) | 719 | Player.super.initData(self, data) |
572 | - self.level = data.level or 1 --level 每增加1级 属性增长 growth * baseAttr | 720 | + -- self.level = data.level or 1 --level 每增加1级 属性增长 growth * baseAttr |
573 | self.growth = data.growth | 721 | self.growth = data.growth |
574 | - self.exp = data.exp or 0 | 722 | + -- self.exp = data.exp or 0 |
575 | self.sp = data.sp or 100 | 723 | self.sp = data.sp or 100 |
576 | self.spMax = data.spMax or 100 | 724 | self.spMax = data.spMax or 100 |
577 | self._spMax = data._spMax or 100 | 725 | self._spMax = data._spMax or 100 |
578 | end | 726 | end |
579 | 727 | ||
580 | -function Player:addExp(value) | ||
581 | - -- buff 经验加成 | ||
582 | - local up = self:getCommonBuffEffect(Buff.EXP_UP) | ||
583 | - value = math.ceil((value + up[0]) * (1 + up[1])) | ||
584 | - | ||
585 | - if value <= 0 then return end | ||
586 | - local newExp = self.exp + value | ||
587 | - local level = self.level | ||
588 | - if level >= #csvdb["adv_levelCsv"] then return end | ||
589 | - while true do | ||
590 | - local curData = csvdb["adv_levelCsv"][level] | ||
591 | - if newExp < curData.exp then break end | ||
592 | - level = level + 1 | ||
593 | - newExp = newExp - curData.exp | ||
594 | - if level >= #csvdb["adv_levelCsv"] then break end | ||
595 | - end | ||
596 | - local delta = level - self.level | ||
597 | - | ||
598 | - self.battle.adv:pushBackEvent(AdvBackEventType.Exp, {delta = value}) | ||
599 | - | ||
600 | - if delta > 0 then | ||
601 | - for attr, _ in pairs(AdvAttsEnum) do | ||
602 | - self:addBaseAttr(attr, self.growth[attr] * delta, 0, true) | ||
603 | - end | ||
604 | - self.battle.adv:pushBackEvent(AdvBackEventType.Level, {level = level, delta = delta}) | ||
605 | - end | ||
606 | - self.level = level | ||
607 | - self.exp = newExp | ||
608 | - return value | ||
609 | -end | 728 | +-- function Player:addExp(value) |
729 | +-- -- buff 经验加成 | ||
730 | +-- local up = self:getCommonBuffEffect(Buff.EXP_UP) | ||
731 | +-- value = math.ceil((value + up[0]) * (1 + up[1])) | ||
732 | + | ||
733 | +-- if value <= 0 then return end | ||
734 | +-- local newExp = self.exp + value | ||
735 | +-- local level = self.level | ||
736 | +-- if level >= #csvdb["adv_levelCsv"] then return end | ||
737 | +-- while true do | ||
738 | +-- local curData = csvdb["adv_levelCsv"][level] | ||
739 | +-- if newExp < curData.exp then break end | ||
740 | +-- level = level + 1 | ||
741 | +-- newExp = newExp - curData.exp | ||
742 | +-- if level >= #csvdb["adv_levelCsv"] then break end | ||
743 | +-- end | ||
744 | +-- local delta = level - self.level | ||
745 | + | ||
746 | +-- self.battle.adv:pushBackEvent(AdvBackEventType.Exp, {delta = value}) | ||
747 | + | ||
748 | +-- if delta > 0 then | ||
749 | +-- for attr, _ in pairs(AdvAttsEnum) do | ||
750 | +-- self:addBaseAttr(attr, self.growth[attr] * delta, 0, true) | ||
751 | +-- end | ||
752 | +-- self.battle.adv:pushBackEvent(AdvBackEventType.Level, {level = level, delta = delta}) | ||
753 | +-- end | ||
754 | +-- self.level = level | ||
755 | +-- self.exp = newExp | ||
756 | +-- return value | ||
757 | +-- end | ||
610 | --vtype 0/1 值/% | 758 | --vtype 0/1 值/% |
611 | function Player:addBaseAttr(attr, value, vtype, ignoreBack) | 759 | function Player:addBaseAttr(attr, value, vtype, ignoreBack) |
612 | local attrName = attr | 760 | local attrName = attr |
@@ -696,34 +844,36 @@ end | @@ -696,34 +844,36 @@ end | ||
696 | function Player:addBuff(buffId, releaser) | 844 | function Player:addBuff(buffId, releaser) |
697 | local status = Player.super.addBuff(self, buffId, releaser) | 845 | local status = Player.super.addBuff(self, buffId, releaser) |
698 | if status then | 846 | if status then |
699 | - self.battle.player:attrChangeCondBuffCheck(2, buffId) | ||
700 | self.battle.adv:checkAchievement(self.battle.adv.AchievType.GetBuff, 1, buffId) | 847 | self.battle.adv:checkAchievement(self.battle.adv.AchievType.GetBuff, 1, buffId) |
701 | self.battle.adv:pushBackEvent(AdvBackEventType.Buff, {buffId = buffId}) | 848 | self.battle.adv:pushBackEvent(AdvBackEventType.Buff, {buffId = buffId}) |
702 | self.battle:triggerPassive(Passive.PLAYER_BUFF, {buffId = buffId}) | 849 | self.battle:triggerPassive(Passive.PLAYER_BUFF, {buffId = buffId}) |
703 | - local buffData = csvdb["adv_map_buffCsv"][buffId] | ||
704 | - if buffData and buffData.show:sismember(1, " ") then | ||
705 | - self.battle.adv:pushBackEvent(AdvBackEventType.BuffEffect, {etype = 1}) | ||
706 | - end | ||
707 | end | 850 | end |
708 | return status | 851 | return status |
709 | end | 852 | end |
853 | +-- 0=所有 1=怪物 2=玩家 | ||
854 | +function Player:checkAuraBuff(buffs) | ||
855 | + local needBuffs = {} | ||
710 | 856 | ||
711 | -function Player:attrChangeCondBuffCheck(etype, cond) | ||
712 | - local effect = {} | ||
713 | - for _, buff in ipairs(self.buffs) do | ||
714 | - if not buff:isHide() and (buff:getType() == Buff.ATTR_CHANGE_COND) then | ||
715 | - local _et, _attr, _co = buff:getEffectBy() | ||
716 | - if etype == _et and (not _co or _co == cond) then | ||
717 | - effect[_attr] = 1 | ||
718 | - end | ||
719 | - | ||
720 | - end | 857 | + for buffId, info in pairs(buffs[0] or {}) do |
858 | + needBuffs[buffId] = needBuffs[buffId] or {} | ||
859 | + needBuffs[buffId].count = (needBuffs[buffId].count or 0) + info.count | ||
860 | + needBuffs[buffId].exist = info.exist | ||
721 | end | 861 | end |
722 | - for attrName, _ in pairs(effect) do | ||
723 | - if attrName == "hp" then | ||
724 | - self:reSetHpMax() | ||
725 | - else | ||
726 | - self:reSetAttr(attrName) | 862 | + |
863 | + for buffId, info in pairs(buffs[2] or {}) do | ||
864 | + needBuffs[buffId] = needBuffs[buffId] or {} | ||
865 | + needBuffs[buffId].count = (needBuffs[buffId].count or 0) + info.count | ||
866 | + needBuffs[buffId].exist = info.exist | ||
867 | + end | ||
868 | + | ||
869 | + for buffId, info in pairs(needBuffs) do | ||
870 | + if info.count < 0 then | ||
871 | + local buff = self:getBuffById(buffId) | ||
872 | + if buff then | ||
873 | + buff:uncover(info.exist and -info.count or -1, true) | ||
874 | + end | ||
875 | + elseif info.count > 0 then | ||
876 | + self:addBuff(buffId, nil, info.count) | ||
727 | end | 877 | end |
728 | end | 878 | end |
729 | end | 879 | end |
@@ -734,7 +884,8 @@ end | @@ -734,7 +884,8 @@ end | ||
734 | 884 | ||
735 | function Player:getDB() | 885 | function Player:getDB() |
736 | local db = Player.super.getDB(self) | 886 | local db = Player.super.getDB(self) |
737 | - for _ , field in pairs({"level", "exp", "growth", "sp", "spMax"}) do | 887 | + -- for _ , field in pairs({"level", "exp", "growth", "sp", "spMax"}) do |
888 | + for _ , field in pairs({"level", "growth", "sp", "spMax"}) do | ||
738 | db[field] = self[field] | 889 | db[field] = self[field] |
739 | end | 890 | end |
740 | db["_spMax"] = self._spMax | 891 | db["_spMax"] = self._spMax |
src/agent.lua
@@ -15,6 +15,7 @@ redisproxy = require "shared.redisproxy" | @@ -15,6 +15,7 @@ redisproxy = require "shared.redisproxy" | ||
15 | datacenter = require "skynet.datacenter" | 15 | datacenter = require "skynet.datacenter" |
16 | mcast_util = require "services/mcast_util" | 16 | mcast_util = require "services/mcast_util" |
17 | csvdb = require "shared.csvdata" | 17 | csvdb = require "shared.csvdata" |
18 | +cluster = require "skynet.cluster" | ||
18 | 19 | ||
19 | local CMD = {} | 20 | local CMD = {} |
20 | local agentInfo = {} -- { client_fd, role, gate_serv, open_timer} | 21 | local agentInfo = {} -- { client_fd, role, gate_serv, open_timer} |
@@ -356,11 +357,6 @@ skynet.start(function() | @@ -356,11 +357,6 @@ skynet.start(function() | ||
356 | return info | 357 | return info |
357 | end) | 358 | end) |
358 | 359 | ||
359 | - redisd = skynet.localname(".redis") | ||
360 | - if tonumber(skynet.getenv "logd") == 1 then | ||
361 | - logd = skynet.localname(".log") | ||
362 | - end | ||
363 | - | ||
364 | cs = queue() | 360 | cs = queue() |
365 | 361 | ||
366 | pvpd = skynet.localname(".pvpcross") | 362 | 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,18 +46,33 @@ function Activity:ctor(properties) | @@ -36,18 +46,33 @@ 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} |
42 | round = {"table", {}}, -- 记录活动到了第几轮 {id = roundnum} | 59 | round = {"table", {}}, -- 记录活动到了第几轮 {id = roundnum} |
43 | act4 = {"table", {}}, -- {0 = day, 1= -1, 2 = -1} == 签到活动 | 60 | act4 = {"table", {}}, -- {0 = day, 1= -1, 2 = -1} == 签到活动 |
44 | - act6 = {"table", {}}, -- {1 = 1, 2 = 1} == 付费签到活动 | 61 | + act6 = {"table", {}}, -- {0 = day, 1 = 1, 2 = 1} == 付费签到活动 |
45 | act8 = {"number", 0}, -- 充值返利 | 62 | act8 = {"number", 0}, -- 充值返利 |
46 | 63 | ||
47 | act11 = {"table", {}}, -- {0 = 贩卖数量, 1=1, 2=1} 贩卖周活动 1表示领取过该档位的奖励 | 64 | act11 = {"table", {}}, -- {0 = 贩卖数量, 1=1, 2=1} 贩卖周活动 1表示领取过该档位的奖励 |
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) |
@@ -236,38 +277,56 @@ function Activity:checkWeeklyAct(actType, notify, count, pool) | @@ -236,38 +277,56 @@ function Activity:checkWeeklyAct(actType, notify, count, pool) | ||
236 | local totalCnt = 0 | 277 | local totalCnt = 0 |
237 | local finishCnt = 0 | 278 | local finishCnt = 0 |
238 | local maxCondition = 0 | 279 | local maxCondition = 0 |
239 | - for k, cfg in pairs(csvdb[info.table] or {}) do | ||
240 | - totalCnt = totalCnt + 1 | ||
241 | - if maxCondition < cfg.condition1 then | ||
242 | - maxCondition = cfg.condition1 | ||
243 | - end | ||
244 | - if not curData[cfg.id] and curData[0] >= cfg.condition1 then | ||
245 | - if info.mailId then | 280 | + local flag = true |
281 | + while flag do | ||
282 | + --print("tatal number :", curData[0]) | ||
283 | + for i = 1, #csvdb[info.table] do | ||
284 | + local cfg = csvdb[info.table][i] | ||
285 | + --for k, cfg in pairs(csvdb[info.table] or {}) do | ||
286 | + totalCnt = totalCnt + 1 | ||
287 | + if maxCondition < cfg.condition1 then | ||
288 | + maxCondition = cfg.condition1 | ||
289 | + end | ||
290 | + --print("cur condition", cfg.condition1) | ||
291 | + if curData[0] < cfg.condition1 then | ||
292 | + flag = false | ||
293 | + break | ||
294 | + end | ||
295 | + | ||
296 | + --print(curData[0], cfg.condition1) | ||
297 | + if not curData[cfg.id] and curData[0] >= cfg.condition1 then | ||
298 | + if info.mailId then | ||
246 | 299 | ||
247 | - self.owner:log("activity", { | ||
248 | - activity_id = cfg.id, -- 活动ID(或活动指定任务的ID) | ||
249 | - activity_type = actType, -- 活动类型,见活动类型枚举表 | ||
250 | - activity_reward = cfg.reward:toNumMap(), -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} | ||
251 | - }) | 300 | + self.owner:log("activity", { |
301 | + activity_id = cfg.id, -- 活动ID(或活动指定任务的ID) | ||
302 | + activity_type = actType, -- 活动类型,见活动类型枚举表 | ||
303 | + activity_reward = cfg.reward:toNumMap(), -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} | ||
304 | + }) | ||
252 | 305 | ||
253 | - self.owner:sendMail(info.mailId, nil, cfg.reward, {cfg.condition1}) | ||
254 | - curData[cfg.id] = 1 | 306 | + self.owner:sendMail(info.mailId, nil, cfg.reward, {cfg.condition1}) |
307 | + curData[cfg.id] = 1 | ||
308 | + end | ||
309 | + end | ||
310 | + if curData[cfg.id] then | ||
311 | + finishCnt = finishCnt + 1 | ||
255 | end | 312 | end |
256 | end | 313 | end |
257 | - if curData[cfg.id] then | ||
258 | - finishCnt = finishCnt + 1 | ||
259 | - end | ||
260 | - end | ||
261 | - if totalCnt == finishCnt then | ||
262 | - roundData[actType] = curRound + 1 | ||
263 | - for k,v in pairs(curData) do | ||
264 | - if k == 0 then | ||
265 | - curData[k] = curData[0] >= maxCondition and curData[0] - maxCondition or 0 | ||
266 | - else | ||
267 | - curData[k] = nil | 314 | + if totalCnt == finishCnt then |
315 | + roundData[actType] = (roundData[actType] or 0) + 1 | ||
316 | + for k,v in pairs(curData) do | ||
317 | + if k == 0 then | ||
318 | + curData[k] = curData[0] >= maxCondition and curData[0] - maxCondition or 0 | ||
319 | + else | ||
320 | + curData[k] = nil | ||
321 | + end | ||
322 | + end | ||
323 | + --print("cur round ".. roundData[actType], ctrlData.condition) | ||
324 | + if roundData[actType] >= ctrlData.condition then | ||
325 | + curData[0] = maxCondition | ||
326 | + flag = false | ||
268 | end | 327 | end |
328 | + self:updateProperty({field = "round", value = roundData, notNotify = not notify}) | ||
269 | end | 329 | end |
270 | - self:updateProperty({field = "round", value = roundData, notNotify = not notify}) | ||
271 | end | 330 | end |
272 | self:updateActData(actType, curData, not notify) | 331 | self:updateActData(actType, curData, not notify) |
273 | end | 332 | end |
@@ -345,6 +404,11 @@ activityFunc[Activity.ActivityType.PaySignIn] = { | @@ -345,6 +404,11 @@ activityFunc[Activity.ActivityType.PaySignIn] = { | ||
345 | ["init"] = function(self, actType, isCrossDay, notify) | 404 | ["init"] = function(self, actType, isCrossDay, notify) |
346 | self:updateActData(actType, {}, not notify) | 405 | self:updateActData(actType, {}, not notify) |
347 | end, | 406 | end, |
407 | + ["crossDay"] = function(self, actType, notify) | ||
408 | + local curData = self:getActData(actType) | ||
409 | + curData[0] = (curData[0] or 0) + 1 | ||
410 | + self:updateActData(actType, curData, not notify) | ||
411 | + end, | ||
348 | ["close"] = function(self, actType, notify) | 412 | ["close"] = function(self, actType, notify) |
349 | self.owner.storeData:SetActGoodsFlag("paySignIn", 0) | 413 | self.owner.storeData:SetActGoodsFlag("paySignIn", 0) |
350 | 414 | ||
@@ -400,7 +464,8 @@ activityFunc[Activity.ActivityType.CalendaTask] = { | @@ -400,7 +464,8 @@ activityFunc[Activity.ActivityType.CalendaTask] = { | ||
400 | local towerInfo = role:getProperty("towerInfo") | 464 | local towerInfo = role:getProperty("towerInfo") |
401 | role:checkTaskEnter("TowerPass", {level = towerInfo.l}) | 465 | role:checkTaskEnter("TowerPass", {level = towerInfo.l}) |
402 | --"PvpWin" | 466 | --"PvpWin" |
403 | - role:checkTaskEnter("HangPass", {}) | 467 | + --role:checkTaskEnter("HangPass", {id = 0}) |
468 | + role:checkCalendaTask(true, 15, 3) | ||
404 | role:checkTaskEnter("HeroStarCollect", {}) | 469 | role:checkTaskEnter("HeroStarCollect", {}) |
405 | role:checkTaskEnter("RuneQualityCollect", {}) | 470 | role:checkTaskEnter("RuneQualityCollect", {}) |
406 | 471 | ||
@@ -409,12 +474,101 @@ activityFunc[Activity.ActivityType.CalendaTask] = { | @@ -409,12 +474,101 @@ activityFunc[Activity.ActivityType.CalendaTask] = { | ||
409 | -- end, | 474 | -- end, |
410 | } | 475 | } |
411 | 476 | ||
477 | +-- 兑换 | ||
478 | +activityFunc[Activity.ActivityType.Exchange] = { | ||
479 | + ["init"] = function(self, actType, isCrossDay, notify, actId) | ||
480 | + local actData = self:getActData(actType) or {} | ||
481 | + actData[actId] = {} | ||
482 | + self:updateActData(actType, actData, not notify) | ||
483 | + end, | ||
484 | + ["crossDay"] = function(self, actType, notify, actId) | ||
485 | + local actData = self:getActData(actType) or {} | ||
486 | + local lastTs = actData["ts"] or 0 | ||
487 | + local timeNow = skynet.timex() | ||
488 | + local cfg = csvdb["activity_ctrlCsv"][actId] | ||
489 | + if not cfg then return end | ||
490 | + local refreshTimes = cfg.condition2:toArray(false, "=") | ||
491 | + for i = 1, #refreshTimes do | ||
492 | + local rt = toUnixtime(refreshTimes[1]..string_format("%02x", RESET_TIME)) | ||
493 | + if timeNow >= rt and rt > lastTs then | ||
494 | + lastTs = rt | ||
495 | + actData = {} | ||
496 | + end | ||
497 | + end | ||
498 | + if next(actData) then | ||
499 | + actData["ts"] = lastTs | ||
500 | + self:updateActData(actType, actData, not notify) | ||
501 | + end | ||
502 | + end, | ||
503 | + ["close"] = function(self, actType, notify, actId) | ||
504 | + local actData = self:getActData(actType) or {} | ||
505 | + actData[actId] = nil | ||
506 | + self:updateActData(actType, actData, not notify) | ||
507 | + end, | ||
508 | +} | ||
509 | + | ||
510 | +-- 扭蛋机 | ||
511 | +activityFunc[Activity.ActivityType.Gachakon] = { | ||
512 | + ["init"] = function(self, actType, isCrossDay, notify, actId) | ||
513 | + self:updateActData(actType, {}, not notify) | ||
514 | + end, | ||
515 | + ["crossDay"] = function(self, actType, notify) | ||
516 | + self:updateActData(actType, {}, not notify) | ||
517 | + end, | ||
518 | +} | ||
519 | + | ||
520 | +-- 活动卡池 | ||
521 | +activityFunc[Activity.ActivityType.ActHeroPool] = { | ||
522 | + ["init"] = function(self, actType, isCrossDay, notify, actId) | ||
523 | + end, | ||
524 | + ["close"] = function(self, actType, notify, actId) | ||
525 | + local actData = self:getActData(actType) | ||
526 | + local cfg = csvdb["activity_ctrlCsv"][actId] | ||
527 | + if not cfg then return end | ||
528 | + actData[cfg.condition] = nil | ||
529 | + self:updateActData(actType, actData, not notify) | ||
530 | + end, | ||
531 | +} | ||
532 | + | ||
533 | +-- 挂机掉落 | ||
534 | +activityFunc[Activity.ActivityType.HangDrop] = { | ||
535 | + ["init"] = function(self, actType, isCrossDay, notify, actId) | ||
536 | + local actime = self:getProperty("actime") | ||
537 | + local ctime = self.owner:getProperty("ctime") | ||
538 | + local startTime = math.max(actime[actId], ctime) | ||
539 | + local actData = self:getActData(actType) or 0 | ||
540 | + local cfg = csvdb["activity_putCsv"][actId] | ||
541 | + if not cfg then return end | ||
542 | + actData = startTime | ||
543 | + self:updateActData(actType, actData, not notify) | ||
544 | + end | ||
545 | +} | ||
546 | + | ||
547 | +--ChallengeLevel | ||
548 | +activityFunc[Activity.ActivityType.ChallengeLevel] = { | ||
549 | + ["init"] = function(self, actType, isCrossDay, notify, actId) | ||
550 | + self:getBattleTicket(actId) | ||
551 | + end, | ||
552 | + ["login"] = function(self, actType, actId) | ||
553 | + self:getBattleTicket(actId) | ||
554 | + end | ||
555 | +} | ||
556 | + | ||
557 | +function Activity:onLoginActivity(actId) | ||
558 | + local actData = csvdb["activity_ctrlCsv"][actId] | ||
559 | + if not actData then return end | ||
560 | + local actType = actData.showType | ||
561 | + if activityFunc[actType] and activityFunc[actType]['login'] then | ||
562 | + activityFunc[actType]["login"](self, actType, actId) | ||
563 | + end | ||
564 | +end | ||
565 | + | ||
412 | function Activity:initActivity(actId, isCrossDay, notify) | 566 | function Activity:initActivity(actId, isCrossDay, notify) |
413 | local actData = csvdb["activity_ctrlCsv"][actId] | 567 | local actData = csvdb["activity_ctrlCsv"][actId] |
414 | if not actData then return end | 568 | if not actData then return end |
415 | local actType = actData.showType | 569 | local actType = actData.showType |
416 | - if activityFunc[actType] and activityFunc[actType]['close'] then | ||
417 | - activityFunc[actType]["init"](self, actType, isCrossDay, notify) | 570 | + if activityFunc[actType] and activityFunc[actType]['init'] then |
571 | + activityFunc[actType]["init"](self, actType, isCrossDay, notify, actId) | ||
418 | end | 572 | end |
419 | end | 573 | end |
420 | 574 | ||
@@ -423,10 +577,13 @@ function Activity:closeActivity(actId, notify, notUpdateAct) | @@ -423,10 +577,13 @@ function Activity:closeActivity(actId, notify, notUpdateAct) | ||
423 | if not actData then return end | 577 | if not actData then return end |
424 | local actType = actData.showType | 578 | local actType = actData.showType |
425 | if activityFunc[actType] and activityFunc[actType]['close'] then | 579 | if activityFunc[actType] and activityFunc[actType]['close'] then |
426 | - activityFunc[actType]["close"](self, actType, notify) | 580 | + activityFunc[actType]["close"](self, actType, notify, actId) |
581 | + self:recycleActItem(actId) | ||
427 | end | 582 | end |
428 | if Activity.schema["act".. actType] then | 583 | if Activity.schema["act".. actType] then |
429 | - self:updateActData(actType, Activity.schema["act" .. actType][2], not notify or notUpdateAct) | 584 | + if not Activity.schema["act" .. actType][3] then |
585 | + self:updateActData(actType, Activity.schema["act" .. actType][2], not notify or notUpdateAct) | ||
586 | + end | ||
430 | end | 587 | end |
431 | end | 588 | end |
432 | 589 | ||
@@ -436,7 +593,7 @@ function Activity:refreshDailyData(notify) | @@ -436,7 +593,7 @@ function Activity:refreshDailyData(notify) | ||
436 | if status and actData then | 593 | if status and actData then |
437 | local actType = actData.showType | 594 | local actType = actData.showType |
438 | if activityFunc[actType] and activityFunc[actType]['crossDay'] then | 595 | if activityFunc[actType] and activityFunc[actType]['crossDay'] then |
439 | - activityFunc[actType]["crossDay"](self, actType, notify) | 596 | + activityFunc[actType]["crossDay"](self, actType, notify, actId) |
440 | end | 597 | end |
441 | end | 598 | end |
442 | end | 599 | end |
@@ -453,8 +610,8 @@ end | @@ -453,8 +610,8 @@ end | ||
453 | -- 获取此次挂机掉落翻倍时长 | 610 | -- 获取此次挂机掉落翻倍时长 |
454 | function Activity:getActHangDoubleTime(lastTs, nowTs) | 611 | function Activity:getActHangDoubleTime(lastTs, nowTs) |
455 | local type = "DoubleDrop" | 612 | local type = "DoubleDrop" |
456 | - local actId = checkActivityType(type) | ||
457 | - local isOpen = self:isOpen(type) | 613 | + --local actId = checkActivityType(type) |
614 | + local isOpen, actId = self:isOpen(type) | ||
458 | local openTs = self:getProperty("actime")[actId] or 0 | 615 | local openTs = self:getProperty("actime")[actId] or 0 |
459 | local timeNow = skynet.timex() | 616 | local timeNow = skynet.timex() |
460 | lastTs = math.max(lastTs, openTs) | 617 | lastTs = math.max(lastTs, openTs) |
@@ -529,5 +686,122 @@ function Activity:getPaySignReward() | @@ -529,5 +686,122 @@ function Activity:getPaySignReward() | ||
529 | --SendPacket(actionCodes.Activity_actPaySignRpc, MsgPack.pack(role:packReward(reward, change))) | 686 | --SendPacket(actionCodes.Activity_actPaySignRpc, MsgPack.pack(role:packReward(reward, change))) |
530 | end | 687 | end |
531 | 688 | ||
689 | +-- 回收活动道具 | ||
690 | +function Activity:recycleActItem(actId) | ||
691 | + local role = self.owner | ||
692 | + local actCfg = csvdb["activity_ctrlCsv"][actId] | ||
693 | + if not actCfg then return end | ||
694 | + local gift = {} | ||
695 | + local costs = {} | ||
696 | + for _, arr in ipairs(actCfg.recycle:toTableArray(true)) do | ||
697 | + local fromId, toId, toNum = arr[1], arr[2], arr[3] | ||
698 | + local itemCount = role:getItemCount(fromId) | ||
699 | + if itemCount > 0 then | ||
700 | + costs[fromId] = (costs[fromId] or 0) + itemCount | ||
701 | + gift[toId] = toNum * itemCount | ||
702 | + end | ||
703 | + end | ||
704 | + if next(costs) then | ||
705 | + local itemStr = "" | ||
706 | + for k, v in pairs(costs) do | ||
707 | + if itemStr ~= "" then | ||
708 | + itemStr = itemStr .. " " | ||
709 | + end | ||
710 | + itemStr = itemStr .. k .. "=" .. v | ||
711 | + end | ||
712 | + role:costItems(costs, {log = {desc = "actRecycle"}}) | ||
713 | + role:sendMail(actCfg.recycle_email, nil, gift, {itemStr}) | ||
714 | + end | ||
715 | +end | ||
716 | + | ||
717 | +-- 活动挑战关卡计算门票 | ||
718 | +function Activity:getBattleTicket(actId) | ||
719 | + local role = self.owner | ||
720 | + local createTs = role:getProperty("ctime") | ||
721 | + local actCfg = csvdb["activity_ctrlCsv"][actId] | ||
722 | + if not actCfg then return 0 end | ||
723 | + | ||
724 | + local actStartTime = 0 | ||
725 | + local openTimes = actCfg.time:toArray(false, "=") | ||
726 | + actStartTime = toUnixtime(openTimes[1]..string_format("%02x", RESET_TIME)) | ||
727 | + local actData = self:getActData("ChallengeLevel") or {} | ||
728 | + local startTs = actData["ts"] or math.max(actStartTime, createTs) | ||
729 | + local timeNow = skynet.timex() | ||
730 | + local modify = false | ||
731 | + local arr = actCfg.condition2:toArray(true, "=") | ||
732 | + | ||
733 | + local ticketId, init, limit, duration = arr[1] or 0, arr[2] or 0, arr[3] or 0, arr[4] or 10000 | ||
734 | + | ||
735 | + local count = actData["ticket"] or init | ||
736 | + local add = math.max(math.floor((timeNow - startTs) / (duration * 60)), 0) | ||
737 | + | ||
738 | + local newCount= math.min(count + add, limit) | ||
739 | + if newCount ~= count or newCount >= limit then | ||
740 | + modify = true | ||
741 | + end | ||
742 | + add = newCount - count | ||
743 | + | ||
744 | + if modify or not next(actData) then | ||
745 | + actData["ticket"] = newCount | ||
746 | + actData["ts"] = newCount >= limit and timeNow or (startTs + add * duration * 60) | ||
747 | + self:updateActData("ChallengeLevel", actData) | ||
748 | + end | ||
749 | +end | ||
750 | + | ||
751 | +activityFunc[Activity.ActivityType.ActShopGoods] = { | ||
752 | + ["init"] = function(self, actType, isCrossDay, notify, actId) | ||
753 | + end, | ||
754 | + ["close"] = function(self, actType, notify) | ||
755 | + local rechargeRecord = self.owner.storeData:getProperty("payR") | ||
756 | + for id, cfg in pairs(csvdb["shop_rechargeCsv"]) do | ||
757 | + if cfg.shop == 3 and cfg.type == ShopPackType.ActShopPack then | ||
758 | + rechargeRecord[id] = nil | ||
759 | + end | ||
760 | + end | ||
761 | + self.owner.storeData:updateProperty({field="payR", value=rechargeRecord}) | ||
762 | + end, | ||
763 | +} | ||
764 | + | ||
765 | + | ||
766 | + | ||
767 | +activityFunc[Activity.ActivityType.Crisis] = { | ||
768 | + ["check"] = function(self, actType, notify, atype, count) -- 检查 | ||
769 | + count = count or 1 | ||
770 | + local isOpen, actId = self:isOpen(actType) | ||
771 | + local actData = self:getActData(actType) or {} | ||
772 | + actData.task = actData.task or {} | ||
773 | + local change = false | ||
774 | + local actCsv = csvdb["activity_crisisCsv"][actId] | ||
775 | + for id, actSet in pairs(actCsv) do | ||
776 | + if actSet.type == atype then | ||
777 | + local status = actData.task[id] or 0 | ||
778 | + status = status + count | ||
779 | + if status >= actSet.condition1 then | ||
780 | + local reward | ||
781 | + if actSet.loop == 1 then | ||
782 | + local rcount = math.floor(status / actSet.condition1) | ||
783 | + reward = actSet.reward:toNumMap() | ||
784 | + for itemId, itemC in pairs(reward) do | ||
785 | + reward[itemId] = itemC * rcount | ||
786 | + end | ||
787 | + status = status % actSet.condition1 | ||
788 | + else | ||
789 | + reward = actSet.reward | ||
790 | + status = -1 | ||
791 | + end | ||
792 | + | ||
793 | + self.owner:award(reward, {log = {desc = "activity_crisis"}, notNotify = not notify}) | ||
794 | + end | ||
795 | + actData.task[id] = status | ||
796 | + change = true | ||
797 | + end | ||
798 | + end | ||
799 | + if change then | ||
800 | + -- 更新下排行榜 | ||
801 | + self.owner:updateRankCommon(RANK_TYPE.ActCrisis, self.owner:getItemCount(ItemId.CrisisScore)) | ||
802 | + self:updateActData(actType, actData) | ||
803 | + end | ||
804 | + end, | ||
805 | +} | ||
532 | 806 | ||
533 | return Activity | 807 | 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 |
@@ -62,17 +62,23 @@ function Email:data() | @@ -62,17 +62,23 @@ function Email:data() | ||
62 | end | 62 | end |
63 | 63 | ||
64 | if attachments == "" and emailData.attachment ~= "" then | 64 | if attachments == "" and emailData.attachment ~= "" then |
65 | - attachments = emailData.attachment:format(table.unpack(rewardPms)) | 65 | + if next(rewardPms) then |
66 | + attachments = emailData.attachment:format(table.unpack(rewardPms)) | ||
67 | + else | ||
68 | + attachments = emailData.attachment | ||
69 | + end | ||
66 | end | 70 | end |
67 | end | 71 | end |
68 | 72 | ||
69 | return { | 73 | return { |
74 | + cfgId = emailId, | ||
70 | id = self:getProperty("id"), | 75 | id = self:getProperty("id"), |
71 | status = self:getProperty("status"), | 76 | status = self:getProperty("status"), |
72 | createtime = self:getProperty("createtime"), | 77 | createtime = self:getProperty("createtime"), |
73 | title = title, | 78 | title = title, |
74 | stitle = stitle, | 79 | stitle = stitle, |
75 | content = content, | 80 | content = content, |
81 | + contentPms = contentPms, | ||
76 | attachments = attachments, | 82 | attachments = attachments, |
77 | } | 83 | } |
78 | end | 84 | end |
src/models/Hero.lua
@@ -15,6 +15,7 @@ Hero.schema = { | @@ -15,6 +15,7 @@ Hero.schema = { | ||
15 | -- loveL = {"number", 0}, --好感度等级 | 15 | -- loveL = {"number", 0}, --好感度等级 |
16 | equip = {"string",""}, --装备 type=level | 16 | equip = {"string",""}, --装备 type=level |
17 | rune = {"string",""}, --零件 type=id | 17 | rune = {"string",""}, --零件 type=id |
18 | + faith = {"number", 0}, -- 信赖 | ||
18 | } | 19 | } |
19 | 20 | ||
20 | function Hero:ctor( properties ) | 21 | function Hero:ctor( properties ) |
@@ -102,6 +103,7 @@ function Hero:data() | @@ -102,6 +103,7 @@ function Hero:data() | ||
102 | -- loveL = self:getProperty("loveL"), | 103 | -- loveL = self:getProperty("loveL"), |
103 | equip = self:getProperty("equip"), | 104 | equip = self:getProperty("equip"), |
104 | rune = self:getProperty("rune"), | 105 | rune = self:getProperty("rune"), |
106 | + faith = self:getProperty("faith") | ||
105 | } | 107 | } |
106 | end | 108 | end |
107 | 109 | ||
@@ -113,4 +115,8 @@ function Hero:getRare() | @@ -113,4 +115,8 @@ function Hero:getRare() | ||
113 | return csvdb["unitCsv"][self:getProperty("type")].rare | 115 | return csvdb["unitCsv"][self:getProperty("type")].rare |
114 | end | 116 | end |
115 | 117 | ||
118 | +function Hero:getPosition() | ||
119 | + return csvdb["unitCsv"][self:getProperty("type")].position | ||
120 | +end | ||
121 | + | ||
116 | return Hero | 122 | return Hero |
117 | \ No newline at end of file | 123 | \ No newline at end of file |
src/models/HeroPlugin.lua
@@ -48,30 +48,29 @@ function HeroPlugin.bind(Hero) | @@ -48,30 +48,29 @@ function HeroPlugin.bind(Hero) | ||
48 | local breakL = params.breakL or self:getProperty("breakL") | 48 | local breakL = params.breakL or self:getProperty("breakL") |
49 | local wakeL = params.wakeL or self:getProperty("wakeL") | 49 | local wakeL = params.wakeL or self:getProperty("wakeL") |
50 | local talent = params.talent or self:getProperty("talent") | 50 | local talent = params.talent or self:getProperty("talent") |
51 | - | 51 | + local heroCfgId = self:getProperty("type") |
52 | --天赋 | 52 | --天赋 |
53 | local talentAttrS = {} | 53 | local talentAttrS = {} |
54 | 54 | ||
55 | -- 四个基础属性 | 55 | -- 四个基础属性 |
56 | local curData = csvdb["unit_talentCsv"][talent:getv(0, 1)] | 56 | local curData = csvdb["unit_talentCsv"][talent:getv(0, 1)] |
57 | + local curTalentLvl = 0 | ||
57 | if not curData then -- 已经满阶段了 | 58 | if not curData then -- 已经满阶段了 |
58 | - curData = csvdb["unit_talentCsv"][#csvdb["unit_talentCsv"]] | ||
59 | - local strength = curData[#curData].strength | ||
60 | - for i = 1, 4 do | ||
61 | - talentAttrS[TalentAttsEnumEx[i]] = (talentAttrS[TalentAttsEnumEx[i]] or 0) + strength | ||
62 | - end | 59 | + local cfgName = "unit_talent_"..heroCfgId.."Csv" |
60 | + curData = csvdb[cfgName][#csvdb[cfgName]] | ||
63 | else | 61 | else |
64 | - for i = 1, 4 do --4个天赋 | ||
65 | - talentAttrS[TalentAttsEnumEx[i]] = (talentAttrS[TalentAttsEnumEx[i]] or 0) + curData[talent:getv(i, 0)].strength | ||
66 | - end | 62 | + curTalentLvl = talent:getv(1, 1) |
67 | end | 63 | end |
68 | - --阶段属性 | ||
69 | - for i = 1, (talent:getv(0, 1) - 1) do | ||
70 | - local curData = csvdb["unit_talentCsv"][i] | ||
71 | - local effect = curData[#curData].effect:toArray(true, "=") | ||
72 | - talentAttrS[AttsEnumEx[effect[1]]] = (talentAttrS[AttsEnumEx[effect[1]]] or 0) + effect[2] | 64 | + for lvl, cfg in pairs(curData) do |
65 | + if lvl < curTalentLvl or curTalentLvl == 0 then | ||
66 | + if cfg.effect ~= 99 then | ||
67 | + local curVal = talentAttrS[cfg.effect] or 0 | ||
68 | + if curVal < cfg.strength then | ||
69 | + talentAttrS[cfg.effect] = cfg.strength | ||
70 | + end | ||
71 | + end | ||
72 | + end | ||
73 | end | 73 | end |
74 | - | ||
75 | 74 | ||
76 | for _, attrName in pairs(AttsEnumEx) do | 75 | for _, attrName in pairs(AttsEnumEx) do |
77 | if talentAttrS[attrName] then | 76 | if talentAttrS[attrName] then |
@@ -79,6 +78,22 @@ function HeroPlugin.bind(Hero) | @@ -79,6 +78,22 @@ function HeroPlugin.bind(Hero) | ||
79 | end | 78 | end |
80 | end | 79 | end |
81 | 80 | ||
81 | + -- 信赖属性 | ||
82 | + local faithAttr = {} | ||
83 | + local faith = self:getProperty("faith") | ||
84 | + local faithConfig = csvdb["unit_trustCsv"] | ||
85 | + for lvl = 1, #faithConfig do | ||
86 | + if faith >= faithConfig[lvl].exp then | ||
87 | + local add = faithConfig[lvl]["position_"..unitData.position]:toArray(true, "=") | ||
88 | + faithAttr[add[1]] = (faithAttr[add[1]] or 0) + add[2] | ||
89 | + end | ||
90 | + end | ||
91 | + for _, attrName in pairs(AttsEnumEx) do | ||
92 | + if faithAttr[attrName] then | ||
93 | + faithAttr[attrName] = addAttr(unitData[attrName], faithAttr[attrName], 1, attrName) | ||
94 | + end | ||
95 | + end | ||
96 | + | ||
82 | local attrs = {} | 97 | local attrs = {} |
83 | for _, attName in pairs(AttsEnumEx) do | 98 | for _, attName in pairs(AttsEnumEx) do |
84 | attrs[attName] = unitData[attName] or 0 | 99 | attrs[attName] = unitData[attName] or 0 |
@@ -90,7 +105,7 @@ function HeroPlugin.bind(Hero) | @@ -90,7 +105,7 @@ function HeroPlugin.bind(Hero) | ||
90 | for attr, value in pairs(attrs) do | 105 | for attr, value in pairs(attrs) do |
91 | attrs[attr] = attrs[attr] + addAttr(attrs[attr], lData[attr .. "Level"], 1, attr) | 106 | attrs[attr] = attrs[attr] + addAttr(attrs[attr], lData[attr .. "Level"], 1, attr) |
92 | attrs[attr] = attrs[attr] + addAttr(attrs[attr], blData[attr .. "Level"], 1, attr) | 107 | attrs[attr] = attrs[attr] + addAttr(attrs[attr], blData[attr .. "Level"], 1, attr) |
93 | - attrs[attr] = attrs[attr] + addAttr(attrs[attr], wData[attr .. "Level"], 1, attr) + (talentAttrS[attr] or 0) | 108 | + attrs[attr] = attrs[attr] + addAttr(attrs[attr], wData[attr .. "Level"], 1, attr) + (talentAttrS[attr] or 0) + (faithAttr[attr] or 0) |
94 | end | 109 | end |
95 | 110 | ||
96 | return attrs | 111 | return attrs |
@@ -111,11 +126,11 @@ function HeroPlugin.bind(Hero) | @@ -111,11 +126,11 @@ function HeroPlugin.bind(Hero) | ||
111 | end | 126 | end |
112 | 127 | ||
113 | -- 羁绊加成 | 128 | -- 羁绊加成 |
114 | - if params.activeRelation then | ||
115 | - for k, attName in pairs(AttsEnumEx) do | ||
116 | - attrs[attName] = attrs[attName] + addAttr(attrs[attName], params.activeRelation[attName], 1, attName) | ||
117 | - end | ||
118 | - 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 | ||
119 | return attrs | 134 | return attrs |
120 | end | 135 | end |
121 | 136 | ||
@@ -209,8 +224,10 @@ function HeroPlugin.bind(Hero) | @@ -209,8 +224,10 @@ function HeroPlugin.bind(Hero) | ||
209 | 224 | ||
210 | 225 | ||
211 | -- 战斗力(当前属性)= POWER[(生命 + 防御 * 7 + 闪避 * 4)*(攻击*4 + 命中 * 2)*(1 + 暴击几率/100 * 暴击伤害/100)* 攻击速度 / 60000 ,0.8 ] | 226 | -- 战斗力(当前属性)= POWER[(生命 + 防御 * 7 + 闪避 * 4)*(攻击*4 + 命中 * 2)*(1 + 暴击几率/100 * 暴击伤害/100)* 攻击速度 / 60000 ,0.8 ] |
212 | - function Hero:getBattleValue(activeRelation) -- isReal包括队伍加成 | ||
213 | - 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() | ||
214 | 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 |
215 | return math.floor(battleValue) | 232 | return math.floor(battleValue) |
216 | end | 233 | end |
@@ -237,6 +254,37 @@ function HeroPlugin.bind(Hero) | @@ -237,6 +254,37 @@ function HeroPlugin.bind(Hero) | ||
237 | return level | 254 | return level |
238 | end | 255 | end |
239 | 256 | ||
257 | + -- 天赋获得的技能 | ||
258 | + function Hero:getTalentSkill() | ||
259 | + local TalentEnum = { | ||
260 | + [1] = 1, -- 血量 | ||
261 | + [2] = 2, -- 攻击 | ||
262 | + [3] = 3, -- 物理防御 | ||
263 | + [4] = 4, -- 命中 | ||
264 | + [5] = 5, -- 闪避 | ||
265 | + } | ||
266 | + local talentCsv = csvdb["unit_talent_" .. self:getProperty("type") .. "Csv"] | ||
267 | + local curLv = self:getProperty("talent"):getv(1,1) - 1 | ||
268 | + local curRan = self:getProperty("talent"):getv(0,1) | ||
269 | + local skills = {} | ||
270 | + for ran, data in ipairs(talentCsv) do | ||
271 | + if ran <= curRan then | ||
272 | + for lv, value in ipairs(data) do | ||
273 | + if ran < curRan or lv <= curLv then | ||
274 | + if not TalentEnum[value.effect] then | ||
275 | + skills[value.strength] = true | ||
276 | + end | ||
277 | + else | ||
278 | + break | ||
279 | + end | ||
280 | + end | ||
281 | + else | ||
282 | + break | ||
283 | + end | ||
284 | + end | ||
285 | + return skills | ||
286 | + end | ||
287 | + | ||
240 | function Hero:getSkillData(idx) | 288 | function Hero:getSkillData(idx) |
241 | local unitData = csvdb["unitCsv"][self:getProperty("type")] | 289 | local unitData = csvdb["unitCsv"][self:getProperty("type")] |
242 | if idx == 1 then | 290 | if idx == 1 then |
@@ -296,6 +344,27 @@ function HeroPlugin.bind(Hero) | @@ -296,6 +344,27 @@ function HeroPlugin.bind(Hero) | ||
296 | end | 344 | end |
297 | return | 345 | return |
298 | end | 346 | end |
347 | + | ||
348 | + -- 添加英雄信赖 | ||
349 | + function Hero:addHeroFaith(exp) | ||
350 | + local faith = self:getProperty("faith") | ||
351 | + local config = csvdb["unit_trustCsv"] | ||
352 | + local star = self:getProperty("wakeL") | ||
353 | + local tmpExp = faith + exp | ||
354 | + for lvl = 1, #config do | ||
355 | + if star < config[lvl].star then | ||
356 | + break | ||
357 | + end | ||
358 | + if tmpExp < config[lvl].exp then | ||
359 | + faith = tmpExp | ||
360 | + break | ||
361 | + else | ||
362 | + faith = config[lvl].exp | ||
363 | + end | ||
364 | + end | ||
365 | + self:setProperty("faith", faith) | ||
366 | + end | ||
367 | + | ||
299 | end | 368 | end |
300 | 369 | ||
301 | 370 |
src/models/Role.lua
@@ -99,11 +99,11 @@ Role.schema = { | @@ -99,11 +99,11 @@ 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} |
106 | - hangTeam = {"table", {}}, -- 挂机队伍 | ||
107 | hangTS = {"table", {}}, -- 挂机队伍他人可读的队伍信息 | 107 | hangTS = {"table", {}}, -- 挂机队伍他人可读的队伍信息 |
108 | hangTB = {"table", {}}, -- 挂机队伍他人可用的战斗信息mao | 108 | hangTB = {"table", {}}, -- 挂机队伍他人可用的战斗信息mao |
109 | hangTBV = {"number", 0}, -- 挂机队伍他人可用的战斗力 | 109 | hangTBV = {"number", 0}, -- 挂机队伍他人可用的战斗力 |
@@ -111,8 +111,11 @@ Role.schema = { | @@ -111,8 +111,11 @@ Role.schema = { | ||
111 | hangInfo = {"table", {}}, -- 当前挂机信息 | 111 | hangInfo = {"table", {}}, -- 当前挂机信息 |
112 | hangBag = {"table", {}}, -- 背包 | 112 | hangBag = {"table", {}}, -- 背包 |
113 | hangBagLimit = {"number", globalCsv.idle_field_origin}, --背包上限 | 113 | hangBagLimit = {"number", globalCsv.idle_field_origin}, --背包上限 |
114 | - bTeam = {"table", {}}, -- 奖励副本队伍 | ||
115 | - heroFormate = {"table", {}}, -- 自选编队 {adv={}, hang={}} | 114 | + hangTeams = {"table", {}}, -- pve自选编队 |
115 | + teamIndex = {"table", {}}, -- 各个系统使用的编队索引 type->index 见TeamSystemType | ||
116 | + advTeams = {"table", {}}, -- 拾荒自选编队 | ||
117 | + | ||
118 | + bonusStar = {"table", {}}, -- 奖励关卡 通关星星 {[id] = 1} 三个二进制位 表示三个星 从低到高 (1 << 0) (1 << 1) (1 << 2) 满星 (1 << 3) - 1 | ||
116 | 119 | ||
117 | --引导相关 | 120 | --引导相关 |
118 | newerGuide = {"string","1=1"}, -- 新手引导 master=slave | 121 | newerGuide = {"string","1=1"}, -- 新手引导 master=slave |
@@ -143,7 +146,6 @@ Role.schema = { | @@ -143,7 +146,6 @@ Role.schema = { | ||
143 | boxL = {"table", {}}, -- boxList 正开启的箱子 -- {[1] = {id = 1010, gem = 101, time = 1313}} | 146 | boxL = {"table", {}}, -- boxList 正开启的箱子 -- {[1] = {id = 1010, gem = 101, time = 1313}} |
144 | 147 | ||
145 | towerInfo = {"table", {c = globalCsv.tower_count_limit, l = 1}}, -- 当天爬塔消耗的次数 -- {t = time, c = count, l = layer, k = battleKey} | 148 | towerInfo = {"table", {c = globalCsv.tower_count_limit, l = 1}}, -- 当天爬塔消耗的次数 -- {t = time, c = count, l = layer, k = battleKey} |
146 | - towerF = {"table", {}}, -- 爬塔阵容 | ||
147 | 149 | ||
148 | spTask = {"table", {}}, -- 特殊任务 -- {id = status} | 150 | spTask = {"table", {}}, -- 特殊任务 -- {id = status} |
149 | 151 | ||
@@ -166,7 +168,8 @@ Role.schema = { | @@ -166,7 +168,8 @@ Role.schema = { | ||
166 | repayMaxC = {"number", 0}, -- 招募保底英雄领取次数 100一次 | 168 | repayMaxC = {"number", 0}, -- 招募保底英雄领取次数 100一次 |
167 | floorHero = {"table", {}}, -- 招募保底 -- {[poolId] = count} | 169 | floorHero = {"table", {}}, -- 招募保底 -- {[poolId] = count} |
168 | ssrUp = {"table", {}}, -- ssr up -- {[poolId] = count} | 170 | ssrUp = {"table", {}}, -- ssr up -- {[poolId] = count} |
169 | - newerDraw = {"table", {}}, -- 新手池子 {N, 1} 抽了多少次, 是否出了ssr | 171 | + newerDraw = {"number", 0}, -- 新手池子抽卡次数 |
172 | + wishPool = {"table", {}}, -- 心愿池子 | ||
170 | 173 | ||
171 | sudoku = {"table", {}}, -- 九宫格 {[-1] = 1, task = {[1] = {}, [2] = {}}}} -- [-1] 阶段 如果为 -1 关闭(都做完了), task 当前阶段任务进度, reward 连串奖励领取情况 | 174 | sudoku = {"table", {}}, -- 九宫格 {[-1] = 1, task = {[1] = {}, [2] = {}}}} -- [-1] 阶段 如果为 -1 关闭(都做完了), task 当前阶段任务进度, reward 连串奖励领取情况 |
172 | sign = {"table", {}}, -- 签到记录 {[1] = 20181029} | 175 | sign = {"table", {}}, -- 签到记录 {[1] = 20181029} |
@@ -179,6 +182,7 @@ Role.schema = { | @@ -179,6 +182,7 @@ Role.schema = { | ||
179 | feedback = {"table", {}}, -- 反馈相关信息 {flag = false, count = 0} flag是否评论过,count 提示次数 | 182 | feedback = {"table", {}}, -- 反馈相关信息 {flag = false, count = 0} flag是否评论过,count 提示次数 |
180 | 183 | ||
181 | calTask = {"table", {}}, -- 英雄令活动 日历任务活动 | 184 | calTask = {"table", {}}, -- 英雄令活动 日历任务活动 |
185 | + radioTask = {"table", {}}, -- 电台任务 {id = {time=end_ts,heros=heros}} 表crusadeCsv | ||
182 | } | 186 | } |
183 | 187 | ||
184 | 188 | ||
@@ -354,11 +358,14 @@ function Role:data() | @@ -354,11 +358,14 @@ function Role:data() | ||
354 | 358 | ||
355 | hangPass = self:getProperty("hangPass"), | 359 | hangPass = self:getProperty("hangPass"), |
356 | hangGift = self:getProperty("hangGift"), | 360 | hangGift = self:getProperty("hangGift"), |
357 | - hangTeam = self:getProperty("hangTeam"), | ||
358 | hangInfo = self:getProperty("hangInfo"), | 361 | hangInfo = self:getProperty("hangInfo"), |
359 | hangBag = self:getProperty("hangBag"), | 362 | hangBag = self:getProperty("hangBag"), |
360 | hangBagLimit = self:getProperty("hangBagLimit"), | 363 | hangBagLimit = self:getProperty("hangBagLimit"), |
361 | - bTeam = self:getProperty("bTeam"), | 364 | + hangTeams = self:getProperty("hangTeams"), |
365 | + teamIndex = self:getProperty("teamIndex"), | ||
366 | + advTeams = self:getProperty("advTeams"), | ||
367 | + | ||
368 | + bonusStar = self:getProperty("bonusStar"), | ||
362 | 369 | ||
363 | newerGuide = self:getProperty("newerGuide"), | 370 | newerGuide = self:getProperty("newerGuide"), |
364 | funcGuide = self:getProperty("funcGuide"), | 371 | funcGuide = self:getProperty("funcGuide"), |
@@ -374,7 +381,6 @@ function Role:data() | @@ -374,7 +381,6 @@ function Role:data() | ||
374 | equips = self:getProperty("equips"), | 381 | equips = self:getProperty("equips"), |
375 | boxL = self:getProperty("boxL"), | 382 | boxL = self:getProperty("boxL"), |
376 | towerInfo = self:getProperty("towerInfo"), | 383 | towerInfo = self:getProperty("towerInfo"), |
377 | - towerF = self:getProperty("towerF"), | ||
378 | spTask = self:getProperty("spTask"), | 384 | spTask = self:getProperty("spTask"), |
379 | dTask = self:getProperty("dTask"), | 385 | dTask = self:getProperty("dTask"), |
380 | wTask = self:getProperty("wTask"), | 386 | wTask = self:getProperty("wTask"), |
@@ -390,6 +396,7 @@ function Role:data() | @@ -390,6 +396,7 @@ function Role:data() | ||
390 | repayHero = self:getProperty("repayHero"), | 396 | repayHero = self:getProperty("repayHero"), |
391 | newerDraw = self:getProperty("newerDraw"), | 397 | newerDraw = self:getProperty("newerDraw"), |
392 | floorHero = self:getProperty("floorHero"), | 398 | floorHero = self:getProperty("floorHero"), |
399 | + wishPool = self:getProperty("wishPool"), | ||
393 | 400 | ||
394 | sudoku = self:getProperty("sudoku"), | 401 | sudoku = self:getProperty("sudoku"), |
395 | sign = self:getProperty("sign"), | 402 | sign = self:getProperty("sign"), |
@@ -401,6 +408,7 @@ function Role:data() | @@ -401,6 +408,7 @@ function Role:data() | ||
401 | feedback = self:getProperty("feedback"), | 408 | feedback = self:getProperty("feedback"), |
402 | ctime = self:getProperty("ctime"), | 409 | ctime = self:getProperty("ctime"), |
403 | calTask = self:getProperty("calTask"), | 410 | calTask = self:getProperty("calTask"), |
411 | + radioTask = self:getProperty("radioTask"), | ||
404 | } | 412 | } |
405 | end | 413 | end |
406 | 414 |
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") |
@@ -57,8 +58,8 @@ function Role:checkBattle(battleType, params) | @@ -57,8 +58,8 @@ function Role:checkBattle(battleType, params) | ||
57 | end | 58 | end |
58 | end, | 59 | end, |
59 | tower = function() | 60 | tower = function() |
60 | - local towerF = self:getProperty("towerF") | ||
61 | - for slot, hero in pairs(self:getTeamHerosInfo(towerF.heros)) do | 61 | + local towerF = self:getTeamFormatByType(TeamSystemType.Tower) |
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) |
@@ -72,8 +73,8 @@ function Role:checkBattle(battleType, params) | @@ -72,8 +73,8 @@ function Role:checkBattle(battleType, params) | ||
72 | end | 73 | end |
73 | end, | 74 | end, |
74 | bonus = function() | 75 | bonus = function() |
75 | - local bTeam = self:getProperty("bTeam") | ||
76 | - for slot, hero in pairs(self:getTeamHerosInfo(bTeam.heros)) do | 76 | + local bTeam = self:getTeamFormatByType(TeamSystemType.BonusBattle) |
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, -- 食材获得 |
@@ -107,6 +117,8 @@ local ItemReason = { | @@ -107,6 +117,8 @@ local ItemReason = { | ||
107 | unlockPool = 1208, -- 解锁英雄定向抽卡池 | 117 | unlockPool = 1208, -- 解锁英雄定向抽卡池 |
108 | downloadCv = 1209, -- 下载 cv包奖励 | 118 | downloadCv = 1209, -- 下载 cv包奖励 |
109 | refer = 1210, -- 穿戴 | 119 | refer = 1210, -- 穿戴 |
120 | + itemCompose = 1211, -- 天赋道具合成 | ||
121 | + radioQuest = 1212, -- 电台任务奖励 | ||
110 | 122 | ||
111 | -- pvp | 123 | -- pvp |
112 | pvpCHead = 1301, -- pvp 跨服竞技场头像 | 124 | pvpCHead = 1301, -- pvp 跨服竞技场头像 |
@@ -242,13 +254,6 @@ local MethodType = { | @@ -242,13 +254,6 @@ local MethodType = { | ||
242 | hero_break_result = "json", -- 英雄突破效果,可记录效果ID,或json格式记录提升效果,{攻击:20,闪避:20,……..} | 254 | hero_break_result = "json", -- 英雄突破效果,可记录效果ID,或json格式记录提升效果,{攻击:20,闪避:20,……..} |
243 | hero_break_level = true, -- 英雄突破后等级上限 | 255 | hero_break_level = true, -- 英雄突破后等级上限 |
244 | }, | 256 | }, |
245 | - hero_talent = { --英雄天赋升级 | ||
246 | - hero_id = true, -- 英雄ID | ||
247 | - hero_talent_cost = "json", -- 英雄天赋升级消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...} | ||
248 | - hero_talent_levelbef = true, -- 英雄技能升级前等级 | ||
249 | - hero_talent_level = true, -- 英雄技能升级后等级 | ||
250 | - hero_talent_id = true, -- 天赋id | ||
251 | - }, | ||
252 | hero_jewel = { --英雄铭文 | 257 | hero_jewel = { --英雄铭文 |
253 | hero_id = true, -- 英雄ID | 258 | hero_id = true, -- 英雄ID |
254 | hero_jewel_sequence = "ucode", -- 铭文装备编号,用以关联一次装备时产生的多条日志 | 259 | hero_jewel_sequence = "ucode", -- 铭文装备编号,用以关联一次装备时产生的多条日志 |
@@ -278,7 +283,7 @@ local MethodType = { | @@ -278,7 +283,7 @@ local MethodType = { | ||
278 | gacha_up = true, -- 卡池UP角色 | 283 | gacha_up = true, -- 卡池UP角色 |
279 | gacha_times = true, -- 抽卡次数 | 284 | gacha_times = true, -- 抽卡次数 |
280 | gacha_reward = "json", -- 抽卡结果,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"} | 285 | gacha_reward = "json", -- 抽卡结果,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"} |
281 | - currency = "json", -- 消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...} | 286 | + gacha_cost = "json", -- 消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...} |
282 | gacha_cnt = true, -- 保底计数 | 287 | gacha_cnt = true, -- 保底计数 |
283 | }, | 288 | }, |
284 | equip_wear = { --装备穿戴与卸载 | 289 | equip_wear = { --装备穿戴与卸载 |
@@ -286,8 +291,8 @@ local MethodType = { | @@ -286,8 +291,8 @@ local MethodType = { | ||
286 | equip_id = true, --装备ID | 291 | equip_id = true, --装备ID |
287 | equip_wear_action = true, --装备操作类型:装备:0,卸载:1 | 292 | equip_wear_action = true, --装备操作类型:装备:0,卸载:1 |
288 | equip_wear_part = true, --装备部位,记录部位ID | 293 | equip_wear_part = true, --装备部位,记录部位ID |
289 | - equip_wear_result = "json", --装备操作后结果,记录属性变化,json格式记录,{“aa”:1234,"bb":4567} | ||
290 | - equip_wear_change = "json", --装备操作变化值,记录属性变化,记录正负值,json格式记录,{“aa”:1234,"bb":-45} | 294 | + equip_wear_scorebef = true, --装备前英雄评分 |
295 | + equip_wear_score = true, --装备后英雄评分 | ||
291 | equip_wear_mode = true, --用以区分自动装备还是手动装备,自动记录为0,手动记录为1 | 296 | equip_wear_mode = true, --用以区分自动装备还是手动装备,自动记录为0,手动记录为1 |
292 | equip_wear_seqid = "ucode", --自动穿戴时记录的系列ID,用以关联一次性装备时候产生的多条记录 | 297 | equip_wear_seqid = "ucode", --自动穿戴时记录的系列ID,用以关联一次性装备时候产生的多条记录 |
293 | }, | 298 | }, |
@@ -404,6 +409,7 @@ local MethodType = { | @@ -404,6 +409,7 @@ local MethodType = { | ||
404 | restaurant_order_status = true, -- 订单任务状态,接受:0, 拒绝:1, 完成:2 | 409 | restaurant_order_status = true, -- 订单任务状态,接受:0, 拒绝:1, 完成:2 |
405 | restaurant_order_rwd = "json", -- 订单完成奖励,json格式记录,{"itemid1":123,"itemid2":12,……….} | 410 | restaurant_order_rwd = "json", -- 订单完成奖励,json格式记录,{"itemid1":123,"itemid2":12,……….} |
406 | restaurant_order_lv = true, -- 订单品质等级,普通:0, 稀有:1, 顶级:2, 豪华:3 | 411 | restaurant_order_lv = true, -- 订单品质等级,普通:0, 稀有:1, 顶级:2, 豪华:3 |
412 | + restaurant_order_type = true, -- 订单任务类型,0:特殊顾客,1:特别订单 | ||
407 | }, | 413 | }, |
408 | restaurant_collect = { --餐厅顾客图谱 | 414 | restaurant_collect = { --餐厅顾客图谱 |
409 | restaurant_collect_id = true, -- 图谱收集ID | 415 | restaurant_collect_id = true, -- 图谱收集ID |
@@ -495,6 +501,28 @@ local MethodType = { | @@ -495,6 +501,28 @@ local MethodType = { | ||
495 | mission_pick_fund_beflv = true, -- 资助前资助等级 | 501 | mission_pick_fund_beflv = true, -- 资助前资助等级 |
496 | mission_pick_fund_aftlv = true, -- 资助后资助等级 | 502 | mission_pick_fund_aftlv = true, -- 资助后资助等级 |
497 | }, | 503 | }, |
504 | + function_open = { -- 功能开启日志 | ||
505 | + function_id = true, --功能ID | ||
506 | + }, | ||
507 | + punitive_action = { -- 讨伐行动 --TODO | ||
508 | + mission_id = true, --关卡ID | ||
509 | + mission_herolist = "json", -- 英雄ID,排序以玩家出战设置为准,示例:[111, 222, 333, 444, 555] | ||
510 | + mission_success_rate = true, -- 大成功几率 | ||
511 | + mission_reward = "json", -- 获得奖励,建议使用json格式记录。示例:{ itemid1: 1, itemid2: 3, itemid3: 5} | ||
512 | + mission_result = true, -- 战斗结果(0-无效,1-胜利,2-失败) | ||
513 | + mission_roundtime = true, -- 完成耗时(秒) | ||
514 | + mission_cleartype = true, -- 1-开始; 2-完成(领取奖励时) | ||
515 | + }, | ||
516 | + hero_talent = { --英雄精进(原英雄天赋升级) TODO | ||
517 | + hero_id = true, --英雄ID | ||
518 | + hero_talent_stagebef = true, --英雄精进升级前停留阶段 | ||
519 | + hero_talent_stage = true, --英雄精进升级后停留阶段 | ||
520 | + hero_talent_cost = "json", --英雄精进升级消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,….} | ||
521 | + hero_talent_subid = true, --升级属性ID,生命、攻击、防御、命中、闪避分别对应(0,1,2,3,4) | ||
522 | + hero_talent_sublevel = true, --升级属性等级,如生命升级从1到2,则记录2 | ||
523 | + }, | ||
524 | + | ||
525 | + | ||
498 | } | 526 | } |
499 | 527 | ||
500 | local function printError(info) | 528 | local function printError(info) |
@@ -515,20 +543,26 @@ local function isIos(self) | @@ -515,20 +543,26 @@ local function isIos(self) | ||
515 | return sid == 2 | 543 | return sid == 2 |
516 | end | 544 | end |
517 | 545 | ||
518 | -local appid, sdkId | 546 | +local sdkId |
547 | +local AppId = { | ||
548 | + [1] = 4787, | ||
549 | + [2] = 4788, | ||
550 | + [3] = 4789, | ||
551 | +} | ||
519 | local function getBaseLog(self) | 552 | local function getBaseLog(self) |
520 | local uid = self:getProperty("uid") | 553 | local uid = self:getProperty("uid") |
521 | - if not appid then | ||
522 | - appid, sdkId = string.match(uid, "(.*)_(.*)") | ||
523 | - if not appid then | 554 | + local sid = self:getProperty("sid") |
555 | + if not sdkId then | ||
556 | + _, sdkId = string.match(uid, "(.*)_(.*)") | ||
557 | + if not _ then | ||
524 | sdkId = uid | 558 | sdkId = uid |
525 | - appid = 0 | ||
526 | end | 559 | end |
527 | end | 560 | end |
561 | + | ||
528 | local log = { | 562 | local log = { |
529 | server_id = server_id, | 563 | server_id = server_id, |
530 | timestamp = skynet.timex(), | 564 | timestamp = skynet.timex(), |
531 | - app_id = appid, | 565 | + app_id = AppId[sid] or 0, |
532 | plat_id = isIos(self) and 0 or 1, | 566 | plat_id = isIos(self) and 0 or 1, |
533 | sdk_uid = sdkId, | 567 | sdk_uid = sdkId, |
534 | account_id = uid, | 568 | account_id = uid, |
@@ -556,6 +590,7 @@ local LogType = { | @@ -556,6 +590,7 @@ local LogType = { | ||
556 | logout = "common", | 590 | logout = "common", |
557 | guide = "common", | 591 | guide = "common", |
558 | newdevice = "common", | 592 | newdevice = "common", |
593 | + cbback = "common", | ||
559 | 594 | ||
560 | in_item = "common", | 595 | in_item = "common", |
561 | out_item = "common", | 596 | out_item = "common", |
@@ -756,8 +791,7 @@ function RoleLog.bind(Role) | @@ -756,8 +791,7 @@ function RoleLog.bind(Role) | ||
756 | end | 791 | end |
757 | end | 792 | end |
758 | end | 793 | end |
759 | - if not logd then return end | ||
760 | - pcall(skynet.send, logd, "lua", "log", doc, "bi") | 794 | + logproxy:log(doc, "bi") |
761 | end | 795 | end |
762 | 796 | ||
763 | function Role:logItems(itemId, before, after, log) | 797 | function Role:logItems(itemId, before, after, log) |
@@ -816,8 +850,7 @@ function RoleLog.bind(Role) | @@ -816,8 +850,7 @@ function RoleLog.bind(Role) | ||
816 | end | 850 | end |
817 | end | 851 | end |
818 | doc["@type"] = logType | 852 | doc["@type"] = logType |
819 | - if not logd then return end | ||
820 | - pcall(skynet.send, logd, "lua", "log", doc, "log") | 853 | + logproxy:log(doc, "log") |
821 | end | 854 | end |
822 | 855 | ||
823 | 856 |
src/models/RolePlugin.lua
@@ -64,6 +64,9 @@ function RolePlugin.bind(Role) | @@ -64,6 +64,9 @@ function RolePlugin.bind(Role) | ||
64 | [ItemId.PlayerExp] = function() | 64 | [ItemId.PlayerExp] = function() |
65 | self:addPlayExp(count, pms) | 65 | self:addPlayExp(count, pms) |
66 | end, | 66 | end, |
67 | + [ItemId.AdvPower] = function() | ||
68 | + self:changeAdvCount(-count) | ||
69 | + end, | ||
67 | } | 70 | } |
68 | 71 | ||
69 | local itemTypeAward = { | 72 | local itemTypeAward = { |
@@ -99,6 +102,35 @@ function RolePlugin.bind(Role) | @@ -99,6 +102,35 @@ function RolePlugin.bind(Role) | ||
99 | [ItemType.FuncOpen] = function() | 102 | [ItemType.FuncOpen] = function() |
100 | self:funcOpen(itemId, count, pms) | 103 | self:funcOpen(itemId, count, pms) |
101 | 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, | ||
102 | } | 134 | } |
103 | -- 对数量筛查 | 135 | -- 对数量筛查 |
104 | count = checkItemCount(self, itemId, count) | 136 | count = checkItemCount(self, itemId, count) |
@@ -324,16 +356,41 @@ function RolePlugin.bind(Role) | @@ -324,16 +356,41 @@ function RolePlugin.bind(Role) | ||
324 | if not self:costDiamond(pms) then | 356 | if not self:costDiamond(pms) then |
325 | return | 357 | return |
326 | end | 358 | end |
327 | - itemCountT[ItemId.Diamond] = nil | ||
328 | end | 359 | end |
329 | for itemId, count in pairs(itemCountT) do | 360 | for itemId, count in pairs(itemCountT) do |
330 | - pms.itemId = itemId | ||
331 | - pms.count = - count | ||
332 | - self:addItem(pms) | 361 | + if itemId ~= ItemId.Diamond then |
362 | + pms.itemId = itemId | ||
363 | + pms.count = - count | ||
364 | + self:addItem(pms) | ||
365 | + self:itemDeltaEvent(pms) | ||
366 | + end | ||
333 | end | 367 | end |
334 | return true | 368 | return true |
335 | end | 369 | end |
336 | 370 | ||
371 | + function Role:itemDeltaEvent(pms) | ||
372 | + self:eventBoxL(pms) | ||
373 | + end | ||
374 | + | ||
375 | + -- 拆解室的生产线启动 | ||
376 | + function Role:eventBoxL(pms) | ||
377 | + local limit = globalCsv.box_key_max[pms.itemId] | ||
378 | + if not limit then return end | ||
379 | + | ||
380 | + local update = false | ||
381 | + local boxL = self:getProperty("boxL") or {} | ||
382 | + for slot, data in pairs(boxL) do | ||
383 | + if data.time == 0 and data.id == pms.itemId and self:getItemCount(pms.itemId) < limit then | ||
384 | + update = true | ||
385 | + data.time = skynet.timex() | ||
386 | + end | ||
387 | + end | ||
388 | + | ||
389 | + if update then | ||
390 | + self:updateProperty({field = "boxL", value = boxL}) | ||
391 | + end | ||
392 | + end | ||
393 | + | ||
337 | function Role:getItemCount(itemId) | 394 | function Role:getItemCount(itemId) |
338 | if itemId == ItemId.Diamond then | 395 | if itemId == ItemId.Diamond then |
339 | return self:getAllDiamond() | 396 | return self:getAllDiamond() |
@@ -803,50 +860,50 @@ function RolePlugin.bind(Role) | @@ -803,50 +860,50 @@ function RolePlugin.bind(Role) | ||
803 | SendPacket(actionCodes.Sys_maintainNotice, MsgPack.pack({ body = text, iskey = not isNotKey})) | 860 | SendPacket(actionCodes.Sys_maintainNotice, MsgPack.pack({ body = text, iskey = not isNotKey})) |
804 | end | 861 | end |
805 | 862 | ||
806 | - function Role:getHeroActiveRelationData(heros) | ||
807 | - local relations = {} | ||
808 | - for _, id in pairs(heros or {}) do | ||
809 | - local hero = self.heros[id] | ||
810 | - if hero then | ||
811 | - local camp = csvdb["unitCsv"][hero:getProperty("type")].camp | ||
812 | - relations[camp] = (relations[camp] or 0) + 1 | ||
813 | - end | ||
814 | - end | ||
815 | - local curData = csvdb["unit_relationCsv"][0] | ||
816 | - if not next(relations) then return curData end | 863 | + -- function Role:getHeroActiveRelationData(heros) |
864 | + -- local relations = {} | ||
865 | + -- for _, id in pairs(heros or {}) do | ||
866 | + -- local hero = self.heros[id] | ||
867 | + -- if hero then | ||
868 | + -- local camp = csvdb["unitCsv"][hero:getProperty("type")].camp | ||
869 | + -- relations[camp] = (relations[camp] or 0) + 1 | ||
870 | + -- end | ||
871 | + -- end | ||
872 | + -- local curData = csvdb["unit_relationCsv"][0] | ||
873 | + -- if not next(relations) then return curData end | ||
817 | 874 | ||
818 | - for _, data in ipairs(csvdb["unit_relationCsv"]) do | ||
819 | - local had = {} | ||
820 | - local isDone = true | ||
821 | - for _, count in pairs(data.relation:toArray(true, "=")) do | ||
822 | - local find = false | ||
823 | - for camp, _count in pairs(relations) do | ||
824 | - if count == _count and not had[camp] then | ||
825 | - had[camp] = true | ||
826 | - find = true | ||
827 | - break | ||
828 | - end | ||
829 | - end | ||
830 | - if not find then | ||
831 | - isDone = false | ||
832 | - break | ||
833 | - end | ||
834 | - end | ||
835 | - if isDone then | ||
836 | - curData = data | ||
837 | - end | ||
838 | - end | ||
839 | - return curData | ||
840 | - end | ||
841 | - | ||
842 | - function Role:getHeroActiveRelation(heros) | ||
843 | - local data = self:getHeroActiveRelationData(heros) | ||
844 | - local result = {} | ||
845 | - for attr, value in pairs(data.effect:toNumMap()) do | ||
846 | - result[AttsEnumEx[attr]] = (result[AttsEnumEx[attr]] or 0) + value | ||
847 | - end | ||
848 | - return result | ||
849 | - end | 875 | + -- for _, data in ipairs(csvdb["unit_relationCsv"]) do |
876 | + -- local had = {} | ||
877 | + -- local isDone = true | ||
878 | + -- for _, count in pairs(data.relation:toArray(true, "=")) do | ||
879 | + -- local find = false | ||
880 | + -- for camp, _count in pairs(relations) do | ||
881 | + -- if count == _count and not had[camp] then | ||
882 | + -- had[camp] = true | ||
883 | + -- find = true | ||
884 | + -- break | ||
885 | + -- end | ||
886 | + -- end | ||
887 | + -- if not find then | ||
888 | + -- isDone = false | ||
889 | + -- break | ||
890 | + -- end | ||
891 | + -- end | ||
892 | + -- if isDone then | ||
893 | + -- curData = data | ||
894 | + -- end | ||
895 | + -- end | ||
896 | + -- return curData | ||
897 | + -- end | ||
898 | + | ||
899 | + -- function Role:getHeroActiveRelation(heros) | ||
900 | + -- local data = self:getHeroActiveRelationData(heros) | ||
901 | + -- local result = {} | ||
902 | + -- for attr, value in pairs(data.effect:toNumMap()) do | ||
903 | + -- result[AttsEnumEx[attr]] = (result[AttsEnumEx[attr]] or 0) + value | ||
904 | + -- end | ||
905 | + -- return result | ||
906 | + -- end | ||
850 | 907 | ||
851 | function Role:getHerosCamp(heros) | 908 | function Role:getHerosCamp(heros) |
852 | local had = {} | 909 | local had = {} |
@@ -867,14 +924,16 @@ function RolePlugin.bind(Role) | @@ -867,14 +924,16 @@ function RolePlugin.bind(Role) | ||
867 | return curCamp | 924 | return curCamp |
868 | end | 925 | end |
869 | 926 | ||
870 | - function Role:getRealBattleValue(heros, activeRelation) -- 获取队伍战斗力 羁绊加成 | 927 | + -- function Role:getRealBattleValue(heros, activeRelation) -- 获取队伍战斗力 羁绊加成 |
928 | + function Role:getRealBattleValue(heros) -- 获取队伍战斗力 羁绊加成 | ||
871 | heros = heros or {} | 929 | heros = heros or {} |
872 | - local activeRelation = activeRelation or self:getHeroActiveRelation(heros) | 930 | + -- local activeRelation = activeRelation or self:getHeroActiveRelation(heros) |
873 | local battleValue = 0 | 931 | local battleValue = 0 |
874 | for _, id in pairs(heros) do | 932 | for _, id in pairs(heros) do |
875 | local hero = self.heros[id] | 933 | local hero = self.heros[id] |
876 | if hero then | 934 | if hero then |
877 | - battleValue = battleValue + hero:getBattleValue(activeRelation) | 935 | + -- battleValue = battleValue + hero:getBattleValue(activeRelation) |
936 | + battleValue = battleValue + hero:getBattleValue() | ||
878 | end | 937 | end |
879 | end | 938 | end |
880 | return battleValue | 939 | return battleValue |
@@ -980,6 +1039,7 @@ function RolePlugin.bind(Role) | @@ -980,6 +1039,7 @@ function RolePlugin.bind(Role) | ||
980 | 1039 | ||
981 | if csvdb["itemCsv"][func] and csvdb["itemCsv"][func].type == ItemType.FuncOpen then | 1040 | if csvdb["itemCsv"][func] and csvdb["itemCsv"][func].type == ItemType.FuncOpen then |
982 | local unlockData = csvdb["unlockCsv"][func] | 1041 | local unlockData = csvdb["unlockCsv"][func] |
1042 | + self:log("function_open", {function_id = func}) | ||
983 | if unlockData.type == 4 then -- 解锁神器 | 1043 | if unlockData.type == 4 then -- 解锁神器 |
984 | if self:getProperty("advAFOpen")[unlockData.value1] ~= 1 then | 1044 | if self:getProperty("advAFOpen")[unlockData.value1] ~= 1 then |
985 | self:changeUpdates({{type = "advAFOpen", field = unlockData.value1, value = 1}}) | 1045 | self:changeUpdates({{type = "advAFOpen", field = unlockData.value1, value = 1}}) |
@@ -1132,7 +1192,7 @@ function RolePlugin.bind(Role) | @@ -1132,7 +1192,7 @@ function RolePlugin.bind(Role) | ||
1132 | local now = skynet.timex() | 1192 | local now = skynet.timex() |
1133 | local ct = math.ceil((now - StdTowerRankTime) / 86400) --按天计算 365 * 27 < 10000 可以维持 27 年 | 1193 | local ct = math.ceil((now - StdTowerRankTime) / 86400) --按天计算 365 * 27 < 10000 可以维持 27 年 |
1134 | local ct = 10000 - ct -- 越早的排名越靠前 | 1194 | local ct = 10000 - ct -- 越早的排名越靠前 |
1135 | - local towerTeam = self:getProperty("towerF") | 1195 | + local towerTeam = self:getTeamFormatByType(TeamSystemType.Tower) |
1136 | local battleV = self:getTeamBattleValue(towerTeam.heros) | 1196 | local battleV = self:getTeamBattleValue(towerTeam.heros) |
1137 | local score = (level * 10000 + ct) * 10000000 + battleV | 1197 | local score = (level * 10000 + ct) * 10000000 + battleV |
1138 | 1198 | ||
@@ -1142,7 +1202,7 @@ function RolePlugin.bind(Role) | @@ -1142,7 +1202,7 @@ function RolePlugin.bind(Role) | ||
1142 | lv = self:getProperty("level"), | 1202 | lv = self:getProperty("level"), |
1143 | batteV = battleV, | 1203 | batteV = battleV, |
1144 | level = level, | 1204 | level = level, |
1145 | - format = self:getTeamHerosInfo(towerTeam.heros), | 1205 | + format = self:getTeamHerosInfo(towerTeam).heros, |
1146 | } | 1206 | } |
1147 | local roleId = self:getProperty("id") | 1207 | local roleId = self:getProperty("id") |
1148 | redisproxy:pipelining(function (red) | 1208 | redisproxy:pipelining(function (red) |
@@ -1260,7 +1320,7 @@ function RolePlugin.bind(Role) | @@ -1260,7 +1320,7 @@ function RolePlugin.bind(Role) | ||
1260 | 1320 | ||
1261 | function Role:getTeamBattleInfo(team) | 1321 | function Role:getTeamBattleInfo(team) |
1262 | local teamInfo = {heros = {}, supports = {}} | 1322 | local teamInfo = {heros = {}, supports = {}} |
1263 | - local activeRelation = self:getHeroActiveRelation(team.heros) | 1323 | + -- local activeRelation = self:getHeroActiveRelation(team.heros) |
1264 | 1324 | ||
1265 | for slot, id in pairs(team.heros or {}) do | 1325 | for slot, id in pairs(team.heros or {}) do |
1266 | local info = {} | 1326 | local info = {} |
@@ -1268,7 +1328,8 @@ function RolePlugin.bind(Role) | @@ -1268,7 +1328,8 @@ function RolePlugin.bind(Role) | ||
1268 | if not hero then | 1328 | if not hero then |
1269 | print("error heroid " .. id) | 1329 | print("error heroid " .. id) |
1270 | end | 1330 | end |
1271 | - local attrs = hero:getTotalAttrs({activeRelation = activeRelation}) | 1331 | + -- local attrs = hero:getTotalAttrs({activeRelation = activeRelation}) |
1332 | + local attrs = hero:getTotalAttrs() | ||
1272 | for k, v in pairs(AttsEnumEx) do | 1333 | for k, v in pairs(AttsEnumEx) do |
1273 | info[v] = (attrs[v] or 0) | 1334 | info[v] = (attrs[v] or 0) |
1274 | end | 1335 | end |
@@ -1279,17 +1340,20 @@ function RolePlugin.bind(Role) | @@ -1279,17 +1340,20 @@ function RolePlugin.bind(Role) | ||
1279 | info.specialLevel = hero:getSkillLevel(1) | 1340 | info.specialLevel = hero:getSkillLevel(1) |
1280 | info.passiveLevel = hero:getSkillLevel(3) | 1341 | info.passiveLevel = hero:getSkillLevel(3) |
1281 | info.runeSkill = hero:getRuneSkill(102) | 1342 | info.runeSkill = hero:getRuneSkill(102) |
1343 | + info.talentSkills = hero:getTalentSkill() | ||
1282 | teamInfo.heros[slot] = info | 1344 | teamInfo.heros[slot] = info |
1283 | end | 1345 | end |
1284 | for slot, id in pairs(team.supports or {}) do | 1346 | for slot, id in pairs(team.supports or {}) do |
1285 | teamInfo.supports[slot] = {id, self.dinerData:getProperty("dishTree"):getv(id, 0)} | 1347 | teamInfo.supports[slot] = {id, self.dinerData:getProperty("dishTree"):getv(id, 0)} |
1286 | end | 1348 | end |
1349 | + teamInfo.tactics = globalCsv.tactics_skill_passive_cell[team.tactics] and team.tactics or nil | ||
1287 | return teamInfo | 1350 | return teamInfo |
1288 | end | 1351 | end |
1289 | 1352 | ||
1290 | - function Role:getTeamHerosInfo(heroIds) | 1353 | + function Role:getTeamHerosInfo(team) |
1354 | + local format = {} | ||
1291 | local heros = {} | 1355 | local heros = {} |
1292 | - for slot, heroId in pairs(heroIds or {}) do | 1356 | + for slot, heroId in pairs(team.heros or {}) do |
1293 | local hero = self.heros[heroId] | 1357 | local hero = self.heros[heroId] |
1294 | heros[slot] = { | 1358 | heros[slot] = { |
1295 | type = hero:getProperty("type"), | 1359 | type = hero:getProperty("type"), |
@@ -1297,7 +1361,10 @@ function RolePlugin.bind(Role) | @@ -1297,7 +1361,10 @@ function RolePlugin.bind(Role) | ||
1297 | wakeL = hero:getProperty("wakeL"), | 1361 | wakeL = hero:getProperty("wakeL"), |
1298 | } | 1362 | } |
1299 | end | 1363 | end |
1300 | - return heros | 1364 | + format.heros = heros |
1365 | + format.supports = team.supports or {} | ||
1366 | + format.tactics = team.tactics or nil | ||
1367 | + return format | ||
1301 | end | 1368 | end |
1302 | 1369 | ||
1303 | function Role:getTeamBattleValue(heros) | 1370 | function Role:getTeamBattleValue(heros) |
@@ -1310,20 +1377,52 @@ function RolePlugin.bind(Role) | @@ -1310,20 +1377,52 @@ function RolePlugin.bind(Role) | ||
1310 | return self:getRealBattleValue(heros) | 1377 | return self:getRealBattleValue(heros) |
1311 | end | 1378 | end |
1312 | 1379 | ||
1313 | - -- 不传参数 只修改保存的阵容信息 | ||
1314 | - function Role:saveHangTeam(team) | ||
1315 | - if not team then | ||
1316 | - team = self:getProperty("hangTeam") | ||
1317 | - else | ||
1318 | - self:updateProperty({field = "hangTeam", value = team}) | ||
1319 | - end | 1380 | + function Role:updateHangTeamInfo() |
1381 | + local team = self:getTeamFormatByType(TeamSystemType.Hang) | ||
1382 | + if not team then return end | ||
1383 | + | ||
1320 | self:setProperties({ | 1384 | self:setProperties({ |
1321 | - hangTS = self:getTeamHerosInfo(team.heros), | 1385 | + hangTS = self:getTeamHerosInfo(team), |
1322 | hangTB = self:getTeamBattleInfo(team), | 1386 | hangTB = self:getTeamBattleInfo(team), |
1323 | hangTBV = self:getTeamBattleValue(team.heros), | 1387 | hangTBV = self:getTeamBattleValue(team.heros), |
1324 | }) | 1388 | }) |
1325 | end | 1389 | end |
1326 | 1390 | ||
1391 | + -- 设置pve阵容 | ||
1392 | + function Role:getTeamFormat(index) | ||
1393 | + local teams = self:getProperty("hangTeams") or {} | ||
1394 | + local team = teams[index] or {} | ||
1395 | + return team | ||
1396 | + end | ||
1397 | + | ||
1398 | + function Role:getTeamFormatByType(type) | ||
1399 | + local teamIndex = self:getProperty("teamIndex") or {} | ||
1400 | + local index = teamIndex[type] | ||
1401 | + if not index then return {} end | ||
1402 | + | ||
1403 | + return self:getTeamFormat(index) | ||
1404 | + end | ||
1405 | + | ||
1406 | + function Role:setTeamFormat(index, team) | ||
1407 | + local teams = self:getProperty("hangTeams") or {} | ||
1408 | + teams[index] = team | ||
1409 | + self:updateProperty({field = "hangTeams", value = teams, notNotify = false}) | ||
1410 | + end | ||
1411 | + | ||
1412 | + -- 设置拾荒编队阵容 | ||
1413 | + function Role:getAdvTeamFormat(index) | ||
1414 | + local teams = self:getProperty("advTeams") or {} | ||
1415 | + local team = teams[index] or {} | ||
1416 | + return team | ||
1417 | + end | ||
1418 | + | ||
1419 | + function Role:setAdvTeamFormat(index, team) | ||
1420 | + local teams = self:getProperty("advTeams") or {} | ||
1421 | + teams[index] = team | ||
1422 | + self:updateProperty({field = "advTeams", value = teams, notNotify = false}) | ||
1423 | + end | ||
1424 | + | ||
1425 | + | ||
1327 | function Role:savePvpCTeam(team) | 1426 | function Role:savePvpCTeam(team) |
1328 | if not team then | 1427 | if not team then |
1329 | team = self:getProperty("pvpTC") | 1428 | team = self:getProperty("pvpTC") |
@@ -1331,7 +1430,7 @@ function RolePlugin.bind(Role) | @@ -1331,7 +1430,7 @@ function RolePlugin.bind(Role) | ||
1331 | self:updateProperty({field = "pvpTC", value = team}) | 1430 | self:updateProperty({field = "pvpTC", value = team}) |
1332 | end | 1431 | end |
1333 | self:setProperties({ | 1432 | self:setProperties({ |
1334 | - pvpTSC = self:getTeamHerosInfo(team.heros), | 1433 | + pvpTSC = self:getTeamHerosInfo(team), |
1335 | pvpTBC = self:getTeamBattleInfo(team), | 1434 | pvpTBC = self:getTeamBattleInfo(team), |
1336 | pvpTBVC = self:getTeamBattleValue(team.heros), | 1435 | pvpTBVC = self:getTeamBattleValue(team.heros), |
1337 | }) | 1436 | }) |
@@ -1347,7 +1446,7 @@ function RolePlugin.bind(Role) | @@ -1347,7 +1446,7 @@ function RolePlugin.bind(Role) | ||
1347 | local pvpTSH, pvpTBH, pvpTBVH = {}, {}, {} | 1446 | local pvpTSH, pvpTBH, pvpTBVH = {}, {}, {} |
1348 | for i = 1, 3 do | 1447 | for i = 1, 3 do |
1349 | if team[i] then | 1448 | if team[i] then |
1350 | - pvpTSH[i] = self:getTeamHerosInfo(team[i].heros) | 1449 | + pvpTSH[i] = self:getTeamHerosInfo(team[i]) |
1351 | pvpTBH[i] = self:getTeamBattleInfo(team[i]) | 1450 | pvpTBH[i] = self:getTeamBattleInfo(team[i]) |
1352 | pvpTBVH[i] = self:getTeamBattleValue(team[i].heros) | 1451 | pvpTBVH[i] = self:getTeamBattleValue(team[i].heros) |
1353 | end | 1452 | end |
@@ -1506,10 +1605,17 @@ function RolePlugin.bind(Role) | @@ -1506,10 +1605,17 @@ function RolePlugin.bind(Role) | ||
1506 | return "" | 1605 | return "" |
1507 | end | 1606 | end |
1508 | local limit = rechargeData.limit | 1607 | local limit = rechargeData.limit |
1509 | - local rechargeRecord = self:getProperty("payR") or {} | 1608 | + local rechargeRecord = self.storeData:getProperty("payR") or {} |
1510 | if limit ~= 0 and limit <= (rechargeRecord[rechargeId] or 0) then | 1609 | if limit ~= 0 and limit <= (rechargeRecord[rechargeId] or 0) then |
1511 | return "" | 1610 | return "" |
1512 | - end | 1611 | + end |
1612 | + | ||
1613 | + --判断是否是活动商品 | ||
1614 | + if rechargeData.activity_id ~= 0 then | ||
1615 | + local actCfg = csvdb["activity_ctrlCsv"][rechargeData.activity_id] | ||
1616 | + if not actCfg then return "" end | ||
1617 | + if not self.activity:isOpenById(rechargeData.activity_id, "ActShopGoods") then return "" end | ||
1618 | + end | ||
1513 | 1619 | ||
1514 | local orderId = redisproxy:hget(string.format(R_ORDERS, roleId), rechargeId) | 1620 | local orderId = redisproxy:hget(string.format(R_ORDERS, roleId), rechargeId) |
1515 | if orderId then | 1621 | if orderId then |
@@ -1527,6 +1633,7 @@ function RolePlugin.bind(Role) | @@ -1527,6 +1633,7 @@ function RolePlugin.bind(Role) | ||
1527 | key = orderKey, | 1633 | key = orderKey, |
1528 | order = partnerOrderId, | 1634 | order = partnerOrderId, |
1529 | rechargeId = rechargeId, | 1635 | rechargeId = rechargeId, |
1636 | + createTime = skynet.timex(), | ||
1530 | }) | 1637 | }) |
1531 | order:create() | 1638 | order:create() |
1532 | -- 正在进行中的订单 缓存 | 1639 | -- 正在进行中的订单 缓存 |
@@ -1570,7 +1677,7 @@ function RolePlugin.bind(Role) | @@ -1570,7 +1677,7 @@ function RolePlugin.bind(Role) | ||
1570 | -- 开始下单 | 1677 | -- 开始下单 |
1571 | if status == "success" then | 1678 | if status == "success" then |
1572 | elseif status == "fail" then | 1679 | elseif status == "fail" then |
1573 | - redisproxy:hdel(string.format(R_ORDERS, roleId), rechargeId) | 1680 | + -- redisproxy:hdel(string.format(R_ORDERS, roleId), rechargeId) |
1574 | elseif status == "finsh" then | 1681 | elseif status == "finsh" then |
1575 | orderObject:setProperty("finishTime", skynet.time()) | 1682 | orderObject:setProperty("finishTime", skynet.time()) |
1576 | redisproxy:hdel(string.format(R_ORDERS, roleId), rechargeId) | 1683 | redisproxy:hdel(string.format(R_ORDERS, roleId), rechargeId) |
@@ -1755,10 +1862,10 @@ function RolePlugin.bind(Role) | @@ -1755,10 +1862,10 @@ function RolePlugin.bind(Role) | ||
1755 | end | 1862 | end |
1756 | 1863 | ||
1757 | -- 抽卡阶段奖励 | 1864 | -- 抽卡阶段奖励 |
1758 | - function Role:getDrawCardExtraReward(oldVal, newVal) | 1865 | + function Role:getDrawCardExtraReward(feedbackId, oldVal, newVal) |
1759 | local reward = nil | 1866 | local reward = nil |
1760 | local maxCount = 0 | 1867 | local maxCount = 0 |
1761 | - for k, v in pairs(csvdb["build_extraRewardCsv"]) do | 1868 | + for k, v in pairs(csvdb["build_extraRewardCsv"][feedbackId]) do |
1762 | if oldVal < k and newVal >= k then | 1869 | if oldVal < k and newVal >= k then |
1763 | reward = v["reward"] or "" | 1870 | reward = v["reward"] or "" |
1764 | end | 1871 | end |
@@ -1860,6 +1967,53 @@ function RolePlugin.bind(Role) | @@ -1860,6 +1967,53 @@ function RolePlugin.bind(Role) | ||
1860 | end | 1967 | end |
1861 | deleteNotify({pattern = pattern}) | 1968 | deleteNotify({pattern = pattern}) |
1862 | end | 1969 | end |
1970 | + | ||
1971 | + local CommonRankTime = toUnixtime("2019010100") | ||
1972 | + local CommonCoef1 = 10000 | ||
1973 | + local CommonCoef2 = 10000 | ||
1974 | + function Role:updateRankCommon(rankType, rankVal, reserve) | ||
1975 | + if not rankType then return end | ||
1976 | + reserve = reserve or 0 | ||
1977 | + local now = skynet.timex() | ||
1978 | + local ct = math.ceil((now - CommonRankTime) / 86400) --按天计算 365 * 27 < 10000 可以维持 27 年 | ||
1979 | + ct = 10000 - ct -- 越早的排名越靠前 | ||
1980 | + local score = (rankVal * CommonCoef1 + ct) * CommonCoef2 + reserve | ||
1981 | + | ||
1982 | + local roleId = self:getProperty("id") | ||
1983 | + redisproxy:pipelining(function (red) | ||
1984 | + red:zadd(RANK_COMMON..rankType, score, roleId) --更新分数 | ||
1985 | + end) | ||
1986 | + end | ||
1987 | + | ||
1988 | + function Role:getRankInfoCommon(rankType) | ||
1989 | + if not rankType then return end | ||
1990 | + local list = {} | ||
1991 | + local rankKey = RANK_COMMON .. rankType | ||
1992 | + local ids = redisproxy:zrevrange(rankKey, 0 , 99, "WITHSCORES") | ||
1993 | + for i = 1, #ids, 2 do | ||
1994 | + local roleId = tonumber(ids[i]) | ||
1995 | + local rankVal = tonumber(ids[i + 1]) | ||
1996 | + rankVal = math.floor(math.floor(rankVal / CommonCoef2) / CommonCoef1) | ||
1997 | + table.insert(list, {roleId = roleId, player = rankVal}) | ||
1998 | + end | ||
1999 | + | ||
2000 | + for _, v in ipairs(list) do | ||
2001 | + local _, curInfo = rpcRole(v.roleId, "friendSInfo") | ||
2002 | + curInfo.ltime = nil | ||
2003 | + curInfo.rankVal = v.player | ||
2004 | + v.player = curInfo | ||
2005 | + end | ||
2006 | + | ||
2007 | + local rank = redisproxy:ZREVRANK(rankKey, self:getProperty("id")) | ||
2008 | + if not rank then | ||
2009 | + rank = -1 | ||
2010 | + else | ||
2011 | + rank = rank + 1 | ||
2012 | + end | ||
2013 | + return {list = list, rank = rank} | ||
2014 | + end | ||
2015 | + | ||
2016 | + | ||
1863 | end | 2017 | end |
1864 | 2018 | ||
1865 | return RolePlugin | 2019 | return RolePlugin |
1866 | \ No newline at end of file | 2020 | \ 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
@@ -33,7 +33,7 @@ local TaskType = { | @@ -33,7 +33,7 @@ local TaskType = { | ||
33 | HangQuick = 303, -- 快速挂机 | 33 | HangQuick = 303, -- 快速挂机 |
34 | HangBattle = 304, -- 挂机战斗 - id | 34 | HangBattle = 304, -- 挂机战斗 - id |
35 | HangGetGold = 305, -- 挂机获得齿轮 - count | 35 | HangGetGold = 305, -- 挂机获得齿轮 - count |
36 | - BonusPass = 306, -- 奖励副本通关 - id | 36 | + BonusPass = 306, -- 奖励副本通关 - id count |
37 | 37 | ||
38 | -- 冒险相关 | 38 | -- 冒险相关 |
39 | AdvPass = 401, -- 冒险通过关 - id level score | 39 | AdvPass = 401, -- 冒险通过关 - id level score |
@@ -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 |
@@ -142,11 +144,11 @@ local CommonListener = { | @@ -142,11 +144,11 @@ local CommonListener = { | ||
142 | [TaskType.GiveFriendP] = {{20, f("count")}}, | 144 | [TaskType.GiveFriendP] = {{20, f("count")}}, |
143 | [TaskType.UnionBoss] = {{21}}, | 145 | [TaskType.UnionBoss] = {{21}}, |
144 | [TaskType.GetFriendP] = {{22, f("count")}}, | 146 | [TaskType.GetFriendP] = {{22, f("count")}}, |
145 | - [TaskType.BonusPass] = {{23}}, | 147 | + [TaskType.BonusPass] = {{23, f("count")}}, |
146 | [TaskType.AdvStartSelf] = {{24}}, | 148 | [TaskType.AdvStartSelf] = {{24}}, |
147 | [TaskType.ShopAll] = {{25, f("count")}}, | 149 | [TaskType.ShopAll] = {{25, f("count")}}, |
148 | [TaskType.RuneUp] = {{26}}, | 150 | [TaskType.RuneUp] = {{26}}, |
149 | - [TaskType.OpenBox] = {{27, 1, f("id")}}, | 151 | + [TaskType.OpenBox] = {{27, f("count"), f("id")}}, |
150 | [TaskType.AdvDraw] = {{28, f("count"), f("ptype")}}, | 152 | [TaskType.AdvDraw] = {{28, f("count"), f("ptype")}}, |
151 | [TaskType.PotionMake] = {{29, f("count"), f("id")}}, | 153 | [TaskType.PotionMake] = {{29, f("count"), f("id")}}, |
152 | } | 154 | } |
@@ -172,7 +174,7 @@ local AchievListener = { | @@ -172,7 +174,7 @@ local AchievListener = { | ||
172 | [TaskType.FoodSellGold] = {{15, f("count")}}, | 174 | [TaskType.FoodSellGold] = {{15, f("count")}}, |
173 | [TaskType.DinerPopular] = {{16, f("count")}}, | 175 | [TaskType.DinerPopular] = {{16, f("count")}}, |
174 | [TaskType.TowerPass] = {{17, f("level")}}, | 176 | [TaskType.TowerPass] = {{17, f("level")}}, |
175 | - [TaskType.OpenBox] = {{18}}, | 177 | + [TaskType.OpenBox] = {{18, f("count")}}, |
176 | [TaskType.DinerLevelUp] = {{19, f("level"), f("type")}}, | 178 | [TaskType.DinerLevelUp] = {{19, f("level"), f("type")}}, |
177 | [TaskType.DinerTalentUp] = {{20, 1, f("type")}}, | 179 | [TaskType.DinerTalentUp] = {{20, 1, f("type")}}, |
178 | [TaskType.HangGetGold] = {{21, f("count")}}, | 180 | [TaskType.HangGetGold] = {{21, f("count")}}, |
@@ -209,7 +211,7 @@ local SudokuListener = { | @@ -209,7 +211,7 @@ local SudokuListener = { | ||
209 | [TaskType.AdvDraw] = {{10, f("count")}}, | 211 | [TaskType.AdvDraw] = {{10, f("count")}}, |
210 | [TaskType.DinerLevelUp] = {{11, f("level"), f("type")}}, | 212 | [TaskType.DinerLevelUp] = {{11, f("level"), f("type")}}, |
211 | [TaskType.FoodSell] = {{12, f("count")}}, | 213 | [TaskType.FoodSell] = {{12, f("count")}}, |
212 | - [TaskType.OpenBox] = {{13, 1}}, | 214 | + [TaskType.OpenBox] = {{13, f("count")}}, |
213 | [TaskType.TowerPass] = {{14, f("level")}}, | 215 | [TaskType.TowerPass] = {{14, f("level")}}, |
214 | [TaskType.PvpWin] = {{15, 1}}, | 216 | [TaskType.PvpWin] = {{15, 1}}, |
215 | [TaskType.DinerTalentUp] = {{16, f("level"), f("type")}}, | 217 | [TaskType.DinerTalentUp] = {{16, f("level"), f("type")}}, |
@@ -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 | ||
@@ -244,7 +249,7 @@ local CalendaTaskListener = { | @@ -244,7 +249,7 @@ local CalendaTaskListener = { | ||
244 | func = "checkCalendaTask", | 249 | func = "checkCalendaTask", |
245 | listen = { | 250 | listen = { |
246 | [TaskType.DrawHero] = {{1, 1, f("count")}}, | 251 | [TaskType.DrawHero] = {{1, 1, f("count")}}, |
247 | - [TaskType.BonusPass]= {{2, 1}}, | 252 | + [TaskType.BonusPass]= {{2, 1, f("count")}}, |
248 | [TaskType.AdvStart]= {{3, 1}}, | 253 | [TaskType.AdvStart]= {{3, 1}}, |
249 | [TaskType.DinerLevelUp]= {{4, 2, f("level")}}, | 254 | [TaskType.DinerLevelUp]= {{4, 2, f("level")}}, |
250 | [TaskType.HeroLvlCollect]= {{5, 3}}, -- x名y级英雄 | 255 | [TaskType.HeroLvlCollect]= {{5, 3}}, -- x名y级英雄 |
@@ -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}) |
@@ -386,6 +392,9 @@ function Store:onBuyPaySignCard(dur) | @@ -386,6 +392,9 @@ function Store:onBuyPaySignCard(dur) | ||
386 | curTs = getServerOpenTs() | 392 | curTs = getServerOpenTs() |
387 | 393 | ||
388 | self:SetActGoodsFlag("paySignIn", curTs) | 394 | self:SetActGoodsFlag("paySignIn", curTs) |
395 | + local actData = self.owner.activity:getActData("PaySignIn") | ||
396 | + actData[0] = 1 | ||
397 | + self.owner.activity:updateActData("PaySignIn", actData) | ||
389 | 398 | ||
390 | --local actGoodsFlag = self:getProperty("actGoodsFlag") or {} | 399 | --local actGoodsFlag = self:getProperty("actGoodsFlag") or {} |
391 | --local goodsIndex = GetActGoodsIndex("paySignIn") | 400 | --local goodsIndex = GetActGoodsIndex("paySignIn") |
@@ -464,6 +473,7 @@ function Store:data() | @@ -464,6 +473,7 @@ function Store:data() | ||
464 | --packTrigger = self:getProperty("packTrigger"), | 473 | --packTrigger = self:getProperty("packTrigger"), |
465 | actGoodsFlag = self:getProperty("actGoodsFlag"), | 474 | actGoodsFlag = self:getProperty("actGoodsFlag"), |
466 | bpInfo = self:getProperty("bpInfo"), | 475 | bpInfo = self:getProperty("bpInfo"), |
476 | + totalRR = self:getProperty("totalRR"), | ||
467 | } | 477 | } |
468 | end | 478 | end |
469 | 479 |
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 |