Commit 24d77701b133518780e0b0b675ef5098e680ecd8
1 parent
e5a2ae07
fix equip
Showing
4 changed files
with
16 additions
and
13 deletions
Show diff stats
src/actions/HeroAction.lua
... | ... | @@ -452,7 +452,7 @@ function _M.createHeroRpc(agent, data) |
452 | 452 | end |
453 | 453 | |
454 | 454 | -- typ 位置,level等级对应唯一装备,level为0时为移除,不为0时无则装备,有则替换 |
455 | -function _M.referEquips(agent, data) | |
455 | +function _M.referEquipsRpc(agent, data) | |
456 | 456 | local role = agent.role |
457 | 457 | local msg = MsgPack.unpack(data) |
458 | 458 | local hero = role.heros[msg.id] |
... | ... | @@ -466,21 +466,21 @@ function _M.referEquips(agent, data) |
466 | 466 | if ownLv == 0 then return 2 end |
467 | 467 | else |
468 | 468 | if role:getEquipCount(typ,level) < 1 then return 3 end |
469 | + local equipSet = csvdb["equipCsv"][typ] | |
470 | + if not equipSet then return 4 end | |
471 | + local equipData = equipSet[level] | |
472 | + if not equipData then return 5 end | |
469 | 473 | end |
470 | - local equipSet = csvdb["equipCsv"][typ] | |
471 | - if not equipSet then return 4 end | |
472 | - local equipData = equipSet[level] | |
473 | - if not equipData then return 5 end | |
474 | 474 | end |
475 | 475 | |
476 | 476 | for typ,level in pairs(equips) do |
477 | 477 | local ownLv = hero:getProperty("equip"):getv(typ,0) |
478 | 478 | if level == 0 then |
479 | - role:addEquip({{type=typ,level=ownLv,count=1}}) | |
479 | + role:addEquip({type=typ,level=ownLv,count=1,isRefer=true}) | |
480 | 480 | else |
481 | - role:addEquip({{type=typ,level=level,count=-1}}) | |
482 | - if ownLv ~= 0 then | |
483 | - role:addEquip({type=typ,level=ownLv,count=1}) | |
481 | + role:addEquip({type=typ,level=level,count=-1,isRefer=true}) | |
482 | + if ownLv > 0 then | |
483 | + role:addEquip({type=typ,level=ownLv,count=1,isRefer=true}) | |
484 | 484 | end |
485 | 485 | end |
486 | 486 | hero:updateProperty({field = "equip", value = hero:getProperty("equip"):setv(typ, level)}) | ... | ... |
src/models/Hero.lua
... | ... | @@ -16,6 +16,7 @@ Hero.schema = { |
16 | 16 | loveL = {"number", 0}, --好感度等级 |
17 | 17 | skin = {"number", 0}, --皮肤 0 、 1、 2、 3 |
18 | 18 | equip = {"string","1=0 2=0 3=0 4=0"}, --装备 type=level |
19 | + rune = {"string","1=0 2=0 3=0 4=0 5=0 6=0"}, --零件 type=id | |
19 | 20 | } |
20 | 21 | |
21 | 22 | function Hero:ctor( properties ) |
... | ... | @@ -77,6 +78,8 @@ function Hero:data() |
77 | 78 | loveExp = self:getProperty("loveExp"), |
78 | 79 | loveL = self:getProperty("loveL"), |
79 | 80 | skin = self:getProperty("skin"), |
81 | + equip = self:getProperty("equip"), | |
82 | + rune = self:getProperty("rune"), | |
80 | 83 | } |
81 | 84 | end |
82 | 85 | ... | ... |
src/models/RolePlugin.lua
... | ... | @@ -386,13 +386,13 @@ function RolePlugin.bind(Role) |
386 | 386 | |
387 | 387 | if equip then |
388 | 388 | local originCount = equip:getProperty("count") |
389 | - if isRefer and count < 0 then | |
389 | + if isRefer then | |
390 | 390 | if count < 0 then |
391 | 391 | if count+originCount<0 then |
392 | 392 | return |
393 | 393 | end |
394 | 394 | else |
395 | - if equip:getProperty("refer")-count<0 then | |
395 | + if equip:getProperty("refer")+count<0 then | |
396 | 396 | return |
397 | 397 | end |
398 | 398 | end |
... | ... | @@ -412,7 +412,7 @@ function RolePlugin.bind(Role) |
412 | 412 | end |
413 | 413 | equip:updateProperty({field = "count", value = count}) |
414 | 414 | if isRefer then |
415 | - equip:updateProperty({field = "refer", value = equip:getProperty("refer")+count}) | |
415 | + equip:updateProperty({field = "refer", value = equip:getProperty("refer")+params.count}) | |
416 | 416 | end |
417 | 417 | self.equipBag[equipType][equipLv] = equip |
418 | 418 | end | ... | ... |