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
18
19
20 
 | 
  
  local _M = {}
  function _M.levelUpRpc( agent, data )
  	local role = agent.role
  	local msg = MsgPack.unpack(data)
 
 | 
1c35c4cf
 
  gaofengduan
 
fix hero awake
 | 
21 
 | 
  	print("msg.id "..msg.id)
 
 | 
0a07bdd9
 
  zhouahaihai
 
角色升级 。gm
 | 
22 
 | 
  	local hero = role.heros[msg.id]
 
 | 
1c35c4cf
 
  gaofengduan
 
fix hero awake
 | 
23 
 | 
  	if not hero then return 1 end
 
 | 
0a07bdd9
 
  zhouahaihai
 
角色升级 。gm
 | 
24 
 | 
  
 
 | 
1c35c4cf
 
  gaofengduan
 
fix hero awake
 | 
25 
 | 
  	if hero:getProperty("level") >= hero:getMaxLevel() then return 2 end
 
 | 
8c74292c
 
  zhouahaihai
 
增加item 以及 角色突破
 | 
26 
 | 
  	local curData = csvdb["unit_expCsv"][hero:getProperty("level")]
 
 | 
997cbdfe
 
  zhouahaihai
 
技能养成
 | 
27 
 | 
  	local cost = {[ItemId.Exp] = curData.exp, [ItemId.Gold] = curData.gold}
 
 | 
1c35c4cf
 
  gaofengduan
 
fix hero awake
 | 
28 
 | 
  	if not role:checkItemEnough(cost) then return 3 end
 
 | 
36204e3c
 
  zhengshouren
 
贩卖逻辑
 | 
29 
 | 
  	role:costItems(cost)
 
 | 
0a07bdd9
 
  zhouahaihai
 
角色升级 。gm
 | 
30 
 | 
  	hero:updateProperty({field = "level", delta = 1})
 
 | 
1c35c4cf
 
  gaofengduan
 
fix hero awake
 | 
31 
 | 
  
 
 | 
0a07bdd9
 
  zhouahaihai
 
角色升级 。gm
 | 
32
33
34
35 
 | 
  	SendPacket(actionCodes.Hero_levelUpRpc, '')
  	return true
  end
  
 
 | 
8c74292c
 
  zhouahaihai
 
增加item 以及 角色突破
 | 
36
37
38
39 
 | 
  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
 | 
40 
 | 
  	if not hero then return 1 end
 
 | 
8c74292c
 
  zhouahaihai
 
增加item 以及 角色突破
 | 
41 
 | 
  
 
 | 
1c35c4cf
 
  gaofengduan
 
fix hero awake
 | 
42
43 
 | 
  	if hero:getProperty("level") < hero:getMaxLevel() then return 2 end
  	if hero:getProperty("breakL") >= #csvdb["unit_breakCsv"] then return 3 end
 
 | 
8c74292c
 
  zhouahaihai
 
增加item 以及 角色突破
 | 
44 
 | 
  	local curData = csvdb["unit_breakCsv"][hero:getProperty("breakL")]
 
 | 
997cbdfe
 
  zhouahaihai
 
技能养成
 | 
45 
 | 
  	local cost = {[ItemId.BreakCost] = curData.cost, [ItemId.Gold] = curData.gold}
 
 | 
1c35c4cf
 
  gaofengduan
 
fix hero awake
 | 
46 
 | 
  	if not role:checkItemEnough(cost) then return 4 end
 
 | 
36204e3c
 
  zhengshouren
 
贩卖逻辑
 | 
47 
 | 
  	role:costItems(cost)
 
 | 
8c74292c
 
  zhouahaihai
 
增加item 以及 角色突破
 | 
48 
 | 
  	hero:updateProperty({field = "breakL", delta = 1})
 
 | 
1c35c4cf
 
  gaofengduan
 
fix hero awake
 | 
49 
 | 
  
 
 | 
8c74292c
 
  zhouahaihai
 
增加item 以及 角色突破
 | 
50
51
52 
 | 
  	SendPacket(actionCodes.Hero_breakRpc, '')
  	return true
  end
 
 | 
0a07bdd9
 
  zhouahaihai
 
角色升级 。gm
 | 
53 
 | 
  
 
 | 
997cbdfe
 
  zhouahaihai
 
技能养成
 | 
54
55
56
57 
 | 
  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
 | 
58
59
60
61
62
63
64
65
66 
 | 
  	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
  
  	local cost = {[typ] = wakeData.costFigment,[hero:getStampId()] = wakeData.costMaterial}
  	if not role:checkItemEnough(cost) then
  		return 4
 
 | 
997cbdfe
 
  zhouahaihai
 
技能养成
 | 
67 
 | 
  	end
 
 | 
1c35c4cf
 
  gaofengduan
 
fix hero awake
 | 
68
69
70
71 
 | 
  
  	local skills = {}
  	for _,v in pairs(wakeData.skill:toArray(true,"=") ) do
  		local skillSet = hero:getSkillData(v)
 
 | 
00e663bd
 
  zhouhaihai
 
剧情相关
 | 
72 
 | 
  		if skillSet and next(skillSet) then
 
 | 
1c35c4cf
 
  gaofengduan
 
fix hero awake
 | 
73
74
75
76
77
78
79
80
81
82 
 | 
  			local skillLv = hero:getSkillLevel(v)+1
  			local skillData = skillSet[skillLv]
  			if skillData and next(skillData) then
  				skills[v] = skillLv
  			else
  				return 5
  			end
  		end
  	end
  
 
 | 
36204e3c
 
  zhengshouren
 
贩卖逻辑
 | 
83 
 | 
  	role:costItems(cost)
 
 | 
1c35c4cf
 
  gaofengduan
 
fix hero awake
 | 
84
85
86 
 | 
  	for k,v in pairs(skills) do
  		hero:updateProperty({field = "skillL", value = hero:getProperty("skillL"):setv(k, v)})
  	end
 
 | 
997cbdfe
 
  zhouahaihai
 
技能养成
 | 
87
88 
 | 
  	hero:updateProperty({field = "wakeL", delta = 1})
  
 
 | 
00e663bd
 
  zhouhaihai
 
剧情相关
 | 
89
90 
 | 
  	role:checkTaskEnter(role.TaskType.Wake, {heroType = typ, wakeL = hero:getProperty("wakeL")})
  
 
 | 
997cbdfe
 
  zhouahaihai
 
技能养成
 | 
91
92
93
94 
 | 
  	SendPacket(actionCodes.Hero_wakeRpc, '')
  	return true
  end
  
 
 | 
1c35c4cf
 
  gaofengduan
 
fix hero awake
 | 
95 
 | 
  -- 已取消技能升级功能,觉醒时自动升级技能
 
 | 
997cbdfe
 
  zhouahaihai
 
技能养成
 | 
96
97
98 
 | 
  function _M.skillUpRpc(agent, data)
  	local role = agent.role
  	local msg = MsgPack.unpack(data)
 
 | 
1c35c4cf
 
  gaofengduan
 
fix hero awake
 | 
99 
 | 
  	local index = msg.skillIdx -- 第几个技能 -- 1  2  3
 
 | 
997cbdfe
 
  zhouahaihai
 
技能养成
 | 
100
101
102 
 | 
  	local hero = role.heros[msg.id]
  	if not hero then return end
  	local curLevel = hero:getSkillLevel(index)
 
 | 
a22cbe63
 
  zhouahaihai
 
bug
 | 
103 
 | 
  	if hero:getLSPoint() <= 0 or curLevel >= #hero:getSkillData(index) then return end
 
 | 
997cbdfe
 
  zhouahaihai
 
技能养成
 | 
104
105
106
107
108
109
110
111
112
113 
 | 
  	hero:updateProperty({field = "skillL", value = hero:getProperty("skillL"):setv(index, curLevel + 1)})
  
  	SendPacket(actionCodes.Hero_skillUpRpc, '')
  	return true
  end
  
  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
 | 
114 
 | 
  	if not hero then return 1 end
 
 | 
997cbdfe
 
  zhouahaihai
 
技能养成
 | 
115
116
117 
 | 
  
  	local index = msg.index -- 第几个天赋
  	local need = {[1] = 1, [2] = 1, [3] = 1, [4] = 1}
 
 | 
b57f0bae
 
  gaofengduan
 
fix hero talent
 | 
118 
 | 
  	if not need[index] then return 2 end
 
 | 
997cbdfe
 
  zhouahaihai
 
技能养成
 | 
119
120
121 
 | 
  
  	local talent = hero:getProperty("talent")
  	local curStage = talent:getv(0, 1)
 
 | 
b57f0bae
 
  gaofengduan
 
fix hero talent
 | 
122 
 | 
  	if curStage > csvdb["unit_breakCsv"][hero:getProperty("breakL")].talent then return 3 end
 
 | 
1c35c4cf
 
  gaofengduan
 
fix hero awake
 | 
123
124 
 | 
  
  	local curData = csvdb["unit_talentCsv"][curStage]
 
 | 
b57f0bae
 
  gaofengduan
 
fix hero talent
 | 
125 
 | 
  	if not curData then return 4 end
 
 | 
997cbdfe
 
  zhouahaihai
 
技能养成
 | 
126
127 
 | 
  
  	local level = talent:getv(index, 0)
 
 | 
b57f0bae
 
  gaofengduan
 
fix hero talent
 | 
128 
 | 
  	if level >= #curData then return 5 end
 
 | 
997cbdfe
 
  zhouahaihai
 
技能养成
 | 
129
130
131 
 | 
  
  	local talentData = curData[level]
  	if not talentData then return end
 
 | 
b57f0bae
 
  gaofengduan
 
fix hero talent
 | 
132
133
134
135 
 | 
  	local cost = talentData.money:toNumMap()
  	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
 
 | 
4b7c7c96
 
  zhouahaihai
 
增加 清空 挂机 冒险gm  角色经验
 | 
136 
 | 
  	end
 
 | 
b57f0bae
 
  gaofengduan
 
fix hero talent
 | 
137 
 | 
  	if not role:checkItemEnough(cost) then return 6 end
 
 | 
36204e3c
 
  zhengshouren
 
贩卖逻辑
 | 
138 
 | 
  	role:costItems(cost)
 
 | 
997cbdfe
 
  zhouahaihai
 
技能养成
 | 
139
140
141
142
143
144
145
146
147
148
149 
 | 
  	talent = talent:incrv(index, 1)
  
  	--是否进阶
  	local max = true
  	for i = 1, 4 do
  		if talent:getv(i, 0) < #curData then
  			max = false
  			break
  		end
  	end
  	if max then
 
 | 
b9bd5cb6
 
  zhouahaihai
 
天赋阶段 bug
 | 
150 
 | 
  		talent = talent:setv(0, curStage + 1)
 
 | 
997cbdfe
 
  zhouahaihai
 
技能养成
 | 
151
152
153
154
155
156
157
158
159 
 | 
  		for i = 1, 4 do
  			talent = talent:setv(i, 0)
  		end
  	end
  	hero:updateProperty({field = "talent", value = talent})
  	SendPacket(actionCodes.Hero_talentRpc, '')
  	return true
  end
  
 
 | 
be9c9ca6
 
  zhouahaihai
 
角色评论
 | 
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240 
 | 
  -- 暂时没有这个功能
  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)
  		local SERV = string.format("NAMED%d", math.random(1, 5))
  		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
 | 
241 
 | 
  			commentId = commentId,
 
 | 
be9c9ca6
 
  zhouahaihai
 
角色评论
 | 
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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315 
 | 
  			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))
  	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
 | 
316 
 | 
  		return
 
 | 
be9c9ca6
 
  zhouahaihai
 
角色评论
 | 
317
318 
 | 
  	end
  
 
 | 
1c35c4cf
 
  gaofengduan
 
fix hero awake
 | 
319
320 
 | 
  	local result = {status = 0}
  	local commentIndex = heroType .. ":" .. commentId
 
 | 
be9c9ca6
 
  zhouahaihai
 
角色评论
 | 
321
322 
 | 
  	local commentRoleKey = string.format("comment:%d:like", role:getProperty("id"))
  	local redret = redisproxy:pipelining(function (red)
 
 | 
1c35c4cf
 
  gaofengduan
 
fix hero awake
 | 
323 
 | 
  		red:hexists(commentKey.commentKey, commentId)
 
 | 
be9c9ca6
 
  zhouahaihai
 
角色评论
 | 
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 
 | 
  		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
  		if redret[1] == 1 then-- 查不到也返回ture
  			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)
  		end
  	end
  
  	SendPacket(actionCodes.Hero_likeCommentRpc, MsgPack.pack(result))
  	return true
  end
  
 
 | 
6947e382
 
  zhouahaihai
 
好感度, 皮肤
 | 
364
365
366 
 | 
  function _M.loveItemRpc(agent, data)
  	local role = agent.role
  	local msg = MsgPack.unpack(data)
 
 | 
3eb77775
 
  wangyujie
 
完成友情界面功能
 | 
367
368
369
370 
 | 
  	local hero = role.heros[msg.heroId]
  	if not hero then
  		return
  	end
 
 | 
6947e382
 
  zhouahaihai
 
好感度, 皮肤
 | 
371
372 
 | 
  	local curL = hero:getProperty("loveL")
  	local curExp = hero:getProperty("loveExp")
 
 | 
00e663bd
 
  zhouhaihai
 
剧情相关
 | 
373
374 
 | 
  	local curType = hero:getProperty("type")
  	local curPlus = csvdb["unit_love_plusCsv"][curType]
 
 | 
3eb77775
 
  wangyujie
 
完成友情界面功能
 | 
375
376
377
378
379
380
381 
 | 
  	if not curPlus then
  		return
  	end
  	if curL >= curPlus.limit then
  		SendPacket(actionCodes.Hero_loveItemRpc, MsgPack.pack({errMsg = 1}))	--已满级
  		return true
  	end
 
 | 
6947e382
 
  zhouahaihai
 
好感度, 皮肤
 | 
382 
 | 
  	local curEffect = csvdb["unit_love_effectCsv"][curL]
 
 | 
3eb77775
 
  wangyujie
 
完成友情界面功能
 | 
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397 
 | 
  	if not curEffect then
  		return
  	end
  	if curExp >= curEffect.loveValue and not msg.bBreak then
  		SendPacket(actionCodes.Hero_loveItemRpc, MsgPack.pack({errMsg = 2}))	--当前等级经验已满
  		return true
  	end
  
  	if msg.bBreak then
  		local cost = curEffect.cost:toArray(true, "=")
  		if not role:checkItemEnough({[cost[1]] = cost[2]}) then
  			SendPacket(actionCodes.Hero_loveItemRpc, MsgPack.pack({errMsg = 3, itemId = cost[1]}))	--物品不足
  			return true
  		end
  		role:costItems({[cost[1]] = cost[2]})
 
 | 
00e663bd
 
  zhouhaihai
 
剧情相关
 | 
398
399 
 | 
  		local newLevel = curL + 1
  		hero:updateProperty({field = "loveL", value = newLevel})
 
 | 
3eb77775
 
  wangyujie
 
完成友情界面功能
 | 
400 
 | 
  		hero:updateProperty({field = "loveExp", value = 0})
 
 | 
00e663bd
 
  zhouhaihai
 
剧情相关
 | 
401
402
403
404
405
406
407 
 | 
  
  		if role:getProperty("loveStatus"):getv(curType, 0) < newLevel then
  			role:changeUpdates({{type = "loveStatus", field = curType, value = newLevel}}) -- 总的
  		end
  
  		role:checkTaskEnter(role.TaskType.LoveBreak, {heroType = curType, loveL = newLevel})
  
 
 | 
3eb77775
 
  wangyujie
 
完成友情界面功能
 | 
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422 
 | 
  	else
  		local delta = globalCsv.unit_love_presentValue[msg.itemId]
  		if not delta then
  			return
  		end
  		if not role:checkItemEnough({[msg.itemId] = 1}) then
  			SendPacket(actionCodes.Hero_loveItemRpc, MsgPack.pack({errMsg = 3, itemId = msg.itemId}))
  			return true
  		end
  		local newExp = curExp + delta
  		if newExp > curEffect.loveValue then
  			newExp = curEffect.loveValue
  		end
  		role:costItems({[msg.itemId] = 1})
  		hero:updateProperty({field = "loveExp", value = newExp})
 
 | 
6947e382
 
  zhouahaihai
 
好感度, 皮肤
 | 
423 
 | 
  	end
 
 | 
3eb77775
 
  wangyujie
 
完成友情界面功能
 | 
424 
 | 
  	SendPacket(actionCodes.Hero_loveItemRpc, "")
 
 | 
6947e382
 
  zhouahaihai
 
好感度, 皮肤
 | 
425
426
427
428
429
430
431
432
433
434
435
436
437
438 
 | 
  	return true
  end
  
  function _M.loveTaskRpc(agent, data)
  	local role = agent.role
  	local msg = MsgPack.unpack(data)
  	local hero = role.heros[msg.id]
  	if not hero then return end
  
  	local curL = hero:getProperty("loveL")
  	local curExp = hero:getProperty("loveExp")
  	local curType = hero:getProperty("type")
  	local curPlus = csvdb["unit_love_plusCsv"][curType]
  	if not curPlus or curL >= curPlus.limit then return end
 
 | 
1c35c4cf
 
  gaofengduan
 
fix hero awake
 | 
439 
 | 
  
 
 | 
6947e382
 
  zhouahaihai
 
好感度, 皮肤
 | 
440
441
442
443
444
445
446
447
448
449
450
451 
 | 
   	local curEffect = csvdb["unit_love_effectCsv"][curL]
  	if not curEffect or curExp < curEffect.loveValue then return end
  
  	local lastEffect = csvdb["unit_love_effectCsv"][curL + 1]
  	local newExp = curExp - curEffect.loveValue
  	if lastEffect and curL + 1 < curPlus.limit then
  		if newExp >= lastEffect.loveValue then
  			-- todo  发任务
  		end
  	else
  		newExp = 0
  	end
 
 | 
00e663bd
 
  zhouhaihai
 
剧情相关
 | 
452 
 | 
  	local newLevel = curL + 1
 
 | 
6947e382
 
  zhouahaihai
 
好感度, 皮肤
 | 
453 
 | 
  	hero:updateProperty({field = "loveExp", value = newExp})
 
 | 
00e663bd
 
  zhouhaihai
 
剧情相关
 | 
454 
 | 
  	hero:updateProperty({field = "loveL", value = newLevel})
 
 | 
1c35c4cf
 
  gaofengduan
 
fix hero awake
 | 
455 
 | 
  
 
 | 
00e663bd
 
  zhouhaihai
 
剧情相关
 | 
456
457 
 | 
  	if role:getProperty("loveStatus"):getv(curType, 0) < newLevel then
  		role:changeUpdates({{type = "loveStatus", field = curType, value = newLevel}}) -- 总的
 
 | 
6947e382
 
  zhouahaihai
 
好感度, 皮肤
 | 
458
459 
 | 
  	end
  
 
 | 
00e663bd
 
  zhouhaihai
 
剧情相关
 | 
460
461 
 | 
  	role:checkTaskEnter(role.TaskType.LoveBreak, {heroType = curType, loveL = newLevel})
  
 
 | 
6947e382
 
  zhouahaihai
 
好感度, 皮肤
 | 
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478 
 | 
  	SendPacket(actionCodes.Hero_loveTaskRpc, "")
  	return true
  end
  
  function _M.changeSkinRpc(agent, data)
  	local role = agent.role
  	local msg = MsgPack.unpack(data)
  	local hero = role.heros[msg.id]
  	if not hero then return end
  	local skin = msg.skin
  	local skinData = csvdb["unit_skinCsv"][hero:getSkinId(skin)]
  	if not skinData or (skinData.itemId ~= 0 and not role:checkItemEnough({[skinData.itemId] = 1})) then return end
  	hero:updateProperty({field = "skin", value = skin})
  	SendPacket(actionCodes.Hero_changeSkinRpc, "")
  	return true
  end
  
 
 | 
312b9db5
 
  zhouahaihai
 
背包
 | 
479
480
481
482
483
484
485
486
487
488
489
490
491
492 
 | 
  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
  
 
 | 
36204e3c
 
  zhengshouren
 
贩卖逻辑
 | 
493 
 | 
  	role:costItems({[heroType] = cost})
 
 | 
8c199cec
 
  zhengshouren
 
简化物品奖励接口,设置默认参数
 | 
494 
 | 
  	role:award({[heroType + ItemStartId.Hero] = 1})
 
 | 
312b9db5
 
  zhouahaihai
 
背包
 | 
495
496
497
498
499 
 | 
  
  	SendPacket(actionCodes.Hero_createHeroRpc, "")
  	return true
  end
  
 
 | 
43cc5f51
 
  gaofengduan
 
调整 equip 数据结构
 | 
500 
 | 
  -- typ 位置,level等级对应唯一装备,level为0时为移除,不为0时无则装备,有则替换
 
 | 
24d77701
 
  gaofengduan
 
fix equip
 | 
501 
 | 
  function _M.referEquipsRpc(agent, data)
 
 | 
43cc5f51
 
  gaofengduan
 
调整 equip 数据结构
 | 
502
503
504
505
506
507
508
509
510
511
512
513
514 
 | 
  	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
  	if not equips or not next(equips) then return 11 end
  
  	for typ,level in pairs(equips) do
  		local ownLv = hero:getProperty("equip"):getv(typ,0)
  		if level == 0 then
  			if ownLv == 0 then return 2 end
  		else
  			if role:getEquipCount(typ,level) < 1 then return 3 end
 
 | 
24d77701
 
  gaofengduan
 
fix equip
 | 
515
516
517
518 
 | 
  			local equipSet = csvdb["equipCsv"][typ]
  			if not equipSet then return 4 end
  			local equipData = equipSet[level]
  			if not equipData then return 5 end
 
 | 
43cc5f51
 
  gaofengduan
 
调整 equip 数据结构
 | 
519 
 | 
  		end
 
 | 
43cc5f51
 
  gaofengduan
 
调整 equip 数据结构
 | 
520
521
522
523
524 
 | 
  	end
  
  	for typ,level in pairs(equips) do
  		local ownLv = hero:getProperty("equip"):getv(typ,0)
  		if level == 0 then
 
 | 
24d77701
 
  gaofengduan
 
fix equip
 | 
525 
 | 
  			role:addEquip({type=typ,level=ownLv,count=1,isRefer=true})
 
 | 
43cc5f51
 
  gaofengduan
 
调整 equip 数据结构
 | 
526 
 | 
  		else
 
 | 
24d77701
 
  gaofengduan
 
fix equip
 | 
527
528
529 
 | 
  			role:addEquip({type=typ,level=level,count=-1,isRefer=true})
  			if ownLv > 0 then
  				role:addEquip({type=typ,level=ownLv,count=1,isRefer=true})
 
 | 
43cc5f51
 
  gaofengduan
 
调整 equip 数据结构
 | 
530
531 
 | 
  			end
  		end
 
 | 
99912630
 
  gaofengduan
 
fix rune
 | 
532
533 
 | 
  		local x = hero:getProperty("equip"):setv(typ, level)
  		hero:updateProperty({field = "equip", value = x})
 
 | 
43cc5f51
 
  gaofengduan
 
调整 equip 数据结构
 | 
534
535
536
537
538 
 | 
  	end
  	SendPacket(actionCodes.Hero_referEquipsRpc, "")
  	return true
  end
  
 
 | 
ee3ac0b5
 
  gaofengduan
 
fix magic
 | 
539
540 
 | 
  -- typ 位置,uid对应唯一符文,uid为0时为移除,不为0时无则装备,有则替换
  function _M.referRunesRpc(agent, data)
 
 | 
43cc5f51
 
  gaofengduan
 
调整 equip 数据结构
 | 
541
542
543
544
545
546 
 | 
  	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
 | 
547
548
549
550
551
552
553
554
555
556
557
558 
 | 
  
  	for typ,uid in pairs(runes) do
  		local referUid = hero:getProperty("rune"):getv(typ,0)
  		if uid == 0 then
  			if referUid == 0 then return 2 end
  		else
  			local ownRune = role.runeBag[uid]
  			if not ownRune then return 3 end
  			if ownRune:getProperty("refer") ~= 0 then return 4 end
  
  			local runeSet = csvdb["runeCsv"][typ]
  			if not runeSet then return 5 end
 
 | 
fb321075
 
  gaofengduan
 
add rune up
 | 
559 
 | 
  			local runeData = runeSet[ownRune:getProperty("id")]
 
 | 
ee3ac0b5
 
  gaofengduan
 
fix magic
 | 
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576 
 | 
  			if not runeData then return 6 end
  		end
  	end
  
  	for typ,uid in pairs(runes) do
  		local referUid = hero:getProperty("rune"):getv(typ,0)
  		if uid == 0 then
  			local referRune = role.runeBag[referUid]
  			referRune:updateProperty({field = "refer",value = 0})
  		else
  			if referUid ~= 0 then
  				local referRune = role.runeBag[referUid]
  				referRune:updateProperty({field = "refer",value = 0})
  			end
  			local ownRune = role.runeBag[uid]
  			ownRune:updateProperty({field = "refer",value = hero:getProperty("id")})
  		end
 
 | 
99912630
 
  gaofengduan
 
fix rune
 | 
577
578 
 | 
  		local x = hero:getProperty("rune"):setv(typ,uid)
  		hero:updateProperty({field = "rune", value = x})
 
 | 
ee3ac0b5
 
  gaofengduan
 
fix magic
 | 
579
580 
 | 
  	end
  	SendPacket(actionCodes.Hero_referRunesRpc, "")
 
 | 
43cc5f51
 
  gaofengduan
 
调整 equip 数据结构
 | 
581
582
583 
 | 
  	return true
  end
  
 
 | 
0a07bdd9
 
  zhouahaihai
 
角色升级 。gm
 | 
584 
 | 
  return _M
 
 |