Commit a5fa0074515a0e2cbd552c0992123ef999875a8f

Authored by zhouhaihai
1 parent 7e6aa5d9

robot

@@ -120,7 +120,7 @@ local function startUnit(unit) @@ -120,7 +120,7 @@ local function startUnit(unit)
120 120
121 local ok, unitTest = pcall(require, "unitTest." .. unit) 121 local ok, unitTest = pcall(require, "unitTest." .. unit)
122 if not ok then 122 if not ok then
123 - print("unitTest load error : " .. unitTest) 123 + log("unitTest load error : " .. unitTest)
124 end 124 end
125 125
126 unitTest.new(client):startTest() 126 unitTest.new(client):startTest()
@@ -142,7 +142,7 @@ function CMD.start(fd, id) @@ -142,7 +142,7 @@ function CMD.start(fd, id)
142 client.uname = uname 142 client.uname = uname
143 local status, body = httpc.get(config.http, "/login?" .. httpGetFormatData({token = uname, device = "test", channel = "develop"})) 143 local status, body = httpc.get(config.http, "/login?" .. httpGetFormatData({token = uname, device = "test", channel = "develop"}))
144 if tonumber(status) ~= 200 then 144 if tonumber(status) ~= 200 then
145 - print("http get error", uname, body) 145 + log("http get error", uname, body)
146 return 146 return
147 end 147 end
148 local servInfo = json.decode(body) 148 local servInfo = json.decode(body)
@@ -170,7 +170,7 @@ skynet.register_protocol { @@ -170,7 +170,7 @@ skynet.register_protocol {
170 dispatch = function(session, address, cmd, data) 170 dispatch = function(session, address, cmd, data)
171 local actionName = actionHandlers[cmd] 171 local actionName = actionHandlers[cmd]
172 if not actionName then 172 if not actionName then
173 - print("actionName not exist", actionName) 173 + log("actionName not exist", actionName)
174 return 174 return
175 end 175 end
176 176
robot/robot_config.lua
@@ -20,19 +20,19 @@ return { @@ -20,19 +20,19 @@ return {
20 max = 200, -- 最大玩家数 必须大于 online 数 20 max = 200, -- 最大玩家数 必须大于 online 数
21 online_time = {10, 60}, -- 在线时间控制 秒 21 online_time = {10, 60}, -- 在线时间控制 秒
22 22
23 - uname_prefix = "robot", --机器名称前缀 23 + uname_prefix = "robothehe", --机器名称前缀
24 24
25 25
26 -- 机器上线后的行为 26 -- 机器上线后的行为
27 units = { 27 units = {
28 - chat = {weight = 100}, -- 聊天  
29 - item = {weight = 100}, -- 物品操作  
30 - hero = {weight = 500}, -- 英雄  
31 - hang = {weight = 1000}, -- 挂机战斗  
32 - tower = {weight = 500}, -- 爬塔  
33 - car = {weight = 100}, -- 爬塔  
34 - pvp = {weight = 500}, -- pvp  
35 - email = {weight = 100}, -- 邮件  
36 - adv = {weight = 200}, -- 冒险 28 + chat = {weight = 1}, -- 聊天
  29 + item = {weight = 1}, -- 物品操作
  30 + hero = {weight = 1}, -- 英雄
  31 + hang = {weight = 1}, -- 挂机战斗
  32 + tower = {weight = 1}, -- 爬塔
  33 + car = {weight = 1}, -- 爬塔
  34 + pvp = {weight = 1}, -- pvp
  35 + email = {weight = 1}, -- 邮件
  36 + adv = {weight = 1}, -- 冒险
37 } 37 }
38 } 38 }
@@ -15,7 +15,7 @@ local id_max = 0 -- robot id @@ -15,7 +15,7 @@ local id_max = 0 -- robot id
15 15
16 16
17 function MSG.open( ... ) 17 function MSG.open( ... )
18 - print("open", ...) 18 + log("open", ...)
19 end 19 end
20 20
21 function MSG.close(fd) 21 function MSG.close(fd)
@@ -30,7 +30,7 @@ function MSG.close(fd) @@ -30,7 +30,7 @@ function MSG.close(fd)
30 end 30 end
31 31
32 function MSG.error(fd, msg) 32 function MSG.error(fd, msg)
33 - print("MSG.error", fd, msg) 33 + log("MSG.error", fd, msg)
34 MSG.close(fd) 34 MSG.close(fd)
35 end 35 end
36 36
robot/unitTest/adv.lua
@@ -8,6 +8,8 @@ local _M = class("hang", require("unitTest.unitTest")) @@ -8,6 +8,8 @@ local _M = class("hang", require("unitTest.unitTest"))
8 8
9 function _M:start() 9 function _M:start()
10 sendServer(actionCodes.Gm_clientRequest, MsgPack.pack({cmd = "fb", pm1 = 10606})) 10 sendServer(actionCodes.Gm_clientRequest, MsgPack.pack({cmd = "fb", pm1 = 10606}))
  11 + requestServer(actionCodes.Adv_roleFormatRpc, MsgPack.pack({index = 1, title = "hehe", leader = 1, leader2 = 2, heros = {[1] = 1, [2] = 2}}))
  12 + requestServer(actionCodes.Adv_selectTeamRpc, MsgPack.pack({index = 1}))
11 self:task() 13 self:task()
12 end 14 end
13 15
@@ -24,8 +26,8 @@ function _M:task() @@ -24,8 +26,8 @@ function _M:task()
24 end 26 end
25 27
26 function _M:startAdv() 28 function _M:startAdv()
27 - sendServer(actionCodes.Gm_clientRequest, MsgPack.pack({cmd = "advf", pm1 = 10606}))  
28 - requestServer(actionCodes.Adv_startAdvRpc, MsgPack.pack({chapterId = 101, format = {leader = 1, leader2 = 2, heros = {[1] = 1, [2] = 2}}})) 29 + sendServer(actionCodes.Gm_clientRequest, MsgPack.pack({cmd = "advf"}))
  30 + requestServer(actionCodes.Adv_startAdvRpc, MsgPack.pack({chapterId = 101}))
29 requestServer(actionCodes.Adv_exitAdvRpc, '') 31 requestServer(actionCodes.Adv_exitAdvRpc, '')
30 end 32 end
31 33
robot/unitTest/hero.lua
@@ -35,8 +35,8 @@ function _M:drawHero10() @@ -35,8 +35,8 @@ function _M:drawHero10()
35 end 35 end
36 36
37 function _M:createHeroRandom() 37 function _M:createHeroRandom()
38 - sendServer(actionCodes.Gm_clientRequest, MsgPack.pack({cmd = "get", pm1 = 703, pm2 = 20}))  
39 - requestServer(actionCodes.Hero_createHeroRandomRpc, MsgPack.pack({itemId = 703})) 38 + sendServer(actionCodes.Gm_clientRequest, MsgPack.pack({cmd = "get", pm1 = 722, pm2 = 40}))
  39 + requestServer(actionCodes.Hero_createHeroRandomRpc, MsgPack.pack({itemId = 722}))
40 end 40 end
41 41
42 42