Commit 340944f186a94d072b7c801ef89ee36e4aa962c7
Merge branch 'cn/develop' into cn/publish/preview
Showing
17 changed files
with
501 additions
and
22 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,6 +16,12 @@ TIME_ZONE = math.floor(os.difftime(START_RESET_TIME_BASE, os.time(os.date("!*t", | ||
16 | 16 | ||
17 | START_RESET_TIME = START_RESET_TIME_BASE - TIME_ZONE * 3600 | 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 | STRUCT_VERSION = 3 -- 数据结构版本 | 25 | STRUCT_VERSION = 3 -- 数据结构版本 |
20 | 26 | ||
21 | IOS_SID = 4 -- 判断是不是ios设备 | 27 | IOS_SID = 4 -- 判断是不是ios设备 |
@@ -158,6 +164,11 @@ TimeReset = { | @@ -158,6 +164,11 @@ TimeReset = { | ||
158 | DrawType1 = 17, -- 变异 抽卡加成 | 164 | DrawType1 = 17, -- 变异 抽卡加成 |
159 | DrawType2 = 18, -- 通常 抽卡加成 | 165 | DrawType2 = 18, -- 通常 抽卡加成 |
160 | DrawType3 = 19, -- 魔法 抽卡加成 | 166 | DrawType3 = 19, -- 魔法 抽卡加成 |
167 | + WorkBattle1 = 22, -- 夜间玩法 1 | ||
168 | + WorkBattle2 = 23, -- 夜间玩法 2 | ||
169 | + WorkBattle3 = 24, -- 夜间玩法 3 | ||
170 | + WorkBattle4 = 25, -- 夜间玩法 4 | ||
171 | + WorkBattle5 = 26, -- 夜间玩法 5 | ||
161 | } | 172 | } |
162 | 173 | ||
163 | -- TimeReset 索引数组 | 174 | -- TimeReset 索引数组 |
src/ProtocolCode.lua
@@ -121,6 +121,10 @@ actionCodes = { | @@ -121,6 +121,10 @@ actionCodes = { | ||
121 | Hang_bagFieldRpc = 263, | 121 | Hang_bagFieldRpc = 263, |
122 | Hang_chatLineRpc = 264, | 122 | Hang_chatLineRpc = 264, |
123 | Hang_selectTeamRpc = 265, | 123 | Hang_selectTeamRpc = 265, |
124 | + Hang_startWorkBattleRpc = 266, | ||
125 | + Hang_endWorkBattleRpc = 267, | ||
126 | + Hang_workBattleInfoRpc = 268, | ||
127 | + Hang_getWorkRewardRpc = 269, | ||
124 | 128 | ||
125 | Diner_updateProperty = 300, | 129 | Diner_updateProperty = 300, |
126 | Diner_addSellRpc = 301, | 130 | Diner_addSellRpc = 301, |
src/RedisKeys.lua
@@ -62,7 +62,7 @@ FRIEND_ENERGY = "role:%d:energy" -- set 送给我活动能量的好友 | @@ -62,7 +62,7 @@ FRIEND_ENERGY = "role:%d:energy" -- set 送给我活动能量的好友 | ||
62 | FRIEND_RECOMMEND = "friend:recommend" -- sort set 登录排序 获取推荐好友 | 62 | FRIEND_RECOMMEND = "friend:recommend" -- sort set 登录排序 获取推荐好友 |
63 | CHAT_OFFLINE = "chat:offline:%d" --消息离线缓存 | 63 | CHAT_OFFLINE = "chat:offline:%d" --消息离线缓存 |
64 | 64 | ||
65 | - | 65 | +WORK_BATTLE_COUNT = "global:workbattle" -- 世界次数统计 |
66 | -- FRIEND_DINER_LIKE_KEY = "role:%d:diner:like" -- list | 66 | -- FRIEND_DINER_LIKE_KEY = "role:%d:diner:like" -- list |
67 | 67 | ||
68 | -- UNION_SET = "global:union" | 68 | -- UNION_SET = "global:union" |
src/actions/ActivityAction.lua
@@ -140,6 +140,13 @@ function _M.signRpc(agent, data) | @@ -140,6 +140,13 @@ function _M.signRpc(agent, data) | ||
140 | role:changeUpdates({{type = "sign", field = curDay, value = yearMonth}}) | 140 | role:changeUpdates({{type = "sign", field = curDay, value = yearMonth}}) |
141 | role:checkTaskEnter("SignIn") | 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 | SendPacket(actionCodes.Activity_signRpc, MsgPack.pack(role:packReward(reward, change))) | 150 | SendPacket(actionCodes.Activity_signRpc, MsgPack.pack(role:packReward(reward, change))) |
144 | return true | 151 | return true |
145 | end | 152 | end |
src/actions/HangAction.lua
@@ -750,6 +750,251 @@ function _M.endBonusBattleRpc(agent, data) | @@ -750,6 +750,251 @@ function _M.endBonusBattleRpc(agent, data) | ||
750 | return true | 750 | return true |
751 | end | 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 | + | ||
759 | + | ||
760 | + reward = bonusData.reward:toNumMap() | ||
761 | + for itemId, c in pairs(reward) do | ||
762 | + reward[itemId] = c * count | ||
763 | + end | ||
764 | + if rewardType == 2 or rewardType == 4 then | ||
765 | + for k, v in pairs(bonusData.perfect_reward:toNumMap()) do | ||
766 | + reward[k] = (reward[k] or 0) + v | ||
767 | + end | ||
768 | + end | ||
769 | + for i = 1, count do | ||
770 | + local chance = bonusData.chance:randWeight(true) | ||
771 | + if chance[1] ~= 0 then | ||
772 | + reward[chance[1]] = (reward[chance[1]] or 0) + chance[2] | ||
773 | + end | ||
774 | + end | ||
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 | function _M.hangGiftRpc(agent, data) | 998 | function _M.hangGiftRpc(agent, data) |
754 | local role = agent.role | 999 | local role = agent.role |
755 | local msg = MsgPack.unpack(data) | 1000 | local msg = MsgPack.unpack(data) |
src/actions/RoleAction.lua
@@ -161,6 +161,9 @@ function _M.loginRpc( agent, data ) | @@ -161,6 +161,9 @@ function _M.loginRpc( agent, data ) | ||
161 | role:getAdvData(true) -- 清掉不合格的数据 | 161 | role:getAdvData(true) -- 清掉不合格的数据 |
162 | role:advEndlessSeasonCheck(true) -- 冒险赛季更新检查 | 162 | role:advEndlessSeasonCheck(true) -- 冒险赛季更新检查 |
163 | role:checkSeaportTrade() -- 检查海港贸易季活动 | 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 | local resetMode = role:updateTimeReset(now) | 169 | local resetMode = role:updateTimeReset(now) |
@@ -936,7 +939,15 @@ function _M.taskActiveRpc(agent, data) | @@ -936,7 +939,15 @@ function _M.taskActiveRpc(agent, data) | ||
936 | return | 939 | return |
937 | end | 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 | role:changeUpdates({ | 951 | role:changeUpdates({ |
941 | { type = roleField[taskType], field = {"at", taskId}, value = -1 } | 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,12 +8,13 @@ function _M.rechargeRpc(agent , data) | ||
8 | local role = agent.role | 8 | local role = agent.role |
9 | local msg = MsgPack.unpack(data) | 9 | local msg = MsgPack.unpack(data) |
10 | local id = msg.id | 10 | local id = msg.id |
11 | + local choose = msg.choose or "" | ||
11 | local dataSet = csvdb["shop_rechargeCsv"][id] | 12 | local dataSet = csvdb["shop_rechargeCsv"][id] |
12 | if not dataSet then return end | 13 | if not dataSet then return end |
13 | local roleId = role:getProperty("id") | 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 | if partnerOrderId == "" then | 18 | if partnerOrderId == "" then |
18 | return 1 | 19 | return 1 |
19 | end | 20 | end |
@@ -162,13 +163,14 @@ function _M.googleRechargeRpc(agent, data) | @@ -162,13 +163,14 @@ function _M.googleRechargeRpc(agent, data) | ||
162 | local role = agent.role | 163 | local role = agent.role |
163 | local msg = MsgPack.unpack(data) | 164 | local msg = MsgPack.unpack(data) |
164 | local id = msg.id | 165 | local id = msg.id |
166 | + local choose = msg.choose or "" | ||
165 | local dataSet = csvdb["shop_rechargeCsv"][id] | 167 | local dataSet = csvdb["shop_rechargeCsv"][id] |
166 | if not dataSet then return end | 168 | if not dataSet then return end |
167 | local roleId = role:getProperty("id") | 169 | local roleId = role:getProperty("id") |
168 | 170 | ||
169 | role.ignoreHeartbeat = true | 171 | role.ignoreHeartbeat = true |
170 | --创建订单号 | 172 | --创建订单号 |
171 | - local partnerOrderId = role:getPurchaseOrder(id) | 173 | + local partnerOrderId = role:getPurchaseOrder(id,nil,choose) |
172 | -- 签名 | 174 | -- 签名 |
173 | -- local secret_key = "b7657fa7ccd44c16a35e3f454ac7a075" | 175 | -- local secret_key = "b7657fa7ccd44c16a35e3f454ac7a075" |
174 | local secret_key = "8920e9dcf0cb4ebca87393ce48021ead" | 176 | local secret_key = "8920e9dcf0cb4ebca87393ce48021ead" |
@@ -190,13 +192,14 @@ function _M.myCardRechargeRpc(agent, data) | @@ -190,13 +192,14 @@ function _M.myCardRechargeRpc(agent, data) | ||
190 | local role = agent.role | 192 | local role = agent.role |
191 | local msg = MsgPack.unpack(data) | 193 | local msg = MsgPack.unpack(data) |
192 | local id = msg.id | 194 | local id = msg.id |
195 | + local choose = msg.choose or "" | ||
193 | local dataSet = csvdb["shop_rechargeCsv"][id] | 196 | local dataSet = csvdb["shop_rechargeCsv"][id] |
194 | if not dataSet then return end | 197 | if not dataSet then return end |
195 | local roleId = role:getProperty("id") | 198 | local roleId = role:getProperty("id") |
196 | 199 | ||
197 | role.ignoreHeartbeat = true | 200 | role.ignoreHeartbeat = true |
198 | --创建订单号 | 201 | --创建订单号 |
199 | - local partnerOrderId = role:getPurchaseOrder(id) | 202 | + local partnerOrderId = role:getPurchaseOrder(id,nil,choose) |
200 | -- 签名 | 203 | -- 签名 |
201 | local secret_key = "48759e07540f46d9af17ec82669b4272" | 204 | local secret_key = "48759e07540f46d9af17ec82669b4272" |
202 | local need = { | 205 | local need = { |
@@ -216,13 +219,14 @@ function _M.iosRechargeRpc(agent, data) | @@ -216,13 +219,14 @@ function _M.iosRechargeRpc(agent, data) | ||
216 | local role = agent.role | 219 | local role = agent.role |
217 | local msg = MsgPack.unpack(data) | 220 | local msg = MsgPack.unpack(data) |
218 | local id = msg.id | 221 | local id = msg.id |
222 | + local choose = msg.choose or "" | ||
219 | local dataSet = csvdb["shop_rechargeCsv"][id] | 223 | local dataSet = csvdb["shop_rechargeCsv"][id] |
220 | if not dataSet then return end | 224 | if not dataSet then return end |
221 | local roleId = role:getProperty("id") | 225 | local roleId = role:getProperty("id") |
222 | 226 | ||
223 | role.ignoreHeartbeat = true | 227 | role.ignoreHeartbeat = true |
224 | --创建订单号 | 228 | --创建订单号 |
225 | - local partnerOrderId = role:getPurchaseOrder(id) | 229 | + local partnerOrderId = role:getPurchaseOrder(id,nil,choose) |
226 | -- 签名 | 230 | -- 签名 |
227 | local secret_key = "1916d62251dd4a8aa5e452121eefc9a1" | 231 | local secret_key = "1916d62251dd4a8aa5e452121eefc9a1" |
228 | local need = { | 232 | local need = { |
@@ -283,7 +287,7 @@ function _M.shopBuyRpc(agent , data) | @@ -283,7 +287,7 @@ function _M.shopBuyRpc(agent , data) | ||
283 | 287 | ||
284 | local cost = {[dataSet.icon] = dataSet.cost * count} | 288 | local cost = {[dataSet.icon] = dataSet.cost * count} |
285 | 289 | ||
286 | - local desc = "unknown" | 290 | + local desc = "unknowShop" |
287 | if dataSet.shop == 1 then -- 普通商店 | 291 | if dataSet.shop == 1 then -- 普通商店 |
288 | desc = "dailyShop" | 292 | desc = "dailyShop" |
289 | local dailySDD = role.dailyData:getProperty("dailySDD") | 293 | local dailySDD = role.dailyData:getProperty("dailySDD") |
src/models/Activity.lua
@@ -884,6 +884,11 @@ function Activity:getBattleTicket(actId) | @@ -884,6 +884,11 @@ function Activity:getBattleTicket(actId) | ||
884 | local ticketId, init, limit, duration = arr[1] or 0, arr[2] or 0, arr[3] or 0, arr[4] or 10000 | 884 | local ticketId, init, limit, duration = arr[1] or 0, arr[2] or 0, arr[3] or 0, arr[4] or 10000 |
885 | 885 | ||
886 | local count = actData["ticket"] or init | 886 | local count = actData["ticket"] or init |
887 | + if count >= limit then | ||
888 | + actData["ts"] = timeNow | ||
889 | + self:updateActData("ChallengeLevel", actData) | ||
890 | + return | ||
891 | + end | ||
887 | local add = math.max(math.floor((timeNow - startTs) / (duration * 60)), 0) | 892 | local add = math.max(math.floor((timeNow - startTs) / (duration * 60)), 0) |
888 | 893 | ||
889 | local newCount= math.min(count + add, limit) | 894 | local newCount= math.min(count + add, limit) |
src/models/Order.lua
@@ -13,6 +13,7 @@ Order.schema = { | @@ -13,6 +13,7 @@ Order.schema = { | ||
13 | finishTime = {"number", 0}, -- 服务端验证完成时间 | 13 | finishTime = {"number", 0}, -- 服务端验证完成时间 |
14 | status = {"string", "create"}, | 14 | status = {"string", "create"}, |
15 | sid = {"number",0}, -- 创建单号的设备的sid | 15 | sid = {"number",0}, -- 创建单号的设备的sid |
16 | + choose = {"string", ""}, -- 自选奖励 | ||
16 | } | 17 | } |
17 | 18 | ||
18 | Order.fields = { | 19 | Order.fields = { |
@@ -23,6 +24,7 @@ Order.fields = { | @@ -23,6 +24,7 @@ Order.fields = { | ||
23 | finishTime = true, | 24 | finishTime = true, |
24 | status = true, | 25 | status = true, |
25 | sid = true, | 26 | sid = true, |
27 | + choose = true, | ||
26 | } | 28 | } |
27 | 29 | ||
28 | return Order | 30 | return Order |
29 | \ No newline at end of file | 31 | \ No newline at end of file |
src/models/Role.lua
@@ -120,6 +120,8 @@ Role.schema = { | @@ -120,6 +120,8 @@ Role.schema = { | ||
120 | towerTeams = {"table", {}}, -- 四个电波塔的队伍 | 120 | towerTeams = {"table", {}}, -- 四个电波塔的队伍 |
121 | 121 | ||
122 | bonusStar = {"table", {}}, -- 奖励关卡 通关星星 {[id] = 1} 三个二进制位 表示三个星 从低到高 (1 << 0) (1 << 1) (1 << 2) 满星 (1 << 3) - 1 | 122 | bonusStar = {"table", {}}, -- 奖励关卡 通关星星 {[id] = 1} 三个二进制位 表示三个星 从低到高 (1 << 0) (1 << 1) (1 << 2) 满星 (1 << 3) - 1 |
123 | + workStar = {"table", {}}, -- 夜间玩法 通关星星 {[id] = 1} 三个二进制位 表示三个星 从低到高 (1 << 0) (1 << 1) (1 << 2) 满星 (1 << 3) - 1 | ||
124 | + workBattle = {"table", {}}, -- 夜间玩法记录 {[1] = 1, [2] = 1, [3] = 1, [4] = 1, round = 10} -- 第N天打了多少次 round 轮次 | ||
123 | 125 | ||
124 | --引导相关 | 126 | --引导相关 |
125 | newerGuide = {"string","1=1"}, -- 新手引导 master=slave | 127 | newerGuide = {"string","1=1"}, -- 新手引导 master=slave |
@@ -379,6 +381,8 @@ function Role:data() | @@ -379,6 +381,8 @@ function Role:data() | ||
379 | towerTeams = self:getProperty("towerTeams"), | 381 | towerTeams = self:getProperty("towerTeams"), |
380 | 382 | ||
381 | bonusStar = self:getProperty("bonusStar"), | 383 | bonusStar = self:getProperty("bonusStar"), |
384 | + workStar = self:getProperty("workStar"), | ||
385 | + workBattle = self:getProperty("workBattle"), | ||
382 | 386 | ||
383 | newerGuide = self:getProperty("newerGuide"), | 387 | newerGuide = self:getProperty("newerGuide"), |
384 | funcGuide = self:getProperty("funcGuide"), | 388 | funcGuide = self:getProperty("funcGuide"), |
src/models/RoleBattle.lua
@@ -17,6 +17,7 @@ local BattleType = { | @@ -17,6 +17,7 @@ local BattleType = { | ||
17 | pvpc = 500, | 17 | pvpc = 500, |
18 | pvph = 501, | 18 | pvph = 501, |
19 | act_battle = 502, | 19 | act_battle = 502, |
20 | + work = 301, | ||
20 | } | 21 | } |
21 | 22 | ||
22 | RoleBattle.bind = function (Role) | 23 | RoleBattle.bind = function (Role) |
@@ -127,6 +128,18 @@ function Role:checkBattleCheat(battleType, params) | @@ -127,6 +128,18 @@ function Role:checkBattleCheat(battleType, params) | ||
127 | -- local carbonData = csvdb["bonus_battleCsv"][params.id] | 128 | -- local carbonData = csvdb["bonus_battleCsv"][params.id] |
128 | -- enemyServer = packBattleEnemyCommon(carbonData) | 129 | -- enemyServer = packBattleEnemyCommon(carbonData) |
129 | end | 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 | cheat["pvpc"] = function() | 143 | cheat["pvpc"] = function() |
131 | if not params.format then return end | 144 | if not params.format then return end |
132 | local team = self:getTeamBattleInfo(params.format) | 145 | local team = self:getTeamBattleInfo(params.format) |
src/models/RoleLog.lua
@@ -58,6 +58,7 @@ local ItemReason = { | @@ -58,6 +58,7 @@ local ItemReason = { | ||
58 | newSign = 142,-- 新的活动签到 | 58 | newSign = 142,-- 新的活动签到 |
59 | advLevelStage = 143, -- 拾荒活动阶段奖励 | 59 | advLevelStage = 143, -- 拾荒活动阶段奖励 |
60 | towerBnous = 144, -- 爬塔到一定层数对某些功能的奖励 | 60 | towerBnous = 144, -- 爬塔到一定层数对某些功能的奖励 |
61 | + unknowShop = 145, -- 未知商店 | ||
61 | 62 | ||
62 | 63 | ||
63 | advHang = 301, -- 拾荒挂机 | 64 | advHang = 301, -- 拾荒挂机 |
@@ -72,6 +73,8 @@ local ItemReason = { | @@ -72,6 +73,8 @@ local ItemReason = { | ||
72 | towerBattle = 310, -- 电波塔战斗 | 73 | towerBattle = 310, -- 电波塔战斗 |
73 | advOver = 311, -- 冒险结算 | 74 | advOver = 311, -- 冒险结算 |
74 | advUnlock = 312, -- 拾荒解锁 | 75 | advUnlock = 312, -- 拾荒解锁 |
76 | + workBattle = 313, -- workBattle夜间打工 | ||
77 | + workReward = 314, -- workBattle夜间打工 阶段奖励 | ||
75 | 78 | ||
76 | dinerFinishTask = 401, -- 餐厅完成任务 | 79 | dinerFinishTask = 401, -- 餐厅完成任务 |
77 | storybookReward = 402, -- 剧情奖励 | 80 | storybookReward = 402, -- 剧情奖励 |
src/models/RolePlugin.lua
@@ -144,7 +144,9 @@ function RolePlugin.bind(Role) | @@ -144,7 +144,9 @@ function RolePlugin.bind(Role) | ||
144 | self:addPotion({id = itemId, count = count, notNotify = pms.notNotify, log = pms.log}) | 144 | self:addPotion({id = itemId, count = count, notNotify = pms.notNotify, log = pms.log}) |
145 | end, | 145 | end, |
146 | [ItemType.BossTicket] = function () | 146 | [ItemType.BossTicket] = function () |
147 | - if not self.activity:isOpen("ChallengeLevel") then return end | 147 | + local isOpen, actId = self.activity:isOpen("ChallengeLevel") |
148 | + if not isOpen then return end | ||
149 | + self.activity:getBattleTicket(actId) | ||
148 | local actData = self.activity:getActData("ChallengeLevel") | 150 | local actData = self.activity:getActData("ChallengeLevel") |
149 | actData["ticket"] = (actData["ticket"] or 0) + count | 151 | actData["ticket"] = (actData["ticket"] or 0) + count |
150 | self.activity:updateActData("ChallengeLevel", actData) | 152 | self.activity:updateActData("ChallengeLevel", actData) |
@@ -861,7 +863,6 @@ function RolePlugin.bind(Role) | @@ -861,7 +863,6 @@ function RolePlugin.bind(Role) | ||
861 | if not params.notNotify then | 863 | if not params.notNotify then |
862 | local response = {} | 864 | local response = {} |
863 | table.insert(response, newSpark:data()) | 865 | table.insert(response, newSpark:data()) |
864 | - dump(response) | ||
865 | SendPacket(actionCodes.Role_loadSparks, MsgPack.pack(response)) | 866 | SendPacket(actionCodes.Role_loadSparks, MsgPack.pack(response)) |
866 | end | 867 | end |
867 | --self:checkTaskEnter("AddRune", {id = params.id, type = params.type, rarity = data.rarity}, params.notNotify) | 868 | --self:checkTaskEnter("AddRune", {id = params.id, type = params.type, rarity = data.rarity}, params.notNotify) |
@@ -1349,18 +1350,22 @@ function RolePlugin.bind(Role) | @@ -1349,18 +1350,22 @@ function RolePlugin.bind(Role) | ||
1349 | local donate = seaport.donate or {} | 1350 | local donate = seaport.donate or {} |
1350 | if not reset and (not donate[1] or not donate[2]) then | 1351 | if not reset and (not donate[1] or not donate[2]) then |
1351 | local result = self:getSeaportServerProgress() | 1352 | local result = self:getSeaportServerProgress() |
1352 | - local seaportCsv = csvdb["seaport_purchaseCsv"] | ||
1353 | - for idx, set in ipairs(seaportCsv) do | 1353 | + for idx, set in ipairs(csvdb["seaport_purchaseCsv"]) do |
1354 | local done = true | 1354 | local done = true |
1355 | for id, data in ipairs(set) do | 1355 | for id, data in ipairs(set) do |
1356 | - if donate[id] or not result[idx] or not result[idx][id] or result[idx][id] < data.need_num then | 1356 | + if donate[idx] or not result[idx] or not result[idx][id] or result[idx][id] < data.need_num then |
1357 | done = false | 1357 | done = false |
1358 | break | 1358 | break |
1359 | end | 1359 | end |
1360 | end | 1360 | end |
1361 | if done then | 1361 | if done then |
1362 | update = true | 1362 | update = true |
1363 | - self:award(set[1].phase_award, {log = {desc = "seaportReward", int1 = set[1].phase, int2 = set[1].id}}) | 1363 | + redisproxy:insertEmail({ |
1364 | + roleId = self:getProperty("id"), | ||
1365 | + emailId = idx == 1 and 361 or 362, | ||
1366 | + attachments = set[1].phase_award, | ||
1367 | + }) | ||
1368 | + -- self:award(set[1].phase_award, {log = {desc = "seaportReward", int1 = set[1].phase, int2 = set[1].id}}) | ||
1364 | donate[idx] = 1 | 1369 | donate[idx] = 1 |
1365 | end | 1370 | end |
1366 | end | 1371 | end |
@@ -1397,6 +1402,8 @@ function RolePlugin.bind(Role) | @@ -1397,6 +1402,8 @@ function RolePlugin.bind(Role) | ||
1397 | local expCarbonId = self:getProperty("hangInfo").expCarbonId | 1402 | local expCarbonId = self:getProperty("hangInfo").expCarbonId |
1398 | local taskCsv = csvdb["seaport_taskCsv"] | 1403 | local taskCsv = csvdb["seaport_taskCsv"] |
1399 | local endTime = openTime0 + 86400 * 2 | 1404 | local endTime = openTime0 + 86400 * 2 |
1405 | + local reward = {} | ||
1406 | + | ||
1400 | for slot, set in pairs(taskCsv) do | 1407 | for slot, set in pairs(taskCsv) do |
1401 | if collect[slot] then | 1408 | if collect[slot] then |
1402 | update = true | 1409 | update = true |
@@ -1433,9 +1440,28 @@ function RolePlugin.bind(Role) | @@ -1433,9 +1440,28 @@ function RolePlugin.bind(Role) | ||
1433 | itemReward[key] = math.ceil(1.5 * value) | 1440 | itemReward[key] = math.ceil(1.5 * value) |
1434 | end | 1441 | end |
1435 | end | 1442 | end |
1436 | - self:award(itemReward, {log = {desc = "seaportTask", int1 = slot, int2 = level}}) | 1443 | + |
1444 | + for itemId, value in pairs(itemReward) do | ||
1445 | + reward[itemId] = (reward[itemId] or 0) + value | ||
1446 | + end | ||
1447 | + -- self:award(itemReward, {log = {desc = "seaportTask", int1 = slot, int2 = level}}) | ||
1448 | + end | ||
1449 | + end | ||
1450 | + end | ||
1451 | + | ||
1452 | + if next(reward) then | ||
1453 | + local rewardStr = "" | ||
1454 | + for itemId, value in pairs(reward) do | ||
1455 | + if rewardStr ~= "" then | ||
1456 | + rewardStr = rewardStr .. " " | ||
1437 | end | 1457 | end |
1458 | + rewardStr = rewardStr .. string.format("%s=%s",itemId,value) | ||
1438 | end | 1459 | end |
1460 | + redisproxy:insertEmail({ | ||
1461 | + roleId = self:getProperty("id"), | ||
1462 | + emailId = 363, | ||
1463 | + attachments = rewardStr, | ||
1464 | + }) | ||
1439 | end | 1465 | end |
1440 | end | 1466 | end |
1441 | seaport.collect = {} | 1467 | seaport.collect = {} |
@@ -2022,7 +2048,7 @@ function RolePlugin.bind(Role) | @@ -2022,7 +2048,7 @@ function RolePlugin.bind(Role) | ||
2022 | return "error money" | 2048 | return "error money" |
2023 | end | 2049 | end |
2024 | -- 发现需要的id | 2050 | -- 发现需要的id |
2025 | - local partnerOrderId = self:getPurchaseOrder(k, params.transactionId) | 2051 | + local partnerOrderId = self:getPurchaseOrder(k, params.transactionId, params.choose) |
2026 | if partnerOrderId == "" then | 2052 | if partnerOrderId == "" then |
2027 | return "no product" | 2053 | return "no product" |
2028 | end | 2054 | end |
@@ -2032,7 +2058,7 @@ function RolePlugin.bind(Role) | @@ -2032,7 +2058,7 @@ function RolePlugin.bind(Role) | ||
2032 | end | 2058 | end |
2033 | 2059 | ||
2034 | -- 获取充值订单号 | 2060 | -- 获取充值订单号 |
2035 | - function Role:getPurchaseOrder(rechargeId, transactionId) | 2061 | + function Role:getPurchaseOrder(rechargeId, transactionId, choose) |
2036 | local roleId = self:getProperty("id") | 2062 | local roleId = self:getProperty("id") |
2037 | local rechargeData = csvdb["shop_rechargeCsv"][rechargeId] | 2063 | local rechargeData = csvdb["shop_rechargeCsv"][rechargeId] |
2038 | if not rechargeData then | 2064 | if not rechargeData then |
@@ -2044,7 +2070,24 @@ function RolePlugin.bind(Role) | @@ -2044,7 +2070,24 @@ function RolePlugin.bind(Role) | ||
2044 | if limit ~= 0 and limit <= (rechargeRecord[rechargeId] or 0) then | 2070 | if limit ~= 0 and limit <= (rechargeRecord[rechargeId] or 0) then |
2045 | return "" | 2071 | return "" |
2046 | end | 2072 | end |
2047 | - | 2073 | + -- 检查礼包自选奖励合法 |
2074 | + if choose and choose ~= "" then | ||
2075 | + if rechargeData.itemgift == "" then return "" end | ||
2076 | + local slot = rechargeData.itemdirect or 0 | ||
2077 | + local set = choose:toTableArray(true) | ||
2078 | + if slot ~= #set then return "" end | ||
2079 | + local pass = {} | ||
2080 | + local groups = rechargeData.itemgift:toTableArray(true) | ||
2081 | + for idx, item in ipairs(set) do | ||
2082 | + for _, group in ipairs(groups) do | ||
2083 | + if group[2] == item[1] and group[3] == item[2] and idx == group[1] then | ||
2084 | + pass[group[1]] = 1 | ||
2085 | + break | ||
2086 | + end | ||
2087 | + end | ||
2088 | + end | ||
2089 | + if #pass ~= slot then return "" end | ||
2090 | + end | ||
2048 | --判断是否是活动商品 | 2091 | --判断是否是活动商品 |
2049 | if rechargeData.activity_id ~= 0 then | 2092 | if rechargeData.activity_id ~= 0 then |
2050 | local actCfg = csvdb["activity_ctrlCsv"][rechargeData.activity_id] | 2093 | local actCfg = csvdb["activity_ctrlCsv"][rechargeData.activity_id] |
@@ -2071,6 +2114,7 @@ function RolePlugin.bind(Role) | @@ -2071,6 +2114,7 @@ function RolePlugin.bind(Role) | ||
2071 | createTime = skynet.timex(), | 2114 | createTime = skynet.timex(), |
2072 | transactionId = transactionId, | 2115 | transactionId = transactionId, |
2073 | sid = self:getProperty("sid"), | 2116 | sid = self:getProperty("sid"), |
2117 | + choose = choose or "", | ||
2074 | }) | 2118 | }) |
2075 | order:create() | 2119 | order:create() |
2076 | -- 正在进行中的订单 缓存 | 2120 | -- 正在进行中的订单 缓存 |
@@ -2139,7 +2183,7 @@ function RolePlugin.bind(Role) | @@ -2139,7 +2183,7 @@ function RolePlugin.bind(Role) | ||
2139 | }) | 2183 | }) |
2140 | end | 2184 | end |
2141 | 2185 | ||
2142 | - return true, rechargeId, sid | 2186 | + return true, rechargeId, sid, orderObject:getProperty("choose") |
2143 | end | 2187 | end |
2144 | 2188 | ||
2145 | -- 充值 -- | 2189 | -- 充值 -- |
@@ -2157,7 +2201,7 @@ function RolePlugin.bind(Role) | @@ -2157,7 +2201,7 @@ function RolePlugin.bind(Role) | ||
2157 | local roleId = self:getProperty("id") | 2201 | local roleId = self:getProperty("id") |
2158 | local partnerOrderStr = params.order | 2202 | local partnerOrderStr = params.order |
2159 | 2203 | ||
2160 | - local status, back, sid = self:updatePurchaseOrder(partnerOrderStr, params.transactionId, "finsh") | 2204 | + local status, back, sid, choose = self:updatePurchaseOrder(partnerOrderStr, params.transactionId, "finsh") |
2161 | if not status then | 2205 | if not status then |
2162 | if back == "finsh" then | 2206 | if back == "finsh" then |
2163 | -- 订单已经处理 | 2207 | -- 订单已经处理 |
@@ -2180,6 +2224,7 @@ function RolePlugin.bind(Role) | @@ -2180,6 +2224,7 @@ function RolePlugin.bind(Role) | ||
2180 | pay_time = params.pay_time, | 2224 | pay_time = params.pay_time, |
2181 | order = partnerOrderStr, | 2225 | order = partnerOrderStr, |
2182 | sid = sid, | 2226 | sid = sid, |
2227 | + choose = choose, | ||
2183 | }) | 2228 | }) |
2184 | 2229 | ||
2185 | if not status then | 2230 | if not status then |
@@ -2227,6 +2272,17 @@ function RolePlugin.bind(Role) | @@ -2227,6 +2272,17 @@ function RolePlugin.bind(Role) | ||
2227 | return 3 | 2272 | return 3 |
2228 | end | 2273 | end |
2229 | 2274 | ||
2275 | + -- 自选奖励部分 | ||
2276 | + if params.choose and params.choose ~= "" then | ||
2277 | + local tReward, tChange = self:award(params.choose, {log = {desc = "recharge", int1 = id}}) | ||
2278 | + for itemId, value in pairs(tReward) do | ||
2279 | + reward[itemId] = (reward[itemId] or 0) + value | ||
2280 | + end | ||
2281 | + for itemId, value in pairs(tChange or {}) do | ||
2282 | + reward[itemId] = (reward[itemId] or 0) + value | ||
2283 | + end | ||
2284 | + end | ||
2285 | + | ||
2230 | if diamondCount > 0 then | 2286 | if diamondCount > 0 then |
2231 | reward[ItemId.Diamond] = (reward[ItemId.Diamond] or 0) + diamondCount | 2287 | reward[ItemId.Diamond] = (reward[ItemId.Diamond] or 0) + diamondCount |
2232 | end | 2288 | end |
src/models/RoleTimeReset.lua
@@ -33,6 +33,38 @@ ResetFunc["CrossDay"] = function(self, notify, response, now) | @@ -33,6 +33,38 @@ ResetFunc["CrossDay"] = function(self, notify, response, now) | ||
33 | self:checkReturner() | 33 | self:checkReturner() |
34 | end | 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 | response.dTask = {} | 68 | response.dTask = {} |
37 | response.advSup = self:getProperty("advSup") | 69 | response.advSup = self:getProperty("advSup") |
38 | self:log("onLogin") | 70 | self:log("onLogin") |
src/services/globald.lua
@@ -184,6 +184,84 @@ local function check_trade_seaport_status() | @@ -184,6 +184,84 @@ local function check_trade_seaport_status() | ||
184 | skynet.timeout(interval, check_trade_seaport_status) | 184 | skynet.timeout(interval, check_trade_seaport_status) |
185 | end | 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 | local CMD = {} | 265 | local CMD = {} |
188 | 266 | ||
189 | 267 | ||
@@ -205,9 +283,12 @@ end | @@ -205,9 +283,12 @@ end | ||
205 | 283 | ||
206 | 284 | ||
207 | function CMD.start() | 285 | function CMD.start() |
286 | + math.randomInit(skynet.timex()) | ||
208 | check_mail_queue() | 287 | check_mail_queue() |
209 | --check_battle_act_close() | 288 | --check_battle_act_close() |
210 | check_trade_seaport_status() | 289 | check_trade_seaport_status() |
290 | + check_trade_seaport_donate() | ||
291 | + check_work_battle() | ||
211 | end | 292 | end |
212 | 293 | ||
213 | local function __init__() | 294 | local function __init__() |
src/utils/CommonFunc.lua
@@ -235,8 +235,9 @@ function specMonday(now) | @@ -235,8 +235,9 @@ function specMonday(now) | ||
235 | return time - (wday - 1) * 86400 | 235 | return time - (wday - 1) * 86400 |
236 | end | 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 | if specday then | 241 | if specday then |
241 | local day = (tm.wday+6)%7 | 242 | local day = (tm.wday+6)%7 |
242 | if day == 0 then day = 7 end | 243 | if day == 0 then day = 7 end |