Blame view

src/actions/GmAction.lua 10.6 KB
314bc5df   zhengshouren   提交服务器初始代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
  local _M = {}
  local redisproxy = redisproxy
  function _M.clientRequest(agent, data)
  	local msg = MsgPack.unpack(data)
  	local role = agent.role
  	local action = _M[msg.cmd]
  	local bin = MsgPack.pack({ cmd = "指令失败" })
  	if not action then
  		SendPacket(actionCodes.Gm_receiveResponse, bin)
  		return true
  	end
  	local ret = action(role, msg)
  	bin = MsgPack.pack({ cmd = ret })
  	SendPacket(actionCodes.Gm_receiveResponse, bin)
  	return true
  end
  
5e5d7680   zhouhaihai   热更新 优化
18
  function _M.testhotfix(role, pms)
2d392ede   zhouhaihai   热更新 最终版
19
  	return csvdb["itemCsv"][1]["name"] .. " -=- " .. csvdb["itemCsv"][2]["name"] .. " -=- " .. role:getItemCount(123) .. " -=- " .. table.pack(next(role.heros))[2]:getBattleValue()
5e5d7680   zhouhaihai   热更新 优化
20
  end
0a07bdd9   zhouahaihai   角色升级 。gm
21
  
58f3a42c   zhouhaihai   gm帮助
22
23
24
  local helpDes = {{"描述", "指令", "参数1", "参数2"	,"参数3"}}
  
  table.insert(helpDes, {"获得角色"	, "hero", "角色类型"})
0a07bdd9   zhouahaihai   角色升级 。gm
25
26
  function _M.hero(role, pms)
  	local heroType = tonum(pms.pm1)
056c01a0   zhouhaihai   简化装备
27
28
29
  	if not role:addHero({type = heroType}) then
  		return "失败"
  	end
0a07bdd9   zhouahaihai   角色升级 。gm
30
31
32
  	return "成功"
  end
  
faabdf3c   suhongyang   Gm加hero add level
33
34
35
36
37
  table.insert(helpDes, {"角色升级"	, "herol", "角色类型", "增加等级"})
  function _M.herol(role, pms)
  	local heroType = tonum(pms.pm1)
  	local addLevel = tonum(pms.pm2)
  	local hero = role.heros[heroType]
b640afba   suhongyang   Gm升级直接突破
38
  	if not hero or (hero:getProperty("breakL") >= #csvdb["unit_breakCsv"] and hero:getProperty("level") >= hero:getMaxLevel()) then
faabdf3c   suhongyang   Gm加hero add level
39
40
  		return "失败"
  	end
b640afba   suhongyang   Gm升级直接突破
41
  	local addbl = #csvdb["unit_breakCsv"] - hero:getProperty("breakL")
d8c07167   suhongyang   防止突破满了还突破
42
43
44
  	if addbl > 0 then
  		hero:updateProperty({field = "breakL", delta = addbl})
  	end
b640afba   suhongyang   Gm升级直接突破
45
  	addLevel = math.min(hero:getMaxLevel() - hero:getProperty("level"), addLevel)
faabdf3c   suhongyang   Gm加hero add level
46
47
48
49
50
  	hero:updateProperty({field = "level", delta = addLevel})
  	role:checkTaskEnter("HeroLevelUp", {level = hero:getProperty("level")})
  	return "成功"
  end
  
58f3a42c   zhouhaihai   gm帮助
51
  table.insert(helpDes, {"获得装备"	, "equip", "装备类型"	, "装备等级", "装备个数"})
43cc5f51   gaofengduan   调整 equip 数据结构
52
53
54
55
56
57
58
59
  function _M.equip(role, pms)
  	local typ = tonum(pms.pm1)
  	local level = tonum(pms.pm2)
  	local count = tonum(pms.pm3)
  	role:addEquip({type = typ,level = level,count = count})
  	return "成功"
  end
  
58f3a42c   zhouhaihai   gm帮助
60
  table.insert(helpDes, {"获得零件"	, "rune", "零件类型", "零件id"})
ad484303   gaofengduan   add rune
61
62
63
64
65
66
67
  function _M.rune(role, pms)
  	local typ = tonum(pms.pm1)
  	local id = tonum(pms.pm2)
  	local result = role:addRune({type = typ,id = id})
  	return result
  end
  
58f3a42c   zhouhaihai   gm帮助
68
  table.insert(helpDes, {"通关挂机副本", "fb", "挂卡id"})
cb85faac   zhouhaihai   增加gm命令
69
70
71
72
73
74
75
76
77
  function _M.fb(role, pms) -- 直接通关
  	local carbonId = tonum(pms.pm1)
  	if not csvdb["idle_battleCsv"][carbonId] then return "不存在的carbon" end
  	local passCarbon = role:getProperty("hangPass")
  	local addPre 
  	addPre = function(carbonId)
  		local carbonData = csvdb["idle_battleCsv"][carbonId]
  		for _, pre in ipairs(carbonData.prepose:toArray(true, "=")) do
  			passCarbon[pre] = 1
03a6166a   zhouhaihai   餐厅优化
78
  			role:checkTaskEnter("HangPass", {id = pre})
cb85faac   zhouhaihai   增加gm命令
79
80
81
82
83
84
  			addPre(pre)
  		end
  	end
  	passCarbon[carbonId] = 1
  	addPre(carbonId)
  	role:updateProperty({field = "hangPass", value = passCarbon})
03a6166a   zhouhaihai   餐厅优化
85
  	role:checkTaskEnter("HangPass", {id = carbonId})
cb85faac   zhouhaihai   增加gm命令
86
87
88
  	return "成功"
  end
  
58f3a42c   zhouhaihai   gm帮助
89
  table.insert(helpDes, {"抵达挂机副本", "fbc", "副本id"})
6433fe76   zhouhaihai   到某一关
90
91
92
93
94
95
96
97
98
  function _M.fbc(role, pms) -- 直接通关
  	local carbonId = tonum(pms.pm1)
  	if not csvdb["idle_battleCsv"][carbonId] then return "不存在的carbon" end
  	local passCarbon = {}
  	local addPre 
  	addPre = function(carbonId)
  		local carbonData = csvdb["idle_battleCsv"][carbonId]
  		for _, pre in ipairs(carbonData.prepose:toArray(true, "=")) do
  			passCarbon[pre] = 1
03a6166a   zhouhaihai   餐厅优化
99
  			role:checkTaskEnter("HangPass", {id = pre})
6433fe76   zhouhaihai   到某一关
100
101
102
103
104
105
  			addPre(pre)
  		end
  	end
  	addPre(carbonId)
  	role:updateProperty({field = "hangInfo", value = {}})
  	role:updateProperty({field = "hangPass", value = passCarbon})
03a6166a   zhouhaihai   餐厅优化
106
  	role:checkTaskEnter("HangPass", {id = carbonId})
6433fe76   zhouhaihai   到某一关
107
108
109
  	return "成功"
  end
  
14f1591b   zhouhaihai   删除好感度相关
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
  -- table.insert(helpDes, {"好感度", "love", "角色类型", "好感度等级", "好感度经验"})
  -- function _M.love(role, pms)
  -- 	local heroType = tonum(pms.pm1)
  -- 	local level = tonum(pms.pm2)
  -- 	local exp = tonum(pms.pm3)
  -- 	local curPlus = csvdb["unit_love_plusCsv"][heroType]
  -- 	if not curPlus then return "参数错误" end
  -- 	level = math.max(math.min(curPlus.limit, level), 0)
  -- 	local curEffect = csvdb["unit_love_effectCsv"][level]
  -- 	exp = math.max(math.min(curEffect.loveValue, exp) , 0)
  -- 	for _, hero in pairs(role.heros) do
  -- 		if hero:getProperty("type") == heroType then
  -- 			hero:updateProperty({field = "loveL", value = level})
  -- 			hero:updateProperty({field = "loveExp", value = exp})
  -- 			if role:getProperty("loveStatus"):getv(heroType, 0) < level then
  -- 				role:changeUpdates({{type = "loveStatus", field = heroType, value = level}}) -- 总的
  -- 			end
  -- 			role:checkTaskEnter("LoveBreak", {heroType = heroType, loveL = level})
  -- 		end
  -- 	end
  -- 	return "成功"
  -- end
cb85faac   zhouhaihai   增加gm命令
132
  
58f3a42c   zhouhaihai   gm帮助
133
  table.insert(helpDes, {"玩家经验", "exp", "经验"})
cb85faac   zhouhaihai   增加gm命令
134
135
136
137
138
139
140
  function _M.exp(role, pms)
  	local exp =  tonum(pms.pm1)
  	exp = math.floor(math.max(exp, 0))
  	role:addPlayExp(exp)
  	return "成功"
  end
  
58f3a42c   zhouhaihai   gm帮助
141
142
143
144
145
146
147
  table.insert(helpDes, {"获得物品", "get", "物品ID", "个数"})
  table.insert(helpDes, {"获得所有物品", "get", "ALL"})
  table.insert(helpDes, {"获得所有装备", "get", "EQUIP"})
  table.insert(helpDes, {"获得所有零件", "get", "RUNE"})
  table.insert(helpDes, {"获得所有碎片", "get", "FRAG"})
  table.insert(helpDes, {"获得所有食物", "get", "FOOD"})
  table.insert(helpDes, {"获得所有角色", "get", "HERO"})
8c74292c   zhouahaihai   增加item 以及 角色突破
148
  function _M.get(role, pms)
747f05a1   gaofengduan   add gm get all
149
  	if pms.pm1 == "ALL" then
58559948   zhouhaihai   getall gm
150
151
152
153
  		local reward = {}
  		for id, data in pairs(csvdb["gm_getallCsv"]) do
  			if csvdb["itemCsv"][id] then
  				reward[id] = data.number
747f05a1   gaofengduan   add gm get all
154
155
  			end
  		end
58559948   zhouhaihai   getall gm
156
  		role:award(reward)
3c8a6b8a   zhouhaihai   get equip
157
158
159
160
161
162
  	elseif pms.pm1 == "EQUIP" then
  		for itemId = 7000 , 8000 do
  			if csvdb["itemCsv"][itemId] then
  				role:award({[itemId] = 100})
  			end
  		end
966034ca   zhouhaihai   获取碎片零件gm
163
  	elseif pms.pm1 == "RUNE" then
58751698   zhouhaihai   修改id 区间
164
  		for itemId = 2000 , 3000 do
966034ca   zhouhaihai   获取碎片零件gm
165
  			if csvdb["itemCsv"][itemId] then
a0013f0b   zhouhaihai   零件分批推送
166
  				role:award({[itemId] = 1})
966034ca   zhouhaihai   获取碎片零件gm
167
168
169
170
171
172
173
174
  			end
  		end
  	elseif pms.pm1 == "FRAG" then
  		for itemId = 100 , 400 do
  			if csvdb["itemCsv"][itemId] then
  				role:award({[itemId] = 100})
  			end
  		end
3b069d52   zhouhaihai   增加获取 food 后台
175
176
177
178
179
180
  	elseif pms.pm1 == "FOOD" then
  		for itemId = 4000 , 5000 do
  			if csvdb["itemCsv"][itemId] then
  				role:award({[itemId] = 100})
  			end
  		end
cb85faac   zhouhaihai   增加gm命令
181
182
183
184
185
186
  	elseif pms.pm1 == "HERO" then
  		for itemId = 400 , 700 do
  			if csvdb["itemCsv"][itemId] then
  				role:award({[itemId] = 1})
  			end
  		end
747f05a1   gaofengduan   add gm get all
187
188
189
190
191
  	else
  		local itemId = tonum(pms.pm1)
  		if not csvdb["itemCsv"][itemId] then
  			return "物品不存在"
  		end
ee999bde   zhouhaihai   零件优化
192
  		local count = tonum(pms.pm2, 1)
747f05a1   gaofengduan   add gm get all
193
  		role:award({[itemId] = count})
8c74292c   zhouahaihai   增加item 以及 角色突破
194
  	end
8c74292c   zhouahaihai   增加item 以及 角色突破
195
196
197
  	return "成功"
  end
  
58f3a42c   zhouhaihai   gm帮助
198
  table.insert(helpDes, {"冒险清除"	, "advc"})
4b7c7c96   zhouahaihai   增加 清空 挂机 冒险gm 角色经验
199
200
  function _M.advc(role, pms)
  	role:updateProperty({field = "advInfo", value = {}})
4faef572   zhouhaihai   冒险任务,冒险扫荡, 冒险中继
201
  	role:updateProperty({field = "advTask", value = {}})
4b7c7c96   zhouahaihai   增加 清空 挂机 冒险gm 角色经验
202
203
  	role:updateProperty({field = "advItems", value = ""})
  	role:updateProperty({field = "advTeam", value = {}})
8781e103   zhouhaihai   冒险 bug
204
205
  	role:updateProperty({field = "advAFGet", value = {}})
  	role:updateProperty({field = "advAFWear", value = {}})
4b7c7c96   zhouahaihai   增加 清空 挂机 冒险gm 角色经验
206
207
208
209
  	role.advData = nil
  	return "成功"
  end
  
58f3a42c   zhouhaihai   gm帮助
210
  table.insert(helpDes, {"冒险次数恢复", "advf"})
4faef572   zhouhaihai   冒险任务,冒险扫荡, 冒险中继
211
212
213
214
215
  function _M.advf(role, pms)
  	role.dailyData:updateProperty({field = "advC", value = 0})
  	return "成功"
  end
  
58f3a42c   zhouhaihai   gm帮助
216
  table.insert(helpDes, {"冒险通关", "adv", "章节id", "层数"})
4faef572   zhouhaihai   冒险任务,冒险扫荡, 冒险中继
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
  function _M.adv(role, pms)
  	local chapterId = tonum(pms.pm1)
  	local layer = tonum(pms.pm2)
  
  	local advData = csvdb["adv_chapterCsv"][chapterId]
  	if not advData then return end
  	layer = math.min(layer, advData.limitlevel)
  	local advPass = role:getProperty("advPass")
  	local addPre 
  	addPre = function(chapterId)
  		local advData = csvdb["adv_chapterCsv"][chapterId]
  		for pre, l in ipairs(advData.prepose:toNumMap()) do
  			if (advPass[pre] or 0) < l then
  				advPass[pre] = l
  				addPre(pre)
  			end
  		end
  	end
  	if (advPass[chapterId] or 0) < layer then
  		advPass[chapterId] = layer
  		addPre(chapterId)
  		role:updateProperty({field = "advPass", value = advPass})
  	end
  
  	return "成功"
  end
  
58f3a42c   zhouhaihai   gm帮助
244
  table.insert(helpDes, {"冒险到达指定层", "advt", "章节id", "层数"})
4d943586   zhouhaihai   直通 advt gm
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
  function _M.advt(role, pms)
  	local chapterId = tonum(pms.pm1)
  	local layer = tonum(pms.pm2)
  	local advData = csvdb["adv_chapterCsv"][chapterId]
  	if not advData then return "不存在的章节" end
  	layer = math.min(layer, advData.limitlevel)
  	local advData = role:getAdvData()
  
  	if not advData.chapterId then
  		return "先随便开启一关"
  	end
  
  	_M.adv(role, {pm1 = chapterId, pm2 = layer - 1})
  
  	
  	advData.chapterId = chapterId
  	advData.level = layer
  
  	advData:saveDB()
  
  	return "成功"
  end
  
f60b89b1   zhouhaihai   奖励副本
268
269
270
271
272
273
274
275
  table.insert(helpDes, {"冒险队等级增加", "advl", "通关次数"})
  function _M.advl(role, pms)
  	local winCount = tonum(pms.pm1)
  	winCount = math.max(0, winCount)
  	role:checkAdvLvByAddWin(winCount)
  	return "成功"
  end
  
68d3fbaf   zhouhaihai   冒险内加经验
276
277
278
279
280
281
282
283
284
  table.insert(helpDes, {"冒险内等级增加", "advcl", "经验值"})
  function _M.advcl(role, pms)
  	local exp = tonum(pms.pm1)
  	local advData = role:getAdvData()
  
  	if not advData.chapterId then
  		return "先随便开启一关"
  	end
  	advData.battle.player:addExp(exp)
679a1fc5   zhouhaihai   增加冒险经验 保存
285
286
  	advData:saveDB()
  	
68d3fbaf   zhouhaihai   冒险内加经验
287
288
289
  	return "成功"
  end
  
58f3a42c   zhouhaihai   gm帮助
290
  table.insert(helpDes, {"挂机清除"	, "idlec"})
4b7c7c96   zhouahaihai   增加 清空 挂机 冒险gm 角色经验
291
292
293
294
295
296
297
298
  function _M.idlec(role, pms)
  	role:updateProperty({field = "hangTeam", value = {}})
  	role:updateProperty({field = "hangInfo", value = {}})
  	role:updateProperty({field = "hangBag", value = {}})
  	role.advData = nil
  	return "成功"
  end
  
d3da3368   zhouhaihai   冒险地图被动技, buff 神器
299
300
  table.insert(helpDes, {"冒险内可使用道具", "advit", "ALL"})
  table.insert(helpDes, {"冒险内消耗道具", "advit", "itemId", "count"})
db3c56ad   zhouhaihai   冒险相关
301
  function _M.advit(role, pms)
98761edc   zhouhaihai   buff 补充
302
  	local reward = {}
d3da3368   zhouhaihai   冒险地图被动技, buff 神器
303
304
305
306
307
  	if pms.pm1 == "ALL" then
  		for k, v in pairs(csvdb["adv_itemCsv"]) do
  			if csvdb["itemCsv"][k] and v.effect ~= 0 then
  				reward[k] = 1
  			end
db3c56ad   zhouhaihai   冒险相关
308
  		end
d3da3368   zhouhaihai   冒险地图被动技, buff 神器
309
310
311
312
313
314
315
316
317
  		for k , v in pairs(csvdb["adv_artifactCsv"]) do
  			if v.unlock == 0 then
  				reward[k] = 1
  			end
  		end
  	else
  		local itemId = tonum(pms.pm1)
  		local count = tonum(pms.pm2)
  		reward[itemId] = count
db3c56ad   zhouhaihai   冒险相关
318
  	end
d3da3368   zhouhaihai   冒险地图被动技, buff 神器
319
320
  	
  	
98761edc   zhouhaihai   buff 补充
321
322
  	local adv = role:getAdvData()
  	adv:award(reward)
db3c56ad   zhouhaihai   冒险相关
323
324
325
326
  	return "成功"
  end
  
  
58f3a42c   zhouhaihai   gm帮助
327
  table.insert(helpDes, {"爬塔到指定层", "tower", "层数"})
4af997e0   zhouhaihai   到达指定层
328
  function _M.tower(role, pms)
0e06d7a6   zhouhaihai   中文逗号
329
  	local level = tonum(pms.pm1, 1)
4af997e0   zhouhaihai   到达指定层
330
331
332
333
334
  	if not csvdb["tower_battleCsv"][level] then return  "不存在" end
  	role:updateProperty({field = "towerInfo", value = {c = globalCsv.tower_count_limit, l = level}})
  	return "成功"
  end
  
147ef2ce   zhouhaihai   邮件 Gm
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
  table.insert(helpDes, {"发送邮件", "email", "id", "奖励"})
  function _M.email(role, pms)
  	local id = tonum(pms.pm1, 0)
  	local reward = pms.pm2
  	redisproxy:insertEmail({
  		roleId = role:getProperty("id"), 
  		emailId = id,
  		createtime = skynet.timex(),
  		title = id == 0 and "来自GM的邮件!" or nil, 
  		stitle = id == 0 and "GM测试" or nil, 
  		content = id == 0 and "测试内容测试内容!!!\n\t 巴拉巴拉!" or nil, 
  		attachments = id == 0 and reward or nil,
  		rewardPms = id ~= 0 and reward or nil,
  	})
  	return "成功"
  end
58f3a42c   zhouhaihai   gm帮助
351
352
353
354
355
356
357
  
  function _M.helpRpc(agent, data)
  	SendPacket(actionCodes.Gm_helpRpc, MsgPack.pack({help = helpDes}))
  	return true
  end
  
  
147ef2ce   zhouhaihai   邮件 Gm
358
359
  
  
314bc5df   zhengshouren   提交服务器初始代码
360
  return _M