Commit ee999bde1e1fe576ded87a907936ac46513cd4f3

Authored by zhouhaihai
1 parent 056c01a0

零件优化

src/ProtocolCode.lua
@@ -23,6 +23,7 @@ actionCodes = { @@ -23,6 +23,7 @@ actionCodes = {
23 Role_pipelining = 109, 23 Role_pipelining = 109,
24 Role_saleItemRpc = 110, 24 Role_saleItemRpc = 110,
25 Role_openItemRpc = 111, 25 Role_openItemRpc = 111,
  26 + Role_loadRunes = 112,
26 Role_updateRune = 113, 27 Role_updateRune = 113,
27 Role_storyBookRewardRpc = 114, 28 Role_storyBookRewardRpc = 114,
28 Role_unLockStoryBookRpc = 115, 29 Role_unLockStoryBookRpc = 115,
src/actions/GmAction.lua
@@ -51,7 +51,7 @@ function _M.get(role, pms) @@ -51,7 +51,7 @@ function _M.get(role, pms)
51 if not csvdb["itemCsv"][itemId] then 51 if not csvdb["itemCsv"][itemId] then
52 return "物品不存在" 52 return "物品不存在"
53 end 53 end
54 - local count = tonum(pms.pm2) 54 + local count = tonum(pms.pm2, 1)
55 role:award({[itemId] = count}) 55 role:award({[itemId] = count})
56 end 56 end
57 return "成功" 57 return "成功"
src/actions/HeroAction.lua
@@ -517,19 +517,17 @@ function _M.referEquipsRpc(agent, data) @@ -517,19 +517,17 @@ function _M.referEquipsRpc(agent, data)
517 for typ = 1, 4 do -- 4件装备 517 for typ = 1, 4 do -- 4件装备
518 if equips[typ] then 518 if equips[typ] then
519 local cur = curEquip:getv(typ, 0) 519 local cur = curEquip:getv(typ, 0)
520 - if equips[typ] == 0 then  
521 - if cur ~= 0 then  
522 - role:addEquip(typ, cur, 1) -- 脱掉 520 + if cur ~= equips[typ] then
  521 + if equips[typ] == 0 then
523 curEquip = curEquip:delk(typ) 522 curEquip = curEquip:delk(typ)
524 - end  
525 - else  
526 - if cur ~= equips[typ] then  
527 - if cur ~= 0 then  
528 - role:addEquip(typ, cur, 1) -- 脱掉  
529 - end 523 + else
530 role:addEquip(typ, equips[typ], -1) -- 穿上 524 role:addEquip(typ, equips[typ], -1) -- 穿上
531 curEquip = curEquip:setv(typ, equips[typ]) 525 curEquip = curEquip:setv(typ, equips[typ])
532 end 526 end
  527 +
  528 + if cur ~= 0 then
  529 + role:addEquip(typ, cur, 1) -- 脱掉
  530 + end
533 end 531 end
534 end 532 end
535 end 533 end
@@ -549,37 +547,35 @@ function _M.referRunesRpc(agent, data) @@ -549,37 +547,35 @@ function _M.referRunesRpc(agent, data)
549 local runes = msg.runes 547 local runes = msg.runes
550 if not runes or not next(runes) then return 11 end 548 if not runes or not next(runes) then return 11 end
551 549
552 - for typ,uid in pairs(runes) do  
553 - local referUid = hero:getProperty("rune"):getv(typ,0)  
554 - if uid == 0 then  
555 - if referUid == 0 then return 2 end  
556 - else  
557 - local ownRune = role.runeBag[uid]  
558 - if not ownRune then return 3 end  
559 - if ownRune:getProperty("refer") ~= 0 then return 4 end  
560 -  
561 - local runeSet = csvdb["runeCsv"][typ]  
562 - if not runeSet then return 5 end  
563 - local runeData = runeSet[ownRune:getProperty("id")]  
564 - if not runeData then return 6 end 550 + for typ = 1, 6 do
  551 + if runes[typ] and runes[typ] ~= 0 then
  552 + local ownRune = role.runeBag[runes[typ]]
  553 + if not ownRune then return end
  554 + if ownRune:getProperty("refer") ~= 0 then return end
565 end 555 end
566 end 556 end
  557 + local curRune = hero:getProperty("rune")
  558 + for typ = 1, 6 do
  559 + if runes[typ] then
  560 + local cur = curRune:getv(typ, 0)
  561 + if cur ~= runes[typ] then
  562 + if runes[typ] == 0 then
  563 + curRune = curRune:delk(typ)
  564 + else
  565 + local newRune = role.runeBag[runes[typ]]
  566 + newRune:updateProperty({field = "refer",value = hero:getProperty("id")})
  567 + curRune = curRune:delk(typ)
  568 + end
567 569
568 - for typ,uid in pairs(runes) do  
569 - local referUid = hero:getProperty("rune"):getv(typ,0)  
570 - if uid == 0 then  
571 - local referRune = role.runeBag[referUid]  
572 - referRune:updateProperty({field = "refer",value = 0})  
573 - else  
574 - if referUid ~= 0 then  
575 - local referRune = role.runeBag[referUid]  
576 - referRune:updateProperty({field = "refer",value = 0}) 570 + if cur ~= 0 then
  571 + local oldR = role.runeBag[cur]
  572 + if oldR then
  573 + oldR:updateProperty({field = "refer",value = 0})
  574 + end
  575 + end
577 end 576 end
578 - local ownRune = role.runeBag[uid]  
579 - ownRune:updateProperty({field = "refer",value = hero:getProperty("id")})  
580 end 577 end
581 - local x = hero:getProperty("rune"):setv(typ,uid)  
582 - hero:updateProperty({field = "rune", value = x}) 578 + hero:updateProperty({field = "rune", value = curRune})
583 end 579 end
584 SendPacket(actionCodes.Hero_referRunesRpc, "") 580 SendPacket(actionCodes.Hero_referRunesRpc, "")
585 return true 581 return true
src/models/Hero.lua
@@ -25,9 +25,14 @@ end @@ -25,9 +25,14 @@ end
25 25
26 function Hero:notifyUpdateProperty(field, newValue, oldValue) 26 function Hero:notifyUpdateProperty(field, newValue, oldValue)
27 local datas = { 27 local datas = {
28 - key = field,  
29 - newValue = newValue,  
30 - oldValue = oldValue, 28 + id = self:getProperty("id"),
  29 + datas = {
  30 + {
  31 + key = field,
  32 + newValue = newValue,
  33 + oldValue = oldValue,
  34 + }
  35 + }
31 } 36 }
32 self:notifyUpdateProperties(datas) 37 self:notifyUpdateProperties(datas)
33 end 38 end
src/models/RolePlugin.lua
@@ -460,7 +460,11 @@ function RolePlugin.bind(Role) @@ -460,7 +460,11 @@ function RolePlugin.bind(Role)
460 newRune:generateAttrs() 460 newRune:generateAttrs()
461 newRune.owner = self 461 newRune.owner = self
462 self.runeBag[runeUid] = newRune 462 self.runeBag[runeUid] = newRune
463 - newRune:notifyUpdateProperties(newRune:data()) 463 + if not params.notNotify then
  464 + local response = {}
  465 + table.insert(response, newRune:data())
  466 + SendPacket(actionCodes.Role_loadRunes, MsgPack.pack(response))
  467 + end
464 return 0 468 return 0
465 else 469 else
466 return 1 470 return 1
src/models/Rune.lua
@@ -14,9 +14,14 @@ end @@ -14,9 +14,14 @@ end
14 14
15 function Rune:notifyUpdateProperty(field, newValue, oldValue) 15 function Rune:notifyUpdateProperty(field, newValue, oldValue)
16 local datas = { 16 local datas = {
17 - key = field,  
18 - newValue = newValue,  
19 - oldValue = oldValue, 17 + uid = self:getProperty("uid"),
  18 + datas = {
  19 + {
  20 + key = field,
  21 + newValue = newValue,
  22 + oldValue = oldValue,
  23 + }
  24 + }
20 } 25 }
21 self:notifyUpdateProperties(datas) 26 self:notifyUpdateProperties(datas)
22 end 27 end
@@ -38,7 +43,10 @@ function Rune:updateProperty(params) @@ -38,7 +43,10 @@ function Rune:updateProperty(params)
38 elseif params.value then 43 elseif params.value then
39 self:setProperty(params.field, params.value) 44 self:setProperty(params.field, params.value)
40 end 45 end
41 - self:notifyUpdateProperties(self:data()) 46 + local datas = {}
  47 + table.insert(datas, {key = params.field, newValue = self:getProperty(params.field)})
  48 +
  49 + self:notifyUpdateProperties(datas)
42 end 50 end
43 51
44 -- types 类型=权重"2=100 3=100 4=100" value最大值=最小值 "50=100 50=100 100=200" 52 -- types 类型=权重"2=100 3=100 4=100" value最大值=最小值 "50=100 50=100 100=200"