Commit 3b069d52ce1c224ca8e1639c98d991827e335f83
1 parent
2445248d
增加获取 food 后台
Showing
3 changed files
with
33 additions
and
0 deletions
Show diff stats
src/ProtocolCode.lua
| @@ -54,6 +54,7 @@ actionCodes = { | @@ -54,6 +54,7 @@ actionCodes = { | ||
| 54 | Hero_createHeroRpc = 215, | 54 | Hero_createHeroRpc = 215, |
| 55 | Hero_referEquipsRpc = 216, | 55 | Hero_referEquipsRpc = 216, |
| 56 | Hero_referRunesRpc = 217, | 56 | Hero_referRunesRpc = 217, |
| 57 | + Hero_createHeroRandomRpc = 218, | ||
| 57 | 58 | ||
| 58 | Hang_startRpc = 251, | 59 | Hang_startRpc = 251, |
| 59 | Hang_checkRpc = 252, | 60 | Hang_checkRpc = 252, |
src/actions/GmAction.lua
| @@ -64,6 +64,12 @@ function _M.get(role, pms) | @@ -64,6 +64,12 @@ function _M.get(role, pms) | ||
| 64 | role:award({[itemId] = 100}) | 64 | role:award({[itemId] = 100}) |
| 65 | end | 65 | end |
| 66 | end | 66 | end |
| 67 | + elseif pms.pm1 == "FOOD" then | ||
| 68 | + for itemId = 4000 , 5000 do | ||
| 69 | + if csvdb["itemCsv"][itemId] then | ||
| 70 | + role:award({[itemId] = 100}) | ||
| 71 | + end | ||
| 72 | + end | ||
| 67 | else | 73 | else |
| 68 | local itemId = tonum(pms.pm1) | 74 | local itemId = tonum(pms.pm1) |
| 69 | if not csvdb["itemCsv"][itemId] then | 75 | if not csvdb["itemCsv"][itemId] then |
src/actions/HeroAction.lua
| @@ -581,4 +581,30 @@ function _M.referRunesRpc(agent, data) | @@ -581,4 +581,30 @@ function _M.referRunesRpc(agent, data) | ||
| 581 | return true | 581 | return true |
| 582 | end | 582 | end |
| 583 | 583 | ||
| 584 | +function _M.createHeroRandomRpc(agent, data) | ||
| 585 | + local role = agent.role | ||
| 586 | + local msg = MsgPack.unpack(data) | ||
| 587 | + local itemId = msg.itemId | ||
| 588 | + local itemData = csvdb["itemCsv"][itemId] | ||
| 589 | + if not itemData or itemData.type ~= ItemType.HeroFCommon then return end | ||
| 590 | + local cost = globalCsv.unit_fragment_cost[itemData.quality] | ||
| 591 | + if not cost or role:getItemCount(itemId) < cost then return end | ||
| 592 | + | ||
| 593 | + local randomData = csvdb["item_randomCsv"][tonumber(itemData.use_effect)] | ||
| 594 | + if not randomData then return end | ||
| 595 | + | ||
| 596 | + local temp = randomData.random_gift:randWeight(true) | ||
| 597 | + if not temp or not next(temp) then return end | ||
| 598 | + local reward = {} | ||
| 599 | + if role:isHaveHero(temp[1]) then | ||
| 600 | + reward = {[temp[1]] = cost} | ||
| 601 | + else | ||
| 602 | + reward = {[temp[1] + ItemStartId.Hero] = 1} | ||
| 603 | + end | ||
| 604 | + role:costItems({[itemId] = cost}) | ||
| 605 | + reward = role:award(reward) | ||
| 606 | + SendPacket(actionCodes.Hero_createHeroRandomRpc, MsgPack.pack({reward = reward})) | ||
| 607 | + return true | ||
| 608 | +end | ||
| 609 | + | ||
| 584 | return _M | 610 | return _M |
| 585 | \ No newline at end of file | 611 | \ No newline at end of file |