Commit ca77b8d12a083457cf9cebe793875b4e79427343
Merge branch 'cn/develop-mysql' of 120.26.43.151:wasteland/server into cn/develop-mysql
Showing
3 changed files
with
42 additions
and
1 deletions
Show diff stats
src/ProtocolCode.lua
| @@ -53,6 +53,7 @@ actionCodes = { | @@ -53,6 +53,7 @@ actionCodes = { | ||
| 53 | Role_accuseRpc = 137, -- 举报 | 53 | Role_accuseRpc = 137, -- 举报 |
| 54 | Role_loadSparks = 138, | 54 | Role_loadSparks = 138, |
| 55 | Role_updateSpark = 139, -- 更新火花 | 55 | Role_updateSpark = 139, -- 更新火花 |
| 56 | + Role_diamondConvertRpc = 140, -- 钻石兑换成别的物品 | ||
| 56 | 57 | ||
| 57 | Adv_startAdvRpc = 151, | 58 | Adv_startAdvRpc = 151, |
| 58 | Adv_startHangRpc = 152, | 59 | Adv_startHangRpc = 152, |
src/actions/RoleAction.lua
| @@ -1395,6 +1395,46 @@ function _M.goldBuyRpc(agent, data) | @@ -1395,6 +1395,46 @@ function _M.goldBuyRpc(agent, data) | ||
| 1395 | return true | 1395 | return true |
| 1396 | end | 1396 | end |
| 1397 | 1397 | ||
| 1398 | +function _M.diamondConvertRpc(agent, data) | ||
| 1399 | + local role = agent.role | ||
| 1400 | + local msg = MsgPack.unpack(data) | ||
| 1401 | + | ||
| 1402 | + local oper = msg.oper | ||
| 1403 | + if oper ~= 1 and oper ~= 2 then return 0 end | ||
| 1404 | + | ||
| 1405 | + local cost = math.ceil(msg.cost or 0) | ||
| 1406 | + if cost <= 0 then return 1 end | ||
| 1407 | + if role:getAllDiamond() < cost then return 2 end | ||
| 1408 | + | ||
| 1409 | + local get = globalCsv.legal_tender_cost * cost | ||
| 1410 | + role:costDiamond({count = cost, log = {desc = "convert", int1 = ItemType.Jade, int2 = get}}) | ||
| 1411 | + local reward, change | ||
| 1412 | + if oper == 1 then -- 钻石兑换成虹光玉 | ||
| 1413 | + reward, change = role:award({[ItemId.Jade] = get}, {log = {desc = "convert"}}) | ||
| 1414 | + elseif oper == 2 then -- 钻石兑换成虹光玉再兑换成招募券 | ||
| 1415 | + local quan = math.floor(get/globalCsv.recruit_cost) | ||
| 1416 | + reward[ItemType.Jade] = reward[ItemType.Jade] - quan * globalCsv.recruit_cost | ||
| 1417 | + if reward[ItemType.Jade] == 0 then | ||
| 1418 | + reward[ItemType.Jade] = nil | ||
| 1419 | + end | ||
| 1420 | + if quan > 0 then | ||
| 1421 | + local tReward, tChange = role:award({[70] = quan}, {log = {desc = "convert"}}) | ||
| 1422 | + for id, value in pairs(tReward) do | ||
| 1423 | + reward[id] = reward[id] + value | ||
| 1424 | + end | ||
| 1425 | + if tChange then | ||
| 1426 | + change = change or {} | ||
| 1427 | + for id, value in pairs(tChange) do | ||
| 1428 | + change[id] = change[id] + value | ||
| 1429 | + end | ||
| 1430 | + end | ||
| 1431 | + end | ||
| 1432 | + end | ||
| 1433 | + | ||
| 1434 | + SendPacket(actionCodes.Role_diamondConvertRpc, MsgPack.pack(role:packReward(reward, change))) | ||
| 1435 | + return true | ||
| 1436 | +end | ||
| 1437 | + | ||
| 1398 | function _M.getDownloadCvRewardRpc(agent, data) | 1438 | function _M.getDownloadCvRewardRpc(agent, data) |
| 1399 | local role = agent.role | 1439 | local role = agent.role |
| 1400 | local flag = role:getProperty("downCvR") or 0 | 1440 | local flag = role:getProperty("downCvR") or 0 |
src/models/RoleLog.lua
| @@ -58,7 +58,7 @@ local ItemReason = { | @@ -58,7 +58,7 @@ local ItemReason = { | ||
| 58 | newSign = 142,-- 新的活动签到 | 58 | newSign = 142,-- 新的活动签到 |
| 59 | advLevelStage = 143, -- 拾荒活动阶段奖励 | 59 | advLevelStage = 143, -- 拾荒活动阶段奖励 |
| 60 | towerBnous = 144, -- 爬塔到一定层数对某些功能的奖励 | 60 | towerBnous = 144, -- 爬塔到一定层数对某些功能的奖励 |
| 61 | - | 61 | + convert = 145, -- 钻石兑换其他物品 |
| 62 | 62 | ||
| 63 | advHang = 301, -- 拾荒挂机 | 63 | advHang = 301, -- 拾荒挂机 |
| 64 | hangBattle = 302, -- 挂机战斗 | 64 | hangBattle = 302, -- 挂机战斗 |