Commit 21774ba5b42decc10bfbc006f1006f8d9d5adaa7
1 parent
8641a577
feat: 金币购买铭文碎片
Showing
2 changed files
with
16 additions
and
0 deletions
Show diff stats
src/ProtocolCode.lua
@@ -55,6 +55,7 @@ actionCodes = { | @@ -55,6 +55,7 @@ actionCodes = { | ||
55 | Role_updateSpark = 139, -- 更新火花 | 55 | Role_updateSpark = 139, -- 更新火花 |
56 | Role_diamondConvertRpc = 140, -- 钻石兑换成别的物品 | 56 | Role_diamondConvertRpc = 140, -- 钻石兑换成别的物品 |
57 | Role_getTimeGiftRpc = 141, | 57 | Role_getTimeGiftRpc = 141, |
58 | + Role_runeBuyRpc = 142, -- 铭文购买 | ||
58 | 59 | ||
59 | Adv_startAdvRpc = 151, | 60 | Adv_startAdvRpc = 151, |
60 | Adv_startHangRpc = 152, | 61 | Adv_startHangRpc = 152, |
src/actions/RoleAction.lua
@@ -1568,4 +1568,19 @@ function _M.getTimeGiftRpc(agent, data) | @@ -1568,4 +1568,19 @@ function _M.getTimeGiftRpc(agent, data) | ||
1568 | return true | 1568 | return true |
1569 | end | 1569 | end |
1570 | 1570 | ||
1571 | +function _M.runeBuyRpc(agent, data) | ||
1572 | + local role = agent.role | ||
1573 | + local msg = MsgPack.unpack(data) | ||
1574 | + local count = msg.count | ||
1575 | + | ||
1576 | + local glodCount = globalCsv.rune_exchange * count | ||
1577 | + if not role:checkItemEnough({[ItemId.Gold] = glodCount}) then return end | ||
1578 | + role:costItems({[ItemId.Gold] = glodCount}, {log = {desc = "glodConvertRune", int1 = count, int2 = glodCount}}) | ||
1579 | + local reward, change = {} | ||
1580 | + reward[ItemId.RuneFragment] = count | ||
1581 | + reward, change = role:award(reward, {log = {desc = "glodConvertRune"}}) | ||
1582 | + SendPacket(actionCodes.Role_runeBuyRpc, MsgPack.pack(role:packReward(reward, change))) | ||
1583 | + return true | ||
1584 | +end | ||
1585 | + | ||
1571 | return _M | 1586 | return _M |
1572 | \ No newline at end of file | 1587 | \ No newline at end of file |