Commit d9d1ba366c82fb2ee164ccdd2ec6158f291e477a

Authored by 熊润斐
2 parents 38f21794 6f2c24ed

Merge branch 'cn/develop' into cn/player

src/actions/HeroAction.lua
... ... @@ -867,7 +867,7 @@ function _M.drawHeroRpc(agent, data)
867 867 if not unitPool then return 7 end
868 868 -- ssr硬性保底
869 869 local isSSRup = false
870   - if unitPool["rare_"..HeroQuality.SSR] or 0 > 0 then
  870 + if (unitPool["rare_"..HeroQuality.SSR] or 0) > 0 then
871 871 isSSRup = true
872 872 end
873 873  
... ... @@ -878,34 +878,57 @@ function _M.drawHeroRpc(agent, data)
878 878 local values = {}
879 879  
880 880 -- check ssr up
881   - if isSSRup then
882   - local ssrUpMap = role:getProperty("ssrUp") or {}
883   - local ssrFloorCnt = ssrUpMap[poolId] or 0
884   - if ssrFloorCnt >= (globalCsv.draw_ssr_guarantee or 40) - 1 then
  881 + local ssrUpMap = role:getProperty("ssrUp") or {}
  882 + local ssrFloorCnt = ssrUpMap[poolId] or 0
  883 + if isSSRup and (ssrFloorCnt >= (globalCsv.draw_ssr_guarantee or 40) - 1) then
  884 + --if ssrFloorCnt >= (globalCsv.draw_ssr_guarantee or 40) - 1 then
885 885 values[1] = HeroQuality.SSR
886 886 ssrUpMap[poolId] = 0
887   - else
888   - for idx, field in ipairs(condition) do
889   - if not values[idx] then
890   - local lpool = {}
891   - local curIdx = 1
892   - while unitPool[field .. "_" .. curIdx] do
893   - lpool[curIdx] = {unitPool[field .. "_" .. curIdx]}
894   - curIdx = curIdx + 1
895   - end
896   -
897   - if next(lpool) then
898   - values[idx] = math.randWeight(lpool, 1)
899   - end
  887 + --else
  888 + -- for idx, field in ipairs(condition) do
  889 + -- if not values[idx] then
  890 + -- local lpool = {}
  891 + -- local curIdx = 1
  892 + -- while unitPool[field .. "_" .. curIdx] do
  893 + -- lpool[curIdx] = {unitPool[field .. "_" .. curIdx]}
  894 + -- curIdx = curIdx + 1
  895 + -- end
  896 +
  897 + -- if next(lpool) then
  898 + -- values[idx] = math.randWeight(lpool, 1)
  899 + -- end
  900 + -- end
  901 + -- end
  902 + -- if values[1] == HeroQuality.SSR then
  903 + -- ssrUpMap[poolId] = 0
  904 + -- else
  905 + -- ssrUpMap[poolId] = ssrFloorCnt + 1
  906 + -- end
  907 + --end
  908 + role:updateProperty({field="ssrUp", value = ssrUpMap, notNotify = true})
  909 + else
  910 + for idx, field in ipairs(condition) do
  911 + if not values[idx] then
  912 + local lpool = {}
  913 + local curIdx = 1
  914 + while unitPool[field .. "_" .. curIdx] do
  915 + lpool[curIdx] = {unitPool[field .. "_" .. curIdx]}
  916 + curIdx = curIdx + 1
  917 + end
  918 +
  919 + if next(lpool) then
  920 + values[idx] = math.randWeight(lpool, 1)
900 921 end
901 922 end
  923 + end
  924 + if isSSRup then
902 925 if values[1] == HeroQuality.SSR then
903 926 ssrUpMap[poolId] = 0
904 927 else
905 928 ssrUpMap[poolId] = ssrFloorCnt + 1
906 929 end
  930 + role:updateProperty({field="ssrUp", value = ssrUpMap, notNotify = true})
907 931 end
908   - role:updateProperty({field="ssrUp", value = ssrUpMap, notNotify = true})
909 932 end
910 933  
911 934  
... ...
src/actions/PvpAction.lua
... ... @@ -325,7 +325,7 @@ function _M.startBattleRpc(agent, data)
325 325  
326 326 if not result and not matchInfo then return 4 end
327 327  
328   - if not result then
  328 + if not revenge then
329 329 -- 次数扣一波
330 330 local pvpFree = role.dailyData:getProperty("pvpFree")
331 331 if pvpFree >= globalCsv.pvp_battle_free_count then
... ... @@ -335,7 +335,9 @@ function _M.startBattleRpc(agent, data)
335 335 else
336 336 role.dailyData:updateProperty({field = "pvpFree", delta = 1})
337 337 end
  338 + end
338 339  
  340 + if not result then
339 341 key = tostring(math.random())
340 342 _pvpStartBattleCacheC = {idx = idx, key = key, revenge = revenge, pvpTC = pvpTC}
341 343  
... ... @@ -574,8 +576,9 @@ function _M.startBattleHRpc(agent, data)
574 576  
575 577 if not result and not enemyTeamRecord then return 4 end
576 578  
577   - if not result then
  579 + if not revenge then
578 580 -- 次数扣一波
  581 + print("xxxxx")
579 582 local pvpFreeH = role.dailyData:getProperty("pvpFreeH")
580 583 if pvpFreeH >= globalCsv.pvp_battle_free_count_high then
581 584 local cost = {[ItemId.PvpKey] = globalCsv.pvp_battle_high_cost}
... ... @@ -584,7 +587,9 @@ function _M.startBattleHRpc(agent, data)
584 587 else
585 588 role.dailyData:updateProperty({field = "pvpFreeH", delta = 1})
586 589 end
  590 + end
587 591  
  592 + if not result then
588 593  
589 594 -- 只发送指定的那个敌人
590 595 if enemyTeamRecord.robot then
... ... @@ -643,17 +648,6 @@ function _M.endBattleHRpc(agent, data)
643 648 match = _pvpRecordInfoCacheH[msg.idx]
644 649 _revengeRecord[match.id] = now + RevengeWaitTime -- 1分钟内不能再打
645 650  
646   - if isWin then
647   - -- 次数扣一波
648   - local pvpFreeH = role.dailyData:getProperty("pvpFreeH")
649   - if pvpFreeH >= globalCsv.pvp_battle_free_count_high then
650   - local cost = {[ItemId.PvpKey] = globalCsv.pvp_battle_high_cost}
651   - if not role:checkItemEnough(cost) then return 5 end
652   - role:costItems(cost, {log = {desc = "startPvp", int1 = 2}})
653   - else
654   - role.dailyData:updateProperty({field = "pvpFreeH", delta = 1})
655   - end
656   - end
657 651 else
658 652 local pvpMH = role:getProperty("pvpMH")
659 653 match = pvpMH[msg.idx]
... ... @@ -728,6 +722,17 @@ function _M.endBattleHRpc(agent, data)
728 722 }))
729 723 return true
730 724 end
  725 + if revenge and isWin then
  726 + -- 次数扣一波
  727 + local pvpFreeH = role.dailyData:getProperty("pvpFreeH")
  728 + if pvpFreeH >= globalCsv.pvp_battle_free_count_high then
  729 + local cost = {[ItemId.PvpKey] = globalCsv.pvp_battle_high_cost}
  730 + if not role:checkItemEnough(cost) then return 5 end
  731 + role:costItems(cost, {log = {desc = "startPvp", int1 = 2}})
  732 + else
  733 + role.dailyData:updateProperty({field = "pvpFreeH", delta = 1})
  734 + end
  735 + end
731 736  
732 737 -- 战斗结束了发奖
733 738 local temp = string.randWeight(csvdb["player_expCsv"][role:getProperty("level")].pvpgroupBonus, true)
... ...
src/utils/CommonFunc.lua
... ... @@ -349,4 +349,15 @@ function httpGetFormatData(params)
349 349 end
350 350  
351 351 return table.concat(body, "&")
352   -end
353 352 \ No newline at end of file
  353 +end
  354 +
  355 +function logdump(obj, prefix)
  356 + for k,v in pairs(obj) do
  357 + local vt = type(v)
  358 + if vt == "table" then
  359 + logdump(v, prefix..':'..k)
  360 + elseif vt == 'string' or vt == 'number' then
  361 + skynet.error(prefix..':'..k..'='..v)
  362 + end
  363 + end
  364 +end
... ...
src/utils/MysqlUtil.lua
1 1 local skynet = require "skynet"
2 2 local mysqlproxy = require "shared.mysqlproxy"
  3 +require "utils.CommonFunc"
3 4  
4 5  
5 6 function getDbCfgVal(tbName, keyName, fieldName)
... ... @@ -29,20 +30,24 @@ end
29 30  
30 31 function addFriend(roleId, friendId)
31 32 local stmt_csp = mysqlproxy:prepare("call add_friends(?, ?, ?)")
  33 + --logdump(stmt_csp, '')
32 34 local r = mysqlproxy:execute(stmt_csp, roleId, friendId, skynet.timex())
33 35 if r[1][1]["t_error"] == 0 then
34 36 rpcRole(roleId, "addFriend", friendId)
35 37 rpcRole(friendId, "addFriend", roleId)
36 38 end
  39 + mysqlproxy:stmt_close(stmt_csp)
37 40 end
38 41  
39 42 function delFriend(roleId, friendId)
40 43 local stmt_csp = mysqlproxy:prepare("call del_friends(?, ?)")
  44 + --logdump(stmt_csp, '')
41 45 local r = mysqlproxy:execute(stmt_csp, roleId, friendId)
42 46 if r[1][1]["t_error"] == 0 then
43 47 rpcRole(roleId, "delFriend", friendId)
44 48 rpcRole(friendId, "delFriend", roleId)
45 49 end
  50 + mysqlproxy:stmt_close(stmt_csp)
46 51 end
47 52  
48 53 function roleExists(roleId)
... ...