Commit 8e1a3c42a83ac43c83572fbfcb9a2a51a7d7a411
Merge branch 'develop' into player
# Conflicts: # config/develop.lua # config/nodenames.lua
Showing
46 changed files
with
3748 additions
and
1084 deletions
Show diff stats
config/develop.lua
... | ... | @@ -6,7 +6,7 @@ codeurl = "127.0.0.1:9090" |
6 | 6 | servId = 1 |
7 | 7 | |
8 | 8 | max_client = 300 |
9 | - | |
9 | +max_queue = 64 | |
10 | 10 | server_port = 20001 |
11 | 11 | debug_port = 10001 |
12 | 12 | httpweb_port = 11001 |
... | ... | @@ -15,4 +15,4 @@ redis_host = "127.0.0.1" |
15 | 15 | redis_port = 6001 |
16 | 16 | redis_db = 0 |
17 | 17 | redis_auth = "zhaolu6001" |
18 | -daemon = "./skynet.pid" | |
19 | 18 | \ No newline at end of file |
19 | +daemon = "./skynet.pid" | ... | ... |
src/GlobalVar.lua
1 | 1 | XXTEA_KEY = "699D448D6D24f7F941E9F6E99F823E18" |
2 | -RESET_TIME = 0 | |
2 | +RESET_TIME = 4 | |
3 | 3 | |
4 | -START_RESET_TIME_BASE = 1584316800 -- 0时区 | |
4 | +START_RESET_TIME_BASE = 1584316800 + RESET_TIME * 3600 -- 0时区 | |
5 | 5 | DAY_SEC = 86400 |
6 | 6 | TIME_ZONE = math.floor(os.difftime(START_RESET_TIME_BASE, os.time(os.date("!*t", START_RESET_TIME_BASE))) / 3600) -- 本地时区 |
7 | 7 | |
... | ... | @@ -69,6 +69,7 @@ ItemType = { |
69 | 69 | FuncOpen = 15, -- 管理功能开放 |
70 | 70 | SpeedBox = 16, -- 加速箱子 |
71 | 71 | SelectItemBox = 17, -- 自选箱子 |
72 | + CommonPaster = 18, -- 万能贴纸 | |
72 | 73 | } |
73 | 74 | |
74 | 75 | --在这个里面的会记录的是功能开放 对应类型open 而不是 ID |
... | ... | @@ -125,6 +126,7 @@ ItemId = { |
125 | 126 | HeroFC = {700, 701, 702, 703}, --通用角色碎片 |
126 | 127 | AdvKey = 80, -- 冒险钥匙 |
127 | 128 | BoxKey = 60, -- 拆解工具 |
129 | + AdvPower = 4701, -- 拾荒体力 | |
128 | 130 | } |
129 | 131 | |
130 | 132 | TimeReset = { |
... | ... | @@ -211,6 +213,8 @@ AdvBackEventType = { |
211 | 213 | Artifact = 24, --获得神器 |
212 | 214 | Level = 25, -- 升级 |
213 | 215 | LinkChooseOver = 26, -- 连锁事件结束 |
216 | + BuffEffect = 27, -- buff 效果 | |
217 | + PassiveEffect = 28, -- 被动 效果 | |
214 | 218 | } |
215 | 219 | |
216 | 220 | AdvScoreType = { |
... | ... | @@ -256,7 +260,7 @@ SettingStatus = { |
256 | 260 | }, |
257 | 261 | } |
258 | 262 | |
259 | -EMAIL_LIMIT = 20 --邮件最大数量 | |
263 | +EMAIL_LIMIT = 50 --邮件最大数量 | |
260 | 264 | |
261 | 265 | RedPointTags = { |
262 | 266 | PvpCR = 1, |
... | ... | @@ -301,19 +305,33 @@ MailId = { |
301 | 305 | ActDrawCardReward = 222, |
302 | 306 | ActAdvDrawReward = 223, |
303 | 307 | ActOpenBoxReward = 224, |
308 | + ActItemRecycle = 225, | |
304 | 309 | |
305 | 310 | PaySignAward = 241, |
306 | 311 | PayBackAward = 242, |
307 | 312 | } |
308 | 313 | |
309 | 314 | TriggerEventType = { |
310 | - HangPass = 1, | |
311 | - LevelUp = 2, | |
315 | + HangPass = 1, | |
316 | + AdvPass = 2, | |
312 | 317 | TowerPass = 3, |
318 | + LevelUp = 4, | |
319 | + AddNewHero = 5, | |
320 | + SSRCount = 6, | |
321 | + AfterTs = 7, -- 某时间以后 | |
313 | 322 | } |
314 | 323 | |
315 | 324 | DrawCardType = { |
316 | 325 | SpecifyDraw = 1, |
317 | 326 | NormalDraw = 2, |
318 | 327 | FriendDraw = 3 |
328 | +} | |
329 | + | |
330 | +-- 阵容系统类型 | |
331 | +TeamSystemType = { | |
332 | + Hang = 1, | |
333 | + BonusBattle = 2, | |
334 | + Tower = 3, | |
335 | + Dinner = 4, | |
336 | + FriendBattle = 5, | |
319 | 337 | } |
320 | 338 | \ No newline at end of file | ... | ... |
src/ProtocolCode.lua
... | ... | @@ -7,6 +7,7 @@ actionCodes = { |
7 | 7 | Sys_commonNotice = 5, |
8 | 8 | Sys_maintainNotice = 6, |
9 | 9 | Sys_customNotice = 7, |
10 | + Sys_checkQueue = 8, | |
10 | 11 | |
11 | 12 | Gm_clientRequest = 20, |
12 | 13 | Gm_receiveResponse = 21, |
... | ... | @@ -47,6 +48,9 @@ actionCodes = { |
47 | 48 | Role_getDownloadCvRewardRpc = 132, |
48 | 49 | Role_updateFeedbackInfoRpc = 133, |
49 | 50 | Role_useSelectItemRpc = 134, -- 使用多选一礼包 |
51 | + Role_broadGetSSR = 135, -- 全服广播 获得ssr英雄 | |
52 | + Role_renameTeamRpc = 136, -- 编队改名 | |
53 | + Role_accuseRpc = 137, -- 举报 | |
50 | 54 | |
51 | 55 | Adv_startAdvRpc = 151, |
52 | 56 | Adv_startHangRpc = 152, |
... | ... | @@ -69,6 +73,8 @@ actionCodes = { |
69 | 73 | Adv_rankRpc = 169, |
70 | 74 | Adv_quickHangRpc = 170, |
71 | 75 | Adv_refreshSupportRpc = 171, |
76 | + Adv_selectTeamRpc = 172, | |
77 | + Adv_roleFormatRpc = 173, | |
72 | 78 | |
73 | 79 | Hero_loadInfos = 201, |
74 | 80 | Hero_updateProperty = 202, |
... | ... | @@ -94,6 +100,8 @@ actionCodes = { |
94 | 100 | Hero_unlockPoolRpc = 222, |
95 | 101 | Hero_changeCrown = 223, |
96 | 102 | Hero_drawHeroExtraRewardNtf = 224, |
103 | + Hero_itemComposeRpc = 225, | |
104 | + Hero_setWishPoolRpc = 226, | |
97 | 105 | |
98 | 106 | Hang_startRpc = 251, |
99 | 107 | Hang_checkRpc = 252, |
... | ... | @@ -109,6 +117,7 @@ actionCodes = { |
109 | 117 | Hang_hangGiftRpc = 262, |
110 | 118 | Hang_bagFieldRpc = 263, |
111 | 119 | Hang_chatLineRpc = 264, |
120 | + Hang_selectTeamRpc = 265, | |
112 | 121 | |
113 | 122 | Diner_updateProperty = 300, |
114 | 123 | Diner_addSellRpc = 301, |
... | ... | @@ -195,6 +204,7 @@ actionCodes = { |
195 | 204 | Store_getGrowFundRewardRpc = 561, --成长助力奖励 |
196 | 205 | Store_getBattlePassRewardRpc = 562, --赛季卡奖励 |
197 | 206 | Store_getExploreCommandRewardRpc = 563, --探索指令 |
207 | + Store_getTotalRechargeAwardRpc = 564, -- 累计充值 | |
198 | 208 | |
199 | 209 | |
200 | 210 | Email_listRpc = 600, |
... | ... | @@ -208,6 +218,15 @@ actionCodes = { |
208 | 218 | Activity_sudokuRewardRpc = 652, |
209 | 219 | Activity_actSignRpc = 653, |
210 | 220 | Activity_actPaySignRewardNtf = 654, |
221 | + Activity_actCalendaTaskRpc = 655, | |
222 | + Activity_actPaySignRpc = 656, | |
223 | + Activity_exchangeRpc = 657, | |
224 | + Activity_gachakonRpc = 658, | |
225 | + Activity_hangDropRpc = 659, | |
226 | + | |
227 | + Radio_startQuestRpc = 700, | |
228 | + Radio_finishQuestRpc = 701, | |
229 | + Radio_cancelQuestRpc = 702, | |
211 | 230 | } |
212 | 231 | |
213 | 232 | rpcResponseBegin = 10000 | ... | ... |
src/RedisKeys.lua
src/actions/ActivityAction.lua
... | ... | @@ -183,19 +183,22 @@ end |
183 | 183 | function _M.actPaySignRpc(agent, data) |
184 | 184 | local role = agent.role |
185 | 185 | local msg = MsgPack.unpack(data) |
186 | + local dayIndex = msg.day | |
186 | 187 | local actGoodsFlag = role.storeData:getProperty("actGoodsFlag") |
187 | 188 | local index = GetActGoodsIndex("paySignIn") |
188 | - local flag = actGoodsFlag[index] or 0 | |
189 | - if flag == 0 then return 1 end | |
189 | + local ts = actGoodsFlag[index] or 0 | |
190 | + if ts == 0 then return 1 end | |
190 | 191 | |
191 | - if not role.activity:isOpen("PaySignIn") then return 2 end | |
192 | + local open, actId = role.activity:isOpen("PaySignIn") | |
193 | + if not open then return 2 end | |
192 | 194 | |
193 | - local diffDay = diffFromOpen() + 1 | |
195 | + local diffDay = diffFromTs(ts) + 1 | |
194 | 196 | |
195 | 197 | local curData = role.activity:getActData("PaySignIn") |
198 | + if not curData then return 3 end | |
196 | 199 | local reward, change = {} |
197 | 200 | for day, csvData in ipairs(csvdb["pay_signInCsv"]) do |
198 | - if day <= diffDay then | |
201 | + if day <= diffDay and day == dayIndex then | |
199 | 202 | if not curData[day] then |
200 | 203 | curData[day] = 1 |
201 | 204 | -- 奖励 |
... | ... | @@ -203,8 +206,8 @@ function _M.actPaySignRpc(agent, data) |
203 | 206 | reward[itemId] = (reward[itemId] or 0) + count |
204 | 207 | end |
205 | 208 | end |
206 | - else | |
207 | - break | |
209 | + --else | |
210 | + -- break | |
208 | 211 | end |
209 | 212 | end |
210 | 213 | if next(reward) then |
... | ... | @@ -213,7 +216,7 @@ function _M.actPaySignRpc(agent, data) |
213 | 216 | end |
214 | 217 | |
215 | 218 | role:log("activity", { |
216 | - activity_id = curData[0], -- 活动ID(或活动指定任务的ID) | |
219 | + activity_id = actId, -- 活动ID(或活动指定任务的ID) | |
217 | 220 | activity_type = role.activity.ActivityType.PaySignIn, -- 活动类型,见活动类型枚举表 |
218 | 221 | activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} |
219 | 222 | }) |
... | ... | @@ -222,4 +225,194 @@ function _M.actPaySignRpc(agent, data) |
222 | 225 | return true |
223 | 226 | end |
224 | 227 | |
228 | +function _M.actCalendaTaskRpc(agent, data) | |
229 | + local role = agent.role | |
230 | + local msg = MsgPack.unpack(data) | |
231 | + local taskId = msg.id | |
232 | + local calTask = role:getProperty("calTask") or {} | |
233 | + local record = calTask["r"] or {} | |
234 | + local flag = record[taskId] or 0 | |
235 | + if flag == 1 then return 1 end | |
236 | + local open, actId = role.activity:isOpen("CalendaTask") | |
237 | + local actData = csvdb["activity_ctrlCsv"][actId] | |
238 | + if not open then return 2 end | |
239 | + if not actData then return 3 end | |
240 | + | |
241 | + local taskList = csvdb["activity_taskCsv"][actData.condition] | |
242 | + if not taskList then return 4 end | |
243 | + local taskCfg = taskList[taskId] | |
244 | + if not taskCfg then return 5 end | |
245 | + if taskCfg.key ~= actData.condition then return 6 end | |
246 | + | |
247 | + if (calTask[taskId] or 0) < taskCfg.condition1 then return 7 end | |
248 | + | |
249 | + record[taskId] = 1 | |
250 | + calTask["r"] = record | |
251 | + | |
252 | + role:updateProperty({field = "calTask", value = calTask}) | |
253 | + | |
254 | + local reward, change = role:award(taskCfg.reward, {log = {desc = "calendaTask"}}) | |
255 | + | |
256 | + role:log("activity", { | |
257 | + activity_id = taskId, -- 活动ID(或活动指定任务的ID) | |
258 | + activity_type = role.activity.ActivityType.CalendaTask, -- 活动类型,见活动类型枚举表 | |
259 | + activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} | |
260 | + }) | |
261 | + | |
262 | + SendPacket(actionCodes.Activity_actCalendaTaskRpc, MsgPack.pack(role:packReward(reward, change))) | |
263 | + return true | |
264 | +end | |
265 | + | |
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 | + if not role.activity:isOpenById(actid) then return 1 end | |
272 | + | |
273 | + local exchangeCfg = csvdb["activity_exchangeCsv"][actid] | |
274 | + if not exchangeCfg then return 2 end | |
275 | + if not exchangeCfg[id] then return 3 end | |
276 | + local curData = role.activity:getActData("Exchange") or {} | |
277 | + local exchangeData = curData[actid] or {} | |
278 | + local curCount = exchangeData[id] or 0 | |
279 | + local actCfg = exchangeCfg[id] | |
280 | + local limitArr = actCfg.limit:toArray(true, "=") | |
281 | + if curCount >= limitArr[2] then return 4 end | |
282 | + | |
283 | + local costs = actCfg.goods:toNumMap() | |
284 | + if not role:checkItemEnough(costs) then return 5 end | |
285 | + role:costItems(costs, {log = {desc = "actExchange", int1 = actid, int2 = id}}) | |
286 | + | |
287 | + curCount = curCount + 1 | |
288 | + exchangeData[id] = curCount | |
289 | + curData[actid] = exchangeData | |
290 | + role.activity:updateActData("Exchange", curData) | |
291 | + | |
292 | + local reward, change = role:award(actCfg.award, {log = {desc = "actExchange", int1 = actid, int2 = id}}) | |
293 | + | |
294 | + | |
295 | + SendPacket(actionCodes.Activity_exchangeRpc, MsgPack.pack(role:packReward(reward, change))) | |
296 | + return true | |
297 | +end | |
298 | + | |
299 | +function _M.gachakonRpc(agent, data) | |
300 | + local role = agent.role | |
301 | + local msg = MsgPack.unpack(data) | |
302 | + local actid = msg.actid | |
303 | + local count = msg.count | |
304 | + | |
305 | + if count > 10 then return end | |
306 | + | |
307 | + if not role.activity:isOpenById(actid) then return 1 end | |
308 | + | |
309 | + local actCtrlData = csvdb["activity_ctrlCsv"][actid] | |
310 | + if not actCtrlData then return 2 end | |
311 | + local cost = actCtrlData.condition2:toNumMap() | |
312 | + | |
313 | + local actCfg = csvdb["activity_capsuleToysCsv"][actid] | |
314 | + if not actCfg then return 3 end | |
315 | + | |
316 | + local gachakonInfo = role.activity:getActData("Gachakon") or {} | |
317 | + local award = {} | |
318 | + local remain = 0 | |
319 | + for i = 1, count do | |
320 | + local tmpCfg = clone(actCfg) | |
321 | + remain = 0 | |
322 | + print("-----------------, ", i) | |
323 | + for id, cfg in pairs(tmpCfg) do | |
324 | + local num = gachakonInfo[id] or 0 | |
325 | + num = cfg.amount >= num and cfg.amount - num or 0 | |
326 | + cfg.weight = cfg.weight * num | |
327 | + if cfg.weight > 0 then | |
328 | + remain = remain + num | |
329 | + end | |
330 | + print("num ".. num, id, cfg.weight, cfg.amount) | |
331 | + end | |
332 | + if remain == 0 then | |
333 | + break | |
334 | + end | |
335 | + local id = math.randWeight(tmpCfg, "weight") | |
336 | + if not id then return 4 end | |
337 | + gachakonInfo[id] = (gachakonInfo[id] or 0) + 1 | |
338 | + local curAward = tmpCfg[id].award:toNumMap() | |
339 | + for k, v in pairs(curAward) do | |
340 | + award[k] = (award[k] or 0) + v | |
341 | + end | |
342 | + end | |
343 | + | |
344 | + for k, v in pairs(cost) do | |
345 | + cost[k] = v * count | |
346 | + end | |
347 | + | |
348 | + if not role:checkItemEnough(cost) then return 5 end | |
349 | + | |
350 | + role:costItems(cost, {log = {desc = "actGachakon", int1 = actid, int2 = count}}) | |
351 | + | |
352 | + local reward, change = role:award(award, {log = {desc = "actGachakon", int1 = actid, int2 = count}}) | |
353 | + if remain <= count then | |
354 | + gachakonInfo = {} | |
355 | + print("hahaha") | |
356 | + end | |
357 | + role.activity:updateActData("Gachakon", gachakonInfo) | |
358 | + | |
359 | + SendPacket(actionCodes.Activity_gachakonRpc, MsgPack.pack(role:packReward(reward, change))) | |
360 | + return true | |
361 | +end | |
362 | + | |
363 | +function _M.hangDropRpc(agent, data) | |
364 | + local role = agent.role | |
365 | + local msg = MsgPack.unpack(data) | |
366 | + local actid = msg.actid | |
367 | + if not role.activity:isOpenById(actid) then return 1 end | |
368 | + | |
369 | + local actCfg = csvdb["activity_putCsv"][actid] | |
370 | + if not actCfg then return 2 end | |
371 | + | |
372 | + local award, period = "", 0 | |
373 | + for i = 1, #actCfg do | |
374 | + local cfg = actCfg[i] | |
375 | + if not cfg then | |
376 | + break | |
377 | + end | |
378 | + if cfg.condition ~= "" then | |
379 | + local arr = cfg.condition:toArray(true, "=") | |
380 | + local type = arr[1] | |
381 | + if type == 1 then | |
382 | + local actId = arr[2] | |
383 | + local carbonId = arr[3] | |
384 | + if not role.activity:isOpenById(actid) then return 3 end | |
385 | + local clInfo = role.activity:getActData("ChallengeLevel") or {} | |
386 | + if not clInfo[carbonId] then | |
387 | + break | |
388 | + end | |
389 | + end | |
390 | + end | |
391 | + award = cfg.reward | |
392 | + period = cfg.period * 60 | |
393 | + end | |
394 | + local actData = role.activity:getActData("HangDrop") or 0 | |
395 | + local timeNow = skynet.timex() | |
396 | + if period == 0 or award == "" then | |
397 | + return 4 | |
398 | + end | |
399 | + local num = math.floor((timeNow - actData)/ period) | |
400 | + num = num > 8 and 8 or num | |
401 | + if num == 0 then | |
402 | + return 5 | |
403 | + end | |
404 | + local reward, change = {}, nil | |
405 | + for id, value in pairs(award:toNumMap()) do | |
406 | + reward[id] = value * num | |
407 | + end | |
408 | + | |
409 | + reward, change = role:award(reward, {log = {desc = "actHangDrop", int1 = actid, int2 = num}}) | |
410 | + | |
411 | + role.activity:updateActData("HangDrop", timeNow) | |
412 | + | |
413 | + SendPacket(actionCodes.Activity_hangDropRpc, MsgPack.pack(role:packReward(reward, change))) | |
414 | + | |
415 | + return true | |
416 | +end | |
417 | + | |
225 | 418 | return _M |
226 | 419 | \ No newline at end of file | ... | ... |
src/actions/AdvAction.lua
... | ... | @@ -47,6 +47,10 @@ local function checkFormat(role, format, checkAdvTeam) |
47 | 47 | end |
48 | 48 | end |
49 | 49 | |
50 | + if not format then | |
51 | + format = role:getProperty("advTeam") | |
52 | + end | |
53 | + | |
50 | 54 | if checkAdvTeam then |
51 | 55 | for _, heroId in pairs(role:getProperty("advTeam").heros or {}) do |
52 | 56 | hadHero[heroId] = true |
... | ... | @@ -83,7 +87,7 @@ function _M.startAdvRpc( agent, data ) |
83 | 87 | local msg = MsgPack.unpack(data) |
84 | 88 | local chapterId = msg.chapterId --关卡id |
85 | 89 | local layer = msg.layer or 1 --选择层数 |
86 | - local format = msg.format --编队 | |
90 | + --local format = msg.format --编队 | |
87 | 91 | local supportIdx = msg.supportIdx --选择的支援效果 |
88 | 92 | if not role:isFuncUnlock(FuncUnlock.Adv) then return end |
89 | 93 | |
... | ... | @@ -127,18 +131,18 @@ function _M.startAdvRpc( agent, data ) |
127 | 131 | end |
128 | 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 | 146 | if AdvCommon.isEndless(chapterId) then |
143 | 147 | role.dailyData:updateProperty({field = "advElC", delta = 1}) |
144 | 148 | else |
... | ... | @@ -243,14 +247,15 @@ function _M.startHangRpc(agent, data) |
243 | 247 | info.format.heros[slot] = heroId |
244 | 248 | end |
245 | 249 | info.time = skynet.timex() + adv_idle_time --挂机时间 |
250 | + info.duration = adv_idle_time | |
246 | 251 | info.campId = campId |
247 | 252 | info.index = index |
248 | 253 | |
249 | 254 | -- 没有在战斗 用team来挂机了 把team清掉 |
250 | - if not role:getAdvData():isRunning() then | |
251 | - role:updateProperty({field = "advTeam", value = {}}) | |
252 | - end | |
253 | - | |
255 | + --if not role:getAdvData():isRunning() then | |
256 | + -- role:updateProperty({field = "advTeam", value = {}}) | |
257 | + --end | |
258 | + role:pushMsg({type = "adv", slot = chapterId, time = adv_idle_time}) | |
254 | 259 | role:changeUpdates({{type = "advHang", field = chapterId, value = info}}) |
255 | 260 | |
256 | 261 | role:changeAdvCount(adv_idle_energy) |
... | ... | @@ -261,6 +266,16 @@ function _M.startHangRpc(agent, data) |
261 | 266 | return true |
262 | 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 | 279 | function _M.quickHangRpc(agent, data) |
265 | 280 | local role = agent.role |
266 | 281 | local msg = MsgPack.unpack(data) |
... | ... | @@ -295,6 +310,7 @@ function _M.quickHangRpc(agent, data) |
295 | 310 | info.time = 0 |
296 | 311 | role:changeUpdates({{type = "advHang", field = chapterId, value = info}}) |
297 | 312 | |
313 | + role:pushCancel({type = "adv", slot = chapterId}) | |
298 | 314 | role:mylog("adv_action", {desc = "advQuickHang", int1 = chapterId}) |
299 | 315 | |
300 | 316 | SendPacket(actionCodes.Adv_quickHangRpc, '') |
... | ... | @@ -327,7 +343,7 @@ function _M.endHangRpc(agent, data) |
327 | 343 | end |
328 | 344 | adv_idle_time = adv_idle_time * 60 |
329 | 345 | |
330 | - local reward, isFull, change | |
346 | + local reward, isFull, change, heroFaithMap | |
331 | 347 | if skynet.timex() >= info.time then |
332 | 348 | -- 最新需求加成取消 |
333 | 349 | --[[ |
... | ... | @@ -356,6 +372,14 @@ function _M.endHangRpc(agent, data) |
356 | 372 | |
357 | 373 | if not maxCampsite then return end |
358 | 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 | + | |
359 | 383 | local totalReward = campSiteData.idleReward_1 .. " " .. campSiteData.idleReward_2 |
360 | 384 | |
361 | 385 | local idleReward = totalReward:toNumMap() |
... | ... | @@ -371,6 +395,7 @@ function _M.endHangRpc(agent, data) |
371 | 395 | -- else |
372 | 396 | -- role:updateProperty({field = "advC", delta = -chapterData.limitlevel}) |
373 | 397 | -- end |
398 | + role:pushCancel({type = "adv", slot = chapterId}) | |
374 | 399 | else |
375 | 400 | return |
376 | 401 | end |
... | ... | @@ -380,7 +405,9 @@ function _M.endHangRpc(agent, data) |
380 | 405 | |
381 | 406 | role:mylog("adv_action", {desc = "endHang", int1 = chapterId, short1 = cancel and 1 or 0}) |
382 | 407 | |
383 | - SendPacket(actionCodes.Adv_endHangRpc, MsgPack.pack({reward = reward, change = change, isFull = isFull})) | |
408 | + role:checkTaskEnter("AdvHang", {}) | |
409 | + | |
410 | + SendPacket(actionCodes.Adv_endHangRpc, MsgPack.pack({reward = reward, change = change, isFull = isFull, heroFaith = heroFaithMap})) | |
384 | 411 | return true |
385 | 412 | end |
386 | 413 | |
... | ... | @@ -435,6 +462,16 @@ function _M.finishTaskRpc(agent, data) |
435 | 462 | role:checkTaskEnter("AdvOverTask", {id = taskId}) |
436 | 463 | |
437 | 464 | adv:mylog({desc = "finishTask", int1 = taskId}) |
465 | + | |
466 | + role:log("mission_pick_achiev", { | |
467 | + mission_threadid = adv.chapterId, -- 大地图ID | |
468 | + mission_threadname = (csvdb["adv_chapterCsv"][adv.chapterId] or {})["chapter"] or "auto", -- 大地图名称 | |
469 | + mission_id = adv.level, -- 关卡ID | |
470 | + mission_sequenceid = adv.logid, -- 本次拾荒ID,用于关联一次拾荒产生多条不同类型的日志 | |
471 | + mission_pick_achiev_id = taskId, -- 任务ID | |
472 | + mission_pick_achiev_reward = reward, -- 任务奖励,[{"id":101,"num":10},{"id":102,"num":20},{"id":103,"num":30}] | |
473 | + }) | |
474 | + | |
438 | 475 | |
439 | 476 | SendPacket(actionCodes.Adv_finishTaskRpc, MsgPack.pack(role:packReward(reward, change))) |
440 | 477 | return true |
... | ... | @@ -490,16 +527,8 @@ function _M.useItemRpc(agent, data) |
490 | 527 | adv:cost({[itemId] = count}, {log = {desc = "useItem", int1 = itemId, int2 = count}}) |
491 | 528 | adv:backUse({[itemId] = count}) |
492 | 529 | end |
493 | - | |
494 | - if itemId == 5020 then | |
495 | - role:finishGuide(53) | |
496 | - end | |
497 | - adv:checkAchievement(adv.AchievType.UseItem, count, itemId) | |
498 | - adv:mylog({desc = "useItem", int1 = itemId, int2 = count}) | |
499 | - | |
500 | - for i = 1, count do | |
501 | - adv:doActive(itemData.effect, target) -- target | |
502 | - end | |
530 | + | |
531 | + adv:useItem(itemId, count, target) | |
503 | 532 | |
504 | 533 | adv:afterRound() |
505 | 534 | adv:saveDB() |
... | ... | @@ -583,6 +612,7 @@ function _M.wearArtifactRpc(agent, data) |
583 | 612 | |
584 | 613 | local status = adv:wearArtifact(slot, id) |
585 | 614 | if not status then return 3 end |
615 | + | |
586 | 616 | adv:saveDB() |
587 | 617 | |
588 | 618 | role:finishGuide(55) |
... | ... | @@ -608,7 +638,20 @@ function _M.upArtifactRpc(agent, data) |
608 | 638 | if not adv:cost(cost, {}, true) then return 4 end |
609 | 639 | |
610 | 640 | local status = adv:artifactLevelUp(id) |
611 | - if not status then return 5 end | |
641 | + if not status then | |
642 | + return 5 | |
643 | + else | |
644 | + role:log("mission_pick_reform", { | |
645 | + mission_threadid = adv.chapterId, -- 大地图ID | |
646 | + mission_threadname = (csvdb["adv_chapterCsv"][adv.chapterId] or {})["chapter"] or "auto", -- 大地图名称 | |
647 | + mission_id = adv.level, -- 关卡ID | |
648 | + mission_pick_equip_id = id, -- 神器ID | |
649 | + mission_pick_reform_beflv = curLevel, -- 神器原等级 | |
650 | + mission_pick_reform_aftlv = curLevel + 1, -- 神器现等级 | |
651 | + mission_pick_reform_cost = cost[ItemId.AdvPoint], -- 消耗探险点数 | |
652 | + mission_sequenceid = adv.logid, -- 本次拾荒ID,用于关联一次拾荒产生多条不同类型的日志 | |
653 | + }) | |
654 | + end | |
612 | 655 | adv:cost(cost, {log = {desc = "upArtifact", int1 = id}}) |
613 | 656 | adv:backCost(cost) |
614 | 657 | if status == 1 then -- 现在穿着呢。更新下 |
... | ... | @@ -703,7 +746,7 @@ function _M.endBattleRpc(agent, data) |
703 | 746 | end |
704 | 747 | end |
705 | 748 | adv:mylog({desc = "endBattle"}) |
706 | - local status = adv:clickBlock(roomId, blockId, {player = player, bySkill = bySkill}) | |
749 | + local status = adv:clickBlock(roomId, blockId, {player = player, enemy = msg.enemy, bySkill = bySkill}) | |
707 | 750 | |
708 | 751 | if not status then return end |
709 | 752 | SendPacket(actionCodes.Adv_endBattleRpc, MsgPack.pack({events = adv:popBackEvents()})) |
... | ... | @@ -770,7 +813,7 @@ function _M.wheelSurfRpc(agent, data) |
770 | 813 | |
771 | 814 | if not role:checkItemEnough(costs) then return 5 end |
772 | 815 | role:costItems(costs, {log = {desc = "advWheelSurf", int1 = ptype}}) |
773 | - role:addAdvLvExp(costs[ItemId.OldCoin] or 0) | |
816 | + local oldLv, lv = role:addAdvLvExp(costs[ItemId.OldCoin] or 0) | |
774 | 817 | local advDrawB = role:getProperty("advDrawB") |
775 | 818 | advDrawB[ptype] = (advDrawB[ptype] or 0) + count |
776 | 819 | role:updateProperty({field = "advDrawB", value = advDrawB}) |
... | ... | @@ -789,6 +832,16 @@ function _M.wheelSurfRpc(agent, data) |
789 | 832 | role:checkTaskEnter("AdvDraw", {count = count, ptype = ptype}) |
790 | 833 | role:mylog("adv_action", {desc = "advWheelSurf", int1 = ptype, int2 = count}) |
791 | 834 | |
835 | + role:log("mission_pick_fund", { | |
836 | + item_id = ItemId.OldCoin, -- 资助花费道具ID | |
837 | + mission_pick_fund_amount = costs[ItemId.OldCoin], -- 资助花费道具数量 | |
838 | + mission_pick_fund_cnt = count, -- 资助花费道具次数,1或者10 | |
839 | + mission_pick_fund_reward = reward, -- 资助获得奖励,[{"id":100,"num":10},{"id":101,"num":20},{"id":102,"num":30}] | |
840 | + mission_pick_fund_stagereward = {}, -- 资助阶段奖励 | |
841 | + mission_pick_fund_beflv = oldLv, -- 资助前资助等级 | |
842 | + mission_pick_fund_aftlv = lv, -- 资助后资助等级 | |
843 | + }) | |
844 | + | |
792 | 845 | SendPacket(actionCodes.Adv_wheelSurfRpc, MsgPack.pack({reward = backReward})) |
793 | 846 | return true |
794 | 847 | end |
... | ... | @@ -903,4 +956,61 @@ function _M.refreshSupportRpc(agent, data) |
903 | 956 | return true |
904 | 957 | end |
905 | 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 | + | |
906 | 1016 | return _M |
907 | 1017 | \ No newline at end of file | ... | ... |
src/actions/DinerAction.lua
... | ... | @@ -75,6 +75,9 @@ function _M.addSellRpc( agent, data ) |
75 | 75 | sells[slot].count = count |
76 | 76 | sells[slot].time = skynet.timex() - calSell.deltaTime |
77 | 77 | |
78 | + local needTime = sells[slot].count * dishData.sell_time + sells[slot].time - skynet.timex() | |
79 | + role:pushMsg({type = "food", slot = slot, time = needTime}) | |
80 | + | |
78 | 81 | -- 检查解锁的顾客 |
79 | 82 | local had = {} |
80 | 83 | for _, sell in pairs(sells) do |
... | ... | @@ -155,6 +158,7 @@ function _M.removeSellRpc( agent, data ) |
155 | 158 | reward, change = role:award(reward, {log = {desc = "removeSell"}}) |
156 | 159 | sells[slot].count = 0 |
157 | 160 | |
161 | + role:pushCancel({type = "food", slot = slot}) | |
158 | 162 | role:log("restaurant_sale", { |
159 | 163 | item_id = dish, -- 售卖物品ID |
160 | 164 | restaurant_sale_seat = slot, -- 售卖物品所在位置 |
... | ... | @@ -605,10 +609,10 @@ function _M.refreshTaskRpc( agent, data ) |
605 | 609 | local role = agent.role |
606 | 610 | local msg = MsgPack.unpack(data) |
607 | 611 | |
608 | - local cost = {[ItemId.Diamond] = 40} | |
609 | - if not role:checkItemEnough(cost) then | |
610 | - return 1 | |
611 | - end | |
612 | + --local cost = {[ItemId.Diamond] = 40} | |
613 | + --if not role:checkItemEnough(cost) then | |
614 | + -- return 1 | |
615 | + --end | |
612 | 616 | |
613 | 617 | local orders = json.decode(role.dinerData:getProperty("order")) |
614 | 618 | ... | ... |
src/actions/EmailAction.lua
... | ... | @@ -121,7 +121,7 @@ function _M.drawAttachRpc(agent, data) |
121 | 121 | local attachments = getEmailAttachments(email) |
122 | 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 | 125 | email:setProperty("status", 2) |
126 | 126 | email:log(role, 2) |
127 | 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 | 402 | return "成功" |
403 | 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 | 420 | table.insert(helpDes, {"挂机清除" , "idlec"}) |
421 | 421 | function _M.idlec(role, pms) |
422 | - role:updateProperty({field = "hangTeam", value = {}}) | |
423 | 422 | role:updateProperty({field = "hangInfo", value = {}}) |
424 | 423 | role:updateProperty({field = "hangBag", value = {}}) |
425 | 424 | role:mylog("gm_action", {desc = "idlec", key1 = pms.sender}) |
... | ... | @@ -534,7 +533,8 @@ function _M.test(role, pms) |
534 | 533 | local id = tonum(pms.pm1, 0) |
535 | 534 | --local hero = require ("actions.HeroAction") |
536 | 535 | --hero.unlockPoolRpc({role = role}, MsgPack.pack({type = id})) |
537 | - print(role:getPaybackReward(0, 10000)) | |
536 | + | |
537 | + --role:sendMail(13, nil, "1=2", {111}) | |
538 | 538 | return "成功" |
539 | 539 | end |
540 | 540 | ... | ... |
src/actions/HangAction.lua
... | ... | @@ -22,9 +22,12 @@ local function checkReward(role) |
22 | 22 | return false |
23 | 23 | end |
24 | 24 | local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId] |
25 | + local expCarbonData = csvdb["idle_battleCsv"][hangInfo.expCarbonId] | |
25 | 26 | local nowCoinTime = math.min(skynet.timex(), hangInfo.endCoinTime or 0) |
26 | 27 | local nowItemTime = math.min(skynet.timex(), hangInfo.endItemTime or 0) |
27 | 28 | |
29 | + local expCoef, itemCoef = role.storeData:getHangDropCoef() | |
30 | + | |
28 | 31 | -- 此次挂机,其中翻倍时长占多少 |
29 | 32 | local doubleTime = role.activity:getActHangDoubleTime(hangInfo.coinTime, nowCoinTime) |
30 | 33 | local normalTime = nowCoinTime - hangInfo.coinTime - doubleTime |
... | ... | @@ -38,10 +41,10 @@ local function checkReward(role) |
38 | 41 | hangInfo.itemTime = nowItemTime |
39 | 42 | |
40 | 43 | local items = role:getProperty("hangBag") |
41 | - coinCount = coinCount + coinDoubleCount | |
42 | - items[ItemId.Gold] = math.floor((items[ItemId.Gold] or 0) + coinCount * carbonData.money) | |
43 | - items[ItemId.Exp] = math.floor((items[ItemId.Exp] or 0) + coinCount * carbonData.exp) | |
44 | - items[ItemId.PlayerExp] = math.floor((items[ItemId.PlayerExp] or 0) + coinCount * carbonData.playerExp) | |
44 | + coinCount = (coinCount + coinDoubleCount) * expCoef | |
45 | + items[ItemId.Gold] = math.floor((items[ItemId.Gold] or 0) + coinCount * expCarbonData.money) | |
46 | + items[ItemId.Exp] = math.floor((items[ItemId.Exp] or 0) + coinCount * expCarbonData.exp) | |
47 | + items[ItemId.PlayerExp] = math.floor((items[ItemId.PlayerExp] or 0) + coinCount * expCarbonData.playerExp) | |
45 | 48 | |
46 | 49 | local pool = {} |
47 | 50 | for _, temp in pairs(carbonData.item:toArray()) do |
... | ... | @@ -58,7 +61,8 @@ local function checkReward(role) |
58 | 61 | |
59 | 62 | -- 特权卡挂机额外栏位 |
60 | 63 | local privExtraCnt = role.storeData:getHangSlotExtraCount() |
61 | - local selfFC = role:getProperty("hangBagLimit") + privExtraCnt | |
64 | + --local selfFC = role:getProperty("hangBagLimit") + privExtraCnt | |
65 | + local selfFC = 50 | |
62 | 66 | local selfIC = selfFC * globalCsv.idle_field_limit |
63 | 67 | |
64 | 68 | local function randomItem() |
... | ... | @@ -73,6 +77,7 @@ local function checkReward(role) |
73 | 77 | if cur[1] == ItemId.BreakCost and doubleTime > 0 then |
74 | 78 | cur[2] = cur[2] * 2 |
75 | 79 | end |
80 | + cur[2] = cur[2] * itemCoef | |
76 | 81 | if (items[cur[1]] and math.ceil((items[cur[1]] + cur[2]) / globalCsv.idle_field_limit) > math.ceil(items[cur[1]] / globalCsv.idle_field_limit)) |
77 | 82 | or not items[cur[1]] then --要占用新栏位的情况 |
78 | 83 | local addFC |
... | ... | @@ -139,6 +144,7 @@ function _M.startRpc( agent, data ) |
139 | 144 | local hangInfo = role:getProperty("hangInfo") |
140 | 145 | local isNew = not hangInfo.carbonId |
141 | 146 | hangInfo.carbonId = carbonId |
147 | + hangInfo.expCarbonId = isNew and carbonId or hangInfo.expCarbonId | |
142 | 148 | local nowTime = skynet.timex() |
143 | 149 | if isNew then |
144 | 150 | hangInfo.coinTime = nowTime |
... | ... | @@ -149,23 +155,16 @@ function _M.startRpc( agent, data ) |
149 | 155 | hangInfo.coinTime = math.min(nowTime, hangInfo.endCoinTime) |
150 | 156 | hangInfo.itemTime = math.min(nowTime, hangInfo.endItemTime) |
151 | 157 | end |
158 | + | |
159 | + role:pushMsg({type = "hang", time = math.min(hangInfo.endCoinTime - nowTime, hangInfo.endItemTime - nowTime)}) | |
152 | 160 | if not role:checkHangPass(carbonId) then |
153 | 161 | hangInfo.bossTime = nowTime + carbonData.idle_time |
154 | 162 | else |
155 | 163 | hangInfo.bossTime = nil |
156 | 164 | end |
165 | + | |
157 | 166 | role:updateProperty({field = "hangInfo", value = hangInfo}) |
158 | 167 | |
159 | - -- 指定当前引导的步骤 | |
160 | - if carbonId == 10101 then | |
161 | - role:saveGuide(5,11) | |
162 | - elseif carbonId == 10102 then | |
163 | - role:saveGuide(8,2) | |
164 | - elseif carbonId == 10103 then | |
165 | - role:saveGuide(9,2) | |
166 | - elseif carbonId == 10220 then | |
167 | - role:saveGuide(22,1) | |
168 | - end | |
169 | 168 | role:mylog("hang_action", {desc = "startHang", int1 = carbonId}) |
170 | 169 | SendPacket(actionCodes.Hang_startRpc, '') |
171 | 170 | return true |
... | ... | @@ -193,12 +192,12 @@ function _M.startBattleRpc(agent, data) |
193 | 192 | return 1 |
194 | 193 | end |
195 | 194 | |
196 | - local hangInfo = role:getProperty("hangInfo") | |
197 | - if curData.main ~= 1 then | |
198 | - if carbonId ~= hangInfo.carbonId then | |
199 | - return 2 | |
200 | - end | |
201 | - end | |
195 | + --local hangInfo = role:getProperty("hangInfo") or {} | |
196 | + --if curData.main ~= 1 then | |
197 | + -- if carbonId ~= hangInfo.carbonId then | |
198 | + -- return 2 | |
199 | + -- end | |
200 | + --end | |
202 | 201 | |
203 | 202 | if role:checkHangPass(carbonId) then |
204 | 203 | return 3 |
... | ... | @@ -214,7 +213,7 @@ end |
214 | 213 | function _M.endBattleRpc(agent, data) |
215 | 214 | local role = agent.role |
216 | 215 | local msg = MsgPack.unpack(data) |
217 | - local hangInfo = role:getProperty("hangInfo") | |
216 | + local hangInfo = role:getProperty("hangInfo") or {} | |
218 | 217 | if not msg.key or msg.key ~= _BattleKey then |
219 | 218 | SendPacket(actionCodes.Hang_endBattleRpc, MsgPack.pack({errorCode = 1})) |
220 | 219 | return true |
... | ... | @@ -225,11 +224,12 @@ function _M.endBattleRpc(agent, data) |
225 | 224 | if not carbonData then |
226 | 225 | return 2 |
227 | 226 | end |
228 | - if carbonData.main ~= 1 then | |
229 | - if carbonId ~= hangInfo.carbonId then | |
230 | - return 3 | |
231 | - end | |
232 | - end | |
227 | + | |
228 | + --if carbonData.main ~= 1 then | |
229 | + -- if carbonId ~= hangInfo.carbonId then | |
230 | + -- return 3 | |
231 | + -- end | |
232 | + --end | |
233 | 233 | |
234 | 234 | if role:checkHangPass(carbonId) then |
235 | 235 | return 4 |
... | ... | @@ -255,12 +255,7 @@ function _M.endBattleRpc(agent, data) |
255 | 255 | |
256 | 256 | -- 引导 |
257 | 257 | if carbonId == 10101 then |
258 | - role:finishGuide(5) | |
259 | - elseif carbonId == 10102 then | |
260 | - role:finishGuide(8) | |
261 | - role:saveGuide(9, 2) | |
262 | - elseif carbonId == 10103 then | |
263 | - role:finishGuide(9) | |
258 | + role:finishGuide(6) | |
264 | 259 | elseif carbonId == 20101 then |
265 | 260 | role:finishGuide(22) |
266 | 261 | end |
... | ... | @@ -273,12 +268,20 @@ function _M.endBattleRpc(agent, data) |
273 | 268 | end |
274 | 269 | local nextCarbonId = role:getNextCarbonId(carbonId) |
275 | 270 | -- 设置挂机关卡 |
276 | - if isWin and hangInfo.carbonId < nextCarbonId then | |
277 | - hangInfo.carbonId = nextCarbonId | |
278 | - local cfg = csvdb["idle_battleCsv"][nextCarbonId] | |
279 | - if cfg then | |
280 | - hangInfo.bossTime = skynet.timex() + cfg.idle_time | |
271 | + if isWin then --and (hangInfo.carbonId or 0) < nextCarbonId then | |
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 | |
281 | 280 | end |
281 | + --local cfg = csvdb["idle_battleCsv"][nextCarbonId] | |
282 | + --if cfg then | |
283 | + -- hangInfo.bossTime = skynet.timex() + cfg.idle_time | |
284 | + --end | |
282 | 285 | end |
283 | 286 | role:updateProperty({field = "hangInfo", value = hangInfo}) |
284 | 287 | |
... | ... | @@ -310,7 +313,10 @@ end |
310 | 313 | function _M.roleFormatRpc(agent , data) |
311 | 314 | local role = agent.role |
312 | 315 | local msg = MsgPack.unpack(data) |
313 | - local hangTeam = role:getProperty("hangTeam") | |
316 | + local index = msg.index -- 阵容索引 | |
317 | + local title = msg.title -- 阵容名称 | |
318 | + local tactics = msg.tactics -- 战术 | |
319 | + local team = {} | |
314 | 320 | for slot, heroId in pairs(msg.heros) do |
315 | 321 | if not role.heros[heroId] then |
316 | 322 | return 1 |
... | ... | @@ -326,15 +332,27 @@ function _M.roleFormatRpc(agent , data) |
326 | 332 | end |
327 | 333 | if not checkLeader(msg.heros, msg.leader) then return 4 end |
328 | 334 | |
329 | - table.clear(hangTeam) | |
330 | - 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 = {} | |
331 | 344 | for slot, heroId in pairs(msg.heros) do |
332 | - hangTeam.heros[slot] = heroId | |
345 | + team.heros[slot] = heroId | |
333 | 346 | end |
334 | - hangTeam.leader = msg.leader | |
335 | - hangTeam.supports = supports | |
336 | - role:saveHangTeam(hangTeam) | |
337 | - role:saveGuide(5,8) | |
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 | + | |
338 | 356 | SendPacket(actionCodes.Hang_roleFormatRpc, '') |
339 | 357 | return true |
340 | 358 | end |
... | ... | @@ -354,7 +372,9 @@ function _M.getRewardRpc(agent , data) |
354 | 372 | hangInfo.itemTime = nowTime |
355 | 373 | role:updateProperty({field = "hangBag", value = items}) |
356 | 374 | role:updateProperty({field = "hangInfo", value = hangInfo}) |
357 | - role:checkTaskEnter("HangGet") | |
375 | + role:pushMsg({type = "hang", time = globalCsv.idle_producetime_max}) | |
376 | + | |
377 | + role:checkTaskEnter("HangGet", {reward = reward}) | |
358 | 378 | if reward[ItemId.Gold] then |
359 | 379 | role:checkTaskEnter("HangGetGold", {count = reward[ItemId.Gold]}) |
360 | 380 | end |
... | ... | @@ -382,6 +402,7 @@ function _M.quickRpc(agent , data) |
382 | 402 | local hangInfo = role:getProperty("hangInfo") |
383 | 403 | if not hangInfo.carbonId then return end |
384 | 404 | local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId] |
405 | + local expCarbonData = csvdb["idle_battleCsv"][hangInfo.expCarbonId] | |
385 | 406 | |
386 | 407 | local curCount = role.dailyData:getProperty("hangQC") + 1 |
387 | 408 | local costs = globalCsv.idle_quickproduce_cost:toArray(true, "=") |
... | ... | @@ -398,9 +419,9 @@ function _M.quickRpc(agent , data) |
398 | 419 | |
399 | 420 | local coinCount = math.floor(time / globalCsv.idle_money_produce_cd) |
400 | 421 | local itemCount = math.floor(time / globalCsv.idle_item_produce_cd) |
401 | - reward[ItemId.Gold] = math.floor((reward[ItemId.Gold] or 0) + coinCount * carbonData.money) | |
402 | - reward[ItemId.Exp] = math.floor((reward[ItemId.Exp] or 0) + coinCount * carbonData.exp) | |
403 | - reward[ItemId.PlayerExp] = math.floor((reward[ItemId.PlayerExp] or 0) + coinCount * carbonData.playerExp) | |
422 | + reward[ItemId.Gold] = math.floor((reward[ItemId.Gold] or 0) + coinCount * expCarbonData.money) | |
423 | + reward[ItemId.Exp] = math.floor((reward[ItemId.Exp] or 0) + coinCount * expCarbonData.exp) | |
424 | + reward[ItemId.PlayerExp] = math.floor((reward[ItemId.PlayerExp] or 0) + coinCount * expCarbonData.playerExp) | |
404 | 425 | |
405 | 426 | local pool = {} |
406 | 427 | for _, temp in pairs(carbonData.item:toArray()) do |
... | ... | @@ -442,36 +463,6 @@ function _M.quickRpc(agent , data) |
442 | 463 | return true |
443 | 464 | end |
444 | 465 | |
445 | -function _M.bonusFormatRpc(agent , data) | |
446 | - local role = agent.role | |
447 | - local msg = MsgPack.unpack(data) | |
448 | - local bTeam = role:getProperty("bTeam") | |
449 | - for slot, heroId in pairs(msg.heros) do | |
450 | - if not role.heros[heroId] then | |
451 | - return | |
452 | - end | |
453 | - end | |
454 | - local supports = {} | |
455 | - for slot, support in pairs(msg.supports) do | |
456 | - if slot ~= 1 and slot ~= 2 then return end | |
457 | - local level = role.dinerData:getProperty("dishTree"):getv(support, 0) | |
458 | - if level <= 0 then return end | |
459 | - supports[slot] = support | |
460 | - end | |
461 | - if not checkLeader(msg.heros, msg.leader) then return end | |
462 | - | |
463 | - table.clear(bTeam) | |
464 | - bTeam.heros = {} | |
465 | - for slot, heroId in pairs(msg.heros) do | |
466 | - bTeam.heros[slot] = heroId | |
467 | - end | |
468 | - bTeam.leader = msg.leader | |
469 | - bTeam.supports = supports | |
470 | - | |
471 | - role:updateProperty({field = "bTeam", value = bTeam}) | |
472 | - SendPacket(actionCodes.Hang_bonusFormatRpc, '') | |
473 | - return true | |
474 | -end | |
475 | 466 | |
476 | 467 | function _M.buyBonusCountRpc(agent, data) |
477 | 468 | local role = agent.role |
... | ... | @@ -490,8 +481,9 @@ function _M.buyBonusCountRpc(agent, data) |
490 | 481 | end |
491 | 482 | |
492 | 483 | local bonusC = role.dailyData:getProperty("bonusC") |
484 | + local extraCnt = role.storeData:getBonusExtraFightCount() | |
493 | 485 | bonusC[btype] = bonusC[btype] or {c = 0, b = 0} |
494 | - local lastCount = globalCsv.bonus_daily_buy_count * coef - bonusC[btype]["b"] | |
486 | + local lastCount = globalCsv.bonus_daily_buy_count * coef + extraCnt - bonusC[btype]["b"] | |
495 | 487 | if math.illegalNum(count, 1, lastCount) then return 1 end |
496 | 488 | |
497 | 489 | if not role:checkItemEnough({[ItemId.Diamond] = globalCsv.bonus_buy_cost * count}) then return 2 end |
... | ... | @@ -506,10 +498,53 @@ function _M.buyBonusCountRpc(agent, data) |
506 | 498 | return true |
507 | 499 | end |
508 | 500 | |
501 | +local function bonusWinReward(role, bonusData, bwin, count) | |
502 | + count = count or 1 | |
503 | + local open, actId = role.activity:isOpen("BonusDouble") | |
504 | + local actData = csvdb["activity_ctrlCsv"][actId] | |
505 | + local extraCnt = role.storeData:getBonusExtraFightCount() | |
506 | + | |
507 | + local coef = 1 | |
508 | + if open and actData then | |
509 | + coef = tonumber(actData.condition2) | |
510 | + end | |
511 | + local bonusC = role.dailyData:getProperty("bonusC") | |
512 | + bonusC[bonusData.type] = bonusC[bonusData.type] or {c = 0, b = 0} | |
513 | + if globalCsv.bonus_daily_count * coef + extraCnt - bonusC[bonusData.type]["c"] < count then return false, 1 end | |
514 | + bonusC[bonusData.type]["c"] = bonusC[bonusData.type]["c"] + count | |
515 | + role.dailyData:updateProperty({field = "bonusC", value = bonusC}) | |
516 | + | |
517 | + local reward, change | |
518 | + reward = bonusData.reward:toNumMap() | |
519 | + for itemId, c in pairs(reward) do | |
520 | + reward[itemId] = c * count | |
521 | + end | |
522 | + for i = 1, count do | |
523 | + local chance = bonusData.chance:randWeight(true) | |
524 | + if chance[1] ~= 0 then | |
525 | + reward[chance[1]] = (reward[chance[1]] or 0) + chance[2] | |
526 | + end | |
527 | + end | |
528 | + | |
529 | + for k, v in pairs(reward) do | |
530 | + reward[k] = v * (coef > 1 and actData.condition or 1) | |
531 | + end | |
532 | + | |
533 | + if bwin then -- 满星 额外奖励 | |
534 | + for k, v in pairs(bonusData.perfect_reward:toNumMap()) do | |
535 | + reward[k] = (reward[k] or 0) + v | |
536 | + end | |
537 | + end | |
538 | + reward, change = role:award(reward, {log = {desc = "bonusBattle", int1 = id}}) | |
539 | + role:checkTaskEnter("BonusPass", {id = id, count = count}) | |
540 | + return true, reward, change | |
541 | +end | |
542 | + | |
509 | 543 | function _M.startBonusBattleRpc(agent, data) |
510 | 544 | local role = agent.role |
511 | 545 | local msg = MsgPack.unpack(data) |
512 | 546 | local id = msg.id |
547 | + local count = msg.count or 1 | |
513 | 548 | |
514 | 549 | local open, actId = role.activity:isOpen("BonusDouble") |
515 | 550 | |
... | ... | @@ -524,26 +559,34 @@ function _M.startBonusBattleRpc(agent, data) |
524 | 559 | if not bonusData then return 3 end |
525 | 560 | if not role:checkHangPass(bonusData.unlock) then return 4 end |
526 | 561 | |
527 | - if not next(role:getProperty("bTeam")) then return 5 end | |
528 | - | |
529 | 562 | local bonusC = role.dailyData:getProperty("bonusC") |
530 | 563 | bonusC[bonusData.type] = bonusC[bonusData.type] or {c = 0, b = 0} |
531 | 564 | |
532 | 565 | local actData = csvdb["activity_ctrlCsv"][actId] |
533 | 566 | |
567 | + local extraCnt = role.storeData:getBonusExtraFightCount() | |
534 | 568 | local coef = 1 |
535 | 569 | if open and actData then |
536 | 570 | coef = tonumber(actData.condition2) |
537 | 571 | end |
572 | + | |
573 | + if math.illegalNum(count, 1, globalCsv.bonus_daily_count * coef + extraCnt - bonusC[bonusData.type]["c"]) then return 7 end | |
538 | 574 | |
539 | - if globalCsv.bonus_daily_count * coef - bonusC[bonusData.type]["c"] <= 0 then return 7 end | |
540 | - | |
575 | + local bonusStar = role:getProperty("bonusStar") | |
576 | + if bonusStar[id] and bonusStar[id] >= (1 << #bonusData.sweep_condition:toTableArray(true)) - 1 then | |
577 | + local status, reward, change = bonusWinReward(role, bonusData, nil, count) | |
578 | + if not status then return 10 * (reward or 0) end | |
579 | + SendPacket(actionCodes.Hang_startBonusBattleRpc, MsgPack.pack({reward = reward, change = change})) | |
580 | + else | |
581 | + local bTeam = role:getTeamFormatByType(TeamSystemType.BonusBattle) | |
582 | + if not next(bTeam) then return 5 end | |
583 | + role.__bonusBattleCache = { | |
584 | + key = tostring(math.random()), | |
585 | + id = id, | |
586 | + } | |
587 | + SendPacket(actionCodes.Hang_startBonusBattleRpc, MsgPack.pack({key = role.__bonusBattleCache.key})) | |
588 | + end | |
541 | 589 | |
542 | - role.__bonusBattleCache = { | |
543 | - key = tostring(math.random()), | |
544 | - id = id, | |
545 | - } | |
546 | - SendPacket(actionCodes.Hang_startBonusBattleRpc, MsgPack.pack({key = role.__bonusBattleCache.key})) | |
547 | 590 | return true |
548 | 591 | end |
549 | 592 | |
... | ... | @@ -554,13 +597,7 @@ function _M.endBonusBattleRpc(agent, data) |
554 | 597 | local key = msg.key |
555 | 598 | local starNum = msg.starNum |
556 | 599 | if not role.__bonusBattleCache then return 1 end |
557 | - local open, actId = role.activity:isOpen("BonusDouble") | |
558 | - local actData = csvdb["activity_ctrlCsv"][actId] | |
559 | - | |
560 | - local coef = 1 | |
561 | - if open and actData then | |
562 | - coef = tonumber(actData.condition2) | |
563 | - end | |
600 | + | |
564 | 601 | |
565 | 602 | if role.__bonusBattleCache.id ~= id or role.__bonusBattleCache.key ~= key then |
566 | 603 | SendPacket(actionCodes.Hang_endBonusBattleRpc, MsgPack.pack({errorCode = 1})) |
... | ... | @@ -569,24 +606,79 @@ function _M.endBonusBattleRpc(agent, data) |
569 | 606 | local bonusData = csvdb["bonus_battleCsv"][id] |
570 | 607 | |
571 | 608 | local reward, change |
609 | + | |
610 | + local bonusStar = role:getProperty("bonusStar") | |
611 | + local curStar = 0 | |
572 | 612 | if starNum and starNum > 0 then |
573 | 613 | -- 胜利扣除次数 |
574 | - local bonusC = role.dailyData:getProperty("bonusC") | |
575 | - bonusC[bonusData.type] = bonusC[bonusData.type] or {c = 0, b = 0} | |
576 | - if globalCsv.bonus_daily_count * coef - bonusC[bonusData.type]["c"] <= 0 then return 3 end | |
577 | - bonusC[bonusData.type]["c"] = bonusC[bonusData.type]["c"] + 1 | |
578 | - role.dailyData:updateProperty({field = "bonusC", value = bonusC}) | |
579 | - | |
580 | - reward = bonusData.reward:toNumMap() | |
581 | - local chance = bonusData.chance:randWeight(true) | |
582 | - if chance[1] ~= 0 then | |
583 | - reward[chance[1]] = (reward[chance[1]] or 0) + chance[2] | |
614 | + | |
615 | + local bTeam = role:getTeamFormatByType(TeamSystemType.BonusBattle) | |
616 | + local herosInfo = role:getTeamHerosInfo(bTeam.heros) | |
617 | + | |
618 | + local check = {} | |
619 | + -- 1 通关 | |
620 | + check[1] = function(_) | |
621 | + return true | |
622 | + end | |
623 | + -- 2 阵亡人数 <= N | |
624 | + check[2] = function(_, cond) | |
625 | + return msg.info.dead and msg.info.dead <= cond | |
626 | + end | |
627 | + -- 3 全员存活 | |
628 | + check[3] = function(_) | |
629 | + return msg.info.dead and msg.info.dead == 0 | |
630 | + end | |
631 | + -- 4 指定种族 >= N | |
632 | + check[4] = function(_, cond) | |
633 | + local count = 0 | |
634 | + for _, one in pairs(herosInfo) do | |
635 | + local heroData = csv["unitCsv"][one.type] | |
636 | + if heroData.camp == cond then | |
637 | + count = count + 1 | |
638 | + end | |
639 | + end | |
640 | + return count >= cond | |
641 | + end | |
642 | + -- 5 指定职业 >= N | |
643 | + check[5] = function(_, cond) | |
644 | + local count = 0 | |
645 | + for _, one in pairs(herosInfo) do | |
646 | + local heroData = csv["unitCsv"][one.type] | |
647 | + if heroData.job == cond then | |
648 | + count = count + 1 | |
649 | + end | |
650 | + end | |
651 | + return count >= cond | |
652 | + end | |
653 | + -- 6 含有指定角色 | |
654 | + check[6] = function(_, cond) | |
655 | + for _, one in pairs(herosInfo) do | |
656 | + if one.type == cond then | |
657 | + return true | |
658 | + end | |
659 | + end | |
660 | + return false | |
584 | 661 | end |
585 | - for k, v in pairs(reward) do | |
586 | - reward[k] = v * (coef > 1 and actData.condition or 1) | |
662 | + -- 7 通关耗时 <= X 秒 msg.info.atime | |
663 | + check[7] = function(_, cond) | |
664 | + return msg.info.atime and msg.info.atime <= cond | |
587 | 665 | end |
588 | - reward, change = role:award(reward, {log = {desc = "bonusBattle", int1 = id}}) | |
589 | - role:checkTaskEnter("BonusPass", {id = id}) | |
666 | + curStar = 0 | |
667 | + local sweepConds = bonusData.sweep_condition:toTableArray(true) | |
668 | + for i, cond in ipairs(sweepConds) do | |
669 | + if check[cond[1]] and check[cond[1]](table.unpack(cond)) then | |
670 | + curStar = curStar + (1 << (i - 1)) | |
671 | + end | |
672 | + end | |
673 | + local status | |
674 | + status, reward, change = bonusWinReward(role, bonusData, curStar >= (1 << #sweepConds) - 1) | |
675 | + if not status then return 10 + (reward or 0) end | |
676 | + else | |
677 | + curStar = 0 | |
678 | + end | |
679 | + if curStar ~= bonusStar[id] then | |
680 | + bonusStar[id] = curStar | |
681 | + role:updateProperty({field = "bonusStar", value = bonusStar}) | |
590 | 682 | end |
591 | 683 | |
592 | 684 | role:checkBattle("bonus", { |
... | ... | @@ -665,4 +757,29 @@ function _M.chatLineRpc(agent, data) |
665 | 757 | return true |
666 | 758 | end |
667 | 759 | |
668 | -return _M | |
669 | 760 | \ No newline at end of file |
761 | +function _M.selectTeamRpc(agent, data) | |
762 | + local role = agent.role | |
763 | + local msg = MsgPack.unpack(data) | |
764 | + local index = msg.index -- 阵容索引 | |
765 | + local type = msg.type -- 系统类型 | |
766 | + | |
767 | + if index > 10 then | |
768 | + return 1 | |
769 | + end | |
770 | + local team = role:getTeamFormat(index) | |
771 | + if not next(team) then return 2 end | |
772 | + | |
773 | + local teamIndex = role:getProperty("teamIndex") or {} | |
774 | + teamIndex[type] = index | |
775 | + role:updateProperty({field = "teamIndex", value = teamIndex}) | |
776 | + | |
777 | + if type == TeamSystemType.Hang then | |
778 | + role:finishGuide(5) | |
779 | + role:updateHangTeamInfo() | |
780 | + end | |
781 | + | |
782 | + SendPacket(actionCodes.Hang_selectTeamRpc, '') | |
783 | + return true | |
784 | +end | |
785 | + | |
786 | +return _M | ... | ... |
src/actions/HeroAction.lua
... | ... | @@ -54,12 +54,11 @@ function _M.levelUpRpc( agent, data ) |
54 | 54 | hero_upgrade_scoreget = hero:getProperty("battleV") - oldBattleV, -- 通过英雄升级提升的评分 |
55 | 55 | }) |
56 | 56 | |
57 | - if hero:getProperty("type") == 103 then | |
58 | - role:finishGuide(7) | |
59 | - end | |
60 | 57 | hero:mylog({desc = "levelUp", int1 = hero:getProperty("level")}) |
61 | 58 | |
62 | 59 | role:checkTaskEnter("HeroLevelUp", {level = hero:getProperty("level")}) |
60 | + | |
61 | + role:checkTaskEnter("HeroLvlCollect", {}) | |
63 | 62 | SendPacket(actionCodes.Hero_levelUpRpc, '') |
64 | 63 | return true |
65 | 64 | end |
... | ... | @@ -127,7 +126,13 @@ function _M.wakeRpc(agent, data) |
127 | 126 | hero_rise_result = getChangeAttrJson(oldAttr, hero:getTotalAttrs()), --英雄觉醒效果,可记录效果ID,或json格式记录提升效果,{攻击:20,闪避:20,……..} |
128 | 127 | }) |
129 | 128 | |
129 | + if hero:getProperty("type") == 204 then | |
130 | + role:finishGuide(7) | |
131 | + end | |
132 | + | |
130 | 133 | SendPacket(actionCodes.Hero_wakeRpc, '') |
134 | + | |
135 | + role:checkTaskEnter("HeroStarCollect", {}) | |
131 | 136 | return true |
132 | 137 | end |
133 | 138 | |
... | ... | @@ -138,74 +143,45 @@ function _M.talentRpc(agent, data) |
138 | 143 | local hero = role.heros[msg.id] |
139 | 144 | if not hero then return 1 end |
140 | 145 | |
141 | - local index = msg.index -- 第几个天赋 | |
142 | - local need = {[0] = 1, [1] = 1, [2] = 1, [3] = 1, [4] = 1} | |
143 | - if not need[index] then return 2 end | |
144 | - | |
145 | 146 | local talent = hero:getProperty("talent") |
147 | + local heroCfgId = hero:getProperty("type") | |
146 | 148 | local curStage = talent:getv(0, 1) |
147 | - local curData = csvdb["unit_talentCsv"][curStage] | |
148 | - if not curData then return 4 end | |
149 | + local curLevel = talent:getv(1, 1) | |
150 | + local curData = csvdb["unit_talent_"..heroCfgId.."Csv"][curStage] | |
151 | + if not curData then return 1 end | |
149 | 152 | local oldSkillLv = hero:getSkillLevel(1) |
150 | 153 | |
151 | 154 | |
152 | 155 | local cost = {} |
153 | - if index == 0 then | |
154 | - --是否进阶 | |
155 | - local max = true | |
156 | - for i = 1, 4 do | |
157 | - if talent:getv(i, 0) < #curData then | |
158 | - max = false | |
159 | - break | |
160 | - end | |
161 | - end | |
162 | - if max then | |
163 | - talent = talent:setv(0, curStage + 1) | |
164 | - for i = 1, 4 do | |
165 | - talent = talent:setv(i, 0) | |
166 | - end | |
167 | - else | |
168 | - return 12 | |
169 | - end | |
156 | + if curLevel == #curData then | |
157 | + talent = talent:setv(0, curStage + 1) | |
158 | + talent = talent:setv(1, 1) | |
170 | 159 | else |
171 | - | |
172 | - local level = talent:getv(index, 0) | |
173 | - if level >= #curData then return 5 end | |
160 | + if curLevel > #curData then return 2 end | |
174 | 161 | |
175 | - local talentData = curData[level] | |
176 | - if not talentData then return end | |
162 | + local talentData = curData[curLevel] | |
163 | + if not talentData then return 3 end | |
177 | 164 | |
178 | - if talentData.lvRequire > hero:getProperty("level") then return 6 end | |
165 | + if talentData.lvRequire > hero:getProperty("level") then return 4 end | |
179 | 166 | |
180 | 167 | cost = talentData.money:toNumMap() |
181 | - local cost2 = talentData.cost:toNumMap() | |
182 | - for k,v in pairs(cost2) do | |
183 | - cost[globalCsv.unit_talent_cost[csvdb["unitCsv"][hero:getProperty("type")].camp][k]] = v | |
184 | - end | |
185 | - if not role:checkItemEnough(cost) then return 6 end | |
168 | + if not role:checkItemEnough(cost) then return 5 end | |
186 | 169 | role:costItems(cost, {log = {desc = "heroTalent", int1 = msg.id, int2 = hero:getProperty("type")}}) |
187 | - talent = talent:incrv(index, 1) | |
188 | - | |
189 | - | |
190 | - local aheadLevel = 0 | |
191 | - for i = 1, talent:getv(0, 1) - 1 do | |
192 | - aheadLevel = aheadLevel + #csvdb["unit_talentCsv"][i] | |
193 | - end | |
194 | - aheadLevel = aheadLevel + talent:getv(index, 0) | |
195 | - | |
196 | - role:checkTaskEnter("HeroTalent", {heroType = hero:getProperty("type"), alv = aheadLevel}) | |
170 | + talent = talent:setv(1, curLevel + 1) | |
197 | 171 | end |
172 | + curStage = talent:getv(0, 1) | |
173 | + role:checkTaskEnter("HeroTalent", {heroType = hero:getProperty("type"), alv = curStage}) | |
198 | 174 | |
199 | 175 | hero:updateProperty({field = "talent", value = talent}) |
200 | 176 | |
201 | 177 | role:log("hero_talent", { |
202 | 178 | hero_id = hero:getProperty("type"), --英雄ID |
203 | - hero_talent_id = index, --天赋ID | |
179 | + hero_talent_id = curStage, --天赋ID | |
204 | 180 | hero_talent_cost = cost, -- 英雄天赋升级消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...} |
205 | 181 | hero_talent_levelbef = oldSkillLv, -- 英雄技能升级前等级 |
206 | 182 | hero_talent_level = hero:getSkillLevel(1), -- 英雄技能升级后等级 |
207 | 183 | }) |
208 | - hero:mylog({desc = "talent", int1 = index, int2 = talent:getv(index, 0)}) | |
184 | + hero:mylog({desc = "talent", int1 = talent:getv(0, 1), int2 = talent:getv(1, 1)}) | |
209 | 185 | |
210 | 186 | SendPacket(actionCodes.Hero_talentRpc, '') |
211 | 187 | return true |
... | ... | @@ -595,6 +571,8 @@ function _M.referRunesRpc(agent, data) |
595 | 571 | }) |
596 | 572 | end |
597 | 573 | end |
574 | + | |
575 | + role:checkTaskEnter("RuneQualityCollect", {}) | |
598 | 576 | |
599 | 577 | SendPacket(actionCodes.Hero_referRunesRpc, "") |
600 | 578 | return true |
... | ... | @@ -607,16 +585,16 @@ function _M.createHeroRandomRpc(agent, data) |
607 | 585 | local itemData = csvdb["itemCsv"][itemId] |
608 | 586 | if not itemData or itemData.type ~= ItemType.HeroFCommon then return end |
609 | 587 | local cost = globalCsv.unit_fragment_cost[itemData.quality] |
610 | - if not cost or role:getItemCount(itemId) < cost then return end | |
588 | + if not cost or role:getItemCount(itemId) < cost then return 1 end | |
611 | 589 | |
612 | 590 | local randomData = csvdb["item_randomCsv"][tonumber(itemData.use_effect)] |
613 | - if not randomData then return end | |
591 | + if not randomData then return 2 end | |
614 | 592 | |
615 | 593 | local temp = randomData.gift1:randWeight(true) |
616 | - if not temp or not next(temp) then return end | |
594 | + if not temp or not next(temp) then return 3 end | |
617 | 595 | |
618 | 596 | role:costItems({[itemId] = cost}, {log = {desc = "createHeroRandom"}}) |
619 | - 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"}}) | |
620 | 598 | |
621 | 599 | |
622 | 600 | SendPacket(actionCodes.Hero_createHeroRandomRpc, MsgPack.pack(role:packReward(reward, change))) |
... | ... | @@ -633,9 +611,37 @@ function _M.getResetRewardRpc(agent, data) |
633 | 611 | local level = hero:getProperty("level") |
634 | 612 | local breakL = hero:getProperty("breakL") |
635 | 613 | local talent = hero:getProperty("talent") |
614 | + local heroCfgId = hero:getProperty("type") | |
636 | 615 | |
616 | + local tmpLevel = level | |
637 | 617 | if level <= 1 and talent == "" then return end |
638 | 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 | + | |
639 | 645 | local reward = {} |
640 | 646 | while level > 1 do |
641 | 647 | local curData = csvdb["unit_expCsv"][level - 1] |
... | ... | @@ -652,32 +658,18 @@ function _M.getResetRewardRpc(agent, data) |
652 | 658 | end |
653 | 659 | |
654 | 660 | local stage = talent:getv(0, 1) |
655 | - 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)} | |
656 | 663 | |
657 | - local talentCostIds = globalCsv.unit_talent_cost[csvdb["unitCsv"][hero:getProperty("type")].camp] | |
658 | 664 | while stage > 0 do |
659 | - local curData = csvdb["unit_talentCsv"][stage] | |
660 | - for level = math.max(table.unpack(tlevel)), 1, -1 do | |
661 | - local add = 0 | |
662 | - for i = 1, 4 do | |
663 | - if tlevel[i] == level then | |
664 | - add = add + 1 | |
665 | - tlevel[i] = tlevel[i] - 1 | |
666 | - end | |
667 | - end | |
668 | - 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] | |
669 | 668 | for itemId, count in pairs(talentData.money:toNumMap()) do |
670 | - reward[itemId] = (reward[itemId] or 0) + count * add | |
671 | - end | |
672 | - for idx , count in pairs(talentData.cost:toNumMap()) do | |
673 | - reward[talentCostIds[idx]] = (reward[talentCostIds[idx]] or 0) + count * add | |
669 | + reward[itemId] = (reward[itemId] or 0) + count | |
674 | 670 | end |
675 | 671 | end |
676 | 672 | stage = stage - 1 |
677 | - curData = csvdb["unit_talentCsv"][stage] | |
678 | - if curData then | |
679 | - tlevel = {#curData, #curData, #curData, #curData} | |
680 | - end | |
681 | 673 | end |
682 | 674 | |
683 | 675 | local equip = hero:getProperty("equip") |
... | ... | @@ -701,9 +693,11 @@ function _M.getResetRewardRpc(agent, data) |
701 | 693 | rune = "", |
702 | 694 | }) |
703 | 695 | hero:mylog({desc = "resetHero"}) |
704 | - | |
696 | + | |
697 | + --local coef = globalCsv.unit_back_discount | |
698 | + --coef = (pay or tmpLevel <= 60) and 1 or coef | |
705 | 699 | for itemId, count in pairs(reward) do |
706 | - reward[itemId] = math.floor(count * globalCsv.unit_back_discount) | |
700 | + reward[itemId] = count | |
707 | 701 | end |
708 | 702 | local change |
709 | 703 | reward, change = role:award(reward, {log = {desc = "resetHero", int1 = msg.id, int2 = hero:getProperty("type")}}) |
... | ... | @@ -722,11 +716,21 @@ function _M.drawHeroRpc(agent, data) |
722 | 716 | local msg = MsgPack.unpack(data) |
723 | 717 | |
724 | 718 | if not role:isFuncUnlock(FuncUnlock.GetHero) then return 1 end |
725 | - local btype = msg.pool -- 1 2 3 卡池类型 | |
719 | + local btype = msg.pool -- 1 2 3 4 5 卡池类型 4新手卡池 5心愿卡池 | |
726 | 720 | local subType = msg.subType or 1-- 定向卡池需要传 子类型 |
727 | 721 | local drawType = msg.type -- 1 单抽 2 十连 |
728 | 722 | if btype ~= 1 then |
729 | 723 | subType = 1 |
724 | + if btype == 4 and role:getProperty("newerDraw") >= 10 then | |
725 | + subType = 2 | |
726 | + end | |
727 | + end | |
728 | + | |
729 | + if btype == 1 then | |
730 | + -- 判断定向卡池活动开启 | |
731 | + if not role.activity:isOpen("RaceDraw") then | |
732 | + return | |
733 | + end | |
730 | 734 | end |
731 | 735 | |
732 | 736 | local buildTypeData = csvdb["build_typeCsv"][btype] |
... | ... | @@ -740,23 +744,32 @@ function _M.drawHeroRpc(agent, data) |
740 | 744 | |
741 | 745 | -- 计算抽卡消耗品 |
742 | 746 | local cost = {} |
743 | - local lastCount = drawCount[drawType] | |
744 | - for _, costType in ipairs({"draw_card", "draw_coin"}) do | |
747 | + if buildTypeData["draw_coin_1"] == "" then | |
748 | + return 11 | |
749 | + end | |
750 | + local diamondCost = buildTypeData["draw_coin_1"]:toArray(true, "=") | |
751 | + | |
752 | + local isEnough = true | |
753 | + for _, costType in ipairs({"draw_card_"}) do | |
754 | + costType = costType..drawCount[drawType] | |
745 | 755 | if buildTypeData[costType] ~= "" then |
746 | 756 | local curCost = buildTypeData[costType]:toArray(true, "=") |
747 | 757 | local hadCount = role:getItemCount(curCost[1]) |
748 | - local curCount = math.floor(hadCount / curCost[2]) | |
749 | - if curCount >= lastCount then | |
750 | - cost[curCost[1]] = curCost[2] * lastCount | |
751 | - lastCount = 0 | |
758 | + if hadCount >= curCost[2] then | |
759 | + cost[curCost[1]] = curCost[2] | |
752 | 760 | break |
753 | - elseif curCount > 0 then | |
754 | - cost[curCost[1]] = curCost[2] * curCount | |
755 | - lastCount = lastCount - curCount | |
761 | + else | |
762 | + cost[curCost[1]] = hadCount | |
763 | + diamondCost[2] = (curCost[2] - hadCount) * diamondCost[2] | |
764 | + if not role:checkItemEnough({[diamondCost[1]]=diamondCost[2]}) then | |
765 | + isEnough = false | |
766 | + break | |
767 | + end | |
768 | + cost[diamondCost[1]] = diamondCost[2] | |
756 | 769 | end |
757 | 770 | end |
758 | 771 | end |
759 | - if lastCount > 0 then -- 钱不够 | |
772 | + if isEnough == false then -- 钱不够 | |
760 | 773 | return 4 |
761 | 774 | end |
762 | 775 | |
... | ... | @@ -806,26 +819,47 @@ function _M.drawHeroRpc(agent, data) |
806 | 819 | end |
807 | 820 | end |
808 | 821 | |
809 | - for itemId, oneData in pairs(isFloorBack and csvdb["build_floorCsv"] or csvdb["build_poolCsv"]) do | |
810 | - local pool_str = "pool_" .. poolId | |
811 | - if oneData[pool_str] and oneData[pool_str] ~= "" then | |
812 | - local itemData = csvdb["itemCsv"][itemId] | |
813 | - while itemData do | |
814 | - if itemData.type ~= ItemType.Hero then break end | |
815 | - local heroData = csvdb["unitCsv"][itemData.id - ItemStartId.Hero] | |
816 | - if not heroData then break end | |
817 | - local ok = true | |
818 | - -- 保底是全随机,不用比较类型 | |
819 | - if not isFloorBack then | |
820 | - for idx, field in ipairs(condition) do | |
821 | - if heroData[field] ~= values[idx] then ok = false break end | |
822 | + local weight = 0 | |
823 | + local up_pool = nil | |
824 | + local rand_v = math.randomInt(1, 100) | |
825 | + if values[1] == HeroQuality.SR then | |
826 | + weight = unitPool["up_sr_weight"] | |
827 | + up_pool = unitPool["up_sr_id"] | |
828 | + elseif values[1] == HeroQuality.SSR then | |
829 | + weight = unitPool["up_ssr_weight"] | |
830 | + up_pool = unitPool["up_ssr_id"] | |
831 | + end | |
832 | + --print(poolId, rand_v, weight, up_pool, values[1]) | |
833 | + if rand_v < weight and up_pool then | |
834 | + up_pool = up_pool:toArray(true, "=") | |
835 | + if btype == 5 then -- 爱心卡池,使用玩家设置的备选池子 | |
836 | + up_pool = role:getProperty("wishPool") | |
837 | + end | |
838 | + for k, v in ipairs(up_pool) do | |
839 | + resultPool[v] = {1} | |
840 | + end | |
841 | + else | |
842 | + for itemId, oneData in pairs(isFloorBack and csvdb["build_floorCsv"] or csvdb["build_poolCsv"]) do | |
843 | + local pool_str = "pool_" .. poolId | |
844 | + if oneData[pool_str] and oneData[pool_str] ~= "" then | |
845 | + local itemData = csvdb["itemCsv"][itemId] | |
846 | + while itemData do | |
847 | + if itemData.type ~= ItemType.Hero then break end | |
848 | + local heroData = csvdb["unitCsv"][itemData.id - ItemStartId.Hero] | |
849 | + if not heroData then break end | |
850 | + local ok = true | |
851 | + -- 保底是全随机,不用比较类型 | |
852 | + if not isFloorBack then | |
853 | + for idx, field in ipairs(condition) do | |
854 | + if heroData[field] ~= values[idx] then ok = false break end | |
855 | + end | |
822 | 856 | end |
857 | + if not ok then break end | |
858 | + if oneData[pool_str] > 0 then | |
859 | + resultPool[itemId] = {oneData[pool_str]} -- itemId, count, 概率 | |
860 | + end | |
861 | + break | |
823 | 862 | end |
824 | - if not ok then break end | |
825 | - if oneData[pool_str] > 0 then | |
826 | - resultPool[itemId] = {oneData[pool_str]} -- itemId, count, 概率 | |
827 | - end | |
828 | - break | |
829 | 863 | end |
830 | 864 | end |
831 | 865 | end |
... | ... | @@ -833,9 +867,9 @@ function _M.drawHeroRpc(agent, data) |
833 | 867 | |
834 | 868 | role:costItems(cost, {log = {desc = "drawHero", int1 = btype, int2 = poolId}}) |
835 | 869 | |
836 | - local guideHero | |
837 | - if role:getProperty("newerGuide") == "11=1" then | |
838 | - guideHero = 613 | |
870 | + local guideHero = nil | |
871 | + if role:getProperty("newerGuide") == "8=1" then | |
872 | + guideHero = globalCsv.newdraw_hero_item_id or 503 | |
839 | 873 | end |
840 | 874 | |
841 | 875 | local ssrCount = 0 |
... | ... | @@ -854,16 +888,26 @@ function _M.drawHeroRpc(agent, data) |
854 | 888 | local itemId = math.randWeight(resultPool, 1) |
855 | 889 | if guideHero then |
856 | 890 | itemId = guideHero |
857 | - guideHero = nil | |
858 | 891 | end |
859 | 892 | |
860 | 893 | local itemData = csvdb["itemCsv"][itemId] |
861 | 894 | if itemData.quality == HeroQuality.SSR then |
862 | 895 | ssrCount = ssrCount + 1 |
896 | + if not guideHero then | |
897 | + -- 广播获得ssr英雄 | |
898 | + local ntf = {heroId = itemData.id - ItemStartId.Hero, nick = role:getProperty("name")} | |
899 | + mcast_util.pub_world(actionCodes.Role_broadGetSSR, MsgPack.pack(ntf)) | |
900 | + end | |
863 | 901 | end |
864 | 902 | |
865 | - if itemData.quality >= HeroQuality.SR then | |
866 | - floorHeroCount = 0 | |
903 | + if btype == 4 and role:getProperty("newerDraw") == 0 then -- 新手卡池 | |
904 | + if itemData.quality == HeroQuality.SSR then | |
905 | + floorHeroCount = 0 | |
906 | + end | |
907 | + else | |
908 | + if itemData.quality >= HeroQuality.SR then | |
909 | + floorHeroCount = 0 | |
910 | + end | |
867 | 911 | end |
868 | 912 | |
869 | 913 | if role:isHaveHero(itemData.id - ItemStartId.Hero) then |
... | ... | @@ -886,11 +930,16 @@ function _M.drawHeroRpc(agent, data) |
886 | 930 | role:setProperty("floorHero", floorHero) |
887 | 931 | end |
888 | 932 | |
933 | + if btype == 4 then | |
934 | + local newCount = role:getProperty("newerDraw") | |
935 | + role:updateProperty({field="newerDraw", value = newCount + drawCount[drawType]}) | |
936 | + end | |
937 | + | |
889 | 938 | role:checkTaskEnter("DrawHero", {pool = btype, count = drawCount[drawType]}) |
890 | 939 | if ssrCount > 0 then |
891 | 940 | role:checkTaskEnter("DrawSSR", {count = ssrCount}) |
892 | 941 | end |
893 | - role:finishGuide(11) | |
942 | + role:finishGuide(8) | |
894 | 943 | |
895 | 944 | role:log("gacha", { |
896 | 945 | gacha_id = poolId, -- 卡池ID |
... | ... | @@ -910,7 +959,28 @@ function _M.drawHeroRpc(agent, data) |
910 | 959 | local drawCardReward, val = role:getDrawCardExtraReward(oldVal, newVal) |
911 | 960 | -- 空字符穿代表直接给英雄 走以前repayHeroRpc |
912 | 961 | if drawCardReward == "" then |
913 | - local id = math.randWeight(csvdb["build_giftCsv"], "pool_1") | |
962 | + local repayHeroMaxCount = role:getProperty("repayMaxC") or 0 | |
963 | + repayHeroMaxCount = repayHeroMaxCount + 1 | |
964 | + | |
965 | + role:updateProperty({field = "repayMaxC", value = repayHeroMaxCount}) | |
966 | + local even = repayHeroMaxCount % 2 | |
967 | + local id = 0 | |
968 | + if even == 1 then | |
969 | + id = math.randWeight(csvdb["build_giftCsv"], "pool_1") | |
970 | + else | |
971 | + local giftHeroSet = {} | |
972 | + for gid, cfg in pairs(csvdb["build_giftCsv"]) do | |
973 | + if cfg["pool_1"] ~= 0 and not role:isHaveHero(gid - ItemStartId.Hero) then | |
974 | + giftHeroSet[gid] = {1} | |
975 | + end | |
976 | + end | |
977 | + if next(giftHeroSet) then | |
978 | + id = math.randWeight(giftHeroSet, 1) | |
979 | + end | |
980 | + end | |
981 | + if id == 0 then | |
982 | + id = math.randWeight(csvdb["build_giftCsv"], "pool_1") | |
983 | + end | |
914 | 984 | |
915 | 985 | local r,change = {} |
916 | 986 | local itemData = csvdb["itemCsv"][id] |
... | ... | @@ -925,8 +995,9 @@ function _M.drawHeroRpc(agent, data) |
925 | 995 | --end |
926 | 996 | SendPacket(actionCodes.Hero_drawHeroExtraRewardNtf, MsgPack.pack(role:packReward(r, change))) |
927 | 997 | elseif drawCardReward and drawCardReward ~= "" then |
928 | - role:award(drawCardReward, {log = {desc = "drawHeroExtraReward", int1 = oldVal, int2 = newVal}}) | |
929 | - SendPacket(actionCodes.Hero_drawHeroExtraRewardNtf, MsgPack.pack({reward = drawCardReward:toNumMap()})) | |
998 | + local r,change = {} | |
999 | + r, change = role:award(drawCardReward, {log = {desc = "drawHeroExtraReward", int1 = oldVal, int2 = newVal}}) | |
1000 | + SendPacket(actionCodes.Hero_drawHeroExtraRewardNtf, MsgPack.pack(role:packReward(r, change))) | |
930 | 1001 | end |
931 | 1002 | role:updateProperty({field = "repayHero", value = val}) |
932 | 1003 | end |
... | ... | @@ -1010,4 +1081,51 @@ function _M.changeCrown(agent, data) |
1010 | 1081 | return true |
1011 | 1082 | end |
1012 | 1083 | |
1013 | -return _M | |
1014 | 1084 | \ No newline at end of file |
1085 | +function _M.itemComposeRpc(agent, data) | |
1086 | + local role = agent.role | |
1087 | + local msg = MsgPack.unpack(data) | |
1088 | + | |
1089 | + local itemId = msg.id | |
1090 | + local count = msg.count | |
1091 | + if not csvdb["itemCsv"][itemId] then return 1 end | |
1092 | + local config = csvdb["item_processCsv"][itemId] | |
1093 | + if not config then return 2 end | |
1094 | + | |
1095 | + local cost = config.cost:toNumMap() | |
1096 | + if not role:checkItemEnough(cost) then return 2 end | |
1097 | + role:costItems(cost, {log = {desc = "itemCompose", int1 = itemId, int2 = count}}) | |
1098 | + role:award({[itemId] = count}, {log = {desc = "itemCompose"}}) | |
1099 | + | |
1100 | + SendPacket(actionCodes.Hero_itemComposeRpc, "") | |
1101 | + return true | |
1102 | +end | |
1103 | + | |
1104 | +function _M.setWishPoolRpc(agent, data) | |
1105 | + local role = agent.role | |
1106 | + local msg = MsgPack.unpack(data) | |
1107 | + | |
1108 | + local heros = msg.heros | |
1109 | + if #heros > 3 then return 1 end | |
1110 | + | |
1111 | + for _, heroId in pairs(heros) do | |
1112 | + local cfg = csvdb["build_poolCsv"][heroId] | |
1113 | + if not cfg then return 2 end | |
1114 | + | |
1115 | + local buildTypeData = csvdb["build_typeCsv"][5] | |
1116 | + if not buildTypeData then return 3 end | |
1117 | + local poolMap = buildTypeData["pool"]:toNumMap() | |
1118 | + local poolId = poolMap[1] | |
1119 | + if not poolId then return 4 end | |
1120 | + | |
1121 | + if cfg["pool_"..poolId] == 0 then | |
1122 | + return 5 | |
1123 | + end | |
1124 | + end | |
1125 | + | |
1126 | + role:updateProperty({field="wishPool", value = heros}) | |
1127 | + | |
1128 | + SendPacket(actionCodes.Hero_setWishPoolRpc, "") | |
1129 | + return true | |
1130 | +end | |
1131 | + | |
1132 | +return _M | ... | ... |
src/actions/PvpAction.lua
... | ... | @@ -23,6 +23,7 @@ local _revengeRecord = {} -- 复仇对单人1分钟间隔 |
23 | 23 | local RevengeWaitTime = 60 |
24 | 24 | |
25 | 25 | function _M.formatCommonRpc(agent , data) |
26 | + if true then return end | |
26 | 27 | local role = agent.role |
27 | 28 | local roleId = role:getProperty("id") |
28 | 29 | local msg = MsgPack.unpack(data) |
... | ... | @@ -50,6 +51,9 @@ function _M.formatCommonRpc(agent , data) |
50 | 51 | end |
51 | 52 | pvpTC.leader = msg.leader |
52 | 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 | 58 | role:savePvpCTeam(pvpTC) |
55 | 59 | SendPacket(actionCodes.Pvp_formatCommonRpc, '') |
... | ... | @@ -60,7 +64,8 @@ function _M.formatHighRpc(agent , data) |
60 | 64 | local role = agent.role |
61 | 65 | local roleId = role:getProperty("id") |
62 | 66 | local msg = MsgPack.unpack(data) |
63 | - | |
67 | + | |
68 | + if not role:isCrossServerPvpPlayer() then return end | |
64 | 69 | local pvpTH = {} |
65 | 70 | local had = {} -- 上阵的角色 |
66 | 71 | local supportHad = {} |
... | ... | @@ -92,6 +97,9 @@ function _M.formatHighRpc(agent , data) |
92 | 97 | curTeam.heros = team.heros |
93 | 98 | curTeam.leader = team.leader |
94 | 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 | 104 | table.insert(pvpTH, curTeam) |
97 | 105 | end |
... | ... | @@ -163,7 +171,7 @@ function _M.infoRpc(agent, data) |
163 | 171 | |
164 | 172 | local pvpMC = role:getProperty("pvpMC") |
165 | 173 | if not next(pvpMC) then --没有分配过对手 |
166 | - role:refreshPvpMatchC(score) | |
174 | + role:refreshPvpMatchC(score, -1) | |
167 | 175 | pvpMC = role:getProperty("pvpMC") |
168 | 176 | end |
169 | 177 | if not next(pvpMC) then return end |
... | ... | @@ -183,7 +191,7 @@ function _M.infoRpc(agent, data) |
183 | 191 | |
184 | 192 | local pvpMH = role:getProperty("pvpMH") |
185 | 193 | if not next(pvpMH) then --没有分配过对手 |
186 | - role:refreshPvpMatchH(score) | |
194 | + role:refreshPvpMatchH(score, -1) | |
187 | 195 | pvpMH = role:getProperty("pvpMH") |
188 | 196 | end |
189 | 197 | if not next(pvpMH) then return end |
... | ... | @@ -249,8 +257,38 @@ function _M.startBattleRpc(agent, data) |
249 | 257 | local idx = msg.idx |
250 | 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 | 293 | local matchInfo, result, key, wait |
256 | 294 | |
... | ... | @@ -293,7 +331,7 @@ function _M.startBattleRpc(agent, data) |
293 | 331 | end |
294 | 332 | |
295 | 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 | 336 | role:checkTaskEnter("PvpBattle") |
299 | 337 | |
... | ... | @@ -336,7 +374,15 @@ function _M.endBattleRpc(agent, data) |
336 | 374 | |
337 | 375 | local temp = string.randWeight(csvdb["player_expCsv"][role:getProperty("level")].pvpBonus, true) |
338 | 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 | 388 | local params = { |
... | ... | @@ -427,8 +473,8 @@ function _M.startBattleHRpc(agent, data) |
427 | 473 | local revenge = msg.revenge |
428 | 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 | 480 | local pvpTH = {} |
... | ... | @@ -462,6 +508,9 @@ function _M.startBattleHRpc(agent, data) |
462 | 508 | curTeam.heros = team.heros |
463 | 509 | curTeam.leader = team.leader |
464 | 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 | 515 | table.insert(pvpTH, curTeam) |
467 | 516 | end |
... | ... | @@ -634,9 +683,18 @@ function _M.endBattleHRpc(agent, data) |
634 | 683 | -- 战斗结束了发奖 |
635 | 684 | local temp = string.randWeight(csvdb["player_expCsv"][role:getProperty("level")].pvpgroupBonus, true) |
636 | 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 | 698 | end |
641 | 699 | |
642 | 700 | -- 加入战斗记录 |
... | ... | @@ -725,6 +783,7 @@ function _M.endBattleHRpc(agent, data) |
725 | 783 | myRank = myRank, |
726 | 784 | oldMyRank = oldMyRank, |
727 | 785 | video = video, |
786 | + headers = headers, | |
728 | 787 | isWin = isWin, |
729 | 788 | })) |
730 | 789 | return true | ... | ... |
... | ... | @@ -0,0 +1,181 @@ |
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 ipairs(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 | + return true | |
106 | +end | |
107 | + | |
108 | +function _M.finishQuestRpc(agent, data) | |
109 | + local role = agent.role | |
110 | + local msg = MsgPack.unpack(data) | |
111 | + local id = msg.id | |
112 | + -- check finish time | |
113 | + local radioTask = role:getProperty("radioTask") | |
114 | + local task = radioTask[id] | |
115 | + if not task then return 1 end | |
116 | + if skynet.timex() < task.time then return 2 end | |
117 | + -- check id | |
118 | + local config = csvdb["crusadeCsv"][id] | |
119 | + if not config then return 3 end | |
120 | + local carbonData = csvdb["idle_battleCsv"][config.unlock] | |
121 | + if not carbonData then return 4 end | |
122 | + -- get heros | |
123 | + local totalCoef = 0 | |
124 | + local exp = config.time / 60 | |
125 | + local heroFaithMap = {} | |
126 | + for _, heroId in ipairs(task.heros) do | |
127 | + local hero = role.heros[heroId] | |
128 | + if hero then | |
129 | + totalCoef = totalCoef + getHeroCoef(hero, config.success) | |
130 | + -- 增加英雄信赖 | |
131 | + hero:addHeroFaith(exp) | |
132 | + heroFaithMap[heroId] = hero:getProperty("faith") | |
133 | + end | |
134 | + end | |
135 | + -- send award | |
136 | + local bigSuccess = false | |
137 | + local result = math.randomInt(0, 100) | |
138 | + if result < totalCoef then | |
139 | + bigSuccess = true | |
140 | + end | |
141 | + local money = math.ceil(carbonData.money / 5) * config.time * config.money_clear | |
142 | + local exp = math.ceil(carbonData.exp / 5) * config.time * config.exp_clear | |
143 | + local itemReward = config.item_clear_special:toNumMap() | |
144 | + itemReward[ItemId.Gold] = (itemReward[ItemId.Gold] or 0) + money | |
145 | + itemReward[ItemId.Exp] = (itemReward[ItemId.Exp] or 0) + exp | |
146 | + if bigSuccess then | |
147 | + for key, value in pairs(itemReward) do | |
148 | + itemReward[key] = math.ceil(1.5 * value) | |
149 | + end | |
150 | + end | |
151 | + | |
152 | + local r, change = role:award(itemReward, {log = {desc = "radioQuest", int1 = id}}) | |
153 | + | |
154 | + radioTask[id] = nil | |
155 | + role:updateProperty({field="radioTask", value=radioTask, notNotify = true}) | |
156 | + | |
157 | + local msg = role:packReward(r, change) | |
158 | + msg["big"] = bigSuccess | |
159 | + msg["id"] = id | |
160 | + msg["heroFaith"] = heroFaithMap | |
161 | + SendPacket(actionCodes.Radio_finishQuestRpc, MsgPack.pack(msg)) | |
162 | + return true | |
163 | +end | |
164 | + | |
165 | +function _M.cancelQuestRpc(agent, data) | |
166 | + local role = agent.role | |
167 | + local msg = MsgPack.unpack(data) | |
168 | + local id = msg.id | |
169 | + -- check finish time | |
170 | + local radioTask = role:getProperty("radioTask") | |
171 | + local task = radioTask[id] | |
172 | + if not task then return 1 end | |
173 | + if skynet.timex() > task.time then return 2 end | |
174 | + radioTask[id] = nil | |
175 | + role:updateProperty({field="radioTask", value=radioTask, notNotify = true}) | |
176 | + | |
177 | + SendPacket(actionCodes.Radio_cancelQuestRpc, MsgPack.pack({id = id})) | |
178 | + return true | |
179 | +end | |
180 | + | |
181 | +return _M | |
0 | 182 | \ No newline at end of file | ... | ... |
src/actions/RoleAction.lua
... | ... | @@ -121,6 +121,9 @@ function _M.loginRpc( agent, data ) |
121 | 121 | role:setProperty("device", device) |
122 | 122 | end |
123 | 123 | end |
124 | + if msg.token then | |
125 | + role._pushToken = msg.token | |
126 | + end | |
124 | 127 | |
125 | 128 | if not msg.isGMlogin then |
126 | 129 | local banTime = role:getProperty("banTime") |
... | ... | @@ -261,7 +264,8 @@ function _M.loginRpc( agent, data ) |
261 | 264 | |
262 | 265 | -- 发下缓存的世界消息 |
263 | 266 | local worldChatResponse = {worldChats = {}} |
264 | - local ok, msgs = pcall(skynet.call, '.globald', "lua", "getWorldMsg", role._channelIdx) | |
267 | + -- local ok, msgs = pcall(skynet.call, '.globald', "lua", "getWorldMsg", role._channelIdx) | |
268 | + local ok, msgs = true, {} | |
265 | 269 | if not ok then |
266 | 270 | msgs = {} |
267 | 271 | end |
... | ... | @@ -287,7 +291,7 @@ function _M.loginRpc( agent, data ) |
287 | 291 | |
288 | 292 | |
289 | 293 | -- 玩家登陆做的一些操作 |
290 | - role:saveHangTeam() | |
294 | + role:updateHangTeamInfo() | |
291 | 295 | role:savePvpCTeam() |
292 | 296 | role:savePvpHTeam() |
293 | 297 | |
... | ... | @@ -550,7 +554,7 @@ function _M.openTimeBoxRpc(agent, data) |
550 | 554 | if boxL[slot] then return end |
551 | 555 | role:costItems({[itemId] = 1}, {log = {desc = "openTimeBox"}}) |
552 | 556 | boxL[slot] = {id = itemId, time = skynet.timex() + randomData.openTime} |
553 | - | |
557 | + role:pushMsg({type = "box", slot = slot, time = randomData.openTime}) | |
554 | 558 | elseif oper == 2 then -- 领取 |
555 | 559 | local quick = msg.quick |
556 | 560 | if not boxL[slot] then return end |
... | ... | @@ -561,6 +565,7 @@ function _M.openTimeBoxRpc(agent, data) |
561 | 565 | costKey = math.ceil((boxL[slot].time - skynet.timex()) / (cost_pre[1] * 60)) * cost_pre[2] |
562 | 566 | if not role:checkItemEnough({[ItemId.BoxKey] = costKey}) then return end |
563 | 567 | role:costItems({[ItemId.BoxKey] = costKey}, {log = {desc = "openTimeBox"}}) |
568 | + role:pushCancel({type = "box", slot = slot}) | |
564 | 569 | end |
565 | 570 | local boxId = boxL[slot].id |
566 | 571 | local itemData = csvdb["itemCsv"][boxId] |
... | ... | @@ -615,52 +620,57 @@ end |
615 | 620 | function _M.openSpeedUpBoxRpc(agent, data) |
616 | 621 | local role = agent.role |
617 | 622 | local msg = MsgPack.unpack(data) |
618 | - | |
619 | - local id = msg.id | |
620 | - local count = msg.count | |
621 | - local itemData = csvdb["itemCsv"][id] | |
622 | - if not itemData or itemData.type ~= ItemType.SpeedBox then return end | |
623 | - | |
624 | - if math.illegalNum(count, 1, role:getItemCount(id)) then return end | |
625 | - local useType, hour = table.unpack(itemData.use_effect:toArray(true, "=")) | |
626 | - local time = hour * 60 * 60 | |
623 | + local itemInfo = msg.itemInfo | |
627 | 624 | |
628 | 625 | local reward = {} |
629 | - if useType == 1 then -- 挂机齿轮 | |
630 | - local hangInfo = role:getProperty("hangInfo") | |
631 | - if not hangInfo.carbonId then | |
632 | - return | |
633 | - end | |
634 | - local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId] | |
635 | - reward[ItemId.Gold] = math.floor(time / globalCsv.idle_money_produce_cd) * carbonData.money * count | |
636 | - elseif useType == 2 then -- 挂机经验 | |
637 | - local hangInfo = role:getProperty("hangInfo") | |
638 | - if not hangInfo.carbonId then | |
639 | - return | |
640 | - end | |
641 | - local carbonData = csvdb["idle_battleCsv"][hangInfo.carbonId] | |
642 | - reward[ItemId.Exp] = math.floor(time / globalCsv.idle_money_produce_cd) * carbonData.exp * count | |
643 | - elseif useType == 3 then -- 食材商人收入 | |
644 | - local buildType = 6 | |
645 | - local level = role.dinerData:getProperty("buildL"):getv(buildType, 1) | |
646 | - local buildingData = csvdb["diner_buildingCsv"][buildType][level] | |
647 | - if not buildingData then | |
648 | - return 1 | |
649 | - end | |
650 | - local gfood = role.dinerData:getProperty("gfood") | |
651 | - if not next(gfood) then return end | |
652 | - for k , v in pairs(gfood) do | |
653 | - local itemId = v.id | |
654 | - local speed = globalCsv.diner_get_food_speed[csvdb["itemCsv"][itemId].quality] * buildingData.speed / 100 | |
655 | - reward[itemId] = math.floor(time / speed) * count | |
626 | + for i = 1, #itemInfo do | |
627 | + local pair = itemInfo[i] | |
628 | + local id = pair[1] | |
629 | + local count = pair[2] | |
630 | + local itemData = csvdb["itemCsv"][id] | |
631 | + if not itemData or itemData.type ~= ItemType.SpeedBox then return end | |
632 | + | |
633 | + if math.illegalNum(count, 1, role:getItemCount(id)) then return 1 end | |
634 | + local useType, hour = table.unpack(itemData.use_effect:toArray(true, "=")) | |
635 | + local time = hour * 60 * 60 | |
636 | + | |
637 | + if useType == 1 then -- 挂机齿轮 | |
638 | + local hangInfo = role:getProperty("hangInfo") | |
639 | + if not hangInfo.expCarbonId then | |
640 | + return 2 | |
641 | + end | |
642 | + local carbonData = csvdb["idle_battleCsv"][hangInfo.expCarbonId] | |
643 | + reward[ItemId.Gold] = (reward[ItemId.Gold] or 0) + math.floor(time / globalCsv.idle_money_produce_cd) * carbonData.money * count | |
644 | + elseif useType == 2 then -- 挂机经验 | |
645 | + local hangInfo = role:getProperty("hangInfo") | |
646 | + if not hangInfo.expCarbonId then | |
647 | + return 3 | |
648 | + end | |
649 | + local carbonData = csvdb["idle_battleCsv"][hangInfo.expCarbonId] | |
650 | + reward[ItemId.Exp] = (reward[ItemId.Exp] or 0) + math.floor(time / globalCsv.idle_money_produce_cd) * carbonData.exp * count | |
651 | + elseif useType == 3 then -- 食材商人收入 | |
652 | + local buildType = 6 | |
653 | + local level = role.dinerData:getProperty("buildL"):getv(buildType, 1) | |
654 | + local buildingData = csvdb["diner_buildingCsv"][buildType][level] | |
655 | + if not buildingData then | |
656 | + return 4 | |
657 | + end | |
658 | + local gfood = role.dinerData:getProperty("gfood") | |
659 | + if not next(gfood) then return 5 end | |
660 | + for k , v in pairs(gfood) do | |
661 | + local itemId = v.id | |
662 | + local speed = globalCsv.diner_get_food_speed[csvdb["itemCsv"][itemId].quality] * buildingData.speed / 100 | |
663 | + reward[itemId] = (reward[itemId] or 0) + math.floor((time / speed) * count) | |
664 | + end | |
665 | + else | |
666 | + return 6 | |
656 | 667 | end |
657 | - else | |
658 | - return | |
668 | + | |
669 | + role:costItems({[id] = count}, {log = {desc = "speedUpBox"}}) | |
659 | 670 | end |
660 | 671 | |
661 | - role:costItems({[id] = count}, {log = {desc = "speedUpBox"}}) | |
662 | 672 | local change |
663 | - reward, change = role:award(reward, {log = {desc = "speedUpBox"}, int1 = id, int2 = count}) | |
673 | + reward, change = role:award(reward, {log = {desc = "speedUpBox"}}) | |
664 | 674 | |
665 | 675 | SendPacket(actionCodes.Role_openSpeedUpBoxRpc, MsgPack.pack(role:packReward(reward, change))) |
666 | 676 | return true |
... | ... | @@ -671,17 +681,18 @@ function _M.storyBookRewardRpc(agent, data) |
671 | 681 | local msg = MsgPack.unpack(data) |
672 | 682 | local storyId = msg.id |
673 | 683 | local storyBookData = csvdb["story_bookCsv"][storyId] |
674 | - if not storyBookData then return end | |
684 | + if not storyBookData then return 1 end | |
675 | 685 | local storyStatus = role:getProperty("storyB") |
676 | 686 | |
677 | 687 | local status = (storyStatus[storyId] or {}).s |
678 | 688 | |
679 | - if status == -1 then return end | |
689 | + if status == -1 then return 2 end | |
680 | 690 | |
681 | 691 | if not status or status ~= 1 then |
682 | - if storyBookData.unlockType == 1 and (role:getProperty("hangInfo").carbonId == tonumber(storyBookData.unlockData) or storyId == 1 or storyId == 2) then -- 挂机剧情正在挂机也可以领奖 | |
692 | + --if storyBookData.unlockType == 1 and (role:getProperty("hangInfo").carbonId == tonumber(storyBookData.unlockData) or storyId == 1 or storyId == 2) then -- 挂机剧情正在挂机也可以领奖 | |
693 | + if storyBookData.unlockType == 1 then -- 挂机剧情正在挂机也可以领奖 | |
683 | 694 | else |
684 | - return | |
695 | + return 3 | |
685 | 696 | end |
686 | 697 | end |
687 | 698 | -- 获取奖励 |
... | ... | @@ -936,7 +947,7 @@ function _M.chatRpc(agent, data) |
936 | 947 | end |
937 | 948 | end |
938 | 949 | mcast_util.pub_world(actionCodes.Role_chat, MsgPack.pack(response)) |
939 | - pcall(skynet.send, '.globald', "lua", "sendWorldMsg", role._channelIdx, response) | |
950 | + -- pcall(skynet.send, '.globald', "lua", "sendWorldMsg", role._channelIdx, response) | |
940 | 951 | role:mylog("role_action", {desc = "chatWorld", text1 = content}) |
941 | 952 | end, |
942 | 953 | -- 私聊 |
... | ... | @@ -1226,7 +1237,7 @@ function _M.useSelectItemRpc(agent, data) |
1226 | 1237 | local count = msg.count |
1227 | 1238 | if math.illegalNum(count, 1, role:getItemCount(itemId)) then return end |
1228 | 1239 | local itemData = csvdb["itemCsv"][itemId] |
1229 | - if itemData.type ~= ItemType.SelectItemBox then return end | |
1240 | + if not (itemData.type == ItemType.SelectItemBox or itemData.type == ItemType.CommonPaster) then return end | |
1230 | 1241 | local itemMap = itemData.use_effect:toNumMap() |
1231 | 1242 | local reward, change = {} |
1232 | 1243 | for k, v in pairs(itemMap) do |
... | ... | @@ -1244,4 +1255,40 @@ function _M.useSelectItemRpc(agent, data) |
1244 | 1255 | return true |
1245 | 1256 | end |
1246 | 1257 | |
1258 | +function _M.renameTeamRpc(agent, data) | |
1259 | + local role = agent.role | |
1260 | + local msg = MsgPack.unpack(data) | |
1261 | + local title = msg.title | |
1262 | + local index = msg.index | |
1263 | + local ispve = msg.ispve | |
1264 | + if ispve then | |
1265 | + local teams = role:getProperty("hangTeams") | |
1266 | + local team = role:getTeamFormat(index) | |
1267 | + team.title = title | |
1268 | + teams[index] = team | |
1269 | + role:updateProperty({field = "hangTeams", value = teams, notNotify = false}) | |
1270 | + else | |
1271 | + local teams = role:getProperty("advTeams") | |
1272 | + local team = role:getAdvTeamFormat(index) | |
1273 | + team.title = title | |
1274 | + teams[index] = team | |
1275 | + role:updateProperty({field = "advTeams", value = teams, notNotify = false}) | |
1276 | + end | |
1277 | + | |
1278 | + SendPacket(actionCodes.Role_renameTeamRpc, "") | |
1279 | + return true | |
1280 | +end | |
1281 | + | |
1282 | +function _M.accuseRpc(agent, data) | |
1283 | + local role = agent.role | |
1284 | + local msg = MsgPack.unpack(data) | |
1285 | + local targetId = msg.targetId | |
1286 | + local atype = msg.type | |
1287 | + local note = msg.note | |
1288 | + | |
1289 | + role:mylog("role_action", {desc = "accuse", int1 = targetId, short1 = atype, text1 = note}) | |
1290 | + SendPacket(actionCodes.Role_accuseRpc, "") | |
1291 | + return true | |
1292 | +end | |
1293 | + | |
1247 | 1294 | return _M |
1248 | 1295 | \ No newline at end of file | ... | ... |
src/actions/StoreAction.lua
1 | 1 | local _M = {} |
2 | 2 | |
3 | -local serverId = tonumber(skynet.getenv("servId")) | |
4 | 3 | local md5 = require "md5" |
5 | 4 | |
6 | -local function makeOrder(roleId, rechargeId) | |
7 | - local orderId = redisproxy:hincrby("autoincrement_set", "order", 1) | |
8 | - local partnerOrderId = string.format("%d_%d_%d", serverId, roleId, orderId) | |
9 | - local orderKey = string.format("order:%d:%d", roleId, orderId) | |
10 | - redisproxy:del(orderKey) | |
11 | - local order = require("models.Order").new({ | |
12 | - key = orderKey, | |
13 | - order = partnerOrderId, | |
14 | - rechargeId = rechargeId, | |
15 | - }) | |
16 | - order:create() | |
17 | - redisproxy:sadd(string.format("role:%d:orders", roleId), partnerOrderId) | |
18 | - return partnerOrderId | |
19 | -end | |
20 | - | |
21 | 5 | -- 入口在正式服关闭 -- mock 充值 |
22 | 6 | function _M.rechargeRpc(agent , data) |
23 | 7 | local role = agent.role |
... | ... | @@ -28,7 +12,7 @@ function _M.rechargeRpc(agent , data) |
28 | 12 | local roleId = role:getProperty("id") |
29 | 13 | |
30 | 14 | --创建订单号 |
31 | - local partnerOrderId = makeOrder(roleId, id) | |
15 | + local partnerOrderId = role:getPurchaseOrder(id) | |
32 | 16 | SendPacket(actionCodes.Store_rechargeRpc, MsgPack.pack({ order = partnerOrderId })) |
33 | 17 | |
34 | 18 | if true then return end |
... | ... | @@ -77,7 +61,7 @@ function _M.googleRechargeRpc(agent, data) |
77 | 61 | |
78 | 62 | role.ignoreHeartbeat = true |
79 | 63 | --创建订单号 |
80 | - local partnerOrderId = makeOrder(roleId, id) | |
64 | + local partnerOrderId = role:getPurchaseOrder(id) | |
81 | 65 | -- 签名 |
82 | 66 | local secret_key = "b7657fa7ccd44c16a35e3f454ac7a075" |
83 | 67 | local need = { |
... | ... | @@ -104,7 +88,7 @@ function _M.myCardRechargeRpc(agent, data) |
104 | 88 | |
105 | 89 | role.ignoreHeartbeat = true |
106 | 90 | --创建订单号 |
107 | - local partnerOrderId = makeOrder(roleId, id) | |
91 | + local partnerOrderId = role:getPurchaseOrder(id) | |
108 | 92 | -- 签名 |
109 | 93 | local secret_key = "48759e07540f46d9af17ec82669b4272" |
110 | 94 | local need = { |
... | ... | @@ -130,7 +114,7 @@ function _M.iosRechargeRpc(agent, data) |
130 | 114 | |
131 | 115 | role.ignoreHeartbeat = true |
132 | 116 | --创建订单号 |
133 | - local partnerOrderId = makeOrder(roleId, id) | |
117 | + local partnerOrderId = role:getPurchaseOrder(id) | |
134 | 118 | -- 签名 |
135 | 119 | local secret_key = "9647d2efe1074c73b9ac19af4337a70e" |
136 | 120 | local need = { |
... | ... | @@ -154,43 +138,15 @@ function _M.purchaseOrderResult(agent, data) |
154 | 138 | |
155 | 139 | role.ignoreHeartbeat = false |
156 | 140 | |
157 | - local partnerOrderStr = msg.order | |
158 | - local _, _, orderId = string.match(partnerOrderStr, "(.+)_(.+)_(.+)") | |
159 | - local orderObject = require("models.Order").new({ key = string.format("order:%d:%d", roleId, orderId) }) | |
160 | - if not orderObject:load() then | |
161 | - -- 订单不存在 | |
162 | - skynet.error("cancelPurchaseRpc", string.format("order %s not exist", partnerOrderStr)) | |
163 | - return true | |
164 | - end | |
165 | - | |
166 | - if msg.status == "success" then | |
167 | - orderObject:setProperty("transactionId", msg.platformOrder or "") | |
168 | - local rechargeId = orderObject:getProperty("rechargeId") | |
169 | - local dataSet = csvdb["shop_rechargeCsv"][rechargeId] | |
170 | - | |
171 | - role:log("setOrder", { | |
172 | - order_status = 100, -- "订单状态:100 - 开始下单(玩家还未开始付费行为记录)200 - 支付完成并发货(SDK通知可以发货时记录),300 - 订单被取消,1000 - 其他" | |
173 | - item_id = rechargeId, -- 道具id | |
174 | - item_type = dataSet.type, -- 购买的道具类型,具体见"onItems"方法中道具类型枚举表 | |
175 | - item_name = dataSet.title, -- 购买的道具名 | |
176 | - item_number = 1, -- 购买的道具数量 | |
177 | - item_level = 1, -- 购买的道具等级 | |
178 | - order_cost = dataSet.rmb * 100, -- 此次消费的现金金额(单位:分),如 51800即未518元,对应客户端SDK传入的'total_fee' | |
179 | - order_currency = "CNY", -- 货币类型,默认为"CNY"(人民币),遵循ISO 4217规范 | |
180 | - order_type = role:getProperty("rmbC") > 0 and 0 or 1, -- 订单类型,首充记录为1,否则为0 | |
181 | - order_id = msg.platformOrder, -- 本条记录的订单号,对应客户端SDK返回的'bs_trade_no' | |
182 | - }) | |
183 | - | |
184 | - return true | |
185 | - end | |
141 | + local status = { | |
142 | + fail = true, | |
143 | + success = true | |
144 | + } | |
186 | 145 | |
187 | - if orderObject:getProperty("finishTime") > 0 then | |
188 | - return true | |
146 | + local partnerOrderStr = msg.order | |
147 | + if partnerOrderStr then | |
148 | + role:updatePurchaseOrder(partnerOrderStr, msg.platformOrder, status[msg.status] and msg.status or "unknown") | |
189 | 149 | end |
190 | - | |
191 | - orderObject:setProperty("status", msg.status) | |
192 | - | |
193 | - redisproxy:srem(string.format("role:%d:orders", roleId), partnerOrderStr) | |
194 | 150 | return true |
195 | 151 | end |
196 | 152 | |
... | ... | @@ -440,4 +396,30 @@ function _M.getExploreCommandRewardRpc(agent, data) |
440 | 396 | return true |
441 | 397 | end |
442 | 398 | |
399 | +-- 累充奖励 | |
400 | +function _M.getTotalRechargeAwardRpc(agent, data) | |
401 | + local role = agent.role | |
402 | + local msg = MsgPack.unpack(data) | |
403 | + local index = msg.index -- 领取的索引id | |
404 | + local totalTwd = role:getProperty("twdC") | |
405 | + local totalRechargeRecord = role.storeData:getProperty("totalRR") | |
406 | + local flag = string.char(string.getbit(totalRechargeRecord, index)) | |
407 | + if flag == "1" then return 1 end | |
408 | + local cfg = csvdb["activity_payRebateCsv"][index] | |
409 | + if not cfg then return 2 end | |
410 | + if cfg.twd > totalTwd then return 3 end | |
411 | + | |
412 | + totalRechargeRecord = string.setbit(totalRechargeRecord, index) | |
413 | + role.storeData:updateProperty({field = "totalRR", value = totalRechargeRecord}) | |
414 | + local main = cfg.main_reward:toNumMap() | |
415 | + local sub = cfg.sub_reward:toNumMap() | |
416 | + for k, v in pairs(sub) do | |
417 | + main[k] = (main[k] or 0) + v | |
418 | + end | |
419 | + | |
420 | + local reward, change = role:award(main, {log = {desc = "totalRecharge", int1 = index}}) | |
421 | + SendPacket(actionCodes.Store_getTotalRechargeAwardRpc, MsgPack.pack(role:packReward(reward, change))) | |
422 | + return true | |
423 | +end | |
424 | + | |
443 | 425 | return _M |
444 | 426 | \ No newline at end of file | ... | ... |
src/actions/TowerAction.lua
... | ... | @@ -8,36 +8,6 @@ local MsgPack = MsgPack |
8 | 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 | 12 | local function getUpdateTime(lastCount, lastTime) |
43 | 13 | local nextCount, nextTime = lastCount, skynet.timex() |
... | ... | @@ -62,7 +32,7 @@ function _M.startBattleRpc(agent, data) |
62 | 32 | |
63 | 33 | if not csvdb["tower_battleCsv"][id] then return end |
64 | 34 | local curCount, nextTime = getUpdateTime(towerInfo.c, towerInfo.t) |
65 | - if curCount < 1 then return end -- 没有次数返回 | |
35 | + --if curCount < 1 then return end -- 没有次数返回 | |
66 | 36 | |
67 | 37 | --搞起来 |
68 | 38 | towerInfo.c = curCount - 1 |
... | ... | @@ -136,10 +106,15 @@ end |
136 | 106 | |
137 | 107 | function _M.bugCountRpc(agent, data) |
138 | 108 | local role = agent.role |
109 | + local msg = MsgPack.unpack(data) | |
110 | + local buyCount = msg.count | |
139 | 111 | |
140 | 112 | local towerInfo = role:getProperty("towerInfo") |
141 | 113 | local curCount, nextTime = getUpdateTime(towerInfo.c, towerInfo.t) |
142 | 114 | local needCount = globalCsv.tower_count_limit - curCount |
115 | + if needCount > buyCount then | |
116 | + needCount = buyCount | |
117 | + end | |
143 | 118 | if needCount > 0 then -- 补充 |
144 | 119 | local cost = globalCsv.tower_chance_item:toNumMap() |
145 | 120 | for k , v in pairs(cost) do |
... | ... | @@ -147,7 +122,7 @@ function _M.bugCountRpc(agent, data) |
147 | 122 | end |
148 | 123 | if not role:checkItemEnough(cost) then return end |
149 | 124 | role:costItems(cost, {log = {desc = "towerCount"}}) |
150 | - curCount = globalCsv.tower_count_limit | |
125 | + curCount = curCount + needCount | |
151 | 126 | end |
152 | 127 | towerInfo.c = curCount |
153 | 128 | towerInfo.t = nextTime | ... | ... |
src/adv/Adv.lua
... | ... | @@ -51,13 +51,14 @@ function Adv:initByInfo(advInfo) |
51 | 51 | self.cacheUnlock = advInfo.cacheUnlock or {} |
52 | 52 | self.shopStatus = advInfo.shopStatus or {} |
53 | 53 | self.support = advInfo.support or {} |
54 | + self.logid = advInfo.logid or "auto" | |
54 | 55 | |
55 | 56 | self.maps = {} |
56 | 57 | for id, map in ipairs(advInfo.maps or {}) do |
57 | 58 | self.maps[id] = AdvMap.new(self, id, map) |
58 | 59 | end |
59 | 60 | |
60 | - self:initBattle() | |
61 | + self:initBattle(advInfo) | |
61 | 62 | end |
62 | 63 | -- 找出level 是否存在中继层 |
63 | 64 | function Adv:isHaveRelay(level, chapterId) |
... | ... | @@ -101,7 +102,11 @@ function Adv:initByChapter(params) |
101 | 102 | self.cacheUnlock = self.cacheUnlock or {} |
102 | 103 | self.shopStatus = self.shopStatus or {} |
103 | 104 | self.support = self.support or {} |
105 | + if self.battle then | |
106 | + self.battle:overBattle() | |
107 | + end | |
104 | 108 | self.battle = nil -- 清掉 老的 battle |
109 | + self.logid = self.owner:getActionUcode() | |
105 | 110 | |
106 | 111 | if isEnter then -- 把 支援效果初始化为易用用的形式 |
107 | 112 | self:initSupport(support or {}) |
... | ... | @@ -144,7 +149,7 @@ function Adv:initByChapter(params) |
144 | 149 | self.maps = {} |
145 | 150 | self.maps[1] = AdvMap.new(self, 1, mapId, isEnter, isNewRelay) |
146 | 151 | |
147 | - self:initBattle(true) | |
152 | + self:initBattle(nil) | |
148 | 153 | |
149 | 154 | self:initLayerTask() |
150 | 155 | |
... | ... | @@ -206,9 +211,10 @@ function Adv:saveDB(notNotify) |
206 | 211 | advInfo.cacheUnlock = self.cacheUnlock |
207 | 212 | advInfo.shopStatus = self.shopStatus |
208 | 213 | advInfo.support = self.support |
214 | + advInfo.logid = self.logid | |
209 | 215 | advInfo.maps = {} |
210 | 216 | |
211 | - self.battle:saveDB() | |
217 | + self.battle:saveDB(advInfo) | |
212 | 218 | |
213 | 219 | for id , map in ipairs(self.maps) do |
214 | 220 | advInfo.maps[id] = map:getDB() |
... | ... | @@ -450,7 +456,7 @@ function Adv:clearAdvUnlockCache() |
450 | 456 | self.cacheUnlock = {} |
451 | 457 | end |
452 | 458 | |
453 | -function Adv:initBattle(notDb) | |
459 | +function Adv:initBattle(info) | |
454 | 460 | self.battle = require("adv.AdvBattle").new(self) |
455 | 461 | for _, passiveC in ipairs(self.cachePassiveEvent or {}) do |
456 | 462 | self.battle:triggerPassive(passiveC[1], passiveC[2]) |
... | ... | @@ -462,9 +468,16 @@ function Adv:initBattle(notDb) |
462 | 468 | map:initBattleAfter() |
463 | 469 | end |
464 | 470 | --下层 |
465 | - if notDb and self.level ~= 1 then | |
471 | + if not info and self.level ~= 1 then | |
466 | 472 | self.battle.player:attrChangeCondBuffCheck(1) |
467 | 473 | end |
474 | + | |
475 | + -- 初始化 | |
476 | + if not info then | |
477 | + self.battle:newBattle() | |
478 | + else | |
479 | + self.battle:loadBattle(info) | |
480 | + end | |
468 | 481 | end |
469 | 482 | |
470 | 483 | function Adv:triggerPassive(condType, params) |
... | ... | @@ -610,6 +623,15 @@ function Adv:wearArtifact(slot, id) |
610 | 623 | id = nil |
611 | 624 | end |
612 | 625 | self:mylog({desc = "wearArtifact", int1 = id}) |
626 | + self.owner:log("mission_pick_equip", { | |
627 | + mission_threadid = self.chapterId, -- 大地图ID | |
628 | + mission_threadname = (csvdb["adv_chapterCsv"][self.chapterId] or {})["chapter"] or "auto", -- 大地图名称 | |
629 | + mission_id = self.level, -- 关卡ID | |
630 | + mission_pick_equip_type = 1, --神器操作类型:1:装备,2:卸下 | |
631 | + mission_pick_equip_id = id, --神器ID | |
632 | + mission_pick_equip_lv = advAFGet[id], --神器等级 | |
633 | + mission_sequenceid = self.logid, -- 本次拾荒ID,用于关联一次拾荒产生多条不同类型的日志 | |
634 | + }) | |
613 | 635 | |
614 | 636 | self.owner:changeUpdates({{type = "advAFWear", field = slot, value = id}}) |
615 | 637 | return true |
... | ... | @@ -670,7 +692,6 @@ function Adv:artifactLevelUp(id, level) |
670 | 692 | |
671 | 693 | self:mylog({desc = "artifactLevelUp", int1 = id, int2 = level}) |
672 | 694 | |
673 | - | |
674 | 695 | local status = 0 |
675 | 696 | if curWear[id] then -- 穿着呢 |
676 | 697 | local oldData = csvdb["adv_artifactCsv"][id][advAFGet[id]] |
... | ... | @@ -815,6 +836,49 @@ function Adv:over(success, rewardRatio, overType) |
815 | 836 | |
816 | 837 | self:mylog({desc = "over", short1 = success and 1 or 0, int1 = overType}) |
817 | 838 | |
839 | + | |
840 | + local team = self.owner:getProperty("advTeam") | |
841 | + local player = {} | |
842 | + local attrs = self.owner:getTeamBattleInfo(team).heros | |
843 | + for attrName, _ in pairs(AdvAttsEnum) do | |
844 | + for _, hero in pairs(attrs) do | |
845 | + player[attrName] = (player[attrName] or 0) + hero[attrName] | |
846 | + end | |
847 | + player[attrName] = player[attrName] * (globalCsv.adv_battle_attr_ratio[attrName] or 1) | |
848 | + end | |
849 | + | |
850 | + local battleV = 1 * player["hp"] | |
851 | + + 2 * player["atk"] | |
852 | + + 1.25 * player["def"] | |
853 | + + 0.226 * player["hit"] | |
854 | + + 0.26 * player["miss"] | |
855 | + | |
856 | + local heroList = {team.leader, team.leader2} | |
857 | + for _, hid in pairs(team.heros) do | |
858 | + if hid ~= team.leader and hid ~= team.leader2 then | |
859 | + heroList[#heroList + 1] = hid | |
860 | + end | |
861 | + end | |
862 | + | |
863 | + self.owner:log("mission_pick", { | |
864 | + mission_threadid = self.chapterId, -- 大地图ID | |
865 | + mission_threadname = (csvdb["adv_chapterCsv"][self.chapterId] or {})["chapter"] or "auto", -- 大地图名称 | |
866 | + mission_id = self.level, -- 关卡ID | |
867 | + mission_herolist = heroList, -- 英雄ID列表,[111, 222, 333, 444, 555] 前两个为队长、副队长 | |
868 | + mission_heroscore = battleV, -- 编队总评分 | |
869 | + mission_teamlv = 0, -- 编队等级 | |
870 | + mission_recscore = csvdb["adv_chapter_campsiteCsv"][self.chapterId][1].recommendValue, -- 关卡推荐评分 | |
871 | + mission_floor_bef = 0, -- 进入前关卡层数 | |
872 | + mission_floor_aft = self.level, -- 结束时关卡层数 | |
873 | + mission_team_status = {HP = team.player.hp, SP = team.player.sp}, -- 队伍状态,{"HP":100, "SP":100, "curse":7} | |
874 | + mission_result = success and 1 or (team.player.hp > 0 and 3 or 2), -- 战斗结果(0-无效,1-胜利,2-血量耗尽退出,3,主动退出) | |
875 | + mission_reward = reward, -- 获得奖励,[{"id":101,"num":10},{"id":102,"num":20},{"id":103,"num":30}] | |
876 | + mission_integral_bef = 0, -- 进入前积分 | |
877 | + mission_integral_aft = score, -- 完成后积分 | |
878 | + mission_cleartype = 1, -- 1正常通关;2代理拾荒 | |
879 | + mission_sequenceid = self.logid, -- 本次拾荒ID,用于关联一次拾荒产生多条不同类型的日志 | |
880 | + }) | |
881 | + | |
818 | 882 | local chapterId = self.chapterId |
819 | 883 | self:clear() |
820 | 884 | self.owner:checkTaskEnter("AdvScore", {score = score}) |
... | ... | @@ -882,7 +946,7 @@ end |
882 | 946 | |
883 | 947 | -- log long1 字段被征用!!! |
884 | 948 | -- 在冒险中获得的物品都发放在冒险背包内 |
885 | -function Adv:award(gift, params) | |
949 | +function Adv:award(gift, params, backRewardParams) | |
886 | 950 | params = params or {} |
887 | 951 | local tgift = {} |
888 | 952 | if type(gift) == "string" then |
... | ... | @@ -894,6 +958,8 @@ function Adv:award(gift, params) |
894 | 958 | end |
895 | 959 | local items = self.owner:getProperty("advItems") |
896 | 960 | local oldItems = items |
961 | + | |
962 | + local autoUse = {} | |
897 | 963 | for itemId, count in pairs(tgift) do |
898 | 964 | if count > 0 then |
899 | 965 | local buffAdd = self.battle.player:getRewardChange(itemId) |
... | ... | @@ -902,41 +968,45 @@ function Adv:award(gift, params) |
902 | 968 | self:checkAchievement(Adv.AchievType.GetItem, count, itemId) |
903 | 969 | end |
904 | 970 | tgift[itemId] = count |
905 | - local origin = items:getv(itemId, 0) | |
906 | - local nums = origin + count | |
907 | - | |
908 | - if csvdb["adv_artifactCsv"][itemId] then -- 获得神器 | |
909 | - self:awardArtifact(itemId, params) | |
910 | - if not self.owner:checkOverGuide(55) then | |
911 | - self.owner:saveGuide(55,1,true) | |
912 | - end | |
971 | + if globalCsv.adv_auto_useItem[itemId] and count > 0 then | |
972 | + autoUse[itemId] = count | |
913 | 973 | else |
914 | - if nums <= 0 then | |
915 | - items = items:delk(itemId) | |
916 | - nums = 0 | |
974 | + local origin = items:getv(itemId, 0) | |
975 | + local nums = origin + count | |
976 | + | |
977 | + if csvdb["adv_artifactCsv"][itemId] then -- 获得神器 | |
978 | + self:awardArtifact(itemId, params) | |
979 | + if not self.owner:checkOverGuide(55) then | |
980 | + self.owner:saveGuide(55,1,true) | |
981 | + end | |
917 | 982 | else |
918 | - items = items:setv(itemId, nums) | |
919 | - end | |
983 | + if nums <= 0 then | |
984 | + items = items:delk(itemId) | |
985 | + nums = 0 | |
986 | + else | |
987 | + items = items:setv(itemId, nums) | |
988 | + end | |
920 | 989 | |
921 | - if itemId == 16 and not self.owner:checkOverGuide(51,4) then | |
922 | - self.owner:saveGuide(51,4) | |
923 | - end | |
924 | - if params.log then | |
925 | - local log = clone(params.log) | |
926 | - if log["cint1"] or log["cint2"] or log["cint3"] or log["long1"] then | |
927 | - print("addAdvItem error log have cint1 or cint2 or cint3 ", debug.traceback()) | |
990 | + if itemId == 16 and not self.owner:checkOverGuide(51,4) then | |
991 | + self.owner:saveGuide(51,4) | |
928 | 992 | end |
929 | - log["cint1"] = itemId | |
930 | - log["cint2"] = math.abs(count) | |
931 | - log["cint3"] = self.chapterId | |
932 | - log["long1"] = self.level | |
933 | - if count >= 0 then | |
934 | - self.owner:mylog("in_adv", log) | |
993 | + if params.log then | |
994 | + local log = clone(params.log) | |
995 | + if log["cint1"] or log["cint2"] or log["cint3"] or log["long1"] then | |
996 | + print("addAdvItem error log have cint1 or cint2 or cint3 ", debug.traceback()) | |
997 | + end | |
998 | + log["cint1"] = itemId | |
999 | + log["cint2"] = math.abs(count) | |
1000 | + log["cint3"] = self.chapterId | |
1001 | + log["long1"] = self.level | |
1002 | + if count >= 0 then | |
1003 | + self.owner:mylog("in_adv", log) | |
1004 | + else | |
1005 | + self.owner:mylog("out_adv", log) | |
1006 | + end | |
935 | 1007 | else |
936 | - self.owner:mylog("out_adv", log) | |
1008 | + print("addAdvItem no log ", debug.traceback()) | |
937 | 1009 | end |
938 | - else | |
939 | - print("addAdvItem no log ", debug.traceback()) | |
940 | 1010 | end |
941 | 1011 | end |
942 | 1012 | end |
... | ... | @@ -947,10 +1017,48 @@ function Adv:award(gift, params) |
947 | 1017 | if tgift[ItemId.OldCoin] then |
948 | 1018 | self.battle.player:attrChangeCondBuffCheck(0) |
949 | 1019 | end |
1020 | + | |
1021 | + if backRewardParams then | |
1022 | + self:backReward(tgift, backRewardParams) | |
1023 | + end | |
1024 | + | |
1025 | + if next(autoUse) then | |
1026 | + for itemId, count in pairs(autoUse) do | |
1027 | + self:useItem(itemId, count) | |
1028 | + end | |
1029 | + self:backUse(autoUse, 1) | |
1030 | + end | |
950 | 1031 | return tgift |
951 | 1032 | end |
952 | 1033 | |
953 | 1034 | |
1035 | +function Adv:useItem(itemId, count, target) | |
1036 | + local itemData = csvdb["adv_itemCsv"][itemId] | |
1037 | + if not itemData then return end | |
1038 | + | |
1039 | + if itemData["function"] == 0 or itemData["function"] == 2 then count = 1 end | |
1040 | + | |
1041 | + if itemId == 5020 then | |
1042 | + self.owner:finishGuide(53) | |
1043 | + end | |
1044 | + | |
1045 | + self:checkAchievement(self.AchievType.UseItem, count, itemId) | |
1046 | + self:mylog({desc = "useItem", int1 = itemId, int2 = count}) | |
1047 | + | |
1048 | + self.owner:log("mission_pick_use", { | |
1049 | + mission_threadid = self.chapterId, -- 大地图ID | |
1050 | + mission_threadname = (csvdb["adv_chapterCsv"][self.chapterId] or {})["chapter"] or "auto", -- 大地图名称 | |
1051 | + mission_id = self.level, -- 关卡ID | |
1052 | + item_id = itemId, -- 道具ID | |
1053 | + mission_pick_use_num = count, -- 道具使用量 | |
1054 | + mission_sequenceid = self.logid, -- 本次拾荒ID,用于关联一次拾荒产生多条不同类型的日志 | |
1055 | + }) | |
1056 | + | |
1057 | + for i = 1, count do | |
1058 | + self:doActive(itemData.effect, target) -- target | |
1059 | + end | |
1060 | +end | |
1061 | + | |
954 | 1062 | -- 消耗物品 优先冒险背包 --check 只是检查够不够 |
955 | 1063 | function Adv:cost(item, params, check) |
956 | 1064 | local items = self.owner:getProperty("advItems") |
... | ... | @@ -986,7 +1094,9 @@ local function clickOut(self, room, block, params, isExit) |
986 | 1094 | end |
987 | 1095 | |
988 | 1096 | if #self.mapStack > 1 then -- 处于夹层中 |
1097 | + local oldMapIdx = self:getCurMapIdx() | |
989 | 1098 | table.remove(self.mapStack) --退出夹层 |
1099 | + self.battle:iLayerChange(oldMapIdx) | |
990 | 1100 | self:backLayer(-1) |
991 | 1101 | else --处于底层 |
992 | 1102 | |
... | ... | @@ -1017,11 +1127,10 @@ local function clickOut(self, room, block, params, isExit) |
1017 | 1127 | self.battle.player:triggerPassive(Passive.DOWN_LAYER) |
1018 | 1128 | |
1019 | 1129 | if curFloorData then |
1020 | - self:backReward(self:award({[ItemId.AdvPoint] = curFloorData.exp}, {log = {desc = "passReward", int1 = self.chapterId, int2 = self.level}})) | |
1130 | + self:award({[ItemId.AdvPoint] = curFloorData.exp}, {log = {desc = "passReward", int1 = self.chapterId, int2 = self.level}}, {}) | |
1021 | 1131 | end |
1022 | 1132 | local isHaveRelay = self:isHaveRelay(self.level) |
1023 | 1133 | |
1024 | - self.owner:getProperty("advTeam").player = self.battle.player:getDB() -- 临时缓存住 battle 的player | |
1025 | 1134 | if isHaveRelay and not self.isRelay then |
1026 | 1135 | self:initByChapter({ |
1027 | 1136 | chapterId = self.chapterId, |
... | ... | @@ -1201,7 +1310,7 @@ local function chooseCommon(self, room, block, chooseData, choose, tag) |
1201 | 1310 | skynet.error(string.format("[ERROR]: event_dropCsv no id %s in %s id: %s", effect[2], tag, chooseData.id)) |
1202 | 1311 | end |
1203 | 1312 | end |
1204 | - self:backReward(self:award(reward, {log = {desc = "chooseEvent", key1 = tag, int1 = chooseData.id}}), {roomId = room.roomId, blockId = block.blockId}) | |
1313 | + self:award(reward, {log = {desc = "chooseEvent", key1 = tag, int1 = chooseData.id}}, {roomId = room.roomId, blockId = block.blockId}) | |
1205 | 1314 | end, |
1206 | 1315 | [2] = function() --获得冒险buff |
1207 | 1316 | local layer = effect[3] or 1 |
... | ... | @@ -1279,19 +1388,31 @@ local function chooseCommon(self, room, block, chooseData, choose, tag) |
1279 | 1388 | [14] = function() -- 指定地块召唤 指定类型的id |
1280 | 1389 | local change = self:getCurMap():layEventToStage(effect[2], effect[3], effect[4], effect[5]) |
1281 | 1390 | for _, one in ipairs(change) do |
1282 | - self:backBlockChange(one[1].roomId, one[2].blockId) | |
1391 | + if one[1].roomId == room.roomId and one[2].blockId == block.blockId then | |
1392 | + clearBlock = false | |
1393 | + else | |
1394 | + self:backBlockChange(one[1].roomId, one[2].blockId) | |
1395 | + end | |
1283 | 1396 | end |
1284 | 1397 | end, |
1285 | 1398 | [15] = function() -- 移除指定事件 |
1286 | 1399 | local change = self:getCurMap():clearEventById(effect[2], effect[3], effect[4]) |
1287 | 1400 | for _, one in ipairs(change) do |
1288 | - self:backBlockChange(one[1].roomId, one[2].blockId) | |
1401 | + if one[1].roomId == room.roomId and one[2].blockId == block.blockId then | |
1402 | + clearBlock = false | |
1403 | + else | |
1404 | + self:backBlockChange(one[1].roomId, one[2].blockId) | |
1405 | + end | |
1289 | 1406 | end |
1290 | 1407 | end, |
1291 | 1408 | [16] = function() -- 指定事件转移 |
1292 | 1409 | local change = self:getCurMap():eventChangeToOther(effect[2], effect[3], effect[4], effect[5], effect[6]) |
1293 | 1410 | for _, one in ipairs(change) do |
1294 | - self:backBlockChange(one[1].roomId, one[2].blockId) | |
1411 | + if one[1].roomId == room.roomId and one[2].blockId == block.blockId then | |
1412 | + clearBlock = false | |
1413 | + else | |
1414 | + self:backBlockChange(one[1].roomId, one[2].blockId) | |
1415 | + end | |
1295 | 1416 | end |
1296 | 1417 | end, |
1297 | 1418 | } |
... | ... | @@ -1365,14 +1486,12 @@ local function clickDrop(self, room, block, params) |
1365 | 1486 | if not self.battle or not self.battle.player then return end |
1366 | 1487 | self.battle.player:triggerPassive(Passive.CLICK_DROP) |
1367 | 1488 | |
1368 | - local reward = self:award({[block.event.item[1]] = block.event.item[2]}, {log = {desc = "clickDrop"}}) | |
1369 | - -- local reward = self:award({[5801] = 1}) | |
1370 | - -- 获取绷带的引导 | |
1489 | + local reward = self:award({[block.event.item[1]] = block.event.item[2]}, {log = {desc = "clickDrop"}}, {roomId = room.roomId, blockId = block.blockId}) | |
1490 | + | |
1371 | 1491 | if block.event.item[1] == 5020 and not self.owner:checkOverGuide(53,2) then |
1372 | 1492 | self.owner:saveGuide(53,2) |
1373 | 1493 | end |
1374 | 1494 | block:clear() |
1375 | - self:backReward(reward, {roomId = room.roomId, blockId = block.blockId}) | |
1376 | 1495 | return true |
1377 | 1496 | end |
1378 | 1497 | |
... | ... | @@ -1393,7 +1512,7 @@ local function clickTrader(self, room, block, params) |
1393 | 1512 | local costCount = math.ceil(goodsData.price * (block.event.shop[buyId][2] or 100) / 100) |
1394 | 1513 | if not self:cost({[goodsData.currency] = costCount}, {log = {desc = "clickTrader", int1 = block.event.id}}) then return false, 6 end --不够 |
1395 | 1514 | self:backCost({[goodsData.currency] = costCount}) |
1396 | - local reward = self:award({[goodsData.item] = goodsData.num}, {log = {desc = "clickTrader", int1 = block.event.id}}) | |
1515 | + self:award({[goodsData.item] = goodsData.num}, {log = {desc = "clickTrader", int1 = block.event.id}}, {}) | |
1397 | 1516 | if goodsData.restrict == 1 then |
1398 | 1517 | self.shopStatus[goodsData.goods] = (self.shopStatus[goodsData.goods] or 0) + 1 |
1399 | 1518 | elseif goodsData.restrict == 2 then |
... | ... | @@ -1405,7 +1524,6 @@ local function clickTrader(self, room, block, params) |
1405 | 1524 | buyCount = buyCount + 1 |
1406 | 1525 | self:checkTask(Adv.TaskType.Shop, 1, block.event.id) |
1407 | 1526 | self:checkAchievement(Adv.AchievType.Shop, 1, block.event.id) |
1408 | - self:backReward(reward) | |
1409 | 1527 | |
1410 | 1528 | if (traderData.purchasetime ~= 0 and traderData.purchasetime <= buyCount) or #block.event.shop <= buyCount then |
1411 | 1529 | block:clear() |
... | ... | @@ -1420,6 +1538,24 @@ local function clickBuild(self, room, block, params) |
1420 | 1538 | local status, clearBlock = chooseCommon(self, room, block, chooseData, choose, "build") |
1421 | 1539 | if not status then return end |
1422 | 1540 | |
1541 | + local isMine = false -- 是不是宝藏怪 | |
1542 | + for _, mid in ipairs(globalCsv.adv_egg_treasureLayer_id) do | |
1543 | + if mid == oldId then | |
1544 | + isMine = true | |
1545 | + break | |
1546 | + end | |
1547 | + end | |
1548 | + if isMine then | |
1549 | + local advMine = self.owner:getProperty("advMine") | |
1550 | + advMine[2] = advMine[2] or {} | |
1551 | + local mineCo2 = advMine[2].co or {} | |
1552 | + if chooseData.limit ~= 0 then | |
1553 | + mineCo2[oldId] = (mineCo2[oldId] or 0) + 1 | |
1554 | + end | |
1555 | + advMine[2].co = mineCo2 | |
1556 | + self.owner:setProperty("advMine", advMine) | |
1557 | + end | |
1558 | + | |
1423 | 1559 | self:checkTask(Adv.TaskType.Build, 1, oldId) |
1424 | 1560 | self:checkAchievement(Adv.AchievType.Build, 1, oldId) |
1425 | 1561 | self:checkAchievement(Adv.AchievType.BuildBySelect, 1, oldId, choose) |
... | ... | @@ -1447,7 +1583,7 @@ local function clickClick(self, room, block, params) |
1447 | 1583 | local item = csvdb["event_dropCsv"][dropId]["range"]:randWeight(true) |
1448 | 1584 | reward[item[1]] = (reward[item[1]] or 0) + item[2] |
1449 | 1585 | end |
1450 | - self:backReward(self:award(reward, {log = {desc = "clickClick", int1 = block.event.id}}), {roomId = room.roomId, blockId = block.blockId}) | |
1586 | + self:award(reward, {log = {desc = "clickClick", int1 = block.event.id}}, {roomId = room.roomId, blockId = block.blockId}) | |
1451 | 1587 | end, |
1452 | 1588 | [3] = function() |
1453 | 1589 | for _, buffId in ipairs(clickData.effect:toArray(true, "=")) do |
... | ... | @@ -1467,6 +1603,7 @@ local function clickClick(self, room, block, params) |
1467 | 1603 | end |
1468 | 1604 | |
1469 | 1605 | local function clickLayer(self, room, block, params) |
1606 | + local oldMapIdx = self:getCurMapIdx() | |
1470 | 1607 | if block.event.mapIdx then |
1471 | 1608 | table.insert(self.mapStack, block.event.mapIdx) --进入夹层 |
1472 | 1609 | else |
... | ... | @@ -1482,6 +1619,7 @@ local function clickLayer(self, room, block, params) |
1482 | 1619 | self.maps[mapIdx]:initBattleAfter() |
1483 | 1620 | self:checkAchievement(Adv.AchievType.EnterILayer, 1, mapId) |
1484 | 1621 | end |
1622 | + self.battle:iLayerChange(oldMapIdx) | |
1485 | 1623 | self:backLayer(1) |
1486 | 1624 | return true |
1487 | 1625 | end |
... | ... | @@ -1788,23 +1926,31 @@ end |
1788 | 1926 | |
1789 | 1927 | -- 地图上物品变化 |
1790 | 1928 | function Adv:mapItemChange(ctype) |
1929 | + local blocks = {} | |
1930 | + for roomId, room in pairs(self:getCurMap().rooms) do | |
1931 | + for blockId, block in pairs(room.blocks) do | |
1932 | + table.insert(blocks, block) | |
1933 | + end | |
1934 | + end | |
1935 | + self:blockDropChange(ctype, blocks) | |
1936 | +end | |
1937 | + | |
1938 | +function Adv:blockDropChange(ctype, blocks) | |
1791 | 1939 | local clist = csvdb["transform_itemCsv"][ctype] |
1792 | 1940 | if clist then |
1793 | - for roomId, room in pairs(self:getCurMap().rooms) do | |
1794 | - for blockId, block in pairs(room.blocks) do | |
1795 | - if block:getEventType() == AdvEventType.Drop and block.event.item then | |
1796 | - local id = block.event.item[1] | |
1797 | - local count = block.event.item[2] | |
1798 | - local changeTo = nil | |
1799 | - if clist[id] then | |
1800 | - changeTo = {clist[id].toId, math.ceil(count * clist[id].num)} | |
1801 | - elseif clist[-1] then | |
1802 | - changeTo = {clist[-1].toId, math.ceil(count * clist[-1].num)} | |
1803 | - end | |
1804 | - if changeTo and changeTo[1] ~= 0 and changeTo[2] ~= 0 then | |
1805 | - block.event.item = changeTo | |
1806 | - self:backBlockChange(roomId, blockId, ctype) | |
1807 | - end | |
1941 | + for _, block in ipairs(blocks) do | |
1942 | + if block:getEventType() == AdvEventType.Drop and block.event.item then | |
1943 | + local id = block.event.item[1] | |
1944 | + local count = block.event.item[2] | |
1945 | + local changeTo = nil | |
1946 | + if clist[id] then | |
1947 | + changeTo = {clist[id].toId, math.ceil(count * clist[id].num)} | |
1948 | + elseif clist[-1] then | |
1949 | + changeTo = {clist[-1].toId, math.ceil(count * clist[-1].num)} | |
1950 | + end | |
1951 | + if changeTo and changeTo[1] ~= 0 and changeTo[2] ~= 0 then | |
1952 | + block.event.item = changeTo | |
1953 | + self:backBlockChange(block.room.roomId, block.blockId, ctype) | |
1808 | 1954 | end |
1809 | 1955 | end |
1810 | 1956 | end |
... | ... | @@ -1833,76 +1979,147 @@ function Adv:enemyDead(enemy, escape) |
1833 | 1979 | else |
1834 | 1980 | self:scoreChange(AdvScoreType.Kill, monsterData.advScore) |
1835 | 1981 | end |
1836 | - local changeV = self.battle.player:addExp(monsterData.exp) | |
1837 | - self:backDead(enemyId, changeV) | |
1838 | - | |
1839 | - local toClick = enemy:hadBuff(Buff.CHANGE_DROP_TO_CLICK) | |
1840 | - if toClick then | |
1841 | - toClick = toClick:effect() | |
1982 | + -- local changeV = self.battle.player:addExp(monsterData.exp) | |
1983 | + -- self:backDead(enemyId, changeV) | |
1984 | + self:backDead(enemyId) | |
1985 | + | |
1986 | + local isMine = false -- 是不是宝藏怪 | |
1987 | + for _, mid in ipairs(globalCsv.adv_egg_treasureMonster_id) do | |
1988 | + if mid == enemyId then | |
1989 | + isMine = true | |
1990 | + break | |
1991 | + end | |
1842 | 1992 | end |
1843 | 1993 | |
1844 | - local changItem = enemy:hadBuff(Buff.CHANGE_DROP) | |
1845 | - if changItem then | |
1846 | - changItem = table.pack(changItem:effect()) | |
1847 | - end | |
1994 | + if isMine then | |
1995 | + local advMine = self.owner:getProperty("advMine") | |
1996 | + advMine[1] = advMine[1] or {} | |
1997 | + advMine[2] = advMine[2] or {} | |
1998 | + local mineCo = advMine[1].co or {} | |
1999 | + local mineCo2 = advMine[2].co or {} | |
2000 | + local mineCh = advMine[2].ch or globalCsv.adv_egg_treasureLayer_showup | |
2001 | + if monsterData.limit ~= 0 then | |
2002 | + mineCo[enemyId] = (mineCo[enemyId] or 0) + 1 | |
2003 | + end | |
1848 | 2004 | |
1849 | - local addMult = 0 | |
1850 | - local dropBuff = enemy:hadBuff(Buff.DROP_BUFF_BY_ENEMY) -- 根据敌人数量变化个数 | |
1851 | - if dropBuff then | |
1852 | - local team = enemy:getTeam(1, true) | |
1853 | - addMult = addMult + 0.2 * #team | |
1854 | - end | |
2005 | + local had = false | |
2006 | + if math.randomInt(1, 100) <= mineCh then -- 刷出来了 | |
2007 | + local mpool = {} | |
2008 | + for _, mid in ipairs(globalCsv.adv_egg_treasureLayer_id) do | |
2009 | + local layer = csvdb["event_buildingCsv"][mid] | |
2010 | + if (not mineCo2[mid] or layer.limit == 0 or mineCo2[mid] < layer.limit) and layer.showup > 0 then | |
2011 | + mpool[mid] = {layer.showup} | |
2012 | + end | |
2013 | + end | |
2014 | + if next(mpool) then | |
2015 | + local cId = math.randWeight(mpool, 1) | |
2016 | + block:updateEvent({ | |
2017 | + etype = AdvEventType.Build, | |
2018 | + id = cId | |
2019 | + }) | |
2020 | + had = true | |
2021 | + end | |
2022 | + end | |
2023 | + if had then | |
2024 | + mineCh = nil | |
2025 | + else | |
2026 | + block:clear() | |
2027 | + mineCh = math.min(mineCh + globalCsv.adv_egg_treasureLayer_showup_add, 100) | |
2028 | + end | |
1855 | 2029 | |
1856 | - local dropIds = monsterData.dropid:toArray(true, "=") | |
1857 | - local drops = {} | |
1858 | - local cCcount = 0 -- 需要改变为click 的个数 | |
1859 | - for _, dropId in ipairs(dropIds) do | |
1860 | - local dropData = csvdb["event_dropCsv"][dropId] | |
1861 | - if dropData then | |
1862 | - local cur = dropData["range"]:randWeight(true) | |
1863 | - if cur and cur[1] ~= 0 then | |
1864 | - if toClick then | |
1865 | - cCcount = cCcount + 1 | |
1866 | - else | |
1867 | - local item = changItem and changItem or cur | |
1868 | - item[2] = math.floor(item[2] * (1 + addMult)) | |
1869 | - drops[#drops + 1] = item | |
2030 | + local drops = {} | |
2031 | + for _, dropId in ipairs(monsterData.dropid:toArray(true, "=")) do | |
2032 | + local dropData = csvdb["event_dropCsv"][dropId] | |
2033 | + if dropData then | |
2034 | + local cur = dropData["range"]:randWeight(true) | |
2035 | + if cur and cur[1] ~= 0 then | |
2036 | + drops[#drops + 1] = cur | |
1870 | 2037 | end |
1871 | 2038 | end |
1872 | 2039 | end |
1873 | - end | |
1874 | - -- 这些奖励可能会有被动加成 | |
1875 | - self.battle.player:triggerPassive(Passive.BATTLE_WIN, {drops = drops}) | |
2040 | + local blocks = self:getCurMap():getEmptyBlocks(roomId, blockId, #drops) | |
2041 | + for _i, cblock in ipairs(blocks) do | |
2042 | + cblock:updateEvent({ | |
2043 | + etype = AdvEventType.Drop, | |
2044 | + item = drops[_i] | |
2045 | + }) | |
2046 | + if cblock ~= block then | |
2047 | + self:backBlockChange(cblock.room.roomId, cblock.blockId) | |
2048 | + end | |
2049 | + end | |
2050 | + advMine[1].co = mineCo | |
2051 | + advMine[2].co = mineCo2 | |
2052 | + advMine[2].ch = mineCh | |
2053 | + self.owner:setProperty("advMine", advMine) | |
2054 | + else | |
2055 | + local toClick = enemy:hadBuff(Buff.CHANGE_DROP_TO_CLICK) | |
2056 | + if toClick then | |
2057 | + toClick = toClick:effect() | |
2058 | + end | |
1876 | 2059 | |
1877 | - -- 自身带的掉落是不会被改变的 也不会被加成 | |
1878 | - if block.event.item and block.event.item[1] ~= 0 then | |
1879 | - table.insert(drops, 1, block.event.item) | |
1880 | - end | |
2060 | + local changItem = enemy:hadBuff(Buff.CHANGE_DROP) | |
2061 | + if changItem then | |
2062 | + changItem = table.pack(changItem:effect()) | |
2063 | + end | |
1881 | 2064 | |
1882 | - -- 清空当前的格子 | |
1883 | - block:clear() | |
2065 | + local addMult = 0 | |
2066 | + local dropBuff = enemy:hadBuff(Buff.DROP_BUFF_BY_ENEMY) -- 根据敌人数量变化个数 | |
2067 | + if dropBuff then | |
2068 | + local team = enemy:getTeam(1, true) | |
2069 | + addMult = addMult + 0.2 * #team | |
2070 | + end | |
1884 | 2071 | |
1885 | - -- 掉落走一波 | |
1886 | - local blocks = self:getCurMap():getEmptyBlocks(roomId, blockId, #drops) | |
1887 | - for _i, cblock in ipairs(blocks) do | |
1888 | - cblock:updateEvent({ | |
1889 | - etype = AdvEventType.Drop, | |
1890 | - item = drops[_i] | |
1891 | - }) | |
1892 | - if cblock ~= block then | |
1893 | - self:backBlockChange(cblock.room.roomId, cblock.blockId) | |
2072 | + local dropIds = monsterData.dropid:toArray(true, "=") | |
2073 | + local drops = {} | |
2074 | + local cCcount = 0 -- 需要改变为click 的个数 | |
2075 | + for _, dropId in ipairs(dropIds) do | |
2076 | + local dropData = csvdb["event_dropCsv"][dropId] | |
2077 | + if dropData then | |
2078 | + local cur = dropData["range"]:randWeight(true) | |
2079 | + if cur and cur[1] ~= 0 then | |
2080 | + if toClick then | |
2081 | + cCcount = cCcount + 1 | |
2082 | + else | |
2083 | + local item = changItem and changItem or cur | |
2084 | + item[2] = math.floor(item[2] * (1 + addMult)) | |
2085 | + drops[#drops + 1] = item | |
2086 | + end | |
2087 | + end | |
2088 | + end | |
1894 | 2089 | end |
1895 | - end | |
2090 | + -- 这些奖励可能会有被动加成 | |
2091 | + self.battle.player:triggerPassive(Passive.BATTLE_WIN, {drops = drops}) | |
1896 | 2092 | |
1897 | - -- 转换的click走一波 | |
1898 | - local blocks = self:getCurMap():getEmptyBlocks(roomId, blockId, cCcount) | |
1899 | - for _i, cblock in ipairs(blocks) do | |
1900 | - cblock:updateEvent({ | |
1901 | - etype = AdvEventType.Click, | |
1902 | - id = clickId | |
1903 | - }) | |
1904 | - if cblock ~= block then | |
1905 | - self:backBlockChange(cblock.room.roomId, cblock.blockId) | |
2093 | + -- 自身带的掉落是不会被改变的 也不会被加成 | |
2094 | + if block.event.item and block.event.item[1] ~= 0 then | |
2095 | + table.insert(drops, 1, block.event.item) | |
2096 | + end | |
2097 | + | |
2098 | + -- 清空当前的格子 | |
2099 | + block:clear() | |
2100 | + | |
2101 | + -- 掉落走一波 | |
2102 | + local blocks = self:getCurMap():getEmptyBlocks(roomId, blockId, #drops) | |
2103 | + for _i, cblock in ipairs(blocks) do | |
2104 | + cblock:updateEvent({ | |
2105 | + etype = AdvEventType.Drop, | |
2106 | + item = drops[_i] | |
2107 | + }) | |
2108 | + if cblock ~= block then | |
2109 | + self:backBlockChange(cblock.room.roomId, cblock.blockId) | |
2110 | + end | |
2111 | + end | |
2112 | + | |
2113 | + -- 转换的click走一波 | |
2114 | + local blocks = self:getCurMap():getEmptyBlocks(roomId, blockId, cCcount) | |
2115 | + for _i, cblock in ipairs(blocks) do | |
2116 | + cblock:updateEvent({ | |
2117 | + etype = AdvEventType.Click, | |
2118 | + id = clickId | |
2119 | + }) | |
2120 | + if cblock ~= block then | |
2121 | + self:backBlockChange(cblock.room.roomId, cblock.blockId) | |
2122 | + end | |
1906 | 2123 | end |
1907 | 2124 | end |
1908 | 2125 | |
... | ... | @@ -1935,10 +2152,13 @@ end |
1935 | 2152 | function Adv:pushBackEvent(btype, params) |
1936 | 2153 | table.insert(self.backEvents, {btype = btype, params = params}) |
1937 | 2154 | end |
1938 | - | |
2155 | +--[=[ | |
2156 | +tag | |
2157 | +1 自动拾取 | |
2158 | +--]=] | |
1939 | 2159 | function Adv:backReward(items, params) |
1940 | 2160 | params = params or {} |
1941 | - self:pushBackEvent(AdvBackEventType.Reward, {items = items, roomId = params.roomId, blockId = params.blockId}) | |
2161 | + self:pushBackEvent(AdvBackEventType.Reward, {items = items, roomId = params.roomId, blockId = params.blockId, tag = params.tag}) | |
1942 | 2162 | end |
1943 | 2163 | |
1944 | 2164 | -- if is player enemyId is nil |
... | ... | @@ -1955,8 +2175,8 @@ function Adv:backBlockChange(roomId, blockId, itemChangeType) |
1955 | 2175 | self:pushBackEvent(AdvBackEventType.BlockChange, {roomId = roomId, blockId = blockId, itemChangeType = itemChangeType}) |
1956 | 2176 | end |
1957 | 2177 | |
1958 | -function Adv:backDead(enemyId, exp) | |
1959 | - self:pushBackEvent(AdvBackEventType.Dead, {enemyId = enemyId, exp = exp}) | |
2178 | +function Adv:backDead(enemyId) | |
2179 | + self:pushBackEvent(AdvBackEventType.Dead, {enemyId = enemyId}) | |
1960 | 2180 | end |
1961 | 2181 | |
1962 | 2182 | function Adv:backTrap() |
... | ... | @@ -1979,8 +2199,12 @@ function Adv:backCost(items) |
1979 | 2199 | self:pushBackEvent(AdvBackEventType.Cost, {items = items}) |
1980 | 2200 | end |
1981 | 2201 | |
1982 | -function Adv:backUse(items) | |
1983 | - self:pushBackEvent(AdvBackEventType.Use, {items = items}) | |
2202 | +--[=[ | |
2203 | +tag | |
2204 | +1 自动使用 | |
2205 | +--]=] | |
2206 | +function Adv:backUse(items, tag) | |
2207 | + self:pushBackEvent(AdvBackEventType.Use, {items = items, tag = tag}) | |
1984 | 2208 | end |
1985 | 2209 | |
1986 | 2210 | |
... | ... | @@ -1990,21 +2214,11 @@ function Adv:scoreChange(scoreType, score) |
1990 | 2214 | end |
1991 | 2215 | |
1992 | 2216 | function Adv:getScore() |
1993 | - self.score[AdvScoreType.Level] = math.floor(self.score[AdvScoreType.Level] or 0) | |
1994 | - self.score[AdvScoreType.Task] = math.floor(self.score[AdvScoreType.Task] or 0) | |
1995 | - self.score[AdvScoreType.Kill] = math.floor(self.score[AdvScoreType.Kill] or 0) | |
1996 | - self.score[AdvScoreType.KillBoss] = math.floor(self.score[AdvScoreType.KillBoss] or 0) | |
1997 | - self.score[AdvScoreType.ItemBack] = math.floor(self.score[AdvScoreType.ItemBack] or 0) | |
1998 | - self.score[AdvScoreType.Event] = math.floor(self.score[AdvScoreType.Event] or 0) | |
1999 | - self.score[AdvScoreType.Story] = math.floor(self.score[AdvScoreType.Story] or 0) | |
2000 | - | |
2001 | - return self.score[AdvScoreType.Level] | |
2002 | - + self.score[AdvScoreType.Task] | |
2003 | - + self.score[AdvScoreType.Kill] | |
2004 | - + self.score[AdvScoreType.KillBoss] | |
2005 | - + self.score[AdvScoreType.ItemBack] | |
2006 | - + self.score[AdvScoreType.Event] | |
2007 | - + self.score[AdvScoreType.Story] | |
2217 | + local allScore = 0 | |
2218 | + for _, score in pairs(self.score) do | |
2219 | + allScore = allScore + math.floor(score) | |
2220 | + end | |
2221 | + return allScore | |
2008 | 2222 | end |
2009 | 2223 | |
2010 | 2224 | function Adv:popBackEvents() | ... | ... |
src/adv/AdvBattle.lua
... | ... | @@ -8,6 +8,7 @@ function Battle:ctor(adv) |
8 | 8 | self.isNewPlayer = false |
9 | 9 | self.enemys = {} --怪 |
10 | 10 | self.builds = {} -- 建筑 |
11 | + self.auras = {} -- 光环 | |
11 | 12 | self.cachePassiveEvent = {} |
12 | 13 | self:initPlayer() |
13 | 14 | self:initEnemys() |
... | ... | @@ -67,16 +68,17 @@ function Battle:initPlayer() |
67 | 68 | local advAddAttrs = self.adv.owner:getAdvLvAddAttrs() |
68 | 69 | |
69 | 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 | 79 | player.sp = getAdvLvAttrUp(advAddAttrs, "sp", 100) |
79 | - player.growth = {} | |
80 | + player.spMax = player.sp | |
81 | + -- player.growth = {} | |
80 | 82 | player.passives = {} |
81 | 83 | |
82 | 84 | for slot, heroId in pairs(advTeam.heros) do |
... | ... | @@ -99,8 +101,8 @@ function Battle:initPlayer() |
99 | 101 | player[attrName] = (player[attrName] or 0) + hero[attrName] |
100 | 102 | end |
101 | 103 | player[attrName] = getAdvLvAttrUp(advAddAttrs, attrName, player[attrName]) * (globalCsv.adv_battle_attr_ratio[attrName] or 1) |
102 | - player.growth[attrName] = player[attrName] * (globalCsv.adv_battle_attr_growth_ratio[attrName] or 1) | |
103 | - 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) | |
104 | 106 | end |
105 | 107 | |
106 | 108 | player.hpMax = player.hp or 0 |
... | ... | @@ -197,8 +199,10 @@ function Battle:addEnemy(room, block, mapIdx, init) |
197 | 199 | end |
198 | 200 | |
199 | 201 | for _, buff in ipairs(buffs) do |
200 | - enemy:addBuff(buff) | |
202 | + player:addBuff(buff) | |
201 | 203 | end |
204 | + -- 新生成的怪 加上 已有的光环buff | |
205 | + player:checkAuraBuff(self:checkDiffAuraBuff({}, self:getAurasByMap())) | |
202 | 206 | end |
203 | 207 | end |
204 | 208 | return player |
... | ... | @@ -312,8 +316,19 @@ function Battle:afterRound() |
312 | 316 | build:afterRound("buffAfter") |
313 | 317 | end |
314 | 318 | |
319 | + self.player:triggerPassive(Passive.AFTER_ROUND) | |
320 | + | |
321 | + self:checkAura() | |
315 | 322 | |
323 | + self:clearRound() | |
324 | + | |
325 | + if self.player.isDead then | |
326 | + self.adv:over(false, nil, -2) | |
327 | + end | |
328 | +end | |
316 | 329 | |
330 | +function Battle:clearRound() | |
331 | + local mapIdx = self.adv:getCurMapIdx() | |
317 | 332 | self.player:clearRound() |
318 | 333 | for _, enemy in ipairs(self.enemys[mapIdx]) do |
319 | 334 | enemy:clearRound() |
... | ... | @@ -343,12 +358,6 @@ function Battle:afterRound() |
343 | 358 | build:clear() |
344 | 359 | end |
345 | 360 | end |
346 | - | |
347 | - self.player:triggerPassive(Passive.AFTER_ROUND) | |
348 | - | |
349 | - if self.player.isDead then | |
350 | - self.adv:over(false, nil, -2) | |
351 | - end | |
352 | 361 | end |
353 | 362 | |
354 | 363 | |
... | ... | @@ -357,18 +366,32 @@ function Battle:battleBegin(roomId, blockId, params) |
357 | 366 | if not enemy then return end |
358 | 367 | local player = params.player |
359 | 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 | |
360 | 386 | -- 玩家没死就是怪死了 |
361 | 387 | if player.hp > 0 then |
362 | - enemy:kill() | |
363 | 388 | self.player:effectBattleBuff() |
364 | - | |
365 | - self.adv.owner:checkTaskEnter("AdvBattleWin", {id = self.adv.chapterId}) | |
366 | 389 | if params.bySkill then |
367 | 390 | self.player:triggerPassive(Passive.SKILL_KILL) |
368 | 391 | end |
369 | 392 | end |
370 | 393 | if player.hp > self.player.hp then |
371 | - self.player:recover(player.hp - self.player.hp, player) | |
394 | + self.player:recover(player.hp - self.player.hp) | |
372 | 395 | else |
373 | 396 | self.player:hurt(math.max(0, math.ceil(self.player.hp - player.hp)), enemy, {hurtType = 5}) --战斗血量只会变少 |
374 | 397 | end |
... | ... | @@ -423,7 +446,7 @@ function Battle:initMapEffect(ilayer) |
423 | 446 | end |
424 | 447 | |
425 | 448 | for _, buff in ipairs(buffs[1] or {}) do |
426 | - self.palyer:addBuff(buff) | |
449 | + self.player:addBuff(buff) | |
427 | 450 | end |
428 | 451 | |
429 | 452 | for _, buff in ipairs(buffs[2] or {}) do |
... | ... | @@ -434,8 +457,126 @@ function Battle:initMapEffect(ilayer) |
434 | 457 | end |
435 | 458 | |
436 | 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 | + | |
437 | 578 | --写入数据 |
438 | -function Battle:saveDB() | |
579 | +function Battle:saveDB(advInfo) | |
439 | 580 | for idx, mapEnemys in pairs(self.enemys) do |
440 | 581 | for _, enemy in ipairs(mapEnemys) do |
441 | 582 | local block = self.adv:getBlock(enemy.roomId, enemy.blockId, idx) |
... | ... | @@ -452,6 +593,7 @@ function Battle:saveDB() |
452 | 593 | end |
453 | 594 | end |
454 | 595 | end |
596 | + advInfo.auras = self.auras | |
455 | 597 | end |
456 | 598 | |
457 | 599 | return Battle |
458 | 600 | \ No newline at end of file | ... | ... |
src/adv/AdvBlock.lua
... | ... | @@ -48,6 +48,8 @@ function Block:updateEvent(event, isInit) |
48 | 48 | end |
49 | 49 | end |
50 | 50 | end |
51 | + local oldet = self:getEventType() | |
52 | + | |
51 | 53 | self.event = event |
52 | 54 | if not isInit and self.event then |
53 | 55 | -- 判断下类型是不是错的 |
... | ... | @@ -58,18 +60,49 @@ function Block:updateEvent(event, isInit) |
58 | 60 | end |
59 | 61 | self:randomEvent() |
60 | 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 | 83 | end |
62 | 84 | |
63 | 85 | function Block:clear() |
64 | - if self:getEventType() == AdvEventType.Trap then | |
86 | + local et = self:getEventType() | |
87 | + if et == AdvEventType.Trap then | |
65 | 88 | self.trapId = self.event.id |
66 | - elseif self:getEventType() == AdvEventType.Build then | |
89 | + elseif et == AdvEventType.Build then | |
67 | 90 | local build = self.room.map.adv.battle:getBuild(self.room.roomId, self.blockId, self.room.map.mapIdx) |
68 | 91 | if build then |
69 | 92 | build.isDead = true |
70 | 93 | end |
71 | 94 | end |
72 | 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 | 106 | end |
74 | 107 | |
75 | 108 | |
... | ... | @@ -90,8 +123,10 @@ function Block:randomEvent() |
90 | 123 | enemy:triggerPassive(Passive.BORN_ONCE) |
91 | 124 | |
92 | 125 | adv.battle.player:triggerPassive(Passive.OPEN_MONSTER, {trigger = enemy}) |
126 | + adv.battle.player:attrChangeCondBuffCheck(3, enemy:getClassify()) | |
93 | 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 | 130 | end |
96 | 131 | end |
97 | 132 | randomFunc[AdvEventType.BOSS] = randomFunc[AdvEventType.Monster] |
... | ... | @@ -208,6 +243,13 @@ function Block:randomEvent() |
208 | 243 | e:addBuff(buffId) |
209 | 244 | end |
210 | 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 | 253 | end |
212 | 254 | |
213 | 255 | if data.specialEff ~= "" then |
... | ... | @@ -263,10 +305,37 @@ function Block:open() |
263 | 305 | local adv = map.adv |
264 | 306 | self.isOpen = true |
265 | 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 | 319 | return true |
267 | 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 | 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 | 339 | local data = self:getEventData() |
271 | 340 | if not data then return 0 end |
272 | 341 | return data.obstacle or 0 | ... | ... |
src/adv/AdvBuff.lua
... | ... | @@ -20,7 +20,7 @@ Buff.HP_CHANGE_NOW = 16 -- 生命变化(每回合生效,立刻生效) |
20 | 20 | Buff.BATTLE_BUFF = 17 -- 切换为战斗中的buff |
21 | 21 | Buff.CHANGE_DROP = 18 -- 转换掉落 |
22 | 22 | Buff.BATTLE_PASSIVE = 19 -- 切换为战斗中的被动技 |
23 | -Buff.EXP_ADD = 20 -- 增加exp(每回合) | |
23 | +-- Buff.EXP_ADD = 20 -- 增加exp(每回合) | |
24 | 24 | Buff.DONT_DEFEND = 21 -- 不看守地板 -- 怪周围点半可点击 |
25 | 25 | Buff.SHOW_DANGER = 22 -- 扫雷 展示地上怪物和陷阱数量的标记 |
26 | 26 | Buff.SHOW_MONSTER_POS = 23 -- 蓝臂章训练场 感知 |
... | ... | @@ -34,6 +34,10 @@ Buff.Buff_EFFECT_CHANGE = 30 -- 改变 buff 效果 |
34 | 34 | Buff.Buff_NO_PASSIVE_MONSTER = 31 -- 地图被动刷新不出来怪物 |
35 | 35 | Buff.SNEAK = 32 --潜行 |
36 | 36 | Buff.DROP_BUFF_BY_ENEMY = 33 -- 怪物掉落加成 -- 怪物使用 |
37 | +Buff.GET_PASSIVE = 34 -- 获得 passive -- 结束失效 | |
38 | +Buff.OBSTACLE_CHANGE = 35 -- 看守类型改变 -- 怪物使用 0 - 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 | 91 | if buff then |
88 | 92 | effectCount = buff.layer |
89 | 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 | 105 | end |
91 | 106 | return self.buffData.effectValue2 * effectCount |
92 | 107 | end |
93 | 108 | |
94 | 109 | _Buff.getEffectBy = function(self) |
95 | 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 | 112 | cond = tonumber(self.buffData.effectValue5) |
98 | 113 | end |
99 | 114 | return self.buffData.effectValue4, attrName, cond |
... | ... | @@ -302,18 +317,30 @@ local BuffFactory = { |
302 | 317 | end |
303 | 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 | 334 | end |
335 | + end, | |
336 | + | |
337 | + [Buff.DISABLE_AURA] = function(_Buff) | |
310 | 338 | _Buff._effectValue = function(self) |
311 | - -- 经验值 | |
312 | - return self.buffData.effectValue1 * self.layer | |
339 | + return self.buffData.effectValue1 | |
313 | 340 | end |
314 | 341 | end, |
315 | 342 | |
316 | - [Buff.DISABLE_BUFF] = function(_Buff) | |
343 | + [Buff.GET_AURA] = function(_Buff) | |
317 | 344 | _Buff._effectValue = function(self) |
318 | 345 | return self.buffData.effectValue1 |
319 | 346 | end |
... | ... | @@ -378,6 +405,14 @@ local BuffFactory = { |
378 | 405 | self.layer = self.buffData.effectValue1 |
379 | 406 | end |
380 | 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 | 418 | -- 同样的返回 effectValue1, effectValue2 * self.layer 类型的buff |
... | ... | @@ -439,10 +474,22 @@ function Buff:initNew(release, data) |
439 | 474 | end |
440 | 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 | 489 | if self._init then |
444 | 490 | self:_init() |
445 | 491 | end |
492 | + self:pushBackEffect(1) | |
446 | 493 | end |
447 | 494 | |
448 | 495 | function Buff:initByDB(data) |
... | ... | @@ -574,8 +621,19 @@ function Buff:canEffect(...) |
574 | 621 | return self:_canEffect(...) |
575 | 622 | end |
576 | 623 | |
624 | +function Buff:pushBackEffect(etype) | |
625 | + local shows = self.buffData.show:toTableArray(true) | |
626 | + for _, one in ipairs(shows) do | |
627 | + if one[1] == etype then | |
628 | + self.owner.battle.adv:pushBackEvent(AdvBackEventType.BuffEffect, {etype = etype, id = self.id, blockId = self.owner.blockId, roomId = self.owner.roomId}) | |
629 | + break | |
630 | + end | |
631 | + end | |
632 | +end | |
633 | + | |
577 | 634 | function Buff:effect() |
578 | 635 | self:decCount() |
636 | + self:pushBackEffect(2) | |
579 | 637 | if self._effectValue then |
580 | 638 | return self:_effectValue() |
581 | 639 | end |
... | ... | @@ -623,12 +681,13 @@ function Buff:getOverlay() |
623 | 681 | end |
624 | 682 | |
625 | 683 | -- 叠加 |
626 | -function Buff:overlay(releaser, data) | |
684 | +function Buff:overlay(releaser, data, layer) | |
627 | 685 | local otype, maxLayer = self:getOverlay() |
628 | 686 | if self.isDel or not otype then -- 新获得的 (不可叠加相当于新获得的) |
629 | - self.isDel = false | |
630 | 687 | self:endBuff() |
688 | + self.isDel = false | |
631 | 689 | self:initNew(releaser, data) |
690 | + self:createAfter(layer) | |
632 | 691 | else |
633 | 692 | -- 重置回合 次数 |
634 | 693 | self.roundSpace = 0 |
... | ... | @@ -641,25 +700,45 @@ function Buff:overlay(releaser, data) |
641 | 700 | |
642 | 701 | self.release = releaser or self.release |
643 | 702 | -- 叠加层数 |
644 | - self.layer = self.layer + 1 | |
703 | + self.layer = self.layer + layer | |
645 | 704 | if maxLayer ~= 0 then |
646 | 705 | self.layer = math.min(maxLayer, self.layer) |
647 | 706 | end |
648 | 707 | if self._overlay then |
649 | 708 | self:_overlay() |
650 | 709 | end |
710 | + | |
711 | + self:pushBackEffect(1) | |
651 | 712 | end |
652 | 713 | end |
653 | 714 | |
654 | 715 | -- 扣减层数 |
655 | -function Buff:uncover() | |
656 | - if self.layer <= 1 then | |
716 | +function Buff:uncover(layer, isAura) | |
717 | + layer = layer or 1 | |
718 | + local oldLayer = self.layer | |
719 | + | |
720 | + self.layer = self.layer - layer | |
721 | + | |
722 | + if self.layer <= 0 then | |
657 | 723 | self.isDel = true |
658 | 724 | end |
659 | 725 | |
660 | - self.layer = self.layer - 1 | |
661 | - if self._uncover then | |
662 | - self:_uncover() | |
726 | + if isAura then | |
727 | + if layer == -1 then | |
728 | + self.layer = 0 | |
729 | + self.isDel = true | |
730 | + else | |
731 | + self.layer = math.max(1, self.layer) | |
732 | + self.isDel = false | |
733 | + end | |
734 | + end | |
735 | + | |
736 | + if self.isDel then return end | |
737 | + | |
738 | + if oldLayer ~= self.layer then | |
739 | + if self._uncover then | |
740 | + self:_uncover() | |
741 | + end | |
663 | 742 | end |
664 | 743 | end |
665 | 744 | ... | ... |
src/adv/AdvMap.lua
... | ... | @@ -13,12 +13,12 @@ local createMap, getEventLib |
13 | 13 | function Map:ctor(adv, mapIdx, mapInfo, isEnter, isNewRelay) |
14 | 14 | self.adv = adv |
15 | 15 | local isNew = type(mapInfo) == "number" |
16 | + self.mapIdx = mapIdx | |
16 | 17 | if isNew then -- mapInfo 传入 id |
17 | 18 | mapInfo = createMap(self, mapInfo, isEnter, isNewRelay) -- 生成地图 |
18 | 19 | end |
19 | 20 | if not mapInfo then return end |
20 | 21 | |
21 | - self.mapIdx = mapIdx | |
22 | 22 | self.mapId = mapInfo.mapId |
23 | 23 | self.isShow = mapInfo.isShow -- 是否全部展示 -- 客户端用 |
24 | 24 | self.rooms = {} |
... | ... | @@ -256,9 +256,9 @@ function Map:openBlock(roomId, blockId, isPlayer, ignoreBack) |
256 | 256 | |
257 | 257 | if status then |
258 | 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 | 260 | self.adv.owner:checkTaskEnter("AdvOpenBlock") |
261 | - | |
261 | + self.adv.battle.player:changeSp(1) -- 翻开格子 sp 加1 | |
262 | 262 | -- 潜行检查 |
263 | 263 | local sneakBuff = self.adv.battle.player:hadBuff(Buff.SNEAK) |
264 | 264 | if sneakBuff then |
... | ... | @@ -272,8 +272,8 @@ function Map:openBlock(roomId, blockId, isPlayer, ignoreBack) |
272 | 272 | if not ignoreBack then |
273 | 273 | self.adv:backBlockChange(roomId, blockId) |
274 | 274 | end |
275 | - | |
276 | 275 | end |
276 | + return status | |
277 | 277 | end |
278 | 278 | |
279 | 279 | function Map:openBlocksBySize(roomId, blockId, size, isPlayer, ignoreBack) |
... | ... | @@ -292,6 +292,41 @@ function Map:openBlocksByRoom(roomId, isPlayer, ignoreBack) |
292 | 292 | end |
293 | 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 | 330 | function Map:openAllBlocks(isPlayer, ignoreBack) |
296 | 331 | for roomId, room in pairs(self.rooms) do |
297 | 332 | self:openBlocksByRoom(room.roomId, isPlayer, ignoreBack) |
... | ... | @@ -309,6 +344,22 @@ function Map:getRBByPos(c, r) |
309 | 344 | end |
310 | 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 | 363 | function Map:getAroundBlocks(room, block) |
313 | 364 | local blocks = {} |
314 | 365 | local range = {1, -1} |
... | ... | @@ -412,6 +463,18 @@ function Map:getEnemysBySize(roomId, blockId, size) |
412 | 463 | return enemys |
413 | 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 | 480 | -- isEnter isNewRelay 区分中继层的类型 --是否是开始进入 是否是第一次进入 |
... | ... | @@ -748,6 +811,48 @@ createMap = function(self, mapId, isEnter, isNewRelay) |
748 | 811 | end |
749 | 812 | end |
750 | 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 | 857 | if mapCsvData.clearType == 1 and not haveBoss then |
753 | 858 | if not next(monsterEvents) then | ... | ... |
src/adv/AdvPassive.lua
... | ... | @@ -7,6 +7,8 @@ Filter.HP_LOW = 4 -- 血量<value% |
7 | 7 | Filter.BUFF_BY_TYPE = 5 -- 指定类型buff |
8 | 8 | Filter.BUFF_BY_ID = 6 -- 指定id的buff |
9 | 9 | Filter.CAMP = 7 -- 玩家是指定阵营 |
10 | +Filter.RANGE = 8 -- 筛选范围 (触发是地块) | |
11 | +Filter.CLASSIFY = 9 -- 标签 | |
10 | 12 | |
11 | 13 | local FilterFactory = {} |
12 | 14 | FilterFactory[Filter.HP_UP_WITH_EQUAL] = function (_Filter) |
... | ... | @@ -46,6 +48,21 @@ FilterFactory[Filter.CAMP] = function (_Filter) |
46 | 48 | end |
47 | 49 | end |
48 | 50 | |
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 | + | |
61 | +FilterFactory[Filter.CLASSIFY] = function (_Filter) | |
62 | + _Filter._execute = function (self, target) | |
63 | + return target.isClassify and target:isClassify(self.value) | |
64 | + end | |
65 | +end | |
49 | 66 | |
50 | 67 | function Filter:ctor(params) |
51 | 68 | self.owner = params.owner |
... | ... | @@ -78,9 +95,8 @@ function Filter:execute(params) |
78 | 95 | if not target then |
79 | 96 | return |
80 | 97 | end |
81 | - if self:_execute(target) then | |
82 | - return self:_execute(target) | |
83 | - end | |
98 | + | |
99 | + return self:_execute(target, params) | |
84 | 100 | end |
85 | 101 | |
86 | 102 | -->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |
... | ... | @@ -121,6 +137,7 @@ Passive.OPEN_BLOCK = 29 --翻开格子 |
121 | 137 | Passive.OPEN_MONSTER = 30 --翻开怪物 |
122 | 138 | Passive.PLAYER_BUFF = 31 --玩家获得buff |
123 | 139 | |
140 | +Passive.PLAYER_BUFF_CLASSIFY = 35 -- 获得指定标签的buff | |
124 | 141 | |
125 | 142 | -- 不同的开启条件 |
126 | 143 | local PassiveCondFactory = {} |
... | ... | @@ -183,6 +200,14 @@ PassiveCondFactory[Passive.GET_BUFF] = function(_Passive) |
183 | 200 | end |
184 | 201 | PassiveCondFactory[Passive.PLAYER_BUFF] = PassiveCondFactory[Passive.GET_BUFF] |
185 | 202 | |
203 | +PassiveCondFactory[Passive.PLAYER_BUFF_CLASSIFY] = function(_Passive) | |
204 | + _Passive._trigger = function(self, params) | |
205 | + if params.classify:sismember(self.passiveData.value, " ") then | |
206 | + return true | |
207 | + end | |
208 | + end | |
209 | +end | |
210 | + | |
186 | 211 | |
187 | 212 | PassiveCondFactory[Passive.BORN_ONCE] = function(_Passive) |
188 | 213 | _Passive._afterRound = function(self) |
... | ... | @@ -314,6 +339,7 @@ function Passive:canEffect(effType, effValue) |
314 | 339 | end |
315 | 340 | |
316 | 341 | function Passive:effect(triggerPms) |
342 | + local hadEffect = false | |
317 | 343 | for _, effect in ipairs(self.effects) do |
318 | 344 | local effType = effect[1] |
319 | 345 | local effValue = effect[2] |
... | ... | @@ -322,10 +348,13 @@ function Passive:effect(triggerPms) |
322 | 348 | table.insert(otherPms, effect[i]) |
323 | 349 | end |
324 | 350 | if self:canEffect(effType, effValue) then |
351 | + hadEffect = true | |
325 | 352 | self["effect" .. effType](self, effValue, triggerPms, table.unpack(otherPms)) |
326 | 353 | end |
327 | 354 | end |
328 | - | |
355 | + if hadEffect then | |
356 | + self.owner.battle.adv:pushBackEvent(AdvBackEventType.PassiveEffect, {id = self.id, level = self.level, roomId = self.owner.roomId, blockId = self.owner.blockId}) | |
357 | + end | |
329 | 358 | if self.count > 0 then |
330 | 359 | self.count = self.count < 999 and self.count - 1 or self.count |
331 | 360 | self.round = self.passiveData.round |
... | ... | @@ -434,6 +463,7 @@ end |
434 | 463 | |
435 | 464 | --3=翻开自己所在格子 |
436 | 465 | function Passive:effect3(value) |
466 | + if not self.owner.roomId or not self.owner.blockId then return end | |
437 | 467 | if value == 0 then |
438 | 468 | self.owner.battle.adv:getCurMap():openBlock(self.owner.roomId, self.owner.blockId) |
439 | 469 | elseif value > 0 then |
... | ... | @@ -486,7 +516,7 @@ function Passive:effect8(dropId) |
486 | 516 | skynet.error(string.format("CSVDATA Error adv_map_passive %s effect 8 not id %s in event_drop", self.id, dropId)) |
487 | 517 | end |
488 | 518 | local item = dropData["range"]:randWeight(true) |
489 | - 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}) | |
519 | + self.owner.battle.adv:award({[item[1]] = item[2]}, {log = {desc = "passive", int1 = self.id}}, {roomId = self.owner.roomId, blockId = self.owner.blockId}) | |
490 | 520 | |
491 | 521 | end |
492 | 522 | |
... | ... | @@ -501,7 +531,7 @@ function Passive:effect9(itemId, triggerPms, ratio, max) |
501 | 531 | return |
502 | 532 | end |
503 | 533 | if not cond then return end |
504 | - 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}) | |
534 | + 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}) | |
505 | 535 | end |
506 | 536 | |
507 | 537 | --10=战斗额外掉落次数 |
... | ... | @@ -553,5 +583,22 @@ function Passive:effect14(value, triggerPms, enemyId) |
553 | 583 | end |
554 | 584 | end |
555 | 585 | |
586 | +--15=翻开房间内的count 个怪 并且增加一个buff | |
587 | +function Passive:effect15(count, triggerPms, buffId) | |
588 | + local roomId = self.owner.roomId | |
589 | + if not roomId then return end | |
590 | + local enemys = self.owner.battle.adv:getCurMap():openBlocksIsMonsterByRoom(roomId, count) | |
591 | + for _, e in ipairs(enemys) do | |
592 | + e:addBuff(buffId) | |
593 | + end | |
594 | +end | |
595 | + | |
596 | +--16=转变 value 范围内的掉落物 为 id count | |
597 | +function Passive:effect16(value, triggerPms, changeType) | |
598 | + if not self.owner.roomId or not self.owner.blockId then return end | |
599 | + local blocks = self.owner.battle.adv:getCurMap():getBlocksBySize(self.owner.roomId, self.owner.blockId, value) | |
600 | + self.owner.battle.adv:blockDropChange(changeType, blocks) | |
601 | +end | |
602 | + | |
556 | 603 | |
557 | 604 | return Passive |
558 | 605 | \ No newline at end of file | ... | ... |
src/adv/AdvPlayer.lua
... | ... | @@ -90,6 +90,12 @@ end |
90 | 90 | function BaseObject:clear() |
91 | 91 | self.buffs = {} |
92 | 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 | 99 | end |
94 | 100 | |
95 | 101 | function BaseObject:addPassive(params) |
... | ... | @@ -137,7 +143,21 @@ function BaseObject:getDisablePassiveCount() |
137 | 143 | return count |
138 | 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 | 161 | local buffData = csvdb["adv_map_buffCsv"][buffId] |
142 | 162 | if not buffData then return end |
143 | 163 | for _, buff in ipairs(self.buffs) do |
... | ... | @@ -151,7 +171,7 @@ function BaseObject:addBuff(buffId, releaser) |
151 | 171 | local oldBuff = self:getBuffById(buffId) |
152 | 172 | if oldBuff then |
153 | 173 | if not oldBuff:checkKeep() then return end |
154 | - oldBuff:overlay(releaser, {}) -- 叠加 | |
174 | + oldBuff:overlay(releaser, {}, layer) -- 叠加 | |
155 | 175 | else |
156 | 176 | -- 不能保持的buff 也加不上去 |
157 | 177 | if not Buff.checkKeep({ |
... | ... | @@ -161,9 +181,11 @@ function BaseObject:addBuff(buffId, releaser) |
161 | 181 | }) then return end |
162 | 182 | local buff = Buff.create(self, releaser, {id = buffId}) |
163 | 183 | table.insert(self.buffs, buff) |
164 | - buff:createAfter() | |
184 | + buff:createAfter(layer) | |
165 | 185 | end |
166 | - self:triggerPassive(Passive.GET_BUFF, {buffId = buffId}) | |
186 | + self:triggerPassive(Passive.GET_BUFF, {trigger = releaser, buffId = buffId}) | |
187 | + self:triggerPassive(Passive.PLAYER_BUFF_CLASSIFY, {trigger = releaser, classify = buffData.classify}) | |
188 | + self:attrChangeCondBuffCheck(2, buffId) | |
167 | 189 | return true |
168 | 190 | end |
169 | 191 | |
... | ... | @@ -216,6 +238,44 @@ end |
216 | 238 | function BaseObject:reSetSpMax() |
217 | 239 | end |
218 | 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 | + | |
219 | 279 | |
220 | 280 | -- 通用的buff 效果汇总 -- 0 固定 1百分比 两种分类 |
221 | 281 | function BaseObject:getCommonBuffEffect(bType, otherCond) |
... | ... | @@ -416,7 +476,7 @@ function BaseObject:hurt(value, releaser, params) |
416 | 476 | if self.hp == 0 then |
417 | 477 | self:triggerPassive(Passive.SELF_DEAD) |
418 | 478 | for _, team in ipairs(self:getTeam(1, true)) do |
419 | - team:triggerPassive(Passive.TEAM_DEAD) | |
479 | + team:triggerPassive(Passive.TEAM_DEAD, {trigger = self}) | |
420 | 480 | end |
421 | 481 | |
422 | 482 | if (params.hurtType == 6 or params.hurtType == 2) and self ~= self.battle.player then |
... | ... | @@ -504,6 +564,50 @@ function BaseObject:getTeam(nType, noSelf, mapIdx, includeLock) |
504 | 564 | return team |
505 | 565 | end |
506 | 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 | + | |
507 | 611 | function BaseObject:getDB() |
508 | 612 | local db = {} |
509 | 613 | db.hp = self.hp |
... | ... | @@ -556,6 +660,51 @@ function Enemy:isEnemy() |
556 | 660 | return true |
557 | 661 | end |
558 | 662 | |
663 | +function Enemy:getObstacle() | |
664 | + local obstacle = csvdb["event_monsterCsv"][self.monsterId].obstacle | |
665 | + if obstacle == 0 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 | + | |
559 | 708 | function Enemy:kill() |
560 | 709 | self:hurt(self.hp, self.battle.player, {hurtType = 5}) |
561 | 710 | end |
... | ... | @@ -568,44 +717,44 @@ end |
568 | 717 | |
569 | 718 | function Player:initData(data) |
570 | 719 | Player.super.initData(self, data) |
571 | - self.level = data.level or 1 --level 每增加1级 属性增长 growth * baseAttr | |
720 | + -- self.level = data.level or 1 --level 每增加1级 属性增长 growth * baseAttr | |
572 | 721 | self.growth = data.growth |
573 | - self.exp = data.exp or 0 | |
722 | + -- self.exp = data.exp or 0 | |
574 | 723 | self.sp = data.sp or 100 |
575 | 724 | self.spMax = data.spMax or 100 |
576 | 725 | self._spMax = data._spMax or 100 |
577 | 726 | end |
578 | 727 | |
579 | -function Player:addExp(value) | |
580 | - -- buff 经验加成 | |
581 | - local up = self:getCommonBuffEffect(Buff.EXP_UP) | |
582 | - value = math.ceil((value + up[0]) * (1 + up[1])) | |
583 | - | |
584 | - if value <= 0 then return end | |
585 | - local newExp = self.exp + value | |
586 | - local level = self.level | |
587 | - if level >= #csvdb["adv_levelCsv"] then return end | |
588 | - while true do | |
589 | - local curData = csvdb["adv_levelCsv"][level] | |
590 | - if newExp < curData.exp then break end | |
591 | - level = level + 1 | |
592 | - newExp = newExp - curData.exp | |
593 | - if level >= #csvdb["adv_levelCsv"] then break end | |
594 | - end | |
595 | - local delta = level - self.level | |
596 | - | |
597 | - self.battle.adv:pushBackEvent(AdvBackEventType.Exp, {delta = value}) | |
598 | - | |
599 | - if delta > 0 then | |
600 | - for attr, _ in pairs(AdvAttsEnum) do | |
601 | - self:addBaseAttr(attr, self.growth[attr] * delta, 0, true) | |
602 | - end | |
603 | - self.battle.adv:pushBackEvent(AdvBackEventType.Level, {level = level, delta = delta}) | |
604 | - end | |
605 | - self.level = level | |
606 | - self.exp = newExp | |
607 | - return value | |
608 | -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 | |
609 | 758 | --vtype 0/1 值/% |
610 | 759 | function Player:addBaseAttr(attr, value, vtype, ignoreBack) |
611 | 760 | local attrName = attr |
... | ... | @@ -670,7 +819,7 @@ function Player:effectBattleBuff() |
670 | 819 | for _, buff in ipairs(self.buffs) do |
671 | 820 | if not buff:isHide() and (buff:getType() == Buff.BATTLE_BUFF or buff:getType() == Buff.BATTLE_PASSIVE) then |
672 | 821 | buff:effect() |
673 | - if not buff.buffData.classify:sismember(7, " ") then -- 神器buff 不会清除 | |
822 | + if not buff.buffData.classify:sismember(7, " ") and not buff.buffData.classify:sismember(8, " ") then -- 神器buff 不会清除 队长技 | |
674 | 823 | buff:uncover() |
675 | 824 | end |
676 | 825 | end |
... | ... | @@ -695,30 +844,36 @@ end |
695 | 844 | function Player:addBuff(buffId, releaser) |
696 | 845 | local status = Player.super.addBuff(self, buffId, releaser) |
697 | 846 | if status then |
698 | - self.battle.player:attrChangeCondBuffCheck(2, buffId) | |
699 | 847 | self.battle.adv:checkAchievement(self.battle.adv.AchievType.GetBuff, 1, buffId) |
700 | 848 | self.battle.adv:pushBackEvent(AdvBackEventType.Buff, {buffId = buffId}) |
701 | 849 | self.battle:triggerPassive(Passive.PLAYER_BUFF, {buffId = buffId}) |
702 | 850 | end |
703 | 851 | return status |
704 | 852 | end |
853 | +-- 0=所有 1=怪物 2=玩家 | |
854 | +function Player:checkAuraBuff(buffs) | |
855 | + local needBuffs = {} | |
705 | 856 | |
706 | -function Player:attrChangeCondBuffCheck(etype, cond) | |
707 | - local effect = {} | |
708 | - for _, buff in ipairs(self.buffs) do | |
709 | - if not buff:isHide() and (buff:getType() == Buff.ATTR_CHANGE_COND) then | |
710 | - local _et, _attr, _co = buff:getEffectBy() | |
711 | - if etype == _et and (not _co or _co == cond) then | |
712 | - effect[_attr] = 1 | |
713 | - end | |
714 | - | |
715 | - 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 | |
716 | 861 | end |
717 | - for attrName, _ in pairs(effect) do | |
718 | - if attrName == "hp" then | |
719 | - self:reSetHpMax() | |
720 | - else | |
721 | - 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) | |
722 | 877 | end |
723 | 878 | end |
724 | 879 | end |
... | ... | @@ -729,7 +884,8 @@ end |
729 | 884 | |
730 | 885 | function Player:getDB() |
731 | 886 | local db = Player.super.getDB(self) |
732 | - 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 | |
733 | 889 | db[field] = self[field] |
734 | 890 | end |
735 | 891 | db["_spMax"] = self._spMax | ... | ... |
src/agent.lua
... | ... | @@ -29,12 +29,6 @@ _codeSession = {} |
29 | 29 | --- {{{ 定时器相关 |
30 | 30 | local function handle_timeout() |
31 | 31 | if not agentInfo.open_timer then return end |
32 | - | |
33 | - if not agentInfo.role then | |
34 | - skynet.timeout(100, handle_timeout) | |
35 | - return | |
36 | - end | |
37 | - | |
38 | 32 | agent_util:update(agentInfo) |
39 | 33 | skynet.timeout(100, handle_timeout) |
40 | 34 | end |
... | ... | @@ -274,6 +268,8 @@ function CMD.start(session, source, gate, fd, ip, hotfixs) |
274 | 268 | end |
275 | 269 | end |
276 | 270 | |
271 | + start_agent_timer() | |
272 | + | |
277 | 273 | -- 这里将消息伪装成 watchdog 发出,这样就由 A->B->C->B->A 变成 A->B->C->A |
278 | 274 | skynet.redirect(gate, source, "lua", session, skynet.pack("forward", fd, 0, skynet.self())) |
279 | 275 | end | ... | ... |
src/main.lua
1 | 1 | local skynet = require "skynet" |
2 | 2 | |
3 | 3 | local max_client = tonumber(skynet.getenv("max_client")) |
4 | +local max_queue = tonumber(skynet.getenv("max_queue")) | |
4 | 5 | |
5 | 6 | skynet.start(function() |
6 | 7 | print("Server start") |
... | ... | @@ -12,7 +13,7 @@ skynet.start(function() |
12 | 13 | |
13 | 14 | skynet.call(watchdog, "lua", "start", { |
14 | 15 | port = tonumber(skynet.getenv("server_port")), |
15 | - maxclient = max_client, | |
16 | + maxclient = max_client + max_queue + 10, | |
16 | 17 | httpd = httpd, |
17 | 18 | |
18 | 19 | redishost = skynet.getenv("redis_host"), | ... | ... |
src/models/Activity.lua
... | ... | @@ -18,6 +18,12 @@ Activity.ActivityType = { |
18 | 18 | DrawHero = 12, --抽卡周 招募 |
19 | 19 | AdvDraw = 13, --拾荒抽周 资助 |
20 | 20 | OpenBox = 14, --拆解周 时钟箱 |
21 | + RaceDraw = 16, -- 定向招募活动 | |
22 | + | |
23 | + ChallengeLevel = 17, -- 挑战关卡活动 | |
24 | + Exchange = 18, -- 兑换活动 | |
25 | + HangDrop = 19, -- 挂机掉落活动 | |
26 | + Gachakon = 20, -- 扭蛋活动 | |
21 | 27 | } |
22 | 28 | |
23 | 29 | |
... | ... | @@ -47,6 +53,11 @@ Activity.schema = { |
47 | 53 | act12 = {"table", {}}, -- {0 = 抽卡次数, 1=1, 2=1} 抽卡周活动 1表示领取过该档位的奖励 |
48 | 54 | act13 = {"table", {}}, -- {0 = 拾荒消耗远古金币数量, 1=1, 2=1} 拾荒周活动 1表示领取过该档位的奖励 |
49 | 55 | act14 = {"table", {}}, -- {0 = 拆解数量, 1=1, 2=1} 拆解周活动 1表示领取过该档位的奖励 |
56 | + | |
57 | + act17 = {"table", {}}, -- {id=关卡星数, totalDmg=Boss总伤害} | |
58 | + act18 = {"table", {}, true}, -- {id=兑换数量} | |
59 | + act19 = {"number", 0}, -- {挂机信息} | |
60 | + act20 = {"table", {}}, -- {id=扭蛋抽出数量} | |
50 | 61 | } |
51 | 62 | |
52 | 63 | function Activity:data() |
... | ... | @@ -60,6 +71,11 @@ function Activity:data() |
60 | 71 | act12 = self:getProperty("act12"), |
61 | 72 | act13 = self:getProperty("act13"), |
62 | 73 | act14 = self:getProperty("act14"), |
74 | + | |
75 | + act17 = self:getProperty("act17"), | |
76 | + act18 = self:getProperty("act18"), | |
77 | + act19 = self:getProperty("act19"), | |
78 | + act20 = self:getProperty("act20"), | |
63 | 79 | } |
64 | 80 | end |
65 | 81 | |
... | ... | @@ -137,6 +153,10 @@ function Activity:isOpen(activityType) |
137 | 153 | return false |
138 | 154 | end |
139 | 155 | |
156 | +function Activity:isOpenById(id) | |
157 | + return self._isOpen[id] | |
158 | +end | |
159 | + | |
140 | 160 | function Activity:getActData(actType) |
141 | 161 | actType = checkActivityType(actType) |
142 | 162 | return self:getProperty("act" .. actType) |
... | ... | @@ -344,8 +364,18 @@ activityFunc[Activity.ActivityType.PaySignIn] = { |
344 | 364 | ["init"] = function(self, actType, isCrossDay, notify) |
345 | 365 | self:updateActData(actType, {}, not notify) |
346 | 366 | end, |
347 | - -- ["close"] = function(self, actType, notify) | |
348 | - -- end, | |
367 | + ["close"] = function(self, actType, notify) | |
368 | + self.owner.storeData:SetActGoodsFlag("paySignIn", 0) | |
369 | + | |
370 | + local rechargeRecord = self.owner.storeData:getProperty("payR") | |
371 | + for id, cfg in pairs(csvdb["shop_rechargeCsv"]) do | |
372 | + if cfg.shop == 2 and cfg.type == CardType.PaySignCard then | |
373 | + rechargeRecord[id] = nil | |
374 | + break | |
375 | + end | |
376 | + end | |
377 | + self.owner.storeData:updateProperty({field="payR", value=rechargeRecord}) | |
378 | + end, | |
349 | 379 | } |
350 | 380 | |
351 | 381 | -- 充值反馈 |
... | ... | @@ -367,12 +397,99 @@ activityFunc[Activity.ActivityType.PayBack] = { |
367 | 397 | -- end, |
368 | 398 | } |
369 | 399 | |
400 | +-- 英雄帖 | |
401 | +activityFunc[Activity.ActivityType.CalendaTask] = { | |
402 | + ["init"] = function(self, actType, isCrossDay, notify) | |
403 | + local calTask = self.owner:getProperty("CalTask") | |
404 | + calTask = {} | |
405 | + local role = self.owner | |
406 | + local buildL = role.dinerData:getProperty("buildL") | |
407 | + local curLevel = buildL:getv(1, 1) | |
408 | + role:checkTaskEnter("DinerLevelUp", {level = curLevel}) | |
409 | + | |
410 | + role:checkTaskEnter("HeroLvlCollect", {}) | |
411 | + role:checkTaskEnter("HeroQualityCollect", {}) | |
412 | + | |
413 | + local curPopular = role.dinerData:getProperty("popular") | |
414 | + role:checkTaskEnter("DinerPopular", {count = curPopular}) | |
415 | + | |
416 | + local rLevel = role:getProperty("level") | |
417 | + role:checkTaskEnter("RoleLevelUp", {level = rLevel}) | |
418 | + | |
419 | + local towerInfo = role:getProperty("towerInfo") | |
420 | + role:checkTaskEnter("TowerPass", {level = towerInfo.l}) | |
421 | + --"PvpWin" | |
422 | + role:checkTaskEnter("HangPass", {}) | |
423 | + role:checkTaskEnter("HeroStarCollect", {}) | |
424 | + role:checkTaskEnter("RuneQualityCollect", {}) | |
425 | + | |
426 | + end, | |
427 | + -- ["close"] = function(self, actType, notify) | |
428 | + -- end, | |
429 | +} | |
430 | + | |
431 | +-- 兑换 | |
432 | +activityFunc[Activity.ActivityType.Exchange] = { | |
433 | + ["init"] = function(self, actType, isCrossDay, notify, actId) | |
434 | + local actData = self:getActData(actType) or {} | |
435 | + actData[actId] = {} | |
436 | + self:updateActData(actType, actData, not notify) | |
437 | + end, | |
438 | + ["crossDay"] = function(self, actType, notify, actId) | |
439 | + local actData = self:getActData(actType) or {} | |
440 | + local lastTs = actData["ts"] or 0 | |
441 | + local timeNow = skynet.timex() | |
442 | + local cfg = csvdb["activity_ctrlCsv"][actId] | |
443 | + if not cfg then return end | |
444 | + local refreshTimes = cfg.condition2:toArray(false, "=") | |
445 | + for i = 1, #refreshTimes do | |
446 | + local rt = toUnixtime(refreshTimes[1]..string_format("%02x", RESET_TIME)) | |
447 | + if timeNow >= rt and rt > lastTs then | |
448 | + lastTs = rt | |
449 | + actData = {} | |
450 | + end | |
451 | + end | |
452 | + if next(actData) then | |
453 | + actData["ts"] = lastTs | |
454 | + self:updateActData(actType, actData, not notify) | |
455 | + end | |
456 | + end, | |
457 | + ["close"] = function(self, actType, notify, actId) | |
458 | + local actData = self:getActData(actType) or {} | |
459 | + actData[actId] = nil | |
460 | + self:updateActData(actType, actData, not notify) | |
461 | + end, | |
462 | +} | |
463 | + | |
464 | +-- 扭蛋机 | |
465 | +activityFunc[Activity.ActivityType.Gachakon] = { | |
466 | + ["init"] = function(self, actType, isCrossDay, notify, actId) | |
467 | + self:updateActData(actType, {}, not notify) | |
468 | + end, | |
469 | + ["crossDay"] = function(self, actType, notify) | |
470 | + self:updateActData(actType, {}, not notify) | |
471 | + end, | |
472 | +} | |
473 | + | |
474 | +-- 挂机掉落 | |
475 | +activityFunc[Activity.ActivityType.HangDrop] = { | |
476 | + ["init"] = function(self, actType, isCrossDay, notify, actId) | |
477 | + local actime = self:getProperty("actime") | |
478 | + local startTime = actime[actId] | |
479 | + local actData = self:getActData(actType) or 0 | |
480 | + local cfg = csvdb["activity_putCsv"][actId] | |
481 | + if not cfg then return end | |
482 | + actData = startTime | |
483 | + self:updateActData(actType, actData, not notify) | |
484 | + end | |
485 | +} | |
486 | + | |
370 | 487 | function Activity:initActivity(actId, isCrossDay, notify) |
371 | 488 | local actData = csvdb["activity_ctrlCsv"][actId] |
372 | 489 | if not actData then return end |
373 | 490 | local actType = actData.showType |
374 | 491 | if activityFunc[actType] and activityFunc[actType]['close'] then |
375 | - activityFunc[actType]["init"](self, actType, isCrossDay, notify) | |
492 | + activityFunc[actType]["init"](self, actType, isCrossDay, notify, actId) | |
376 | 493 | end |
377 | 494 | end |
378 | 495 | |
... | ... | @@ -381,7 +498,8 @@ function Activity:closeActivity(actId, notify, notUpdateAct) |
381 | 498 | if not actData then return end |
382 | 499 | local actType = actData.showType |
383 | 500 | if activityFunc[actType] and activityFunc[actType]['close'] then |
384 | - activityFunc[actType]["close"](self, actType, notify) | |
501 | + activityFunc[actType]["close"](self, actType, notify, actId) | |
502 | + self:recycleActItem(actId) | |
385 | 503 | end |
386 | 504 | if Activity.schema["act".. actType] then |
387 | 505 | self:updateActData(actType, Activity.schema["act" .. actType][2], not notify or notUpdateAct) |
... | ... | @@ -394,7 +512,7 @@ function Activity:refreshDailyData(notify) |
394 | 512 | if status and actData then |
395 | 513 | local actType = actData.showType |
396 | 514 | if activityFunc[actType] and activityFunc[actType]['crossDay'] then |
397 | - activityFunc[actType]["crossDay"](self, actType, notify) | |
515 | + activityFunc[actType]["crossDay"](self, actType, notify, actId) | |
398 | 516 | end |
399 | 517 | end |
400 | 518 | end |
... | ... | @@ -411,8 +529,8 @@ end |
411 | 529 | -- 获取此次挂机掉落翻倍时长 |
412 | 530 | function Activity:getActHangDoubleTime(lastTs, nowTs) |
413 | 531 | local type = "DoubleDrop" |
414 | - local actId = checkActivityType(type) | |
415 | - local isOpen = self:isOpen(type) | |
532 | + --local actId = checkActivityType(type) | |
533 | + local isOpen, actId = self:isOpen(type) | |
416 | 534 | local openTs = self:getProperty("actime")[actId] or 0 |
417 | 535 | local timeNow = skynet.timex() |
418 | 536 | lastTs = math.max(lastTs, openTs) |
... | ... | @@ -487,5 +605,33 @@ function Activity:getPaySignReward() |
487 | 605 | --SendPacket(actionCodes.Activity_actPaySignRpc, MsgPack.pack(role:packReward(reward, change))) |
488 | 606 | end |
489 | 607 | |
608 | +-- 回收活动道具 | |
609 | +function Activity:recycleActItem(actId) | |
610 | + local role = self.owner | |
611 | + local actCfg = csvdb["activity_ctrlCsv"][actId] | |
612 | + if not actCfg then return end | |
613 | + local gift = {} | |
614 | + local costs = {} | |
615 | + for _, arr in ipairs(actCfg.recycle:toTableArray(true)) do | |
616 | + local fromId, toId, toNum = arr[1], arr[2], arr[3] | |
617 | + local itemCount = role:getItemCount(fromId) | |
618 | + if itemCount > 0 then | |
619 | + costs[fromId] = (costs[fromId] or 0) + itemCount | |
620 | + gift[toId] = toNum * itemCount | |
621 | + end | |
622 | + end | |
623 | + if next(costs) then | |
624 | + local itemStr = "" | |
625 | + for k, v in pairs(costs) do | |
626 | + if itemStr ~= "" then | |
627 | + itemStr = itemStr .. " " | |
628 | + end | |
629 | + itemStr = itemStr .. k .. "=" .. v | |
630 | + end | |
631 | + role:costItems(costs, {log = {desc = "actRecycle"}}) | |
632 | + role:sendMail(actCfg.recycle_email, nil, gift, {itemStr}) | |
633 | + end | |
634 | +end | |
635 | + | |
490 | 636 | |
491 | 637 | return Activity | ... | ... |
src/models/Diner.lua
... | ... | @@ -298,6 +298,9 @@ function Diner:expediteSell(slot) |
298 | 298 | self:checkDinerTask(DinerTask.SellDishType, expediteCount, math.ceil(sell.dish / 100)) |
299 | 299 | self:checkDinerTask(DinerTask.SellDishRare, expediteCount, dishData.rarity) |
300 | 300 | self.owner:checkTaskEnter("FoodSell", {count = expediteCount}) |
301 | + | |
302 | + local needTime = sells[slot].count * dishData.sell_time + sells[slot].time - skynet.timex() | |
303 | + self.owner:pushMsg({type = "food", slot = slot, time = needTime}) | |
301 | 304 | end |
302 | 305 | return { |
303 | 306 | expediteCount = expediteCount, | ... | ... |
src/models/Email.lua
... | ... | @@ -48,10 +48,10 @@ function Email:data() |
48 | 48 | |
49 | 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 | 56 | if title == "" and emailData.title ~= "" then |
57 | 57 | title = emailData.title |
... | ... | @@ -67,12 +67,14 @@ function Email:data() |
67 | 67 | end |
68 | 68 | |
69 | 69 | return { |
70 | + cfgId = emailId, | |
70 | 71 | id = self:getProperty("id"), |
71 | 72 | status = self:getProperty("status"), |
72 | 73 | createtime = self:getProperty("createtime"), |
73 | 74 | title = title, |
74 | 75 | stitle = stitle, |
75 | 76 | content = content, |
77 | + contentPms = contentPms, | |
76 | 78 | attachments = attachments, |
77 | 79 | } |
78 | 80 | end | ... | ... |
src/models/Hero.lua
... | ... | @@ -15,6 +15,7 @@ Hero.schema = { |
15 | 15 | -- loveL = {"number", 0}, --好感度等级 |
16 | 16 | equip = {"string",""}, --装备 type=level |
17 | 17 | rune = {"string",""}, --零件 type=id |
18 | + faith = {"number", 0}, -- 信赖 | |
18 | 19 | } |
19 | 20 | |
20 | 21 | function Hero:ctor( properties ) |
... | ... | @@ -102,6 +103,7 @@ function Hero:data() |
102 | 103 | -- loveL = self:getProperty("loveL"), |
103 | 104 | equip = self:getProperty("equip"), |
104 | 105 | rune = self:getProperty("rune"), |
106 | + faith = self:getProperty("faith") | |
105 | 107 | } |
106 | 108 | end |
107 | 109 | |
... | ... | @@ -109,4 +111,12 @@ function Hero:getCamp() |
109 | 111 | return csvdb["unitCsv"][self:getProperty("type")].camp |
110 | 112 | end |
111 | 113 | |
114 | +function Hero:getRare() | |
115 | + return csvdb["unitCsv"][self:getProperty("type")].rare | |
116 | +end | |
117 | + | |
118 | +function Hero:getPosition() | |
119 | + return csvdb["unitCsv"][self:getProperty("type")].position | |
120 | +end | |
121 | + | |
112 | 122 | return Hero |
113 | 123 | \ No newline at end of file | ... | ... |
src/models/HeroPlugin.lua
... | ... | @@ -48,30 +48,29 @@ function HeroPlugin.bind(Hero) |
48 | 48 | local breakL = params.breakL or self:getProperty("breakL") |
49 | 49 | local wakeL = params.wakeL or self:getProperty("wakeL") |
50 | 50 | local talent = params.talent or self:getProperty("talent") |
51 | - | |
51 | + local heroCfgId = self:getProperty("type") | |
52 | 52 | --天赋 |
53 | 53 | local talentAttrS = {} |
54 | 54 | |
55 | 55 | -- 四个基础属性 |
56 | 56 | local curData = csvdb["unit_talentCsv"][talent:getv(0, 1)] |
57 | + local curTalentLvl = 0 | |
57 | 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 | 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 | 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 | 73 | end |
74 | - | |
75 | 74 | |
76 | 75 | for _, attrName in pairs(AttsEnumEx) do |
77 | 76 | if talentAttrS[attrName] then |
... | ... | @@ -79,6 +78,22 @@ function HeroPlugin.bind(Hero) |
79 | 78 | end |
80 | 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 | 97 | local attrs = {} |
83 | 98 | for _, attName in pairs(AttsEnumEx) do |
84 | 99 | attrs[attName] = unitData[attName] or 0 |
... | ... | @@ -90,7 +105,7 @@ function HeroPlugin.bind(Hero) |
90 | 105 | for attr, value in pairs(attrs) do |
91 | 106 | attrs[attr] = attrs[attr] + addAttr(attrs[attr], lData[attr .. "Level"], 1, attr) |
92 | 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 | 109 | end |
95 | 110 | |
96 | 111 | return attrs |
... | ... | @@ -111,11 +126,11 @@ function HeroPlugin.bind(Hero) |
111 | 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 | 134 | return attrs |
120 | 135 | end |
121 | 136 | |
... | ... | @@ -209,8 +224,10 @@ function HeroPlugin.bind(Hero) |
209 | 224 | |
210 | 225 | |
211 | 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 | 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 | 232 | return math.floor(battleValue) |
216 | 233 | end |
... | ... | @@ -237,6 +254,37 @@ function HeroPlugin.bind(Hero) |
237 | 254 | return level |
238 | 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 | 288 | function Hero:getSkillData(idx) |
241 | 289 | local unitData = csvdb["unitCsv"][self:getProperty("type")] |
242 | 290 | if idx == 1 then |
... | ... | @@ -296,6 +344,27 @@ function HeroPlugin.bind(Hero) |
296 | 344 | end |
297 | 345 | return |
298 | 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 | 368 | end |
300 | 369 | |
301 | 370 | ... | ... |
src/models/Role.lua
... | ... | @@ -27,6 +27,7 @@ function Role:ctor( properties ) |
27 | 27 | self.runeBag = {} |
28 | 28 | self.advData = nil |
29 | 29 | self.activity = nil |
30 | + self._pushToken = nil | |
30 | 31 | self.advElChapter = tonum(redisproxy:hget("adv_season", "chapter"), globalCsv.adv_endless_default_chapter) -- 无尽模式记录的赛季对应章节 |
31 | 32 | self.advOverTime = tonum(redisproxy:hget("adv_season", "overTime")) -- 无尽模式关闭时间戳 |
32 | 33 | if self.advOverTime == 0 then |
... | ... | @@ -98,11 +99,11 @@ Role.schema = { |
98 | 99 | advLimit = {"table", {}}, -- 冒险事件每次的limit |
99 | 100 | advC = {"number", 0}, -- 冒险次数(消耗体力) |
100 | 101 | advCT = {"number", 0}, -- 冒险次数 上次恢复时间 |
101 | - | |
102 | + advMine = {"table", {}}, -- -- {1 = {ch = 0, co = {id = count}}, 2 = {ch = 0, co = {id = count}}} 宝藏怪刷出概率 1 宝藏怪 2 宝藏洞 ch 概率 co 不同id 次数记录 | |
103 | + | |
102 | 104 | --挂机相关 |
103 | 105 | hangPass = {"table", {}}, -- 挂机通过的最大关卡 |
104 | 106 | hangGift = {"table", {}}, -- 挂机奖励 {id = 1} |
105 | - hangTeam = {"table", {}}, -- 挂机队伍 | |
106 | 107 | hangTS = {"table", {}}, -- 挂机队伍他人可读的队伍信息 |
107 | 108 | hangTB = {"table", {}}, -- 挂机队伍他人可用的战斗信息mao |
108 | 109 | hangTBV = {"number", 0}, -- 挂机队伍他人可用的战斗力 |
... | ... | @@ -110,7 +111,11 @@ Role.schema = { |
110 | 111 | hangInfo = {"table", {}}, -- 当前挂机信息 |
111 | 112 | hangBag = {"table", {}}, -- 背包 |
112 | 113 | hangBagLimit = {"number", globalCsv.idle_field_origin}, --背包上限 |
113 | - bTeam = {"table", {}}, -- 奖励副本队伍 | |
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 | |
114 | 119 | |
115 | 120 | --引导相关 |
116 | 121 | newerGuide = {"string","1=1"}, -- 新手引导 master=slave |
... | ... | @@ -141,7 +146,6 @@ Role.schema = { |
141 | 146 | boxL = {"table", {}}, -- boxList 正开启的箱子 -- {[1] = {id = 1010, gem = 101, time = 1313}} |
142 | 147 | |
143 | 148 | towerInfo = {"table", {c = globalCsv.tower_count_limit, l = 1}}, -- 当天爬塔消耗的次数 -- {t = time, c = count, l = layer, k = battleKey} |
144 | - towerF = {"table", {}}, -- 爬塔阵容 | |
145 | 149 | |
146 | 150 | spTask = {"table", {}}, -- 特殊任务 -- {id = status} |
147 | 151 | |
... | ... | @@ -161,9 +165,11 @@ Role.schema = { |
161 | 165 | emailSync = {"number", 0}, -- 已经同步到的邮件Id |
162 | 166 | |
163 | 167 | repayHero = {"number", 0}, -- 招募次数 (除去友情招募) |
168 | + repayMaxC = {"number", 0}, -- 招募保底英雄领取次数 100一次 | |
164 | 169 | floorHero = {"table", {}}, -- 招募保底 -- {[poolId] = count} |
165 | 170 | ssrUp = {"table", {}}, -- ssr up -- {[poolId] = count} |
166 | - newerDraw = {"table", {}}, -- 新手池子 {N, 1} 抽了多少次, 是否出了ssr | |
171 | + newerDraw = {"number", 0}, -- 新手池子抽卡次数 | |
172 | + wishPool = {"table", {}}, -- 心愿池子 | |
167 | 173 | |
168 | 174 | sudoku = {"table", {}}, -- 九宫格 {[-1] = 1, task = {[1] = {}, [2] = {}}}} -- [-1] 阶段 如果为 -1 关闭(都做完了), task 当前阶段任务进度, reward 连串奖励领取情况 |
169 | 175 | sign = {"table", {}}, -- 签到记录 {[1] = 20181029} |
... | ... | @@ -174,6 +180,9 @@ Role.schema = { |
174 | 180 | |
175 | 181 | downCvR = {"number", 0}, -- 下载cv扩展包奖励 |
176 | 182 | feedback = {"table", {}}, -- 反馈相关信息 {flag = false, count = 0} flag是否评论过,count 提示次数 |
183 | + | |
184 | + calTask = {"table", {}}, -- 英雄令活动 日历任务活动 | |
185 | + radioTask = {"table", {}}, -- 电台任务 {id = {time=end_ts,heros=heros}} 表crusadeCsv | |
177 | 186 | } |
178 | 187 | |
179 | 188 | |
... | ... | @@ -349,11 +358,14 @@ function Role:data() |
349 | 358 | |
350 | 359 | hangPass = self:getProperty("hangPass"), |
351 | 360 | hangGift = self:getProperty("hangGift"), |
352 | - hangTeam = self:getProperty("hangTeam"), | |
353 | 361 | hangInfo = self:getProperty("hangInfo"), |
354 | 362 | hangBag = self:getProperty("hangBag"), |
355 | 363 | hangBagLimit = self:getProperty("hangBagLimit"), |
356 | - 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"), | |
357 | 369 | |
358 | 370 | newerGuide = self:getProperty("newerGuide"), |
359 | 371 | funcGuide = self:getProperty("funcGuide"), |
... | ... | @@ -369,7 +381,6 @@ function Role:data() |
369 | 381 | equips = self:getProperty("equips"), |
370 | 382 | boxL = self:getProperty("boxL"), |
371 | 383 | towerInfo = self:getProperty("towerInfo"), |
372 | - towerF = self:getProperty("towerF"), | |
373 | 384 | spTask = self:getProperty("spTask"), |
374 | 385 | dTask = self:getProperty("dTask"), |
375 | 386 | wTask = self:getProperty("wTask"), |
... | ... | @@ -385,6 +396,7 @@ function Role:data() |
385 | 396 | repayHero = self:getProperty("repayHero"), |
386 | 397 | newerDraw = self:getProperty("newerDraw"), |
387 | 398 | floorHero = self:getProperty("floorHero"), |
399 | + wishPool = self:getProperty("wishPool"), | |
388 | 400 | |
389 | 401 | sudoku = self:getProperty("sudoku"), |
390 | 402 | sign = self:getProperty("sign"), |
... | ... | @@ -395,6 +407,8 @@ function Role:data() |
395 | 407 | downCvR = self:getProperty("downCvR"), -- 下载cv扩展包奖励 |
396 | 408 | feedback = self:getProperty("feedback"), |
397 | 409 | ctime = self:getProperty("ctime"), |
410 | + calTask = self:getProperty("calTask"), | |
411 | + radioTask = self:getProperty("radioTask"), | |
398 | 412 | } |
399 | 413 | end |
400 | 414 | ... | ... |
src/models/RoleBattle.lua
... | ... | @@ -57,7 +57,7 @@ function Role:checkBattle(battleType, params) |
57 | 57 | end |
58 | 58 | end, |
59 | 59 | tower = function() |
60 | - local towerF = self:getProperty("towerF") | |
60 | + local towerF = self:getTeamFormatByType(TeamSystemType.Tower) | |
61 | 61 | for slot, hero in pairs(self:getTeamHerosInfo(towerF.heros)) do |
62 | 62 | selflist[slot] = hero.type |
63 | 63 | end |
... | ... | @@ -72,7 +72,7 @@ function Role:checkBattle(battleType, params) |
72 | 72 | end |
73 | 73 | end, |
74 | 74 | bonus = function() |
75 | - local bTeam = self:getProperty("bTeam") | |
75 | + local bTeam = self:getTeamFormatByType(TeamSystemType.BonusBattle) | |
76 | 76 | for slot, hero in pairs(self:getTeamHerosInfo(bTeam.heros)) do |
77 | 77 | selflist[slot] = hero.type |
78 | 78 | end | ... | ... |
src/models/RoleCross.lua
... | ... | @@ -287,7 +287,7 @@ end |
287 | 287 | |
288 | 288 | function CMD.friendBattleInfo(roleId) |
289 | 289 | local info = CMD.getProperties(roleId, {"pvpTBC", "hangTB"}) |
290 | - return next(info.pvpTBC) and info.pvpTBC or info.hangTB | |
290 | + return (next(info.pvpTBC) and next(info.pvpTBC.heros)) and info.pvpTBC or info.hangTB | |
291 | 291 | end |
292 | 292 | |
293 | 293 | function CMD.pvpCInfo(roleId) | ... | ... |
src/models/RoleLog.lua
... | ... | @@ -42,6 +42,11 @@ local ItemReason = { |
42 | 42 | freeGift = 127, -- 免费礼包 |
43 | 43 | exploreCommand = 128, -- 探索指令 |
44 | 44 | drawHeroExtraReward = 129, -- 抽卡阶段奖励 |
45 | + actRecycle = 130, -- 活动道具回收 | |
46 | + actExchange = 131, -- 兑换活动 | |
47 | + actGachakon = 132, -- 扭蛋活动 | |
48 | + totalRecharge = 133, -- 累计充值奖励 | |
49 | + actHangDrop = 134, -- 掉落活动奖励 | |
45 | 50 | |
46 | 51 | |
47 | 52 | advHang = 301, -- 拾荒挂机 |
... | ... | @@ -81,6 +86,7 @@ local ItemReason = { |
81 | 86 | birth = 1006, -- 出生奖励 |
82 | 87 | actSign = 1007, -- 活动签到 |
83 | 88 | actPaySign = 1008, -- 活动付费签到 |
89 | + calendaTask = 1009, -- 英雄帖 | |
84 | 90 | |
85 | 91 | -- 餐厅 |
86 | 92 | greenHourse = 1101, -- 食材获得 |
... | ... | @@ -106,6 +112,8 @@ local ItemReason = { |
106 | 112 | unlockPool = 1208, -- 解锁英雄定向抽卡池 |
107 | 113 | downloadCv = 1209, -- 下载 cv包奖励 |
108 | 114 | refer = 1210, -- 穿戴 |
115 | + itemCompose = 1211, -- 天赋道具合成 | |
116 | + radioQuest = 1212, -- 电台任务奖励 | |
109 | 117 | |
110 | 118 | -- pvp |
111 | 119 | pvpCHead = 1301, -- pvp 跨服竞技场头像 |
... | ... | @@ -421,6 +429,79 @@ local MethodType = { |
421 | 429 | gift_name = true, -- 礼包名称 |
422 | 430 | gift_reason = true, -- 礼包发放原因,见发放原因枚举表 |
423 | 431 | }, |
432 | + | |
433 | + push_gift = { -- 礼包推送 | |
434 | + gift_id = true, --礼包ID | |
435 | + gift_name = true, --礼包名称 | |
436 | + }, | |
437 | + | |
438 | + mission_pick = { --拾荒玩法 | |
439 | + mission_threadid = true, -- 大地图ID | |
440 | + mission_threadname = true, -- 大地图名称 | |
441 | + mission_id = true, -- 关卡ID | |
442 | + mission_herolist = "json", -- 英雄ID列表,[111, 222, 333, 444, 555] 前两个为队长、副队长 | |
443 | + mission_heroscore = true, -- 编队总评分 | |
444 | + mission_teamlv = true, -- 编队等级 | |
445 | + mission_recscore = true, -- 关卡推荐评分 | |
446 | + mission_floor_bef = true, -- 进入前关卡层数 | |
447 | + mission_floor_aft = true, -- 结束时关卡层数 | |
448 | + mission_team_status = "json", -- 队伍状态,{"HP":100, "SP":100, "curse":7} | |
449 | + mission_result = true, -- 战斗结果(0-无效,1-胜利,2-血量耗尽退出,3,主动退出) | |
450 | + mission_reward = "json", -- 获得奖励,[{"id":101,"num":10},{"id":102,"num":20},{"id":103,"num":30}] | |
451 | + mission_integral_bef = true, -- 进入前积分 | |
452 | + mission_integral_aft = true, -- 完成后积分 | |
453 | + mission_cleartype = true, -- 1正常通关;2代理拾荒 | |
454 | + mission_sequenceid = true, -- 本次拾荒ID,用于关联一次拾荒产生多条不同类型的日志 | |
455 | + }, | |
456 | + | |
457 | + mission_pick_achiev = { --拾荒任务 | |
458 | + mission_threadid = true, -- 大地图ID | |
459 | + mission_threadname = true, -- 大地图名称 | |
460 | + mission_id = true, -- 关卡ID | |
461 | + mission_pick_achiev_id = true, -- 任务ID | |
462 | + mission_pick_achiev_reward = "json", -- 任务奖励,[{"id":101,"num":10},{"id":102,"num":20},{"id":103,"num":30}] | |
463 | + mission_sequenceid = true, -- 本次拾荒ID,用于关联一次拾荒产生多条不同类型的日志 | |
464 | + }, | |
465 | + | |
466 | + mission_pick_equip = { -- 拾荒神器装备 | |
467 | + mission_threadid = true, --大地图ID | |
468 | + mission_threadname = true, --大地图名称 | |
469 | + mission_id = true, --关卡ID | |
470 | + mission_pick_equip_type = true, --神器操作类型:1:装备,2:卸下 | |
471 | + mission_pick_equip_id = true, --神器ID | |
472 | + mission_pick_equip_lv = true, --神器等级 | |
473 | + mission_sequenceid = true, --本次拾荒ID,用于关联一次拾荒产生多条不同类型的日志 | |
474 | + }, | |
475 | + | |
476 | + mission_pick_reform = { --拾荒神器升级 | |
477 | + mission_threadid = true, -- 大地图ID | |
478 | + mission_threadname = true, -- 大地图名称 | |
479 | + mission_id = true, -- 关卡ID | |
480 | + mission_pick_equip_id = true, -- 神器ID | |
481 | + mission_pick_reform_beflv = true, -- 神器原等级 | |
482 | + mission_pick_reform_aftlv = true, -- 神器现等级 | |
483 | + mission_pick_reform_cost = true, -- 消耗探险点数 | |
484 | + mission_sequenceid = true, -- 本次拾荒ID,用于关联一次拾荒产生多条不同类型的日志 | |
485 | + }, | |
486 | + | |
487 | + mission_pick_use = { --拾荒任务道具使用 | |
488 | + mission_threadid = true, -- 大地图ID | |
489 | + mission_threadname = true, -- 大地图名称 | |
490 | + mission_id = true, -- 关卡ID | |
491 | + item_id = true, -- 道具ID | |
492 | + mission_pick_use_num = true, -- 道具使用量 | |
493 | + mission_sequenceid = true, -- 本次拾荒ID,用于关联一次拾荒产生多条不同类型的日志 | |
494 | + }, | |
495 | + | |
496 | + mission_pick_fund = { --拾荒资助 | |
497 | + item_id = true, -- 资助花费道具ID | |
498 | + mission_pick_fund_amount = true, -- 资助花费道具数量 | |
499 | + mission_pick_fund_cnt = true, -- 资助花费道具次数,1或者10 | |
500 | + mission_pick_fund_reward = "json", -- 资助获得奖励,[{"id":100,"num":10},{"id":101,"num":20},{"id":102,"num":30}] | |
501 | + mission_pick_fund_stagereward = "json", -- 资助阶段奖励 | |
502 | + mission_pick_fund_beflv = true, -- 资助前资助等级 | |
503 | + mission_pick_fund_aftlv = true, -- 资助后资助等级 | |
504 | + }, | |
424 | 505 | } |
425 | 506 | |
426 | 507 | local function printError(info) | ... | ... |
src/models/RolePlugin.lua
1 | 1 | |
2 | - | |
2 | +local serverId = tonumber(skynet.getenv("servId")) | |
3 | 3 | local RolePlugin = {} |
4 | 4 | |
5 | 5 | function RolePlugin.bind(Role) |
... | ... | @@ -64,6 +64,9 @@ function RolePlugin.bind(Role) |
64 | 64 | [ItemId.PlayerExp] = function() |
65 | 65 | self:addPlayExp(count, pms) |
66 | 66 | end, |
67 | + [ItemId.AdvPower] = function() | |
68 | + self:changeAdvCount(-count) | |
69 | + end, | |
67 | 70 | } |
68 | 71 | |
69 | 72 | local itemTypeAward = { |
... | ... | @@ -99,6 +102,35 @@ function RolePlugin.bind(Role) |
99 | 102 | [ItemType.FuncOpen] = function() |
100 | 103 | self:funcOpen(itemId, count, pms) |
101 | 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 | 136 | count = checkItemCount(self, itemId, count) |
... | ... | @@ -452,7 +484,12 @@ function RolePlugin.bind(Role) |
452 | 484 | newHero.owner = self |
453 | 485 | newHero:saveBattleValue() |
454 | 486 | self.heros[heroId] = newHero |
455 | - self:checkTaskEnter("AddHero", {heroType = heroType, wakeL = newHero:getProperty("wakeL"), camp = unitData.camp, job = unitData.job}, params.notNotify) | |
487 | + local ssrCount = 0 | |
488 | + if unitData.rare == HeroQuality.SSR then | |
489 | + ssrCount = self:getSSRHeroCount() | |
490 | + end | |
491 | + self:checkTaskEnter("AddHero", {heroType = heroType, wakeL = newHero:getProperty("wakeL"), camp = unitData.camp, job = unitData.job, ssrCount = ssrCount}, params.notNotify) | |
492 | + self:checkTaskEnter("HeroQualityCollect", {}) | |
456 | 493 | if not params.notNotify then |
457 | 494 | local heroResponse = {} |
458 | 495 | table.insert(heroResponse, newHero:data()) |
... | ... | @@ -485,6 +522,16 @@ function RolePlugin.bind(Role) |
485 | 522 | end |
486 | 523 | end |
487 | 524 | |
525 | + function Role:getSSRHeroCount() | |
526 | + local count = 0 | |
527 | + for _, hero in pairs(self.heros) do | |
528 | + if hero:getRare() == HeroQuality.SSR then | |
529 | + count = count + 1 | |
530 | + end | |
531 | + end | |
532 | + return count | |
533 | + end | |
534 | + | |
488 | 535 | |
489 | 536 | function Role:loadHeros() |
490 | 537 | local roleId = self:getProperty("id") |
... | ... | @@ -788,50 +835,50 @@ function RolePlugin.bind(Role) |
788 | 835 | SendPacket(actionCodes.Sys_maintainNotice, MsgPack.pack({ body = text, iskey = not isNotKey})) |
789 | 836 | end |
790 | 837 | |
791 | - function Role:getHeroActiveRelationData(heros) | |
792 | - local relations = {} | |
793 | - for _, id in pairs(heros or {}) do | |
794 | - local hero = self.heros[id] | |
795 | - if hero then | |
796 | - local camp = csvdb["unitCsv"][hero:getProperty("type")].camp | |
797 | - relations[camp] = (relations[camp] or 0) + 1 | |
798 | - end | |
799 | - end | |
800 | - local curData = csvdb["unit_relationCsv"][0] | |
801 | - if not next(relations) then return curData end | |
838 | + -- function Role:getHeroActiveRelationData(heros) | |
839 | + -- local relations = {} | |
840 | + -- for _, id in pairs(heros or {}) do | |
841 | + -- local hero = self.heros[id] | |
842 | + -- if hero then | |
843 | + -- local camp = csvdb["unitCsv"][hero:getProperty("type")].camp | |
844 | + -- relations[camp] = (relations[camp] or 0) + 1 | |
845 | + -- end | |
846 | + -- end | |
847 | + -- local curData = csvdb["unit_relationCsv"][0] | |
848 | + -- if not next(relations) then return curData end | |
802 | 849 | |
803 | - for _, data in ipairs(csvdb["unit_relationCsv"]) do | |
804 | - local had = {} | |
805 | - local isDone = true | |
806 | - for _, count in pairs(data.relation:toArray(true, "=")) do | |
807 | - local find = false | |
808 | - for camp, _count in pairs(relations) do | |
809 | - if count == _count and not had[camp] then | |
810 | - had[camp] = true | |
811 | - find = true | |
812 | - break | |
813 | - end | |
814 | - end | |
815 | - if not find then | |
816 | - isDone = false | |
817 | - break | |
818 | - end | |
819 | - end | |
820 | - if isDone then | |
821 | - curData = data | |
822 | - end | |
823 | - end | |
824 | - return curData | |
825 | - end | |
826 | - | |
827 | - function Role:getHeroActiveRelation(heros) | |
828 | - local data = self:getHeroActiveRelationData(heros) | |
829 | - local result = {} | |
830 | - for attr, value in pairs(data.effect:toNumMap()) do | |
831 | - result[AttsEnumEx[attr]] = (result[AttsEnumEx[attr]] or 0) + value | |
832 | - end | |
833 | - return result | |
834 | - end | |
850 | + -- for _, data in ipairs(csvdb["unit_relationCsv"]) do | |
851 | + -- local had = {} | |
852 | + -- local isDone = true | |
853 | + -- for _, count in pairs(data.relation:toArray(true, "=")) do | |
854 | + -- local find = false | |
855 | + -- for camp, _count in pairs(relations) do | |
856 | + -- if count == _count and not had[camp] then | |
857 | + -- had[camp] = true | |
858 | + -- find = true | |
859 | + -- break | |
860 | + -- end | |
861 | + -- end | |
862 | + -- if not find then | |
863 | + -- isDone = false | |
864 | + -- break | |
865 | + -- end | |
866 | + -- end | |
867 | + -- if isDone then | |
868 | + -- curData = data | |
869 | + -- end | |
870 | + -- end | |
871 | + -- return curData | |
872 | + -- end | |
873 | + | |
874 | + -- function Role:getHeroActiveRelation(heros) | |
875 | + -- local data = self:getHeroActiveRelationData(heros) | |
876 | + -- local result = {} | |
877 | + -- for attr, value in pairs(data.effect:toNumMap()) do | |
878 | + -- result[AttsEnumEx[attr]] = (result[AttsEnumEx[attr]] or 0) + value | |
879 | + -- end | |
880 | + -- return result | |
881 | + -- end | |
835 | 882 | |
836 | 883 | function Role:getHerosCamp(heros) |
837 | 884 | local had = {} |
... | ... | @@ -852,14 +899,16 @@ function RolePlugin.bind(Role) |
852 | 899 | return curCamp |
853 | 900 | end |
854 | 901 | |
855 | - function Role:getRealBattleValue(heros, activeRelation) -- 获取队伍战斗力 羁绊加成 | |
902 | + -- function Role:getRealBattleValue(heros, activeRelation) -- 获取队伍战斗力 羁绊加成 | |
903 | + function Role:getRealBattleValue(heros) -- 获取队伍战斗力 羁绊加成 | |
856 | 904 | heros = heros or {} |
857 | - local activeRelation = activeRelation or self:getHeroActiveRelation(heros) | |
905 | + -- local activeRelation = activeRelation or self:getHeroActiveRelation(heros) | |
858 | 906 | local battleValue = 0 |
859 | 907 | for _, id in pairs(heros) do |
860 | 908 | local hero = self.heros[id] |
861 | 909 | if hero then |
862 | - battleValue = battleValue + hero:getBattleValue(activeRelation) | |
910 | + -- battleValue = battleValue + hero:getBattleValue(activeRelation) | |
911 | + battleValue = battleValue + hero:getBattleValue() | |
863 | 912 | end |
864 | 913 | end |
865 | 914 | return battleValue |
... | ... | @@ -1117,7 +1166,7 @@ function RolePlugin.bind(Role) |
1117 | 1166 | local now = skynet.timex() |
1118 | 1167 | local ct = math.ceil((now - StdTowerRankTime) / 86400) --按天计算 365 * 27 < 10000 可以维持 27 年 |
1119 | 1168 | local ct = 10000 - ct -- 越早的排名越靠前 |
1120 | - local towerTeam = self:getProperty("towerF") | |
1169 | + local towerTeam = self:getTeamFormatByType(TeamSystemType.Tower) | |
1121 | 1170 | local battleV = self:getTeamBattleValue(towerTeam.heros) |
1122 | 1171 | local score = (level * 10000 + ct) * 10000000 + battleV |
1123 | 1172 | |
... | ... | @@ -1174,6 +1223,7 @@ function RolePlugin.bind(Role) |
1174 | 1223 | function Role:addAdvLvExp(exp) |
1175 | 1224 | local advL = self:getProperty("advL") |
1176 | 1225 | local level = advL[1] |
1226 | + local oldLevel = level | |
1177 | 1227 | local newExp = (advL[2] or 0) + exp |
1178 | 1228 | |
1179 | 1229 | if not csvdb["adv_level_fundCsv"][level + 1] then |
... | ... | @@ -1181,7 +1231,8 @@ function RolePlugin.bind(Role) |
1181 | 1231 | end |
1182 | 1232 | |
1183 | 1233 | while newExp >= csvdb["adv_level_fundCsv"][level].exp do |
1184 | - if csvdb["adv_level_fundCsv"][level + 1] and self:advChapterIsOpen(100 + csvdb["adv_level_fundCsv"][level + 1].chapter) then -- 有下一级 | |
1234 | + --if csvdb["adv_level_fundCsv"][level + 1] and self:advChapterIsOpen(100 + csvdb["adv_level_fundCsv"][level + 1].chapter) then -- 有下一级 | |
1235 | + if csvdb["adv_level_fundCsv"][level + 1] then -- 有下一级 | |
1185 | 1236 | newExp = newExp - csvdb["adv_level_fundCsv"][level].exp |
1186 | 1237 | level = level + 1 |
1187 | 1238 | else |
... | ... | @@ -1195,6 +1246,7 @@ function RolePlugin.bind(Role) |
1195 | 1246 | advL[1] = level |
1196 | 1247 | advL[2] = newExp |
1197 | 1248 | self:updateProperty({field = "advL", value = advL}) |
1249 | + return oldLevel, level | |
1198 | 1250 | end |
1199 | 1251 | |
1200 | 1252 | function Role:getAdvWheelSurfLv(ptype) |
... | ... | @@ -1242,7 +1294,7 @@ function RolePlugin.bind(Role) |
1242 | 1294 | |
1243 | 1295 | function Role:getTeamBattleInfo(team) |
1244 | 1296 | local teamInfo = {heros = {}, supports = {}} |
1245 | - local activeRelation = self:getHeroActiveRelation(team.heros) | |
1297 | + -- local activeRelation = self:getHeroActiveRelation(team.heros) | |
1246 | 1298 | |
1247 | 1299 | for slot, id in pairs(team.heros or {}) do |
1248 | 1300 | local info = {} |
... | ... | @@ -1250,7 +1302,8 @@ function RolePlugin.bind(Role) |
1250 | 1302 | if not hero then |
1251 | 1303 | print("error heroid " .. id) |
1252 | 1304 | end |
1253 | - local attrs = hero:getTotalAttrs({activeRelation = activeRelation}) | |
1305 | + -- local attrs = hero:getTotalAttrs({activeRelation = activeRelation}) | |
1306 | + local attrs = hero:getTotalAttrs() | |
1254 | 1307 | for k, v in pairs(AttsEnumEx) do |
1255 | 1308 | info[v] = (attrs[v] or 0) |
1256 | 1309 | end |
... | ... | @@ -1261,11 +1314,13 @@ function RolePlugin.bind(Role) |
1261 | 1314 | info.specialLevel = hero:getSkillLevel(1) |
1262 | 1315 | info.passiveLevel = hero:getSkillLevel(3) |
1263 | 1316 | info.runeSkill = hero:getRuneSkill(102) |
1317 | + info.talentSkills = hero:getTalentSkill() | |
1264 | 1318 | teamInfo.heros[slot] = info |
1265 | 1319 | end |
1266 | 1320 | for slot, id in pairs(team.supports or {}) do |
1267 | 1321 | teamInfo.supports[slot] = {id, self.dinerData:getProperty("dishTree"):getv(id, 0)} |
1268 | 1322 | end |
1323 | + teamInfo.tactics = globalCsv.tactics_skill_passive_cell[team.tactics] and team.tactics or nil | |
1269 | 1324 | return teamInfo |
1270 | 1325 | end |
1271 | 1326 | |
... | ... | @@ -1292,13 +1347,10 @@ function RolePlugin.bind(Role) |
1292 | 1347 | return self:getRealBattleValue(heros) |
1293 | 1348 | end |
1294 | 1349 | |
1295 | - -- 不传参数 只修改保存的阵容信息 | |
1296 | - function Role:saveHangTeam(team) | |
1297 | - if not team then | |
1298 | - team = self:getProperty("hangTeam") | |
1299 | - else | |
1300 | - self:updateProperty({field = "hangTeam", value = team}) | |
1301 | - end | |
1350 | + function Role:updateHangTeamInfo() | |
1351 | + local team = self:getTeamFormatByType(TeamSystemType.Hang) | |
1352 | + if not team then return end | |
1353 | + | |
1302 | 1354 | self:setProperties({ |
1303 | 1355 | hangTS = self:getTeamHerosInfo(team.heros), |
1304 | 1356 | hangTB = self:getTeamBattleInfo(team), |
... | ... | @@ -1306,6 +1358,41 @@ function RolePlugin.bind(Role) |
1306 | 1358 | }) |
1307 | 1359 | end |
1308 | 1360 | |
1361 | + -- 设置pve阵容 | |
1362 | + function Role:getTeamFormat(index) | |
1363 | + local teams = self:getProperty("hangTeams") or {} | |
1364 | + local team = teams[index] or {} | |
1365 | + return team | |
1366 | + end | |
1367 | + | |
1368 | + function Role:getTeamFormatByType(type) | |
1369 | + local teamIndex = self:getProperty("teamIndex") or {} | |
1370 | + local index = teamIndex[type] | |
1371 | + if not index then return {} end | |
1372 | + | |
1373 | + return self:getTeamFormat(index) | |
1374 | + end | |
1375 | + | |
1376 | + function Role:setTeamFormat(index, team) | |
1377 | + local teams = self:getProperty("hangTeams") or {} | |
1378 | + teams[index] = team | |
1379 | + self:updateProperty({field = "hangTeams", value = teams, notNotify = false}) | |
1380 | + end | |
1381 | + | |
1382 | + -- 设置拾荒编队阵容 | |
1383 | + function Role:getAdvTeamFormat(index) | |
1384 | + local teams = self:getProperty("advTeams") or {} | |
1385 | + local team = teams[index] or {} | |
1386 | + return team | |
1387 | + end | |
1388 | + | |
1389 | + function Role:setAdvTeamFormat(index, team) | |
1390 | + local teams = self:getProperty("advTeams") or {} | |
1391 | + teams[index] = team | |
1392 | + self:updateProperty({field = "advTeams", value = teams, notNotify = false}) | |
1393 | + end | |
1394 | + | |
1395 | + | |
1309 | 1396 | function Role:savePvpCTeam(team) |
1310 | 1397 | if not team then |
1311 | 1398 | team = self:getProperty("pvpTC") |
... | ... | @@ -1479,6 +1566,102 @@ function RolePlugin.bind(Role) |
1479 | 1566 | self:updateProperty({field = "redp", value = redp}) |
1480 | 1567 | end |
1481 | 1568 | |
1569 | + -- 获取充值订单号 | |
1570 | + function Role:getPurchaseOrder(rechargeId) | |
1571 | + local roleId = self:getProperty("id") | |
1572 | + local rechargeData = csvdb["shop_rechargeCsv"][rechargeId] | |
1573 | + if not rechargeData then | |
1574 | + skynet.error("recharge id not exist", rechargeId) | |
1575 | + return "" | |
1576 | + end | |
1577 | + local limit = rechargeData.limit | |
1578 | + local rechargeRecord = self:getProperty("payR") or {} | |
1579 | + if limit ~= 0 and limit <= (rechargeRecord[rechargeId] or 0) then | |
1580 | + return "" | |
1581 | + end | |
1582 | + | |
1583 | + local orderId = redisproxy:hget(string.format(R_ORDERS, roleId), rechargeId) | |
1584 | + if orderId then | |
1585 | + local orderObject = require("models.Order").new({ key = string.format(R_ORDER, roleId, orderId) }) | |
1586 | + if orderObject:load() and orderObject:getProperty("rechargeId") == rechargeId and math.abs(skynet.timex() - orderObject:getProperty("createTime")) < 5 * 60 then | |
1587 | + return string.format("%d_%d_%d", serverId, roleId, orderId) | |
1588 | + end | |
1589 | + end | |
1590 | + | |
1591 | + orderId = redisproxy:hincrby("autoincrement_set", "order", 1) | |
1592 | + local partnerOrderId = string.format("%d_%d_%d", serverId, roleId, orderId) | |
1593 | + local orderKey = string.format(R_ORDER, roleId, orderId) | |
1594 | + redisproxy:del(orderKey) -- 删掉可能有了 | |
1595 | + local order = require("models.Order").new({ | |
1596 | + key = orderKey, | |
1597 | + order = partnerOrderId, | |
1598 | + rechargeId = rechargeId, | |
1599 | + }) | |
1600 | + order:create() | |
1601 | + -- 正在进行中的订单 缓存 | |
1602 | + redisproxy:hset(string.format(R_ORDERS, roleId), rechargeId, orderId) | |
1603 | + return partnerOrderId | |
1604 | + end | |
1605 | + | |
1606 | + -- 更新订单信息 | |
1607 | + --[[ | |
1608 | + | |
1609 | + status | |
1610 | + | |
1611 | + success | |
1612 | + fail | |
1613 | + finsh | |
1614 | + unknow | |
1615 | + | |
1616 | + --]] | |
1617 | + function Role:updatePurchaseOrder(partnerOrderStr, platformOrder, status) | |
1618 | + if not partnerOrderStr then return false end | |
1619 | + local _, _, orderId = string.match(partnerOrderStr, "(.+)_(.+)_(.+)") | |
1620 | + | |
1621 | + local roleId = self:getProperty("id") | |
1622 | + local orderObject = require("models.Order").new({ key = string.format(R_ORDER, roleId, orderId) }) | |
1623 | + if not orderObject:load() then | |
1624 | + return false | |
1625 | + end | |
1626 | + | |
1627 | + local rechargeId = orderObject:getProperty("rechargeId") | |
1628 | + local dataSet = csvdb["shop_rechargeCsv"][rechargeId] | |
1629 | + | |
1630 | + if orderObject:getProperty("finishTime") > 0 then | |
1631 | + return false, "finsh" | |
1632 | + end | |
1633 | + | |
1634 | + if platformOrder then | |
1635 | + orderObject:setProperty("transactionId", platformOrder) | |
1636 | + end | |
1637 | + orderObject:setProperty("status", status) | |
1638 | + | |
1639 | + -- 开始下单 | |
1640 | + if status == "success" then | |
1641 | + elseif status == "fail" then | |
1642 | + redisproxy:hdel(string.format(R_ORDERS, roleId), rechargeId) | |
1643 | + elseif status == "finsh" then | |
1644 | + orderObject:setProperty("finishTime", skynet.time()) | |
1645 | + redisproxy:hdel(string.format(R_ORDERS, roleId), rechargeId) | |
1646 | + end | |
1647 | + | |
1648 | + if status ~= "unknow" then | |
1649 | + self:log("setOrder", { | |
1650 | + order_status = ({success = 100, finsh = 200, fail = 300})[status] or 1000, -- "订单状态:100 - 开始下单(玩家还未开始付费行为记录)200 - 支付完成并发货(SDK通知可以发货时记录),300 - 订单被取消,1000 - 其他" | |
1651 | + item_id = rechargeId, -- 道具id | |
1652 | + item_type = dataSet.type, -- 购买的道具类型,具体见"onItems"方法中道具类型枚举表 | |
1653 | + item_name = dataSet.title, -- 购买的道具名 | |
1654 | + item_number = 1, -- 购买的道具数量 | |
1655 | + item_level = 1, -- 购买的道具等级 | |
1656 | + order_cost = dataSet.rmb * 100, -- 此次消费的现金金额(单位:分),如 51800即未518元,对应客户端SDK传入的'total_fee' | |
1657 | + order_currency = "CNY", -- 货币类型,默认为"CNY"(人民币),遵循ISO 4217规范 | |
1658 | + order_type = self:getProperty("rmbC") > 0 and 0 or 1, -- 订单类型,首充记录为1,否则为0 | |
1659 | + order_id = platformOrder, -- 本条记录的订单号,对应客户端SDK返回的'bs_trade_no' | |
1660 | + }) | |
1661 | + end | |
1662 | + | |
1663 | + return true, rechargeId | |
1664 | + end | |
1482 | 1665 | |
1483 | 1666 | -- 充值 -- |
1484 | 1667 | --[[ |
... | ... | @@ -1493,63 +1676,37 @@ function RolePlugin.bind(Role) |
1493 | 1676 | local roleId = self:getProperty("id") |
1494 | 1677 | local partnerOrderStr = params.order |
1495 | 1678 | |
1496 | - local _, _, orderId = string.match(partnerOrderStr, "(.+)_(.+)_(.+)") | |
1497 | - local orderObject = require("models.Order").new({ key = string.format("order:%d:%d", roleId, orderId) }) | |
1498 | - if not orderObject:load() then | |
1499 | - -- 订单不存在 | |
1500 | - skynet.error("ayncPurchaseRpc", string.format("order %s not exist", partnerOrderStr)) | |
1501 | - return | |
1502 | - end | |
1503 | 1679 | |
1504 | - if orderObject:getProperty("finishTime") > 0 then | |
1505 | - -- 订单已经处理 | |
1506 | - SendPacket(actionCodes.Store_ayncPurchaseRpc, MsgPack.pack({ result = "handled" })) | |
1680 | + local status, back = self:updatePurchaseOrder(partnerOrderStr, params.transactionId, "finsh") | |
1681 | + if not status then | |
1682 | + if back == "finsh" then | |
1683 | + -- 订单已经处理 | |
1684 | + SendPacket(actionCodes.Store_ayncPurchaseRpc, MsgPack.pack({ result = "handled" })) | |
1685 | + end | |
1507 | 1686 | return |
1508 | 1687 | end |
1509 | - local rechargeId = orderObject:getProperty("rechargeId") | |
1688 | + local rechargeId = back | |
1510 | 1689 | local rechargeData = csvdb["shop_rechargeCsv"][rechargeId] |
1511 | 1690 | if rechargeData.rmb ~= tonumber(params.amount) then |
1512 | - skynet.error(string.format("fake order: %s, roleId: %d, order: %s, rmb %s, get %s", | |
1691 | + skynet.error(string.format("[recharge] fake order: %s, roleId: %d, order: %s, rmb %s, get %s", | |
1513 | 1692 | params.transactionId, roleId, partnerOrderStr, rechargeData.rmb, params.amount |
1514 | 1693 | )) |
1515 | 1694 | return |
1516 | 1695 | end |
1517 | 1696 | |
1518 | - local order_type = self:getProperty("rmbC") > 0 and 0 or 1 | |
1519 | 1697 | local status, reward = self:recharge({ |
1520 | 1698 | id = rechargeId, |
1521 | 1699 | transactionId = params.transactionId, |
1522 | 1700 | pay_time = params.pay_time, |
1523 | 1701 | order = partnerOrderStr, |
1524 | 1702 | }) |
1525 | - orderObject:setProperty("finishTime", skynet.time()) | |
1526 | - orderObject:setProperty("status", "finish") | |
1527 | - | |
1528 | - redisproxy:srem(string.format("role:%d:orders", roleId), partnerOrderStr) | |
1529 | 1703 | |
1530 | 1704 | if not status then |
1531 | - status = 200 | |
1532 | - else | |
1533 | - status = 1000 + status | |
1534 | - end | |
1535 | - self:log("setOrder", { | |
1536 | - order_status = status, -- "订单状态:100 - 开始下单(玩家还未开始付费行为记录)200 - 支付完成并发货(SDK通知可以发货时记录),300 - 订单被取消,1000 - 其他" | |
1537 | - item_id = rechargeId, -- 道具id | |
1538 | - item_type = rechargeData.type, -- 购买的道具类型,具体见"onItems"方法中道具类型枚举表 | |
1539 | - item_name = rechargeData.title, -- 购买的道具名 | |
1540 | - item_number = 1, -- 购买的道具数量 | |
1541 | - item_level = 1, -- 购买的道具等级 | |
1542 | - order_cost = rechargeData.rmb * 100, -- 此次消费的现金金额(单位:分),如 51800即未518元,对应客户端SDK传入的'total_fee' | |
1543 | - order_currency = "CNY", -- 货币类型,默认为"CNY"(人民币),遵循ISO 4217规范 | |
1544 | - order_type = order_type, -- 订单类型,首充记录为1,否则为0 | |
1545 | - order_id = params.transactionId, -- 本条记录的订单号,对应客户端SDK返回的'bs_trade_no' | |
1546 | - }) | |
1547 | - if status ~= 200 then return end | |
1548 | - | |
1549 | - SendPacket(actionCodes.Store_ayncPurchaseRpc, MsgPack.pack({ order = partnerOrderStr, | |
1550 | - result = "success", reward = reward})) | |
1705 | + SendPacket(actionCodes.Store_ayncPurchaseRpc, MsgPack.pack({ order = partnerOrderStr, | |
1706 | + result = "success", reward = reward})) | |
1707 | + end | |
1551 | 1708 | |
1552 | - return orderObject:getProperty("rechargeId") | |
1709 | + return rechargeId | |
1553 | 1710 | end |
1554 | 1711 | |
1555 | 1712 | |
... | ... | @@ -1557,7 +1714,7 @@ function RolePlugin.bind(Role) |
1557 | 1714 | local id = tonumber(params.id) |
1558 | 1715 | local rechargeData = csvdb["shop_rechargeCsv"][id] |
1559 | 1716 | if not rechargeData then |
1560 | - skynet.error("recharge id not exist", id) | |
1717 | + skynet.error("[recharge] recharge id not exist", id) | |
1561 | 1718 | return 1 |
1562 | 1719 | end |
1563 | 1720 | |
... | ... | @@ -1582,7 +1739,7 @@ function RolePlugin.bind(Role) |
1582 | 1739 | elseif rechargeData.shop == 3 then -- 礼包商店 |
1583 | 1740 | reward, _ = self:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}}) |
1584 | 1741 | else |
1585 | - skynet.error("invalid recharge shop type " .. id) | |
1742 | + skynet.error("[recharge] invalid recharge shop type " .. id) | |
1586 | 1743 | return 3 |
1587 | 1744 | end |
1588 | 1745 | |
... | ... | @@ -1742,7 +1899,36 @@ function RolePlugin.bind(Role) |
1742 | 1899 | end) |
1743 | 1900 | return gift, checkPoint |
1744 | 1901 | end |
1902 | + --[[ | |
1903 | + "hang" : "挂机资源满", | |
1904 | + "box" : "箱子拆解完毕", | |
1905 | + "food" : "食物出售完毕", | |
1906 | + "adv" : "代理拾荒完毕", | |
1907 | + --]] | |
1908 | + function Role:pushMsg(params) | |
1909 | + if not self._pushToken or self._pushToken == "" then return end | |
1910 | + if params.time <= 0 then | |
1911 | + self:pushCancel(params) | |
1912 | + return | |
1913 | + end | |
1914 | + local content = string.format("push:%d:%s:%s:%s", self:getProperty("id"), params.type, params.slot or 1, self._pushToken) | |
1915 | + notifyClient({content = content, time = math.floor(params.time)}) | |
1916 | + end | |
1917 | + | |
1918 | + function Role:pushCancel(params) | |
1919 | + if not self._pushToken or self._pushToken == "" then return end | |
1920 | + local content = string.format("push:%d:%s:%s:%s", self:getProperty("id"), params.type, params.slot or 1, self._pushToken) | |
1921 | + deleteNotify({content = content}) | |
1922 | + end | |
1745 | 1923 | |
1924 | + function Role:pushCancelAll(ptype) | |
1925 | + if not self._pushToken or self._pushToken == "" then return end | |
1926 | + local pattern = string.format("push:%d:*", self:getProperty("id")) | |
1927 | + if ptype then | |
1928 | + pattern = string.format("push:%d:%s:*", self:getProperty("id"), ptype) | |
1929 | + end | |
1930 | + deleteNotify({pattern = pattern}) | |
1931 | + end | |
1746 | 1932 | end |
1747 | 1933 | |
1748 | 1934 | return RolePlugin |
1749 | 1935 | \ No newline at end of file | ... | ... |
src/models/RolePvp.lua
... | ... | @@ -6,7 +6,12 @@ RolePvp.bind = function (Role) |
6 | 6 | local PVP_RANK_TIME_SORT_STD = 1924876800 -- 2030-12-31 00:00:00 |
7 | 7 | local PVP_RANK_TIME_SORT_PLACE = 1000000 -- 时间戳占据 6位数 |
8 | 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 | 17 | function Role:unpackPvpScore(score) |
... | ... | @@ -34,7 +39,7 @@ function Role:changePvpScore(rankKey, changeScoreCallback, matchId) |
34 | 39 | end) |
35 | 40 | local myScore = self:unpackPvpScore(redret[1]) |
36 | 41 | local oldMyRank = tonumber(redret[2] or -2) + 1 |
37 | - local matchScore = PVP_RANK_ROBOT_SCORE | |
42 | + local matchScore = PVP_RANK_BASE_SCORE | |
38 | 43 | if isPlayer then |
39 | 44 | matchScore = self:unpackPvpScore(redret[3]) |
40 | 45 | end |
... | ... | @@ -68,7 +73,7 @@ function Role:changePvpScoreCommon(matchId, isWin) |
68 | 73 | if isWin then |
69 | 74 | local scoreChange = math.ceil(60 / (1 + 10 ^ ((myScore - matchScore) / 400))) |
70 | 75 | myScore = myScore + scoreChange |
71 | - matchScore = matchScore - scoreChange | |
76 | + matchScore = matchScore - math.ceil(scoreChange / 3) -- 防守方失败时,扣分减为原来的1/3 | |
72 | 77 | else |
73 | 78 | local scoreChange = math.ceil(60 / (1 + 10 ^ ((matchScore - myScore) / 400))) |
74 | 79 | myScore = myScore - scoreChange |
... | ... | @@ -78,7 +83,7 @@ function Role:changePvpScoreCommon(matchId, isWin) |
78 | 83 | end |
79 | 84 | |
80 | 85 | local result = self:changePvpScore(RANK_PVP_COMMON, changeScoreCallback, matchId) |
81 | - self:refreshPvpMatchC(result[1]) | |
86 | + self:refreshPvpMatchC(result[1], result[5]) | |
82 | 87 | return table.unpack(result) |
83 | 88 | end |
84 | 89 | |
... | ... | @@ -134,7 +139,7 @@ function Role:changePvpScoreHigh(matchId, isWin) |
134 | 139 | if isWin then |
135 | 140 | local scoreChange = math.ceil(50 / (1 + 10 ^ ((myScore - matchScore) / 1000))) |
136 | 141 | myScore = myScore + scoreChange |
137 | - matchScore = matchScore - scoreChange | |
142 | + matchScore = matchScore - math.ceil(scoreChange / 3) -- 防守方失败时,扣分减为原来的1/3 | |
138 | 143 | else |
139 | 144 | local scoreChange = math.ceil(50 / (1 + 10 ^ ((matchScore - myScore) / 1000))) |
140 | 145 | myScore = myScore - scoreChange |
... | ... | @@ -162,85 +167,50 @@ function Role:changePvpScoreHigh(matchId, isWin) |
162 | 167 | }) |
163 | 168 | end |
164 | 169 | |
165 | - self:refreshPvpMatchH(result[1]) | |
170 | + self:refreshPvpMatchH(result[1], result[5]) | |
166 | 171 | return table.unpack(result) |
167 | 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 | 189 | local Fields = { |
172 | 190 | [RANK_PVP_COMMON] = "pvpMC", |
173 | 191 | [RANK_PVP_HIGHT] = "pvpMH", |
174 | 192 | } |
175 | 193 | local RobotCsvs = { |
176 | 194 | [RANK_PVP_COMMON] = "pvp_robotCsv", |
177 | - [RANK_PVP_HIGHT] = "pvp_robotCsv", | |
195 | + [RANK_PVP_HIGHT] = "pvp_robot_groupCsv", | |
178 | 196 | } |
197 | + | |
179 | 198 | local mField = Fields[rankKey] |
180 | 199 | local robotCsv = RobotCsvs[rankKey] |
181 | - local dbKey = self:getPvpDBKey(rankKey) | |
182 | 200 | |
201 | + local dbKey = self:getPvpDBKey(rankKey) | |
183 | 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 | 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 | 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 | 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 | 214 | local match = self:getProperty(mField) |
245 | 215 | local hadPlayer = {[roleId] = 1} |
246 | 216 | local hadRobot = {} |
... | ... | @@ -252,97 +222,261 @@ function Role:refreshPvpMatch(score, rankKey) |
252 | 222 | end |
253 | 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 | 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 | + print(low, heigh) | |
237 | + local rangeIds = redisproxy:ZREVRANGE(dbKey, low, heigh) | |
238 | + local lastRangeIds = {} | |
239 | + for idx, one in ipairs(rangeIds) do | |
240 | + local cid = tonumber(one) | |
241 | + if not hadPlayer[cid] then | |
242 | + lastRangeIds[#lastRangeIds + 1] = cid | |
277 | 243 | end |
278 | 244 | 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 | |
245 | + if score < PVP_GET_ROBOT_SCORE then | |
246 | + needRobot = 1 | |
288 | 247 | 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} | |
248 | + local len = #lastRangeIds | |
249 | + if len < NEED_MATCH then | |
250 | + needRobot = NEED_MATCH - len | |
296 | 251 | 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 | |
252 | + local needPlayer = NEED_MATCH - needRobot | |
253 | + if needPlayer > 0 then | |
254 | + local pre = math.floor(len / needPlayer) | |
255 | + for i = 1, needPlayer do | |
256 | + local idx = math.randomInt((i - 1) * pre + 1, i * pre) | |
257 | + tempMatch[#tempMatch + 1] = {t = 1, id = lastRangeIds[idx]} | |
307 | 258 | end |
259 | + end | |
308 | 260 | |
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 | |
261 | + end | |
262 | + if needRobot > 0 then | |
263 | + local RobotPoolCount = 20 | |
264 | + local max = #csvdb[robotCsv] | |
265 | + local min = 1 | |
266 | + local mid | |
267 | + while min <= max do | |
268 | + mid = math.floor((min + max) / 2) | |
269 | + local tempPt = csvdb[robotCsv][mid].pt | |
270 | + if score == tempPt then | |
271 | + break | |
272 | + elseif score > tempPt then | |
273 | + min = mid + 1 | |
274 | + elseif score < tempPt then | |
275 | + max = mid - 1 | |
320 | 276 | end |
321 | 277 | 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 | |
278 | + assert(mid, "pvp no robot " .. robotCsv) | |
279 | + local low = mid - RobotPoolCount / 2 | |
280 | + local heigh = mid + RobotPoolCount / 2 | |
281 | + if low < 1 then | |
282 | + heigh = heigh + (1 - low) | |
283 | + low = 1 | |
284 | + end | |
285 | + if heigh > #csvdb[robotCsv] then | |
286 | + heigh = #csvdb[robotCsv] | |
287 | + end | |
288 | + local pools = {} | |
289 | + for i = low, heigh do | |
290 | + if not hadRobot[i] then | |
291 | + pools[#pools + 1] = i | |
334 | 292 | end |
335 | 293 | end |
294 | + local pre = math.floor(#pools / needRobot) | |
295 | + for i = 1, needRobot do | |
296 | + local idx = math.randomInt((i - 1) * pre + 1, i * pre) | |
297 | + tempMatch[#tempMatch + 1] = {t = 2, id = pools[idx]} | |
298 | + end | |
336 | 299 | end |
337 | 300 | self:setProperty(mField, tempMatch) |
338 | 301 | end |
339 | 302 | |
340 | -function Role:refreshPvpMatchC(score) | |
341 | - self:refreshPvpMatch(score, RANK_PVP_COMMON) | |
303 | +-- function Role:refreshPvpMatch(score, rank, rankKey) | |
304 | + | |
305 | +-- local Fields = { | |
306 | +-- [RANK_PVP_COMMON] = "pvpMC", | |
307 | +-- [RANK_PVP_HIGHT] = "pvpMH", | |
308 | +-- } | |
309 | +-- local RobotCsvs = { | |
310 | +-- [RANK_PVP_COMMON] = "pvp_robotCsv", | |
311 | +-- [RANK_PVP_HIGHT] = "pvp_robotCsv", | |
312 | +-- } | |
313 | +-- local mField = Fields[rankKey] | |
314 | +-- local robotCsv = RobotCsvs[rankKey] | |
315 | +-- local dbKey = self:getPvpDBKey(rankKey) | |
316 | + | |
317 | +-- local roleId = self:getProperty("id") | |
318 | +-- score = score or self:unpackPvpScore(redisproxy:zscore(dbKey, roleId)) | |
319 | + | |
320 | +-- local function getPlayers(levels) | |
321 | +-- local redret = redisproxy:pipelining(function(red) | |
322 | +-- for _, level in ipairs(levels) do | |
323 | +-- local low, high = table.unpack(level) | |
324 | +-- red:zadd(dbKey, low * PVP_RANK_TIME_SORT_PLACE, "std_temp1") | |
325 | +-- red:zadd(dbKey, high * PVP_RANK_TIME_SORT_PLACE + PVP_RANK_TIME_SORT_PLACE - 1, "std_temp2") | |
326 | +-- red:ZREVRANK(dbKey, "std_temp1") | |
327 | +-- red:ZREVRANK(dbKey, "std_temp2") | |
328 | +-- end | |
329 | +-- red:zrem(dbKey, "std_temp1", "std_temp2") | |
330 | +-- end) | |
331 | + | |
332 | +-- local PreGetCount = 7 | |
333 | +-- local redret = redisproxy:pipelining(function(red) | |
334 | +-- for idx, level in ipairs(levels) do | |
335 | +-- local rank1 = tonumber(redret[(idx - 1) * 4 + 3]) | |
336 | +-- local rank2 = tonumber(redret[(idx - 1) * 4 + 4]) | |
337 | +-- if rank1 - rank2 > PreGetCount then | |
338 | +-- rank2 = math.randomInt(rank2, rank1 - PreGetCount + 1) | |
339 | +-- rank1 = rank2 + PreGetCount - 1 | |
340 | +-- end | |
341 | +-- red:ZREVRANGE(dbKey, rank2, rank1) | |
342 | +-- end | |
343 | +-- end) | |
344 | +-- return redret | |
345 | +-- end | |
346 | + | |
347 | +-- local findIdx = #globalCsv.pvp_division | |
348 | +-- for idx, limit in ipairs(globalCsv.pvp_division) do | |
349 | +-- if score < limit then | |
350 | +-- findIdx = idx - 1 | |
351 | +-- break | |
352 | +-- end | |
353 | +-- end | |
354 | +-- local levels = { | |
355 | +-- {}, {}, {} | |
356 | +-- } | |
357 | +-- if globalCsv.pvp_division[findIdx + 1] then | |
358 | +-- levels[1] = {globalCsv.pvp_division[findIdx + 1], (globalCsv.pvp_division[findIdx + 2] or 100000000) - 1} | |
359 | +-- end | |
360 | +-- levels[2] = {globalCsv.pvp_division[findIdx], (globalCsv.pvp_division[findIdx + 1] or 100000000) - 1} | |
361 | +-- if globalCsv.pvp_division[findIdx - 1] then | |
362 | +-- levels[3] = {globalCsv.pvp_division[findIdx - 1], globalCsv.pvp_division[findIdx] - 1} | |
363 | +-- end | |
364 | +-- local redirect = {} | |
365 | +-- for i = #levels , 1, -1 do | |
366 | +-- if not next(levels[i]) then | |
367 | +-- table.remove(levels, i) | |
368 | +-- redirect[i] = -1 | |
369 | +-- for _, v in pairs(redirect) do | |
370 | +-- redirect[_] = v - 1 | |
371 | +-- end | |
372 | +-- else | |
373 | +-- redirect[i] = i | |
374 | +-- end | |
375 | +-- end | |
376 | + | |
377 | +-- local result = getPlayers(levels) | |
378 | +-- local match = self:getProperty(mField) | |
379 | +-- local hadPlayer = {[roleId] = 1} | |
380 | +-- local hadRobot = {} | |
381 | +-- for _, one in pairs(match) do | |
382 | +-- if one.t == 1 then | |
383 | +-- hadPlayer[one.id] = 1 | |
384 | +-- elseif one.t == 2 then | |
385 | +-- hadRobot[one.id] = 1 | |
386 | +-- end | |
387 | +-- end | |
388 | + | |
389 | +-- for _, temp in pairs(result) do | |
390 | +-- for i = #temp, 1, -1 do | |
391 | +-- local id = tonumber(temp[i]) | |
392 | +-- if hadPlayer[id] then | |
393 | +-- table.remove(temp, i) | |
394 | +-- else | |
395 | +-- temp[i] = id | |
396 | +-- hadPlayer[id] = 1 | |
397 | +-- end | |
398 | +-- end | |
399 | +-- end | |
400 | +-- -- 增加第几个 | |
401 | +-- local function getPlayer(idx) | |
402 | +-- for i = idx, 3 do | |
403 | +-- if redirect[i] ~= -1 then | |
404 | +-- local curR = result[redirect[i]] or {} | |
405 | +-- if next(curR) then | |
406 | +-- local curIdx = math.randomInt(1, #curR) | |
407 | +-- local objId = curR[curIdx] | |
408 | +-- table.remove(curR, curIdx) | |
409 | +-- return objId | |
410 | +-- end | |
411 | +-- end | |
412 | +-- end | |
413 | +-- end | |
414 | + | |
415 | +-- local tempMatch = {} | |
416 | +-- local curCount = 0 | |
417 | +-- for i = 1, 3 do | |
418 | +-- local objId = getPlayer(i) | |
419 | +-- if objId then | |
420 | +-- tempMatch[i] = {t = 1, id = objId} | |
421 | +-- curCount = curCount + 1 | |
422 | +-- end | |
423 | +-- end | |
424 | + | |
425 | +-- -- 正常的玩家不够了 低一档继续 | |
426 | +-- if curCount < 3 then | |
427 | +-- local level = nil | |
428 | +-- if globalCsv.pvp_division[findIdx - 2] then | |
429 | +-- level = {globalCsv.pvp_division[findIdx - 2], globalCsv.pvp_division[findIdx - 1] - 1} | |
430 | +-- end | |
431 | +-- if level then | |
432 | +-- local result = getPlayers({level})[1] or {} | |
433 | +-- for i = #result, 1, -1 do | |
434 | +-- local id = tonumber(result[i]) | |
435 | +-- if hadPlayer[id] then | |
436 | +-- table.remove(result, i) | |
437 | +-- else | |
438 | +-- result[i] = id | |
439 | +-- hadPlayer[id] = 1 | |
440 | +-- end | |
441 | +-- end | |
442 | + | |
443 | +-- if next(result) then | |
444 | +-- for i = curCount + 1, 3 do | |
445 | +-- local curIdx = math.randomInt(1, #result) | |
446 | +-- local objId = result[curIdx] | |
447 | +-- table.remove(result, curIdx) | |
448 | +-- tempMatch[i] = {t = 1, id = objId} | |
449 | +-- curCount = curCount + 1 | |
450 | +-- if not next(result) then | |
451 | +-- break | |
452 | +-- end | |
453 | +-- end | |
454 | +-- end | |
455 | +-- end | |
456 | +-- end | |
457 | + | |
458 | +-- -- 增加机器人 | |
459 | +-- if curCount < 3 then | |
460 | +-- for i = curCount + 1, 3 do | |
461 | +-- while true do | |
462 | +-- local id = math.randomInt(1, #csvdb[robotCsv]) | |
463 | +-- if not hadRobot[id] then | |
464 | +-- hadRobot[id] = 1 | |
465 | +-- tempMatch[i] = {t = 2, id = id} | |
466 | +-- break | |
467 | +-- end | |
468 | +-- end | |
469 | +-- end | |
470 | +-- end | |
471 | +-- self:setProperty(mField, tempMatch) | |
472 | +-- end | |
473 | + | |
474 | +function Role:refreshPvpMatchC(score, rank) | |
475 | + self:refreshPvpMatch(score, rank, RANK_PVP_COMMON) | |
342 | 476 | end |
343 | 477 | |
344 | -function Role:refreshPvpMatchH(score) | |
345 | - self:refreshPvpMatch(score, RANK_PVP_HIGHT) | |
478 | +function Role:refreshPvpMatchH(score, rank) | |
479 | + self:refreshPvpMatch(score, rank, RANK_PVP_HIGHT) | |
346 | 480 | end |
347 | 481 | |
348 | 482 | function Role:getPvpDBKey(ptype) | ... | ... |
src/models/RoleTask.lua
... | ... | @@ -33,7 +33,7 @@ local TaskType = { |
33 | 33 | HangQuick = 303, -- 快速挂机 |
34 | 34 | HangBattle = 304, -- 挂机战斗 - id |
35 | 35 | HangGetGold = 305, -- 挂机获得齿轮 - count |
36 | - BonusPass = 306, -- 奖励副本通关 - id | |
36 | + BonusPass = 306, -- 奖励副本通关 - id count | |
37 | 37 | |
38 | 38 | -- 冒险相关 |
39 | 39 | AdvPass = 401, -- 冒险通过关 - id level score |
... | ... | @@ -142,7 +142,7 @@ local CommonListener = { |
142 | 142 | [TaskType.GiveFriendP] = {{20, f("count")}}, |
143 | 143 | [TaskType.UnionBoss] = {{21}}, |
144 | 144 | [TaskType.GetFriendP] = {{22, f("count")}}, |
145 | - [TaskType.BonusPass] = {{23}}, | |
145 | + [TaskType.BonusPass] = {{23, f("count")}}, | |
146 | 146 | [TaskType.AdvStartSelf] = {{24}}, |
147 | 147 | [TaskType.ShopAll] = {{25, f("count")}}, |
148 | 148 | [TaskType.RuneUp] = {{26}}, |
... | ... | @@ -235,6 +235,8 @@ local StoreListener = { |
235 | 235 | [TaskType.HangPass] = {{TriggerEventType.HangPass, f("id")}}, |
236 | 236 | [TaskType.RoleLevelUp] = {{TriggerEventType.LevelUp, f("level")}}, |
237 | 237 | [TaskType.TowerPass] = {{TriggerEventType.TowerPass, f("level")}}, |
238 | + [TaskType.AdvPass] = {{TriggerEventType.AdvPass, f("id")}}, | |
239 | + [TaskType.AddHero] = {{TriggerEventType.AddNewHero, f("heroType")}, {TriggerEventType.SSRCount, f("ssrCount")}}, | |
238 | 240 | } |
239 | 241 | } |
240 | 242 | |
... | ... | @@ -242,8 +244,8 @@ local CalendaTaskListener = { |
242 | 244 | func = "checkCalendaTask", |
243 | 245 | listen = { |
244 | 246 | [TaskType.DrawHero] = {{1, 1, f("count")}}, |
245 | - [TaskType.BonusPass]= {{2, 1}}, | |
246 | - [TaskType.AdvPass]= {{3, 1}}, | |
247 | + [TaskType.BonusPass]= {{2, 1, f("count")}}, | |
248 | + [TaskType.AdvStart]= {{3, 1}}, | |
247 | 249 | [TaskType.DinerLevelUp]= {{4, 2, f("level")}}, |
248 | 250 | [TaskType.HeroLvlCollect]= {{5, 3}}, -- x名y级英雄 |
249 | 251 | [TaskType.AdvHang]= {{6, 1}}, ---- |
... | ... | @@ -255,11 +257,11 @@ local CalendaTaskListener = { |
255 | 257 | [TaskType.RoleLevelUp]= {{12, 2, f("level")}}, |
256 | 258 | [TaskType.TowerPass]= {{13, 2, f("level")}}, |
257 | 259 | [TaskType.HeroTalent]= {{14, 1}}, |
258 | - [TaskType.HangPass]= {{15, 2, f("id")}}, | |
260 | + [TaskType.HangPass]= {{15, 3}}, | |
259 | 261 | [TaskType.HeroStarCollect]= {{16, 3}}, |
260 | 262 | [TaskType.FoodSell]= {{17, 1, f("count")}}, |
261 | 263 | [TaskType.HangGet]= {{18, 3, f("reward")}}, |
262 | - [TaskType.RuneQualityCollect]= {{19, 3, f("id")}}, | |
264 | + [TaskType.RuneQualityCollect]= {{19, 3}}, | |
263 | 265 | [TaskType.OpenBox]= {{20, 3, f("count"), f("quality")}}, |
264 | 266 | } |
265 | 267 | } |
... | ... | @@ -272,6 +274,7 @@ local TaskListeners = { |
272 | 274 | SudokuListener, |
273 | 275 | ActivityListener, |
274 | 276 | StoreListener, |
277 | + CalendaTaskListener, | |
275 | 278 | } |
276 | 279 | |
277 | 280 | local RoleTask = {} |
... | ... | @@ -579,14 +582,18 @@ function RoleTask.bind(Role) |
579 | 582 | end |
580 | 583 | |
581 | 584 | function Role:checkActivityTask(notNotify, activityType, ...) |
585 | + if not self.activity then return end | |
582 | 586 | self.activity:checkActivity(notNotify, activityType, ...) |
583 | 587 | end |
584 | 588 | |
585 | 589 | function Role:checkStoreTask(notNotify, triggerType, param) |
590 | + if not self.storeData then return end | |
586 | 591 | self.storeData:OnTriggerLimitTimePack(triggerType, param) |
587 | 592 | end |
588 | 593 | |
589 | 594 | function Role:checkCalendaTask(notNotify, mainType, subType, param1, param2) |
595 | + --print("check calenda taskl", mainType, subType, param1, param2) | |
596 | + if not self.activity then return end | |
590 | 597 | local open, actId = self.activity:isOpen("CalendaTask") |
591 | 598 | local actData = csvdb["activity_ctrlCsv"][actId] |
592 | 599 | if not actData then return end |
... | ... | @@ -606,11 +613,86 @@ function RoleTask.bind(Role) |
606 | 613 | elseif subType == 2 then -- 直接赋值 |
607 | 614 | calTask[id] = param1 |
608 | 615 | elseif subType == 3 then -- 自定义类型 |
616 | + if cfg.type == 7 then -- 英雄品质收集进度 | |
617 | + local count = 0 | |
618 | + for _, hero in pairs(self.heros) do | |
619 | + local unitData = csvdb["unitCsv"][hero:getProperty("type")] | |
620 | + if unitData then | |
621 | + if cfg.condition2 <= unitData.rare then | |
622 | + count = count + 1 | |
623 | + end | |
624 | + end | |
625 | + end | |
626 | + if (calTask[id] or 0) < count then | |
627 | + calTask[id] = count | |
628 | + end | |
629 | + elseif cfg.type == 5 then -- 英雄等级收集进度 | |
630 | + local count = 0 | |
631 | + for _, hero in pairs(self.heros) do | |
632 | + if cfg.condition2 <= hero:getProperty("level") then | |
633 | + count = count + 1 | |
634 | + end | |
635 | + end | |
636 | + if (calTask[id] or 0) < count then | |
637 | + calTask[id] = count | |
638 | + end | |
639 | + elseif cfg.type == 16 then -- 英雄星级收集进度 | |
640 | + local count = 0 | |
641 | + for _, hero in pairs(self.heros) do | |
642 | + if cfg.condition2 <= hero:getProperty("wakeL") then | |
643 | + count = count + 1 | |
644 | + end | |
645 | + end | |
646 | + if (calTask[id] or 0) < count then | |
647 | + calTask[id] = count | |
648 | + end | |
649 | + elseif cfg.type == 18 then -- 挂机累计收获id,y个 | |
650 | + for rid, v in pairs(param1) do | |
651 | + if cfg.condition2 == rid then | |
652 | + calTask[id] = (calTask[id] or 0) + v | |
653 | + end | |
654 | + end | |
655 | + elseif cfg.type == 19 then -- x名英雄装备y品质以上符文套装 | |
656 | + local count = 0 | |
657 | + for _, hero in pairs(self.heros) do | |
658 | + local rcount = 0 | |
659 | + for _,uid in pairs(hero:getRunes()) do | |
660 | + if uid > 0 then | |
661 | + local runeData = self.runeBag[uid] | |
662 | + if runeData then | |
663 | + local csvData = csvdb["runeCsv"][runeData:getProperty("type")][runeData:getProperty("id")] | |
664 | + | |
665 | + if csvData and cfg.condition2 <= csvData.rarity then | |
666 | + rcount = rcount + 1 | |
667 | + end | |
668 | + end | |
669 | + end | |
670 | + end | |
671 | + if rcount == 6 then | |
672 | + count = count + 1 | |
673 | + end | |
674 | + end | |
675 | + calTask[id] = count | |
676 | + elseif cfg.type == 20 then -- 开启x品质时钟箱子 | |
677 | + if cfg.condition2 <= (param2 or 0) then | |
678 | + calTask[id] = (calTask[id] or 0) + param2 | |
679 | + end | |
680 | + elseif cfg.type == 15 then -- 通关关卡 | |
681 | + if (calTask[id] or 0) == 0 then | |
682 | + local hangPass = self:getProperty("hangPass") | |
683 | + local diff = math.floor(cfg.condition2 / 10000) | |
684 | + if (hangPass[diff] or 0) >= cfg.condition1 then | |
685 | + calTask[id] = 1 | |
686 | + end | |
687 | + end | |
688 | + end | |
609 | 689 | end |
610 | 690 | end |
611 | 691 | end |
612 | 692 | end |
613 | 693 | end |
694 | + self:updateProperty({field = "calTask", value = calTask, notNotify = notNotify}) | |
695 | + --dump(calTask) | |
614 | 696 | end |
615 | 697 | |
616 | 698 | end | ... | ... |
src/models/RoleTimeReset.lua
... | ... | @@ -17,6 +17,11 @@ ResetFunc["CrossDay"] = function(self, notify, response, now) |
17 | 17 | self:advRandomSupportEffect(not notify) |
18 | 18 | |
19 | 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 | 26 | response.dTask = {} |
22 | 27 | response.advSup = self:getProperty("advSup") |
... | ... | @@ -24,10 +29,16 @@ ResetFunc["CrossDay"] = function(self, notify, response, now) |
24 | 29 | end |
25 | 30 | |
26 | 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 | 36 | self:setProperties({ |
28 | 37 | wTask = {}, |
29 | 38 | dinerS = {}, |
39 | + advMine = advMine, | |
30 | 40 | }) |
41 | + | |
31 | 42 | response.wTask = {} |
32 | 43 | response.dinerS = {} |
33 | 44 | end |
... | ... | @@ -90,7 +101,7 @@ function Role:updateTimeReset(now, notify) |
90 | 101 | self:setProperties({timeReset = timeReset, ltime = now}) |
91 | 102 | |
92 | 103 | response.timeReset = timeReset |
93 | - response.ltime = ltime | |
104 | + response.ltime = now | |
94 | 105 | |
95 | 106 | if notify then |
96 | 107 | self:notifyUpdateProperties(response) | ... | ... |
src/models/Store.lua
... | ... | @@ -23,16 +23,18 @@ Store.schema = { |
23 | 23 | battleFR = {"string", ""}, -- 免费赛季卡领取记录 |
24 | 24 | battleLR = {"string", ""}, -- 付费赛季卡领取记录 |
25 | 25 | |
26 | - limitTPack = {"table", {}}, -- 限时礼包 {id=expire_ts} | |
26 | + limitTPack = {"table", {}}, -- 限时礼包 {id={expire_ts, trigger_type}} | |
27 | 27 | privCardEx = {"number", 0}, -- 特权卡过期时间戳 |
28 | 28 | getMailT1 = {"number",0}, -- 上次发送月卡福利邮件的时间 |
29 | 29 | getMailT2 = {"number",0}, -- 上次发送超级月卡福利邮件的时间 |
30 | - packTrigger = {"table", {}}, -- 礼包触发记录 {关卡难度1={id, 通关关卡数,升级数,爬塔层数}, ...} | |
30 | + --packTrigger = {"table", {}}, -- 礼包触发记录 {关卡难度1={id, 通关关卡数,升级数,爬塔层数}, ...} | |
31 | 31 | |
32 | 32 | -- 活动商品购买记录 |
33 | 33 | actGoodsFlag = {"table", {}}, -- ActGoodsType 1购买,0未购买 |
34 | 34 | |
35 | 35 | bpInfo = {"table", {}}, -- battle pass 探索指令 1={flag=0 为1表示买了,br=""付费领取记录, fr=""免费领取记录},2,3,4 |
36 | + | |
37 | + totalRR = {"string", ""}, -- 累计充值奖励领取记录 | |
36 | 38 | } |
37 | 39 | |
38 | 40 | function Store:updateProperty(params) |
... | ... | @@ -57,7 +59,7 @@ end |
57 | 59 | function Store:onCrossDay() |
58 | 60 | self:sendMonthCardEmail() |
59 | 61 | self:deleteExpireLimitGoods() |
60 | - self:checkPaySignReward() | |
62 | + --self:checkPaySignReward() | |
61 | 63 | end |
62 | 64 | |
63 | 65 | -- 删除过期商品 |
... | ... | @@ -65,10 +67,11 @@ function Store:deleteExpireLimitGoods() |
65 | 67 | local timeNow = skynet.timex() |
66 | 68 | local limitGoodsList = self:getProperty("limitTPack") |
67 | 69 | for k, v in pairs(limitGoodsList) do |
68 | - if timeNow > v then | |
70 | + if timeNow > v[1] then | |
69 | 71 | limitGoodsList[k] = nil |
70 | 72 | end |
71 | 73 | end |
74 | + self:updateProperty({field = "limitTPack", value = limitGoodsList, notNotify = true}) | |
72 | 75 | end |
73 | 76 | |
74 | 77 | -- 发送月卡邮件 |
... | ... | @@ -162,6 +165,26 @@ function Store:getGearExchangeCoef() |
162 | 165 | return 1 + coef |
163 | 166 | end |
164 | 167 | |
168 | +-- 奖励关卡 特权卡额外数量 | |
169 | +function Store:getBonusExtraFightCount() | |
170 | + if self:isPrivCardExpire() then | |
171 | + return 0 | |
172 | + end | |
173 | + | |
174 | + local cnt = globalCsv.bonus_extra_fight_count or 1 | |
175 | + return cnt | |
176 | +end | |
177 | + | |
178 | +-- 挂机道具掉落系数 特权卡挂机掉落系数 | |
179 | +function Store:getHangDropCoef() | |
180 | + if self:isPrivCardExpire() then | |
181 | + return 1, 1 | |
182 | + end | |
183 | + | |
184 | + return (1 + globalCsv.hang_drop_exp_coef) or 1, (1 + globalCsv.hang_drop_item_coef) or 1 | |
185 | +end | |
186 | + | |
187 | + | |
165 | 188 | -- 购买通行证 |
166 | 189 | function Store:onBuyCard(type, duration, id) |
167 | 190 | local timeNow = skynet.timex() |
... | ... | @@ -203,9 +226,9 @@ end |
203 | 226 | |
204 | 227 | --检测购买是否超过限制数量 |
205 | 228 | function Store:checkRechargeRecord(limit, id) |
206 | - local rechargeRecord = self:getProperty("payR") | |
229 | + local rechargeRecord = self:getProperty("payR") or {} | |
207 | 230 | if limit ~= 0 and limit <= (rechargeRecord[id] or 0) then |
208 | - skynet.error(string.format("recharge id:%d count over limit, user id:%d", id, self.owner:getProperty("id"))) | |
231 | + skynet.error(string.format("[recharge] recharge id:%d count over limit, user id:%d", id, self.owner:getProperty("id"))) | |
209 | 232 | return false |
210 | 233 | end |
211 | 234 | rechargeRecord[id] = (rechargeRecord[id] or 0) + 1 |
... | ... | @@ -292,96 +315,103 @@ end |
292 | 315 | --触发限时礼包 |
293 | 316 | function Store:OnTriggerLimitTimePack(eventType, param) |
294 | 317 | local limitPack = self:getProperty("limitTPack") |
295 | - local payRecord = self:getProperty("payR") | |
318 | + --local payRecord = self:getProperty("payR") | |
296 | 319 | local timeNow = skynet.timex() |
297 | - local find = false | |
320 | + --local find = false | |
298 | 321 | -- 有未过期的限时礼包不再推送 |
299 | - for k, v in pairs(limitPack) do | |
300 | - if v > timeNow and not payRecord[k] then | |
301 | - find = true | |
302 | - break | |
303 | - end | |
304 | - end | |
305 | - if find == true then | |
306 | - return | |
307 | - end | |
308 | - limitPack = {} | |
309 | - local hangPass = self.owner:getProperty("hangPass") | |
310 | - local triggerRecord = self:getProperty("packTrigger") | |
311 | - local result = {} | |
312 | - local maxDiff = 0 | |
322 | + --for k, v in pairs(limitPack) do | |
323 | + -- if v > timeNow and not payRecord[k] then | |
324 | + -- find = true | |
325 | + -- break | |
326 | + -- end | |
327 | + --end | |
328 | + --if find == true then | |
329 | + -- return | |
330 | + --end | |
331 | + --local hangPass = self.owner:getProperty("hangPass") | |
332 | + --local triggerRecord = self:getProperty("packTrigger") | |
333 | + --local result = {} | |
334 | + --local maxDiff = 0 | |
313 | 335 | -- 取满足限时礼包关卡要求的对应数据 |
314 | - for diff, maxCarbonId in pairs(hangPass) do | |
315 | - for id, cfg in pairs(csvdb["shop_packCsv"]) do | |
316 | - local range = cfg.showRange:toArray(true, "=") | |
317 | - local beginRange = range[1] or 0 | |
318 | - local endRange = range[2] or 0 | |
319 | - if maxCarbonId > beginRange and maxCarbonId <= endRange and cfg.type == eventType then | |
320 | - result[diff] = cfg | |
321 | - maxDiff = math.max(maxDiff, diff) | |
322 | - break | |
323 | - end | |
324 | - end | |
325 | - end | |
326 | - local shopGoodsId = 0 | |
327 | - for diff, cfg in pairs(result) do | |
328 | - if diff == maxDiff then | |
329 | - local record = triggerRecord[diff] or {} | |
330 | - if (record[0] or 0) ~= cfg.id and next(record) then | |
331 | - record = {} | |
332 | - end | |
333 | - record[0] = cfg.id | |
334 | - record[eventType] = (record[eventType] or 0) + 1 | |
335 | - if record[eventType] > 0 and record[eventType] % 10 == 0 then | |
336 | - local pool = cfg.packId:toArray(true, "=") | |
337 | - local idx = math.random(1, #pool) | |
338 | - shopGoodsId = pool[idx] | |
339 | - end | |
340 | - triggerRecord[diff] = record | |
336 | + --for diff, maxCarbonId in pairs(hangPass) do | |
337 | + -- for id, cfg in pairs(csvdb["shop_packCsv"]) do | |
338 | + -- local range = cfg.showRange:toArray(true, "=") | |
339 | + -- local beginRange = range[1] or 0 | |
340 | + -- local endRange = range[2] or 0 | |
341 | + -- if maxCarbonId > beginRange and maxCarbonId <= endRange and cfg.type == eventType then | |
342 | + -- result[diff] = cfg | |
343 | + -- maxDiff = math.max(maxDiff, diff) | |
344 | + -- break | |
345 | + -- end | |
346 | + -- end | |
347 | + --end | |
348 | + local config = nil | |
349 | + for id, cfg in pairs(csvdb["shop_packCsv"]) do | |
350 | + if cfg.type == eventType and cfg.condition == param then | |
351 | + config = cfg | |
341 | 352 | end |
342 | 353 | end |
343 | - if shopGoodsId ~= 0 then | |
344 | - local rechargeCfg = csvdb["shop_rechargeCsv"][shopGoodsId] | |
354 | + if config ~= nil then | |
355 | + local rechargeCfg = csvdb["shop_rechargeCsv"][config.packId] | |
345 | 356 | if rechargeCfg then |
346 | - limitPack[rechargeCfg.id] = timeNow + rechargeCfg.time | |
357 | + limitPack[rechargeCfg.id] = {timeNow + rechargeCfg.time, config.id} | |
358 | + self.owner:log("push_gift", { | |
359 | + gift_id = rechargeCfg.id, --礼包ID | |
360 | + gift_name = rechargeCfg.title, --礼包名称 | |
361 | + }) | |
347 | 362 | self:updateProperty({field = "limitTPack", value = limitPack}) |
348 | 363 | end |
349 | 364 | end |
350 | - if next(result) then | |
351 | - self:updateProperty({field = "packTrigger", value = triggerRecord}) | |
352 | - end | |
365 | + --if next(result) then | |
366 | + -- self:updateProperty({field = "packTrigger", value = triggerRecord}) | |
367 | + --end | |
353 | 368 | end |
354 | 369 | |
355 | 370 | function GetActGoodsIndex(goodsType) |
356 | 371 | return ActGoodsType[goodsType] or 0 |
357 | 372 | end |
358 | 373 | |
359 | --- 购买付费签到 按开服时间算奖励 | |
360 | -function Store:onBuyPaySignCard(dur) | |
361 | - local curTs = skynet.timex() | |
374 | +function Store:SetActGoodsFlag(goodsType, flag) | |
362 | 375 | local actGoodsFlag = self:getProperty("actGoodsFlag") or {} |
363 | - local goodsIndex = GetActGoodsIndex("paySignIn") | |
376 | + local goodsIndex = GetActGoodsIndex(goodsType) | |
364 | 377 | if goodsIndex == 0 then |
365 | 378 | print("get act goods index fail :paySignIn") |
366 | 379 | return |
367 | 380 | end |
368 | - actGoodsFlag[goodsIndex] = 1 | |
381 | + actGoodsFlag[goodsIndex] = flag | |
369 | 382 | self:updateProperty({field = "actGoodsFlag", value = actGoodsFlag}) |
370 | - -- 发钱 | |
371 | - local change | |
372 | - local reward, curData = self.owner.activity:getPaySignReward() | |
373 | - if next(reward) then | |
374 | - self.owner.activity:updateActData("PaySignIn", curData) | |
375 | - reward, change = self.owner:award(reward, {log = {desc = "actPaySign"}}) | |
376 | - end | |
377 | - | |
378 | - self.owner:log("activity", { | |
379 | - activity_id = 0, -- 活动ID(或活动指定任务的ID) | |
380 | - activity_type = self.owner.activity.ActivityType.PaySignIn, -- 活动类型,见活动类型枚举表 | |
381 | - activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} | |
382 | - }) | |
383 | +end | |
383 | 384 | |
384 | - SendPacket(actionCodes.Activity_actPaySignRewardNtf, MsgPack.pack(self.owner:packReward(reward, change))) | |
385 | +-- 购买付费签到 按开服时间算奖励 | |
386 | +function Store:onBuyPaySignCard(dur) | |
387 | + local curTs = skynet.timex() | |
388 | + curTs = getServerOpenTs() | |
389 | + | |
390 | + self:SetActGoodsFlag("paySignIn", curTs) | |
391 | + | |
392 | + --local actGoodsFlag = self:getProperty("actGoodsFlag") or {} | |
393 | + --local goodsIndex = GetActGoodsIndex("paySignIn") | |
394 | + --if goodsIndex == 0 then | |
395 | + -- print("get act goods index fail :paySignIn") | |
396 | + -- return | |
397 | + --end | |
398 | + --actGoodsFlag[goodsIndex] = 1 | |
399 | + --self:updateProperty({field = "actGoodsFlag", value = actGoodsFlag}) | |
400 | + -- 发钱 | |
401 | + --local change | |
402 | + --local reward, curData = self.owner.activity:getPaySignReward() | |
403 | + --if next(reward) then | |
404 | + -- self.owner.activity:updateActData("PaySignIn", curData) | |
405 | + -- reward, change = self.owner:award(reward, {log = {desc = "actPaySign"}}) | |
406 | + --end | |
407 | + | |
408 | + --self.owner:log("activity", { | |
409 | + -- activity_id = 0, -- 活动ID(或活动指定任务的ID) | |
410 | + -- activity_type = self.owner.activity.ActivityType.PaySignIn, -- 活动类型,见活动类型枚举表 | |
411 | + -- activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} | |
412 | + --}) | |
413 | + | |
414 | + --SendPacket(actionCodes.Activity_actPaySignRewardNtf, MsgPack.pack(self.owner:packReward(reward, change))) | |
385 | 415 | end |
386 | 416 | |
387 | 417 | function Store:checkPaySignReward() |
... | ... | @@ -392,7 +422,35 @@ function Store:checkPaySignReward() |
392 | 422 | end |
393 | 423 | end |
394 | 424 | |
425 | +-- 临时用 登录触发限时礼包 时间点以后 | |
426 | +function Store:OnTriggerLimitTimePackAfterTs(eventType, param) | |
427 | + local limitPack = self:getProperty("limitTPack") | |
428 | + local timeNow = skynet.timex() | |
429 | + local config = nil | |
430 | + for id, cfg in pairs(csvdb["shop_packCsv"]) do | |
431 | + local ts = toUnixtime(""..cfg.condition) | |
432 | + if cfg.type == eventType and ts < param then | |
433 | + config = cfg | |
434 | + | |
435 | + if config ~= nil then | |
436 | + local rechargeCfg = csvdb["shop_rechargeCsv"][config.packId] | |
437 | + if rechargeCfg then | |
438 | + if not limitPack[rechargeCfg.id] then | |
439 | + limitPack[rechargeCfg.id] = {timeNow + rechargeCfg.time, config.id} | |
440 | + self.owner:log("push_gift", { | |
441 | + gift_id = rechargeCfg.id, --礼包ID | |
442 | + gift_name = rechargeCfg.title, --礼包名称 | |
443 | + }) | |
444 | + self:updateProperty({field = "limitTPack", value = limitPack, notNotify = false}) | |
445 | + end | |
446 | + end | |
447 | + end | |
448 | + end | |
449 | + end | |
450 | +end | |
451 | + | |
395 | 452 | function Store:data() |
453 | + self:OnTriggerLimitTimePackAfterTs(TriggerEventType.AfterTs, skynet.timex()) | |
396 | 454 | return { |
397 | 455 | buyR = self:getProperty("buyR"), |
398 | 456 | payR = self:getProperty("payR"), |
... | ... | @@ -405,9 +463,10 @@ function Store:data() |
405 | 463 | battleLR = self:getProperty("battleLR"), |
406 | 464 | limitTPack = self:getProperty("limitTPack"), |
407 | 465 | privCardEx = self:getProperty("privCardEx"), |
408 | - packTrigger = self:getProperty("packTrigger"), | |
466 | + --packTrigger = self:getProperty("packTrigger"), | |
409 | 467 | actGoodsFlag = self:getProperty("actGoodsFlag"), |
410 | 468 | bpInfo = self:getProperty("bpInfo"), |
469 | + totalRR = self:getProperty("totalRR"), | |
411 | 470 | } |
412 | 471 | end |
413 | 472 | ... | ... |
src/services/agent_ctrl.lua
... | ... | @@ -5,6 +5,7 @@ local netpack = require "skynet.netpack" |
5 | 5 | local xxtea = require "xxtea" |
6 | 6 | local deque = require "deque" |
7 | 7 | local datacenter = require "skynet.datacenter" |
8 | +local agent_queued = require "services.agent_queued" | |
8 | 9 | |
9 | 10 | local pcall = pcall |
10 | 11 | local string_format = string.format |
... | ... | @@ -58,10 +59,15 @@ function _M:exit_agent(fd) |
58 | 59 | local agent = get_a(pack) |
59 | 60 | |
60 | 61 | pcall(skynet.send, agent, "lua", "exit") |
61 | - pcall(skynet.send, poold, "lua", "feed") | |
62 | 62 | |
63 | 63 | self.f2u[fd] = nil |
64 | 64 | self.u2f[uid] = nil |
65 | + local nuid, nfd = agent_queued.pop() | |
66 | + if not nuid then | |
67 | + pcall(skynet.send, poold, "lua", "feed") | |
68 | + else | |
69 | + self:query_agent(nfd, nuid, true) | |
70 | + end | |
65 | 71 | end |
66 | 72 | |
67 | 73 | -- @desc: 客户端连入 |
... | ... | @@ -73,7 +79,11 @@ end |
73 | 79 | function _M:socket_close(fd) |
74 | 80 | self.f2i[fd] = nil |
75 | 81 | local uid = self.f2u[fd] |
76 | - if not uid then return end | |
82 | + if not uid then | |
83 | + -- 排队中? | |
84 | + agent_queued.socket_close(fd) | |
85 | + return | |
86 | + end | |
77 | 87 | self.f2e[fd] = skynet.timex() + AGENT_EXPIRE_TIME |
78 | 88 | |
79 | 89 | if not self.u2f[uid] then |
... | ... | @@ -89,7 +99,11 @@ end |
89 | 99 | function _M:socket_error(fd) |
90 | 100 | self.f2i[fd] = nil |
91 | 101 | local uid = self.f2u[fd] |
92 | - if not uid then return end | |
102 | + if not uid then | |
103 | + -- 排队中? | |
104 | + agent_queued.socket_close(fd) | |
105 | + return | |
106 | + end | |
93 | 107 | |
94 | 108 | if not self.u2f[uid] then |
95 | 109 | self.f2u[fd] = nil |
... | ... | @@ -114,6 +128,7 @@ local next_log_time = 0 |
114 | 128 | local CHECK_AGENT_STATUS_INTERVAL = 100 -- 检查agent状态的定时间隔 |
115 | 129 | -- @desc: 检查agent状态,若过期,则让agent退出;并定时打日志统计在线人数 |
116 | 130 | function _M:check_agent_status() |
131 | + agent_queued.handle_timeout() | |
117 | 132 | local now = skynet.timex() |
118 | 133 | if now >= next_check_time then |
119 | 134 | next_check_time = now + CHECK_AGENT_STATUS_INTERVAL |
... | ... | @@ -151,7 +166,7 @@ local function query_agent_response(fd, response) |
151 | 166 | end |
152 | 167 | |
153 | 168 | -- @desc: 玩家登陆第一个包,queryLogin,watchdog为客户端分配一个agent,并告诉gate分配成功,之后的消息直接走agent |
154 | -function _M:query_agent(fd, uid) | |
169 | +function _M:query_agent(fd, uid, isQueue) | |
155 | 170 | local pack = self.u2f[uid] |
156 | 171 | if pack then |
157 | 172 | local f = get_f(pack) |
... | ... | @@ -159,7 +174,6 @@ function _M:query_agent(fd, uid) |
159 | 174 | skynet.error(string.format("%s same fd %d", uid, fd)) |
160 | 175 | return |
161 | 176 | end |
162 | - | |
163 | 177 | -- self.f2u[f] 肯定存在;self.f2e[f]不存在,则说明在线,则需要踢下线 |
164 | 178 | if not self.f2e[f] then |
165 | 179 | local head = string.pack("H", actionCodes.Sys_maintainNotice) |
... | ... | @@ -182,12 +196,29 @@ function _M:query_agent(fd, uid) |
182 | 196 | self.f2u[f] = nil |
183 | 197 | self.u2f[uid] = set_pack(fd, agent) |
184 | 198 | else |
185 | - -- 该uid未存储,则说明至少超过10分钟未登陆,由agent池服务pop出一个agent | |
186 | - local agent = self.factory:pop() | |
187 | - if not agent then | |
188 | - -- 服务器满 | |
189 | - query_agent_response(fd, {ret = "RET_SERVER_FULL"}) | |
190 | - return | |
199 | + local agent | |
200 | + if isQueue then | |
201 | + agent = self.factory:pop() | |
202 | + if agent then | |
203 | + pcall(skynet.send, poold, "lua", "feed") | |
204 | + else | |
205 | + agent = skynet.newservice("agent") | |
206 | + end | |
207 | + else | |
208 | + -- 该uid未存储,则说明至少超过10分钟未登陆,由agent池服务pop出一个agent | |
209 | + if agent_queued.count() > 0 then | |
210 | + -- 服务器满 开始排队 | |
211 | + local rank = agent_queued.push(uid, fd) | |
212 | + query_agent_response(fd, {ret = "RET_SERVER_FULL", rank = rank}) | |
213 | + return | |
214 | + end | |
215 | + | |
216 | + agent = self.factory:pop() | |
217 | + if not agent then | |
218 | + local rank = agent_queued.push(uid, fd) | |
219 | + query_agent_response(fd, {ret = "RET_SERVER_FULL", rank = rank}) | |
220 | + return | |
221 | + end | |
191 | 222 | end |
192 | 223 | |
193 | 224 | local ok = pcall(skynet.call, agent, "lua", "start", gate_serv, fd, self.f2i[fd], hotfixList) | ... | ... |
... | ... | @@ -0,0 +1,154 @@ |
1 | +-- 排队系统 | |
2 | + | |
3 | +require "ProtocolCode" | |
4 | +require "shared.init" | |
5 | +require "utils.init" | |
6 | +require "GlobalVar" | |
7 | +require "RedisKeys" | |
8 | +require "skynet.manager" | |
9 | + | |
10 | +local queue = require "skynet.queue" | |
11 | +local netpack = require "skynet.netpack" | |
12 | +local socket = require "skynet.socket" | |
13 | +local xxtea = require "xxtea" | |
14 | + | |
15 | +skynet = require "skynet" | |
16 | + | |
17 | +local MAX_COUNT = tonumber(skynet.getenv("max_queue")) | |
18 | +-- 心跳定时间隔 | |
19 | +local HEART_TIMER_INTERVAL = 30 | |
20 | +local HEART_TIMEOUT_COUNT_MAX = 3 | |
21 | + | |
22 | +local CMD = {} | |
23 | +local f2u = {} | |
24 | +local u2i = {} -- {idx, fd, {lastHeart, timeOutCount, nextCheck}} | |
25 | +local idx2u = {} | |
26 | +local curIdx = 0 -- 下一个即将进入游戏的玩家索引 | |
27 | +local nextIdx = 0 -- 新加的位置 | |
28 | + | |
29 | + | |
30 | +local function getRank(uid) | |
31 | + local info = u2i[uid] | |
32 | + if not info then return -1 end | |
33 | + return (info[1] + MAX_COUNT - curIdx) % MAX_COUNT + 1 | |
34 | +end | |
35 | + | |
36 | + | |
37 | +function SendPacket(actionCode, bin, client_fd) | |
38 | + if #bin > 0 then bin = xxtea.encrypt(bin, XXTEA_KEY) end | |
39 | + local head = string.pack("H", actionCode) | |
40 | + return socket.write(client_fd, netpack.pack(head .. bin)) | |
41 | +end | |
42 | + | |
43 | +local function checkQueue(fd) | |
44 | + if not f2u[fd] then return end | |
45 | + local info = u2i[f2u[fd]] | |
46 | + if info then | |
47 | + info[3][1] = skynet.timex() | |
48 | + end | |
49 | + local rank = getRank(f2u[fd]) | |
50 | + SendPacket(actionCodes.Sys_checkQueue, MsgPack.pack({rank = rank}), fd) | |
51 | +end | |
52 | + | |
53 | + | |
54 | +skynet.register_protocol { | |
55 | + name = "client", | |
56 | + id = skynet.PTYPE_CLIENT, | |
57 | + unpack = function (msg, sz) | |
58 | + local data = skynet.tostring(msg, sz) | |
59 | + local cmd = string.unpack("H", string.sub(data, 1, 2)) | |
60 | + return cmd, string.sub(data, 3) | |
61 | + end, | |
62 | + dispatch = function(session, address, cmd, data) | |
63 | + skynet.ignoreret() | |
64 | + if cmd == actionCodes.Sys_checkQueue then | |
65 | + checkQueue(session) | |
66 | + end | |
67 | + end | |
68 | +} | |
69 | + | |
70 | +function CMD.push(uid, fd) | |
71 | + uid = tostring(uid) | |
72 | + if u2i[uid] then -- 存在] | |
73 | + local oldfd = u2i[uid][2] | |
74 | + if oldfd and oldfd ~= fd then | |
75 | + -- 踢掉老的 | |
76 | + SendPacket(actionCodes.Sys_maintainNotice, MsgPack.pack({body = "server_accountOccupied", iskey = true}), oldfd) | |
77 | + skynet.timeout(10, function () | |
78 | + skynet.call(gate_serv, "lua", "kick", oldfd) | |
79 | + end) | |
80 | + f2u[oldfd] = nil | |
81 | + end | |
82 | + u2i[uid][2] = fd | |
83 | + f2u[fd] = uid | |
84 | + u2i[uid][3] = {skynet.timex(), 0, skynet.timex() + HEART_TIMER_INTERVAL} | |
85 | + else -- 新排队的用户 | |
86 | + if nextIdx == curIdx and next(idx2u) then -- 满了 | |
87 | + return | |
88 | + end | |
89 | + u2i[uid] = {nextIdx, fd, {skynet.timex(), 0, skynet.timex() + HEART_TIMER_INTERVAL}} | |
90 | + f2u[fd] = uid | |
91 | + idx2u[nextIdx] = uid | |
92 | + nextIdx = (nextIdx + 1) % MAX_COUNT | |
93 | + end | |
94 | + skynet.call(gate_serv, "lua", "forward", fd, 0, skynet.self()) | |
95 | + | |
96 | + return getRank(uid) | |
97 | +end | |
98 | + | |
99 | +function CMD.pop() | |
100 | + while true do | |
101 | + local uid = idx2u[curIdx] | |
102 | + if not uid then return end -- 空的 | |
103 | + local info = u2i[uid] | |
104 | + if not info then | |
105 | + idx2u[curIdx] = nil | |
106 | + else | |
107 | + if info[2] then | |
108 | + -- 找到合适的了 | |
109 | + u2i[uid] = nil | |
110 | + idx2u[curIdx] = nil | |
111 | + f2u[info[2]] = nil | |
112 | + | |
113 | + curIdx = (curIdx + 1) % MAX_COUNT | |
114 | + return uid, info[2] | |
115 | + else | |
116 | + idx2u[curIdx] = nil | |
117 | + u2i[uid] = nil | |
118 | + end | |
119 | + end | |
120 | + curIdx = (curIdx + 1) % MAX_COUNT | |
121 | + end | |
122 | +end | |
123 | + | |
124 | + | |
125 | +-- 下线了 | |
126 | +function CMD.socket_close(fd) | |
127 | + local uid = f2u[fd] | |
128 | + if not uid then return end | |
129 | + f2u[fd] = nil | |
130 | + local info = u2i[uid] | |
131 | + info[2] = nil | |
132 | +end | |
133 | + | |
134 | +function CMD.handle_timeout() | |
135 | + local now = skynet.timex() | |
136 | + for uid, info in pairs(u2i) do | |
137 | + if info[2] and info[3] and now >= info[3][3] then --存在fd 检查心跳 | |
138 | + if info[3][1] - now > HEART_TIMER_INTERVAL or now - info[3][1] > HEART_TIMER_INTERVAL then | |
139 | + info[3][2] = info[3][2] + 1 | |
140 | + info[3][3] = now + HEART_TIMER_INTERVAL | |
141 | + if info[3][2] >= HEART_TIMEOUT_COUNT_MAX then | |
142 | + skynet.error("timeout! then queued will closed", info[2], uid) | |
143 | + skynet.call(gate_serv, "lua", "kick", info[2]) | |
144 | + end | |
145 | + end | |
146 | + end | |
147 | + end | |
148 | +end | |
149 | + | |
150 | +function CMD.count() | |
151 | + return (nextIdx + MAX_COUNT - curIdx) % MAX_COUNT | |
152 | +end | |
153 | + | |
154 | +return CMD | ... | ... |
src/services/agent_util.lua
... | ... | @@ -17,15 +17,32 @@ local HEART_TIMEOUT_COUNT_MAX = 20 |
17 | 17 | local HEART_QUICK_COUNT_MAX = 5 |
18 | 18 | -- 心跳定时间隔 |
19 | 19 | local HEART_TIMER_INTERVAL = 5 |
20 | +-- 忽略心跳的等待时间 | |
21 | +local WAIT_IGNORE_HEART = 300 | |
22 | + | |
23 | +--开始忽略心跳的时间 | |
24 | +local ignoreHeartTime = nil | |
20 | 25 | |
21 | 26 | local function check_heart_beat(agent, now) |
22 | 27 | -- 充值等操作不检查心跳 |
23 | 28 | local role = agent.role |
24 | - if role.ignoreHeartbeat then | |
29 | + if not role or role.ignoreHeartbeat then | |
25 | 30 | lastHeartCheckTime = now - HEART_TIMER_INTERVAL |
26 | 31 | heartTimeoutCount = 0 |
32 | + | |
33 | + if not ignoreHeartTime then | |
34 | + ignoreHeartTime = now | |
35 | + end | |
36 | + | |
37 | + if now - ignoreHeartTime >= WAIT_IGNORE_HEART then -- 等待太久了 踢掉 | |
38 | + skynet.error("timeout! then agent will shut down by self with ignoreHeartbeat or no login", agent.client_fd) | |
39 | + skynet.call(agent.gate_serv, "lua", "kick", agent.client_fd) | |
40 | + ignoreHeartTime = nil | |
41 | + end | |
27 | 42 | return |
28 | 43 | end |
44 | + ignoreHeartTime = nil | |
45 | + | |
29 | 46 | if lastHeartCheckTime - now > HEART_TIMER_INTERVAL or |
30 | 47 | now - lastHeartCheckTime > HEART_TIMER_INTERVAL then |
31 | 48 | heartTimeoutCount = heartTimeoutCount + 1 |
... | ... | @@ -46,6 +63,7 @@ function _M:update(agent) |
46 | 63 | pcall(check_heart_beat, agent, now) |
47 | 64 | nextCheckTime = now + HEART_TIMER_INTERVAL |
48 | 65 | end |
66 | + if not role then return end | |
49 | 67 | pcall(role.onRecoverTimer, role, now) |
50 | 68 | end |
51 | 69 | |
... | ... | @@ -73,6 +91,7 @@ end |
73 | 91 | function _M:reset() |
74 | 92 | heartTimeoutCount = 0 |
75 | 93 | heartQuickCount = 0 |
94 | + ignoreHeartTime = nil | |
76 | 95 | lastHeartCheckTime = skynet.timex() |
77 | 96 | end |
78 | 97 | ... | ... |
src/services/poold.lua
... | ... | @@ -7,14 +7,15 @@ local deque = require "deque" |
7 | 7 | local CMD = {} |
8 | 8 | local factory |
9 | 9 | |
10 | +local PRE_FEED_COUNT = 5 | |
10 | 11 | local dead = 0 |
11 | 12 | -- agent死亡,通知poold补充,当累计到5个agent时,马上生成5个agent放入poold中 |
12 | 13 | -- 当然这里也可以写得更复杂,参考redis落地规则 |
13 | 14 | function CMD.feed() |
14 | 15 | dead = dead + 1 |
15 | - if dead == 5 then | |
16 | + if dead == PRE_FEED_COUNT then | |
16 | 17 | dead = 0 |
17 | - for i=1, 5 do | |
18 | + for i=1, PRE_FEED_COUNT do | |
18 | 19 | factory:push(skynet.newservice("agent")) |
19 | 20 | end |
20 | 21 | end | ... | ... |
src/utils/CommonFunc.lua
... | ... | @@ -161,6 +161,18 @@ function diffFromOpen() |
161 | 161 | return math.floor((now - openTime) / DAY_SEC) |
162 | 162 | end |
163 | 163 | |
164 | +function diffFromTs(ts) | |
165 | + local now = skynet.timex() | |
166 | + local tm = os.date("*t", ts) | |
167 | + | |
168 | + local time = os.time({year = tm.year, month = tm.month, day = tm.day, hour = RESET_TIME}) | |
169 | + if now < time then | |
170 | + return 0 | |
171 | + end | |
172 | + | |
173 | + return math.floor((now - time) / DAY_SEC) | |
174 | +end | |
175 | + | |
164 | 176 | function getServerOpenTs() |
165 | 177 | local openTime = os.time{ |
166 | 178 | year = tonum(SERV_OPEN:sub(1,4)), |
... | ... | @@ -298,7 +310,7 @@ function notifyClient(params) |
298 | 310 | params.key = "zhaolugame20170831" |
299 | 311 | |
300 | 312 | local status, body = httpc.get(skynet.getenv("codeurl"), |
301 | - "/mipush/notify_user?" .. httpGetFormatData(params), {}, {}) | |
313 | + "/push/notify_user?" .. httpGetFormatData(params), {}, {}) | |
302 | 314 | if tonumber(status) ~= 200 then |
303 | 315 | skynet.error(status, body) |
304 | 316 | return |
... | ... | @@ -313,7 +325,7 @@ function deleteNotify(params) |
313 | 325 | params.key = "zhaolugame20170831" |
314 | 326 | |
315 | 327 | local status, body = httpc.get(skynet.getenv("codeurl"), |
316 | - "/mipush/delete_notify?" .. httpGetFormatData(params), {}, {}) | |
328 | + "/push/delete_notify?" .. httpGetFormatData(params), {}, {}) | |
317 | 329 | if tonumber(status) ~= 200 then |
318 | 330 | skynet.error(status, body) |
319 | 331 | return | ... | ... |
src/utils/StringUtil.lua
... | ... | @@ -347,4 +347,20 @@ function string.toMap(str, tonum, sep) |
347 | 347 | end |
348 | 348 | end |
349 | 349 | return tab |
350 | +end | |
351 | + | |
352 | +--[[ | |
353 | +from: 1=2=3=4 | |
354 | +to: {1,2,3,4} | |
355 | +]] | |
356 | +function string.toMap(str, tonum, sep) | |
357 | + local str_vec = string.split(str, " ") | |
358 | + local tab = {} | |
359 | + for _, v in pairs(str_vec) do | |
360 | + local vec = string.split(v, sep) | |
361 | + if #vec == 2 then | |
362 | + tab[vec[1]] = tonum and tonumber(vec[2]) or vec[2] | |
363 | + end | |
364 | + end | |
365 | + return tab | |
350 | 366 | end |
351 | 367 | \ No newline at end of file | ... | ... |