Commit f58eefd7e32ed94dff9499073ea972f08971f399

Authored by gaofengduan
2 parents 24d77701 3eb77775

Merge branch 'master' into feng/equip

Showing 2 changed files with 61 additions and 12 deletions   Show diff stats
README.md
... ... @@ -0,0 +1,17 @@
  1 +## 快速开始
  2 +copy database
  3 +
  4 +cd redis-4.0.1
  5 +
  6 +make install
  7 +
  8 +redis-server database/redis.conf
  9 +
  10 +cd server
  11 +
  12 +sh restart.sh
  13 +
  14 +## 重启
  15 +cd server
  16 +
  17 +sh restart.sh
0 18 \ No newline at end of file
... ...
src/actions/HeroAction.lua
... ... @@ -362,23 +362,55 @@ end
362 362 function _M.loveItemRpc(agent, data)
363 363 local role = agent.role
364 364 local msg = MsgPack.unpack(data)
365   - local hero = role.heros[msg.id]
366   - if not hero then return end
367   - local result = {}
  365 + local hero = role.heros[msg.heroId]
  366 + if not hero then
  367 + return
  368 + end
368 369 local curL = hero:getProperty("loveL")
369 370 local curExp = hero:getProperty("loveExp")
370 371 local curPlus = csvdb["unit_love_plusCsv"][hero:getProperty("type")]
371   - if not curPlus or curL >= curPlus.limit then return end
372   -
  372 + if not curPlus then
  373 + return
  374 + end
  375 + if curL >= curPlus.limit then
  376 + SendPacket(actionCodes.Hero_loveItemRpc, MsgPack.pack({errMsg = 1})) --已满级
  377 + return true
  378 + end
373 379 local curEffect = csvdb["unit_love_effectCsv"][curL]
374   - if not curEffect or curExp >= curEffect.loveValue then return end
375   - local delta = 100 -- todo
376   - local newExp = curExp + delta
377   - hero:updateProperty({field = "loveExp", value = newExp})
378   - if newExp >= curEffect.loveValue then
379   - -- todo 发任务
  380 + if not curEffect then
  381 + return
  382 + end
  383 + if curExp >= curEffect.loveValue and not msg.bBreak then
  384 + SendPacket(actionCodes.Hero_loveItemRpc, MsgPack.pack({errMsg = 2})) --当前等级经验已满
  385 + return true
  386 + end
  387 +
  388 + if msg.bBreak then
  389 + local cost = curEffect.cost:toArray(true, "=")
  390 + if not role:checkItemEnough({[cost[1]] = cost[2]}) then
  391 + SendPacket(actionCodes.Hero_loveItemRpc, MsgPack.pack({errMsg = 3, itemId = cost[1]})) --物品不足
  392 + return true
  393 + end
  394 + role:costItems({[cost[1]] = cost[2]})
  395 + hero:updateProperty({field = "loveL", value = curL + 1})
  396 + hero:updateProperty({field = "loveExp", value = 0})
  397 + else
  398 + local delta = globalCsv.unit_love_presentValue[msg.itemId]
  399 + if not delta then
  400 + return
  401 + end
  402 + if not role:checkItemEnough({[msg.itemId] = 1}) then
  403 + SendPacket(actionCodes.Hero_loveItemRpc, MsgPack.pack({errMsg = 3, itemId = msg.itemId}))
  404 + return true
  405 + end
  406 + local newExp = curExp + delta
  407 + if newExp > curEffect.loveValue then
  408 + newExp = curEffect.loveValue
  409 + end
  410 + role:costItems({[msg.itemId] = 1})
  411 + hero:updateProperty({field = "loveExp", value = newExp})
380 412 end
381   - SendPacket(actionCodes.Hero_loveItemRpc, MsgPack.pack({delta = delta}))
  413 + SendPacket(actionCodes.Hero_loveItemRpc, "")
382 414 return true
383 415 end
384 416  
... ...