Commit 9d2a3cb27ac0e63f42df6adc1e1403a167fd42e7

Authored by 熊润斐
2 parents 02e210c4 0e3acc50

Merge branch 'tr/develop' into tr/publish/qa-out

@@ -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 MAX_ROLE_NUM = 1000000 27 MAX_ROLE_NUM = 1000000
@@ -155,6 +161,11 @@ TimeReset = { @@ -155,6 +161,11 @@ TimeReset = {
155 DrawType1 = 17, -- 变异 抽卡加成 161 DrawType1 = 17, -- 变异 抽卡加成
156 DrawType2 = 18, -- 通常 抽卡加成 162 DrawType2 = 18, -- 通常 抽卡加成
157 DrawType3 = 19, -- 魔法 抽卡加成 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 -- TimeReset 索引数组 171 -- 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,
@@ -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,260 @@ function _M.endBonusBattleRpc(agent, data) @@ -750,6 +750,260 @@ 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 + 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 + if rewardType == 3 then
  765 + reward = bonusData.reward:toNumMap()
  766 + for itemId, c in pairs(reward) do
  767 + reward[itemId] = c * count
  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 + end
  776 + if sweep then
  777 + -- local bnousReward = role:getBnousSweep()
  778 + -- for key, value in pairs(bnousReward) do
  779 + -- reward[key] = (reward[key] or 0) + value * count
  780 + -- end
  781 + end
  782 +
  783 + reward, change = role:award(reward, {log = {desc = "workBattle", int1 = bonusData.id}})
  784 + -- role:checkTaskEnter("BonusPass", {id = bonusData.id, count = count})
  785 + return reward, change
  786 +end
  787 +
  788 +function _M.workBattleInfoRpc(agent, data)
  789 + local role = agent.role
  790 + local msg = MsgPack.unpack(data)
  791 + local workMainCsv = csvdb["work_mainCsv"][msg.type]
  792 + if not workMainCsv then return 1 end
  793 + if not role:isTimeResetOpen(TimeReset["WorkBattle" .. msg.type]) then return 2 end
  794 + SendPacket(actionCodes.Hang_workBattleInfoRpc, MsgPack.pack({count = tonum(redisproxy:hget(WORK_BATTLE_COUNT, role:getTimeResetRound(TimeReset["WorkBattle" .. msg.type]) * 10 + msg.type))}))
  795 + return true
  796 +end
  797 +
  798 +
  799 +function _M.getWorkRewardRpc(agent, data)
  800 + local role = agent.role
  801 + local msg = MsgPack.unpack(data)
  802 + local workMainCsv = csvdb["work_mainCsv"][msg.type]
  803 + if not workMainCsv then return 1 end
  804 + if not role:isTimeResetOpen(TimeReset["WorkBattle" .. msg.type]) then return 2 end
  805 + local count = tonum(redisproxy:hget(WORK_BATTLE_COUNT, role:getTimeResetRound(TimeReset["WorkBattle" .. msg.type]) * 10 + msg.type))
  806 + if count < workMainCsv.target_num then return 3 end
  807 + local workBattle = role:getProperty("workBattle")
  808 + if workBattle[msg.type] ~= 1 then
  809 + return 4
  810 + end
  811 + workBattle[msg.type] = -1
  812 + role:updateProperty({field = "workBattle", value = workBattle})
  813 + local reward, change = role:award(workMainCsv.phase_award, {log = {desc = "workReward"}})
  814 + SendPacket(actionCodes.Hang_getWorkRewardRpc, MsgPack.pack({reward = reward, change = change}))
  815 + return true
  816 +end
  817 +
  818 +function _M.startWorkBattleRpc(agent, data)
  819 + local role = agent.role
  820 + local msg = MsgPack.unpack(data)
  821 + local id = msg.id
  822 + local count = msg.count or 1
  823 +
  824 + if not role:isFuncUnlock(FuncUnlock.BonusBattle) then return 1 end
  825 +
  826 + local bonusData = csvdb["work_battleCsv"][id]
  827 +
  828 + if not bonusData then return 3 end
  829 +
  830 + if not role:isTimeResetOpen(TimeReset["WorkBattle" .. bonusData.type]) then return 2 end
  831 +
  832 + local ticketId = csvdb["work_mainCsv"][bonusData.type].ticket
  833 + local workStar = role:getProperty("workStar")
  834 +
  835 + if bonusData.unlock ~= 0 and (not workStar[bonusData.unlock] or workStar[bonusData.unlock] == 0) then return 4 end
  836 + local workBattle = role:getProperty("workBattle")
  837 + workBattle[bonusData.type] = workBattle[bonusData.type] or 0
  838 + local needCount = count - (workBattle[bonusData.type] == 0 and 1 or 0)
  839 + if needCount ~= 0 and not role:checkItemEnough({[ticketId] = needCount}) then return 11 end
  840 +
  841 + if workStar[id] and workStar[id] >= (1 << #bonusData.sweep_condition:toTableArray(true)) - 1 then
  842 + if workBattle[bonusData.type] == 0 then
  843 + workBattle[bonusData.type] = 1
  844 + role:updateProperty({field = "workBattle", value = workBattle})
  845 + end
  846 + if needCount > 0 then
  847 + role:costItems({[ticketId] = needCount}, {log = {desc = "workBattle", int1 = id}})
  848 + end
  849 + redisproxy:hincrby(WORK_BATTLE_COUNT, role:getTimeResetRound(TimeReset["WorkBattle" .. bonusData.type]) * 10 + bonusData.type, count)
  850 + local reward, change = workWinReward(role, bonusData, 3, count, true)
  851 + SendPacket(actionCodes.Hang_startWorkBattleRpc, MsgPack.pack({reward = reward, change = change}))
  852 + else
  853 + local bTeam = role:getTeamFormatByType(TeamSystemType.BonusBattle)
  854 + if not next(bTeam) then return 5 end
  855 + role.__bonusBattleCache = {
  856 + key = tostring(math.random()),
  857 + id = id,
  858 + }
  859 + SendPacket(actionCodes.Hang_startWorkBattleRpc, MsgPack.pack({key = role.__bonusBattleCache.key}))
  860 + end
  861 +
  862 + return true
  863 +end
  864 +
  865 +function _M.endWorkBattleRpc(agent, data)
  866 + local role = agent.role
  867 + local msg = MsgPack.unpack(data)
  868 + local id = msg.id
  869 + local key = msg.key
  870 + local starNum = msg.starNum
  871 + if not role.__bonusBattleCache then return 1 end
  872 +
  873 +
  874 + if role.__bonusBattleCache.id ~= id or role.__bonusBattleCache.key ~= key then
  875 + SendPacket(actionCodes.Hang_endWorkBattleRpc, MsgPack.pack({errorCode = 1}))
  876 + return true
  877 + end
  878 + role.__bonusBattleCache = nil
  879 +
  880 + -- 防作弊
  881 + if not role:checkBattleCheat("work", {
  882 + id = id,
  883 + isWin = starNum and starNum > 0,
  884 + info = msg.info
  885 + }) then
  886 + SendPacket(actionCodes.Hang_endWorkBattleRpc, MsgPack.pack({errorCode = 1}))
  887 + return true
  888 + end
  889 +
  890 + local bonusData = csvdb["work_battleCsv"][id]
  891 + local ticketId = csvdb["work_mainCsv"][bonusData.type].ticket
  892 + local reward, change = {}
  893 +
  894 + local workStar = role:getProperty("workStar")
  895 + local oldStar = workStar[id] or 0
  896 + local curStar = 0
  897 + if starNum and starNum > 0 then
  898 + -- 胜利扣除次数
  899 +
  900 + local bTeam = role:getTeamFormatByType(TeamSystemType.BonusBattle)
  901 + local herosInfo = role:getTeamHerosInfo(bTeam).heros
  902 +
  903 + local check = {}
  904 + -- 1 通关
  905 + check[1] = function(_)
  906 + return true
  907 + end
  908 + -- 2 阵亡人数 <= N
  909 + check[2] = function(_, cond)
  910 + return msg.info.dead and msg.info.dead <= cond
  911 + end
  912 + -- 3 全员存活
  913 + check[3] = function(_)
  914 + return msg.info.dead and msg.info.dead == 0
  915 + end
  916 + -- 4 指定种族 >= N
  917 + check[4] = function(_, cond)
  918 + local count = 0
  919 + for _, one in pairs(herosInfo) do
  920 + local heroData = csvdb["unitCsv"][one.type]
  921 + if heroData.camp == cond then
  922 + count = count + 1
  923 + end
  924 + end
  925 + return count >= cond
  926 + end
  927 + -- 5 指定职业 >= N
  928 + check[5] = function(_, cond)
  929 + local count = 0
  930 + for _, one in pairs(herosInfo) do
  931 + local heroData = csvdb["unitCsv"][one.type]
  932 + if heroData.job == cond then
  933 + count = count + 1
  934 + end
  935 + end
  936 + return count >= cond
  937 + end
  938 + -- 6 含有指定角色
  939 + check[6] = function(_, cond)
  940 + for _, one in pairs(herosInfo) do
  941 + if one.type == cond then
  942 + return true
  943 + end
  944 + end
  945 + return false
  946 + end
  947 + -- 7 通关耗时 <= X 秒 msg.info.atime
  948 + check[7] = function(_, cond)
  949 + return msg.info.atime and msg.info.atime <= cond
  950 + end
  951 + curStar = 0
  952 + local sweepConds = bonusData.sweep_condition:toTableArray(true)
  953 + for i, cond in ipairs(sweepConds) do
  954 + if check[cond[1]] and check[cond[1]](table.unpack(cond)) then
  955 + curStar = curStar + (1 << (i - 1))
  956 + end
  957 + end
  958 + local status
  959 + local rewardType = 0
  960 + if curStar >= (1 << #sweepConds) - 1 then -- 满星
  961 + rewardType = 2
  962 + if oldStar == 0 then --通关
  963 + rewardType = 4
  964 + end
  965 + elseif oldStar == 0 then --通关
  966 + rewardType = 1
  967 + end
  968 +
  969 + if rewardType ~= 0 then
  970 + local workBattle = role:getProperty("workBattle")
  971 + workBattle[bonusData.type] = workBattle[bonusData.type] or 0
  972 + local needCount = 1 - (workBattle[bonusData.type] == 0 and 1 or 0)
  973 + if workBattle[1] == 0 then
  974 + workBattle[1] = 1
  975 + role:updateProperty({field = "workBattle", value = workBattle})
  976 + end
  977 + if needCount > 0 then
  978 + role:costItems({[ticketId] = needCount}, {log = {desc = "workBattle", int1 = id}})
  979 + end
  980 + redisproxy:hincrby(WORK_BATTLE_COUNT, role:getTimeResetRound(TimeReset["WorkBattle" .. bonusData.type]) * 10 + bonusData.type, 1)
  981 + reward, change = workWinReward(role, bonusData, rewardType)
  982 + end
  983 + else
  984 + curStar = oldStar
  985 + end
  986 + if curStar ~= oldStar then
  987 + workStar[id] = curStar
  988 + role:updateProperty({field = "workStar", value = workStar})
  989 + end
  990 +
  991 + role:checkBattle("work", {
  992 + id = id,
  993 + isWin = starNum and starNum > 0,
  994 + info = msg.info,
  995 + reward = reward,
  996 + })
  997 + role:mylog("hang_action", {desc = "workBattle", short1 = msg.starNum > 0 and 1 or 0, int1 = id})
  998 +
  999 + SendPacket(actionCodes.Hang_endWorkBattleRpc, MsgPack.pack({
  1000 + starNum = starNum,
  1001 + reward = reward,
  1002 + change = change
  1003 + }))
  1004 + return true
  1005 +end
  1006 +
753 function _M.hangGiftRpc(agent, data) 1007 function _M.hangGiftRpc(agent, data)
754 local role = agent.role 1008 local role = agent.role
755 local msg = MsgPack.unpack(data) 1009 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
@@ -7,12 +7,13 @@ function _M.rechargeRpc(agent , data) @@ -7,12 +7,13 @@ function _M.rechargeRpc(agent , data)
7 local role = agent.role 7 local role = agent.role
8 local msg = MsgPack.unpack(data) 8 local msg = MsgPack.unpack(data)
9 local id = msg.id 9 local id = msg.id
  10 + local choose = msg.choose or ""
10 local dataSet = csvdb["shop_rechargeCsv"][id] 11 local dataSet = csvdb["shop_rechargeCsv"][id]
11 if not dataSet then return end 12 if not dataSet then return end
12 local roleId = role:getProperty("id") 13 local roleId = role:getProperty("id")
13 14
14 --创建订单号 15 --创建订单号
15 - local partnerOrderId = role:getPurchaseOrder(id) 16 + local partnerOrderId = role:getPurchaseOrder(id,nil,choose)
16 if partnerOrderId == "" then 17 if partnerOrderId == "" then
17 return 1 18 return 1
18 end 19 end
@@ -58,13 +59,14 @@ function _M.googleRechargeRpc(agent, data) @@ -58,13 +59,14 @@ function _M.googleRechargeRpc(agent, data)
58 local role = agent.role 59 local role = agent.role
59 local msg = MsgPack.unpack(data) 60 local msg = MsgPack.unpack(data)
60 local id = msg.id 61 local id = msg.id
  62 + local choose = msg.choose or ""
61 local dataSet = csvdb["shop_rechargeCsv"][id] 63 local dataSet = csvdb["shop_rechargeCsv"][id]
62 if not dataSet then return end 64 if not dataSet then return end
63 local roleId = role:getProperty("id") 65 local roleId = role:getProperty("id")
64 66
65 role.ignoreHeartbeat = true 67 role.ignoreHeartbeat = true
66 --创建订单号 68 --创建订单号
67 - local partnerOrderId = role:getPurchaseOrder(id) 69 + local partnerOrderId = role:getPurchaseOrder(id,nil,choose)
68 -- 签名 70 -- 签名
69 local secret_key = "b7657fa7ccd44c16a35e3f454ac7a075" 71 local secret_key = "b7657fa7ccd44c16a35e3f454ac7a075"
70 local need = { 72 local need = {
@@ -85,13 +87,14 @@ function _M.myCardRechargeRpc(agent, data) @@ -85,13 +87,14 @@ function _M.myCardRechargeRpc(agent, data)
85 local role = agent.role 87 local role = agent.role
86 local msg = MsgPack.unpack(data) 88 local msg = MsgPack.unpack(data)
87 local id = msg.id 89 local id = msg.id
  90 + local choose = msg.choose or ""
88 local dataSet = csvdb["shop_rechargeCsv"][id] 91 local dataSet = csvdb["shop_rechargeCsv"][id]
89 if not dataSet then return end 92 if not dataSet then return end
90 local roleId = role:getProperty("id") 93 local roleId = role:getProperty("id")
91 94
92 role.ignoreHeartbeat = true 95 role.ignoreHeartbeat = true
93 --创建订单号 96 --创建订单号
94 - local partnerOrderId = role:getPurchaseOrder(id) 97 + local partnerOrderId = role:getPurchaseOrder(id,nil,choose)
95 -- 签名 98 -- 签名
96 local secret_key = "48759e07540f46d9af17ec82669b4272" 99 local secret_key = "48759e07540f46d9af17ec82669b4272"
97 local need = { 100 local need = {
@@ -111,13 +114,14 @@ function _M.iosRechargeRpc(agent, data) @@ -111,13 +114,14 @@ function _M.iosRechargeRpc(agent, data)
111 local role = agent.role 114 local role = agent.role
112 local msg = MsgPack.unpack(data) 115 local msg = MsgPack.unpack(data)
113 local id = msg.id 116 local id = msg.id
  117 + local choose = msg.choose or ""
114 local dataSet = csvdb["shop_rechargeCsv"][id] 118 local dataSet = csvdb["shop_rechargeCsv"][id]
115 if not dataSet then return end 119 if not dataSet then return end
116 local roleId = role:getProperty("id") 120 local roleId = role:getProperty("id")
117 121
118 role.ignoreHeartbeat = true 122 role.ignoreHeartbeat = true
119 --创建订单号 123 --创建订单号
120 - local partnerOrderId = role:getPurchaseOrder(id) 124 + local partnerOrderId = role:getPurchaseOrder(id,nil,choose)
121 -- 签名 125 -- 签名
122 local secret_key = "9647d2efe1074c73b9ac19af4337a70e" 126 local secret_key = "9647d2efe1074c73b9ac19af4337a70e"
123 local need = { 127 local need = {
src/models/Order.lua
@@ -12,6 +12,7 @@ Order.schema = { @@ -12,6 +12,7 @@ Order.schema = {
12 createTime = {"number", skynet.timex()}, -- 订单创建时间 12 createTime = {"number", skynet.timex()}, -- 订单创建时间
13 finishTime = {"number", 0}, -- 服务端验证完成时间 13 finishTime = {"number", 0}, -- 服务端验证完成时间
14 status = {"string", "create"}, 14 status = {"string", "create"},
  15 + choose = {"string", ""}, -- 自选奖励
15 } 16 }
16 17
17 Order.fields = { 18 Order.fields = {
@@ -21,6 +22,7 @@ Order.fields = { @@ -21,6 +22,7 @@ Order.fields = {
21 createTime = true, 22 createTime = true,
22 finishTime = true, 23 finishTime = true,
23 status = true, 24 status = true,
  25 + choose = true,
24 } 26 }
25 27
26 return Order 28 return Order
27 \ No newline at end of file 29 \ No newline at end of file
src/models/Role.lua
@@ -119,6 +119,8 @@ Role.schema = { @@ -119,6 +119,8 @@ Role.schema = {
119 towerTeams = {"table", {}}, -- 四个电波塔的队伍 119 towerTeams = {"table", {}}, -- 四个电波塔的队伍
120 120
121 bonusStar = {"table", {}}, -- 奖励关卡 通关星星 {[id] = 1} 三个二进制位 表示三个星 从低到高 (1 << 0) (1 << 1) (1 << 2) 满星 (1 << 3) - 1 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 newerGuide = {"string","1=1"}, -- 新手引导 master=slave 126 newerGuide = {"string","1=1"}, -- 新手引导 master=slave
@@ -378,6 +380,8 @@ function Role:data() @@ -378,6 +380,8 @@ function Role:data()
378 towerTeams = self:getProperty("towerTeams"), 380 towerTeams = self:getProperty("towerTeams"),
379 381
380 bonusStar = self:getProperty("bonusStar"), 382 bonusStar = self:getProperty("bonusStar"),
  383 + workStar = self:getProperty("workStar"),
  384 + workBattle = self:getProperty("workBattle"),
381 385
382 newerGuide = self:getProperty("newerGuide"), 386 newerGuide = self:getProperty("newerGuide"),
383 funcGuide = self:getProperty("funcGuide"), 387 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
@@ -72,6 +72,8 @@ local ItemReason = { @@ -72,6 +72,8 @@ local ItemReason = {
72 towerBattle = 310, -- 电波塔战斗 72 towerBattle = 310, -- 电波塔战斗
73 advOver = 311, -- 冒险结算 73 advOver = 311, -- 冒险结算
74 advUnlock = 312, -- 拾荒解锁 74 advUnlock = 312, -- 拾荒解锁
  75 + workBattle = 313, -- workBattle夜间打工
  76 + workReward = 314, -- workBattle夜间打工 阶段奖励
75 77
76 dinerFinishTask = 401, -- 餐厅完成任务 78 dinerFinishTask = 401, -- 餐厅完成任务
77 storybookReward = 402, -- 剧情奖励 79 storybookReward = 402, -- 剧情奖励
src/models/RolePlugin.lua
@@ -1340,8 +1340,7 @@ function RolePlugin.bind(Role) @@ -1340,8 +1340,7 @@ function RolePlugin.bind(Role)
1340 local donate = seaport.donate or {} 1340 local donate = seaport.donate or {}
1341 if not reset and (not donate[1] or not donate[2]) then 1341 if not reset and (not donate[1] or not donate[2]) then
1342 local result = self:getSeaportServerProgress() 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 local done = true 1344 local done = true
1346 for id, data in ipairs(set) do 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[id] or not result[idx] or not result[idx][id] or result[idx][id] < data.need_num then
@@ -1351,7 +1350,12 @@ function RolePlugin.bind(Role) @@ -1351,7 +1350,12 @@ function RolePlugin.bind(Role)
1351 end 1350 end
1352 if done then 1351 if done then
1353 update = true 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 donate[idx] = 1 1359 donate[idx] = 1
1356 end 1360 end
1357 end 1361 end
@@ -1388,6 +1392,8 @@ function RolePlugin.bind(Role) @@ -1388,6 +1392,8 @@ function RolePlugin.bind(Role)
1388 local expCarbonId = self:getProperty("hangInfo").expCarbonId 1392 local expCarbonId = self:getProperty("hangInfo").expCarbonId
1389 local taskCsv = csvdb["seaport_taskCsv"] 1393 local taskCsv = csvdb["seaport_taskCsv"]
1390 local endTime = openTime0 + 86400 * 2 1394 local endTime = openTime0 + 86400 * 2
  1395 + local reward = {}
  1396 +
1391 for slot, set in pairs(taskCsv) do 1397 for slot, set in pairs(taskCsv) do
1392 if collect[slot] then 1398 if collect[slot] then
1393 update = true 1399 update = true
@@ -1424,9 +1430,28 @@ function RolePlugin.bind(Role) @@ -1424,9 +1430,28 @@ function RolePlugin.bind(Role)
1424 itemReward[key] = math.ceil(1.5 * value) 1430 itemReward[key] = math.ceil(1.5 * value)
1425 end 1431 end
1426 end 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 end 1447 end
  1448 + rewardStr = rewardStr .. string.format("%s=%s",itemId,value)
1429 end 1449 end
  1450 + redisproxy:insertEmail({
  1451 + roleId = self:getProperty("id"),
  1452 + emailId = 363,
  1453 + attachments = rewardStr,
  1454 + })
1430 end 1455 end
1431 end 1456 end
1432 seaport.collect = {} 1457 seaport.collect = {}
@@ -2013,7 +2038,7 @@ function RolePlugin.bind(Role) @@ -2013,7 +2038,7 @@ function RolePlugin.bind(Role)
2013 return "error money" 2038 return "error money"
2014 end 2039 end
2015 -- 发现需要的id 2040 -- 发现需要的id
2016 - local partnerOrderId = self:getPurchaseOrder(k, params.transactionId) 2041 + local partnerOrderId = self:getPurchaseOrder(k, params.transactionId, params.choose)
2017 if partnerOrderId == "" then 2042 if partnerOrderId == "" then
2018 return "no product" 2043 return "no product"
2019 end 2044 end
@@ -2023,7 +2048,7 @@ function RolePlugin.bind(Role) @@ -2023,7 +2048,7 @@ function RolePlugin.bind(Role)
2023 end 2048 end
2024 2049
2025 -- 获取充值订单号 2050 -- 获取充值订单号
2026 - function Role:getPurchaseOrder(rechargeId, transactionId) 2051 + function Role:getPurchaseOrder(rechargeId, transactionId, choose)
2027 local roleId = self:getProperty("id") 2052 local roleId = self:getProperty("id")
2028 local rechargeData = csvdb["shop_rechargeCsv"][rechargeId] 2053 local rechargeData = csvdb["shop_rechargeCsv"][rechargeId]
2029 if not rechargeData then 2054 if not rechargeData then
@@ -2035,7 +2060,24 @@ function RolePlugin.bind(Role) @@ -2035,7 +2060,24 @@ function RolePlugin.bind(Role)
2035 if limit ~= 0 and limit <= (rechargeRecord[rechargeId] or 0) then 2060 if limit ~= 0 and limit <= (rechargeRecord[rechargeId] or 0) then
2036 return "" 2061 return ""
2037 end 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 if rechargeData.activity_id ~= 0 then 2082 if rechargeData.activity_id ~= 0 then
2041 local actCfg = csvdb["activity_ctrlCsv"][rechargeData.activity_id] 2083 local actCfg = csvdb["activity_ctrlCsv"][rechargeData.activity_id]
@@ -2061,6 +2103,7 @@ function RolePlugin.bind(Role) @@ -2061,6 +2103,7 @@ function RolePlugin.bind(Role)
2061 rechargeId = rechargeId, 2103 rechargeId = rechargeId,
2062 createTime = skynet.timex(), 2104 createTime = skynet.timex(),
2063 transactionId = transactionId, 2105 transactionId = transactionId,
  2106 + choose = choose or "",
2064 }) 2107 })
2065 order:create() 2108 order:create()
2066 -- 正在进行中的订单 缓存 2109 -- 正在进行中的订单 缓存
@@ -2128,7 +2171,7 @@ function RolePlugin.bind(Role) @@ -2128,7 +2171,7 @@ function RolePlugin.bind(Role)
2128 }) 2171 })
2129 end 2172 end
2130 2173
2131 - return true, rechargeId 2174 + return true, rechargeId, orderObject:getProperty("choose")
2132 end 2175 end
2133 2176
2134 -- 充值 -- 2177 -- 充值 --
@@ -2146,7 +2189,7 @@ function RolePlugin.bind(Role) @@ -2146,7 +2189,7 @@ function RolePlugin.bind(Role)
2146 local roleId = self:getProperty("id") 2189 local roleId = self:getProperty("id")
2147 local partnerOrderStr = params.order 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 if not status then 2193 if not status then
2151 if back == "finsh" then 2194 if back == "finsh" then
2152 -- 订单已经处理 2195 -- 订单已经处理
@@ -2168,6 +2211,7 @@ function RolePlugin.bind(Role) @@ -2168,6 +2211,7 @@ function RolePlugin.bind(Role)
2168 transactionId = params.transactionId, 2211 transactionId = params.transactionId,
2169 pay_time = params.pay_time, 2212 pay_time = params.pay_time,
2170 order = partnerOrderStr, 2213 order = partnerOrderStr,
  2214 + choose = choose,
2171 }) 2215 })
2172 2216
2173 if not status then 2217 if not status then
@@ -2215,6 +2259,17 @@ function RolePlugin.bind(Role) @@ -2215,6 +2259,17 @@ function RolePlugin.bind(Role)
2215 return 3 2259 return 3
2216 end 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 if diamondCount > 0 then 2273 if diamondCount > 0 then
2219 reward[ItemId.Diamond] = (reward[ItemId.Diamond] or 0) + diamondCount 2274 reward[ItemId.Diamond] = (reward[ItemId.Diamond] or 0) + diamondCount
2220 end 2275 end
src/models/RoleTimeReset.lua
@@ -33,6 +33,38 @@ ResetFunc[&quot;CrossDay&quot;] = function(self, notify, response, now) @@ -33,6 +33,38 @@ ResetFunc[&quot;CrossDay&quot;] = 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,67 @@ local function check_trade_seaport_status() @@ -184,6 +184,67 @@ 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 +
187 local CMD = {} 248 local CMD = {}
188 249
189 250
@@ -208,6 +269,7 @@ function CMD.start() @@ -208,6 +269,7 @@ function CMD.start()
208 check_mail_queue() 269 check_mail_queue()
209 --check_battle_act_close() 270 --check_battle_act_close()
210 check_trade_seaport_status() 271 check_trade_seaport_status()
  272 + check_trade_seaport_donate()
211 end 273 end
212 274
213 local function __init__() 275 local function __init__()