be83d162
zhouahaihai
登陆成功。 增加数据结构修正功能
|
1
2
3
4
5
6
7
8
9
10
11
|
local RolePlugin = {}
function RolePlugin.bind(Role)
function Role:log()
end
function Role:loadAll()
|
0a07bdd9
zhouahaihai
角色升级 。gm
|
12
|
self:loadHeros()
|
be83d162
zhouahaihai
登陆成功。 增加数据结构修正功能
|
13
14
15
|
end
function Role:reloadWhenLogin()
|
0a07bdd9
zhouahaihai
角色升级 。gm
|
16
17
18
19
20
21
22
23
24
25
26
27
|
end
function Role:onCrossDay(now)
end
function Role:addHero(params)
local roleId = self:getProperty("id")
local heroId = tonum(redisproxy:hincrby(string.format(R_INCR, roleId), "hero", 1))
local heroType = params.type
local unitData = csvdb["unitCsv"][heroType]
|
be83d162
zhouahaihai
登陆成功。 增加数据结构修正功能
|
28
|
|
0a07bdd9
zhouahaihai
角色升级 。gm
|
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
redisproxy:sadd(string.format(R_HEROS, roleId), heroId)
local heroInfo = {
key = string.format(R_HERO, roleId, heroId),
id = heroId,
type= heroType,
}
local newHero = require("models.Hero").new(heroInfo)
newHero:create()
newHero.owner = self
self.heros[heroId] = newHero
if not params.notNotify then
local heroResponse = {}
table.insert(heroResponse, newHero:data())
local bin = MsgPack.pack(heroResponse)
SendPacket(actionCodes.Hero_loadInfos, bin)
end
|
be83d162
zhouahaihai
登陆成功。 增加数据结构修正功能
|
48
49
|
end
|
0a07bdd9
zhouahaihai
角色升级 。gm
|
50
51
52
53
54
55
56
57
58
59
60
61
|
function Role:delHero(params)
local roleId = self:getProperty('id')
local hero = self.heros[heroId]
if not hero then return end
self.heros[heroId] = nil
redisproxy:pipelining(function (red)
red:del(string.format(R_HERO, roleId, heroId))
red:srem(string.format(R_HEROS, roleId), heroId)
end)
SendPacket(actionCodes.Hero_loadInfos, MsgPack.pack({{id = heroId, bDel = true}}))
end
|
be83d162
zhouahaihai
登陆成功。 增加数据结构修正功能
|
62
|
|
0a07bdd9
zhouahaihai
角色升级 。gm
|
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
function Role:loadHeros()
local roleId = self:getProperty("id")
local heroIds = redisproxy:smembers(string.format(R_HEROS, roleId))
local redret = redisproxy:pipelining(function (red)
for _, heroId in ipairs(heroIds) do
red:hgetall(string.format(R_HERO, roleId, heroId))
end
end)
for index, heroId in ipairs(heroIds) do
local hero = require("models.Hero").new({key = string.format(R_HERO, roleId, heroId)})
if hero:load(table.array2Table(redret[index])) then
hero.owner = self
self.heros[tonumber(heroId)] = hero
end
end
end
-- 发奖功能入口
function Role:award()
end
|
be83d162
zhouahaihai
登陆成功。 增加数据结构修正功能
|
84
85
86
|
end
return RolePlugin
|