diff --git a/robot/robot.conf b/robot/robot.conf new file mode 100644 index 0000000..5f33b02 --- /dev/null +++ b/robot/robot.conf @@ -0,0 +1,12 @@ +root = "./" +thread = 8 +logger = nil +harbor = 0 +start = "start" -- main script +bootstrap = "snlua bootstrap" -- The service for bootstrap + +lua_path = root .."skynet/lualib/?.lua;"..root.."robot/?.lua;"..root.."src/?.lua" +luaservice = root.."skynet/service/?.lua;"..root.."robot/?.lua" +lualoader = "skynet/lualib/loader.lua" +cpath = root.."skynet/cservice/?.so" +lua_cpath = "skynet/luaclib/?.so" diff --git a/robot/robot.lua b/robot/robot.lua new file mode 100644 index 0000000..d3c46dd --- /dev/null +++ b/robot/robot.lua @@ -0,0 +1,190 @@ +require "ProtocolCode" +require "shared.init" +require "utils.init" +skynet = require "skynet" +local socketdriver = require "skynet.socketdriver" +local netpack = require "skynet.netpack" +local xxtea = require "xxtea" +local httpc = require("http.httpc") +local config = require "robot_config" + +local XXTEA_KEY = "699D448D6D24f7F941E9F6E99F823E18" + +local CMD = {} +local client = {} +local eventListener = {} + +local ignoreListener = { + ["Role.updateProperty"] = function(data) + local msg = MsgPack.unpack(data) + for _, one in pairs(msg) do + client.role[one.key] = one.newValue + end + end, + ["Role.updateProperties"] = function(data) + local msg = MsgPack.unpack(data) + for field, value in pairs(msg) do + client.role[field] = value + end + end, + ["Role.notifyNewEvent"] = true, + ["Role.chat"] = true, + ["Role.updateItems"] = true, + ["Gm.receiveResponse"] = true, + ["Role.changeUpdate"] = true, + ["Role.loadRunes"] = true, + ["Hero.loadInfos"] = true, + ["Sys.innerErrorMsg"] = function(data) + local msg = MsgPack.unpack(data) + log("innerErrorMsg: " .. msg.id) + end, +} + +function addListener(actionCode, callback, isKeep) + callback = callback or function() end + local handlerName = actionHandlers[actionCode] + if string.sub(handlerName, -3, -1) == "Rpc" then + actionCode = actionCode + rpcResponseBegin + end + if eventListener[actionHandlers[actionCode]] then + log(handlerName .. " had listener") + end + local trueCall = callback + if not isKeep then + trueCall = function(data) + removeListener(actionCode) + callback(data) + end + end + eventListener[actionHandlers[actionCode]] = trueCall +end + +function removeListener(actionCode) + local handlerName = actionHandlers[actionCode] + if string.sub(handlerName, -3, -1) == "Rpc" then + actionCode = actionCode + rpcResponseBegin + end + eventListener[actionHandlers[actionCode]] = nil +end + +function triggerListener(listener, data) + if eventListener[listener] then + if #data > 0 then data = xxtea.decrypt(data, XXTEA_KEY) end + eventListener[listener](data) + elseif ignoreListener[listener] then + if type(ignoreListener[listener]) == "function" then + if #data > 0 then data = xxtea.decrypt(data, XXTEA_KEY) end + ignoreListener[listener](data) + end + else + log(listener .. " no handle!!!") + end +end + +function sendServer(actionCode, bin) + local session = 0 + local handlerName = actionHandlers[actionCode] + if actionCode == actionCodes.Role_queryLoginRpc or string.sub(handlerName, -3, -1) ~= "Rpc" then + session = nil + end + + local data = string.pack("H", actionCode) + if session then + data = data .. string.pack("H", session) + end + + if #bin > 0 then bin = xxtea.encrypt(bin, XXTEA_KEY) end + data = data .. bin + + socketdriver.send(client.fd, netpack.pack(data)) +end + +function requestServer(actionCode, bin, callback, isKeep) + sendServer(actionCode, bin) + addListener(actionCode, callback, isKeep) +end + +local function heartBeat() + sendServer(actionCodes.Sys_heartBeat, "") + skynet.timeout(500, heartBeat) +end + +local function startUnit(unit) + if unit == "login" then + else + unit = math.randWeight(config.units, "weight") + end + + local ok, unitTest = pcall(require, "unitTest." .. unit) + if not ok then + print("unitTest load error : " .. unitTest) + end + + unitTest.new(client):startTest() +end + +local function handle_timeout10000() + rpcServer(actionCodes.Gm_clientRequest, MsgPack.pack({cmd = "get", pm1 = 1, pm2 = 500})) + rpcServer(actionCodes.Gm_clientRequest, MsgPack.pack({cmd = "get", pm1 = 2, pm2 = 500})) + skynet.timeout(10000, handle_timeout6000) +end + +-- 登录成功开始任务 +function CMD.task() + heartBeat() + startUnit() +end + +-- 开始登录 +function CMD.start(fd, id) + client.fd = fd + client.clientId = id + + local uname = config.uname_prefix .. id + client.uname = uname + local status, body = httpc.get(config.http, "/login?" .. httpGetFormatData({token = uname, device = "test", channel = "develop"})) + if tonumber(status) ~= 200 then + print("http get error", uname, body) + return + end + local servInfo = json.decode(body) + client.uid = servInfo.userid + + startUnit("login") +end + +-- 退出 +function CMD.exit() + skynet.exit() +end + +skynet.register_protocol { + name = "client", + id = skynet.PTYPE_CLIENT, + unpack = function (msg, sz) + local data = skynet.tostring(msg, sz) + local cmd = string.unpack("H", string.sub(data, 1, 2)) + return cmd, string.sub(data, 3) + end, + dispatch = function(session, address, cmd, data) + local actionName = actionHandlers[cmd] + if not actionName then + print("actionName not exist", actionName) + return + end + + if cmd > rpcResponseBegin and actionName ~= "Role.queryLoginRpcResponse" then + -- 回复 有session + session = string.unpack("H", string.sub(data, 1, 2)) + data = string.sub(data, 3) + end + + triggerListener(actionName, data) + end, +} + +skynet.start(function () + skynet.dispatch("lua", function (_,_,cmd,...) + skynet.ret(skynet.pack(CMD[cmd](...))) + end) +end) diff --git a/robot/robot_config.lua b/robot/robot_config.lua new file mode 100644 index 0000000..56ae0f2 --- /dev/null +++ b/robot/robot_config.lua @@ -0,0 +1,38 @@ +local skynet = require "skynet" +local string_format = string.format +local math_floor = math.floor + + +function log( msg ) + print(string_format("[%s]: %s", os.date("%m%d %H:%M:%S", math_floor(skynet.time())), msg)) +end + + + +return { + http = "http://106.13.60.20:9090", -- 登录服 + host = "127.0.0.1", --服务器地址 + port = 12001, -- 服务器端口 + + + online = 100, -- 稳定状态在线人数 + inpre = 10, -- 稳定前每秒进入人数 -- 必须小于online数 + max = 200, -- 最大玩家数 必须大于 online 数 + online_time = {10 * 60, 20 * 60}, -- 在线时间控制 秒 + + uname_prefix = "robot", --机器名称前缀 + + + -- 机器上线后的行为 + units = { + chat = {weight = 100}, -- 聊天 + item = {weight = 100}, -- 物品操作 + hero = {weight = 500}, -- 英雄 + hang = {weight = 1000}, -- 挂机战斗 + tower = {weight = 500}, -- 爬塔 + car = {weight = 100}, -- 爬塔 + pvp = {weight = 500}, -- pvp + email = {weight = 100}, -- 邮件 + adv = {weight = 200}, -- 冒险 + } +} diff --git a/robot/start.lua b/robot/start.lua new file mode 100644 index 0000000..fb6605a --- /dev/null +++ b/robot/start.lua @@ -0,0 +1,135 @@ +require("utils.StringUtil") +require("utils.TableUtil") +require "utils.MathUtil" +local config = require "robot_config" +local skynet = require "skynet" +local netpack = require "skynet.netpack" +local socketdriver = require "skynet.socketdriver" +local string_format = string.format + +local queue = {} +local fd2serv = {} +local id2fd = {} +local MSG = {} +local id_max = 0 -- robot id + + +function MSG.open( ... ) + print("open", ...) +end + +function MSG.close(fd) + if fd2serv[fd] then + skynet.send(fd2serv[fd].agent, "lua", "exit") + + log(string_format("logout %s", fd2serv[fd].id)) + + id2fd[fd2serv[fd].id] = nil + fd2serv[fd] = nil + end +end + +function MSG.error(fd, msg) + print("MSG.error", fd, msg) + MSG.close(fd) +end + +function MSG.data(fd, msg, sz) + if fd2serv[fd] then + skynet.redirect(fd2serv[fd].agent, 0, "client", 0, msg, sz) + end +end + +local function dispatch_queue() + local fd, msg, sz = netpack.pop(queue) + if fd then + skynet.fork(dispatch_queue) + MSG.data(fd, msg, sz) + for fd, msg, sz in netpack.pop, queue do + MSG.data(fd, msg, sz) + end + end +end +MSG.more = dispatch_queue + +skynet.register_protocol { + name = "socket", + id = skynet.PTYPE_SOCKET, + unpack = function (msg, sz) + return netpack.filter(queue, msg, sz) + end, + dispatch = function (_, _, q, type, ...) + queue = q + if type then + MSG[type](...) + end + end +} + +skynet.register_protocol { + name = "client", + id = skynet.PTYPE_CLIENT, +} + +local function add_robot() + local robot = skynet.newservice("robot") + local fd = socketdriver.connect(config.host, config.port) + socketdriver.start(fd) + local id + if id_max >= config.max then + while true do + id = math.randomInt(1, config.max) + if not id2fd[id] then + break + end + end + else + id_max = id_max + 1 + id = id_max + end + fd2serv[fd] = {agent = robot, id = id} + id2fd[id] = fd + pcall(skynet.call, robot, "lua", "start", fd, id) + log(string_format("login %s", fd2serv[fd].id)) + + -- 定时下线 + skynet.timeout(math.randomInt(config.online_time[1], config.online_time[2]) * 100, function() + socketdriver.close(fd) + MSG.close(fd) + end) +end + +local function online() + local curCount = 0 + for _, _ in pairs(fd2serv) do + curCount = curCount + 1 + end + + -- 及时补充人数 + if curCount < config.online then + for i = curCount + 1, config.online do + add_robot() + end + end + + -- log(string_format("online %s", curCount)) + skynet.timeout(100, online) +end + +local function start() + log("start testing ...") + + for i = 1, config.online, config.inpre do + for j = 1, config.inpre do + add_robot() + end + skynet.sleep(100) + end + + -- 每秒检查补充在线人数 + online() +end + +skynet.start(function() + skynet.fork(start) +end) \ No newline at end of file diff --git a/robot/unitTest/adv.lua b/robot/unitTest/adv.lua new file mode 100644 index 0000000..e5e53e2 --- /dev/null +++ b/robot/unitTest/adv.lua @@ -0,0 +1,38 @@ +local MsgPack = MsgPack +local skynet = require "skynet" + + +local TIME_WAIT = 10 + +local _M = class("hang", require("unitTest.unitTest")) + +function _M:start() + sendServer(actionCodes.Gm_clientRequest, MsgPack.pack({cmd = "fb", pm1 = 10606})) + self:task() +end + + +local taskMap = { + startAdv = {100}, + rank = {10}, +} + +function _M:task() + local curTask = math.randWeight(taskMap, 1) + self[curTask](self) + skynet.timeout(TIME_WAIT * 100, handler(self, self.task)) +end + +function _M:startAdv() + sendServer(actionCodes.Gm_clientRequest, MsgPack.pack({cmd = "advf", pm1 = 10606})) + requestServer(actionCodes.Adv_startAdvRpc, MsgPack.pack({chapterId = 101, format = {leader = 1, leader2 = 2, heros = {[1] = 1, [2] = 2}}})) + requestServer(actionCodes.Adv_exitAdvRpc, '') +end + + +function _M:rank() + requestServer(actionCodes.Adv_rankRpc, '') +end + + +return _M \ No newline at end of file diff --git a/robot/unitTest/car.lua b/robot/unitTest/car.lua new file mode 100644 index 0000000..eb79778 --- /dev/null +++ b/robot/unitTest/car.lua @@ -0,0 +1,34 @@ +local MsgPack = MsgPack +local skynet = require "skynet" + + +local TIME_WAIT = 10 + +local _M = class("hang", require("unitTest.unitTest")) + +function _M:start() + sendServer(actionCodes.Gm_clientRequest, MsgPack.pack({cmd = "fb", pm1 = 10606})) + self:task() +end + + +local taskMap = { + equip = {100}, +} + +function _M:task() + local curTask = math.randWeight(taskMap, 1) + self[curTask](self) + skynet.timeout(TIME_WAIT * 100, handler(self, self.task)) +end + +function _M:equip() + sendServer(actionCodes.Gm_clientRequest, MsgPack.pack({cmd = "get", pm1 = 7103})) + requestServer(actionCodes.Car_saleEquipRpc, MsgPack.pack({backs = {[7103] = 1}})) +end + + + + + +return _M \ No newline at end of file diff --git a/robot/unitTest/chat.lua b/robot/unitTest/chat.lua new file mode 100644 index 0000000..60d203f --- /dev/null +++ b/robot/unitTest/chat.lua @@ -0,0 +1,43 @@ +local MsgPack = MsgPack +local skynet = require "skynet" + + +local TIME_WAIT = 10 + +local _M = class("chat", require("unitTest.unitTest")) + +function _M:start() + self:task() +end + +local taskMap = { + chat = {100}, + searchFriend = {100}, + friendList = {100}, + friendRandom = {100}, +} + +function _M:task() + local curTask = math.randWeight(taskMap, 1) + self[curTask](self) + skynet.timeout(TIME_WAIT * 100, handler(self, self.task)) +end + + +function _M:chat() + requestServer(actionCodes.Role_chatRpc, MsgPack.pack({ cmd = 1, content = "我就是个机器人, 我来测试测试没问题吧。"})) +end + +function _M:searchFriend() + requestServer(actionCodes.Friend_searchRpc, MsgPack.pack({ key = "hehehe"})) +end + +function _M:friendList() + requestServer(actionCodes.Friend_listRpc, '') +end + +function _M:friendRandom() + requestServer(actionCodes.Friend_randomRpc, '') +end + +return _M \ No newline at end of file diff --git a/robot/unitTest/email.lua b/robot/unitTest/email.lua new file mode 100644 index 0000000..da38f16 --- /dev/null +++ b/robot/unitTest/email.lua @@ -0,0 +1,39 @@ +local MsgPack = MsgPack +local skynet = require "skynet" + + +local TIME_WAIT = 10 + +local _M = class("hero", require("unitTest.unitTest")) + +function _M:start() + self:task() +end + + +local taskMap = { + list = {100}, + drawAllAttach = {100}, + delete = {100}, +} + +function _M:task() + local curTask = math.randWeight(taskMap, 1) + self[curTask](self) + skynet.timeout(TIME_WAIT * 100, handler(self, self.task)) +end + +function _M:list() + requestServer(actionCodes.Email_listRpc, '') +end + +function _M:drawAllAttach() + requestServer(actionCodes.Email_drawAllAttachRpc, '') +end + +function _M:delete() + requestServer(actionCodes.Email_delRpc, '') +end + + +return _M \ No newline at end of file diff --git a/robot/unitTest/hang.lua b/robot/unitTest/hang.lua new file mode 100644 index 0000000..4011f0c --- /dev/null +++ b/robot/unitTest/hang.lua @@ -0,0 +1,37 @@ +local MsgPack = MsgPack +local skynet = require "skynet" + + +local TIME_WAIT = 10 + +local _M = class("hang", require("unitTest.unitTest")) + +function _M:start() + self:task() +end + + +local taskMap = { + hangBattle = {100}, +} + +function _M:task() + local curTask = math.randWeight(taskMap, 1) + self[curTask](self) + skynet.timeout(TIME_WAIT * 100, handler(self, self.task)) +end + +function _M:hangBattle() + sendServer(actionCodes.Gm_clientRequest, MsgPack.pack({cmd = "fbc", pm1 = 10101})) + requestServer(actionCodes.Hang_startRpc, MsgPack.pack({carbonId = 10101}), function() + requestServer(actionCodes.Hang_startBattleRpc, MsgPack.pack({carbonId = 10101}), function(data) + local msg = MsgPack.unpack(data) + requestServer(actionCodes.Hang_endBattleRpc, MsgPack.pack({key = msg.key, carbonId = 10101, starNum = 1})) + end) + end) +end + + + + +return _M \ No newline at end of file diff --git a/robot/unitTest/hero.lua b/robot/unitTest/hero.lua new file mode 100644 index 0000000..6991c22 --- /dev/null +++ b/robot/unitTest/hero.lua @@ -0,0 +1,43 @@ +local MsgPack = MsgPack +local skynet = require "skynet" + + +local TIME_WAIT = 10 + +local _M = class("hero", require("unitTest.unitTest")) + +function _M:start() + sendServer(actionCodes.Gm_clientRequest, MsgPack.pack({cmd = "fb", pm1 = 10606})) + self:task() +end + + +local taskMap = { + drawHero = {100}, + drawHero10 = {10}, + createHeroRandom = {10000}, +} + +function _M:task() + local curTask = math.randWeight(taskMap, 1) + self[curTask](self) + skynet.timeout(TIME_WAIT * 100, handler(self, self.task)) +end + +function _M:drawHero() + sendServer(actionCodes.Gm_clientRequest, MsgPack.pack({cmd = "get", pm1 = 3, pm2 = 400})) + requestServer(actionCodes.Hero_drawHeroRpc, MsgPack.pack({pool = 1, type = 1})) +end + +function _M:drawHero10() + sendServer(actionCodes.Gm_clientRequest, MsgPack.pack({cmd = "get", pm1 = 3, pm2 = 4000})) + requestServer(actionCodes.Hero_drawHeroRpc, MsgPack.pack({pool = 2, type = 2})) +end + +function _M:createHeroRandom() + sendServer(actionCodes.Gm_clientRequest, MsgPack.pack({cmd = "get", pm1 = 703, pm2 = 20})) + requestServer(actionCodes.Hero_createHeroRandomRpc, MsgPack.pack({itemId = 703})) +end + + +return _M \ No newline at end of file diff --git a/robot/unitTest/item.lua b/robot/unitTest/item.lua new file mode 100644 index 0000000..f1e75ec --- /dev/null +++ b/robot/unitTest/item.lua @@ -0,0 +1,46 @@ +local MsgPack = MsgPack +local skynet = require "skynet" + + +local TIME_WAIT = 10 + +local _M = class("item", require("unitTest.unitTest")) + +function _M:start() + self:task() +end + + +local taskMap = { + saleItem = {100}, + openItem = {100}, + openTimeBox = {100}, +} + +function _M:task() + local curTask = math.randWeight(taskMap, 1) + self[curTask](self) + skynet.timeout(TIME_WAIT * 100, handler(self, self.task)) +end + + +function _M:saleItem() + sendServer(actionCodes.Gm_clientRequest, MsgPack.pack({cmd = "get", pm1 = 105, pm2 = 500})) + requestServer(actionCodes.Role_saleItemRpc, MsgPack.pack({backs = {[105] = 500}})) +end + + +function _M:openItem() + sendServer(actionCodes.Gm_clientRequest, MsgPack.pack({cmd = "get", pm1 = 701, pm2 = 20})) + requestServer(actionCodes.Role_openItemRpc, MsgPack.pack({itemId = 701, count = 1})) +end + +function _M:openTimeBox() + sendServer(actionCodes.Gm_clientRequest, MsgPack.pack({cmd = "get", pm1 = 6001, pm2 = 1})) + sendServer(actionCodes.Gm_clientRequest, MsgPack.pack({cmd = "get", pm1 = 60, pm2 = 100})) + requestServer(actionCodes.Role_openTimeBoxRpc, MsgPack.pack({oper = 1, slot = 1, itemId = 6001}), function() + requestServer(actionCodes.Role_openTimeBoxRpc, MsgPack.pack({oper = 2, slot = 1, quick = 1})) + end) +end + +return _M \ No newline at end of file diff --git a/robot/unitTest/login.lua b/robot/unitTest/login.lua new file mode 100644 index 0000000..91e6238 --- /dev/null +++ b/robot/unitTest/login.lua @@ -0,0 +1,90 @@ +local MsgPack = MsgPack +local skynet = require "skynet" + +local _M = class("login", require("unitTest.unitTest")) + +function _M:start() + requestServer(actionCodes.Role_queryLoginRpc, MsgPack.pack({uid = self.client.uid}), handler(self, self.onQueryLogin)) +end + +function _M:onQueryLogin(data) + local msg = MsgPack.unpack(data) + + if msg.ret == "RET_NOT_EXIST" then + requestServer(actionCodes.Role_createRpc, MsgPack.pack({ uid = self.client.uid }), function(data2) + local msg2 = MsgPack.unpack(data2) + self:sendLogin(msg2.roleName) + end) + elseif msg.ret == "RET_HAS_EXISTED" then + self:sendLogin(msg.name) + elseif msg.ret == "INNER_ERROR" then + -- 过几秒中尝试登录 + -- local time = math.random(5)*100 + -- skynet.timeout(time, function () + -- rpcServer(actionCodes.Role_queryLoginRpc, MsgPack.pack({uid = self.client.uid})) + -- end) + print("INNER_ERROR") + end +end + + +function _M:sendLogin(name) + self.client.name = name + + local totalWave = 0 + local roleData = {} + local waveTag = {} + + requestServer(actionCodes.Role_loginRpc, MsgPack.pack({name = self.client.name, codeVersion = 1}), function(data) + local msg = MsgPack.unpack(data) + if msg.wave then + totalWave = msg.wave + for key, value in pairs(msg) do + roleData[key] = value + end + waveTag[1] = true + end + + if msg.runeWave then + if not roleData.runeBag then + roleData.runeBag = {} + end + for _, rune in pairs(msg.runeBag) do + table.insert(roleData.runeBag, rune) + end + waveTag[msg.runeWave] = true + end + + if msg.heroWave then + if not roleData.heros then + roleData.heros = {} + end + for _, hero in pairs(msg.heros) do + table.insert(roleData.heros, hero) + end + waveTag[msg.heroWave] = true + end + + if msg.chatWave then + waveTag[msg.chatWave] = true + end + + -- 检查是否全部接收完 + if totalWave > 0 then + local finish = true + for _wave = 1, totalWave do + if not waveTag[_wave] then + finish = false + break + end + end + if finish then + self.client.role = roleData + removeListener(actionCodes.Role_loginRpc) + pcall(skynet.call, skynet.self(), "lua", "task") -- 开始任务 + end + end + end, true) +end + +return _M \ No newline at end of file diff --git a/robot/unitTest/pvp.lua b/robot/unitTest/pvp.lua new file mode 100644 index 0000000..c41f0f0 --- /dev/null +++ b/robot/unitTest/pvp.lua @@ -0,0 +1,47 @@ +local MsgPack = MsgPack +local skynet = require "skynet" + + +local TIME_WAIT = 10 + +local _M = class("pvp", require("unitTest.unitTest")) + +function _M:start() + sendServer(actionCodes.Gm_clientRequest, MsgPack.pack({cmd = "fb", pm1 = 10606})) + self:task() +end + + +local taskMap = { + info = {1000}, + refresh = {100}, + rank = {100}, + record = {100}, +} + +function _M:task() + local curTask = math.randWeight(taskMap, 1) + self[curTask](self) + skynet.timeout(TIME_WAIT * 100, handler(self, self.task)) +end + +function _M:info() + requestServer(actionCodes.Pvp_infoRpc, MsgPack.pack({ptype = 1})) +end + +function _M:refresh() + requestServer(actionCodes.Pvp_refreshMatchCRpc, '') +end + + +function _M:rank() + requestServer(actionCodes.Pvp_rankListRpc, MsgPack.pack({ptype = 1})) +end + +function _M:record() + requestServer(actionCodes.Pvp_recordListRpc, MsgPack.pack({ptype = 1})) +end + + + +return _M \ No newline at end of file diff --git a/robot/unitTest/tower.lua b/robot/unitTest/tower.lua new file mode 100644 index 0000000..4133ef2 --- /dev/null +++ b/robot/unitTest/tower.lua @@ -0,0 +1,40 @@ +local MsgPack = MsgPack +local skynet = require "skynet" + + +local TIME_WAIT = 10 + +local _M = class("hang", require("unitTest.unitTest")) + +function _M:start() + sendServer(actionCodes.Gm_clientRequest, MsgPack.pack({cmd = "fb", pm1 = 10606})) + self:task() +end + + +local taskMap = { + towerBattle = {100}, + towerRank = {3}, +} + +function _M:task() + local curTask = math.randWeight(taskMap, 1) + self[curTask](self) + skynet.timeout(TIME_WAIT * 100, handler(self, self.task)) +end + +function _M:towerBattle() + sendServer(actionCodes.Gm_clientRequest, MsgPack.pack({cmd = "tower", pm1 = 1})) + requestServer(actionCodes.Tower_startBattleRpc, MsgPack.pack({id = 1}), function(data) + requestServer(actionCodes.Tower_endBattleRpc, MsgPack.pack({key = self.client.role.towerInfo.k, id = 1, passTime = 100, starNum = 1})) + end) +end + +function _M:towerRank() + requestServer(actionCodes.Tower_rankRpc, MsgPack.pack({id = 1})) +end + + + + +return _M \ No newline at end of file diff --git a/robot/unitTest/unitTest.lua b/robot/unitTest/unitTest.lua new file mode 100644 index 0000000..eeee981 --- /dev/null +++ b/robot/unitTest/unitTest.lua @@ -0,0 +1,16 @@ +local unitTest = class("unitTest") + + +function unitTest:ctor(client) + self.client = client +end + +function unitTest:startTest() + self:start() +end + +function unitTest:start() + print("no start") +end + +return unitTest \ No newline at end of file -- libgit2 0.21.2