0a07bdd9
zhouahaihai
角色升级 。gm
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
local ipairs = ipairs
local table = table
local math = math
local next = next
local string = string
local redisproxy = redisproxy
local MsgPack = MsgPack
local getRandomName = getRandomName
local mcast_util = mcast_util
local string_format = string.format
local tonumber = tonumber
local require = require
local table_insert = table.insert
local tconcat = table.concat
|
be9c9ca6
zhouahaihai
角色评论
|
15
|
local table_unpack = table.unpack
|
0a07bdd9
zhouahaihai
角色升级 。gm
|
16
17
|
local _M = {}
|
058a0cbb
zhouhaihai
抽卡
|
18
|
|
c59e058b
zhouhaihai
新一批日志记录
|
19
20
21
22
23
24
25
26
27
|
local function getChangeAttrJson(oldAttr, newAttr)
local change = {}
for k, v in pairs(newAttr) do
change[k] = v - oldAttr[k]
change[k] = math.ceil(change[k])
if change[k] == 0 then
change[k] = nil
end
end
|
887c1843
zhouhaihai
日志新一批
|
28
|
return change
|
c59e058b
zhouhaihai
新一批日志记录
|
29
30
|
end
|
0a07bdd9
zhouahaihai
角色升级 。gm
|
31
32
33
|
function _M.levelUpRpc( agent, data )
local role = agent.role
local msg = MsgPack.unpack(data)
|
36482c8b
zhouhaihai
回收养成
|
34
|
|
0a07bdd9
zhouahaihai
角色升级 。gm
|
35
|
local hero = role.heros[msg.id]
|
1c35c4cf
gaofengduan
fix hero awake
|
36
|
if not hero then return 1 end
|
0a07bdd9
zhouahaihai
角色升级 。gm
|
37
|
|
1c35c4cf
gaofengduan
fix hero awake
|
38
|
if hero:getProperty("level") >= hero:getMaxLevel() then return 2 end
|
8c74292c
zhouahaihai
增加item 以及 角色突破
|
39
|
local curData = csvdb["unit_expCsv"][hero:getProperty("level")]
|
997cbdfe
zhouahaihai
技能养成
|
40
|
local cost = {[ItemId.Exp] = curData.exp, [ItemId.Gold] = curData.gold}
|
1c35c4cf
gaofengduan
fix hero awake
|
41
|
if not role:checkItemEnough(cost) then return 3 end
|
3133cb76
zhouhaihai
日志
|
42
|
role:costItems(cost, {log = {desc = "heroLevelUp", int1 = msg.id, int2 = hero:getProperty("type")}})
|
c59e058b
zhouhaihai
新一批日志记录
|
43
44
45
|
local oldAttr = hero:getTotalAttrs()
local oldBattleV = hero:getProperty("battleV")
|
0a07bdd9
zhouahaihai
角色升级 。gm
|
46
|
hero:updateProperty({field = "level", delta = 1})
|
1c35c4cf
gaofengduan
fix hero awake
|
47
|
|
c59e058b
zhouhaihai
新一批日志记录
|
48
49
|
role:log("hero_upgrade", {
hero_id = hero:getProperty("type"), --英雄ID
|
887c1843
zhouhaihai
日志新一批
|
50
|
hero_upgrade_cost = cost, -- 英雄升级消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...}
|
c59e058b
zhouhaihai
新一批日志记录
|
51
52
53
54
55
|
hero_upgrade_result = getChangeAttrJson(oldAttr, hero:getTotalAttrs()), -- 英雄升级效果,可记录效果ID,或json格式记录提升效果,{攻击:20,闪避:20,……..}
hero_upgrade_type = 0, -- 英雄升级方式,连续升级:1,单击升级:0
hero_upgrade_score = hero:getProperty("battleV"), -- 英雄升级后评分
hero_upgrade_scoreget = hero:getProperty("battleV") - oldBattleV, -- 通过英雄升级提升的评分
})
|
3133cb76
zhouhaihai
日志
|
56
|
|
f22a33af
zhouhaihai
自己的日志
|
57
|
hero:mylog({desc = "levelUp", int1 = hero:getProperty("level")})
|
1e9cb217
chenyueqi
服务器记录控制引导过程
|
58
|
|
53e8037e
zhouhaihai
任务
|
59
|
role:checkTaskEnter("HeroLevelUp", {level = hero:getProperty("level")})
|
190e1415
liuzujun
英雄帖活动初始化
|
60
61
|
role:checkTaskEnter("HeroLvlCollect", {})
|
0a07bdd9
zhouahaihai
角色升级 。gm
|
62
63
64
65
|
SendPacket(actionCodes.Hero_levelUpRpc, '')
return true
end
|
8c74292c
zhouahaihai
增加item 以及 角色突破
|
66
67
68
69
|
function _M.breakRpc( agent, data )
local role = agent.role
local msg = MsgPack.unpack(data)
local hero = role.heros[msg.id]
|
1c35c4cf
gaofengduan
fix hero awake
|
70
|
if not hero then return 1 end
|
8c74292c
zhouahaihai
增加item 以及 角色突破
|
71
|
|
1c35c4cf
gaofengduan
fix hero awake
|
72
73
|
if hero:getProperty("level") < hero:getMaxLevel() then return 2 end
if hero:getProperty("breakL") >= #csvdb["unit_breakCsv"] then return 3 end
|
8c74292c
zhouahaihai
增加item 以及 角色突破
|
74
|
local curData = csvdb["unit_breakCsv"][hero:getProperty("breakL")]
|
997cbdfe
zhouahaihai
技能养成
|
75
|
local cost = {[ItemId.BreakCost] = curData.cost, [ItemId.Gold] = curData.gold}
|
1c35c4cf
gaofengduan
fix hero awake
|
76
|
if not role:checkItemEnough(cost) then return 4 end
|
3133cb76
zhouhaihai
日志
|
77
|
role:costItems(cost, {log = {desc = "heroBreak", int1 = msg.id, int2 = hero:getProperty("type")}})
|
c59e058b
zhouhaihai
新一批日志记录
|
78
|
local oldAttr = hero:getTotalAttrs()
|
8c74292c
zhouahaihai
增加item 以及 角色突破
|
79
|
hero:updateProperty({field = "breakL", delta = 1})
|
1c35c4cf
gaofengduan
fix hero awake
|
80
|
|
c59e058b
zhouhaihai
新一批日志记录
|
81
82
|
role:log("hero_break", {
hero_id = hero:getProperty("type"), --英雄ID
|
887c1843
zhouhaihai
日志新一批
|
83
|
hero_break_cost = cost, -- 英雄突破消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...}
|
c59e058b
zhouhaihai
新一批日志记录
|
84
85
86
|
hero_break_result = getChangeAttrJson(oldAttr, hero:getTotalAttrs()), -- 英雄突破效果,可记录效果ID,或json格式记录提升效果,{攻击:20,闪避:20,……..}
hero_break_level = hero:getMaxLevel(), -- 英雄突破后等级上限
})
|
f22a33af
zhouhaihai
自己的日志
|
87
|
hero:mylog({desc = "break", int1 = hero:getProperty("breakL")})
|
3133cb76
zhouhaihai
日志
|
88
|
|
8c74292c
zhouahaihai
增加item 以及 角色突破
|
89
90
91
|
SendPacket(actionCodes.Hero_breakRpc, '')
return true
end
|
0a07bdd9
zhouahaihai
角色升级 。gm
|
92
|
|
997cbdfe
zhouahaihai
技能养成
|
93
94
95
96
|
function _M.wakeRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
local hero = role.heros[msg.id]
|
1c35c4cf
gaofengduan
fix hero awake
|
97
98
99
100
101
|
if not hero then return 1 end
if hero:getProperty("wakeL") >= #csvdb["unit_wakeCsv"] then return 2 end
local typ = hero:getProperty("type")
local wakeData = csvdb["unit_wakeCsv"][hero:getProperty("wakeL")]
if not wakeData then return 3 end
|
15cba0bf
zhouhaihai
修改天赋升级消耗
|
102
103
|
local costMaterial = wakeData.costMaterial:toArray(true,"=")
local cost = {[typ] = wakeData.costFigment,[globalCsv.unit_wake_cost[hero:getCamp()][costMaterial[1]]] = costMaterial[2]}
|
1c35c4cf
gaofengduan
fix hero awake
|
104
105
|
if not role:checkItemEnough(cost) then
return 4
|
997cbdfe
zhouahaihai
技能养成
|
106
|
end
|
1c35c4cf
gaofengduan
fix hero awake
|
107
|
|
3133cb76
zhouhaihai
日志
|
108
|
role:costItems(cost, {log = {desc = "heroWake", int1 = msg.id, int2 = hero:getProperty("type")}})
|
0889982f
zhouhaihai
优化角色技能等级
|
109
|
|
c59e058b
zhouhaihai
新一批日志记录
|
110
|
local oldAttr = hero:getTotalAttrs()
|
43293781
zhouhaihai
日志bug
|
111
|
local oldBattleV = hero:getProperty("battleV")
|
997cbdfe
zhouahaihai
技能养成
|
112
113
|
hero:updateProperty({field = "wakeL", delta = 1})
|
53e8037e
zhouhaihai
任务
|
114
|
local curLevel = hero:getProperty("wakeL")
|
f6a9215f
zhouhaihai
觉醒 误删了 任务
|
115
|
role:checkTaskEnter("Wake", {heroType = typ, wakeL = curLevel})
|
bcbb0c7b
zhouhaihai
3星解锁 cg
|
116
|
if curLevel == 3 then -- 解锁cg
|
53e8037e
zhouhaihai
任务
|
117
118
|
role:checkTaskEnter("WakeCG", {heroType = typ})
end
|
f22a33af
zhouhaihai
自己的日志
|
119
|
hero:mylog({desc = "wake", int1 = hero:getProperty("wakeL")})
|
3133cb76
zhouhaihai
日志
|
120
|
|
c59e058b
zhouhaihai
新一批日志记录
|
121
122
|
role:log("hero_rise", {
hero_id = typ, --英雄ID
|
887c1843
zhouhaihai
日志新一批
|
123
|
hero_rise_cost = cost, --英雄觉醒消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...}
|
c59e058b
zhouhaihai
新一批日志记录
|
124
|
hero_rise_score = hero:getProperty("battleV"), --英雄觉醒后评分提升
|
43293781
zhouhaihai
日志bug
|
125
|
hero_rise_scoreget = hero:getProperty("battleV") - oldBattleV, --英雄觉醒后评分提升
|
c59e058b
zhouhaihai
新一批日志记录
|
126
127
128
|
hero_rise_result = getChangeAttrJson(oldAttr, hero:getTotalAttrs()), --英雄觉醒效果,可记录效果ID,或json格式记录提升效果,{攻击:20,闪避:20,……..}
})
|
a5b98c30
chenyueqi
引导调整
|
129
130
131
132
|
if hero:getProperty("type") == 204 then
role:finishGuide(7)
end
|
997cbdfe
zhouahaihai
技能养成
|
133
|
SendPacket(actionCodes.Hero_wakeRpc, '')
|
190e1415
liuzujun
英雄帖活动初始化
|
134
135
|
role:checkTaskEnter("HeroStarCollect", {})
|
997cbdfe
zhouahaihai
技能养成
|
136
137
138
|
return true
end
|
997cbdfe
zhouahaihai
技能养成
|
139
140
141
142
143
|
function _M.talentRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
local hero = role.heros[msg.id]
|
b57f0bae
gaofengduan
fix hero talent
|
144
|
if not hero then return 1 end
|
997cbdfe
zhouahaihai
技能养成
|
145
146
|
local index = msg.index -- 第几个天赋
|
6fc397d6
zhouhaihai
角色新突破 冒险优化点击地块
|
147
|
local need = {[0] = 1, [1] = 1, [2] = 1, [3] = 1, [4] = 1}
|
b57f0bae
gaofengduan
fix hero talent
|
148
|
if not need[index] then return 2 end
|
997cbdfe
zhouahaihai
技能养成
|
149
|
|
04258e10
zhouhaihai
天赋bug
|
150
|
local talent = hero:getProperty("talent")
|
997cbdfe
zhouahaihai
技能养成
|
151
|
local curStage = talent:getv(0, 1)
|
1c35c4cf
gaofengduan
fix hero awake
|
152
|
local curData = csvdb["unit_talentCsv"][curStage]
|
b57f0bae
gaofengduan
fix hero talent
|
153
|
if not curData then return 4 end
|
c59e058b
zhouhaihai
新一批日志记录
|
154
155
|
local oldSkillLv = hero:getSkillLevel(1)
|
997cbdfe
zhouahaihai
技能养成
|
156
|
|
c59e058b
zhouhaihai
新一批日志记录
|
157
|
local cost = {}
|
6fc397d6
zhouhaihai
角色新突破 冒险优化点击地块
|
158
|
if index == 0 then
|
6fc397d6
zhouhaihai
角色新突破 冒险优化点击地块
|
159
160
|
--是否进阶
local max = true
|
997cbdfe
zhouahaihai
技能养成
|
161
|
for i = 1, 4 do
|
6fc397d6
zhouhaihai
角色新突破 冒险优化点击地块
|
162
163
164
165
|
if talent:getv(i, 0) < #curData then
max = false
break
end
|
997cbdfe
zhouahaihai
技能养成
|
166
|
end
|
6fc397d6
zhouhaihai
角色新突破 冒险优化点击地块
|
167
168
169
170
171
172
|
if max then
talent = talent:setv(0, curStage + 1)
for i = 1, 4 do
talent = talent:setv(i, 0)
end
else
|
cbc6973f
zhouhaihai
天赋bug 日志调整
|
173
|
return 12
|
6fc397d6
zhouhaihai
角色新突破 冒险优化点击地块
|
174
175
176
177
178
179
180
181
182
183
184
|
end
else
local level = talent:getv(index, 0)
if level >= #curData then return 5 end
local talentData = curData[level]
if not talentData then return end
if talentData.lvRequire > hero:getProperty("level") then return 6 end
|
c59e058b
zhouhaihai
新一批日志记录
|
185
|
cost = talentData.money:toNumMap()
|
6fc397d6
zhouhaihai
角色新突破 冒险优化点击地块
|
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
local cost2 = talentData.cost:toNumMap()
for k,v in pairs(cost2) do
cost[globalCsv.unit_talent_cost[csvdb["unitCsv"][hero:getProperty("type")].camp][k]] = v
end
if not role:checkItemEnough(cost) then return 6 end
role:costItems(cost, {log = {desc = "heroTalent", int1 = msg.id, int2 = hero:getProperty("type")}})
talent = talent:incrv(index, 1)
local aheadLevel = 0
for i = 1, talent:getv(0, 1) - 1 do
aheadLevel = aheadLevel + #csvdb["unit_talentCsv"][i]
end
aheadLevel = aheadLevel + talent:getv(index, 0)
role:checkTaskEnter("HeroTalent", {heroType = hero:getProperty("type"), alv = aheadLevel})
|
997cbdfe
zhouahaihai
技能养成
|
202
|
end
|
53e8037e
zhouhaihai
任务
|
203
|
|
6fc397d6
zhouhaihai
角色新突破 冒险优化点击地块
|
204
|
hero:updateProperty({field = "talent", value = talent})
|
53e8037e
zhouhaihai
任务
|
205
|
|
c59e058b
zhouhaihai
新一批日志记录
|
206
207
|
role:log("hero_talent", {
hero_id = hero:getProperty("type"), --英雄ID
|
43293781
zhouhaihai
日志bug
|
208
|
hero_talent_id = index, --天赋ID
|
887c1843
zhouhaihai
日志新一批
|
209
|
hero_talent_cost = cost, -- 英雄天赋升级消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...}
|
c59e058b
zhouhaihai
新一批日志记录
|
210
211
212
|
hero_talent_levelbef = oldSkillLv, -- 英雄技能升级前等级
hero_talent_level = hero:getSkillLevel(1), -- 英雄技能升级后等级
})
|
f22a33af
zhouhaihai
自己的日志
|
213
|
hero:mylog({desc = "talent", int1 = index, int2 = talent:getv(index, 0)})
|
3133cb76
zhouhaihai
日志
|
214
|
|
997cbdfe
zhouahaihai
技能养成
|
215
216
217
218
|
SendPacket(actionCodes.Hero_talentRpc, '')
return true
end
|
6fc397d6
zhouhaihai
角色新突破 冒险优化点击地块
|
219
|
|
be9c9ca6
zhouahaihai
角色评论
|
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
|
-- 暂时没有这个功能
function _M.likeHeroRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
local heroType = msg.type
local result = {status = 0}
local isLike = false
local hadLike = role:getProperty("likeHero"):toArray(true, "=")
for _, v in pairs(hadLike) do
if v == heroType then
isLike = true
break
end
end
if isLike then
result.status = 1
else
redisproxy:hincrby("hero:like", "hero:"..heroType, 1)
table.insert(hadLike, heroType)
role:setProperty("likeHero", table.concat(hadLike, "="))
end
SendPacket(actionCodes.Hero_likeHeroRpc, MsgPack.pack(result))
return true
end
local RankLikeNum = 5 --热度显示几个
local TimeLikeNum = 95 -- 时间显示几个
local function getCommentKey(heroType)
return {
commentListKey = string.format("list:%d:herocomments", heroType),
commentRankKey = string.format("rank:%d:herocomments", heroType),
commentKey = string.format("hero:%d:comments", heroType),
}
end
local function trimComment(heroType, commentId) -- 剪裁 CommentList
local commentKey = getCommentKey(heroType)
local redret = redisproxy:pipelining(function (red)
red:lpush(commentKey.commentListKey, commentId)
red:lrange(commentKey.commentListKey, TimeLikeNum,-1)
red:ltrim(commentKey.commentListKey, 0, TimeLikeNum - 1)
red:zrevrange(commentKey.commentRankKey, 0, RankLikeNum - 1)
end)
local hots = {}
for _, hot in pairs(redret[4]) do
hots[hot] = 1
end
redisproxy:pipelining(function (red)
local needDel = {}
for _, tempId in pairs(redret[2]) do
if not hots[tempId] then
table.insert(needDel, tempId)
end
end
if #needDel > 0 then
red:zrem(commentKey.commentRankKey, table_unpack(needDel))
red:hdel(commentKey.commentKey, table_unpack(needDel))
end
end)
end
function _M.commentHeroRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
local heroType = msg.type
local content = msg.content
local result = {status = 0} -- status 0 成功 1 已经评论过了
local curStutus = role.dailyData:getProperty("commentHero")
if curStutus:getv(heroType, 0) ~= 0 then
result.status = 1
else
local commentKey = getCommentKey(heroType)
|
3c0ea5fb
zhouhaihai
抽英雄
|
294
|
local SERV = string.format(".chated%d", math.random(1, 5))
|
be9c9ca6
zhouahaihai
角色评论
|
295
296
297
298
299
300
|
local legal, mod = skynet.call(SERV, "lua", "check", content)
if not legal then
content = mod or ""
end
local commentId = tostring(redisproxy:hincrby("hero:comment:autoincr", "hero:" .. heroType, 1))
local comment = {
|
1c35c4cf
gaofengduan
fix hero awake
|
301
|
commentId = commentId,
|
be9c9ca6
zhouahaihai
角色评论
|
302
303
304
305
306
307
308
309
310
311
312
|
content = content,
roleId = role:getProperty("id"),
name = role:getProperty("name"),
-- time = skynet.timex()
}
redisproxy:hset(commentKey.commentKey, commentId, json.encode(comment))
trimComment(heroType, commentId)
comment.like = 0
result.comment = comment
role.dailyData:setProperty("commentHero", curStutus:setv(heroType, 1))
|
c59e058b
zhouhaihai
新一批日志记录
|
313
314
315
316
317
318
319
320
|
role:log("hero_note", {
hero_id = heroType, -- 英雄ID
hero_note_action = 0, -- 英雄评价界面操作,发布评论:0,点赞:1,反对:2
hero_note_id = commentId, -- 操作的评价ID
hero_note_text = content, -- 操作的评价内容
})
|
be9c9ca6
zhouahaihai
角色评论
|
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
|
end
SendPacket(actionCodes.Hero_commentHeroRpc, MsgPack.pack(result))
return true
end
function _M.getCommentsRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
local heroType = msg.type
local list = {} -- 评论列表
local commentKey = getCommentKey(heroType)
local commentRoleKey = string.format("comment:%d:like", role:getProperty("id"))
local redret = redisproxy:pipelining(function (red)
red:lrange(commentKey.commentListKey, 0,TimeLikeNum - 1)
red:zrevrange(commentKey.commentRankKey, 0, -1, "WITHSCORES") --热门
red:hget("hero:like", "hero:"..heroType)
red:lrange(commentRoleKey, 0, 999)
end)
local likeMap = {}
local idList = {}
local liked = {}
for i = 1, #redret[2], 2 do
likeMap[redret[2][i]] = redret[2][i + 1]
if i < RankLikeNum * 2 then
table.insert(idList, redret[2][i])
end
end
for i = 1, #redret[1] do
table.insert(idList, redret[1][i])
end
for i = 1, #redret[4] do
liked[redret[4][i]] = 1
end
local commentData = redisproxy:pipelining(function (red)
for _, commentId in ipairs(idList) do
red:hget(commentKey.commentKey, commentId)
end
end)
for _, commentS in ipairs(commentData or {}) do
local comment = json.decode(commentS)
comment.like = likeMap[tostring(comment.commentId)] or 0
comment.liked = liked[heroType .. ":" .. comment.commentId] or 0
table.insert(list, comment)
end
SendPacket(actionCodes.Hero_getCommentsRpc, MsgPack.pack({list = list, like = tonumber(redret[3] or 0)}))
return true
end
function _M.likeCommentRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
local actType = msg.actType -- 1 顶 2 踩
local heroType = msg.type
local commentId = msg.commentId --评论id
local commentKey = getCommentKey(heroType)
local add = 0
if actType == 1 then
add = 1
elseif actType == 2 then
add = -1
else
|
1c35c4cf
gaofengduan
fix hero awake
|
384
|
return
|
be9c9ca6
zhouahaihai
角色评论
|
385
386
|
end
|
1c35c4cf
gaofengduan
fix hero awake
|
387
388
|
local result = {status = 0}
local commentIndex = heroType .. ":" .. commentId
|
be9c9ca6
zhouahaihai
角色评论
|
389
390
|
local commentRoleKey = string.format("comment:%d:like", role:getProperty("id"))
local redret = redisproxy:pipelining(function (red)
|
c59e058b
zhouhaihai
新一批日志记录
|
391
|
red:hget(commentKey.commentKey, commentId)
|
be9c9ca6
zhouahaihai
角色评论
|
392
393
394
395
396
397
398
|
red:lrem(commentRoleKey, 1, commentIndex)
red:lpush(commentRoleKey, commentIndex)
red:ltrim(commentRoleKey, 0, 999)
end)
if (tonumber(redret[2]) or 0) > 0 then
result.status = 1
else
|
c59e058b
zhouhaihai
新一批日志记录
|
399
400
|
if redret[1] then-- 查不到也返回ture
local comment = json.decode(redret[1])
|
be9c9ca6
zhouahaihai
角色评论
|
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
|
local redret2 = redisproxy:pipelining(function (red)
red:zrevrange(commentKey.commentRankKey, 0, RankLikeNum - 1) --热门
red:zincrby(commentKey.commentRankKey, add, commentId)
red:zrevrange(commentKey.commentRankKey, 0, RankLikeNum - 1) --热门
end)
local out = {}
for _, v in pairs(redret2[1]) do
out[v] = 1
end
local new = {}
for _, v in pairs(redret2[3]) do
if out[v] then
out[v] = nil
else
new[v] = 1
end
end
for tempId, _ in pairs(out) do
trimComment(heroType, tempId)
end
redisproxy:pipelining(function (red)
for tempId, _ in pairs(new) do
red:lrem(commentKey.commentListKey, 0, tempId)
end
end)
|
c59e058b
zhouhaihai
新一批日志记录
|
426
427
428
429
430
431
432
|
role:log("hero_note", {
hero_id = heroType, -- 英雄ID
hero_note_action = add > 0 and 1 or 2, -- 英雄评价界面操作,发布评论:0,点赞:1,反对:2
hero_note_id = commentId, -- 操作的评价ID
hero_note_text = comment.content, -- 操作的评价内容
})
|
be9c9ca6
zhouahaihai
角色评论
|
433
434
435
436
437
438
439
|
end
end
SendPacket(actionCodes.Hero_likeCommentRpc, MsgPack.pack(result))
return true
end
|
312b9db5
zhouahaihai
背包
|
440
441
442
443
444
445
446
447
448
449
450
451
452
453
|
function _M.createHeroRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
local heroType = msg.heroType
local unitData = csvdb["unitCsv"][heroType]
if not unitData then return end
local cost = globalCsv.unit_fragment_cost[unitData["rare"]]
if not cost then return end
if role:getItemCount(heroType) < cost then return end
for _, hero in pairs(role.heros) do
if hero:getProperty("type") == heroType then return end
end
|
3133cb76
zhouhaihai
日志
|
454
455
|
role:costItems({[heroType] = cost}, {log = {desc = "createHero"}})
role:award({[heroType + ItemStartId.Hero] = 1}, {log = {desc = "createHero"}})
|
312b9db5
zhouahaihai
背包
|
456
457
458
459
460
|
SendPacket(actionCodes.Hero_createHeroRpc, "")
return true
end
|
43cc5f51
gaofengduan
调整 equip 数据结构
|
461
|
-- typ 位置,level等级对应唯一装备,level为0时为移除,不为0时无则装备,有则替换
|
24d77701
gaofengduan
fix equip
|
462
|
function _M.referEquipsRpc(agent, data)
|
43cc5f51
gaofengduan
调整 equip 数据结构
|
463
464
465
466
467
|
local role = agent.role
local msg = MsgPack.unpack(data)
local hero = role.heros[msg.id]
if not hero then return 10 end
local equips = msg.equips
|
3efc352e
zhouhaihai
增加记录log
|
468
|
local isAuto = msg.isAuto
|
43cc5f51
gaofengduan
调整 equip 数据结构
|
469
470
|
if not equips or not next(equips) then return 11 end
|
056c01a0
zhouhaihai
简化装备
|
471
472
473
474
475
|
for typ = 1, 4 do -- 4件装备
if equips[typ] and equips[typ] ~= 0 then
if role:getEquipCount(typ, equips[typ]) <= 0 then
return
end
|
43cc5f51
gaofengduan
调整 equip 数据结构
|
476
|
end
|
43cc5f51
gaofengduan
调整 equip 数据结构
|
477
|
end
|
c59e058b
zhouhaihai
新一批日志记录
|
478
479
480
481
482
|
local oldAttr = hero:getTotalAttrs()
local oldBattleV = hero:getProperty("battleV")
local wear = {}
|
056c01a0
zhouhaihai
简化装备
|
483
484
485
486
|
local curEquip = hero:getProperty("equip")
for typ = 1, 4 do -- 4件装备
if equips[typ] then
local cur = curEquip:getv(typ, 0)
|
ee999bde
zhouhaihai
零件优化
|
487
488
|
if cur ~= equips[typ] then
if equips[typ] == 0 then
|
056c01a0
zhouhaihai
简化装备
|
489
|
curEquip = curEquip:delk(typ)
|
ee999bde
zhouhaihai
零件优化
|
490
|
else
|
3133cb76
zhouhaihai
日志
|
491
|
role:addEquip(typ, equips[typ], -1, {log = {desc = "refer"}}) -- 穿上
|
056c01a0
zhouhaihai
简化装备
|
492
|
curEquip = curEquip:setv(typ, equips[typ])
|
c59e058b
zhouhaihai
新一批日志记录
|
493
494
|
wear[typ] = {id = equips[typ], act = 0}
|
056c01a0
zhouhaihai
简化装备
|
495
|
end
|
ee999bde
zhouhaihai
零件优化
|
496
497
|
if cur ~= 0 then
|
3133cb76
zhouhaihai
日志
|
498
|
role:addEquip(typ, cur, 1, {log = {desc = "refer"}}) -- 脱掉
|
c59e058b
zhouhaihai
新一批日志记录
|
499
500
|
wear[typ] = {id = cur, act = 1}
|
ee999bde
zhouhaihai
零件优化
|
501
|
end
|
43cc5f51
gaofengduan
调整 equip 数据结构
|
502
503
|
end
end
|
43cc5f51
gaofengduan
调整 equip 数据结构
|
504
|
end
|
c59e058b
zhouhaihai
新一批日志记录
|
505
|
|
056c01a0
zhouhaihai
简化装备
|
506
507
508
|
-- 更新角色
hero:updateProperty({field = "equip", value = curEquip})
|
1e9cb217
chenyueqi
服务器记录控制引导过程
|
509
510
|
role:finishGuide(23)
|
c59e058b
zhouhaihai
新一批日志记录
|
511
512
513
|
local curAttr = hero:getTotalAttrs()
local attrChange = getChangeAttrJson(oldAttr, curAttr)
for typ, data in pairs(wear) do
|
c3a70cde
zhouhaihai
返还
|
514
|
role:log("equip_wear", {
|
c59e058b
zhouhaihai
新一批日志记录
|
515
516
517
518
519
520
521
522
523
|
hero_id = hero:getProperty("type"), --英雄ID
equip_id = data.id, --装备ID
equip_wear_action = data.act, --装备操作类型:装备:0,卸载:1
equip_wear_part = typ, --装备部位,记录部位ID
equip_wear_result = curAttr, --装备操作后结果,记录属性变化,json格式记录,{“aa”:1234,"bb":4567}
equip_wear_change = attrChange, --装备操作变化值,记录属性变化,记录正负值,json格式记录,{“aa”:1234,"bb":-45}
equip_wear_mode = isAuto and 0 or 1, --用以区分自动装备还是手动装备,自动记录为0,手动记录为1
})
end
|
43cc5f51
gaofengduan
调整 equip 数据结构
|
524
525
526
527
|
SendPacket(actionCodes.Hero_referEquipsRpc, "")
return true
end
|
ee3ac0b5
gaofengduan
fix magic
|
528
529
|
-- typ 位置,uid对应唯一符文,uid为0时为移除,不为0时无则装备,有则替换
function _M.referRunesRpc(agent, data)
|
43cc5f51
gaofengduan
调整 equip 数据结构
|
530
531
532
533
534
535
|
local role = agent.role
local msg = MsgPack.unpack(data)
local hero = role.heros[msg.id]
if not hero then return 10 end
local runes = msg.runes
if not runes or not next(runes) then return 11 end
|
ee3ac0b5
gaofengduan
fix magic
|
536
|
|
f52efe51
zhouhaihai
符文升级
|
537
|
local used = {}
|
ee999bde
zhouhaihai
零件优化
|
538
539
540
541
|
for typ = 1, 6 do
if runes[typ] and runes[typ] ~= 0 then
local ownRune = role.runeBag[runes[typ]]
if not ownRune then return end
|
f52efe51
zhouhaihai
符文升级
|
542
543
544
545
546
547
548
549
550
551
552
553
554
555
|
if ownRune:getProperty("refer") ~= 0 then
used[ownRune:getProperty("refer")] = used[ownRune:getProperty("refer")] or {}
used[ownRune:getProperty("refer")][runes[typ]] = 1
end
end
end
for cheroId, cIds in pairs(used) do
local chero = role.heros[cheroId]
local hrunes = chero:getProperty("rune")
for slot, rId in pairs(hrunes:toNumMap()) do
if cIds[rId] then
hrunes = hrunes:delk(slot)
end
|
ee3ac0b5
gaofengduan
fix magic
|
556
|
end
|
f52efe51
zhouhaihai
符文升级
|
557
|
chero:updateProperty({field = "rune", value = hrunes})
|
ee3ac0b5
gaofengduan
fix magic
|
558
|
end
|
f52efe51
zhouhaihai
符文升级
|
559
|
|
c59e058b
zhouhaihai
新一批日志记录
|
560
561
562
|
local oldAttr = hero:getTotalAttrs()
local oldBattleV = hero:getProperty("battleV")
local wear = {}
|
ee999bde
zhouhaihai
零件优化
|
563
564
565
566
567
568
569
570
571
572
|
local curRune = hero:getProperty("rune")
for typ = 1, 6 do
if runes[typ] then
local cur = curRune:getv(typ, 0)
if cur ~= runes[typ] then
if runes[typ] == 0 then
curRune = curRune:delk(typ)
else
local newRune = role.runeBag[runes[typ]]
newRune:updateProperty({field = "refer",value = hero:getProperty("id")})
|
4ea1b5ac
zhouhaihai
穿戴零件
|
573
|
curRune = curRune:setv(typ, runes[typ])
|
c59e058b
zhouhaihai
新一批日志记录
|
574
|
wear[runes[typ]] = typ
|
ee999bde
zhouhaihai
零件优化
|
575
|
end
|
ee3ac0b5
gaofengduan
fix magic
|
576
|
|
ee999bde
zhouhaihai
零件优化
|
577
578
579
580
581
582
|
if cur ~= 0 then
local oldR = role.runeBag[cur]
if oldR then
oldR:updateProperty({field = "refer",value = 0})
end
end
|
ee3ac0b5
gaofengduan
fix magic
|
583
|
end
|
ee3ac0b5
gaofengduan
fix magic
|
584
|
end
|
ee3ac0b5
gaofengduan
fix magic
|
585
|
end
|
c59e058b
zhouhaihai
新一批日志记录
|
586
|
|
4ea1b5ac
zhouhaihai
穿戴零件
|
587
|
hero:updateProperty({field = "rune", value = curRune})
|
c59e058b
zhouhaihai
新一批日志记录
|
588
589
590
591
|
local attrChange = getChangeAttrJson(oldAttr, hero:getTotalAttrs())
for runeId, typ in pairs(wear) do
local ownRune = role.runeBag[runeId]
|
43293781
zhouhaihai
日志bug
|
592
593
594
595
596
597
598
599
600
601
|
if ownRune then
role:log("hero_jewel", {
hero_id = hero:getProperty("type"), -- 英雄ID
hero_jewel_id = ownRune:getProperty("id"), -- 铭文ID
hero_jewel_part = typ, -- 铭文装备部位
hero_jewel_score = hero:getProperty("battleV"), -- 铭文装备后的英雄分值
hero_jewel_scorebefore = oldBattleV, -- 铭文装备前的英雄分值
hero_jewel_result = attrChange, -- 铭文装备后效果,可记录效果ID,或json格式记录提升效果,{攻击:20,闪避:20,……..}
})
end
|
c59e058b
zhouhaihai
新一批日志记录
|
602
|
end
|
190e1415
liuzujun
英雄帖活动初始化
|
603
604
|
role:checkTaskEnter("RuneQualityCollect", {})
|
c59e058b
zhouhaihai
新一批日志记录
|
605
|
|
ee3ac0b5
gaofengduan
fix magic
|
606
|
SendPacket(actionCodes.Hero_referRunesRpc, "")
|
43cc5f51
gaofengduan
调整 equip 数据结构
|
607
608
609
|
return true
end
|
3b069d52
zhouhaihai
增加获取 food 后台
|
610
611
612
613
614
615
616
617
618
619
620
621
|
function _M.createHeroRandomRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
local itemId = msg.itemId
local itemData = csvdb["itemCsv"][itemId]
if not itemData or itemData.type ~= ItemType.HeroFCommon then return end
local cost = globalCsv.unit_fragment_cost[itemData.quality]
if not cost or role:getItemCount(itemId) < cost then return end
local randomData = csvdb["item_randomCsv"][tonumber(itemData.use_effect)]
if not randomData then return end
|
007af97e
zhouhaihai
item_random 结构更改
|
622
|
local temp = randomData.gift1:randWeight(true)
|
3b069d52
zhouhaihai
增加获取 food 后台
|
623
|
if not temp or not next(temp) then return end
|
7bb30dca
zhouhaihai
修改发奖
|
624
|
|
3133cb76
zhouhaihai
日志
|
625
|
role:costItems({[itemId] = cost}, {log = {desc = "createHeroRandom"}})
|
7bb30dca
zhouhaihai
修改发奖
|
626
627
628
629
|
local reward, change = role:award({[temp[1] + ItemStartId.Hero] = 1}, {log = {desc = "createHeroRandom"}})
SendPacket(actionCodes.Hero_createHeroRandomRpc, MsgPack.pack(role:packReward(reward, change)))
|
3b069d52
zhouhaihai
增加获取 food 后台
|
630
631
632
|
return true
end
|
36482c8b
zhouhaihai
回收养成
|
633
634
635
|
function _M.getResetRewardRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
|
36482c8b
zhouhaihai
回收养成
|
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
|
local hero = role.heros[msg.id]
if not hero then return end
local level = hero:getProperty("level")
local breakL = hero:getProperty("breakL")
local talent = hero:getProperty("talent")
if level <= 1 and talent == "" then return end
local reward = {}
while level > 1 do
local curData = csvdb["unit_expCsv"][level - 1]
reward[ItemId.Exp] = (reward[ItemId.Exp] or 0) + curData.exp
reward[ItemId.Gold] = (reward[ItemId.Gold] or 0) + curData.gold
level = level - 1
end
while breakL > 0 do
local curData = csvdb["unit_breakCsv"][breakL - 1]
reward[ItemId.BreakCost] = (reward[ItemId.BreakCost] or 0) + curData.cost
reward[ItemId.Gold] = (reward[ItemId.Gold] or 0) + curData.gold
breakL = breakL - 1
end
local stage = talent:getv(0, 1)
local tlevel = {talent:getv(1, 0), talent:getv(2, 0), talent:getv(3, 0), talent:getv(4, 0)}
local talentCostIds = globalCsv.unit_talent_cost[csvdb["unitCsv"][hero:getProperty("type")].camp]
while stage > 0 do
local curData = csvdb["unit_talentCsv"][stage]
for level = math.max(table.unpack(tlevel)), 1, -1 do
local add = 0
for i = 1, 4 do
if tlevel[i] == level then
add = add + 1
tlevel[i] = tlevel[i] - 1
end
end
local talentData = curData[level - 1]
for itemId, count in pairs(talentData.money:toNumMap()) do
reward[itemId] = (reward[itemId] or 0) + count * add
end
for idx , count in pairs(talentData.cost:toNumMap()) do
reward[talentCostIds[idx]] = (reward[talentCostIds[idx]] or 0) + count * add
end
end
stage = stage - 1
curData = csvdb["unit_talentCsv"][stage]
if curData then
tlevel = {#curData, #curData, #curData, #curData}
end
end
|
c3a70cde
zhouhaihai
返还
|
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
|
local equip = hero:getProperty("equip")
for k, v in pairs(equip:toNumMap()) do
role:addEquip(k, v, 1, {log = {desc = "resetHero", int1 = msg.id, int2 = hero:getProperty("type")}})
end
local rune = hero:getProperty("rune")
for _, id in pairs(rune:toNumMap()) do
local curRune = role.runeBag[id]
if curRune then
curRune:updateProperty({field = "refer", value = 0})
end
end
hero:updateProperties({
level = level,
breakL = breakL,
talent = "",
equip = "",
rune = "",
})
|
f22a33af
zhouhaihai
自己的日志
|
710
|
hero:mylog({desc = "resetHero"})
|
36482c8b
zhouhaihai
回收养成
|
711
712
713
714
|
for itemId, count in pairs(reward) do
reward[itemId] = math.floor(count * globalCsv.unit_back_discount)
end
|
7bb30dca
zhouhaihai
修改发奖
|
715
716
|
local change
reward, change = role:award(reward, {log = {desc = "resetHero", int1 = msg.id, int2 = hero:getProperty("type")}})
|
36482c8b
zhouhaihai
回收养成
|
717
|
|
c59e058b
zhouhaihai
新一批日志记录
|
718
|
role:log("hero_recycle", {
|
c3a70cde
zhouhaihai
返还
|
719
|
hero_recycle_list = {[hero:getProperty("type")] = 1}, -- 回收的英雄id列表,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"}
|
887c1843
zhouhaihai
日志新一批
|
720
|
hero_recycle_reward = reward, -- 回收后获得的奖励,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"}
|
c59e058b
zhouhaihai
新一批日志记录
|
721
722
|
hero_recycle_cnt = 1, -- 总回收英雄量
})
|
7bb30dca
zhouhaihai
修改发奖
|
723
|
SendPacket(actionCodes.Hero_getResetRewardRpc, MsgPack.pack(role:packReward(reward, change)))
|
36482c8b
zhouhaihai
回收养成
|
724
725
726
|
return true
end
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
727
728
729
730
|
function _M.drawHeroRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
|
accf94c4
liuzujun
活动以类型标识,修改双倍活动bug
|
731
|
if not role:isFuncUnlock(FuncUnlock.GetHero) then return 1 end
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
732
733
734
|
local btype = msg.pool -- 1 2 3 卡池类型
local subType = msg.subType or 1-- 定向卡池需要传 子类型
local drawType = msg.type -- 1 单抽 2 十连
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
735
736
737
|
if btype ~= 1 then
subType = 1
end
|
8cd3770f
liuzujun
挂机关卡可以选择,经验金币根据最高...
|
738
739
740
|
if btype == 1 then
-- 判断定向卡池活动开启
|
1070d7ce
liuzujun
定向抽卡活动与ssr up活动统一...
|
741
|
if not role.activity:isOpen("SsrUpPoolChange") then
|
8cd3770f
liuzujun
挂机关卡可以选择,经验金币根据最高...
|
742
743
744
|
return
end
end
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
745
746
|
local buildTypeData = csvdb["build_typeCsv"][btype]
|
accf94c4
liuzujun
活动以类型标识,修改双倍活动bug
|
747
|
if not buildTypeData then return 2 end
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
748
749
|
local drawCount = {1, 10} -- 抽取次数
|
accf94c4
liuzujun
活动以类型标识,修改双倍活动bug
|
750
|
if not drawCount[drawType] then return 3 end
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
751
|
|
93f6e69b
liuzujun
拾荒选择时间,抽卡增加sr保底
|
752
753
754
|
local draw_floor_back_counts = globalCsv.draw_floor_back_counts[btype]
local floorHeroCount = role:getProperty("floorHero")[btype] or 0
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
|
-- 计算抽卡消耗品
local cost = {}
local lastCount = drawCount[drawType]
for _, costType in ipairs({"draw_card", "draw_coin"}) do
if buildTypeData[costType] ~= "" then
local curCost = buildTypeData[costType]:toArray(true, "=")
local hadCount = role:getItemCount(curCost[1])
local curCount = math.floor(hadCount / curCost[2])
if curCount >= lastCount then
cost[curCost[1]] = curCost[2] * lastCount
lastCount = 0
break
elseif curCount > 0 then
cost[curCost[1]] = curCost[2] * curCount
lastCount = lastCount - curCount
end
end
end
if lastCount > 0 then -- 钱不够
|
accf94c4
liuzujun
活动以类型标识,修改双倍活动bug
|
774
|
return 4
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
775
776
777
778
779
|
end
-- 抽取的池子
local poolMap = buildTypeData["pool"]:toNumMap()
local poolId = poolMap[subType]
|
accf94c4
liuzujun
活动以类型标识,修改双倍活动bug
|
780
|
if not poolId then return 5 end
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
781
782
783
784
785
786
|
--判断定向卡池是否开启
if btype == 1 then
if not role:isTimeResetOpen(TimeReset["DrawType" .. subType]) then
local unlockPool = role.dailyData:getProperty("unlockPool")
if not unlockPool[subType] then
|
accf94c4
liuzujun
活动以类型标识,修改双倍活动bug
|
787
|
return 6
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
788
789
790
791
792
|
end
end
end
--TODO 活动覆盖
|
93f6e69b
liuzujun
拾荒选择时间,抽卡增加sr保底
|
793
794
795
796
|
local actPoolId = role.activity:getActivityPool(btype, subType)
if actPoolId ~= 0 then
poolId = actPoolId
end
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
797
798
|
local unitPool = csvdb["build_unitCsv"][poolId]
|
accf94c4
liuzujun
活动以类型标识,修改双倍活动bug
|
799
|
if not unitPool then return 7 end
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
800
801
802
|
-- 开始抽
local resultPool = {}
|
93f6e69b
liuzujun
拾荒选择时间,抽卡增加sr保底
|
803
|
local function fillDrawPool(isFloorBack)
|
accf94c4
liuzujun
活动以类型标识,修改双倍活动bug
|
804
|
local condition = {"rare"}
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
805
806
|
local values = {}
|
93f6e69b
liuzujun
拾荒选择时间,抽卡增加sr保底
|
807
|
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
|
for idx, field in ipairs(condition) do
if not values[idx] then
local lpool = {}
local curIdx = 1
while unitPool[field .. "_" .. curIdx] do
lpool[curIdx] = {unitPool[field .. "_" .. curIdx]}
curIdx = curIdx + 1
end
if next(lpool) then
values[idx] = math.randWeight(lpool, 1)
end
end
end
|
4839b94d
liuzujun
增加抽卡英雄up
|
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
|
local weight = 0
local up_pool = nil
local rand_v = math.randomInt(1, 100)
if values[1] == HeroQuality.SR then
weight = unitPool["up_sr_weight"]
up_pool = unitPool["up_sr_id"]
elseif values[1] == HeroQuality.SSR then
weight = unitPool["up_ssr_weight"]
up_pool = unitPool["up_ssr_id"]
end
--print(poolId, rand_v, weight, up_pool, values[1])
if rand_v < weight and up_pool then
up_pool = up_pool:toArray(true, "=")
for k, v in ipairs(up_pool) do
resultPool[v] = {1}
end
else
for itemId, oneData in pairs(isFloorBack and csvdb["build_floorCsv"] or csvdb["build_poolCsv"]) do
local pool_str = "pool_" .. poolId
if oneData[pool_str] and oneData[pool_str] ~= "" then
local itemData = csvdb["itemCsv"][itemId]
while itemData do
if itemData.type ~= ItemType.Hero then break end
local heroData = csvdb["unitCsv"][itemData.id - ItemStartId.Hero]
if not heroData then break end
local ok = true
-- 保底是全随机,不用比较类型
if not isFloorBack then
for idx, field in ipairs(condition) do
if heroData[field] ~= values[idx] then ok = false break end
end
|
bb10924f
liuzujun
10连保底使用池子全随机
|
854
|
end
|
4839b94d
liuzujun
增加抽卡英雄up
|
855
856
857
858
859
|
if not ok then break end
if oneData[pool_str] > 0 then
resultPool[itemId] = {oneData[pool_str]} -- itemId, count, 概率
end
break
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
860
|
end
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
861
862
863
864
865
|
end
end
end
end
|
c59e058b
zhouhaihai
新一批日志记录
|
866
|
role:costItems(cost, {log = {desc = "drawHero", int1 = btype, int2 = poolId}})
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
867
|
|
00bf6029
liuzujun
限时礼包,抽卡ssr广播
|
868
|
local guideHero = nil
|
a5b98c30
chenyueqi
引导调整
|
869
870
|
if role:getProperty("newerGuide") == "8=1" then
guideHero = globalCsv.newdraw_hero_item_id or 503
|
16f5fa68
chenyueqi
引导招募的引导改动被回退
|
871
872
|
end
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
873
874
|
local ssrCount = 0
local reward = {}
|
37bb4611
liuzujun
付费签到,抽卡阶段奖励,探索指令
|
875
|
local logReward = {}
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
876
|
for i = 1, drawCount[drawType] do
|
93f6e69b
liuzujun
拾荒选择时间,抽卡增加sr保底
|
877
878
|
floorHeroCount = floorHeroCount + 1
local isFloorBack = draw_floor_back_counts and floorHeroCount >= draw_floor_back_counts
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
879
|
resultPool = {}
|
93f6e69b
liuzujun
拾荒选择时间,抽卡增加sr保底
|
880
881
882
|
fillDrawPool(isFloorBack)
if not next(resultPool) then
skynet.error("random pool error, poolId:" .. poolId)
|
accf94c4
liuzujun
活动以类型标识,修改双倍活动bug
|
883
|
return 8
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
884
885
|
end
|
16f5fa68
chenyueqi
引导招募的引导改动被回退
|
886
887
888
|
local itemId = math.randWeight(resultPool, 1)
if guideHero then
itemId = guideHero
|
16f5fa68
chenyueqi
引导招募的引导改动被回退
|
889
890
|
end
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
891
892
893
|
local itemData = csvdb["itemCsv"][itemId]
if itemData.quality == HeroQuality.SSR then
ssrCount = ssrCount + 1
|
00bf6029
liuzujun
限时礼包,抽卡ssr广播
|
894
|
if not guideHero then
|
4839b94d
liuzujun
增加抽卡英雄up
|
895
|
-- 广播获得ssr英雄
|
00bf6029
liuzujun
限时礼包,抽卡ssr广播
|
896
897
898
|
local ntf = {heroId = itemData.id - ItemStartId.Hero, nick = role:getProperty("name")}
mcast_util.pub_world(actionCodes.Role_broadGetSSR, MsgPack.pack(ntf))
end
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
899
900
|
end
|
93f6e69b
liuzujun
拾荒选择时间,抽卡增加sr保底
|
901
902
903
904
|
if itemData.quality >= HeroQuality.SR then
floorHeroCount = 0
end
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
905
906
907
908
|
if role:isHaveHero(itemData.id - ItemStartId.Hero) then
local fragId = itemData.id - ItemStartId.Hero
local heroData = csvdb["unitCsv"][fragId]
local count = globalCsv.draw_unit_tofragment[heroData.rare]
|
c59e058b
zhouhaihai
新一批日志记录
|
909
|
role:award({[fragId] = count}, {log = {desc = "drawHero", int1 = btype, int2 = poolId}})
|
b5481708
zhouhaihai
保底日志
|
910
|
logReward[fragId] = (logReward[fragId] or 0) + count
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
911
912
|
table.insert(reward, {id = fragId, count = count, from = itemId, fcount = 1})
else
|
c59e058b
zhouhaihai
新一批日志记录
|
913
|
role:award({[itemId] = 1}, {log = {desc = "drawHero", int1 = btype, int2 = poolId}})
|
b5481708
zhouhaihai
保底日志
|
914
|
logReward[itemId] = (logReward[itemId] or 0) + 1
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
915
916
917
918
|
table.insert(reward, {id = itemId, count = 1})
end
end
|
93f6e69b
liuzujun
拾荒选择时间,抽卡增加sr保底
|
919
920
921
922
923
924
|
if draw_floor_back_counts then
local floorHero = role:getProperty("floorHero")
floorHero[btype] = floorHeroCount
role:setProperty("floorHero", floorHero)
end
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
925
926
927
928
|
role:checkTaskEnter("DrawHero", {pool = btype, count = drawCount[drawType]})
if ssrCount > 0 then
role:checkTaskEnter("DrawSSR", {count = ssrCount})
end
|
a5b98c30
chenyueqi
引导调整
|
929
|
role:finishGuide(8)
|
b5481708
zhouhaihai
保底日志
|
930
|
|
c59e058b
zhouhaihai
新一批日志记录
|
931
932
933
934
935
|
role:log("gacha", {
gacha_id = poolId, -- 卡池ID
gacha_type = btype, -- 卡池类型
gacha_up = 0, -- 卡池UP角色
gacha_times = drawCount[drawType], -- 抽卡次数
|
b5481708
zhouhaihai
保底日志
|
936
|
gacha_reward = logReward, -- 抽卡结果,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"}
|
887c1843
zhouhaihai
日志新一批
|
937
|
currency = cost, -- 购买道具消耗的货币
|
b5481708
zhouhaihai
保底日志
|
938
|
gacha_cnt = floorHeroCount,
|
c59e058b
zhouhaihai
新一批日志记录
|
939
|
})
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
940
|
SendPacket(actionCodes.Hero_drawHeroRpc, MsgPack.pack({reward = reward})) -- 这个 reward 是数组
|
37bb4611
liuzujun
付费签到,抽卡阶段奖励,探索指令
|
941
942
943
944
945
946
|
if btype == 1 or btype == 2 then
-- 达到一定次数,给响应奖励
local oldVal = role:getProperty("repayHero") or 0
local newVal = oldVal + drawCount[drawType]
local drawCardReward, val = role:getDrawCardExtraReward(oldVal, newVal)
|
37bb4611
liuzujun
付费签到,抽卡阶段奖励,探索指令
|
947
948
949
950
|
-- 空字符穿代表直接给英雄 走以前repayHeroRpc
if drawCardReward == "" then
local id = math.randWeight(csvdb["build_giftCsv"], "pool_1")
|
e0290d8e
liuzujun
修改引导, 抽卡阶段奖励修改
|
951
|
local r,change = {}
|
37bb4611
liuzujun
付费签到,抽卡阶段奖励,探索指令
|
952
|
local itemData = csvdb["itemCsv"][id]
|
e0290d8e
liuzujun
修改引导, 抽卡阶段奖励修改
|
953
954
955
956
957
958
959
960
961
962
|
--if itemData.type == ItemType.Hero and role:isHaveHero(itemData.id - ItemStartId.Hero) then
-- local fragId = itemData.id - ItemStartId.Hero
-- local heroData = csvdb["unitCsv"][fragId]
-- local count = globalCsv.draw_unit_tofragment[heroData.rare]
-- r, change = role:award({[fragId] = count}, {log = {desc = "drawHeroExtraReward"}})
-- --r = {id = fragId, count = count, from = id, fcount = 1}
--else
r, change = role:award({[id] = 1}, {log = {desc = "drawHeroExtraReward"}})
--end
SendPacket(actionCodes.Hero_drawHeroExtraRewardNtf, MsgPack.pack(role:packReward(r, change)))
|
37bb4611
liuzujun
付费签到,抽卡阶段奖励,探索指令
|
963
964
965
966
967
968
|
elseif drawCardReward and drawCardReward ~= "" then
role:award(drawCardReward, {log = {desc = "drawHeroExtraReward", int1 = oldVal, int2 = newVal}})
SendPacket(actionCodes.Hero_drawHeroExtraRewardNtf, MsgPack.pack({reward = drawCardReward:toNumMap()}))
end
role:updateProperty({field = "repayHero", value = val})
end
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
969
970
971
|
return true
end
|
317a46a9
liuzujun
添加特权卡
|
972
973
|
function _M.repayHeroRpc(agent, data)
local role = agent.role
|
a35233c6
zhouhaihai
保底和回馈
|
974
|
|
317a46a9
liuzujun
添加特权卡
|
975
|
local repayHero = role:getProperty("repayHero")
|
fb3d084d
liuzujun
月卡赛季卡发送邮件奖励
|
976
977
|
local cnt = globalCsv.draw_times_to_get_ssr or 100
if repayHero < cnt then
|
317a46a9
liuzujun
添加特权卡
|
978
979
|
return
end
|
fb3d084d
liuzujun
月卡赛季卡发送邮件奖励
|
980
|
local result = repayHero - cnt
|
a35233c6
zhouhaihai
保底和回馈
|
981
|
|
317a46a9
liuzujun
添加特权卡
|
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
|
role:updateProperty({field = "repayHero", value = result})
local id = math.randWeight(csvdb["build_giftCsv"], "pool_1")
local reward = {}
local itemData = csvdb["itemCsv"][id]
if itemData.type == ItemType.Hero and role:isHaveHero(itemData.id - ItemStartId.Hero) then
local fragId = itemData.id - ItemStartId.Hero
local heroData = csvdb["unitCsv"][fragId]
local count = globalCsv.draw_unit_tofragment[heroData.rare]
role:award({[fragId] = count}, {log = {desc = "heroRepay"}})
reward = {id = fragId, count = count, from = id, fcount = 1}
else
role:award({[id] = 1}, {log = {desc = "heroRepay"}})
reward = {id = id, count = 1}
end
|
f22a33af
zhouhaihai
自己的日志
|
997
|
role:mylog("hero_action", {desc = "heroRepay", int1=result})
|
317a46a9
liuzujun
添加特权卡
|
998
999
1000
|
SendPacket(actionCodes.Hero_repayHeroRpc, MsgPack.pack({reward = reward}))
return true
end
|
a35233c6
zhouhaihai
保底和回馈
|
1001
|
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
|
function _M.unlockPoolRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
if not role:isFuncUnlock(FuncUnlock.GetHero) then return end
local type = msg.type -- 指定定向卡池需要类型 1, 2, 3
local needCost = true
--当前开启的类型不用解锁
if role:isTimeResetOpen(TimeReset["DrawType" .. type]) then
needCost = false
end
--已经解锁的不需要重复解锁
local unlockPool = role.dailyData:getProperty("unlockPool")
if unlockPool[type] then
needCost = false
end
if needCost then
|
f3eb34b1
liuzujun
删除无用日志
|
1020
|
if not role:costDiamond({count = globalCsv.draw_unlock_pool_diamond or 300, log = {desc = "unlockPool", int1 = type}}) then
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
1021
1022
1023
1024
1025
1026
1027
1028
|
return
end
end
unlockPool[type] = 1
role.dailyData:updateProperty({field="unlockPool", value = unlockPool})
role.dailyData:updateProperty({field="curPool", value = type})
|
f22a33af
zhouhaihai
自己的日志
|
1029
|
role:mylog("hero_action", {desc = "unlockPool", int1=type})
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
1030
1031
1032
1033
|
SendPacket(actionCodes.Hero_unlockPoolRpc, MsgPack.pack({}))
return true
end
|
51d9d20b
liuzujun
付费签到,应用市场反馈
|
1034
|
function _M.changeCrown(agent, data)
|
c59e058b
zhouhaihai
新一批日志记录
|
1035
1036
1037
1038
1039
|
local role = agent.role
local msg = MsgPack.unpack(data)
local heroType = msg.heroType
|
4c7d396c
zhouhaihai
不回复 更改看板娘
|
1040
|
if not role:isHaveHero(heroType) then return true end
|
c59e058b
zhouhaihai
新一批日志记录
|
1041
1042
1043
1044
1045
|
role:setProperty("crown", heroType)
role:log("hero_show", {
hero_id = heroType,
})
|
c59e058b
zhouhaihai
新一批日志记录
|
1046
1047
1048
|
return true
end
|
1af7ada5
liuzujun
fix confict
|
1049
|
return _M
|