item.lua
1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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 = 831, pm2 = 1}))
requestServer(actionCodes.Role_openItemRpc, MsgPack.pack({itemId = 831, 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