Commit 7356e583270cfda8e46be6118b508ed261de745d
1 parent
344d2df3
feat: 增加角色注销协议
Showing
4 changed files
with
26 additions
and
2 deletions
Show diff stats
src/ProtocolCode.lua
@@ -65,6 +65,7 @@ actionCodes = { | @@ -65,6 +65,7 @@ actionCodes = { | ||
65 | Role_worldLineRouletteRpc = 146, --世界线抽轮盘 | 65 | Role_worldLineRouletteRpc = 146, --世界线抽轮盘 |
66 | Role_worldLineRewardRpc = 147, -- 世界线一键领取奖励 | 66 | Role_worldLineRewardRpc = 147, -- 世界线一键领取奖励 |
67 | Role_itemConvertDevilTicketRpc = 148, -- 兑换魔鬼训练营门票 | 67 | Role_itemConvertDevilTicketRpc = 148, -- 兑换魔鬼训练营门票 |
68 | + Role_unRegisterRpc = 149, --注销账号 | ||
68 | 69 | ||
69 | Adv_startAdvRpc = 151, | 70 | Adv_startAdvRpc = 151, |
70 | Adv_startHangRpc = 152, | 71 | Adv_startHangRpc = 152, |
src/actions/RoleAction.lua
@@ -506,6 +506,20 @@ function _M.createRpc(agent, data) | @@ -506,6 +506,20 @@ function _M.createRpc(agent, data) | ||
506 | return true | 506 | return true |
507 | end | 507 | end |
508 | 508 | ||
509 | +function _M.unRegisterRpc(agent, data) | ||
510 | + local role = agent.role | ||
511 | + local roleId = role:getProperty("id") | ||
512 | + local msg = MsgPack.unpack(data) | ||
513 | + local id = msg.roleId | ||
514 | + if id ~= roleId then | ||
515 | + return 0 | ||
516 | + end | ||
517 | + | ||
518 | + if not roleUnRegister(roleId) then return 1 end | ||
519 | + SendPacket(actionCodes.Role_unRegisterRpc, MsgPack.pack({})) | ||
520 | + return true | ||
521 | +end | ||
522 | + | ||
509 | function _M.changeNameRpc(agent, data) | 523 | function _M.changeNameRpc(agent, data) |
510 | local role = agent.role | 524 | local role = agent.role |
511 | local roleId = role:getProperty("id") | 525 | local roleId = role:getProperty("id") |
src/models/Role.lua
@@ -217,6 +217,7 @@ Role.schema = { | @@ -217,6 +217,7 @@ Role.schema = { | ||
217 | 217 | ||
218 | worldChangePoints = {"table", {}}, -- 世界变动积分 {[1]= 转盘抽取次数, [2]= 获得的积分, [3]=魔导石消耗, [4]= 虹光玉消耗} | 218 | worldChangePoints = {"table", {}}, -- 世界变动积分 {[1]= 转盘抽取次数, [2]= 获得的积分, [3]=魔导石消耗, [4]= 虹光玉消耗} |
219 | worldLineReward = {"table", {}}, -- 世界积分 领取记录 {[id] = 1} | 219 | worldLineReward = {"table", {}}, -- 世界积分 领取记录 {[id] = 1} |
220 | + del = {"number", 0}, -- 标记删除 0=未删除,1=已删除 | ||
220 | } | 221 | } |
221 | 222 | ||
222 | 223 |
src/utils/MysqlUtil.lua
@@ -51,7 +51,7 @@ function delFriend(roleId, friendId) | @@ -51,7 +51,7 @@ function delFriend(roleId, friendId) | ||
51 | end | 51 | end |
52 | 52 | ||
53 | function roleExists(roleId) | 53 | function roleExists(roleId) |
54 | - local res = mysqlproxy:query(string.format("SELECT `id` FROM `Role` WHERE `id` = %s", roleId)) | 54 | + local res = mysqlproxy:query(string.format("SELECT `id` FROM `Role` WHERE `del` = 0 and `id` = %s", roleId)) |
55 | if res["errno"] or not next(res) then | 55 | if res["errno"] or not next(res) then |
56 | return false | 56 | return false |
57 | end | 57 | end |
@@ -60,10 +60,18 @@ function roleExists(roleId) | @@ -60,10 +60,18 @@ function roleExists(roleId) | ||
60 | end | 60 | end |
61 | 61 | ||
62 | function roleUidExists(uid) | 62 | function roleUidExists(uid) |
63 | - local res = mysqlproxy:query(string.format("SELECT `name` FROM `Role` WHERE `uid` = '%s'", uid)) | 63 | + local res = mysqlproxy:query(string.format("SELECT `name` FROM `Role` WHERE `del` = 0 and `uid` = '%s'", uid)) |
64 | if res["errno"] or not next(res) then | 64 | if res["errno"] or not next(res) then |
65 | return false | 65 | return false |
66 | end | 66 | end |
67 | 67 | ||
68 | return true, res[1]["name"] | 68 | return true, res[1]["name"] |
69 | +end | ||
70 | + | ||
71 | +function roleUnRegister(roleId) | ||
72 | + local res = mysqlproxy:query(string.format("UPDATE`Role` SET `del` = 1 WHERE `id` = %s", roleId)) | ||
73 | + if res["errno"] or not next(res) then | ||
74 | + return false | ||
75 | + end | ||
76 | + return true | ||
69 | end | 77 | end |
70 | \ No newline at end of file | 78 | \ No newline at end of file |