Commit 087bd090d796344007131174951024fecd5d08ae
Merge branch 'tr/bugfix' into tr/publish/release
Showing
15 changed files
with
490 additions
and
18 deletions
Show diff stats
src/GlobalVar.lua
| ... | ... | @@ -16,6 +16,12 @@ TIME_ZONE = math.floor(os.difftime(START_RESET_TIME_BASE, os.time(os.date("!*t", |
| 16 | 16 | |
| 17 | 17 | START_RESET_TIME = START_RESET_TIME_BASE - TIME_ZONE * 3600 |
| 18 | 18 | |
| 19 | +function weekday(now) | |
| 20 | + local day = math.ceil((now - START_RESET_TIME) % 604800 / 86400) | |
| 21 | + if day == 0 then day = 1 end | |
| 22 | + return day | |
| 23 | +end | |
| 24 | + | |
| 19 | 25 | STRUCT_VERSION = 3 -- 数据结构版本 |
| 20 | 26 | |
| 21 | 27 | MAX_ROLE_NUM = 1000000 |
| ... | ... | @@ -155,6 +161,11 @@ TimeReset = { |
| 155 | 161 | DrawType1 = 17, -- 变异 抽卡加成 |
| 156 | 162 | DrawType2 = 18, -- 通常 抽卡加成 |
| 157 | 163 | DrawType3 = 19, -- 魔法 抽卡加成 |
| 164 | + WorkBattle1 = 22, -- 夜间玩法 1 | |
| 165 | + WorkBattle2 = 23, -- 夜间玩法 2 | |
| 166 | + WorkBattle3 = 24, -- 夜间玩法 3 | |
| 167 | + WorkBattle4 = 25, -- 夜间玩法 4 | |
| 168 | + WorkBattle5 = 26, -- 夜间玩法 5 | |
| 158 | 169 | } |
| 159 | 170 | |
| 160 | 171 | -- TimeReset 索引数组 | ... | ... |
src/ProtocolCode.lua
| ... | ... | @@ -121,6 +121,10 @@ actionCodes = { |
| 121 | 121 | Hang_bagFieldRpc = 263, |
| 122 | 122 | Hang_chatLineRpc = 264, |
| 123 | 123 | Hang_selectTeamRpc = 265, |
| 124 | + Hang_startWorkBattleRpc = 266, | |
| 125 | + Hang_endWorkBattleRpc = 267, | |
| 126 | + Hang_workBattleInfoRpc = 268, | |
| 127 | + Hang_getWorkRewardRpc = 269, | |
| 124 | 128 | |
| 125 | 129 | Diner_updateProperty = 300, |
| 126 | 130 | Diner_addSellRpc = 301, | ... | ... |
src/RedisKeys.lua
| ... | ... | @@ -62,7 +62,7 @@ FRIEND_ENERGY = "role:%d:energy" -- set 送给我活动能量的好友 |
| 62 | 62 | FRIEND_RECOMMEND = "friend:recommend" -- sort set 登录排序 获取推荐好友 |
| 63 | 63 | CHAT_OFFLINE = "chat:offline:%d" --消息离线缓存 |
| 64 | 64 | |
| 65 | - | |
| 65 | +WORK_BATTLE_COUNT = "global:workbattle" -- 世界次数统计 | |
| 66 | 66 | -- FRIEND_DINER_LIKE_KEY = "role:%d:diner:like" -- list |
| 67 | 67 | |
| 68 | 68 | -- UNION_SET = "global:union" | ... | ... |
src/actions/ActivityAction.lua
| ... | ... | @@ -140,6 +140,13 @@ function _M.signRpc(agent, data) |
| 140 | 140 | role:changeUpdates({{type = "sign", field = curDay, value = yearMonth}}) |
| 141 | 141 | role:checkTaskEnter("SignIn") |
| 142 | 142 | |
| 143 | + if monthData[curDay].daily_sign_email ~= "" then | |
| 144 | + local emails = monthData[curDay].daily_sign_email:toArray(true,"=") | |
| 145 | + for _, emailId in pairs(emails) do | |
| 146 | + redisproxy:insertEmail({roleId = role:getProperty("id"), emailId = emailId}) | |
| 147 | + end | |
| 148 | + end | |
| 149 | + | |
| 143 | 150 | SendPacket(actionCodes.Activity_signRpc, MsgPack.pack(role:packReward(reward, change))) |
| 144 | 151 | return true |
| 145 | 152 | end | ... | ... |
src/actions/HangAction.lua
| ... | ... | @@ -750,6 +750,251 @@ function _M.endBonusBattleRpc(agent, data) |
| 750 | 750 | return true |
| 751 | 751 | end |
| 752 | 752 | |
| 753 | + | |
| 754 | + | |
| 755 | +local function workWinReward(role, bonusData, rewardType, count, sweep) | |
| 756 | + count = count or 1 | |
| 757 | + local reward, change = {} | |
| 758 | + if rewardType == 2 or rewardType == 4 then | |
| 759 | + for k, v in pairs(bonusData.perfect_reward:toNumMap()) do | |
| 760 | + reward[k] = (reward[k] or 0) + v | |
| 761 | + end | |
| 762 | + end | |
| 763 | + | |
| 764 | + reward = bonusData.reward:toNumMap() | |
| 765 | + for itemId, c in pairs(reward) do | |
| 766 | + reward[itemId] = (reward[itemId] or 0) + c * count | |
| 767 | + end | |
| 768 | + for i = 1, count do | |
| 769 | + local chance = bonusData.chance:randWeight(true) | |
| 770 | + if chance[1] ~= 0 then | |
| 771 | + reward[chance[1]] = (reward[chance[1]] or 0) + chance[2] | |
| 772 | + end | |
| 773 | + end | |
| 774 | + | |
| 775 | + reward, change = role:award(reward, {log = {desc = "workBattle", int1 = bonusData.id}}) | |
| 776 | + return reward, change | |
| 777 | +end | |
| 778 | + | |
| 779 | +function _M.workBattleInfoRpc(agent, data) | |
| 780 | + local role = agent.role | |
| 781 | + local msg = MsgPack.unpack(data) | |
| 782 | + local workMainCsv = csvdb["work_mainCsv"][msg.type] | |
| 783 | + if not workMainCsv then return 1 end | |
| 784 | + if not role:isTimeResetOpen(TimeReset["WorkBattle" .. msg.type]) then return 2 end | |
| 785 | + SendPacket(actionCodes.Hang_workBattleInfoRpc, MsgPack.pack({count = tonum(redisproxy:hget(WORK_BATTLE_COUNT, role:getTimeResetRound(TimeReset["WorkBattle" .. msg.type]) * 10 + msg.type))})) | |
| 786 | + return true | |
| 787 | +end | |
| 788 | + | |
| 789 | + | |
| 790 | +function _M.getWorkRewardRpc(agent, data) | |
| 791 | + local role = agent.role | |
| 792 | + local msg = MsgPack.unpack(data) | |
| 793 | + local workMainCsv = csvdb["work_mainCsv"][msg.type] | |
| 794 | + if not workMainCsv then return 1 end | |
| 795 | + if not role:isTimeResetOpen(TimeReset["WorkBattle" .. msg.type]) then return 2 end | |
| 796 | + local count = tonum(redisproxy:hget(WORK_BATTLE_COUNT, role:getTimeResetRound(TimeReset["WorkBattle" .. msg.type]) * 10 + msg.type)) | |
| 797 | + if count < workMainCsv.target_num then return 3 end | |
| 798 | + local workBattle = role:getProperty("workBattle") | |
| 799 | + if workBattle[msg.type] ~= 1 then | |
| 800 | + return 4 | |
| 801 | + end | |
| 802 | + workBattle[msg.type] = -1 | |
| 803 | + role:updateProperty({field = "workBattle", value = workBattle}) | |
| 804 | + local reward, change = role:award(workMainCsv.phase_award, {log = {desc = "workReward"}}) | |
| 805 | + SendPacket(actionCodes.Hang_getWorkRewardRpc, MsgPack.pack({reward = reward, change = change})) | |
| 806 | + return true | |
| 807 | +end | |
| 808 | + | |
| 809 | +function _M.startWorkBattleRpc(agent, data) | |
| 810 | + local role = agent.role | |
| 811 | + local msg = MsgPack.unpack(data) | |
| 812 | + local id = msg.id | |
| 813 | + local count = msg.count or 1 | |
| 814 | + | |
| 815 | + if not role:isFuncUnlock(FuncUnlock.BonusBattle) then return 1 end | |
| 816 | + | |
| 817 | + local bonusData = csvdb["work_battleCsv"][id] | |
| 818 | + | |
| 819 | + if not bonusData then return 3 end | |
| 820 | + | |
| 821 | + if not role:isTimeResetOpen(TimeReset["WorkBattle" .. bonusData.type]) then return 2 end | |
| 822 | + | |
| 823 | + local ticketId = csvdb["work_mainCsv"][bonusData.type].ticket | |
| 824 | + local workStar = role:getProperty("workStar") | |
| 825 | + | |
| 826 | + if bonusData.unlock ~= 0 and (not workStar[bonusData.unlock] or workStar[bonusData.unlock] == 0) then return 4 end | |
| 827 | + local workBattle = role:getProperty("workBattle") | |
| 828 | + workBattle[bonusData.type] = workBattle[bonusData.type] or 0 | |
| 829 | + local needCount = count - (workBattle[bonusData.type] == 0 and 1 or 0) | |
| 830 | + if needCount ~= 0 and not role:checkItemEnough({[ticketId] = needCount}) then return 11 end | |
| 831 | + | |
| 832 | + if workStar[id] and workStar[id] >= (1 << #bonusData.sweep_condition:toTableArray(true)) - 1 then | |
| 833 | + if workBattle[bonusData.type] == 0 then | |
| 834 | + workBattle[bonusData.type] = 1 | |
| 835 | + role:updateProperty({field = "workBattle", value = workBattle}) | |
| 836 | + end | |
| 837 | + if needCount > 0 then | |
| 838 | + role:costItems({[ticketId] = needCount}, {log = {desc = "workBattle", int1 = id}}) | |
| 839 | + end | |
| 840 | + redisproxy:hincrby(WORK_BATTLE_COUNT, role:getTimeResetRound(TimeReset["WorkBattle" .. bonusData.type]) * 10 + bonusData.type, count * bonusData.target_add) | |
| 841 | + local reward, change = workWinReward(role, bonusData, 3, count, true) | |
| 842 | + SendPacket(actionCodes.Hang_startWorkBattleRpc, MsgPack.pack({reward = reward, change = change})) | |
| 843 | + else | |
| 844 | + local bTeam = role:getTeamFormatByType(TeamSystemType.BonusBattle) | |
| 845 | + if not next(bTeam) then return 5 end | |
| 846 | + role.__bonusBattleCache = { | |
| 847 | + key = tostring(math.random()), | |
| 848 | + id = id, | |
| 849 | + } | |
| 850 | + SendPacket(actionCodes.Hang_startWorkBattleRpc, MsgPack.pack({key = role.__bonusBattleCache.key})) | |
| 851 | + end | |
| 852 | + | |
| 853 | + return true | |
| 854 | +end | |
| 855 | + | |
| 856 | +function _M.endWorkBattleRpc(agent, data) | |
| 857 | + local role = agent.role | |
| 858 | + local msg = MsgPack.unpack(data) | |
| 859 | + local id = msg.id | |
| 860 | + local key = msg.key | |
| 861 | + local starNum = msg.starNum | |
| 862 | + if not role.__bonusBattleCache then return 1 end | |
| 863 | + | |
| 864 | + | |
| 865 | + if role.__bonusBattleCache.id ~= id or role.__bonusBattleCache.key ~= key then | |
| 866 | + SendPacket(actionCodes.Hang_endWorkBattleRpc, MsgPack.pack({errorCode = 1})) | |
| 867 | + return true | |
| 868 | + end | |
| 869 | + role.__bonusBattleCache = nil | |
| 870 | + | |
| 871 | + -- 防作弊 | |
| 872 | + if not role:checkBattleCheat("work", { | |
| 873 | + id = id, | |
| 874 | + isWin = starNum and starNum > 0, | |
| 875 | + info = msg.info | |
| 876 | + }) then | |
| 877 | + SendPacket(actionCodes.Hang_endWorkBattleRpc, MsgPack.pack({errorCode = 1})) | |
| 878 | + return true | |
| 879 | + end | |
| 880 | + | |
| 881 | + local bonusData = csvdb["work_battleCsv"][id] | |
| 882 | + local ticketId = csvdb["work_mainCsv"][bonusData.type].ticket | |
| 883 | + local reward, change = {} | |
| 884 | + | |
| 885 | + local workStar = role:getProperty("workStar") | |
| 886 | + local oldStar = workStar[id] or 0 | |
| 887 | + local curStar = 0 | |
| 888 | + if starNum and starNum > 0 then | |
| 889 | + -- 胜利扣除次数 | |
| 890 | + | |
| 891 | + local bTeam = role:getTeamFormatByType(TeamSystemType.BonusBattle) | |
| 892 | + local herosInfo = role:getTeamHerosInfo(bTeam).heros | |
| 893 | + | |
| 894 | + local check = {} | |
| 895 | + -- 1 通关 | |
| 896 | + check[1] = function(_) | |
| 897 | + return true | |
| 898 | + end | |
| 899 | + -- 2 阵亡人数 <= N | |
| 900 | + check[2] = function(_, cond) | |
| 901 | + return msg.info.dead and msg.info.dead <= cond | |
| 902 | + end | |
| 903 | + -- 3 全员存活 | |
| 904 | + check[3] = function(_) | |
| 905 | + return msg.info.dead and msg.info.dead == 0 | |
| 906 | + end | |
| 907 | + -- 4 指定种族 >= N | |
| 908 | + check[4] = function(_, cond) | |
| 909 | + local count = 0 | |
| 910 | + for _, one in pairs(herosInfo) do | |
| 911 | + local heroData = csvdb["unitCsv"][one.type] | |
| 912 | + if heroData.camp == cond then | |
| 913 | + count = count + 1 | |
| 914 | + end | |
| 915 | + end | |
| 916 | + return count >= cond | |
| 917 | + end | |
| 918 | + -- 5 指定职业 >= N | |
| 919 | + check[5] = function(_, cond) | |
| 920 | + local count = 0 | |
| 921 | + for _, one in pairs(herosInfo) do | |
| 922 | + local heroData = csvdb["unitCsv"][one.type] | |
| 923 | + if heroData.job == cond then | |
| 924 | + count = count + 1 | |
| 925 | + end | |
| 926 | + end | |
| 927 | + return count >= cond | |
| 928 | + end | |
| 929 | + -- 6 含有指定角色 | |
| 930 | + check[6] = function(_, cond) | |
| 931 | + for _, one in pairs(herosInfo) do | |
| 932 | + if one.type == cond then | |
| 933 | + return true | |
| 934 | + end | |
| 935 | + end | |
| 936 | + return false | |
| 937 | + end | |
| 938 | + -- 7 通关耗时 <= X 秒 msg.info.atime | |
| 939 | + check[7] = function(_, cond) | |
| 940 | + return msg.info.atime and msg.info.atime <= cond | |
| 941 | + end | |
| 942 | + curStar = 0 | |
| 943 | + local sweepConds = bonusData.sweep_condition:toTableArray(true) | |
| 944 | + for i, cond in ipairs(sweepConds) do | |
| 945 | + if check[cond[1]] and check[cond[1]](table.unpack(cond)) then | |
| 946 | + curStar = curStar + (1 << (i - 1)) | |
| 947 | + end | |
| 948 | + end | |
| 949 | + local status | |
| 950 | + local rewardType = 0 | |
| 951 | + if curStar >= (1 << #sweepConds) - 1 then -- 满星 | |
| 952 | + rewardType = 2 | |
| 953 | + if oldStar == 0 then --通关 | |
| 954 | + rewardType = 4 | |
| 955 | + end | |
| 956 | + elseif oldStar == 0 then --通关 | |
| 957 | + rewardType = 1 | |
| 958 | + end | |
| 959 | + | |
| 960 | + if rewardType ~= 0 then | |
| 961 | + local workBattle = role:getProperty("workBattle") | |
| 962 | + workBattle[bonusData.type] = workBattle[bonusData.type] or 0 | |
| 963 | + local needCount = 1 - (workBattle[bonusData.type] == 0 and 1 or 0) | |
| 964 | + if workBattle[bonusData.type] == 0 then | |
| 965 | + workBattle[bonusData.type] = 1 | |
| 966 | + role:updateProperty({field = "workBattle", value = workBattle}) | |
| 967 | + end | |
| 968 | + if needCount > 0 then | |
| 969 | + role:costItems({[ticketId] = needCount}, {log = {desc = "workBattle", int1 = id}}) | |
| 970 | + end | |
| 971 | + redisproxy:hincrby(WORK_BATTLE_COUNT, role:getTimeResetRound(TimeReset["WorkBattle" .. bonusData.type]) * 10 + bonusData.type, bonusData.target_add) | |
| 972 | + reward, change = workWinReward(role, bonusData, rewardType) | |
| 973 | + end | |
| 974 | + else | |
| 975 | + curStar = oldStar | |
| 976 | + end | |
| 977 | + if curStar ~= oldStar then | |
| 978 | + workStar[id] = curStar | |
| 979 | + role:updateProperty({field = "workStar", value = workStar}) | |
| 980 | + end | |
| 981 | + | |
| 982 | + role:checkBattle("work", { | |
| 983 | + id = id, | |
| 984 | + isWin = starNum and starNum > 0, | |
| 985 | + info = msg.info, | |
| 986 | + reward = reward, | |
| 987 | + }) | |
| 988 | + role:mylog("hang_action", {desc = "workBattle", short1 = msg.starNum > 0 and 1 or 0, int1 = id}) | |
| 989 | + | |
| 990 | + SendPacket(actionCodes.Hang_endWorkBattleRpc, MsgPack.pack({ | |
| 991 | + starNum = starNum, | |
| 992 | + reward = reward, | |
| 993 | + change = change | |
| 994 | + })) | |
| 995 | + return true | |
| 996 | +end | |
| 997 | + | |
| 753 | 998 | function _M.hangGiftRpc(agent, data) |
| 754 | 999 | local role = agent.role |
| 755 | 1000 | local msg = MsgPack.unpack(data) | ... | ... |
src/actions/RoleAction.lua
| ... | ... | @@ -161,6 +161,9 @@ function _M.loginRpc( agent, data ) |
| 161 | 161 | role:getAdvData(true) -- 清掉不合格的数据 |
| 162 | 162 | role:advEndlessSeasonCheck(true) -- 冒险赛季更新检查 |
| 163 | 163 | role:checkSeaportTrade() -- 检查海港贸易季活动 |
| 164 | + if not next(role:getProperty("workBattle")) then | |
| 165 | + role:setProperty("workBattle", {round = math.floor((now - START_RESET_TIME) / 604800)}) | |
| 166 | + end | |
| 164 | 167 | |
| 165 | 168 | -- 跨天登陆事件 |
| 166 | 169 | local resetMode = role:updateTimeReset(now) |
| ... | ... | @@ -936,7 +939,15 @@ function _M.taskActiveRpc(agent, data) |
| 936 | 939 | return |
| 937 | 940 | end |
| 938 | 941 | |
| 939 | - local reward, change = role:award(taskData.reward, {log = {desc = "taskActive", int1 = taskType, int2 = taskId}}) | |
| 942 | + local needReward = taskData.reward:toNumMap() | |
| 943 | + if taskData.reward_2 ~= 0 then | |
| 944 | + local day = weekday(skynet.timex()) | |
| 945 | + local workMainCsv = csvdb["work_mainCsv"][day] | |
| 946 | + if workMainCsv then | |
| 947 | + needReward[workMainCsv.ticket] = taskData.reward_2 | |
| 948 | + end | |
| 949 | + end | |
| 950 | + local reward, change = role:award(needReward, {log = {desc = "taskActive", int1 = taskType, int2 = taskId}}) | |
| 940 | 951 | role:changeUpdates({ |
| 941 | 952 | { type = roleField[taskType], field = {"at", taskId}, value = -1 } |
| 942 | 953 | }) | ... | ... |
src/actions/StoreAction.lua
| ... | ... | @@ -8,12 +8,13 @@ function _M.rechargeRpc(agent , data) |
| 8 | 8 | local role = agent.role |
| 9 | 9 | local msg = MsgPack.unpack(data) |
| 10 | 10 | local id = msg.id |
| 11 | + local choose = msg.choose or "" | |
| 11 | 12 | local dataSet = csvdb["shop_rechargeCsv"][id] |
| 12 | 13 | if not dataSet then return end |
| 13 | 14 | local roleId = role:getProperty("id") |
| 14 | 15 | |
| 15 | 16 | --创建订单号 |
| 16 | - local partnerOrderId = role:getPurchaseOrder(id) | |
| 17 | + local partnerOrderId = role:getPurchaseOrder(id,nil,choose) | |
| 17 | 18 | if partnerOrderId == "" then |
| 18 | 19 | return 1 |
| 19 | 20 | end |
| ... | ... | @@ -58,13 +59,14 @@ function _M.googleRechargeRpc(agent, data) |
| 58 | 59 | local role = agent.role |
| 59 | 60 | local msg = MsgPack.unpack(data) |
| 60 | 61 | local id = msg.id |
| 62 | + local choose = msg.choose or "" | |
| 61 | 63 | local dataSet = csvdb["shop_rechargeCsv"][id] |
| 62 | 64 | if not dataSet then return end |
| 63 | 65 | local roleId = role:getProperty("id") |
| 64 | 66 | |
| 65 | 67 | role.ignoreHeartbeat = true |
| 66 | 68 | --创建订单号 |
| 67 | - local partnerOrderId = role:getPurchaseOrder(id) | |
| 69 | + local partnerOrderId = role:getPurchaseOrder(id,nil,choose) | |
| 68 | 70 | -- 签名 |
| 69 | 71 | local secret_key = "b7657fa7ccd44c16a35e3f454ac7a075" |
| 70 | 72 | local need = { |
| ... | ... | @@ -85,13 +87,14 @@ function _M.myCardRechargeRpc(agent, data) |
| 85 | 87 | local role = agent.role |
| 86 | 88 | local msg = MsgPack.unpack(data) |
| 87 | 89 | local id = msg.id |
| 90 | + local choose = msg.choose or "" | |
| 88 | 91 | local dataSet = csvdb["shop_rechargeCsv"][id] |
| 89 | 92 | if not dataSet then return end |
| 90 | 93 | local roleId = role:getProperty("id") |
| 91 | 94 | |
| 92 | 95 | role.ignoreHeartbeat = true |
| 93 | 96 | --创建订单号 |
| 94 | - local partnerOrderId = role:getPurchaseOrder(id) | |
| 97 | + local partnerOrderId = role:getPurchaseOrder(id,nil,choose) | |
| 95 | 98 | -- 签名 |
| 96 | 99 | local secret_key = "48759e07540f46d9af17ec82669b4272" |
| 97 | 100 | local need = { |
| ... | ... | @@ -111,13 +114,14 @@ function _M.iosRechargeRpc(agent, data) |
| 111 | 114 | local role = agent.role |
| 112 | 115 | local msg = MsgPack.unpack(data) |
| 113 | 116 | local id = msg.id |
| 117 | + local choose = msg.choose or "" | |
| 114 | 118 | local dataSet = csvdb["shop_rechargeCsv"][id] |
| 115 | 119 | if not dataSet then return end |
| 116 | 120 | local roleId = role:getProperty("id") |
| 117 | 121 | |
| 118 | 122 | role.ignoreHeartbeat = true |
| 119 | 123 | --创建订单号 |
| 120 | - local partnerOrderId = role:getPurchaseOrder(id) | |
| 124 | + local partnerOrderId = role:getPurchaseOrder(id,nil,choose) | |
| 121 | 125 | -- 签名 |
| 122 | 126 | local secret_key = "9647d2efe1074c73b9ac19af4337a70e" |
| 123 | 127 | local need = { | ... | ... |
src/models/Order.lua
| ... | ... | @@ -12,6 +12,7 @@ Order.schema = { |
| 12 | 12 | createTime = {"number", skynet.timex()}, -- 订单创建时间 |
| 13 | 13 | finishTime = {"number", 0}, -- 服务端验证完成时间 |
| 14 | 14 | status = {"string", "create"}, |
| 15 | + choose = {"string", ""}, -- 自选奖励 | |
| 15 | 16 | } |
| 16 | 17 | |
| 17 | 18 | Order.fields = { |
| ... | ... | @@ -21,6 +22,7 @@ Order.fields = { |
| 21 | 22 | createTime = true, |
| 22 | 23 | finishTime = true, |
| 23 | 24 | status = true, |
| 25 | + choose = true, | |
| 24 | 26 | } |
| 25 | 27 | |
| 26 | 28 | return Order |
| 27 | 29 | \ No newline at end of file | ... | ... |
src/models/Role.lua
| ... | ... | @@ -119,6 +119,8 @@ Role.schema = { |
| 119 | 119 | towerTeams = {"table", {}}, -- 四个电波塔的队伍 |
| 120 | 120 | |
| 121 | 121 | bonusStar = {"table", {}}, -- 奖励关卡 通关星星 {[id] = 1} 三个二进制位 表示三个星 从低到高 (1 << 0) (1 << 1) (1 << 2) 满星 (1 << 3) - 1 |
| 122 | + workStar = {"table", {}}, -- 夜间玩法 通关星星 {[id] = 1} 三个二进制位 表示三个星 从低到高 (1 << 0) (1 << 1) (1 << 2) 满星 (1 << 3) - 1 | |
| 123 | + workBattle = {"table", {}}, -- 夜间玩法记录 {[1] = 1, [2] = 1, [3] = 1, [4] = 1, round = 10} -- 第N天打了多少次 round 轮次 | |
| 122 | 124 | |
| 123 | 125 | --引导相关 |
| 124 | 126 | newerGuide = {"string","1=1"}, -- 新手引导 master=slave |
| ... | ... | @@ -378,6 +380,8 @@ function Role:data() |
| 378 | 380 | towerTeams = self:getProperty("towerTeams"), |
| 379 | 381 | |
| 380 | 382 | bonusStar = self:getProperty("bonusStar"), |
| 383 | + workStar = self:getProperty("workStar"), | |
| 384 | + workBattle = self:getProperty("workBattle"), | |
| 381 | 385 | |
| 382 | 386 | newerGuide = self:getProperty("newerGuide"), |
| 383 | 387 | funcGuide = self:getProperty("funcGuide"), | ... | ... |
src/models/RoleBattle.lua
| ... | ... | @@ -17,6 +17,7 @@ local BattleType = { |
| 17 | 17 | pvpc = 500, |
| 18 | 18 | pvph = 501, |
| 19 | 19 | act_battle = 502, |
| 20 | + work = 301, | |
| 20 | 21 | } |
| 21 | 22 | |
| 22 | 23 | RoleBattle.bind = function (Role) |
| ... | ... | @@ -127,6 +128,18 @@ function Role:checkBattleCheat(battleType, params) |
| 127 | 128 | -- local carbonData = csvdb["bonus_battleCsv"][params.id] |
| 128 | 129 | -- enemyServer = packBattleEnemyCommon(carbonData) |
| 129 | 130 | end |
| 131 | + cheat["work"] = function() | |
| 132 | + local team = self:getTeamBattleInfo(self:getTeamFormatByType(TeamSystemType.BonusBattle)) | |
| 133 | + for slot, hero in pairs(team.heros) do | |
| 134 | + local temp = {} | |
| 135 | + for arr, _ in pairs(checkCheatAttrs) do | |
| 136 | + temp[arr] = hero[arr] | |
| 137 | + end | |
| 138 | + selfTeamServer[hero.type] = temp | |
| 139 | + end | |
| 140 | + -- local carbonData = csvdb["bonus_battleCsv"][params.id] | |
| 141 | + -- enemyServer = packBattleEnemyCommon(carbonData) | |
| 142 | + end | |
| 130 | 143 | cheat["pvpc"] = function() |
| 131 | 144 | if not params.format then return end |
| 132 | 145 | local team = self:getTeamBattleInfo(params.format) | ... | ... |
src/models/RoleLog.lua
| ... | ... | @@ -72,6 +72,8 @@ local ItemReason = { |
| 72 | 72 | towerBattle = 310, -- 电波塔战斗 |
| 73 | 73 | advOver = 311, -- 冒险结算 |
| 74 | 74 | advUnlock = 312, -- 拾荒解锁 |
| 75 | + workBattle = 313, -- workBattle夜间打工 | |
| 76 | + workReward = 314, -- workBattle夜间打工 阶段奖励 | |
| 75 | 77 | |
| 76 | 78 | dinerFinishTask = 401, -- 餐厅完成任务 |
| 77 | 79 | storybookReward = 402, -- 剧情奖励 | ... | ... |
src/models/RolePlugin.lua
| ... | ... | @@ -1340,18 +1340,22 @@ function RolePlugin.bind(Role) |
| 1340 | 1340 | local donate = seaport.donate or {} |
| 1341 | 1341 | if not reset and (not donate[1] or not donate[2]) then |
| 1342 | 1342 | local result = self:getSeaportServerProgress() |
| 1343 | - local seaportCsv = csvdb["seaport_purchaseCsv"] | |
| 1344 | - for idx, set in ipairs(seaportCsv) do | |
| 1343 | + for idx, set in ipairs(csvdb["seaport_purchaseCsv"]) do | |
| 1345 | 1344 | local done = true |
| 1346 | 1345 | for id, data in ipairs(set) do |
| 1347 | - if donate[id] or not result[idx] or not result[idx][id] or result[idx][id] < data.need_num then | |
| 1346 | + if donate[idx] or not result[idx] or not result[idx][id] or result[idx][id] < data.need_num then | |
| 1348 | 1347 | done = false |
| 1349 | 1348 | break |
| 1350 | 1349 | end |
| 1351 | 1350 | end |
| 1352 | 1351 | if done then |
| 1353 | 1352 | update = true |
| 1354 | - self:award(set[1].phase_award, {log = {desc = "seaportReward", int1 = set[1].phase, int2 = set[1].id}}) | |
| 1353 | + redisproxy:insertEmail({ | |
| 1354 | + roleId = self:getProperty("id"), | |
| 1355 | + emailId = idx == 1 and 361 or 362, | |
| 1356 | + attachments = set[1].phase_award, | |
| 1357 | + }) | |
| 1358 | + -- self:award(set[1].phase_award, {log = {desc = "seaportReward", int1 = set[1].phase, int2 = set[1].id}}) | |
| 1355 | 1359 | donate[idx] = 1 |
| 1356 | 1360 | end |
| 1357 | 1361 | end |
| ... | ... | @@ -1388,6 +1392,8 @@ function RolePlugin.bind(Role) |
| 1388 | 1392 | local expCarbonId = self:getProperty("hangInfo").expCarbonId |
| 1389 | 1393 | local taskCsv = csvdb["seaport_taskCsv"] |
| 1390 | 1394 | local endTime = openTime0 + 86400 * 2 |
| 1395 | + local reward = {} | |
| 1396 | + | |
| 1391 | 1397 | for slot, set in pairs(taskCsv) do |
| 1392 | 1398 | if collect[slot] then |
| 1393 | 1399 | update = true |
| ... | ... | @@ -1424,9 +1430,28 @@ function RolePlugin.bind(Role) |
| 1424 | 1430 | itemReward[key] = math.ceil(1.5 * value) |
| 1425 | 1431 | end |
| 1426 | 1432 | end |
| 1427 | - self:award(itemReward, {log = {desc = "seaportTask", int1 = slot, int2 = level}}) | |
| 1433 | + | |
| 1434 | + for itemId, value in pairs(itemReward) do | |
| 1435 | + reward[itemId] = (reward[itemId] or 0) + value | |
| 1436 | + end | |
| 1437 | + -- self:award(itemReward, {log = {desc = "seaportTask", int1 = slot, int2 = level}}) | |
| 1438 | + end | |
| 1439 | + end | |
| 1440 | + end | |
| 1441 | + | |
| 1442 | + if next(reward) then | |
| 1443 | + local rewardStr = "" | |
| 1444 | + for itemId, value in pairs(reward) do | |
| 1445 | + if rewardStr ~= "" then | |
| 1446 | + rewardStr = rewardStr .. " " | |
| 1428 | 1447 | end |
| 1448 | + rewardStr = rewardStr .. string.format("%s=%s",itemId,value) | |
| 1429 | 1449 | end |
| 1450 | + redisproxy:insertEmail({ | |
| 1451 | + roleId = self:getProperty("id"), | |
| 1452 | + emailId = 363, | |
| 1453 | + attachments = rewardStr, | |
| 1454 | + }) | |
| 1430 | 1455 | end |
| 1431 | 1456 | end |
| 1432 | 1457 | seaport.collect = {} |
| ... | ... | @@ -2013,7 +2038,7 @@ function RolePlugin.bind(Role) |
| 2013 | 2038 | return "error money" |
| 2014 | 2039 | end |
| 2015 | 2040 | -- 发现需要的id |
| 2016 | - local partnerOrderId = self:getPurchaseOrder(k, params.transactionId) | |
| 2041 | + local partnerOrderId = self:getPurchaseOrder(k, params.transactionId, params.choose) | |
| 2017 | 2042 | if partnerOrderId == "" then |
| 2018 | 2043 | return "no product" |
| 2019 | 2044 | end |
| ... | ... | @@ -2023,7 +2048,7 @@ function RolePlugin.bind(Role) |
| 2023 | 2048 | end |
| 2024 | 2049 | |
| 2025 | 2050 | -- 获取充值订单号 |
| 2026 | - function Role:getPurchaseOrder(rechargeId, transactionId) | |
| 2051 | + function Role:getPurchaseOrder(rechargeId, transactionId, choose) | |
| 2027 | 2052 | local roleId = self:getProperty("id") |
| 2028 | 2053 | local rechargeData = csvdb["shop_rechargeCsv"][rechargeId] |
| 2029 | 2054 | if not rechargeData then |
| ... | ... | @@ -2035,7 +2060,24 @@ function RolePlugin.bind(Role) |
| 2035 | 2060 | if limit ~= 0 and limit <= (rechargeRecord[rechargeId] or 0) then |
| 2036 | 2061 | return "" |
| 2037 | 2062 | end |
| 2038 | - | |
| 2063 | + -- 检查礼包自选奖励合法 | |
| 2064 | + if choose and choose ~= "" then | |
| 2065 | + if rechargeData.itemgift == "" then return "" end | |
| 2066 | + local slot = rechargeData.itemdirect or 0 | |
| 2067 | + local set = choose:toTableArray(true) | |
| 2068 | + if slot ~= #set then return "" end | |
| 2069 | + local pass = {} | |
| 2070 | + local groups = rechargeData.itemgift:toTableArray(true) | |
| 2071 | + for idx, item in ipairs(set) do | |
| 2072 | + for _, group in ipairs(groups) do | |
| 2073 | + if group[2] == item[1] and group[3] == item[2] and idx == group[1] then | |
| 2074 | + pass[group[1]] = 1 | |
| 2075 | + break | |
| 2076 | + end | |
| 2077 | + end | |
| 2078 | + end | |
| 2079 | + if #pass ~= slot then return "" end | |
| 2080 | + end | |
| 2039 | 2081 | --判断是否是活动商品 |
| 2040 | 2082 | if rechargeData.activity_id ~= 0 then |
| 2041 | 2083 | local actCfg = csvdb["activity_ctrlCsv"][rechargeData.activity_id] |
| ... | ... | @@ -2061,6 +2103,7 @@ function RolePlugin.bind(Role) |
| 2061 | 2103 | rechargeId = rechargeId, |
| 2062 | 2104 | createTime = skynet.timex(), |
| 2063 | 2105 | transactionId = transactionId, |
| 2106 | + choose = choose or "", | |
| 2064 | 2107 | }) |
| 2065 | 2108 | order:create() |
| 2066 | 2109 | -- 正在进行中的订单 缓存 |
| ... | ... | @@ -2128,7 +2171,7 @@ function RolePlugin.bind(Role) |
| 2128 | 2171 | }) |
| 2129 | 2172 | end |
| 2130 | 2173 | |
| 2131 | - return true, rechargeId | |
| 2174 | + return true, rechargeId, orderObject:getProperty("choose") | |
| 2132 | 2175 | end |
| 2133 | 2176 | |
| 2134 | 2177 | -- 充值 -- |
| ... | ... | @@ -2146,7 +2189,7 @@ function RolePlugin.bind(Role) |
| 2146 | 2189 | local roleId = self:getProperty("id") |
| 2147 | 2190 | local partnerOrderStr = params.order |
| 2148 | 2191 | |
| 2149 | - local status, back = self:updatePurchaseOrder(partnerOrderStr, params.transactionId, "finsh") | |
| 2192 | + local status, back, choose = self:updatePurchaseOrder(partnerOrderStr, params.transactionId, "finsh") | |
| 2150 | 2193 | if not status then |
| 2151 | 2194 | if back == "finsh" then |
| 2152 | 2195 | -- 订单已经处理 |
| ... | ... | @@ -2168,6 +2211,7 @@ function RolePlugin.bind(Role) |
| 2168 | 2211 | transactionId = params.transactionId, |
| 2169 | 2212 | pay_time = params.pay_time, |
| 2170 | 2213 | order = partnerOrderStr, |
| 2214 | + choose = choose, | |
| 2171 | 2215 | }) |
| 2172 | 2216 | |
| 2173 | 2217 | if not status then |
| ... | ... | @@ -2215,6 +2259,17 @@ function RolePlugin.bind(Role) |
| 2215 | 2259 | return 3 |
| 2216 | 2260 | end |
| 2217 | 2261 | |
| 2262 | + -- 自选奖励部分 | |
| 2263 | + if params.choose and params.choose ~= "" then | |
| 2264 | + local tReward, tChange = self:award(params.choose, {log = {desc = "recharge", int1 = id}}) | |
| 2265 | + for itemId, value in pairs(tReward) do | |
| 2266 | + reward[itemId] = (reward[itemId] or 0) + value | |
| 2267 | + end | |
| 2268 | + for itemId, value in pairs(tChange or {}) do | |
| 2269 | + reward[itemId] = (reward[itemId] or 0) + value | |
| 2270 | + end | |
| 2271 | + end | |
| 2272 | + | |
| 2218 | 2273 | if diamondCount > 0 then |
| 2219 | 2274 | reward[ItemId.Diamond] = (reward[ItemId.Diamond] or 0) + diamondCount |
| 2220 | 2275 | end | ... | ... |
src/models/RoleTimeReset.lua
| ... | ... | @@ -33,6 +33,38 @@ ResetFunc["CrossDay"] = function(self, notify, response, now) |
| 33 | 33 | self:checkReturner() |
| 34 | 34 | end |
| 35 | 35 | |
| 36 | + -- 检查 夜间打工 | |
| 37 | + local workBattle = self:getProperty("workBattle") | |
| 38 | + local need = {} | |
| 39 | + for i = 1, 5 do | |
| 40 | + if workBattle[i] == 1 then | |
| 41 | + need[#need + 1] = workBattle.round * 10 + i | |
| 42 | + end | |
| 43 | + end | |
| 44 | + local change = false | |
| 45 | + if next(need) then | |
| 46 | + local ret = redisproxy:hmget(WORK_BATTLE_COUNT, table.unpack(need)) | |
| 47 | + for idx, v in ipairs(need) do | |
| 48 | + local ctype = v % 10 | |
| 49 | + local ccount = tonum(ret[idx]) | |
| 50 | + local workMainCsv = csvdb["work_mainCsv"][ctype] | |
| 51 | + if ccount >= workMainCsv.target_num then | |
| 52 | + self:sendMail(workMainCsv.email, nil, workMainCsv.phase_award) | |
| 53 | + end | |
| 54 | + workBattle[ctype] = -1 | |
| 55 | + end | |
| 56 | + change = true | |
| 57 | + end | |
| 58 | + local newRound = math.floor((now - START_RESET_TIME) / 604800) | |
| 59 | + if newRound ~= workBattle.round then | |
| 60 | + workBattle = {round = newRound} | |
| 61 | + change = true | |
| 62 | + end | |
| 63 | + if change then | |
| 64 | + self:setProperty("workBattle", workBattle) | |
| 65 | + response.workBattle = workBattle | |
| 66 | + end | |
| 67 | + | |
| 36 | 68 | response.dTask = {} |
| 37 | 69 | response.advSup = self:getProperty("advSup") |
| 38 | 70 | self:log("onLogin") | ... | ... |
src/services/globald.lua
| ... | ... | @@ -184,6 +184,84 @@ local function check_trade_seaport_status() |
| 184 | 184 | skynet.timeout(interval, check_trade_seaport_status) |
| 185 | 185 | end |
| 186 | 186 | |
| 187 | +-- @desc: 海港贸易捐赠作弊 | |
| 188 | +local seaportTimes = {} | |
| 189 | +local function check_trade_seaport_donate() | |
| 190 | + local time1 = tonumber(redisproxy:hget("autoincrement_set", "seaportTime1")) or 0 | |
| 191 | + local time2 = tonumber(redisproxy:hget("autoincrement_set", "seaportTime2")) or 0 | |
| 192 | + if time1 == 0 and time2 == 0 then | |
| 193 | + seaportTimes = {} | |
| 194 | + skynet.timeout(360000, check_trade_seaport_donate) | |
| 195 | + return | |
| 196 | + end | |
| 197 | + | |
| 198 | + local csvdb = require "shared.csvdata" | |
| 199 | + local donateCsv = csvdb["seaport_purchaseCsv"] | |
| 200 | + | |
| 201 | + local times = {time1, time2} | |
| 202 | + for phase, open in ipairs(times) do | |
| 203 | + if open == 1 and not seaportTimes[phase] then | |
| 204 | + seaportTimes[phase] = {} | |
| 205 | + for _, _ in ipairs(donateCsv[phase]) do | |
| 206 | + table.insert(seaportTimes[phase],math.randomInt(1800, 3600)) | |
| 207 | + end | |
| 208 | + end | |
| 209 | + end | |
| 210 | + | |
| 211 | + local interval = 3600 | |
| 212 | + local phase, id = 0, 0 | |
| 213 | + | |
| 214 | + for key1, data in ipairs(seaportTimes) do | |
| 215 | + for key2, temp in pairs(data) do | |
| 216 | + if times[key1] == 1 and temp < interval then | |
| 217 | + interval = temp | |
| 218 | + phase = key1 | |
| 219 | + id = key2 | |
| 220 | + end | |
| 221 | + end | |
| 222 | + end | |
| 223 | + | |
| 224 | + for _, data in ipairs(seaportTimes) do | |
| 225 | + for id, temp in pairs(data) do | |
| 226 | + data[id] = temp - interval | |
| 227 | + if data[id] == 0 then | |
| 228 | + data[id] = math.randomInt(1800, 3600) | |
| 229 | + end | |
| 230 | + end | |
| 231 | + end | |
| 232 | + | |
| 233 | + if phase ~= 0 and id ~= 0 then | |
| 234 | + local redisKeys = {SEAPORT_TRADE_TASK_1,SEAPORT_TRADE_TASK_2} | |
| 235 | + local all = donateCsv[phase][id].need_num | |
| 236 | + local old = tonumber(redisproxy:hget(redisKeys[phase],id)) or 0 | |
| 237 | + local add = math.min(math.randomInt(math.floor(all/20),math.floor(all/12)),all - old) | |
| 238 | + if add > 0 then | |
| 239 | + redisproxy:hincrby(redisKeys[phase],id,add) | |
| 240 | + else | |
| 241 | + seaportTimes[phase][id] = nil | |
| 242 | + end | |
| 243 | + end | |
| 244 | + | |
| 245 | + skynet.timeout(interval * 100, check_trade_seaport_donate) | |
| 246 | +end | |
| 247 | + | |
| 248 | +local function check_work_battle() | |
| 249 | + local csvdb = require "shared.csvdata" | |
| 250 | + local now = skynet.timex() | |
| 251 | + local day = weekday(now) | |
| 252 | + local workMainCsv = csvdb["work_mainCsv"][day] | |
| 253 | + if workMainCsv and isSpecTime(now - RESET_TIME * 3600, csvdb["time_resetCsv"][TimeReset["WorkBattle1"]].start / 3600, 24) then | |
| 254 | + local round = math.floor((now - START_RESET_TIME) / 604800) | |
| 255 | + local field = round * 10 + day | |
| 256 | + local count = tonum(redisproxy:hget(WORK_BATTLE_COUNT, field)) | |
| 257 | + if count < workMainCsv.target_num then | |
| 258 | + local add = math.floor(workMainCsv.target_num * math.randomInt(3125, 5000) / 100000) | |
| 259 | + redisproxy:hincrby(WORK_BATTLE_COUNT, field, add) | |
| 260 | + end | |
| 261 | + end | |
| 262 | + skynet.timeout(math.randomInt(10 * 60, 15 * 60) * 100, check_work_battle) | |
| 263 | +end | |
| 264 | + | |
| 187 | 265 | local CMD = {} |
| 188 | 266 | |
| 189 | 267 | |
| ... | ... | @@ -205,9 +283,12 @@ end |
| 205 | 283 | |
| 206 | 284 | |
| 207 | 285 | function CMD.start() |
| 286 | + math.randomInit(skynet.timex()) | |
| 208 | 287 | check_mail_queue() |
| 209 | 288 | --check_battle_act_close() |
| 210 | 289 | check_trade_seaport_status() |
| 290 | + check_trade_seaport_donate() | |
| 291 | + check_work_battle() | |
| 211 | 292 | end |
| 212 | 293 | |
| 213 | 294 | local function __init__() | ... | ... |
src/utils/CommonFunc.lua
| ... | ... | @@ -235,8 +235,9 @@ function specMonday(now) |
| 235 | 235 | return time - (wday - 1) * 86400 |
| 236 | 236 | end |
| 237 | 237 | |
| 238 | -function isSpecTime(startHour, endHour, specday) | |
| 239 | - local tm = os.date("*t", skynet.timex()) | |
| 238 | +function isSpecTime(ctime, startHour, endHour, specday) | |
| 239 | + ctime = ctime or skynet.timex() | |
| 240 | + local tm = os.date("*t", ctime) | |
| 240 | 241 | if specday then |
| 241 | 242 | local day = (tm.wday+6)%7 |
| 242 | 243 | if day == 0 then day = 7 end | ... | ... |