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
|
|
94449a78
chenyueqi
英雄升级和突破增加关卡限制
|
38
39
40
|
local level = hero:getProperty("level")
if level >= hero:getMaxLevel() then return 2 end
local curData = csvdb["unit_expCsv"][level]
|
997cbdfe
zhouahaihai
技能养成
|
41
|
local cost = {[ItemId.Exp] = curData.exp, [ItemId.Gold] = curData.gold}
|
1c35c4cf
gaofengduan
fix hero awake
|
42
|
if not role:checkItemEnough(cost) then return 3 end
|
94449a78
chenyueqi
英雄升级和突破增加关卡限制
|
43
44
|
-- 通过指定关卡后才能升级英雄等级
|
81e36dfb
zhangqijia
Revert "revert: 使...
|
45
46
47
48
|
--local pass = globalCsv.unit_exp_level_pass[level + 1]
--if pass then
-- if not role:checkHangPass(pass) then return 4 end
--end
|
e66080dd
zhangqijia
test: 去除关卡卡角色等级;改...
|
49
50
|
--账号等级提升角色等级上限
|
81e36dfb
zhangqijia
Revert "revert: 使...
|
51
52
|
local accountLevel = role:getAccountLevel()
if level >= accountLevel then return 4 end
|
94449a78
chenyueqi
英雄升级和突破增加关卡限制
|
53
|
|
7cbae6f3
zhangqijia
fix: Role:costIte...
|
54
|
if not role:costItems(cost, {log = {desc = "heroLevelUp", int1 = msg.id, int2 = hero:getProperty("type")}}) then return 5 end
|
c59e058b
zhouhaihai
新一批日志记录
|
55
56
57
|
local oldAttr = hero:getTotalAttrs()
local oldBattleV = hero:getProperty("battleV")
|
0a07bdd9
zhouahaihai
角色升级 。gm
|
58
|
hero:updateProperty({field = "level", delta = 1})
|
1c35c4cf
gaofengduan
fix hero awake
|
59
|
|
c59e058b
zhouhaihai
新一批日志记录
|
60
61
|
role:log("hero_upgrade", {
hero_id = hero:getProperty("type"), --英雄ID
|
887c1843
zhouhaihai
日志新一批
|
62
|
hero_upgrade_cost = cost, -- 英雄升级消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...}
|
c59e058b
zhouhaihai
新一批日志记录
|
63
64
65
66
67
|
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
日志
|
68
|
|
54b7749c
zhangqijia
fix:英雄突破和英雄升级,日志增...
|
69
|
hero:mylog({desc = "levelUp", int1 = hero:getProperty("level"), int2 = hero:getProperty("type")})
|
1e9cb217
chenyueqi
服务器记录控制引导过程
|
70
|
|
53e8037e
zhouhaihai
任务
|
71
|
role:checkTaskEnter("HeroLevelUp", {level = hero:getProperty("level")})
|
190e1415
liuzujun
英雄帖活动初始化
|
72
73
|
role:checkTaskEnter("HeroLvlCollect", {})
|
0a07bdd9
zhouahaihai
角色升级 。gm
|
74
75
76
77
|
SendPacket(actionCodes.Hero_levelUpRpc, '')
return true
end
|
8c74292c
zhouahaihai
增加item 以及 角色突破
|
78
79
80
81
|
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
|
82
|
if not hero then return 1 end
|
8c74292c
zhouahaihai
增加item 以及 角色突破
|
83
|
|
94449a78
chenyueqi
英雄升级和突破增加关卡限制
|
84
|
local breakL = hero:getProperty("breakL")
|
1c35c4cf
gaofengduan
fix hero awake
|
85
|
if hero:getProperty("level") < hero:getMaxLevel() then return 2 end
|
94449a78
chenyueqi
英雄升级和突破增加关卡限制
|
86
87
|
if breakL >= #csvdb["unit_breakCsv"] then return 3 end
local curData = csvdb["unit_breakCsv"][breakL]
|
702a3769
liuzujun
跑马灯gm指令, 突破时候检测星级要求
|
88
|
if hero:getProperty("wakeL") < curData["starLimit"] then return 4 end
|
997cbdfe
zhouahaihai
技能养成
|
89
|
local cost = {[ItemId.BreakCost] = curData.cost, [ItemId.Gold] = curData.gold}
|
1c35c4cf
gaofengduan
fix hero awake
|
90
|
if not role:checkItemEnough(cost) then return 4 end
|
94449a78
chenyueqi
英雄升级和突破增加关卡限制
|
91
92
|
-- 通过指定关卡后才能突破英雄
|
81e36dfb
zhangqijia
Revert "revert: 使...
|
93
94
95
96
|
--local pass = globalCsv.unit_break_level_pass[breakL + 1]
--if pass then
-- if not role:checkHangPass(pass) then return 4 end
--end
|
94449a78
chenyueqi
英雄升级和突破增加关卡限制
|
97
|
|
7cbae6f3
zhangqijia
fix: Role:costIte...
|
98
|
if not role:costItems(cost, {log = {desc = "heroBreak", int1 = msg.id, int2 = hero:getProperty("type")}}) then return 5 end
|
c59e058b
zhouhaihai
新一批日志记录
|
99
|
local oldAttr = hero:getTotalAttrs()
|
8c74292c
zhouahaihai
增加item 以及 角色突破
|
100
|
hero:updateProperty({field = "breakL", delta = 1})
|
1c35c4cf
gaofengduan
fix hero awake
|
101
|
|
c59e058b
zhouhaihai
新一批日志记录
|
102
103
|
role:log("hero_break", {
hero_id = hero:getProperty("type"), --英雄ID
|
887c1843
zhouhaihai
日志新一批
|
104
|
hero_break_cost = cost, -- 英雄突破消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...}
|
c59e058b
zhouhaihai
新一批日志记录
|
105
106
107
|
hero_break_result = getChangeAttrJson(oldAttr, hero:getTotalAttrs()), -- 英雄突破效果,可记录效果ID,或json格式记录提升效果,{攻击:20,闪避:20,……..}
hero_break_level = hero:getMaxLevel(), -- 英雄突破后等级上限
})
|
54b7749c
zhangqijia
fix:英雄突破和英雄升级,日志增...
|
108
|
hero:mylog({desc = "break", int1 = hero:getProperty("breakL"), int2 = hero:getProperty("type")})
|
3133cb76
zhouhaihai
日志
|
109
|
|
8c74292c
zhouahaihai
增加item 以及 角色突破
|
110
111
112
|
SendPacket(actionCodes.Hero_breakRpc, '')
return true
end
|
0a07bdd9
zhouahaihai
角色升级 。gm
|
113
|
|
997cbdfe
zhouahaihai
技能养成
|
114
115
116
117
|
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
|
118
119
120
121
122
|
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
修改天赋升级消耗
|
123
124
|
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
|
125
126
|
if not role:checkItemEnough(cost) then
return 4
|
997cbdfe
zhouahaihai
技能养成
|
127
|
end
|
3d8468b2
liuzujun
火花系统
|
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
local curLevel = hero:getProperty("wakeL")
local sparkInfo = hero:getProperty("spark")
-- 大于等于7的时候需要装备火花才能升
if curLevel >= 7 then
if #sparkInfo == 0 then
return 5
end
local ok = false
for _, info in ipairs(sparkInfo) do
local cfg = csvdb["sparkCsv"][info.cfg_id][info.level or 0]
if not cfg then return 6 end
if cfg.star == curLevel then
ok = true
break
end
end
if not ok then return 7 end
end
|
1c35c4cf
gaofengduan
fix hero awake
|
147
|
|
7cbae6f3
zhangqijia
fix: Role:costIte...
|
148
|
if not role:costItems(cost, {log = {desc = "heroWake", int1 = msg.id, int2 = hero:getProperty("type")}}) then return 8 end
|
0889982f
zhouhaihai
优化角色技能等级
|
149
|
|
c59e058b
zhouhaihai
新一批日志记录
|
150
|
local oldAttr = hero:getTotalAttrs()
|
43293781
zhouhaihai
日志bug
|
151
|
local oldBattleV = hero:getProperty("battleV")
|
997cbdfe
zhouahaihai
技能养成
|
152
153
|
hero:updateProperty({field = "wakeL", delta = 1})
|
b88939d5
zhangqijia
fix: 玛尼的英雄帖增加任务类型...
|
154
155
|
curLevel = curLevel + 1
role:checkTaskEnter("Wake", {heroType = typ, wakeL = curLevel})
|
bcbb0c7b
zhouhaihai
3星解锁 cg
|
156
|
if curLevel == 3 then -- 解锁cg
|
53e8037e
zhouhaihai
任务
|
157
|
role:checkTaskEnter("WakeCG", {heroType = typ})
|
b88939d5
zhangqijia
fix: 玛尼的英雄帖增加任务类型...
|
158
|
role:checkTaskEnter("WakeCGSum", {count = 1})
|
53e8037e
zhouhaihai
任务
|
159
|
end
|
47343863
zhangqijia
fix: 天赋点自动升级,重置觉醒...
|
160
161
|
if curLevel >= 4 then --自动觉醒技能
|
8e2d9f73
chenyueqi
修复英雄觉醒之后可升级的天赋技没有...
|
162
163
|
local new = hero:increGeniusTree()
hero:updateProperty({field = "genius", value = new})
|
47343863
zhangqijia
fix: 天赋点自动升级,重置觉醒...
|
164
|
end
|
f22a33af
zhouhaihai
自己的日志
|
165
|
hero:mylog({desc = "wake", int1 = hero:getProperty("wakeL")})
|
3133cb76
zhouhaihai
日志
|
166
|
|
c59e058b
zhouhaihai
新一批日志记录
|
167
168
|
role:log("hero_rise", {
hero_id = typ, --英雄ID
|
887c1843
zhouhaihai
日志新一批
|
169
|
hero_rise_cost = cost, --英雄觉醒消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,………...}
|
c59e058b
zhouhaihai
新一批日志记录
|
170
|
hero_rise_score = hero:getProperty("battleV"), --英雄觉醒后评分提升
|
43293781
zhouhaihai
日志bug
|
171
|
hero_rise_scoreget = hero:getProperty("battleV") - oldBattleV, --英雄觉醒后评分提升
|
c59e058b
zhouhaihai
新一批日志记录
|
172
173
174
|
hero_rise_result = getChangeAttrJson(oldAttr, hero:getTotalAttrs()), --英雄觉醒效果,可记录效果ID,或json格式记录提升效果,{攻击:20,闪避:20,……..}
})
|
a5b98c30
chenyueqi
引导调整
|
175
176
177
178
|
if hero:getProperty("type") == 204 then
role:finishGuide(7)
end
|
997cbdfe
zhouahaihai
技能养成
|
179
|
SendPacket(actionCodes.Hero_wakeRpc, '')
|
190e1415
liuzujun
英雄帖活动初始化
|
180
181
|
role:checkTaskEnter("HeroStarCollect", {})
|
b88939d5
zhangqijia
fix: 玛尼的英雄帖增加任务类型...
|
182
|
role:checkTaskEnter("HeroStartSum", {})
|
997cbdfe
zhouahaihai
技能养成
|
183
184
185
|
return true
end
|
997cbdfe
zhouahaihai
技能养成
|
186
187
188
189
190
|
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
|
191
|
if not hero then return 1 end
|
997cbdfe
zhouahaihai
技能养成
|
192
|
|
04258e10
zhouhaihai
天赋bug
|
193
|
local talent = hero:getProperty("talent")
|
96d591f7
liuzujun
天赋升级修改,增加英雄信赖
|
194
|
local heroCfgId = hero:getProperty("type")
|
997cbdfe
zhouahaihai
技能养成
|
195
|
local curStage = talent:getv(0, 1)
|
6a2b449c
liuzujun
扭蛋机奖励不合并显示, 新增多队挂...
|
196
|
local oldStage = curStage
|
96d591f7
liuzujun
天赋升级修改,增加英雄信赖
|
197
|
local curLevel = talent:getv(1, 1)
|
6a2b449c
liuzujun
扭蛋机奖励不合并显示, 新增多队挂...
|
198
|
local oldLevel = curLevel
|
96d591f7
liuzujun
天赋升级修改,增加英雄信赖
|
199
200
|
local curData = csvdb["unit_talent_"..heroCfgId.."Csv"][curStage]
if not curData then return 1 end
|
c59e058b
zhouhaihai
新一批日志记录
|
201
202
|
local oldSkillLv = hero:getSkillLevel(1)
|
997cbdfe
zhouahaihai
技能养成
|
203
|
|
c59e058b
zhouhaihai
新一批日志记录
|
204
|
local cost = {}
|
235d8a37
liuzujun
#fxcn_11862 角色精进点...
|
205
206
|
if curLevel < #curData then
--if curLevel > #curData then return 2 end
|
6fc397d6
zhouhaihai
角色新突破 冒险优化点击地块
|
207
|
|
96d591f7
liuzujun
天赋升级修改,增加英雄信赖
|
208
209
|
local talentData = curData[curLevel]
if not talentData then return 3 end
|
6fc397d6
zhouhaihai
角色新突破 冒险优化点击地块
|
210
|
|
96d591f7
liuzujun
天赋升级修改,增加英雄信赖
|
211
|
if talentData.lvRequire > hero:getProperty("level") then return 4 end
|
6fc397d6
zhouhaihai
角色新突破 冒险优化点击地块
|
212
|
|
c59e058b
zhouhaihai
新一批日志记录
|
213
|
cost = talentData.money:toNumMap()
|
96d591f7
liuzujun
天赋升级修改,增加英雄信赖
|
214
|
if not role:checkItemEnough(cost) then return 5 end
|
7cbae6f3
zhangqijia
fix: Role:costIte...
|
215
|
if not role:costItems(cost, {log = {desc = "heroTalent", int1 = msg.id, int2 = hero:getProperty("type")}}) then return 6 end
|
96d591f7
liuzujun
天赋升级修改,增加英雄信赖
|
216
|
talent = talent:setv(1, curLevel + 1)
|
235d8a37
liuzujun
#fxcn_11862 角色精进点...
|
217
218
219
220
221
222
223
|
if curLevel + 1 == #curData then
talent = talent:setv(0, curStage + 1)
talent = talent:setv(1, 1)
end
else
return 2
|
997cbdfe
zhouahaihai
技能养成
|
224
|
end
|
96d591f7
liuzujun
天赋升级修改,增加英雄信赖
|
225
|
curStage = talent:getv(0, 1)
|
b454725a
zhangqijia
feat: 英雄精进触发礼包, 修...
|
226
|
role:checkTaskEnter("HeroTalent", {heroType = hero:getProperty("type"), alv = curStage, count = 1})
|
53e8037e
zhouhaihai
任务
|
227
|
|
6fc397d6
zhouhaihai
角色新突破 冒险优化点击地块
|
228
|
hero:updateProperty({field = "talent", value = talent})
|
53e8037e
zhouhaihai
任务
|
229
|
|
6a2b449c
liuzujun
扭蛋机奖励不合并显示, 新增多队挂...
|
230
231
232
233
234
|
role:log("hero_talent", {
hero_id = hero:getProperty("type"), --英雄ID
hero_talent_stagebef = oldStage, --英雄精进升级前停留阶段
hero_talent_stage = curStage, --英雄精进升级后停留阶段
|
8ec16c21
liuzujun
天赋升级写日志报错
|
235
|
hero_talent_cost = cost, --英雄精进升级消耗,json格式记录,{道具ID1:消耗数量1,道具ID2:消耗数量2,….}
|
6a2b449c
liuzujun
扭蛋机奖励不合并显示, 新增多队挂...
|
236
237
238
239
|
hero_talent_subid = curData[oldLevel].effect, --升级属性ID,生命、攻击、防御、命中、闪避分别对应(0,1,2,3,4)
hero_talent_sublevel = curData[oldLevel].level, --升级属性等级,如生命升级从1到2,则记录2
})
|
96d591f7
liuzujun
天赋升级修改,增加英雄信赖
|
240
|
hero:mylog({desc = "talent", int1 = talent:getv(0, 1), int2 = talent:getv(1, 1)})
|
3133cb76
zhouhaihai
日志
|
241
|
|
997cbdfe
zhouahaihai
技能养成
|
242
243
244
245
|
SendPacket(actionCodes.Hero_talentRpc, '')
return true
end
|
6fc397d6
zhouhaihai
角色新突破 冒险优化点击地块
|
246
|
|
be9c9ca6
zhouahaihai
角色评论
|
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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
|
-- 暂时没有这个功能
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
抽英雄
|
321
|
local SERV = string.format(".chated%d", math.random(1, 5))
|
be9c9ca6
zhouahaihai
角色评论
|
322
323
324
325
326
327
|
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
|
328
|
commentId = commentId,
|
be9c9ca6
zhouahaihai
角色评论
|
329
330
331
332
333
334
335
336
337
338
339
|
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
新一批日志记录
|
340
341
342
343
344
345
346
347
|
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
角色评论
|
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
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
|
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
|
411
|
return
|
be9c9ca6
zhouahaihai
角色评论
|
412
413
|
end
|
1c35c4cf
gaofengduan
fix hero awake
|
414
415
|
local result = {status = 0}
local commentIndex = heroType .. ":" .. commentId
|
be9c9ca6
zhouahaihai
角色评论
|
416
417
|
local commentRoleKey = string.format("comment:%d:like", role:getProperty("id"))
local redret = redisproxy:pipelining(function (red)
|
c59e058b
zhouhaihai
新一批日志记录
|
418
|
red:hget(commentKey.commentKey, commentId)
|
be9c9ca6
zhouahaihai
角色评论
|
419
420
421
422
423
424
425
|
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
新一批日志记录
|
426
427
|
if redret[1] then-- 查不到也返回ture
local comment = json.decode(redret[1])
|
be9c9ca6
zhouahaihai
角色评论
|
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
|
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
新一批日志记录
|
453
454
455
456
457
458
459
|
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
角色评论
|
460
461
462
463
464
465
466
|
end
end
SendPacket(actionCodes.Hero_likeCommentRpc, MsgPack.pack(result))
return true
end
|
312b9db5
zhouahaihai
背包
|
467
468
469
470
471
472
473
474
475
476
477
478
479
480
|
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
|
7cbae6f3
zhangqijia
fix: Role:costIte...
|
481
|
if not role:costItems({[heroType] = cost}, {log = {desc = "createHero"}}) then return end
|
3133cb76
zhouhaihai
日志
|
482
|
role:award({[heroType + ItemStartId.Hero] = 1}, {log = {desc = "createHero"}})
|
312b9db5
zhouahaihai
背包
|
483
484
485
486
487
|
SendPacket(actionCodes.Hero_createHeroRpc, "")
return true
end
|
43cc5f51
gaofengduan
调整 equip 数据结构
|
488
|
-- typ 位置,level等级对应唯一装备,level为0时为移除,不为0时无则装备,有则替换
|
24d77701
gaofengduan
fix equip
|
489
|
function _M.referEquipsRpc(agent, data)
|
43cc5f51
gaofengduan
调整 equip 数据结构
|
490
491
492
493
494
|
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
|
495
|
local isAuto = msg.isAuto
|
43cc5f51
gaofengduan
调整 equip 数据结构
|
496
497
|
if not equips or not next(equips) then return 11 end
|
056c01a0
zhouhaihai
简化装备
|
498
499
500
501
502
|
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 数据结构
|
503
|
end
|
43cc5f51
gaofengduan
调整 equip 数据结构
|
504
|
end
|
c59e058b
zhouhaihai
新一批日志记录
|
505
|
|
c59e058b
zhouhaihai
新一批日志记录
|
506
507
508
|
local oldBattleV = hero:getProperty("battleV")
local wear = {}
|
056c01a0
zhouhaihai
简化装备
|
509
510
511
512
|
local curEquip = hero:getProperty("equip")
for typ = 1, 4 do -- 4件装备
if equips[typ] then
local cur = curEquip:getv(typ, 0)
|
ee999bde
zhouhaihai
零件优化
|
513
514
|
if cur ~= equips[typ] then
if equips[typ] == 0 then
|
056c01a0
zhouhaihai
简化装备
|
515
|
curEquip = curEquip:delk(typ)
|
ee999bde
zhouhaihai
零件优化
|
516
|
else
|
3133cb76
zhouhaihai
日志
|
517
|
role:addEquip(typ, equips[typ], -1, {log = {desc = "refer"}}) -- 穿上
|
056c01a0
zhouhaihai
简化装备
|
518
|
curEquip = curEquip:setv(typ, equips[typ])
|
c59e058b
zhouhaihai
新一批日志记录
|
519
520
|
wear[typ] = {id = equips[typ], act = 0}
|
056c01a0
zhouhaihai
简化装备
|
521
|
end
|
ee999bde
zhouhaihai
零件优化
|
522
523
|
if cur ~= 0 then
|
3133cb76
zhouhaihai
日志
|
524
|
role:addEquip(typ, cur, 1, {log = {desc = "refer"}}) -- 脱掉
|
c59e058b
zhouhaihai
新一批日志记录
|
525
526
|
wear[typ] = {id = cur, act = 1}
|
ee999bde
zhouhaihai
零件优化
|
527
|
end
|
43cc5f51
gaofengduan
调整 equip 数据结构
|
528
529
|
end
end
|
43cc5f51
gaofengduan
调整 equip 数据结构
|
530
|
end
|
c59e058b
zhouhaihai
新一批日志记录
|
531
|
|
056c01a0
zhouhaihai
简化装备
|
532
533
534
|
-- 更新角色
hero:updateProperty({field = "equip", value = curEquip})
|
c59e058b
zhouhaihai
新一批日志记录
|
535
|
for typ, data in pairs(wear) do
|
c3a70cde
zhouhaihai
返还
|
536
|
role:log("equip_wear", {
|
c59e058b
zhouhaihai
新一批日志记录
|
537
538
539
540
|
hero_id = hero:getProperty("type"), --英雄ID
equip_id = data.id, --装备ID
equip_wear_action = data.act, --装备操作类型:装备:0,卸载:1
equip_wear_part = typ, --装备部位,记录部位ID
|
9be3f3ea
zhouhaihai
日志需求
|
541
542
|
equip_wear_scorebef = oldBattleV, --装备前英雄评分
equip_wear_score = hero:getProperty("battleV"), --装备后英雄评分
|
c59e058b
zhouhaihai
新一批日志记录
|
543
544
545
|
equip_wear_mode = isAuto and 0 or 1, --用以区分自动装备还是手动装备,自动记录为0,手动记录为1
})
end
|
43cc5f51
gaofengduan
调整 equip 数据结构
|
546
547
548
549
|
SendPacket(actionCodes.Hero_referEquipsRpc, "")
return true
end
|
ee3ac0b5
gaofengduan
fix magic
|
550
551
|
-- typ 位置,uid对应唯一符文,uid为0时为移除,不为0时无则装备,有则替换
function _M.referRunesRpc(agent, data)
|
43cc5f51
gaofengduan
调整 equip 数据结构
|
552
553
554
555
556
557
|
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
|
558
|
|
f52efe51
zhouhaihai
符文升级
|
559
|
local used = {}
|
ee999bde
zhouhaihai
零件优化
|
560
561
562
563
|
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
符文升级
|
564
565
566
567
568
569
570
|
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
|
6b7ee7b1
chenyueqi
铭文替换服务器报错
|
571
|
local roleId = role:getProperty("id")
|
f52efe51
zhouhaihai
符文升级
|
572
|
for cheroId, cIds in pairs(used) do
|
6b7ee7b1
chenyueqi
铭文替换服务器报错
|
573
574
|
local heroId = cheroId % (roleId * MAX_HERO_NUM)
local chero = role.heros[heroId]
|
f52efe51
zhouhaihai
符文升级
|
575
576
577
578
579
|
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
|
580
|
end
|
f52efe51
zhouhaihai
符文升级
|
581
|
chero:updateProperty({field = "rune", value = hrunes})
|
ee3ac0b5
gaofengduan
fix magic
|
582
|
end
|
f52efe51
zhouhaihai
符文升级
|
583
|
|
c59e058b
zhouhaihai
新一批日志记录
|
584
585
586
|
local oldAttr = hero:getTotalAttrs()
local oldBattleV = hero:getProperty("battleV")
local wear = {}
|
ee999bde
zhouhaihai
零件优化
|
587
588
589
590
591
592
593
594
595
596
|
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
穿戴零件
|
597
|
curRune = curRune:setv(typ, runes[typ])
|
c59e058b
zhouhaihai
新一批日志记录
|
598
|
wear[runes[typ]] = typ
|
ee999bde
zhouhaihai
零件优化
|
599
|
end
|
ee3ac0b5
gaofengduan
fix magic
|
600
|
|
ee999bde
zhouhaihai
零件优化
|
601
602
603
604
605
606
|
if cur ~= 0 then
local oldR = role.runeBag[cur]
if oldR then
oldR:updateProperty({field = "refer",value = 0})
end
end
|
ee3ac0b5
gaofengduan
fix magic
|
607
|
end
|
ee3ac0b5
gaofengduan
fix magic
|
608
|
end
|
ee3ac0b5
gaofengduan
fix magic
|
609
|
end
|
c59e058b
zhouhaihai
新一批日志记录
|
610
|
|
4ea1b5ac
zhouhaihai
穿戴零件
|
611
|
hero:updateProperty({field = "rune", value = curRune})
|
c59e058b
zhouhaihai
新一批日志记录
|
612
613
614
615
|
local attrChange = getChangeAttrJson(oldAttr, hero:getTotalAttrs())
for runeId, typ in pairs(wear) do
local ownRune = role.runeBag[runeId]
|
43293781
zhouhaihai
日志bug
|
616
617
618
619
620
621
622
623
624
625
|
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
新一批日志记录
|
626
|
end
|
190e1415
liuzujun
英雄帖活动初始化
|
627
628
|
role:checkTaskEnter("RuneQualityCollect", {})
|
c59e058b
zhouhaihai
新一批日志记录
|
629
|
|
ee3ac0b5
gaofengduan
fix magic
|
630
|
SendPacket(actionCodes.Hero_referRunesRpc, "")
|
43cc5f51
gaofengduan
调整 equip 数据结构
|
631
632
633
|
return true
end
|
3b069d52
zhouhaihai
增加获取 food 后台
|
634
635
636
637
638
639
640
|
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]
|
b8b1c164
liuzujun
扭蛋活动,万能碎片bug
|
641
|
if not cost or role:getItemCount(itemId) < cost then return 1 end
|
3b069d52
zhouhaihai
增加获取 food 后台
|
642
643
|
local randomData = csvdb["item_randomCsv"][tonumber(itemData.use_effect)]
|
b8b1c164
liuzujun
扭蛋活动,万能碎片bug
|
644
|
if not randomData then return 2 end
|
3b069d52
zhouhaihai
增加获取 food 后台
|
645
|
|
007af97e
zhouhaihai
item_random 结构更改
|
646
|
local temp = randomData.gift1:randWeight(true)
|
b8b1c164
liuzujun
扭蛋活动,万能碎片bug
|
647
|
if not temp or not next(temp) then return 3 end
|
7bb30dca
zhouhaihai
修改发奖
|
648
|
|
7cbae6f3
zhangqijia
fix: Role:costIte...
|
649
|
if not role:costItems({[itemId] = cost}, {log = {desc = "createHeroRandom"}}) then return 4 end
|
b8b1c164
liuzujun
扭蛋活动,万能碎片bug
|
650
|
local reward, change = role:award({[temp[1]] = 1}, {log = {desc = "createHeroRandom"}})
|
7bb30dca
zhouhaihai
修改发奖
|
651
652
653
|
SendPacket(actionCodes.Hero_createHeroRandomRpc, MsgPack.pack(role:packReward(reward, change)))
|
3b069d52
zhouhaihai
增加获取 food 后台
|
654
655
656
|
return true
end
|
36482c8b
zhouhaihai
回收养成
|
657
658
659
|
function _M.getResetRewardRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
|
36482c8b
zhouhaihai
回收养成
|
660
661
662
663
664
665
666
|
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")
|
96d591f7
liuzujun
天赋升级修改,增加英雄信赖
|
667
|
local heroCfgId = hero:getProperty("type")
|
36482c8b
zhouhaihai
回收养成
|
668
|
|
782ee57d
liuzujun
多编队功能
|
669
|
local tmpLevel = level
|
36482c8b
zhouhaihai
回收养成
|
670
671
|
if level <= 1 and talent == "" then return end
|
fe296849
liuzujun
归还消耗指定道具或钻石
|
672
|
local pay = true
|
336fa4a6
chenyueqi
新的活动签到,新春三重奏之返还0消耗
|
673
|
if level <= 60 or role.activity:isOpen("HeroBackFree") then
|
782ee57d
liuzujun
多编队功能
|
674
675
676
|
pay = false
end
|
fe296849
liuzujun
归还消耗指定道具或钻石
|
677
678
679
680
681
682
683
684
|
if pay then
local costArr = globalCsv.unit_heroBack_cost:toArray(true, "=")
local itemCount = role:getItemCount(costArr[1])
local totalCost = {}
if itemCount >= costArr[2] then
totalCost[costArr[1]] = costArr[2]
else
local diamond = (costArr[2] - itemCount) * costArr[3]
|
3d8050ef
liuzujun
钻石3改成虹光玉8
|
685
|
if role:getItemCount(ItemId.Jade) < diamond then
|
fe296849
liuzujun
归还消耗指定道具或钻石
|
686
687
688
|
return 1
end
totalCost[costArr[1]] = itemCount
|
3d8050ef
liuzujun
钻石3改成虹光玉8
|
689
|
totalCost[ItemId.Jade] = diamond
|
fe296849
liuzujun
归还消耗指定道具或钻石
|
690
691
692
693
694
|
end
--if pay and not role:costDiamond({count = globalCsv.unit_heroBack_cost or 200, log = {desc = "resetHero", int1 = msg.id}}) then
-- return 1
--end
|
7cbae6f3
zhangqijia
fix: Role:costIte...
|
695
|
if not role:costItems(totalCost, {log = {desc = "resetHero", int1 = msg.id}}) then return 2 end
|
782ee57d
liuzujun
多编队功能
|
696
697
|
end
|
36482c8b
zhouhaihai
回收养成
|
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
|
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)
|
96d591f7
liuzujun
天赋升级修改,增加英雄信赖
|
714
715
|
local curTalentLvl = talent:getv(1, 1)
--local tlevel = {talent:getv(1, 0), talent:getv(2, 0), talent:getv(3, 0), talent:getv(4, 0)}
|
36482c8b
zhouhaihai
回收养成
|
716
|
|
36482c8b
zhouhaihai
回收养成
|
717
|
while stage > 0 do
|
96d591f7
liuzujun
天赋升级修改,增加英雄信赖
|
718
|
local curData = csvdb["unit_talent_"..heroCfgId.."Csv"][stage]
|
0e96d6f4
zhouhaihai
返还bug
|
719
720
|
local offset = stage == talent:getv(0,1) and curTalentLvl - 1 or #curData
for lvl = 1, offset do
|
96d591f7
liuzujun
天赋升级修改,增加英雄信赖
|
721
|
local talentData = curData[lvl]
|
36482c8b
zhouhaihai
回收养成
|
722
|
for itemId, count in pairs(talentData.money:toNumMap()) do
|
96d591f7
liuzujun
天赋升级修改,增加英雄信赖
|
723
|
reward[itemId] = (reward[itemId] or 0) + count
|
36482c8b
zhouhaihai
回收养成
|
724
725
726
|
end
end
stage = stage - 1
|
36482c8b
zhouhaihai
回收养成
|
727
728
|
end
|
c3a70cde
zhouhaihai
返还
|
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
|
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 = "",
})
|
70fb62d1
liuzujun
服务器数据打点
|
749
|
hero:mylog({desc = "resetHero", int1=tmpLevel})
|
782ee57d
liuzujun
多编队功能
|
750
|
|
fe296849
liuzujun
归还消耗指定道具或钻石
|
751
752
|
--local coef = globalCsv.unit_back_discount
--coef = (pay or tmpLevel <= 60) and 1 or coef
|
36482c8b
zhouhaihai
回收养成
|
753
|
for itemId, count in pairs(reward) do
|
fe296849
liuzujun
归还消耗指定道具或钻石
|
754
|
reward[itemId] = count
|
36482c8b
zhouhaihai
回收养成
|
755
|
end
|
7bb30dca
zhouhaihai
修改发奖
|
756
757
|
local change
reward, change = role:award(reward, {log = {desc = "resetHero", int1 = msg.id, int2 = hero:getProperty("type")}})
|
36482c8b
zhouhaihai
回收养成
|
758
|
|
c59e058b
zhouhaihai
新一批日志记录
|
759
|
role:log("hero_recycle", {
|
c3a70cde
zhouhaihai
返还
|
760
|
hero_recycle_list = {[hero:getProperty("type")] = 1}, -- 回收的英雄id列表,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"}
|
887c1843
zhouhaihai
日志新一批
|
761
|
hero_recycle_reward = reward, -- 回收后获得的奖励,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"}
|
c59e058b
zhouhaihai
新一批日志记录
|
762
763
|
hero_recycle_cnt = 1, -- 总回收英雄量
})
|
7bb30dca
zhouhaihai
修改发奖
|
764
|
SendPacket(actionCodes.Hero_getResetRewardRpc, MsgPack.pack(role:packReward(reward, change)))
|
36482c8b
zhouhaihai
回收养成
|
765
766
767
|
return true
end
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
768
769
770
|
function _M.drawHeroRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
|
686d4fd6
liuzujun
兑换活动支持兑换多个, 新增卡池
|
771
|
local actid = msg.actid
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
772
|
|
accf94c4
liuzujun
活动以类型标识,修改双倍活动bug
|
773
|
if not role:isFuncUnlock(FuncUnlock.GetHero) then return 1 end
|
86584add
liuzujun
新手卡池,心愿单卡池
|
774
|
local btype = msg.pool -- 1 2 3 4 5 卡池类型 4新手卡池 5心愿卡池
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
775
776
|
local subType = msg.subType or 1-- 定向卡池需要传 子类型
local drawType = msg.type -- 1 单抽 2 十连
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
777
778
|
if btype ~= 1 then
subType = 1
|
86584add
liuzujun
新手卡池,心愿单卡池
|
779
780
|
if btype == 4 and role:getProperty("newerDraw") >= 10 then
subType = 2
|
de1a55b4
liuzujun
新手卡池限制30抽
|
781
782
783
|
if(role:getProperty("newerDraw") >= 30) then
return 30
end
|
86584add
liuzujun
新手卡池,心愿单卡池
|
784
|
end
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
785
|
end
|
8cd3770f
liuzujun
挂机关卡可以选择,经验金币根据最高...
|
786
|
|
eb5ffd1c
liuzujun
世界boss翻牌奖励 活动卡池保底...
|
787
|
-- 另开活动卡池
|
686d4fd6
liuzujun
兑换活动支持兑换多个, 新增卡池
|
788
789
790
791
792
793
794
795
|
if actid then
if not role.activity:isOpenById(actid, "ActHeroPool") then return end
local cfg = csvdb["activity_ctrlCsv"][actid]
if not cfg then return end
btype = cfg.condition
end
|
8cd3770f
liuzujun
挂机关卡可以选择,经验金币根据最高...
|
796
797
|
if btype == 1 then
-- 判断定向卡池活动开启
|
f7a55da3
liuzujun
新增cb2临时限时礼包
|
798
|
if not role.activity:isOpen("RaceDraw") then
|
8cd3770f
liuzujun
挂机关卡可以选择,经验金币根据最高...
|
799
800
|
return
end
|
686d4fd6
liuzujun
兑换活动支持兑换多个, 新增卡池
|
801
802
803
804
805
806
807
808
809
810
811
812
|
elseif btype == 2 then
if role:getProperty("newerGuide") ~= "8=1" then
-- 判断普通卡池
if role.activity:isOpen("WishHeroPool") then
return
end
end
elseif btype == 5 then
-- 判断心愿单卡池
if not role.activity:isOpen("WishHeroPool") then
return
end
|
8cd3770f
liuzujun
挂机关卡可以选择,经验金币根据最高...
|
813
|
end
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
814
815
|
local buildTypeData = csvdb["build_typeCsv"][btype]
|
accf94c4
liuzujun
活动以类型标识,修改双倍活动bug
|
816
|
if not buildTypeData then return 2 end
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
817
818
|
local drawCount = {1, 10} -- 抽取次数
|
accf94c4
liuzujun
活动以类型标识,修改双倍活动bug
|
819
|
if not drawCount[drawType] then return 3 end
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
820
|
|
bb8c1d57
liuzujun
取消抽卡保底的保底次数默认值,因为...
|
821
|
local draw_floor_back_counts = globalCsv.draw_floor_back_counts[btype]
|
93f6e69b
liuzujun
拾荒选择时间,抽卡增加sr保底
|
822
823
|
local floorHeroCount = role:getProperty("floorHero")[btype] or 0
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
824
825
|
-- 计算抽卡消耗品
local cost = {}
|
51e10199
chenyueqi
招募增加附加奖励
|
826
|
local drawAddReward = {}
|
86584add
liuzujun
新手卡池,心愿单卡池
|
827
828
829
830
831
832
833
834
|
if buildTypeData["draw_coin_1"] == "" then
return 11
end
local diamondCost = buildTypeData["draw_coin_1"]:toArray(true, "=")
local isEnough = true
for _, costType in ipairs({"draw_card_"}) do
costType = costType..drawCount[drawType]
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
835
836
837
|
if buildTypeData[costType] ~= "" then
local curCost = buildTypeData[costType]:toArray(true, "=")
local hadCount = role:getItemCount(curCost[1])
|
86584add
liuzujun
新手卡池,心愿单卡池
|
838
839
|
if hadCount >= curCost[2] then
cost[curCost[1]] = curCost[2]
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
840
|
break
|
86584add
liuzujun
新手卡池,心愿单卡池
|
841
842
843
844
845
846
847
848
|
else
cost[curCost[1]] = hadCount
diamondCost[2] = (curCost[2] - hadCount) * diamondCost[2]
if not role:checkItemEnough({[diamondCost[1]]=diamondCost[2]}) then
isEnough = false
break
end
cost[diamondCost[1]] = diamondCost[2]
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
849
850
851
|
end
end
end
|
86584add
liuzujun
新手卡池,心愿单卡池
|
852
|
if isEnough == false then -- 钱不够
|
accf94c4
liuzujun
活动以类型标识,修改双倍活动bug
|
853
|
return 4
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
854
855
856
857
858
|
end
-- 抽取的池子
local poolMap = buildTypeData["pool"]:toNumMap()
local poolId = poolMap[subType]
|
accf94c4
liuzujun
活动以类型标识,修改双倍活动bug
|
859
|
if not poolId then return 5 end
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
860
861
862
863
864
865
|
--判断定向卡池是否开启
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
|
866
|
return 6
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
867
868
869
870
871
|
end
end
end
--TODO 活动覆盖
|
93f6e69b
liuzujun
拾荒选择时间,抽卡增加sr保底
|
872
873
874
875
|
local actPoolId = role.activity:getActivityPool(btype, subType)
if actPoolId ~= 0 then
poolId = actPoolId
end
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
876
877
|
local unitPool = csvdb["build_unitCsv"][poolId]
|
accf94c4
liuzujun
活动以类型标识,修改双倍活动bug
|
878
|
if not unitPool then return 7 end
|
78139af8
liuzujun
ssr增加硬性保底
|
879
880
|
-- ssr硬性保底
local isSSRup = false
|
6f2c24ed
liuzujun
友情池bug
|
881
|
if (unitPool["rare_"..HeroQuality.SSR] or 0) > 0 then
|
78139af8
liuzujun
ssr增加硬性保底
|
882
883
|
isSSRup = true
end
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
884
885
886
|
-- 开始抽
local resultPool = {}
|
93f6e69b
liuzujun
拾荒选择时间,抽卡增加sr保底
|
887
|
local function fillDrawPool(isFloorBack)
|
accf94c4
liuzujun
活动以类型标识,修改双倍活动bug
|
888
|
local condition = {"rare"}
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
889
890
|
local values = {}
|
78139af8
liuzujun
ssr增加硬性保底
|
891
|
-- check ssr up
|
6f2c24ed
liuzujun
友情池bug
|
892
893
894
895
|
local ssrUpMap = role:getProperty("ssrUp") or {}
local ssrFloorCnt = ssrUpMap[poolId] or 0
if isSSRup and (ssrFloorCnt >= (globalCsv.draw_ssr_guarantee or 40) - 1) then
--if ssrFloorCnt >= (globalCsv.draw_ssr_guarantee or 40) - 1 then
|
78139af8
liuzujun
ssr增加硬性保底
|
896
897
|
values[1] = HeroQuality.SSR
ssrUpMap[poolId] = 0
|
6f2c24ed
liuzujun
友情池bug
|
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
|
--else
-- 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
-- if values[1] == HeroQuality.SSR then
-- ssrUpMap[poolId] = 0
-- else
-- ssrUpMap[poolId] = ssrFloorCnt + 1
-- end
--end
role:updateProperty({field="ssrUp", value = ssrUpMap, notNotify = true})
else
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)
|
78139af8
liuzujun
ssr增加硬性保底
|
932
933
|
end
end
|
6f2c24ed
liuzujun
友情池bug
|
934
935
|
end
if isSSRup then
|
78139af8
liuzujun
ssr增加硬性保底
|
936
937
938
939
940
|
if values[1] == HeroQuality.SSR then
ssrUpMap[poolId] = 0
else
ssrUpMap[poolId] = ssrFloorCnt + 1
end
|
6f2c24ed
liuzujun
友情池bug
|
941
|
role:updateProperty({field="ssrUp", value = ssrUpMap, notNotify = true})
|
78139af8
liuzujun
ssr增加硬性保底
|
942
|
end
|
78139af8
liuzujun
ssr增加硬性保底
|
943
|
end
|
93f6e69b
liuzujun
拾荒选择时间,抽卡增加sr保底
|
944
|
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
945
|
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
946
|
|
4839b94d
liuzujun
增加抽卡英雄up
|
947
948
949
950
951
952
953
954
955
|
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"]
|
aa4838cb
liuzujun
心愿卡池根据心愿单英雄数量调整概率
|
956
957
958
959
|
if btype == 5 then
local wishPool = role:getProperty("wishPool") or {}
weight = weight * #wishPool
end
|
4839b94d
liuzujun
增加抽卡英雄up
|
960
961
962
963
|
end
--print(poolId, rand_v, weight, up_pool, values[1])
if rand_v < weight and up_pool then
up_pool = up_pool:toArray(true, "=")
|
86584add
liuzujun
新手卡池,心愿单卡池
|
964
965
966
|
if btype == 5 then -- 爱心卡池,使用玩家设置的备选池子
up_pool = role:getProperty("wishPool")
end
|
4839b94d
liuzujun
增加抽卡英雄up
|
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
|
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连保底使用池子全随机
|
985
|
end
|
43611d57
liuzujun
抽卡up失败走全随机,随机池把up...
|
986
|
-- 随机剔除up池中的角色
|
064ca715
liuzujun
抽卡up_pool判空
|
987
988
989
990
991
992
|
if up_pool then
for k, v in ipairs(up_pool) do
if v == itemData.id then
ok = false
break
end
|
43611d57
liuzujun
抽卡up失败走全随机,随机池把up...
|
993
994
|
end
end
|
4839b94d
liuzujun
增加抽卡英雄up
|
995
996
997
998
999
|
if not ok then break end
if oneData[pool_str] > 0 then
resultPool[itemId] = {oneData[pool_str]} -- itemId, count, 概率
end
break
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
1000
|
end
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
1001
1002
1003
1004
1005
|
end
end
end
end
|
7cbae6f3
zhangqijia
fix: Role:costIte...
|
1006
|
if not role:costItems(cost, {log = {desc = "drawHero", int1 = btype, int2 = poolId}}) then return 7 end
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
1007
|
|
00bf6029
liuzujun
限时礼包,抽卡ssr广播
|
1008
|
local guideHero = nil
|
a5b98c30
chenyueqi
引导调整
|
1009
1010
|
if role:getProperty("newerGuide") == "8=1" then
guideHero = globalCsv.newdraw_hero_item_id or 503
|
16f5fa68
chenyueqi
引导招募的引导改动被回退
|
1011
1012
|
end
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
1013
1014
|
local ssrCount = 0
local reward = {}
|
37bb4611
liuzujun
付费签到,抽卡阶段奖励,探索指令
|
1015
|
local logReward = {}
|
7113ad0c
liuzujun
每日抽卡次数触发礼包
|
1016
1017
|
-- 限时礼包
local dailyDrawCnt = role.dailyData:getProperty("drawHeroCnt") or 0
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
1018
|
for i = 1, drawCount[drawType] do
|
93f6e69b
liuzujun
拾荒选择时间,抽卡增加sr保底
|
1019
1020
|
floorHeroCount = floorHeroCount + 1
local isFloorBack = draw_floor_back_counts and floorHeroCount >= draw_floor_back_counts
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
1021
|
resultPool = {}
|
93f6e69b
liuzujun
拾荒选择时间,抽卡增加sr保底
|
1022
1023
1024
|
fillDrawPool(isFloorBack)
if not next(resultPool) then
skynet.error("random pool error, poolId:" .. poolId)
|
accf94c4
liuzujun
活动以类型标识,修改双倍活动bug
|
1025
|
return 8
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
1026
1027
|
end
|
16f5fa68
chenyueqi
引导招募的引导改动被回退
|
1028
1029
1030
|
local itemId = math.randWeight(resultPool, 1)
if guideHero then
itemId = guideHero
|
7125137e
chenyueqi
手抽英雄只奖励一个
|
1031
|
guideHero = nil
|
16f5fa68
chenyueqi
引导招募的引导改动被回退
|
1032
1033
|
end
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
1034
1035
1036
|
local itemData = csvdb["itemCsv"][itemId]
if itemData.quality == HeroQuality.SSR then
ssrCount = ssrCount + 1
|
00bf6029
liuzujun
限时礼包,抽卡ssr广播
|
1037
|
if not guideHero then
|
4839b94d
liuzujun
增加抽卡英雄up
|
1038
|
-- 广播获得ssr英雄
|
00bf6029
liuzujun
限时礼包,抽卡ssr广播
|
1039
1040
|
local ntf = {heroId = itemData.id - ItemStartId.Hero, nick = role:getProperty("name")}
mcast_util.pub_world(actionCodes.Role_broadGetSSR, MsgPack.pack(ntf))
|
850c54f5
liuzujun
抽卡概率明示相关
|
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
|
local record = {}
record["uid"] = role:getProperty("uid")
record["serverId"] = skynet.getenv("servId")
local function userNick(name)
local t = {}
local index = 0
for _, v in utf8.codes(name) do
if index == 0 then
table.insert(t, utf8.char(v))
else
table.insert(t, '*')
end
index = index + 1
end
return table.concat(t, '')
end
record["nick"] = userNick(role:getProperty("name"))
record["hero"] = itemData.name
record["quality"] = itemData.quality
|
54bd82e3
zhangqijia
fix: 修复 查询抽奖ssr记录...
|
1062
|
redisproxy:lpush("drawHeroRecord", MsgPack.pack(record))
|
e4814423
zhangqijia
fix: 修复 ltrim调用问题
|
1063
|
redisproxy:ltrim("drawHeroRecord", 0, 10000)
|
00bf6029
liuzujun
限时礼包,抽卡ssr广播
|
1064
|
end
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
1065
1066
|
end
|
86584add
liuzujun
新手卡池,心愿单卡池
|
1067
1068
1069
1070
1071
1072
1073
1074
|
if btype == 4 and role:getProperty("newerDraw") == 0 then -- 新手卡池
if itemData.quality == HeroQuality.SSR then
floorHeroCount = 0
end
else
if itemData.quality >= HeroQuality.SR then
floorHeroCount = 0
end
|
93f6e69b
liuzujun
拾荒选择时间,抽卡增加sr保底
|
1075
1076
|
end
|
e84a1beb
liuzujun
gm后台查询日志,公告相关协议
|
1077
|
local itemCount = 1
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
1078
1079
1080
1081
|
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]
|
70fb62d1
liuzujun
服务器数据打点
|
1082
|
role:award({[fragId] = count}, {log = {desc = "drawHero", int1 = btype, int2 = poolId, short1=isFloorBack and 1 or 0}})
|
b5481708
zhouhaihai
保底日志
|
1083
|
logReward[fragId] = (logReward[fragId] or 0) + count
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
1084
|
table.insert(reward, {id = fragId, count = count, from = itemId, fcount = 1})
|
e84a1beb
liuzujun
gm后台查询日志,公告相关协议
|
1085
|
itemCount = count
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
1086
|
else
|
70fb62d1
liuzujun
服务器数据打点
|
1087
|
role:award({[itemId] = 1}, {log = {desc = "drawHero", int1 = btype, int2 = poolId, short1=isFloorBack and 1 or 0}})
|
b5481708
zhouhaihai
保底日志
|
1088
|
logReward[itemId] = (logReward[itemId] or 0) + 1
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
1089
1090
|
table.insert(reward, {id = itemId, count = 1})
end
|
7113ad0c
liuzujun
每日抽卡次数触发礼包
|
1091
|
|
51e10199
chenyueqi
招募增加附加奖励
|
1092
1093
1094
1095
1096
1097
|
-- 招募得到的英雄追加奖励
local unitData = csvdb["unitCsv"][itemData.id - ItemStartId.Hero]
if unitData.build_award ~= "" then
for tId, tCount in pairs(unitData.build_award:toNumMap()) do
drawAddReward[tId] = (drawAddReward[tId] or 0) + tCount
end
|
51e10199
chenyueqi
招募增加附加奖励
|
1098
1099
1100
|
end
--
|
7113ad0c
liuzujun
每日抽卡次数触发礼包
|
1101
1102
|
dailyDrawCnt = dailyDrawCnt + 1
role:checkTaskEnter("DrawHeroLimitPack", {count = dailyDrawCnt})
|
e84a1beb
liuzujun
gm后台查询日志,公告相关协议
|
1103
1104
1105
1106
|
local ssrUpMap = role:getProperty("ssrUp") or {}
local ssrFloorCnt = ssrUpMap[poolId] or 0
role:mylog("hero_action", {desc = "drawHero", int1=poolId, int2=btype, short1 = drawCount[drawType], cint1 = ssrFloorCnt, cint2 = itemId, cint3 = itemCount})
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
1107
1108
|
end
|
36f26bdb
chenyueqi
招募附赠奖励代码移到for循环外
|
1109
|
role:award(drawAddReward, {log = {desc = "drawHero", int1 = btype}})
|
7113ad0c
liuzujun
每日抽卡次数触发礼包
|
1110
1111
|
role.dailyData:setProperty("drawHeroCnt", dailyDrawCnt)
|
93f6e69b
liuzujun
拾荒选择时间,抽卡增加sr保底
|
1112
1113
1114
1115
1116
1117
|
if draw_floor_back_counts then
local floorHero = role:getProperty("floorHero")
floorHero[btype] = floorHeroCount
role:setProperty("floorHero", floorHero)
end
|
86584add
liuzujun
新手卡池,心愿单卡池
|
1118
1119
1120
1121
1122
|
if btype == 4 then
local newCount = role:getProperty("newerDraw")
role:updateProperty({field="newerDraw", value = newCount + drawCount[drawType]})
end
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
1123
|
role:checkTaskEnter("DrawHero", {pool = btype, count = drawCount[drawType]})
|
dfa9ae5e
liuzujun
战令任务活动
|
1124
1125
1126
|
if btype ~= 3 then
role:checkTaskEnter("DrawHeroNotFriend", {pool = btype, count = drawCount[drawType]})
end
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
1127
1128
1129
|
if ssrCount > 0 then
role:checkTaskEnter("DrawSSR", {count = ssrCount})
end
|
a5b98c30
chenyueqi
引导调整
|
1130
|
role:finishGuide(8)
|
b5481708
zhouhaihai
保底日志
|
1131
|
|
69525ba2
zhangqijia
feat: 每次抽卡获得对应货币
|
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
|
--每次抽卡获得对应货币,可在招募商城购买道具
if buildTypeData["draw_type_item"] ~= 0 then
local drawTypeItem = {}
for id, count in pairs(buildTypeData["draw_type_item"]:toNumMap()) do
drawTypeItem[id] = count * drawCount[drawType]
drawAddReward[id] = drawTypeItem[id]
end
role:award(drawTypeItem, {log = {desc = "drawHero", int1 = btype}})
end
|
c59e058b
zhouhaihai
新一批日志记录
|
1142
1143
1144
1145
1146
|
role:log("gacha", {
gacha_id = poolId, -- 卡池ID
gacha_type = btype, -- 卡池类型
gacha_up = 0, -- 卡池UP角色
gacha_times = drawCount[drawType], -- 抽卡次数
|
b5481708
zhouhaihai
保底日志
|
1147
|
gacha_reward = logReward, -- 抽卡结果,建议使用json格式记录。示例:{ "XX": "1", "XXX": "3"}
|
9be3f3ea
zhouhaihai
日志需求
|
1148
|
gacha_cost = cost, -- 购买道具消耗的货币
|
b5481708
zhouhaihai
保底日志
|
1149
|
gacha_cnt = floorHeroCount,
|
c59e058b
zhouhaihai
新一批日志记录
|
1150
|
})
|
70fb62d1
liuzujun
服务器数据打点
|
1151
|
|
e84a1beb
liuzujun
gm后台查询日志,公告相关协议
|
1152
|
--role:mylog("hero_action", {desc = "drawHero", int1=poolId, int2=btype, short1 = drawCount[drawType]})
|
51e10199
chenyueqi
招募增加附加奖励
|
1153
|
SendPacket(actionCodes.Hero_drawHeroRpc, MsgPack.pack({reward = reward, subReward = drawAddReward})) -- 这个 reward 是数组
|
37bb4611
liuzujun
付费签到,抽卡阶段奖励,探索指令
|
1154
|
|
eb5ffd1c
liuzujun
世界boss翻牌奖励 活动卡池保底...
|
1155
|
local feedbackId = buildTypeData["can_feedback"] or 0
|
6857a37f
liuzujun
世界Boss 增加行动点
|
1156
|
if feedbackId ~= 0 then
|
37bb4611
liuzujun
付费签到,抽卡阶段奖励,探索指令
|
1157
1158
|
-- 达到一定次数,给响应奖励
local oldVal = role:getProperty("repayHero") or 0
|
eb5ffd1c
liuzujun
世界boss翻牌奖励 活动卡池保底...
|
1159
1160
|
if actid then
local actData = role.activity:getActData("ActHeroPool")
|
6857a37f
liuzujun
世界Boss 增加行动点
|
1161
|
oldVal = actData[btype] or 0
|
eb5ffd1c
liuzujun
世界boss翻牌奖励 活动卡池保底...
|
1162
|
end
|
37bb4611
liuzujun
付费签到,抽卡阶段奖励,探索指令
|
1163
|
local newVal = oldVal + drawCount[drawType]
|
eb5ffd1c
liuzujun
世界boss翻牌奖励 活动卡池保底...
|
1164
|
local drawCardReward, val = role:getDrawCardExtraReward(feedbackId, oldVal, newVal)
|
37bb4611
liuzujun
付费签到,抽卡阶段奖励,探索指令
|
1165
1166
|
-- 空字符穿代表直接给英雄 走以前repayHeroRpc
if drawCardReward == "" then
|
c8d4058c
liuzujun
保底机制修改,200次出未拥有的永雄
|
1167
1168
1169
1170
1171
1172
1173
|
local repayHeroMaxCount = role:getProperty("repayMaxC") or 0
repayHeroMaxCount = repayHeroMaxCount + 1
role:updateProperty({field = "repayMaxC", value = repayHeroMaxCount})
local even = repayHeroMaxCount % 2
local id = 0
if even == 1 then
|
c8c76cda
liuzujun
活动卡池保底出指定英雄
|
1174
|
id = math.randWeight(csvdb["build_giftCsv"], "pool_"..feedbackId)
|
c8d4058c
liuzujun
保底机制修改,200次出未拥有的永雄
|
1175
1176
1177
|
else
local giftHeroSet = {}
for gid, cfg in pairs(csvdb["build_giftCsv"]) do
|
eb5ffd1c
liuzujun
世界boss翻牌奖励 活动卡池保底...
|
1178
|
if cfg["pool_"..feedbackId] ~= 0 and not role:isHaveHero(gid - ItemStartId.Hero) then
|
c8d4058c
liuzujun
保底机制修改,200次出未拥有的永雄
|
1179
1180
1181
1182
1183
1184
1185
1186
|
giftHeroSet[gid] = {1}
end
end
if next(giftHeroSet) then
id = math.randWeight(giftHeroSet, 1)
end
end
if id == 0 then
|
c8c76cda
liuzujun
活动卡池保底出指定英雄
|
1187
|
id = math.randWeight(csvdb["build_giftCsv"], "pool_"..feedbackId)
|
c8d4058c
liuzujun
保底机制修改,200次出未拥有的永雄
|
1188
|
end
|
37bb4611
liuzujun
付费签到,抽卡阶段奖励,探索指令
|
1189
|
|
e0290d8e
liuzujun
修改引导, 抽卡阶段奖励修改
|
1190
|
local r,change = {}
|
37bb4611
liuzujun
付费签到,抽卡阶段奖励,探索指令
|
1191
|
local itemData = csvdb["itemCsv"][id]
|
e0290d8e
liuzujun
修改引导, 抽卡阶段奖励修改
|
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
|
--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
付费签到,抽卡阶段奖励,探索指令
|
1202
|
elseif drawCardReward and drawCardReward ~= "" then
|
ceef9d00
liuzujun
抽卡50次保底英雄转换碎片bug
|
1203
1204
1205
|
local r,change = {}
r, change = role:award(drawCardReward, {log = {desc = "drawHeroExtraReward", int1 = oldVal, int2 = newVal}})
SendPacket(actionCodes.Hero_drawHeroExtraRewardNtf, MsgPack.pack(role:packReward(r, change)))
|
37bb4611
liuzujun
付费签到,抽卡阶段奖励,探索指令
|
1206
|
end
|
eb5ffd1c
liuzujun
世界boss翻牌奖励 活动卡池保底...
|
1207
1208
1209
1210
1211
1212
1213
|
if not actid then
role:updateProperty({field = "repayHero", value = val})
else
local actData = role.activity:getActData("ActHeroPool")
actData[btype] = val
role.activity:updateActData("ActHeroPool", actData)
end
|
37bb4611
liuzujun
付费签到,抽卡阶段奖励,探索指令
|
1214
|
end
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
1215
1216
1217
|
return true
end
|
317a46a9
liuzujun
添加特权卡
|
1218
1219
|
function _M.repayHeroRpc(agent, data)
local role = agent.role
|
a35233c6
zhouhaihai
保底和回馈
|
1220
|
|
317a46a9
liuzujun
添加特权卡
|
1221
|
local repayHero = role:getProperty("repayHero")
|
fb3d084d
liuzujun
月卡赛季卡发送邮件奖励
|
1222
1223
|
local cnt = globalCsv.draw_times_to_get_ssr or 100
if repayHero < cnt then
|
317a46a9
liuzujun
添加特权卡
|
1224
1225
|
return
end
|
fb3d084d
liuzujun
月卡赛季卡发送邮件奖励
|
1226
|
local result = repayHero - cnt
|
a35233c6
zhouhaihai
保底和回馈
|
1227
|
|
317a46a9
liuzujun
添加特权卡
|
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
|
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
自己的日志
|
1243
|
role:mylog("hero_action", {desc = "heroRepay", int1=result})
|
317a46a9
liuzujun
添加特权卡
|
1244
1245
1246
|
SendPacket(actionCodes.Hero_repayHeroRpc, MsgPack.pack({reward = reward}))
return true
end
|
a35233c6
zhouhaihai
保底和回馈
|
1247
|
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
|
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
删除无用日志
|
1266
|
if not role:costDiamond({count = globalCsv.draw_unlock_pool_diamond or 300, log = {desc = "unlockPool", int1 = type}}) then
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
1267
1268
1269
1270
1271
1272
1273
1274
|
return
end
end
unlockPool[type] = 1
role.dailyData:updateProperty({field="unlockPool", value = unlockPool})
role.dailyData:updateProperty({field="curPool", value = type})
|
f22a33af
zhouhaihai
自己的日志
|
1275
|
role:mylog("hero_action", {desc = "unlockPool", int1=type})
|
1a0b3c56
liuzujun
抽卡保底,切换定向卡池
|
1276
1277
1278
1279
|
SendPacket(actionCodes.Hero_unlockPoolRpc, MsgPack.pack({}))
return true
end
|
51d9d20b
liuzujun
付费签到,应用市场反馈
|
1280
|
function _M.changeCrown(agent, data)
|
c59e058b
zhouhaihai
新一批日志记录
|
1281
1282
1283
1284
1285
|
local role = agent.role
local msg = MsgPack.unpack(data)
local heroType = msg.heroType
|
866852ff
chenyueqi
主城看板有可能是story cg id
|
1286
|
if heroType < 10000 and not role:isHaveHero(heroType) then return true end
|
c59e058b
zhouhaihai
新一批日志记录
|
1287
1288
1289
1290
1291
|
role:setProperty("crown", heroType)
role:log("hero_show", {
hero_id = heroType,
})
|
c59e058b
zhouhaihai
新一批日志记录
|
1292
1293
1294
|
return true
end
|
16634605
liuzujun
多队挂机,天赋道具合成
|
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
|
function _M.itemComposeRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
local itemId = msg.id
local count = msg.count
if not csvdb["itemCsv"][itemId] then return 1 end
local config = csvdb["item_processCsv"][itemId]
if not config then return 2 end
local cost = config.cost:toNumMap()
|
cd949029
liuzujun
合成道具数量不对bug
|
1306
1307
1308
|
for k, v in pairs(cost) do
cost[k] = v * count
end
|
16634605
liuzujun
多队挂机,天赋道具合成
|
1309
|
if not role:checkItemEnough(cost) then return 2 end
|
7cbae6f3
zhangqijia
fix: Role:costIte...
|
1310
|
if not role:costItems(cost, {log = {desc = "itemCompose", int1 = itemId, int2 = count}}) then return 3 end
|
16634605
liuzujun
多队挂机,天赋道具合成
|
1311
1312
1313
1314
1315
1316
|
role:award({[itemId] = count}, {log = {desc = "itemCompose"}})
SendPacket(actionCodes.Hero_itemComposeRpc, "")
return true
end
|
86584add
liuzujun
新手卡池,心愿单卡池
|
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
|
function _M.setWishPoolRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
local heros = msg.heros
if #heros > 3 then return 1 end
for _, heroId in pairs(heros) do
local cfg = csvdb["build_poolCsv"][heroId]
if not cfg then return 2 end
local buildTypeData = csvdb["build_typeCsv"][5]
if not buildTypeData then return 3 end
local poolMap = buildTypeData["pool"]:toNumMap()
local poolId = poolMap[1]
if not poolId then return 4 end
if cfg["pool_"..poolId] == 0 then
return 5
end
end
role:updateProperty({field="wishPool", value = heros})
SendPacket(actionCodes.Hero_setWishPoolRpc, "")
return true
end
|
3d8468b2
liuzujun
火花系统
|
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
|
function _M.changeSparkRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
local idx = msg.index
local sparkId = msg.spark_id
local heroId = msg.hero_id
local hero = role.heros[heroId]
if not hero then return 1 end
local spark = role.sparkBag[sparkId]
if not spark then return 2 end
local lvl = spark:getProperty("level")
local cfgId = spark:getProperty("cfg_id")
local dataSet = csvdb["sparkCsv"][cfgId]
if not dataSet then return 3 end
local cfg = dataSet[lvl]
if not cfg then return 4 end
if hero:getProperty("wakeL") < cfg.star then return 5 end
local itemCfg = csvdb["itemCsv"][cfgId]
if not itemCfg then return 6 end
if itemCfg.quality ~= hero:getRare() then return 6 end
local sparkList = hero:getProperty("spark") or {}
local oldSparkInfo = sparkList[idx] or {}
sparkList[idx] = spark:data()
hero:updateProperty({field="spark", value=sparkList})
role:delSparks({sparkId}, {log = {desc = "changeSpark"}})
local oldId = oldSparkInfo["cfg_id"] or 0
local oldLevel = oldSparkInfo["level"] or 0
local oldSparkSet = csvdb["sparkCsv"][oldId]
|
3d8468b2
liuzujun
火花系统
|
1381
1382
1383
|
local reward = {}
if oldSparkSet then
local oldSparkCfg = oldSparkSet[oldLevel]
|
3d8468b2
liuzujun
火花系统
|
1384
1385
1386
1387
|
if oldSparkSet then
reward = oldSparkCfg.back:toNumMap()
end
end
|
3d8468b2
liuzujun
火花系统
|
1388
|
|
37f8fb69
zhangqijia
fix: 修复点燃火花获得的奖励未...
|
1389
1390
1391
1392
1393
|
local change = {}
if next(reward) then
reward, change = role:award(reward, {log = {desc = "changeSpark"}})
end
SendPacket(actionCodes.Hero_changeSparkRpc, MsgPack.pack(role:packReward(reward, change)))
|
3d8468b2
liuzujun
火花系统
|
1394
1395
1396
|
return true
end
|
659fe200
zhangqijia
feat: 天赋点
|
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
|
function _M.saveGeniusTreeRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
local awake = msg.awake
local wakeL = msg.wakeL
local heroId = msg.hero_id
local hero = role.heros[tonumber(heroId)]
if not hero then print("hero is nil") return 0 end
|
6aedd904
chenyueqi
判断觉醒技能所在的觉醒等级不能大于...
|
1407
|
|
6cb24616
chenyueqi
重置突破等级的时候不判断突破等级合法
|
1408
|
if wakeL and wakeL > hero:getProperty("wakeL") then return 1 end
|
6aedd904
chenyueqi
判断觉醒技能所在的觉醒等级不能大于...
|
1409
|
|
659fe200
zhangqijia
feat: 天赋点
|
1410
1411
1412
1413
1414
|
local genius = hero:saveGeniusTree(wakeL, awake)
if #genius == 0 then
genius = ""
end
hero:updateProperty({field="genius", value=genius})
|
659fe200
zhangqijia
feat: 天赋点
|
1415
1416
1417
1418
|
SendPacket(actionCodes.Hero_saveGeniusTreeRpc, MsgPack.pack({genius = genius}))
return true
end
|
3ad19fe4
zhangqijia
feat: 贴纸兑换功能
|
1419
1420
1421
1422
1423
1424
|
function _M.stickersConvertRpc(agent, data)
local role = agent.role
local msg = MsgPack.unpack(data)
local itemId = msg.itemId
local heroType = msg.heroType -- heroId-300 举例 [泡泡]= {[heroType] = 120, [heroId]= 420}
|
d63519df
zhangqijia
fix: 贴纸兑换 修复 item...
|
1425
|
local itemData = csvdb["itemCsv"][itemId]
|
3ad19fe4
zhangqijia
feat: 贴纸兑换功能
|
1426
1427
1428
1429
1430
1431
1432
1433
1434
|
if not itemData then return 1 end
local useEffect = itemData["use_effect"]:toNumMap()
if not useEffect[heroType] then return 2 end
if not role:isHaveHero(heroType) then return 3 end
local cost = {[itemId] = 1}
if not role:checkItemEnough(cost) then return 4 end
|
7cbae6f3
zhangqijia
fix: Role:costIte...
|
1435
|
if not role:costItems({[heroType] = cost}, {log = {desc = "heroStickers"}}) then return 5 end
|
3ad19fe4
zhangqijia
feat: 贴纸兑换功能
|
1436
1437
1438
1439
1440
1441
|
local reward, change = role:award({[heroType] = 1}, {log = {desc = "heroStickers"}})
SendPacket(actionCodes.Hero_stickersConvertRpc, MsgPack.pack(role:packReward(reward, change)))
return true
end
|
1af7ada5
liuzujun
fix confict
|
1442
|
return _M
|