Commit 3e76a4633d5a2cc64b0ef85cf8bb5fad43ec33e7
Merge branch 'tr/bugfix' into tr/publish/release
* tr/bugfix: 清空背包gm 修复拾荒结算时,返还药剂错误导致药水被吞的bug 进入拾荒自动补给药水,按当前等级下的携带最大数量计算 获得所有SSR 且满级 满觉醒 同时获得全部满级金色铭文 满精进 充值mycard pvp 匹配 和 失败扣减积分 Revert "修改 robot" 修改 robot 联动任务活动 appid 好友赠送能量活动bug修复 活动能量bug 修改联动好友赠送活动的消息通知结构 少个大括号 修改联动好友赠送获得的红点记录和通知 未测试版好友能量助力活动 联动签到活动 调理剂生产和使用逻辑优化 # Conflicts: # src/csvdata
Showing
18 changed files
with
819 additions
and
44 deletions
Show diff stats
src/GlobalVar.lua
... | ... | @@ -73,7 +73,7 @@ ItemType = { |
73 | 73 | EquipBase = 9, -- 基础装备 |
74 | 74 | Rune = 10, -- 符文 |
75 | 75 | Cuisine = 11, -- 料理(用于增加好感度、贩卖获得金币) |
76 | - LunchBox = 12, -- 便当盒(料理合成,冒险系统消耗道具) | |
76 | + Potion = 12, -- 拾荒药剂 | |
77 | 77 | TimeBox = 13, -- 时间箱(开启需要时间,随机产出道具) |
78 | 78 | AdvItem = 14, -- 冒险道具 |
79 | 79 | FuncOpen = 15, -- 管理功能开放 | ... | ... |
src/ProtocolCode.lua
... | ... | @@ -229,6 +229,8 @@ actionCodes = { |
229 | 229 | Activity_battleMilestoneRpc = 663, |
230 | 230 | Activity_bossRewardRpc = 664, |
231 | 231 | Activity_crisisMilestoneRpc = 665, |
232 | + Activity_commonSignRpc = 666, | |
233 | + Activity_friendHelpRpc = 667, | |
232 | 234 | |
233 | 235 | Radio_startQuestRpc = 700, |
234 | 236 | Radio_finishQuestRpc = 701, | ... | ... |
src/RedisKeys.lua
... | ... | @@ -47,6 +47,7 @@ FRIEND_KEY = "role:%d:friend" --哈希表 好友 |
47 | 47 | FRIEND_APPLY_KEY = "role:%d:apply" -- sort set 申请列表 |
48 | 48 | FRIEND_BLACK_KEY = "role:%d:black" -- set 黑名单 |
49 | 49 | FRIEND_POINT = "role:%d:point" -- set 当天送给我心的人 |
50 | +FRIEND_ENERGY = "role:%d:energy" -- set 送给我活动能量的好友 | |
50 | 51 | FRIEND_RECOMMEND = "friend:recommend" -- sort set 登录排序 获取推荐好友 |
51 | 52 | CHAT_OFFLINE = "chat:offline:%d" --消息离线缓存 |
52 | 53 | ... | ... |
src/actions/ActivityAction.lua
... | ... | @@ -259,7 +259,10 @@ function _M.actCalendaTaskRpc(agent, data) |
259 | 259 | activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} |
260 | 260 | }) |
261 | 261 | |
262 | + role:checkTaskEnter("FinishSpeTask", {taskId = taskId, actId = actId}) | |
263 | + | |
262 | 264 | SendPacket(actionCodes.Activity_actCalendaTaskRpc, MsgPack.pack(role:packReward(reward, change))) |
265 | + | |
263 | 266 | return true |
264 | 267 | end |
265 | 268 | |
... | ... | @@ -905,4 +908,216 @@ function _M.bossRewardRpc(agent, data) |
905 | 908 | return true |
906 | 909 | end |
907 | 910 | |
911 | +function _M.commonSignRpc(agent, data) | |
912 | + local role = agent.role | |
913 | + local msg = MsgPack.unpack(data) | |
914 | + local actid = msg.actid | |
915 | + local index = msg.index | |
916 | + | |
917 | + if not role.activity:isOpenById(actid, "CommonSignIn") then return 1 end | |
918 | + | |
919 | + local actData = role.activity:getActData("CommonSignIn") | |
920 | + if (actData[0] or 0) < index then | |
921 | + return 2 | |
922 | + end | |
923 | + if (actData[index] or 0) == 1 then | |
924 | + return 3 | |
925 | + end | |
926 | + | |
927 | + local actCfg = csvdb["activity_signInCsv"][actid] | |
928 | + if not actCfg then return 4 end | |
929 | + actCfg = actCfg[index] | |
930 | + if not actCfg then return 5 end | |
931 | + | |
932 | + actData[index] = 1 | |
933 | + role.activity:updateActData("CommonSignIn", actData) | |
934 | + | |
935 | + local award = actCfg.reward:toNumMap() | |
936 | + local reward, change = role:award(award, {log = {desc = "commonSign", int1 = actid, int2 = index}}) | |
937 | + SendPacket(actionCodes.Activity_commonSignRpc, MsgPack.pack(role:packReward(reward, change))) | |
938 | + return true | |
939 | +end | |
940 | + | |
941 | +function _M.friendHelpRpc(agent, data) | |
942 | + local role = agent.role | |
943 | + local roleId = role:getProperty("id") | |
944 | + local msg = MsgPack.unpack(data) | |
945 | + local oper = tonumber(msg.oper) or -1 | |
946 | + local award = {} | |
947 | + local result | |
948 | + | |
949 | + | |
950 | + local actid = 37 | |
951 | + if not role.activity:isOpenById(actid, "FriendEnergy") then return 1 end | |
952 | + if oper < 1 or oper > 4 then return 2 end | |
953 | + | |
954 | + local actCsv = csvdb["activity_ctrlCsv"][actid] | |
955 | + local getLimit = actCsv.condition | |
956 | + local gifts = actCsv.condition2:toTableArray(true) | |
957 | + | |
958 | + local actData = role.activity:getActData("FriendEnergy") or {} | |
959 | + | |
960 | + local function getIds() | |
961 | + local ids = {} | |
962 | + local friends = redisproxy:hgetall(FRIEND_KEY:format(roleId)) | |
963 | + for i = 1, #friends , 2 do | |
964 | + local objId = tonumber(friends[i]) | |
965 | + ids[objId] = 1 | |
966 | + end | |
967 | + return ids | |
968 | + end | |
969 | + | |
970 | + if oper == 1 then -- 赠送好友能量 | |
971 | + local giveAE = actData.giveAE or {} | |
972 | + local objId = msg.roleId | |
973 | + local gift = gifts[1] | |
974 | + local ids = {} | |
975 | + | |
976 | + if not objId then | |
977 | + return 3 | |
978 | + end | |
979 | + if not redisproxy:hexists(FRIEND_KEY:format(roleId), objId) then | |
980 | + result = 2 | |
981 | + end | |
982 | + if giveAE[objId] then | |
983 | + result = 1 | |
984 | + end | |
985 | + | |
986 | + if not result then | |
987 | + giveAE[objId] = 1 | |
988 | + award[gift[1]] = gift[2] | |
989 | + redisproxy:sadd(FRIEND_ENERGY:format(objId), roleId) | |
990 | + rpcRole(objId, "SendPacket", actionCodes.Role_notifyNewEvent, MsgPack.pack({events = {actFriendGive = roleId}})) | |
991 | + actData.giveAE = giveAE | |
992 | + end | |
993 | + elseif oper == 2 then -- 收取能量 | |
994 | + local objId = msg.roleId | |
995 | + local gift = gifts[2] | |
996 | + local getAE = actData.getAE or {} | |
997 | + local limit = actData.limit or 0 | |
998 | + | |
999 | + if limit >= getLimit then return 4 end | |
1000 | + if not redisproxy:sismember(FRIEND_ENERGY:format(roleId), objId) then | |
1001 | + result = 3 | |
1002 | + end | |
1003 | + if getAE[objId] then | |
1004 | + result = 2 | |
1005 | + end | |
1006 | + if limit >= getLimit then | |
1007 | + result = 1 | |
1008 | + end | |
1009 | + | |
1010 | + if not result then | |
1011 | + limit = limit + 1 | |
1012 | + getAE[objId] = 1 | |
1013 | + award[gift[1]] = gift[2] | |
1014 | + redisproxy:srem(FRIEND_ENERGY:format(roleId), objId) | |
1015 | + actData.limit = limit | |
1016 | + actData.getAE = getAE | |
1017 | + end | |
1018 | + elseif oper == 3 then -- 一键送领全部 | |
1019 | + local giveAE = actData.giveAE or {} | |
1020 | + local getAE = actData.getAE or {} | |
1021 | + local gift1 = gifts[1] | |
1022 | + local gift2 = gifts[2] | |
1023 | + local limit = actData.limit or 0 | |
1024 | + local cmd1, cmd2 = 0, 0 | |
1025 | + local ids = getIds() | |
1026 | + | |
1027 | + local members = {} | |
1028 | + local temp = redisproxy:smembers(FRIEND_ENERGY:format(roleId)) | |
1029 | + for _, id in pairs(temp) do | |
1030 | + members[tonumber(id)] = 1 | |
1031 | + end | |
1032 | + | |
1033 | + redisproxy:pipelining(function(red) | |
1034 | + for friendId, _ in pairs(ids) do | |
1035 | + if not giveAE[friendId] then | |
1036 | + giveAE[friendId] = 1 | |
1037 | + award[gift1[1]] = (award[gift1[1]] or 0) + gift1[2] | |
1038 | + red:sadd(FRIEND_ENERGY:format(friendId), roleId) | |
1039 | + rpcRole(friendId, "SendPacket", actionCodes.Role_notifyNewEvent, MsgPack.pack({events = {actFriendGive = roleId}})) | |
1040 | + cmd1 = 2 | |
1041 | + end | |
1042 | + | |
1043 | + if members[friendId] and not getAE[friendId] and limit <= getLimit then | |
1044 | + cmd2 = 1 | |
1045 | + limit = limit + 1 | |
1046 | + getAE[friendId] = 1 | |
1047 | + award[gift2[1]] = (award[gift2[1]] or 0) + gift2[2] | |
1048 | + red:srem(FRIEND_ENERGY:format(roleId), friendId) | |
1049 | + end | |
1050 | + end | |
1051 | + end) | |
1052 | + | |
1053 | + local sum = cmd1 + cmd2 | |
1054 | + if sum == 0 then | |
1055 | + result = 3 | |
1056 | + elseif sum ~= 3 then | |
1057 | + result = sum | |
1058 | + end | |
1059 | + | |
1060 | + actData.limit = limit | |
1061 | + actData.giveAE = giveAE | |
1062 | + actData.getAE = getAE | |
1063 | + elseif oper == 4 then -- 抽大奖 | |
1064 | + local magic = actData.magic or 0 | |
1065 | + local rewards = actData.reward or {} | |
1066 | + local rewardCsv = csvdb["activity_orderRewardsCsv"][actid] | |
1067 | + local itemId1 = gifts[1][1] | |
1068 | + local itemId2 = gifts[2][1] | |
1069 | + | |
1070 | + local level = math.min(magic + 1,#rewardCsv) | |
1071 | + local rewardData = rewardCsv[level] | |
1072 | + | |
1073 | + local cost = {[itemId1] = rewardData.condition1, [itemId2] = rewardData.condition2} | |
1074 | + | |
1075 | + if not role:checkItemEnough(cost) then return 7 end | |
1076 | + role:costItems(cost, {log = {desc = "actFriendHelp", int1 = actid, int2 = level}}) | |
1077 | + | |
1078 | + if rewardData.reward ~= "" then | |
1079 | + result = 1 | |
1080 | + award = rewardData.reward:toNumMap() | |
1081 | + end | |
1082 | + if rewardData.reward_random ~= "" then | |
1083 | + result = 1 | |
1084 | + local pool = {} | |
1085 | + for _, temp in pairs(rewardData.reward_random:toArray()) do | |
1086 | + table.insert(pool, temp:toArray(true, "=")) | |
1087 | + end | |
1088 | + local gift = pool[math.randWeight(pool, 3)] | |
1089 | + award[gift[1]] = (award[gift[1]] or 0) + gift[2] | |
1090 | + end | |
1091 | + rewards[level] = 1 | |
1092 | + actData.reward = rewards | |
1093 | + actData.magic = level | |
1094 | + else | |
1095 | + return 5 | |
1096 | + end | |
1097 | + | |
1098 | + local ids = {} | |
1099 | + local members = {} | |
1100 | + local friendIds = getIds() | |
1101 | + local temp = redisproxy:smembers(FRIEND_ENERGY:format(roleId)) | |
1102 | + for _, id in pairs(temp) do | |
1103 | + members[tonumber(id)] = 1 | |
1104 | + end | |
1105 | + | |
1106 | + for id, _ in pairs(friendIds) do | |
1107 | + if members[id] then | |
1108 | + ids[id] = 1 | |
1109 | + end | |
1110 | + end | |
1111 | + | |
1112 | + actData.new = ids | |
1113 | + | |
1114 | + local reward, change | |
1115 | + if next(award) then | |
1116 | + reward, change = role:award(award, {log = {desc = "actFriendHelp", int1 = actid, int2 = level}}) | |
1117 | + end | |
1118 | + role.activity:updateActData("FriendEnergy", actData) | |
1119 | + SendPacket(actionCodes.Activity_friendHelpRpc, MsgPack.pack({result = result, reward = reward})) | |
1120 | + return true | |
1121 | +end | |
1122 | + | |
908 | 1123 | return _M |
909 | 1124 | \ No newline at end of file | ... | ... |
src/actions/AdvAction.lua
... | ... | @@ -345,6 +345,7 @@ function _M.endHangRpc(agent, data) |
345 | 345 | adv_idle_time = adv_idle_time * 60 |
346 | 346 | |
347 | 347 | local reward, isFull, change, heroFaithMap |
348 | + local heroCnt = 0 | |
348 | 349 | if skynet.timex() >= info.time then |
349 | 350 | -- 最新需求加成取消 |
350 | 351 | --[[ |
... | ... | @@ -379,6 +380,7 @@ function _M.endHangRpc(agent, data) |
379 | 380 | for _, heroId in pairs(info.format.heros) do |
380 | 381 | local curFaith = addHeroFaith(role, heroId, exp) |
381 | 382 | heroFaithMap[heroId] = curFaith |
383 | + heroCnt = heroCnt + 1 | |
382 | 384 | end |
383 | 385 | |
384 | 386 | local totalReward = campSiteData.idleReward_1 .. " " .. campSiteData.idleReward_2 |
... | ... | @@ -407,6 +409,7 @@ function _M.endHangRpc(agent, data) |
407 | 409 | role:mylog("adv_action", {desc = "endHang", int1 = chapterId, short1 = cancel and 1 or 0}) |
408 | 410 | |
409 | 411 | role:checkTaskEnter("AdvHang", {}) |
412 | + role:checkTaskEnter("AdvHangHeroCnt", {count = heroCnt}) | |
410 | 413 | |
411 | 414 | SendPacket(actionCodes.Adv_endHangRpc, MsgPack.pack({reward = reward, change = change, isFull = isFull, heroFaith = heroFaithMap})) |
412 | 415 | return true |
... | ... | @@ -544,8 +547,8 @@ function _M.usePotionRpc(agent, data) |
544 | 547 | local msg = MsgPack.unpack(data) |
545 | 548 | local potionId = msg.potionId -- 营养剂Id |
546 | 549 | local target = msg.target -- {roomId = 1, blockId = 1} 选择的目标 |
547 | - local potionLv = role.dinerData:getProperty("dishTree"):getv(potionId, 0) | |
548 | - if potionLv == 0 then return 1 end | |
550 | + local potionLv = role.dinerData:getProperty("dishTree"):getv(potionId, 1) | |
551 | + if potionLv < 1 then return 1 end | |
549 | 552 | |
550 | 553 | local potionSet = csvdb["adv_potionCsv"][potionId] |
551 | 554 | if not potionSet then return 2 end |
... | ... | @@ -553,12 +556,9 @@ function _M.usePotionRpc(agent, data) |
553 | 556 | local potionData = potionSet[potionLv] |
554 | 557 | if not potionData then return 3 end |
555 | 558 | |
556 | - local potionBag = role:getProperty("potionBag") | |
557 | - local own = potionBag[potionId] or 0 | |
558 | - if own <= 0 then return 4 end | |
559 | - | |
560 | 559 | if not isCanContinue(role) then return end |
561 | 560 | local adv = role:getAdvData() |
561 | + if not adv:cost({[potionId] = 1}, {}, true) then return 4 end | |
562 | 562 | if adv:isWaitChooseArtifact() then return end |
563 | 563 | |
564 | 564 | adv:mylog({desc = "usePotion", int1 = potionId}) |
... | ... | @@ -566,8 +566,7 @@ function _M.usePotionRpc(agent, data) |
566 | 566 | local status = adv:doActive(potionData.effect, target) -- target |
567 | 567 | if not status then return end |
568 | 568 | |
569 | - potionBag[potionId] = own - 1 | |
570 | - role:updateProperty({field = "potionBag", value = potionBag}) | |
569 | + adv:cost({[potionId] = 1}, {log = {desc = "usePotion", int1 = potionId}}) | |
571 | 570 | adv:pushBackEvent(AdvBackEventType.Potion, {id = potionId}) |
572 | 571 | adv:afterRound() |
573 | 572 | adv:saveDB() |
... | ... | @@ -738,7 +737,7 @@ function _M.endBattleRpc(agent, data) |
738 | 737 | role:finishGuide(52) |
739 | 738 | -- 调理剂使用引导(生命药剂) |
740 | 739 | if not role:checkOverGuide(61) then |
741 | - local potionBag = role:getProperty("potionBag") | |
740 | + local potionBag = role:getProperty("advItems"):toNumMap() | |
742 | 741 | local own = potionBag[10] or 0 |
743 | 742 | if own > 0 then |
744 | 743 | -- 造假 | ... | ... |
src/actions/CarAction.lua
... | ... | @@ -13,7 +13,7 @@ function _M.makePotionRpc( agent, data ) |
13 | 13 | local count = msg.count |
14 | 14 | if count < 1 then return 0 end |
15 | 15 | local potionBag = role:getProperty("potionBag") |
16 | - local potionLv = role.dinerData:getProperty("dishTree"):getv(potionId, 0) | |
16 | + local potionLv = role.dinerData:getProperty("dishTree"):getv(potionId, 1) | |
17 | 17 | if potionLv < 1 then return 1 end |
18 | 18 | |
19 | 19 | local potionSet = csvdb["adv_potionCsv"][potionId] |
... | ... | @@ -22,20 +22,15 @@ function _M.makePotionRpc( agent, data ) |
22 | 22 | local potionData = potionSet[potionLv] |
23 | 23 | if not potionData then return 3 end |
24 | 24 | |
25 | - local own = potionBag[potionId] or 0 | |
26 | - if own+count > potionData.limit then | |
27 | - return 4 | |
28 | - end | |
29 | - | |
30 | 25 | local cost = potionData.material:toNumMap() |
31 | 26 | for k, n in pairs(cost) do |
32 | 27 | cost[k] = n * count |
33 | 28 | end |
34 | 29 | if not role:checkItemEnough(cost) then |
35 | - return 5 | |
30 | + return 4 | |
36 | 31 | end |
37 | - | |
38 | 32 | role:costItems(cost, {log = {desc = "makePotion", int1 = potionId, int2 = count}}) |
33 | + local own = potionBag[potionId] or 0 | |
39 | 34 | potionBag[potionId] = own + count |
40 | 35 | role:updateProperty({field = "potionBag", value = potionBag}) |
41 | 36 | role:checkTaskEnter("PotionMake", {count = count, id = potionId}) | ... | ... |
src/actions/DinerAction.lua
... | ... | @@ -385,22 +385,12 @@ function _M.talentUpRpc( agent, data ) |
385 | 385 | local msg = MsgPack.unpack(data) |
386 | 386 | local dish = msg.dish |
387 | 387 | local dishTree = role.dinerData:getProperty("dishTree") |
388 | - local dishLevel = dishTree:getv(dish, 0) | |
389 | 388 | |
390 | 389 | local talentSet = csvdb["diner_talentCsv"][dish] |
391 | 390 | if not talentSet then |
392 | 391 | return 1 |
393 | 392 | end |
394 | 393 | |
395 | - local talentData = talentSet[dishLevel] | |
396 | - if not talentData then | |
397 | - return 2 | |
398 | - end | |
399 | - | |
400 | - if not talentSet[dishLevel+1] then | |
401 | - return 21 | |
402 | - end | |
403 | - | |
404 | 394 | local typ = math.floor(dish/100 + 1) |
405 | 395 | local treeSet = csvdb["diner_treeCsv"][typ] |
406 | 396 | if not treeSet then |
... | ... | @@ -412,6 +402,17 @@ function _M.talentUpRpc( agent, data ) |
412 | 402 | return 4 |
413 | 403 | end |
414 | 404 | |
405 | + -- 调理剂的默认等级是1级 | |
406 | + local dishLevel = dishTree:getv(dish, treeData.rarity == 2 and 1 or 0) | |
407 | + local talentData = talentSet[dishLevel] | |
408 | + if not talentData then | |
409 | + return 2 | |
410 | + end | |
411 | + | |
412 | + if not talentSet[dishLevel+1] then | |
413 | + return 21 | |
414 | + end | |
415 | + | |
415 | 416 | local limit = talentData.pointFront:toNumMap() |
416 | 417 | for k,v in pairs(limit) do |
417 | 418 | local lv = dishTree:getv(k, 0) | ... | ... |
src/actions/GmAction.lua
... | ... | @@ -251,6 +251,7 @@ table.insert(helpDes, {"获得所有零件", "get", "RUNE"}) |
251 | 251 | table.insert(helpDes, {"获得所有碎片", "get", "FRAG"}) |
252 | 252 | table.insert(helpDes, {"获得所有食物", "get", "FOOD"}) |
253 | 253 | table.insert(helpDes, {"获得所有角色", "get", "HERO"}) |
254 | +table.insert(helpDes, {"获得满级满觉醒角色,满级满精进铭文", "get", "MAXHERO"}) | |
254 | 255 | function _M.get(role, pms) |
255 | 256 | if pms.pm1 == "ALL" then |
256 | 257 | local reward = {} |
... | ... | @@ -267,7 +268,7 @@ function _M.get(role, pms) |
267 | 268 | end |
268 | 269 | end |
269 | 270 | elseif pms.pm1 == "RUNE" then |
270 | - for itemId = 2000 , 3000 do | |
271 | + for itemId = 10000 , 20000 do | |
271 | 272 | if csvdb["itemCsv"][itemId] then |
272 | 273 | role:award({[itemId] = 1}, {log = {desc = "gm"}}) |
273 | 274 | end |
... | ... | @@ -290,6 +291,36 @@ function _M.get(role, pms) |
290 | 291 | role:award({[itemId] = 1}, {log = {desc = "gm"}}) |
291 | 292 | end |
292 | 293 | end |
294 | + elseif pms.pm1 == "MAXHERO" then | |
295 | + -- 给英雄 | |
296 | + for itemId = 400 , 700 do | |
297 | + if csvdb["itemCsv"][itemId] then | |
298 | + role:award({[itemId] = 1}, {log = {desc = "gm"}}) | |
299 | + end | |
300 | + end | |
301 | + -- 升满级 | |
302 | + for _, hero in ipairs(role.heros) do | |
303 | + hero:updateProperty({field = "level", value = 140}) | |
304 | + hero:updateProperty({field = "wakeL", value = #csvdb["unit_wakeCsv"]}) | |
305 | + end | |
306 | + | |
307 | + -- 添加铭文 | |
308 | + for itemId = 10000 , 20000 do | |
309 | + if csvdb["itemCsv"][itemId] then | |
310 | + role:award({[itemId] = 1}, {log = {desc = "gm"}}) | |
311 | + end | |
312 | + end | |
313 | + for _, rune in ipairs(role.runeBag) do | |
314 | + local typ = rune:getProperty("type") | |
315 | + local id = rune:getProperty("id") | |
316 | + | |
317 | + local runeSet = csvdb["runeCsv"][typ] | |
318 | + if not runeSet then break end | |
319 | + local runeData = runeSet[id] | |
320 | + if not runeData then break end | |
321 | + | |
322 | + rune:updateProperty({field = "level",value = runeData.lvLimit}) | |
323 | + end | |
293 | 324 | else |
294 | 325 | local itemId = tonum(pms.pm1) |
295 | 326 | if not csvdb["itemCsv"][itemId] then |
... | ... | @@ -531,6 +562,26 @@ function _M.actbattle(role, pms) |
531 | 562 | return "成功" |
532 | 563 | end |
533 | 564 | |
565 | +table.insert(helpDes, {"清空背包", "clearbag"}) | |
566 | +function _M.clearbag(role, pms) | |
567 | + -- 装备 | |
568 | + role:updateProperty({field="equips", value = {}}) | |
569 | + -- 道具 | |
570 | + local items = role:getProperty("items"):toNumMap() | |
571 | + for k, v in pairs(items) do | |
572 | + role:addItem({itemId = k, count = -v, log = {desc = "gm"}}) | |
573 | + end | |
574 | + | |
575 | + -- 铭文 | |
576 | + local uids = {} | |
577 | + for uid, _ in pairs(role.runeBag) do | |
578 | + table.insert(uids, uid) | |
579 | + end | |
580 | + role:delRunes(uids, {log = {desc = "gm"}}) | |
581 | + | |
582 | + return "成功" | |
583 | +end | |
584 | + | |
534 | 585 | function _M.helpRpc(agent, data) |
535 | 586 | SendPacket(actionCodes.Gm_helpRpc, MsgPack.pack({help = helpDes})) |
536 | 587 | return true |
... | ... | @@ -538,11 +589,23 @@ end |
538 | 589 | |
539 | 590 | function _M.test(role, pms) |
540 | 591 | local id = tonum(pms.pm1, 0) |
592 | + local actid = nil | |
593 | + if id > 100 then | |
594 | + actid = tonum(pms.pm2, 0) | |
595 | + end | |
541 | 596 | --local hero = require ("actions.HeroAction") |
542 | 597 | --hero.unlockPoolRpc({role = role}, MsgPack.pack({type = id})) |
543 | 598 | |
544 | 599 | --role:sendMail(13, nil, "1=2", {111}) |
545 | - dump(redisproxy:zrevrange("rank:tower", 0 , 10, "WITHSCORES")) | |
600 | + local file = io.open("draw_hero_"..id..".csv", "a") | |
601 | + for i=1, 10000 do | |
602 | + local heroIds = _M.drawHero(role, id, actid) | |
603 | + for k, v in ipairs(heroIds) do | |
604 | + print((i - 1)* 10 + k, v) | |
605 | + file:write(v.."\n") | |
606 | + end | |
607 | + end | |
608 | + io.close(file) | |
546 | 609 | return "成功" |
547 | 610 | end |
548 | 611 | |
... | ... | @@ -551,6 +614,12 @@ function _M.ayncPurchase(role, params) |
551 | 614 | return role:handlePurchase(params) or "" |
552 | 615 | end |
553 | 616 | |
617 | +-- 获取订单号 | |
618 | +function _M.getPurchaseOrder(role, params) | |
619 | + return role:getPurchaseOrderByPlatform(params) or "" | |
620 | +end | |
621 | + | |
622 | + | |
554 | 623 | function _M.cz(role, pms) |
555 | 624 | local id = tonum(pms.pm1) |
556 | 625 | local csvData = csvdb["shop_rechargeCsv"][id] |
... | ... | @@ -567,5 +636,259 @@ function _M.cz(role, pms) |
567 | 636 | return "指令成功" |
568 | 637 | end |
569 | 638 | |
639 | +function _M.drawHero(role, t, act) | |
640 | + local btype = t -- 1 2 3 4 5 卡池类型 4新手卡池 5心愿卡池 | |
641 | + local subType = 1-- 定向卡池需要传 子类型 | |
642 | + local drawType = 2 -- 1 单抽 2 十连 | |
643 | + if btype ~= 1 then | |
644 | + subType = 1 | |
645 | + end | |
646 | + | |
647 | + local actid = act | |
648 | + -- 另开活动卡池 | |
649 | + if actid then | |
650 | + --if not role.activity:isOpenById(actid, "ActHeroPool") then return end | |
651 | + local cfg = csvdb["activity_ctrlCsv"][actid] | |
652 | + if not cfg then return end | |
653 | + | |
654 | + btype = cfg.condition | |
655 | + end | |
656 | + | |
657 | + local buildTypeData = csvdb["build_typeCsv"][btype] | |
658 | + if not buildTypeData then return 2 end | |
659 | + | |
660 | + local drawCount = {1, 10} -- 抽取次数 | |
661 | + if not drawCount[drawType] then return 3 end | |
662 | + | |
663 | + local draw_floor_back_counts = globalCsv.draw_floor_back_counts[btype] | |
664 | + local floorHeroCount = role:getProperty("floorHero")[btype] or 0 | |
665 | + | |
666 | + -- 抽取的池子 | |
667 | + local poolMap = buildTypeData["pool"]:toNumMap() | |
668 | + local poolId = poolMap[subType] | |
669 | + if not poolId then return 5 end | |
670 | + | |
671 | + --TODO 活动覆盖 | |
672 | + local actPoolId = role.activity:getActivityPool(btype, subType) | |
673 | + if actPoolId ~= 0 then | |
674 | + poolId = actPoolId | |
675 | + end | |
676 | + | |
677 | + local unitPool = csvdb["build_unitCsv"][poolId] | |
678 | + if not unitPool then return 7 end | |
679 | + | |
680 | + -- 开始抽 | |
681 | + local resultPool = {} | |
682 | + local function fillDrawPool(isFloorBack) | |
683 | + local condition = {"rare"} | |
684 | + local values = {} | |
685 | + | |
686 | + | |
687 | + for idx, field in ipairs(condition) do | |
688 | + if not values[idx] then | |
689 | + local lpool = {} | |
690 | + local curIdx = 1 | |
691 | + while unitPool[field .. "_" .. curIdx] do | |
692 | + lpool[curIdx] = {unitPool[field .. "_" .. curIdx]} | |
693 | + curIdx = curIdx + 1 | |
694 | + end | |
695 | + | |
696 | + if next(lpool) then | |
697 | + values[idx] = math.randWeight(lpool, 1) | |
698 | + end | |
699 | + end | |
700 | + end | |
701 | + | |
702 | + local weight = 0 | |
703 | + local up_pool = nil | |
704 | + local rand_v = math.randomInt(1, 100) | |
705 | + if values[1] == HeroQuality.SR then | |
706 | + weight = unitPool["up_sr_weight"] | |
707 | + up_pool = unitPool["up_sr_id"] | |
708 | + elseif values[1] == HeroQuality.SSR then | |
709 | + weight = unitPool["up_ssr_weight"] | |
710 | + up_pool = unitPool["up_ssr_id"] | |
711 | + end | |
712 | + --print(poolId, rand_v, weight, up_pool, values[1]) | |
713 | + if rand_v < weight and up_pool then | |
714 | + up_pool = up_pool:toArray(true, "=") | |
715 | + if btype == 5 then -- 爱心卡池,使用玩家设置的备选池子 | |
716 | + up_pool = role:getProperty("wishPool") | |
717 | + up_pool[1] = 606 | |
718 | + up_pool[2] = 607 | |
719 | + up_pool[3] = 608 | |
720 | + end | |
721 | + for k, v in ipairs(up_pool) do | |
722 | + resultPool[v] = {1} | |
723 | + end | |
724 | + else | |
725 | + for itemId, oneData in pairs(isFloorBack and csvdb["build_floorCsv"] or csvdb["build_poolCsv"]) do | |
726 | + local pool_str = "pool_" .. poolId | |
727 | + if oneData[pool_str] and oneData[pool_str] ~= "" then | |
728 | + local itemData = csvdb["itemCsv"][itemId] | |
729 | + while itemData do | |
730 | + if itemData.type ~= ItemType.Hero then break end | |
731 | + local heroData = csvdb["unitCsv"][itemData.id - ItemStartId.Hero] | |
732 | + if not heroData then break end | |
733 | + local ok = true | |
734 | + -- 保底是全随机,不用比较类型 | |
735 | + if not isFloorBack then | |
736 | + for idx, field in ipairs(condition) do | |
737 | + if heroData[field] ~= values[idx] then ok = false break end | |
738 | + end | |
739 | + end | |
740 | + if not ok then break end | |
741 | + if oneData[pool_str] > 0 then | |
742 | + resultPool[itemId] = {oneData[pool_str]} -- itemId, count, 概率 | |
743 | + end | |
744 | + break | |
745 | + end | |
746 | + end | |
747 | + end | |
748 | + end | |
749 | + end | |
750 | + | |
751 | + local guideHero = nil | |
752 | + if role:getProperty("newerGuide") == "8=1" then | |
753 | + guideHero = globalCsv.newdraw_hero_item_id or 503 | |
754 | + end | |
755 | + | |
756 | + local ssrCount = 0 | |
757 | + local reward = {} | |
758 | + local logReward = {} | |
759 | + local result = {} | |
760 | + for i = 1, drawCount[drawType] do | |
761 | + floorHeroCount = floorHeroCount + 1 | |
762 | + local isFloorBack = draw_floor_back_counts and floorHeroCount >= draw_floor_back_counts | |
763 | + resultPool = {} | |
764 | + fillDrawPool(isFloorBack) | |
765 | + if not next(resultPool) then | |
766 | + skynet.error("random pool error, poolId:" .. poolId, isFloorBack) | |
767 | + return 8 | |
768 | + end | |
769 | + | |
770 | + local itemId = math.randWeight(resultPool, 1) | |
771 | + if guideHero then | |
772 | + itemId = guideHero | |
773 | + end | |
774 | + | |
775 | + local itemData = csvdb["itemCsv"][itemId] | |
776 | + if itemData.quality == HeroQuality.SSR then | |
777 | + ssrCount = ssrCount + 1 | |
778 | + if not guideHero then | |
779 | + -- 广播获得ssr英雄 | |
780 | + local ntf = {heroId = itemData.id - ItemStartId.Hero, nick = role:getProperty("name")} | |
781 | + --mcast_util.pub_world(actionCodes.Role_broadGetSSR, MsgPack.pack(ntf)) | |
782 | + end | |
783 | + end | |
784 | + | |
785 | + if btype == 4 and role:getProperty("newerDraw") == 0 then -- 新手卡池 | |
786 | + if itemData.quality == HeroQuality.SSR then | |
787 | + floorHeroCount = 0 | |
788 | + end | |
789 | + else | |
790 | + if itemData.quality >= HeroQuality.SR then | |
791 | + floorHeroCount = 0 | |
792 | + end | |
793 | + end | |
794 | + | |
795 | + if role:isHaveHero(itemData.id - ItemStartId.Hero) then | |
796 | + local fragId = itemData.id - ItemStartId.Hero | |
797 | + local heroData = csvdb["unitCsv"][fragId] | |
798 | + local count = globalCsv.draw_unit_tofragment[heroData.rare] | |
799 | + role:award({[fragId] = count}, {log = {desc = "drawHero", int1 = btype, int2 = poolId}}) | |
800 | + logReward[fragId] = (logReward[fragId] or 0) + count | |
801 | + table.insert(reward, {id = fragId, count = count, from = itemId, fcount = 1}) | |
802 | + else | |
803 | + role:award({[itemId] = 1}, {log = {desc = "drawHero", int1 = btype, int2 = poolId}}) | |
804 | + logReward[itemId] = (logReward[itemId] or 0) + 1 | |
805 | + table.insert(reward, {id = itemId, count = 1}) | |
806 | + end | |
807 | + end | |
808 | + | |
809 | + if draw_floor_back_counts then | |
810 | + local floorHero = role:getProperty("floorHero") | |
811 | + floorHero[btype] = floorHeroCount | |
812 | + role:setProperty("floorHero", floorHero) | |
813 | + end | |
814 | + | |
815 | + if btype == 4 then | |
816 | + local newCount = role:getProperty("newerDraw") | |
817 | + role:updateProperty({field="newerDraw", value = newCount + drawCount[drawType]}) | |
818 | + end | |
819 | + | |
820 | + --SendPacket(actionCodes.Hero_drawHeroRpc, MsgPack.pack({reward = reward})) -- 这个 reward 是数组 | |
821 | + for k, v in pairs(reward) do | |
822 | + local hero = v | |
823 | + if hero["from"] then | |
824 | + result[#result+1] = hero["from"] | |
825 | + else | |
826 | + result[#result+1] = hero["id"] | |
827 | + end | |
828 | + end | |
829 | + | |
830 | + local feedbackId = buildTypeData["can_feedback"] or 0 | |
831 | + if feedbackId ~= 0 then | |
832 | + -- 达到一定次数,给响应奖励 | |
833 | + local oldVal = role:getProperty("repayHero") or 0 | |
834 | + if actid then | |
835 | + local actData = role.activity:getActData("ActHeroPool") | |
836 | + oldVal = actData[btype] or 0 | |
837 | + end | |
838 | + local newVal = oldVal + drawCount[drawType] | |
839 | + local drawCardReward, val = role:getDrawCardExtraReward(feedbackId, oldVal, newVal) | |
840 | + -- 空字符穿代表直接给英雄 走以前repayHeroRpc | |
841 | + if drawCardReward == "" then | |
842 | + local repayHeroMaxCount = role:getProperty("repayMaxC") or 0 | |
843 | + repayHeroMaxCount = repayHeroMaxCount + 1 | |
844 | + | |
845 | + role:updateProperty({field = "repayMaxC", value = repayHeroMaxCount}) | |
846 | + local even = repayHeroMaxCount % 2 | |
847 | + local id = 0 | |
848 | + if even == 1 then | |
849 | + id = math.randWeight(csvdb["build_giftCsv"], "pool_"..feedbackId) | |
850 | + else | |
851 | + local giftHeroSet = {} | |
852 | + for gid, cfg in pairs(csvdb["build_giftCsv"]) do | |
853 | + if cfg["pool_"..feedbackId] ~= 0 and not role:isHaveHero(gid - ItemStartId.Hero) then | |
854 | + giftHeroSet[gid] = {1} | |
855 | + end | |
856 | + end | |
857 | + if next(giftHeroSet) then | |
858 | + id = math.randWeight(giftHeroSet, 1) | |
859 | + end | |
860 | + end | |
861 | + if id == 0 then | |
862 | + id = math.randWeight(csvdb["build_giftCsv"], "pool_"..feedbackId) | |
863 | + end | |
864 | + | |
865 | + local r,change = {} | |
866 | + local itemData = csvdb["itemCsv"][id] | |
867 | + --if itemData.type == ItemType.Hero and role:isHaveHero(itemData.id - ItemStartId.Hero) then | |
868 | + -- local fragId = itemData.id - ItemStartId.Hero | |
869 | + -- local heroData = csvdb["unitCsv"][fragId] | |
870 | + -- local count = globalCsv.draw_unit_tofragment[heroData.rare] | |
871 | + -- r, change = role:award({[fragId] = count}, {log = {desc = "drawHeroExtraReward"}}) | |
872 | + -- --r = {id = fragId, count = count, from = id, fcount = 1} | |
873 | + --else | |
874 | + r, change = role:award({[id] = 1}, {log = {desc = "drawHeroExtraReward"}}) | |
875 | + --end | |
876 | + SendPacket(actionCodes.Hero_drawHeroExtraRewardNtf, MsgPack.pack(role:packReward(r, change))) | |
877 | + elseif drawCardReward and drawCardReward ~= "" then | |
878 | + local r,change = {} | |
879 | + r, change = role:award(drawCardReward, {log = {desc = "drawHeroExtraReward", int1 = oldVal, int2 = newVal}}) | |
880 | + SendPacket(actionCodes.Hero_drawHeroExtraRewardNtf, MsgPack.pack(role:packReward(r, change))) | |
881 | + end | |
882 | + if not actid then | |
883 | + role:updateProperty({field = "repayHero", value = val}) | |
884 | + else | |
885 | + local actData = role.activity:getActData("ActHeroPool") | |
886 | + actData[btype] = val | |
887 | + role.activity:updateActData("ActHeroPool", actData) | |
888 | + end | |
889 | + end | |
890 | + return result | |
891 | +end | |
892 | + | |
570 | 893 | |
571 | 894 | return _M |
572 | 895 | \ No newline at end of file | ... | ... |
src/actions/HangAction.lua
... | ... | @@ -591,6 +591,8 @@ function _M.startBonusBattleRpc(agent, data) |
591 | 591 | |
592 | 592 | local reward, change = bonusWinReward(role, bonusData, 3, count) |
593 | 593 | SendPacket(actionCodes.Hang_startBonusBattleRpc, MsgPack.pack({reward = reward, change = change})) |
594 | + | |
595 | + role:checkTaskEnter("BonusQuick", {count = count}) | |
594 | 596 | else |
595 | 597 | local bTeam = role:getTeamFormatByType(TeamSystemType.BonusBattle) |
596 | 598 | if not next(bTeam) then return 5 end | ... | ... |
src/actions/HttpAction.lua
... | ... | @@ -147,6 +147,15 @@ function _M.gm_action(query) |
147 | 147 | return status |
148 | 148 | end |
149 | 149 | |
150 | +function _M.query_role(query) | |
151 | + if not query.uid then return "not found" end | |
152 | + local user = redisproxy:get(string.format("uid:%s", query.uid)) | |
153 | + if not user then return "not found" end | |
154 | + local roleId = redisproxy:get(string_format("user:%s", string.upper(user))) | |
155 | + if not roleId then return "not found" end | |
156 | + return json.encode({roleId, user}) | |
157 | +end | |
158 | + | |
150 | 159 | function _M.broadcast(query) |
151 | 160 | local msg = {} |
152 | 161 | local handle = { | ... | ... |
src/actions/RadioAction.lua
... | ... | @@ -179,6 +179,7 @@ function _M.finishQuestRpc(agent, data) |
179 | 179 | msg["heroFaith"] = heroFaithMap |
180 | 180 | SendPacket(actionCodes.Radio_finishQuestRpc, MsgPack.pack(msg)) |
181 | 181 | |
182 | + role:checkTaskEnter("RadioTaskStart", {heroCnt = #task.heros}) | |
182 | 183 | |
183 | 184 | local herolist = {} |
184 | 185 | for _, heroId in ipairs(task.heros) do | ... | ... |
src/actions/RoleAction.lua
... | ... | @@ -848,6 +848,11 @@ function _M.taskRpc(agent, data) |
848 | 848 | local reward, change = role:award(taskData.reward, {log = {desc = "finishTask", int1 = taskType, int2 = taskId}}) |
849 | 849 | local active = (taskStatus["a"] or 0) + taskData.active |
850 | 850 | |
851 | + -- 日常活动完成 | |
852 | + if taskType == 1 then | |
853 | + role:checkTaskEnter("DailyTask", {pre = (taskStatus["a"] or 0), cur = active}) | |
854 | + end | |
855 | + | |
851 | 856 | role:changeUpdates({ |
852 | 857 | { type = roleField[taskType], field = {"t", taskId}, value = -1 }, |
853 | 858 | { type = roleField[taskType], field = "a", value = active}, | ... | ... |
src/adv/Adv.lua
... | ... | @@ -141,6 +141,11 @@ function Adv:initByChapter(params) |
141 | 141 | isNewRelay = true |
142 | 142 | end |
143 | 143 | end |
144 | + | |
145 | + if self.level == 1 or self.isRelay then | |
146 | + self:supplyPotion() | |
147 | + end | |
148 | + | |
144 | 149 | self.maps = {} |
145 | 150 | self.maps[1] = AdvMap.new(self, 1, mapId, isEnter, isNewRelay) |
146 | 151 | |
... | ... | @@ -402,9 +407,16 @@ function Adv:forceOver(notNotify, force) |
402 | 407 | local advTeam = self.owner:getProperty("advTeam") |
403 | 408 | advTeam.player = nil |
404 | 409 | |
410 | + local advPotionCsv = csvdb["adv_potionCsv"] | |
411 | + local potionBag = self.owner:getProperty("potionBag") | |
412 | + | |
405 | 413 | local reward = self.owner:getProperty("advItems"):toNumMap() |
406 | 414 | for itemId, count in pairs(reward) do |
407 | - reward[itemId] = math.ceil(count * globalCsv.adv_fail_reward_ratio / 100) -- 奖励相当于失败 | |
415 | + if advPotionCsv[itemId] then | |
416 | + potionBag[itemId] = (potionBag[itemId] or 0) + count | |
417 | + else | |
418 | + reward[itemId] = math.ceil(count * globalCsv.adv_fail_reward_ratio / 100) -- 奖励相当于失败 | |
419 | + end | |
408 | 420 | end |
409 | 421 | self.owner:award(reward, {log = {desc = "advOver", int1 = self.chapterId}, notNotify = notNotify}) |
410 | 422 | |
... | ... | @@ -415,6 +427,7 @@ function Adv:forceOver(notNotify, force) |
415 | 427 | advItems = "", |
416 | 428 | advAFGet = {}, |
417 | 429 | advAFWear = {}, |
430 | + potionBag = potionBag, | |
418 | 431 | }, notNotify) |
419 | 432 | end |
420 | 433 | end |
... | ... | @@ -795,9 +808,13 @@ function Adv:over(success, rewardRatio, overType) |
795 | 808 | self.battle.player:triggerPassive(Passive.ADV_OVER, {score = score, level = self.level}) |
796 | 809 | |
797 | 810 | local reward = {} |
811 | + local advPotionCsv = csvdb["adv_potionCsv"] | |
812 | + local potionBag = self.owner:getProperty("potionBag") | |
798 | 813 | for itemId, count in pairs(self.owner:getProperty("advItems"):toNumMap()) do |
799 | 814 | local itemCsv = csvdb["itemCsv"][itemId] |
800 | - if not itemCsv then | |
815 | + if advPotionCsv[itemId] then | |
816 | + potionBag[itemId] = (potionBag[itemId] or 0) + count | |
817 | + elseif not itemCsv then | |
801 | 818 | print("ERROR: no itemId in ItemCsv : ", itemId) |
802 | 819 | elseif itemCsv.type ~= ItemType.AdvItem then |
803 | 820 | reward[itemId] = math.ceil(count * rewardRatio / 100) |
... | ... | @@ -896,6 +913,7 @@ function Adv:over(success, rewardRatio, overType) |
896 | 913 | advItems = "", |
897 | 914 | advAFGet = {}, |
898 | 915 | advAFWear = {}, |
916 | + potionBag = potionBag, | |
899 | 917 | }) |
900 | 918 | self:pushBackEvent(AdvBackEventType.End, { |
901 | 919 | success = success, |
... | ... | @@ -980,7 +998,8 @@ function Adv:award(gift, params, backRewardParams) |
980 | 998 | if globalCsv.adv_auto_useItem[itemId] and count > 0 then |
981 | 999 | autoUse[itemId] = count |
982 | 1000 | else |
983 | - local origin = items:getv(itemId, 0) | |
1001 | + local transId = globalCsv.adv_item_potion[itemId] or itemId | |
1002 | + local origin = items:getv(transId, 0) | |
984 | 1003 | local nums = origin + count |
985 | 1004 | |
986 | 1005 | if csvdb["adv_artifactCsv"][itemId] then -- 获得神器 |
... | ... | @@ -990,10 +1009,10 @@ function Adv:award(gift, params, backRewardParams) |
990 | 1009 | end |
991 | 1010 | else |
992 | 1011 | if nums <= 0 then |
993 | - items = items:delk(itemId) | |
1012 | + items = items:delk(transId) | |
994 | 1013 | nums = 0 |
995 | 1014 | else |
996 | - items = items:setv(itemId, nums) | |
1015 | + items = items:setv(transId, nums) | |
997 | 1016 | end |
998 | 1017 | |
999 | 1018 | if itemId == 16 and not self.owner:checkOverGuide(51,4) then |
... | ... | @@ -1071,6 +1090,7 @@ end |
1071 | 1090 | -- 消耗物品 优先冒险背包 --check 只是检查够不够 |
1072 | 1091 | function Adv:cost(item, params, check) |
1073 | 1092 | local items = self.owner:getProperty("advItems") |
1093 | + local potionCsv = csvdb["adv_potionCsv"] | |
1074 | 1094 | local less = {} |
1075 | 1095 | local advCost = {} |
1076 | 1096 | for itemId, count in pairs(item) do |
... | ... | @@ -1084,9 +1104,13 @@ function Adv:cost(item, params, check) |
1084 | 1104 | less[itemId] = -last |
1085 | 1105 | end |
1086 | 1106 | |
1107 | + if potionCsv[itemId] and last < 0 then -- 只能使用冒险背包里的药水 | |
1108 | + return | |
1109 | + end | |
1087 | 1110 | end |
1088 | 1111 | if next(less) and not self.owner:checkItemEnough(less) then return end --不够 |
1089 | 1112 | if check then return true end |
1113 | + | |
1090 | 1114 | self:award(advCost, params) |
1091 | 1115 | if next(less) then |
1092 | 1116 | self.owner:costItems(less, params) |
... | ... | @@ -1094,6 +1118,27 @@ function Adv:cost(item, params, check) |
1094 | 1118 | return true |
1095 | 1119 | end |
1096 | 1120 | |
1121 | +-- 补满冒险背包药剂,从药剂背包扣除药水放到冒险背包 | |
1122 | +function Adv:supplyPotion() | |
1123 | + local potionCsv = csvdb["adv_potionCsv"] | |
1124 | + local potionBag = self.owner:getProperty("potionBag") | |
1125 | + local advItems = self.owner:getProperty("advItems") | |
1126 | + local dishTree = self.owner.dinerData:getProperty("dishTree") | |
1127 | + for potionId, set in pairs(potionCsv) do | |
1128 | + local count = potionBag[potionId] or 0 | |
1129 | + if count > 0 then | |
1130 | + local level = dishTree:getv(potionId,1) | |
1131 | + local num = math.min(set[level].limit,count) | |
1132 | + advItems = advItems:setv(potionId,num) | |
1133 | + potionBag[potionId] = num ~= count and (count - num) or nil | |
1134 | + end | |
1135 | + end | |
1136 | + self.owner:updateProperties({ | |
1137 | + advItems = advItems, | |
1138 | + potionBag = potionBag, | |
1139 | + }) | |
1140 | +end | |
1141 | + | |
1097 | 1142 | --事件点击处理 |
1098 | 1143 | local function clickOut(self, room, block, params, isExit) |
1099 | 1144 | if self:getCurMap():checkOver() then --检查是否可以出去了 |
... | ... | @@ -2150,6 +2195,7 @@ function Adv:enemyDead(enemy, escape) |
2150 | 2195 | self:checkAchievement(Adv.AchievType.KillBossNoBuff, 1) |
2151 | 2196 | self:checkAchievement(Adv.AchievType.KillBossWithMWeapon, 1) |
2152 | 2197 | self:checkAchievement(Adv.AchievType.KillBossWithAMWeapon, 1) |
2198 | + self.owner:checkTaskEnter("AdvKillBoss") | |
2153 | 2199 | elseif monsterData.type == 3 then |
2154 | 2200 | self:checkTask(Adv.TaskType.KillElite, 1, enemyId) |
2155 | 2201 | end | ... | ... |
src/models/Activity.lua
... | ... | @@ -30,6 +30,9 @@ Activity.ActivityType = { |
30 | 30 | ActShopGoods = 25, -- 活动商品 |
31 | 31 | |
32 | 32 | Crisis = 26, -- 宝藏怪活动 |
33 | + | |
34 | + CommonSignIn = 28, --通用签到 | |
35 | + FriendEnergy = 30, -- 好友互赠能量活动 | |
33 | 36 | } |
34 | 37 | |
35 | 38 | local function checkActivityType(activityType) |
... | ... | @@ -73,6 +76,9 @@ Activity.schema = { |
73 | 76 | |
74 | 77 | act24 = {"table", {}, true}, -- 活动卡池 {id=repaynum} |
75 | 78 | act26 = {"table", {}}, -- {task = {id = count}, socre = {id = status}} |
79 | + | |
80 | + act28 = {"table", {}}, -- 每日活跃签到 {0=day, 1=1,2=1,3=1} | |
81 | + act30 = {"table", {}}, -- {magic = 0, limit = 0, reward = {id = 1, id = 1}, giveAE = {}, getAE = {}} 奖励字段1表示领取过奖励 | |
76 | 82 | } |
77 | 83 | |
78 | 84 | function Activity:data() |
... | ... | @@ -93,6 +99,9 @@ function Activity:data() |
93 | 99 | act20 = self:getProperty("act20"), |
94 | 100 | act24 = self:getProperty("act24"), |
95 | 101 | act26 = self:getProperty("act26"), |
102 | + | |
103 | + act28 = self:getProperty("act28"), | |
104 | + act30 = self:getProperty("act30"), | |
96 | 105 | } |
97 | 106 | end |
98 | 107 | |
... | ... | @@ -471,8 +480,9 @@ activityFunc[Activity.ActivityType.CalendaTask] = { |
471 | 480 | role:checkTaskEnter("RuneQualityCollect", {}) |
472 | 481 | |
473 | 482 | end, |
474 | - -- ["close"] = function(self, actType, notify) | |
475 | - -- end, | |
483 | + ["close"] = function(self, actType, notify) | |
484 | + self.owner:updateProperty({field="CalTask", value={}}) | |
485 | + end, | |
476 | 486 | } |
477 | 487 | |
478 | 488 | -- 兑换 |
... | ... | @@ -772,7 +782,46 @@ activityFunc[Activity.ActivityType.ActShopGoods] = { |
772 | 782 | end, |
773 | 783 | } |
774 | 784 | |
785 | +activityFunc[Activity.ActivityType.FriendEnergy] = { | |
786 | + ["init"] = function (self, actType, isCrossDay, notify, actId) | |
787 | + local data = {magic = 0, limit = 0, reward = {}, giveAE = {}, getAE = {}, new = self:getActFriendNew()} | |
788 | + self:updateActData(actType, data, not notify) | |
789 | + end, | |
790 | + ["login"] = function (self, actType) | |
791 | + local actData = self:getActData(actType) or {} | |
792 | + actData.new = self:getActFriendNew() | |
793 | + self:updateActData(actType, actData, not notify) | |
794 | + end, | |
795 | + ["crossDay"] = function(self, actType, notify) | |
796 | + local actData = self:getActData(actType) | |
797 | + actData.limit = 0 | |
798 | + actData.giveAE = {} | |
799 | + actData.getAE = {} | |
800 | + self:updateActData(actType, actData, not notify) | |
801 | + end, | |
802 | + ["close"] = function (self, actType, notify, actId) | |
803 | + redisproxy:del(FRIEND_ENERGY:format(self.owner:getProperty("id"))) | |
804 | + end | |
805 | +} | |
775 | 806 | |
807 | +function Activity:getActFriendNew() | |
808 | + local roleId = self.owner:getProperty("id") | |
809 | + local friendIds = {} | |
810 | + local friends = redisproxy:hgetall(FRIEND_KEY:format(roleId)) | |
811 | + for i = 1, #friends , 2 do | |
812 | + local objId = tonumber(friends[i]) | |
813 | + friendIds[objId] = 1 | |
814 | + end | |
815 | + | |
816 | + local ids = {} | |
817 | + local members = redisproxy:smembers(FRIEND_ENERGY:format(roleId)) | |
818 | + for _, id in pairs(members) do | |
819 | + if friendIds[tonumber(id)] then | |
820 | + ids[tonumber(id)] = 1 | |
821 | + end | |
822 | + end | |
823 | + return ids | |
824 | +end | |
776 | 825 | |
777 | 826 | activityFunc[Activity.ActivityType.Crisis] = { |
778 | 827 | ["check"] = function(self, actType, notify, atype, count) -- 检查 |
... | ... | @@ -814,4 +863,40 @@ activityFunc[Activity.ActivityType.Crisis] = { |
814 | 863 | end, |
815 | 864 | } |
816 | 865 | |
866 | +activityFunc[Activity.ActivityType.CommonSignIn] = { | |
867 | + ["init"] = function(self, actType, isCrossDay, notify, actId) | |
868 | + if not isCrossDay then | |
869 | + activityFunc[Activity.ActivityType.CommonSignIn]["crossDay"](self, actType, notify, actId) | |
870 | + end | |
871 | + end, | |
872 | + ["crossDay"] = function(self, actType, notify, actId) | |
873 | + local actCfg = csvdb["activity_ctrlCsv"][actId] | |
874 | + if not actCfg then return end | |
875 | + local conArr = actCfg.condition2:toArray("true", "=") | |
876 | + -- 0 登录即可, 1 达到指定活跃度 | |
877 | + if conArr[1] ~= 0 then | |
878 | + return | |
879 | + end | |
880 | + local curData = self:getActData(actType) or {} | |
881 | + curData[0] = (curData[0] or 0) + 1 | |
882 | + self:updateActData(actType, curData, not notify) | |
883 | + end, | |
884 | + ["check"] = function(self, actType, notify, pre, cur) -- 检查 | |
885 | + local isOpen, actId = self:isOpen(actType) | |
886 | + local actData = self:getActData(actType) or {} | |
887 | + local actCfg = csvdb["activity_ctrlCsv"][actId] | |
888 | + if not actCfg then return end | |
889 | + local conArr = actCfg.condition2:toArray("true", "=") | |
890 | + -- 0 登录即可, 1 达到指定活跃度 | |
891 | + if conArr[1] ~= 1 then | |
892 | + return | |
893 | + end | |
894 | + local val = conArr[2] or 0 | |
895 | + if pre < val and cur >= val then | |
896 | + actData[0] = (actData[0] or 0) + 1 | |
897 | + self:updateActData(actType, actData, not notify) | |
898 | + end | |
899 | + end, | |
900 | +} | |
901 | + | |
817 | 902 | return Activity | ... | ... |
src/models/RoleLog.lua
src/models/RolePlugin.lua
... | ... | @@ -131,6 +131,9 @@ function RolePlugin.bind(Role) |
131 | 131 | self:addItem(pms) |
132 | 132 | end |
133 | 133 | end, |
134 | + [ItemType.Potion] = function () | |
135 | + self:addPotion({id = itemId, count = count, notNotify = pms.notNotify, log = pms.log}) | |
136 | + end, | |
134 | 137 | } |
135 | 138 | -- 对数量筛查 |
136 | 139 | count = checkItemCount(self, itemId, count) |
... | ... | @@ -290,6 +293,37 @@ function RolePlugin.bind(Role) |
290 | 293 | self:changeCrossServerPvpSelfInfo("level") |
291 | 294 | end |
292 | 295 | |
296 | + function Role:addPotion(params) | |
297 | + dump(params) | |
298 | + local pId = globalCsv.adv_item_potion[params.id] | |
299 | + local potionBag = self:getProperty("potionBag") | |
300 | + local origin = potionBag[pId] or 0 | |
301 | + local nums = origin + params.count | |
302 | + potionBag[pId] = nums | |
303 | + | |
304 | + self:logItems(params.id, origin, nums, params.log) | |
305 | + if params.log then | |
306 | + local log = clone(params.log) | |
307 | + if log["cint1"] or log["cint2"] then | |
308 | + print("addItem error log have cint1 or cint2 ", debug.traceback()) | |
309 | + end | |
310 | + log["cint1"] = params.id | |
311 | + log["cint2"] = math.abs(params.count) | |
312 | + if params.count <= 0 then | |
313 | + self:mylog("out_item", log) | |
314 | + else | |
315 | + self:mylog("in_item", log) | |
316 | + end | |
317 | + else | |
318 | + print("addItem no log ", debug.traceback()) | |
319 | + end | |
320 | + | |
321 | + self:updateProperty({field = "potionBag", value = potionBag}) | |
322 | + if not params.notNotify then | |
323 | + SendPacket(actionCodes.Role_updateItems, MsgPack.pack({[params.id] = params.count})) | |
324 | + end | |
325 | + end | |
326 | + | |
293 | 327 | function Role:addItem(params) |
294 | 328 | params = params or {} |
295 | 329 | params.count = math.floor(params.count or 0) |
... | ... | @@ -1588,7 +1622,6 @@ function RolePlugin.bind(Role) |
1588 | 1622 | if table.pack(next(newReward))[2] >= divisionData.limit then |
1589 | 1623 | return true |
1590 | 1624 | end |
1591 | - | |
1592 | 1625 | end |
1593 | 1626 | |
1594 | 1627 | local events = {} |
... | ... | @@ -1641,8 +1674,34 @@ function RolePlugin.bind(Role) |
1641 | 1674 | self:updateProperty({field = "redp", value = redp}) |
1642 | 1675 | end |
1643 | 1676 | |
1677 | + -- 网页支付获取订单号 | |
1678 | + function Role:getPurchaseOrderByPlatform(params) | |
1679 | + local checkPlatform = { | |
1680 | + ["mycard"] = "mycard_product_id", | |
1681 | + } | |
1682 | + local pidField = checkPlatform[params.payMode or ""] | |
1683 | + if not pidField or not params.product_id or params.product_id == "" then | |
1684 | + return "no product" | |
1685 | + end | |
1686 | + | |
1687 | + for k , v in pairs(csvdb["shop_rechargeCsv"]) do | |
1688 | + if not v[pidField] then return "no product" end | |
1689 | + if v[pidField] == params.product_id then | |
1690 | + if v.rmb ~= params.money then | |
1691 | + return "error money" | |
1692 | + end | |
1693 | + -- 发现需要的id | |
1694 | + local partnerOrderId = self:getPurchaseOrder(k, params.transactionId) | |
1695 | + if partnerOrderId == "" then | |
1696 | + return "no product" | |
1697 | + end | |
1698 | + return json.encode({order = partnerOrderId}) | |
1699 | + end | |
1700 | + end | |
1701 | + end | |
1702 | + | |
1644 | 1703 | -- 获取充值订单号 |
1645 | - function Role:getPurchaseOrder(rechargeId) | |
1704 | + function Role:getPurchaseOrder(rechargeId, transactionId) | |
1646 | 1705 | local roleId = self:getProperty("id") |
1647 | 1706 | local rechargeData = csvdb["shop_rechargeCsv"][rechargeId] |
1648 | 1707 | if not rechargeData then |
... | ... | @@ -1679,6 +1738,7 @@ function RolePlugin.bind(Role) |
1679 | 1738 | order = partnerOrderId, |
1680 | 1739 | rechargeId = rechargeId, |
1681 | 1740 | createTime = skynet.timex(), |
1741 | + transactionId = transactionId, | |
1682 | 1742 | }) |
1683 | 1743 | order:create() |
1684 | 1744 | -- 正在进行中的订单 缓存 |
... | ... | @@ -1757,6 +1817,7 @@ function RolePlugin.bind(Role) |
1757 | 1817 | request.product_id = data.product_id |
1758 | 1818 | request.pay_time = data.pay_time |
1759 | 1819 | request.transactionId = data.order_no |
1820 | + request.extension_info = data.extension_info | |
1760 | 1821 | ]] |
1761 | 1822 | function Role:handlePurchase(params) |
1762 | 1823 | local roleId = self:getProperty("id") |
... | ... | @@ -1787,6 +1848,10 @@ function RolePlugin.bind(Role) |
1787 | 1848 | }) |
1788 | 1849 | |
1789 | 1850 | if not status then |
1851 | + if params.extension_info == "mycard_web" then | |
1852 | + -- todo 发邮件 | |
1853 | + skynet.error("mycard_web " .. params.order) | |
1854 | + end | |
1790 | 1855 | SendPacket(actionCodes.Store_ayncPurchaseRpc, MsgPack.pack({ order = partnerOrderStr, |
1791 | 1856 | result = "success", reward = reward})) |
1792 | 1857 | end | ... | ... |
src/models/RolePvp.lua
... | ... | @@ -9,7 +9,7 @@ local PVP_RANK_TIME_SORT_PRECISION = 360 -- 时间精度 每6分钟忽略差异 |
9 | 9 | local PVP_RANK_BASE_SCORE = globalCsv.pvp_base_score -- 初始积分 |
10 | 10 | |
11 | 11 | -- 匹配规则改为以排名来匹配 |
12 | -local PVP_GET_ROBOT_SCORE = 2400 -- 2400分以下低档位匹配机器人 | |
12 | +local PVP_GET_ROBOT_SCORE = 1300 -- 1300分以下低档位匹配机器人 | |
13 | 13 | local PRE_RANGE_COUNT = 20 -- 每个档位人数 |
14 | 14 | local NEED_MATCH = 3 --匹配到多少人 |
15 | 15 | |
... | ... | @@ -73,7 +73,7 @@ function Role:changePvpScoreCommon(matchId, isWin) |
73 | 73 | if isWin then |
74 | 74 | local scoreChange = math.ceil(60 / (1 + 10 ^ ((myScore - matchScore) / 400))) |
75 | 75 | myScore = myScore + scoreChange |
76 | - matchScore = matchScore - math.ceil(scoreChange / 3) -- 防守方失败时,扣分减为原来的1/3 | |
76 | + matchScore = matchScore - math.ceil(scoreChange / 3 * 2) -- 防守方失败时,扣分减为原来的2/3 | |
77 | 77 | else |
78 | 78 | local scoreChange = math.ceil(60 / (1 + 10 ^ ((matchScore - myScore) / 400))) |
79 | 79 | myScore = myScore - scoreChange |
... | ... | @@ -139,7 +139,7 @@ function Role:changePvpScoreHigh(matchId, isWin) |
139 | 139 | if isWin then |
140 | 140 | local scoreChange = math.ceil(50 / (1 + 10 ^ ((myScore - matchScore) / 1000))) |
141 | 141 | myScore = myScore + scoreChange |
142 | - matchScore = matchScore - math.ceil(scoreChange / 3) -- 防守方失败时,扣分减为原来的1/3 | |
142 | + matchScore = matchScore - math.ceil(scoreChange / 3 * 2) -- 防守方失败时,扣分减为原来的2/3 | |
143 | 143 | else |
144 | 144 | local scoreChange = math.ceil(50 / (1 + 10 ^ ((matchScore - myScore) / 1000))) |
145 | 145 | myScore = myScore - scoreChange | ... | ... |
src/models/RoleTask.lua
... | ... | @@ -34,6 +34,7 @@ local TaskType = { |
34 | 34 | HangBattle = 304, -- 挂机战斗 - id |
35 | 35 | HangGetGold = 305, -- 挂机获得齿轮 - count |
36 | 36 | BonusPass = 306, -- 奖励副本通关 - id count |
37 | + BonusQuick = 307, -- 奖励关卡扫荡 -- id count | |
37 | 38 | |
38 | 39 | -- 冒险相关 |
39 | 40 | AdvPass = 401, -- 冒险通过关 - id level score |
... | ... | @@ -50,7 +51,9 @@ local TaskType = { |
50 | 51 | AdvHang = 412, -- 代理拾荒次数 |
51 | 52 | AdvMineKill = 413, -- 宝藏怪击杀 |
52 | 53 | AdvMineLayer = 414, -- 宝藏洞激活 |
53 | - AdvPassFirst = 415, -- 冒险首次通关 - id | |
54 | + AdvKillBoss = 415, -- 拾荒击杀boss | |
55 | + AdvHangHeroCnt = 416, -- 拾荒人数 | |
56 | + AdvPassFirst = 417, -- 冒险首次通关 - id | |
54 | 57 | |
55 | 58 | --爬塔相关 |
56 | 59 | TowerPass = 501, -- 爬塔通关 - level |
... | ... | @@ -92,6 +95,9 @@ local TaskType = { |
92 | 95 | SignIn = 901, -- 签到 |
93 | 96 | Pay = 902, -- 充值 |
94 | 97 | ShopAll = 903, -- 在任意商店购买 |
98 | + DailyTask = 904, -- 完成每日活跃任务 | |
99 | + RadioTaskStart = 905, -- 电台任务开始 | |
100 | + FinishSpeTask = 906, -- 指定任务完成 | |
95 | 101 | |
96 | 102 | --功能未实现 todo |
97 | 103 | AdvShop = 1002, -- 冒险商城 |
... | ... | @@ -232,6 +238,7 @@ local ActivityListener = { |
232 | 238 | [TaskType.Pay] = {{Activity.ActivityType.PayBack, f("twd")}}, |
233 | 239 | [TaskType.AdvMineKill] = {{Activity.ActivityType.Crisis, 1}}, |
234 | 240 | [TaskType.AdvMineLayer] = {{Activity.ActivityType.Crisis, 2}}, |
241 | + [TaskType.DailyTask] = {{Activity.ActivityType.CommonSignIn, f("pre"), f("cur")}}, | |
235 | 242 | } |
236 | 243 | } |
237 | 244 | |
... | ... | @@ -269,6 +276,14 @@ local CalendaTaskListener = { |
269 | 276 | [TaskType.HangGet]= {{18, 3, f("reward")}}, |
270 | 277 | [TaskType.RuneQualityCollect]= {{19, 3}}, |
271 | 278 | [TaskType.OpenBox]= {{20, 3, f("count"), f("quality")}}, |
279 | + [TaskType.RadioTaskStart] = {{21, 1}, {22, 3, f("heroCnt")}}, | |
280 | + [TaskType.BonusQuick] = {{23, 1, f("count")}}, | |
281 | + [TaskType.AdvHangHeroCnt] = {{24, 3, f("HeroCnt")}}, | |
282 | + [TaskType.AdvKillBoss] = {{25, 1}}, | |
283 | + [TaskType.AdvMineKill] = {{26, 1}}, | |
284 | + [TaskType.PvpBattle] = {{27, 1}}, | |
285 | + [TaskType.FinishSpeTask] = {{28, 3, f("taskId"), f("actId")}}, | |
286 | + | |
272 | 287 | } |
273 | 288 | } |
274 | 289 | |
... | ... | @@ -701,6 +716,15 @@ function RoleTask.bind(Role) |
701 | 716 | calTask[id] = 1 |
702 | 717 | end |
703 | 718 | end |
719 | + elseif cfg.type == 22 then -- 电台任务出勤人数 | |
720 | + calTask[id] = (calTask[id] or 0) + (param1 or 0) | |
721 | + elseif cfg.type == 24 then -- 代理拾荒出勤人数 | |
722 | + calTask[id] = (calTask[id] or 0) + (param1 or 0) | |
723 | + elseif cfg.type == 28 then -- 完成指定任务 | |
724 | + print(actId,param2, cfg.condition2, param1) | |
725 | + if actId == param2 and cfg.condition2 == param1 then | |
726 | + calTask[id] = (calTask[id] or 0) + 1 | |
727 | + end | |
704 | 728 | end |
705 | 729 | end |
706 | 730 | end |
... | ... | @@ -713,4 +737,4 @@ function RoleTask.bind(Role) |
713 | 737 | |
714 | 738 | end |
715 | 739 | |
716 | -return RoleTask | |
717 | 740 | \ No newline at end of file |
741 | +return RoleTask | ... | ... |