Commit c6c2b8287cce6490769706e540cf0ac8c3f5d9c0

Authored by 熊润斐
2 parents 9114aab3 6df9d5e1

Merge branch 'tr/bugfix-qa' into cn/develop

@@ -16,6 +16,7 @@ TIME_ZONE = math.floor(os.difftime(START_RESET_TIME_BASE, os.time(os.date("!*t", @@ -16,6 +16,7 @@ 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 +STRUCT_VERSION = 3 -- 数据结构版本
19 20
20 MAX_ROLE_NUM = 1000000 21 MAX_ROLE_NUM = 1000000
21 -- 属性枚举 22 -- 属性枚举
@@ -72,7 +73,7 @@ ItemType = { @@ -72,7 +73,7 @@ ItemType = {
72 EquipBase = 9, -- 基础装备 73 EquipBase = 9, -- 基础装备
73 Rune = 10, -- 符文 74 Rune = 10, -- 符文
74 Cuisine = 11, -- 料理(用于增加好感度、贩卖获得金币) 75 Cuisine = 11, -- 料理(用于增加好感度、贩卖获得金币)
75 - LunchBox = 12, -- 便当盒(料理合成,冒险系统消耗道具) 76 + Potion = 12, -- 拾荒药剂
76 TimeBox = 13, -- 时间箱(开启需要时间,随机产出道具) 77 TimeBox = 13, -- 时间箱(开启需要时间,随机产出道具)
77 AdvItem = 14, -- 冒险道具 78 AdvItem = 14, -- 冒险道具
78 FuncOpen = 15, -- 管理功能开放 79 FuncOpen = 15, -- 管理功能开放
@@ -141,7 +142,6 @@ ItemId = { @@ -141,7 +142,6 @@ ItemId = {
141 TimeReset = { 142 TimeReset = {
142 CrossDay = 1, --通用跨天 143 CrossDay = 1, --通用跨天
143 CrossWeek = 2, --通用跨周 144 CrossWeek = 2, --通用跨周
144 - CrossMonth = 1, --通用跨月 索引使用跨天,在回调方法中判断是否跨越 跨月的前置条件是跨天  
145 DinerRank = 1, -- 餐厅排行榜 145 DinerRank = 1, -- 餐厅排行榜
146 PvpRank = 2, -- pvp排行榜 146 PvpRank = 2, -- pvp排行榜
147 PvpHight = 11, --高级竞技场 147 PvpHight = 11, --高级竞技场
@@ -224,6 +224,7 @@ AdvBackEventType = { @@ -224,6 +224,7 @@ AdvBackEventType = {
224 LinkChooseOver = 26, -- 连锁事件结束 224 LinkChooseOver = 26, -- 连锁事件结束
225 BuffEffect = 27, -- buff 效果 225 BuffEffect = 27, -- buff 效果
226 PassiveEffect = 28, -- 被动 效果 226 PassiveEffect = 28, -- 被动 效果
  227 + ChooseDice = 29, -- 选择点随机效果
227 } 228 }
228 229
229 AdvScoreType = { 230 AdvScoreType = {
@@ -290,6 +291,7 @@ CardType = { @@ -290,6 +291,7 @@ CardType = {
290 BattleCard = 5, --赛季卡 291 BattleCard = 5, --赛季卡
291 PaySignCard = 6, -- 付费签到卡 292 PaySignCard = 6, -- 付费签到卡
292 BattlePassCard = 7, -- 探索指令 293 BattlePassCard = 7, -- 探索指令
  294 + ActBattleCommandCard = 8, -- 战令活动卡
293 } 295 }
294 296
295 ShopPackType = { 297 ShopPackType = {
@@ -324,6 +326,7 @@ MailId = { @@ -324,6 +326,7 @@ MailId = {
324 PayBackAward = 242, 326 PayBackAward = 242,
325 CBBackAward = 243, 327 CBBackAward = 243,
326 CBBackAward2 = 244, 328 CBBackAward2 = 244,
  329 + ActivityPoolRet = 280,
327 } 330 }
328 331
329 TriggerEventType = { 332 TriggerEventType = {
src/ProtocolCode.lua
@@ -232,6 +232,13 @@ actionCodes = { @@ -232,6 +232,13 @@ actionCodes = {
232 Activity_battleMilestoneRpc = 663, 232 Activity_battleMilestoneRpc = 663,
233 Activity_bossRewardRpc = 664, 233 Activity_bossRewardRpc = 664,
234 Activity_crisisMilestoneRpc = 665, 234 Activity_crisisMilestoneRpc = 665,
  235 + Activity_commonSignRpc = 666,
  236 + Activity_friendHelpRpc = 667,
  237 + Activity_battleCommandRpc = 668,
  238 + Activity_actBattleCommandTaskRpc = 669,
  239 + Activity_newSignRpc = 670,
  240 + Activity_advLevelRpc = 671,
  241 + Activity_buyBattleCommandLvlRpc = 672,
235 242
236 Radio_startQuestRpc = 700, 243 Radio_startQuestRpc = 700,
237 Radio_finishQuestRpc = 701, 244 Radio_finishQuestRpc = 701,
@@ -249,4 +256,4 @@ for key, value in pairs(actionCodes) do @@ -249,4 +256,4 @@ for key, value in pairs(actionCodes) do
249 actionHandlers[value + rpcResponseBegin] = handlerName .. "Response" 256 actionHandlers[value + rpcResponseBegin] = handlerName .. "Response"
250 end 257 end
251 actionHandlers[value] = string.gsub(key, "_", ".") 258 actionHandlers[value] = string.gsub(key, "_", ".")
252 -end  
253 \ No newline at end of file 259 \ No newline at end of file
  260 +end
@@ -47,6 +47,7 @@ FRIEND_KEY = "role:%d:friend" --哈希表 好友 @@ -47,6 +47,7 @@ FRIEND_KEY = "role:%d:friend" --哈希表 好友
47 FRIEND_APPLY_KEY = "role:%d:apply" -- sort set 申请列表 47 FRIEND_APPLY_KEY = "role:%d:apply" -- sort set 申请列表
48 FRIEND_BLACK_KEY = "role:%d:black" -- set 黑名单 48 FRIEND_BLACK_KEY = "role:%d:black" -- set 黑名单
49 FRIEND_POINT = "role:%d:point" -- set 当天送给我心的人 49 FRIEND_POINT = "role:%d:point" -- set 当天送给我心的人
  50 +FRIEND_ENERGY = "role:%d:energy" -- set 送给我活动能量的好友
50 FRIEND_RECOMMEND = "friend:recommend" -- sort set 登录排序 获取推荐好友 51 FRIEND_RECOMMEND = "friend:recommend" -- sort set 登录排序 获取推荐好友
51 CHAT_OFFLINE = "chat:offline:%d" --消息离线缓存 52 CHAT_OFFLINE = "chat:offline:%d" --消息离线缓存
52 53
src/actions/ActivityAction.lua
@@ -259,7 +259,57 @@ function _M.actCalendaTaskRpc(agent, data) @@ -259,7 +259,57 @@ function _M.actCalendaTaskRpc(agent, data)
259 activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...} 259 activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...}
260 }) 260 })
261 261
  262 + role:checkTaskEnter("FinishSpeTask", {taskId = taskId, actId = actId})
  263 +
262 SendPacket(actionCodes.Activity_actCalendaTaskRpc, MsgPack.pack(role:packReward(reward, change))) 264 SendPacket(actionCodes.Activity_actCalendaTaskRpc, MsgPack.pack(role:packReward(reward, change)))
  265 +
  266 + return true
  267 +end
  268 +
  269 +function _M.actBattleCommandTaskRpc(agent, data)
  270 + local role = agent.role
  271 + local msg = MsgPack.unpack(data)
  272 + local taskId = msg.id
  273 + local calTask = role:getProperty("bcTask") or {}
  274 + local record = calTask["r"] or {}
  275 + local flag = record[taskId] or 0
  276 + if flag == 1 then return 1 end
  277 + local open, actId = role.activity:isOpen("BattleCommandTask")
  278 + local actData = csvdb["activity_ctrlCsv"][actId]
  279 + if not open then return 2 end
  280 + if not actData then return 3 end
  281 +
  282 + local taskList = csvdb["activity_taskCsv"][actData.condition]
  283 + if not taskList then return 4 end
  284 + local taskCfg = taskList[taskId]
  285 + if not taskCfg then return 5 end
  286 + if taskCfg.key ~= actData.condition then return 6 end
  287 +
  288 + if (calTask[taskId] or 0) < taskCfg.condition1 then return 7 end
  289 +
  290 + local open, actId = role.activity:isOpen("BattleCommand")
  291 + local actData = csvdb["activity_ctrlCsv"][actId]
  292 + if not open then return 2 end
  293 + if not actData then return 3 end
  294 +
  295 +
  296 + record[taskId] = 1
  297 + calTask["r"] = record
  298 +
  299 + role:updateProperty({field = "bcTask", value = calTask})
  300 +
  301 + local reward, change = role:award(taskCfg.reward, {log = {desc = "battleCommandTask"}})
  302 +
  303 + role:log("activity", {
  304 + activity_id = taskId, -- 活动ID(或活动指定任务的ID)
  305 + activity_type = role.activity.ActivityType.BattleCommandTask, -- 活动类型,见活动类型枚举表
  306 + activity_reward = reward, -- 活动奖励,json格式记录,{'itemid1':123,'itemid2':456,………...}
  307 + })
  308 +
  309 + role:checkTaskEnter("FinishSpeTask", {taskId = taskId, actId = actId})
  310 +
  311 + SendPacket(actionCodes.Activity_actBattleCommandTaskRpc, MsgPack.pack(role:packReward(reward, change)))
  312 +
263 return true 313 return true
264 end 314 end
265 315
@@ -511,6 +561,7 @@ function _M.startBattleRpc(agent, data) @@ -511,6 +561,7 @@ function _M.startBattleRpc(agent, data)
511 key = tostring(math.random()), 561 key = tostring(math.random()),
512 actid = actid, 562 actid = actid,
513 id = id, 563 id = id,
  564 + format = msg.format,
514 } 565 }
515 SendPacket(actionCodes.Activity_startBattleRpc, MsgPack.pack({key = role.__actBattleCache.key})) 566 SendPacket(actionCodes.Activity_startBattleRpc, MsgPack.pack({key = role.__actBattleCache.key}))
516 else 567 else
@@ -539,7 +590,7 @@ function _M.startBattleRpc(agent, data) @@ -539,7 +590,7 @@ function _M.startBattleRpc(agent, data)
539 bi["bossP"] = (bi["bossP"] or 0) + bi["maxP"] * count 590 bi["bossP"] = (bi["bossP"] or 0) + bi["maxP"] * count
540 end 591 end
541 592
542 - bi["sum"] = bi["sum"] + bi["top"] 593 + bi["sum"] = bi["sum"] + bi["top"] * count
543 actData["ticket"] = ticket - num 594 actData["ticket"] = ticket - num
544 actData[id] = bi 595 actData[id] = bi
545 changeFlag = true 596 changeFlag = true
@@ -568,7 +619,10 @@ function _M.endBattleRpc(agent, data) @@ -568,7 +619,10 @@ function _M.endBattleRpc(agent, data)
568 local isWin = msg.isWin 619 local isWin = msg.isWin
569 local heros = msg.heros 620 local heros = msg.heros
570 local support = msg.support 621 local support = msg.support
571 - if not role.activity:isOpenById(actid, "ChallengeLevel") then return 1 end 622 + if not role.activity:isOpenById(actid, "ChallengeLevel") then
  623 + SendPacket(actionCodes.Activity_endBattleRpc, MsgPack.pack({}))
  624 + return true
  625 + end
572 626
573 if not role.__actBattleCache then return 2 end 627 if not role.__actBattleCache then return 2 end
574 628
@@ -576,6 +630,18 @@ function _M.endBattleRpc(agent, data) @@ -576,6 +630,18 @@ function _M.endBattleRpc(agent, data)
576 SendPacket(actionCodes.Activity_endBattleRpc, MsgPack.pack({errorCode = 1})) 630 SendPacket(actionCodes.Activity_endBattleRpc, MsgPack.pack({errorCode = 1}))
577 end 631 end
578 632
  633 + -- 防作弊
  634 + if not role:checkBattleCheat("act_battle", {
  635 + id = id,
  636 + isWin = isWin,
  637 + info = msg.info,
  638 + format = role.__actBattleCache.format
  639 + }) then
  640 + SendPacket(actionCodes.Activity_endBattleRpc, MsgPack.pack({errorCode = 1}))
  641 + return true
  642 + end
  643 + role.__actBattleCache = nil
  644 +
579 local actCfg = csvdb["activity_battleCsv"][actid] 645 local actCfg = csvdb["activity_battleCsv"][actid]
580 if not actCfg then return 3 end 646 if not actCfg then return 3 end
581 647
@@ -889,4 +955,417 @@ function _M.bossRewardRpc(agent, data) @@ -889,4 +955,417 @@ function _M.bossRewardRpc(agent, data)
889 return true 955 return true
890 end 956 end
891 957
892 -return _M  
893 \ No newline at end of file 958 \ No newline at end of file
  959 +function _M.commonSignRpc(agent, data)
  960 + local role = agent.role
  961 + local msg = MsgPack.unpack(data)
  962 + local actid = msg.actid
  963 + local index = msg.index
  964 +
  965 + if not role.activity:isOpenById(actid, "CommonSignIn") then return 1 end
  966 +
  967 + local actData = role.activity:getActData("CommonSignIn")
  968 + if (actData[0] or 0) < index then
  969 + return 2
  970 + end
  971 + if (actData[index] or 0) == 1 then
  972 + return 3
  973 + end
  974 +
  975 + local actCfg = csvdb["activity_signInCsv"][actid]
  976 + if not actCfg then return 4 end
  977 + actCfg = actCfg[index]
  978 + if not actCfg then return 5 end
  979 +
  980 + actData[index] = 1
  981 + role.activity:updateActData("CommonSignIn", actData)
  982 +
  983 + local award = actCfg.reward:toNumMap()
  984 + local reward, change = role:award(award, {log = {desc = "commonSign", int1 = actid, int2 = index}})
  985 + SendPacket(actionCodes.Activity_commonSignRpc, MsgPack.pack(role:packReward(reward, change)))
  986 + return true
  987 +end
  988 +
  989 +function _M.friendHelpRpc(agent, data)
  990 + local role = agent.role
  991 + local roleId = role:getProperty("id")
  992 + local msg = MsgPack.unpack(data)
  993 + local oper = tonumber(msg.oper) or -1
  994 + local award = {}
  995 + local result
  996 +
  997 +
  998 + local actid = 37
  999 + if not role.activity:isOpenById(actid, "FriendEnergy") then return 1 end
  1000 + if oper < 1 or oper > 4 then return 2 end
  1001 +
  1002 + local actCsv = csvdb["activity_ctrlCsv"][actid]
  1003 + local getLimit = actCsv.condition
  1004 + local gifts = actCsv.condition2:toTableArray(true)
  1005 +
  1006 + local actData = role.activity:getActData("FriendEnergy") or {}
  1007 +
  1008 + local function getIds()
  1009 + local ids = {}
  1010 + local friends = redisproxy:hgetall(FRIEND_KEY:format(roleId))
  1011 + for i = 1, #friends , 2 do
  1012 + local objId = tonumber(friends[i])
  1013 + ids[objId] = 1
  1014 + end
  1015 + return ids
  1016 + end
  1017 +
  1018 + if oper == 1 then -- 赠送好友能量
  1019 + local giveAE = actData.giveAE or {}
  1020 + local objId = msg.roleId
  1021 + local gift = gifts[1]
  1022 + local ids = {}
  1023 +
  1024 + if not objId then
  1025 + return 3
  1026 + end
  1027 + if not redisproxy:hexists(FRIEND_KEY:format(roleId), objId) then
  1028 + result = 2
  1029 + end
  1030 + if giveAE[objId] then
  1031 + result = 1
  1032 + end
  1033 +
  1034 + if not result then
  1035 + giveAE[objId] = 1
  1036 + award[gift[1]] = gift[2]
  1037 + redisproxy:sadd(FRIEND_ENERGY:format(objId), roleId)
  1038 + rpcRole(objId, "SendPacket", actionCodes.Role_notifyNewEvent, MsgPack.pack({events = {actFriendGive = roleId}}))
  1039 + actData.giveAE = giveAE
  1040 + end
  1041 + elseif oper == 2 then -- 收取能量
  1042 + local objId = msg.roleId
  1043 + local gift = gifts[2]
  1044 + local getAE = actData.getAE or {}
  1045 + local limit = actData.limit or 0
  1046 +
  1047 + if limit >= getLimit then return 4 end
  1048 + if not redisproxy:sismember(FRIEND_ENERGY:format(roleId), objId) then
  1049 + result = 3
  1050 + end
  1051 + if getAE[objId] then
  1052 + result = 2
  1053 + end
  1054 + if limit >= getLimit then
  1055 + result = 1
  1056 + end
  1057 +
  1058 + if not result then
  1059 + limit = limit + 1
  1060 + getAE[objId] = 1
  1061 + award[gift[1]] = gift[2]
  1062 + redisproxy:srem(FRIEND_ENERGY:format(roleId), objId)
  1063 + actData.limit = limit
  1064 + actData.getAE = getAE
  1065 + end
  1066 + elseif oper == 3 then -- 一键送领全部
  1067 + local giveAE = actData.giveAE or {}
  1068 + local getAE = actData.getAE or {}
  1069 + local gift1 = gifts[1]
  1070 + local gift2 = gifts[2]
  1071 + local limit = actData.limit or 0
  1072 + local cmd1, cmd2 = 0, 0
  1073 + local ids = getIds()
  1074 +
  1075 + local members = {}
  1076 + local temp = redisproxy:smembers(FRIEND_ENERGY:format(roleId))
  1077 + for _, id in pairs(temp) do
  1078 + members[tonumber(id)] = 1
  1079 + end
  1080 +
  1081 + redisproxy:pipelining(function(red)
  1082 + for friendId, _ in pairs(ids) do
  1083 + if not giveAE[friendId] then
  1084 + giveAE[friendId] = 1
  1085 + award[gift1[1]] = (award[gift1[1]] or 0) + gift1[2]
  1086 + red:sadd(FRIEND_ENERGY:format(friendId), roleId)
  1087 + rpcRole(friendId, "SendPacket", actionCodes.Role_notifyNewEvent, MsgPack.pack({events = {actFriendGive = roleId}}))
  1088 + cmd1 = 2
  1089 + end
  1090 +
  1091 + if members[friendId] and not getAE[friendId] and limit <= getLimit then
  1092 + cmd2 = 1
  1093 + limit = limit + 1
  1094 + getAE[friendId] = 1
  1095 + award[gift2[1]] = (award[gift2[1]] or 0) + gift2[2]
  1096 + red:srem(FRIEND_ENERGY:format(roleId), friendId)
  1097 + end
  1098 + end
  1099 + end)
  1100 +
  1101 + local sum = cmd1 + cmd2
  1102 + if sum == 0 then
  1103 + result = 3
  1104 + elseif sum ~= 3 then
  1105 + result = sum
  1106 + end
  1107 +
  1108 + actData.limit = limit
  1109 + actData.giveAE = giveAE
  1110 + actData.getAE = getAE
  1111 + elseif oper == 4 then -- 抽大奖
  1112 + local magic = actData.magic or 0
  1113 + local rewards = actData.reward or {}
  1114 + local rewardCsv = csvdb["activity_orderRewardsCsv"][actid]
  1115 + local itemId1 = gifts[1][1]
  1116 + local itemId2 = gifts[2][1]
  1117 +
  1118 + local level = math.min(magic + 1,#rewardCsv)
  1119 + local rewardData = rewardCsv[level]
  1120 +
  1121 + local cost = {[itemId1] = rewardData.condition1, [itemId2] = rewardData.condition2}
  1122 +
  1123 + if not role:checkItemEnough(cost) then return 7 end
  1124 + role:costItems(cost, {log = {desc = "actFriendHelp", int1 = actid, int2 = level}})
  1125 +
  1126 + if rewardData.reward ~= "" then
  1127 + result = 1
  1128 + award = rewardData.reward:toNumMap()
  1129 + end
  1130 + if rewardData.reward_random ~= "" then
  1131 + result = 1
  1132 + local pool = {}
  1133 + for _, temp in pairs(rewardData.reward_random:toArray()) do
  1134 + table.insert(pool, temp:toArray(true, "="))
  1135 + end
  1136 + local gift = pool[math.randWeight(pool, 3)]
  1137 + award[gift[1]] = (award[gift[1]] or 0) + gift[2]
  1138 + end
  1139 + rewards[level] = 1
  1140 + actData.reward = rewards
  1141 + actData.magic = level
  1142 + else
  1143 + return 5
  1144 + end
  1145 +
  1146 + local ids = {}
  1147 + local members = {}
  1148 + local friendIds = getIds()
  1149 + local temp = redisproxy:smembers(FRIEND_ENERGY:format(roleId))
  1150 + for _, id in pairs(temp) do
  1151 + members[tonumber(id)] = 1
  1152 + end
  1153 +
  1154 + for id, _ in pairs(friendIds) do
  1155 + if members[id] then
  1156 + ids[id] = 1
  1157 + end
  1158 + end
  1159 +
  1160 + actData.new = ids
  1161 +
  1162 + local reward, change
  1163 + if next(award) then
  1164 + reward, change = role:award(award, {log = {desc = "actFriendHelp", int1 = actid}})
  1165 + end
  1166 + role.activity:updateActData("FriendEnergy", actData)
  1167 + SendPacket(actionCodes.Activity_friendHelpRpc, MsgPack.pack({result = result, reward = reward}))
  1168 + return true
  1169 +end
  1170 +
  1171 +-- 战令活动奖励
  1172 +function _M.battleCommandRpc(agent, data)
  1173 + local role = agent.role
  1174 + local msg = MsgPack.unpack(data)
  1175 + local actid = msg.actid -- 活动id
  1176 + local index = msg.index -- 领取的阶段id
  1177 + local pay = msg.pay -- 是否是超级奖励
  1178 +
  1179 + if not role.activity:isOpenById(actid, "BattleCommand") then return 1 end
  1180 + local actCtrlData = csvdb["activity_ctrlCsv"][actid]
  1181 +
  1182 + if not actCtrlData then return end
  1183 +
  1184 + local actData = role.activity:getActData("BattleCommand") or {}
  1185 + if pay and not actData["unlock"] then return 2 end
  1186 +
  1187 + local bpCfg = csvdb["activity_battlepass_rewardCsv"][actid]
  1188 + if not bpCfg then return 3 end
  1189 +
  1190 + local unlock = actData["unlock"] or 0
  1191 + local award = {}
  1192 + if not index then -- 一键领取
  1193 + for i = 1, #bpCfg do
  1194 + local cfg = bpCfg[i]
  1195 + if not cfg then return 4 end
  1196 +
  1197 + if (actData["lvl"] or 0) < cfg["type"] then break end
  1198 + local records = {{"freeR", "rewardNormal"}, {"payR", "rewardHigh"}}
  1199 +
  1200 + for _, info in ipairs(records) do
  1201 + local typeKey, rewardKey = info[1], info[2]
  1202 + if typeKey == "payR" and unlock == 0 then
  1203 + break
  1204 + end
  1205 + local record = actData[typeKey] or ""
  1206 + local flag = string.char(string.getbit(record, i))
  1207 + if flag == "0" then
  1208 + record = string.setbit(record, i)
  1209 + local awd = cfg[rewardKey]
  1210 + for k, v in pairs(awd:toNumMap()) do
  1211 + award[k] = (award[k] or 0) + v
  1212 + end
  1213 + end
  1214 + actData[typeKey] = record
  1215 +
  1216 + end
  1217 + end
  1218 + else
  1219 + bpCfg = bpCfg[index]
  1220 + if not bpCfg then return 4 end
  1221 +
  1222 + if (actData["lvl"] or 0) < bpCfg["type"] then return 5 end
  1223 +
  1224 + local record = ""
  1225 + if pay then
  1226 + record = actData["payR"] or ""
  1227 + else
  1228 + record = actData["freeR"] or ""
  1229 + end
  1230 +
  1231 + local flag = string.char(string.getbit(record, index))
  1232 +
  1233 + if flag == "1" then
  1234 + return 6
  1235 + end
  1236 +
  1237 + record = string.setbit(record, index)
  1238 + local awd = ""
  1239 + if pay then
  1240 + actData["payR"] = record
  1241 + awd = bpCfg["rewardHigh"]
  1242 + else
  1243 + actData["freeR"] = record
  1244 + awd = bpCfg["rewardNormal"]
  1245 + end
  1246 + for k, v in pairs(awd:toNumMap()) do
  1247 + award[k] = (award[k] or 0) + v
  1248 + end
  1249 + end
  1250 +
  1251 + role.activity:updateActData("BattleCommand", actData)
  1252 +
  1253 + local reward, change = role:award(award, {log = {desc = "actBattleCommand", int1 = actid, int2 = index}})
  1254 +
  1255 + SendPacket(actionCodes.Activity_battleCommandRpc, MsgPack.pack(role:packReward(reward, change)))
  1256 + return true
  1257 +end
  1258 +
  1259 +function _M.buyBattleCommandLvlRpc(agent, data)
  1260 + local role = agent.role
  1261 + local msg = MsgPack.unpack(data)
  1262 + local actid = msg.actid -- 活动id
  1263 + local count = msg.count
  1264 +
  1265 + if not role.activity:isOpenById(actid, "BattleCommand") then return 1 end
  1266 + local actCtrlData = csvdb["activity_ctrlCsv"][actid]
  1267 +
  1268 + if not actCtrlData then return 2 end
  1269 +
  1270 + local bpCfg = csvdb["activity_battlepass_rewardCsv"][actid]
  1271 + if not bpCfg then return 3 end
  1272 +
  1273 + local actData = role.activity:getActData("BattleCommand") or {}
  1274 +
  1275 + local curLvl = actData["lvl"] or 0
  1276 + local nextLvl = curLvl + count
  1277 + if curLvl >= bpCfg[#bpCfg]["type"] then return 4 end
  1278 + local cost = 0
  1279 + for i = 1, #bpCfg do
  1280 + local cfg = bpCfg[i]
  1281 + if cfg["type"] > curLvl and cfg["type"] <= nextLvl then
  1282 + cost = cost + cfg["cost"]
  1283 + elseif cfg["type"] > nextLvl then
  1284 + break
  1285 + end
  1286 + end
  1287 + if cost == 0 then return 5 end
  1288 +
  1289 + if not role:checkItemEnough({[ItemId.Diamond] = cost}) then return 6 end
  1290 + role:costItems({[ItemId.Diamond] = cost}, {log = {desc = "actBuyBpLevel", int1 = curLvl}})
  1291 + actData["lvl"] = nextLvl
  1292 + role.activity:updateActData("BattleCommand", actData)
  1293 +
  1294 + SendPacket(actionCodes.Activity_buyBattleCommandLvlRpc, MsgPack.pack({}))
  1295 + return true
  1296 +end
  1297 +
  1298 +function _M.newSignRpc(agent, data)
  1299 + local role = agent.role
  1300 + local msg = MsgPack.unpack(data)
  1301 +
  1302 + local open, actId = role.activity:isOpen("NewSign")
  1303 + if not open then return 1 end
  1304 +
  1305 + local actData = role.activity:getActData("NewSign")
  1306 + if actData[actData[0] or 0] then
  1307 + return 2
  1308 + end
  1309 +
  1310 + local actCfg = csvdb["activity_signInCsv"][actId]
  1311 + if not actCfg then return 4 end
  1312 +
  1313 + local sumDay = actData[0] or 0
  1314 + local award = {}
  1315 + for k, data in pairs(actCfg) do
  1316 + if not actData[data.day] and data.day <= sumDay then
  1317 + for id, value in pairs(data.reward:toNumMap()) do
  1318 + award[id] = (award[id] or 0) + value
  1319 + end
  1320 + actData[data.day] = 1
  1321 + end
  1322 + end
  1323 +
  1324 + local reward, change
  1325 + if next(award) then
  1326 + role.activity:updateActData("NewSign", actData)
  1327 + reward, change = role:award(award, {log = {desc = "newSign", int1 = actId, int2 = sumDay}})
  1328 + end
  1329 +
  1330 + SendPacket(actionCodes.Activity_newSignRpc, MsgPack.pack(role:packReward(reward, change)))
  1331 + return true
  1332 +end
  1333 +
  1334 +-- 活动拾荒领取阶段奖励
  1335 +function _M.advLevelRpc(agent, data)
  1336 + local role = agent.role
  1337 + local msg = MsgPack.unpack(data)
  1338 + local actid = msg.actid
  1339 + local index = msg.index
  1340 +
  1341 + if not role.activity:isOpenById(actid, "AdvLevel") then return 1 end
  1342 +
  1343 + local actCfg = csvdb["activity_stagesAwardCsv"][actid]
  1344 + if not actCfg then return 2 end
  1345 + actCfg = actCfg[index]
  1346 + if not actCfg then return 3 end
  1347 +
  1348 + local actData = role.activity:getActData("AdvLevel") or {}
  1349 + local record = actData["r"] or ""
  1350 + local flag = string.char(string.getbit(record, index))
  1351 +
  1352 + if flag == "1" then return 4 end
  1353 +
  1354 + local chapters = actCfg["condition2"]:toArray(true, "=")
  1355 + local totalVal = 0
  1356 + for i = 1, #chapters do
  1357 + local cid = chapters[i]
  1358 + local info = actData[cid] or {}
  1359 + totalVal = totalVal + (info["max"] or 0)
  1360 + end
  1361 + if totalVal < actCfg["condition1"] then return 5 end
  1362 +
  1363 + actData["r"] = string.setbit(record, index)
  1364 + role.activity:updateActData("AdvLevel", actData)
  1365 +
  1366 + local reward, change = role:award(actCfg.reward, {log = {desc = "advLevelStage", int1 = actid, int2 = index}})
  1367 +
  1368 + SendPacket(actionCodes.Activity_advLevelRpc, MsgPack.pack(role:packReward(reward, change)))
  1369 + return true
  1370 +end
  1371 +
  1372 +return _M
src/actions/AdvAction.lua
@@ -57,6 +57,15 @@ local function checkFormat(role, format, checkAdvTeam) @@ -57,6 +57,15 @@ local function checkFormat(role, format, checkAdvTeam)
57 end 57 end
58 end 58 end
59 59
  60 + -- 多队挂机 电台任务英雄也不能重用
  61 + local radioTask = role:getProperty("radioTask")
  62 + for id, taskInfo in pairs(radioTask) do
  63 + local heros = taskInfo["heros"] or {}
  64 + for _, heroId in ipairs(heros) do
  65 + hadHero[heroId] = true
  66 + end
  67 + end
  68 +
60 if not format.leader then return end 69 if not format.leader then return end
61 if format.leader2 == format.leader then return end 70 if format.leader2 == format.leader then return end
62 local hadLeader = false 71 local hadLeader = false
@@ -86,22 +95,58 @@ function _M.startAdvRpc( agent, data ) @@ -86,22 +95,58 @@ function _M.startAdvRpc( agent, data )
86 local role = agent.role 95 local role = agent.role
87 local msg = MsgPack.unpack(data) 96 local msg = MsgPack.unpack(data)
88 local chapterId = msg.chapterId --关卡id 97 local chapterId = msg.chapterId --关卡id
  98 + local actid = msg.actid --活动id
89 local layer = msg.layer or 1 --选择层数 99 local layer = msg.layer or 1 --选择层数
90 --local format = msg.format --编队 100 --local format = msg.format --编队
91 local supportIdx = msg.supportIdx --选择的支援效果 101 local supportIdx = msg.supportIdx --选择的支援效果
92 if not role:isFuncUnlock(FuncUnlock.Adv) then return end 102 if not role:isFuncUnlock(FuncUnlock.Adv) then return end
93 - 103 +
94 --上一个关卡结束才可以开始新的关卡 104 --上一个关卡结束才可以开始新的关卡
95 if role:getAdvData():isRunning() then return 8 end 105 if role:getAdvData():isRunning() then return 8 end
96 local advHang = role:getProperty("advHang") 106 local advHang = role:getProperty("advHang")
97 -- if advHang[chapterId] then return 9 end --正在挂机 107 -- if advHang[chapterId] then return 9 end --正在挂机
98 108
  109 + -- 检查活动正确性
  110 + if actid then
  111 + if not role.activity:isOpenById(actid, "AdvLevel") then
  112 + return 20
  113 + end
  114 + local actCfg = csvdb["activity_adv_chapterCsv"][actid]
  115 + if not actCfg then return 21 end
  116 + actCfg = actCfg[chapterId]
  117 + if not actCfg then return 22 end
  118 +
  119 + if actCfg["unlockTime"] ~= 0 then
  120 + local st = toUnixtime(actCfg["unlockTime"]..string_format("%02x", RESET_TIME))
  121 + if st > skynet.timex() then return 23 end
  122 + end
  123 +
  124 + if actCfg["prepose"] ~= "" then
  125 + local type, cid = actCfg["prepose"]:toArray(true, "=")
  126 + if type == 1 then
  127 + local actData = role.activity:getActData("ChallengeLevel")
  128 + local battleInfo = actData[cid] or {}
  129 + if (battleInfo["star"] or 0) == 0 then
  130 + return 24
  131 + end
  132 + elseif type == 2 then
  133 + local actData = role.activity:getActData("AdvLevel")
  134 + local advInfo = actData[cid] or {}
  135 + if not advInfo["pass"] then
  136 + return 25
  137 + end
  138 + end
  139 + end
  140 + end
99 141
100 local chapterData = csvdb["adv_chapterCsv"][chapterId] 142 local chapterData = csvdb["adv_chapterCsv"][chapterId]
101 if not chapterData or layer < 1 then return 1 end 143 if not chapterData or layer < 1 then return 1 end
102 144
103 local advPass = role:getProperty("advPass") 145 local advPass = role:getProperty("advPass")
104 146
  147 + if not checkFormat(role) then return 7 end
  148 +
  149 + local cost = 0
105 if AdvCommon.isEndless(chapterId) then -- 无尽模式判断 150 if AdvCommon.isEndless(chapterId) then -- 无尽模式判断
106 151
107 if chapterId ~= role.advElChapter then return end -- 不是当前进行的章节 152 if chapterId ~= role.advElChapter then return end -- 不是当前进行的章节
@@ -118,37 +163,27 @@ function _M.startAdvRpc( agent, data ) @@ -118,37 +163,27 @@ function _M.startAdvRpc( agent, data )
118 if not relayData then return 14 end -- 不是中继层 163 if not relayData then return 14 end -- 不是中继层
119 if advElM < relayData.unlockfloor then return 15 end --未解锁 164 if advElM < relayData.unlockfloor then return 15 end --未解锁
120 end 165 end
  166 +
  167 + role.dailyData:updateProperty({field = "advElC", delta = 1})
  168 + cost = 1
121 else -- 普通模式判断 169 else -- 普通模式判断
122 - if not role:checkAdvCount(chapterData.limitlevel) then return 2 end -- 是否有体力  
123 if layer >= chapterData.limitlevel then return 4 end 170 if layer >= chapterData.limitlevel then return 4 end
124 - -- 关卡开放判断  
125 - if not role:advChapterIsOpen(chapterId) then return 5 end  
126 171
  172 + local relayData = role:getAdvData():isHaveRelay(layer, chapterId, true)
  173 + if not relayData then return 6 end -- 不是中继层
127 if layer ~= 1 then 174 if layer ~= 1 then
128 - local relayData = role:getAdvData():isHaveRelay(layer, chapterId)  
129 - if not relayData then return 6 end -- 不是中继层  
130 - if (advPass[chapterId] or 0) < relayData.floor then return 21 end 175 + local advRelay = role:getProperty("advRelay")
  176 + if not (advRelay[chapterId] or {})[layer] then return 21 end -- 没有开放
131 end 177 end
132 - end  
133 -  
134 - if not checkFormat(role) then return 7 end  
135 -  
136 - --local advTeam = role:getProperty("advTeam")  
137 - --table.clear(advTeam) 178 + if not role:checkAdvCount(relayData.supply) then return 2 end -- 是否有体力
  179 + -- 关卡开放判断
  180 + if not role:advChapterIsOpen(chapterId) then return 5 end
138 181
139 - --advTeam.heros = {}  
140 - --for slot, heroId in pairs(format.heros) do  
141 - -- advTeam.heros[slot] = heroId  
142 - --end  
143 - --advTeam.leader = format.leader  
144 - --advTeam.leader2 = format.leader2  
145 - --role:updateProperty({field = "advTeam", value = advTeam})  
146 - if AdvCommon.isEndless(chapterId) then  
147 - role.dailyData:updateProperty({field = "advElC", delta = 1})  
148 - else  
149 - role:changeAdvCount(chapterData.limitlevel) 182 + role:changeAdvCount(relayData.supply)
  183 + cost = relayData.supply
150 end 184 end
151 - 185 + role:checkTaskEnter("AdvCostPower", {count = cost})
  186 +
152 local support = {} -- 支援效果 187 local support = {} -- 支援效果
153 if AdvCommon.isEndless(chapterId) then 188 if AdvCommon.isEndless(chapterId) then
154 -- 选择的支援效果 189 -- 选择的支援效果
@@ -168,13 +203,16 @@ function _M.startAdvRpc( agent, data ) @@ -168,13 +203,16 @@ function _M.startAdvRpc( agent, data )
168 end 203 end
169 end 204 end
170 end 205 end
  206 +
171 role:getAdvData():initByChapter({ 207 role:getAdvData():initByChapter({
172 chapterId = chapterId, 208 chapterId = chapterId,
173 level = layer, 209 level = layer,
174 isRelay = layer ~= 1, 210 isRelay = layer ~= 1,
175 isEnter = true, 211 isEnter = true,
176 support = support, 212 support = support,
  213 + actid = actid
177 }) 214 })
  215 +
178 role:checkTaskEnter("AdvStart", {id = chapterId}) 216 role:checkTaskEnter("AdvStart", {id = chapterId})
179 role:checkTaskEnter("AdvStartSelf", {id = chapterId}) 217 role:checkTaskEnter("AdvStartSelf", {id = chapterId})
180 role:getAdvData():popBackEvents() -- 清一下事件 218 role:getAdvData():popBackEvents() -- 清一下事件
@@ -191,8 +229,42 @@ function _M.startHangRpc(agent, data) @@ -191,8 +229,42 @@ function _M.startHangRpc(agent, data)
191 local campId = msg.campId or 2 --营地id 229 local campId = msg.campId or 2 --营地id
192 local format = msg.format --编队 230 local format = msg.format --编队
193 local index = msg.index or 1--时间索引id 231 local index = msg.index or 1--时间索引id
  232 + local actid = msg.actid
194 233
195 - local chapterData = csvdb["adv_chapter_campsiteCsv"][chapterId] 234 + -- 检查活动正确性
  235 + if actid then
  236 + if not role.activity:isOpenById(actid, "AdvLevel") then
  237 + return 20
  238 + end
  239 + local actCfg = csvdb["activity_adv_chapterCsv"][actid]
  240 + if not actCfg then return 21 end
  241 + actCfg = actCfg[chapterId]
  242 + if not actCfg then return 22 end
  243 +
  244 + if actCfg["unlockTime"] ~= 0 then
  245 + local st = toUnixtime(actCfg["unlockTime"]..string_format("%02x", RESET_TIME))
  246 + if st > skynet.timex() then return 23 end
  247 + end
  248 +
  249 + if actCfg["prepose"] ~= "" then
  250 + local type, cid = actCfg["prepose"]:toArray(true, "=")
  251 + if type == 1 then
  252 + local actData = role.activity:getActData("ChallengeLevel")
  253 + local battleInfo = actData[cid] or {}
  254 + if (battleInfo["star"] or 0) == 0 then
  255 + return 24
  256 + end
  257 + elseif type == 2 then
  258 + local actData = role.activity:getActData("AdvLevel")
  259 + local advInfo = actData[cid] or {}
  260 + if not advInfo["pass"] then
  261 + return 25
  262 + end
  263 + end
  264 + end
  265 + end
  266 +
  267 + local chapterData = csvdb["adv_chapter_campsiteCsv"][chapterId]
196 if not chapterData then return 1 end 268 if not chapterData then return 1 end
197 local campSiteData = chapterData[campId] 269 local campSiteData = chapterData[campId]
198 if not campSiteData then return 1 end 270 if not campSiteData then return 1 end
@@ -214,11 +286,13 @@ function _M.startHangRpc(agent, data) @@ -214,11 +286,13 @@ function _M.startHangRpc(agent, data)
214 if AdvCommon.isEndless(chapterId) then return 5 end -- 无尽没有代理 286 if AdvCommon.isEndless(chapterId) then return 5 end -- 无尽没有代理
215 287
216 local advRelay = role:getProperty("advRelay") 288 local advRelay = role:getProperty("advRelay")
217 - if not next(advRelay[chapterId] or {}) then return 6 end -- 没有开放 289 + if not (advRelay[chapterId] or {})[campSiteData.floor] then return 6 end -- 没有开放
218 290
219 291
220 if not role:checkAdvCount(adv_idle_energy) then return 7 end -- 是否有体力 292 if not role:checkAdvCount(adv_idle_energy) then return 7 end -- 是否有体力
221 293
  294 + role:checkTaskEnter("AdvCostPower", {count = adv_idle_energy})
  295 +
222 if not checkFormat(role, format, role:getAdvData():isRunning()) then return 8 end --编队是否正确 296 if not checkFormat(role, format, role:getAdvData():isRunning()) then return 8 end --编队是否正确
223 297
224 local player = {} 298 local player = {}
@@ -236,7 +310,8 @@ function _M.startHangRpc(agent, data) @@ -236,7 +310,8 @@ function _M.startHangRpc(agent, data)
236 + 0.226 * player["hit"] 310 + 0.226 * player["hit"]
237 + 0.26 * player["miss"] 311 + 0.26 * player["miss"]
238 312
239 - if battleV < campSiteData.idleValue then return 9 end -- 战斗力是否满足 313 + --print(math.ceil(battleV), campSiteData.idleValue)
  314 + if math.ceil(battleV) < campSiteData.idleValue then return 9 end -- 战斗力是否满足
240 315
241 local info = {} 316 local info = {}
242 info.format = {} 317 info.format = {}
@@ -344,6 +419,7 @@ function _M.endHangRpc(agent, data) @@ -344,6 +419,7 @@ function _M.endHangRpc(agent, data)
344 adv_idle_time = adv_idle_time * 60 419 adv_idle_time = adv_idle_time * 60
345 420
346 local reward, isFull, change, heroFaithMap 421 local reward, isFull, change, heroFaithMap
  422 + local heroCnt = 0
347 if skynet.timex() >= info.time then 423 if skynet.timex() >= info.time then
348 -- 最新需求加成取消 424 -- 最新需求加成取消
349 --[[ 425 --[[
@@ -378,6 +454,7 @@ function _M.endHangRpc(agent, data) @@ -378,6 +454,7 @@ function _M.endHangRpc(agent, data)
378 for _, heroId in pairs(info.format.heros) do 454 for _, heroId in pairs(info.format.heros) do
379 local curFaith = addHeroFaith(role, heroId, exp) 455 local curFaith = addHeroFaith(role, heroId, exp)
380 heroFaithMap[heroId] = curFaith 456 heroFaithMap[heroId] = curFaith
  457 + heroCnt = heroCnt + 1
381 end 458 end
382 459
383 local totalReward = campSiteData.idleReward_1 .. " " .. campSiteData.idleReward_2 460 local totalReward = campSiteData.idleReward_1 .. " " .. campSiteData.idleReward_2
@@ -406,6 +483,7 @@ function _M.endHangRpc(agent, data) @@ -406,6 +483,7 @@ function _M.endHangRpc(agent, data)
406 role:mylog("adv_action", {desc = "endHang", int1 = chapterId, short1 = cancel and 1 or 0}) 483 role:mylog("adv_action", {desc = "endHang", int1 = chapterId, short1 = cancel and 1 or 0})
407 484
408 role:checkTaskEnter("AdvHang", {}) 485 role:checkTaskEnter("AdvHang", {})
  486 + role:checkTaskEnter("AdvHangHeroCnt", {count = heroCnt})
409 487
410 SendPacket(actionCodes.Adv_endHangRpc, MsgPack.pack({reward = reward, change = change, isFull = isFull, heroFaith = heroFaithMap})) 488 SendPacket(actionCodes.Adv_endHangRpc, MsgPack.pack({reward = reward, change = change, isFull = isFull, heroFaith = heroFaithMap}))
411 return true 489 return true
@@ -543,8 +621,8 @@ function _M.usePotionRpc(agent, data) @@ -543,8 +621,8 @@ function _M.usePotionRpc(agent, data)
543 local msg = MsgPack.unpack(data) 621 local msg = MsgPack.unpack(data)
544 local potionId = msg.potionId -- 营养剂Id 622 local potionId = msg.potionId -- 营养剂Id
545 local target = msg.target -- {roomId = 1, blockId = 1} 选择的目标 623 local target = msg.target -- {roomId = 1, blockId = 1} 选择的目标
546 - local potionLv = role.dinerData:getProperty("dishTree"):getv(potionId, 0)  
547 - if potionLv == 0 then return 1 end 624 + local potionLv = role.dinerData:getProperty("dishTree"):getv(potionId, 1)
  625 + if potionLv < 1 then return 1 end
548 626
549 local potionSet = csvdb["adv_potionCsv"][potionId] 627 local potionSet = csvdb["adv_potionCsv"][potionId]
550 if not potionSet then return 2 end 628 if not potionSet then return 2 end
@@ -552,12 +630,9 @@ function _M.usePotionRpc(agent, data) @@ -552,12 +630,9 @@ function _M.usePotionRpc(agent, data)
552 local potionData = potionSet[potionLv] 630 local potionData = potionSet[potionLv]
553 if not potionData then return 3 end 631 if not potionData then return 3 end
554 632
555 - local potionBag = role:getProperty("potionBag")  
556 - local own = potionBag[potionId] or 0  
557 - if own <= 0 then return 4 end  
558 -  
559 if not isCanContinue(role) then return end 633 if not isCanContinue(role) then return end
560 local adv = role:getAdvData() 634 local adv = role:getAdvData()
  635 + if not adv:cost({[potionId] = 1}, {}, true) then return 4 end
561 if adv:isWaitChooseArtifact() then return end 636 if adv:isWaitChooseArtifact() then return end
562 637
563 adv:mylog({desc = "usePotion", int1 = potionId}) 638 adv:mylog({desc = "usePotion", int1 = potionId})
@@ -565,8 +640,7 @@ function _M.usePotionRpc(agent, data) @@ -565,8 +640,7 @@ function _M.usePotionRpc(agent, data)
565 local status = adv:doActive(potionData.effect, target) -- target 640 local status = adv:doActive(potionData.effect, target) -- target
566 if not status then return end 641 if not status then return end
567 642
568 - potionBag[potionId] = own - 1  
569 - role:updateProperty({field = "potionBag", value = potionBag}) 643 + adv:cost({[potionId] = 1}, {log = {desc = "usePotion", int1 = potionId}})
570 adv:pushBackEvent(AdvBackEventType.Potion, {id = potionId}) 644 adv:pushBackEvent(AdvBackEventType.Potion, {id = potionId})
571 adv:afterRound() 645 adv:afterRound()
572 adv:saveDB() 646 adv:saveDB()
@@ -737,7 +811,7 @@ function _M.endBattleRpc(agent, data) @@ -737,7 +811,7 @@ function _M.endBattleRpc(agent, data)
737 role:finishGuide(52) 811 role:finishGuide(52)
738 -- 调理剂使用引导(生命药剂) 812 -- 调理剂使用引导(生命药剂)
739 if not role:checkOverGuide(61) then 813 if not role:checkOverGuide(61) then
740 - local potionBag = role:getProperty("potionBag") 814 + local potionBag = role:getProperty("advItems"):toNumMap()
741 local own = potionBag[10] or 0 815 local own = potionBag[10] or 0
742 if own > 0 then 816 if own > 0 then
743 -- 造假 817 -- 造假
@@ -962,6 +1036,9 @@ function _M.roleFormatRpc(agent , data) @@ -962,6 +1036,9 @@ function _M.roleFormatRpc(agent , data)
962 local index = msg.index -- 阵容索引 1036 local index = msg.index -- 阵容索引
963 local title = msg.title -- 阵容名称 1037 local title = msg.title -- 阵容名称
964 local team = {} 1038 local team = {}
  1039 +
  1040 + if role:getAdvData():isRunning() then return 3 end
  1041 +
965 for slot, heroId in pairs(msg.heros) do 1042 for slot, heroId in pairs(msg.heros) do
966 if not role.heros[heroId] then 1043 if not role.heros[heroId] then
967 return 1 1044 return 1
@@ -1004,6 +1081,9 @@ function _M.selectTeamRpc(agent, data) @@ -1004,6 +1081,9 @@ function _M.selectTeamRpc(agent, data)
1004 local role = agent.role 1081 local role = agent.role
1005 local msg = MsgPack.unpack(data) 1082 local msg = MsgPack.unpack(data)
1006 local index = msg.index -- 阵容索引 1083 local index = msg.index -- 阵容索引
  1084 +
  1085 + if role:getAdvData():isRunning() then return 1 end
  1086 +
1007 local team = role:getAdvTeamFormat(index) 1087 local team = role:getAdvTeamFormat(index)
1008 if not next(team) then return end 1088 if not next(team) then return end
1009 team["index"] = index 1089 team["index"] = index
src/actions/CarAction.lua
@@ -13,7 +13,7 @@ function _M.makePotionRpc( agent, data ) @@ -13,7 +13,7 @@ function _M.makePotionRpc( agent, data )
13 local count = msg.count 13 local count = msg.count
14 if count < 1 then return 0 end 14 if count < 1 then return 0 end
15 local potionBag = role:getProperty("potionBag") 15 local potionBag = role:getProperty("potionBag")
16 - local potionLv = role.dinerData:getProperty("dishTree"):getv(potionId, 0) 16 + local potionLv = role.dinerData:getProperty("dishTree"):getv(potionId, 1)
17 if potionLv < 1 then return 1 end 17 if potionLv < 1 then return 1 end
18 18
19 local potionSet = csvdb["adv_potionCsv"][potionId] 19 local potionSet = csvdb["adv_potionCsv"][potionId]
@@ -22,20 +22,15 @@ function _M.makePotionRpc( agent, data ) @@ -22,20 +22,15 @@ function _M.makePotionRpc( agent, data )
22 local potionData = potionSet[potionLv] 22 local potionData = potionSet[potionLv]
23 if not potionData then return 3 end 23 if not potionData then return 3 end
24 24
25 - local own = potionBag[potionId] or 0  
26 - if own+count > potionData.limit then  
27 - return 4  
28 - end  
29 -  
30 local cost = potionData.material:toNumMap() 25 local cost = potionData.material:toNumMap()
31 for k, n in pairs(cost) do 26 for k, n in pairs(cost) do
32 cost[k] = n * count 27 cost[k] = n * count
33 end 28 end
34 if not role:checkItemEnough(cost) then 29 if not role:checkItemEnough(cost) then
35 - return 5 30 + return 4
36 end 31 end
37 -  
38 role:costItems(cost, {log = {desc = "makePotion", int1 = potionId, int2 = count}}) 32 role:costItems(cost, {log = {desc = "makePotion", int1 = potionId, int2 = count}})
  33 + local own = potionBag[potionId] or 0
39 potionBag[potionId] = own + count 34 potionBag[potionId] = own + count
40 role:updateProperty({field = "potionBag", value = potionBag}) 35 role:updateProperty({field = "potionBag", value = potionBag})
41 role:checkTaskEnter("PotionMake", {count = count, id = potionId}) 36 role:checkTaskEnter("PotionMake", {count = count, id = potionId})
src/actions/DinerAction.lua
@@ -305,7 +305,7 @@ function _M.expediteSellRpc( agent, data ) @@ -305,7 +305,7 @@ function _M.expediteSellRpc( agent, data )
305 local gift = reward:toNumMap() 305 local gift = reward:toNumMap()
306 306
307 -- 特权卡获取加速获得额外道具 307 -- 特权卡获取加速获得额外道具
308 - local coef = role.storeData:getProduceItemSpeedCoef() 308 + local coef = 1 --role.storeData:getProduceItemSpeedCoef()
309 for k, v in pairs(gift) do 309 for k, v in pairs(gift) do
310 if coef > 1 then 310 if coef > 1 then
311 v = math.floor(v * coef) 311 v = math.floor(v * coef)
@@ -385,22 +385,12 @@ function _M.talentUpRpc( agent, data ) @@ -385,22 +385,12 @@ function _M.talentUpRpc( agent, data )
385 local msg = MsgPack.unpack(data) 385 local msg = MsgPack.unpack(data)
386 local dish = msg.dish 386 local dish = msg.dish
387 local dishTree = role.dinerData:getProperty("dishTree") 387 local dishTree = role.dinerData:getProperty("dishTree")
388 - local dishLevel = dishTree:getv(dish, 0)  
389 388
390 local talentSet = csvdb["diner_talentCsv"][dish] 389 local talentSet = csvdb["diner_talentCsv"][dish]
391 if not talentSet then 390 if not talentSet then
392 return 1 391 return 1
393 end 392 end
394 393
395 - local talentData = talentSet[dishLevel]  
396 - if not talentData then  
397 - return 2  
398 - end  
399 -  
400 - if not talentSet[dishLevel+1] then  
401 - return 21  
402 - end  
403 -  
404 local typ = math.floor(dish/100 + 1) 394 local typ = math.floor(dish/100 + 1)
405 local treeSet = csvdb["diner_treeCsv"][typ] 395 local treeSet = csvdb["diner_treeCsv"][typ]
406 if not treeSet then 396 if not treeSet then
@@ -412,6 +402,17 @@ function _M.talentUpRpc( agent, data ) @@ -412,6 +402,17 @@ function _M.talentUpRpc( agent, data )
412 return 4 402 return 4
413 end 403 end
414 404
  405 + -- 调理剂的默认等级是1级
  406 + local dishLevel = dishTree:getv(dish, treeData.rarity == 2 and 1 or 0)
  407 + local talentData = talentSet[dishLevel]
  408 + if not talentData then
  409 + return 2
  410 + end
  411 +
  412 + if not talentSet[dishLevel+1] then
  413 + return 21
  414 + end
  415 +
415 local limit = talentData.pointFront:toNumMap() 416 local limit = talentData.pointFront:toNumMap()
416 for k,v in pairs(limit) do 417 for k,v in pairs(limit) do
417 local lv = dishTree:getv(k, 0) 418 local lv = dishTree:getv(k, 0)
src/actions/EmailAction.lua
@@ -40,10 +40,17 @@ function _M.listRpc(agent, data) @@ -40,10 +40,17 @@ function _M.listRpc(agent, data)
40 local count = 1 40 local count = 1
41 for _, data in ipairs(result) do 41 for _, data in ipairs(result) do
42 local email = tarr2tab(data) 42 local email = tarr2tab(data)
43 - if tonum(email.createtime) > role:getProperty("ctime")  
44 - and ( not email.mid or tonum(email.mid) == mid ) 43 + -- 0 需要判斷創角時間小於郵件創建時間 1 只需要在時間段內登陸即可領取
  44 + local delayType = tonum(email.delayType)
  45 + local flag = false
  46 + if delayType == 1 then
  47 + flag = skynet.timex() > tonum(email.createtime)
  48 + else
  49 + flag = tonum(email.createtime) > role:getProperty("ctime")
  50 + end
  51 + if flag and ( not email.mid or tonum(email.mid) == mid )
45 and ( not email.endtime or tonum(email.endtime) > now )then 52 and ( not email.endtime or tonum(email.endtime) > now )then
46 - local time = math.max(tonum(email.timestamp, 0) or email.createtime) 53 + local time = math.max(tonum(email.timestamp, 0) , tonum(email.createtime))
47 redisproxy:insertEmail({ 54 redisproxy:insertEmail({
48 roleId = roleId, 55 roleId = roleId,
49 emailId = 0, 56 emailId = 0,
src/actions/GmAction.lua
@@ -36,26 +36,15 @@ function _M.ban(role, pms) @@ -36,26 +36,15 @@ function _M.ban(role, pms)
36 local time = tonum(pms.pm1, 1) 36 local time = tonum(pms.pm1, 1)
37 local ctype = tonum(pms.pm2, 0) 37 local ctype = tonum(pms.pm2, 0)
38 38
39 - local isBan = role:getProperty("banTime") <= now  
40 role:setBan(time, ctype) 39 role:setBan(time, ctype)
41 - if time > 0 then  
42 - role:sendGmMsg("server_accountBanned_1")  
43 - local agent = datacenter.get("agent", role:getProperty("id"))  
44 - if agent then  
45 - skynet.timeout(50, function ()  
46 - skynet.call(agent.gate_serv, "lua", "forcekick", agent.fd)  
47 - end)  
48 - end  
49 - end  
50 -  
51 role:mylog("gm_action", {desc = "ban", int1 = time, int2 = ctype, key1 = pms.sender}) 40 role:mylog("gm_action", {desc = "ban", int1 = time, int2 = ctype, key1 = pms.sender})
52 -  
53 - return isBan and "解封杀成功" or "封杀成功" 41 + return "封杀成功"
54 end 42 end
55 43
  44 +
56 function _M.unban(role, pms) 45 function _M.unban(role, pms)
57 role:setBan(0, 0) 46 role:setBan(0, 0)
58 - 47 + role:setProperty("cheatCount", 0) -- 清除作弊次数
59 role:mylog("gm_action", {desc = "unban", key1 = pms.sender}) 48 role:mylog("gm_action", {desc = "unban", key1 = pms.sender})
60 49
61 return "解封杀成功" 50 return "解封杀成功"
@@ -63,18 +52,17 @@ end @@ -63,18 +52,17 @@ end
63 52
64 function _M.gmmsg(role, pms) 53 function _M.gmmsg(role, pms)
65 role:sendGmMsg(pms.pm1, true) 54 role:sendGmMsg(pms.pm1, true)
66 -  
67 - local agent = datacenter.get("agent", role:getProperty("id"))  
68 - if agent then  
69 - skynet.timeout(50, function ()  
70 - skynet.call(agent.gate_serv, "lua", "forcekick", agent.fd)  
71 - end)  
72 - end  
73 role:mylog("gm_action", {desc = "gmmsg", text1 = pms.pm1, key1 = pms.sender}) 55 role:mylog("gm_action", {desc = "gmmsg", text1 = pms.pm1, key1 = pms.sender})
74 -  
75 return "指令成功" 56 return "指令成功"
76 end 57 end
77 58
  59 +
  60 +function _M.reset_rank(role, pms)
  61 + role:resetRank()
  62 + role:mylog("gm_action", {desc = "reset_rank", key1 = pms.sender})
  63 + return "封杀成功"
  64 +end
  65 +
78 function _M.silent(role, pms) 66 function _M.silent(role, pms)
79 local pm1 = tonum(pms.pm1) 67 local pm1 = tonum(pms.pm1)
80 if pm1 < 1 then 68 if pm1 < 1 then
@@ -259,6 +247,7 @@ table.insert(helpDes, {&quot;获得所有零件&quot;, &quot;get&quot;, &quot;RUNE&quot;}) @@ -259,6 +247,7 @@ table.insert(helpDes, {&quot;获得所有零件&quot;, &quot;get&quot;, &quot;RUNE&quot;})
259 table.insert(helpDes, {"获得所有碎片", "get", "FRAG"}) 247 table.insert(helpDes, {"获得所有碎片", "get", "FRAG"})
260 table.insert(helpDes, {"获得所有食物", "get", "FOOD"}) 248 table.insert(helpDes, {"获得所有食物", "get", "FOOD"})
261 table.insert(helpDes, {"获得所有角色", "get", "HERO"}) 249 table.insert(helpDes, {"获得所有角色", "get", "HERO"})
  250 +table.insert(helpDes, {"获得满级满觉醒角色,满级满精进铭文", "get", "MAXHERO"})
262 function _M.get(role, pms) 251 function _M.get(role, pms)
263 if pms.pm1 == "ALL" then 252 if pms.pm1 == "ALL" then
264 local reward = {} 253 local reward = {}
@@ -275,7 +264,7 @@ function _M.get(role, pms) @@ -275,7 +264,7 @@ function _M.get(role, pms)
275 end 264 end
276 end 265 end
277 elseif pms.pm1 == "RUNE" then 266 elseif pms.pm1 == "RUNE" then
278 - for itemId = 2000 , 3000 do 267 + for itemId = 10000 , 20000 do
279 if csvdb["itemCsv"][itemId] then 268 if csvdb["itemCsv"][itemId] then
280 role:award({[itemId] = 1}, {log = {desc = "gm"}}) 269 role:award({[itemId] = 1}, {log = {desc = "gm"}})
281 end 270 end
@@ -298,6 +287,36 @@ function _M.get(role, pms) @@ -298,6 +287,36 @@ function _M.get(role, pms)
298 role:award({[itemId] = 1}, {log = {desc = "gm"}}) 287 role:award({[itemId] = 1}, {log = {desc = "gm"}})
299 end 288 end
300 end 289 end
  290 + elseif pms.pm1 == "MAXHERO" then
  291 + -- 给英雄
  292 + for itemId = 400 , 700 do
  293 + if csvdb["itemCsv"][itemId] then
  294 + role:award({[itemId] = 1}, {log = {desc = "gm"}})
  295 + end
  296 + end
  297 + -- 升满级
  298 + for _, hero in ipairs(role.heros) do
  299 + hero:updateProperty({field = "level", value = 140})
  300 + hero:updateProperty({field = "wakeL", value = #csvdb["unit_wakeCsv"]})
  301 + end
  302 +
  303 + -- 添加铭文
  304 + for itemId = 10000 , 20000 do
  305 + if csvdb["itemCsv"][itemId] then
  306 + role:award({[itemId] = 1}, {log = {desc = "gm"}})
  307 + end
  308 + end
  309 + for _, rune in ipairs(role.runeBag) do
  310 + local typ = rune:getProperty("type")
  311 + local id = rune:getProperty("id")
  312 +
  313 + local runeSet = csvdb["runeCsv"][typ]
  314 + if not runeSet then break end
  315 + local runeData = runeSet[id]
  316 + if not runeData then break end
  317 +
  318 + rune:updateProperty({field = "level",value = runeData.lvLimit})
  319 + end
301 else 320 else
302 local itemId = tonum(pms.pm1) 321 local itemId = tonum(pms.pm1)
303 if not csvdb["itemCsv"][itemId] then 322 if not csvdb["itemCsv"][itemId] then
@@ -371,6 +390,7 @@ function _M.advt(role, pms) @@ -371,6 +390,7 @@ function _M.advt(role, pms)
371 local chapterId = tonum(pms.pm1) 390 local chapterId = tonum(pms.pm1)
372 local layer = tonum(pms.pm2) 391 local layer = tonum(pms.pm2)
373 local mapId = tonum(pms.pm3) 392 local mapId = tonum(pms.pm3)
  393 + local actid = tonum(pms.pm4)
374 local advCsv = csvdb["adv_chapterCsv"][chapterId] 394 local advCsv = csvdb["adv_chapterCsv"][chapterId]
375 if not advCsv then return "不存在的章节" end 395 if not advCsv then return "不存在的章节" end
376 396
@@ -387,6 +407,7 @@ function _M.advt(role, pms) @@ -387,6 +407,7 @@ function _M.advt(role, pms)
387 level = layer, 407 level = layer,
388 isEnter = true, 408 isEnter = true,
389 debugMapId = mapId, 409 debugMapId = mapId,
  410 + actid = actid,
390 }) 411 })
391 role:mylog("gm_action", {desc = "advt", int1 = chapterId, int2 = layer, key1 = pms.sender}) 412 role:mylog("gm_action", {desc = "advt", int1 = chapterId, int2 = layer, key1 = pms.sender})
392 return "成功" 413 return "成功"
@@ -539,6 +560,26 @@ function _M.actbattle(role, pms) @@ -539,6 +560,26 @@ function _M.actbattle(role, pms)
539 return "成功" 560 return "成功"
540 end 561 end
541 562
  563 +table.insert(helpDes, {"清空背包", "clearbag"})
  564 +function _M.clearbag(role, pms)
  565 + -- 装备
  566 + role:updateProperty({field="equips", value = {}})
  567 + -- 道具
  568 + local items = role:getProperty("items"):toNumMap()
  569 + for k, v in pairs(items) do
  570 + role:addItem({itemId = k, count = -v, log = {desc = "gm"}})
  571 + end
  572 +
  573 + -- 铭文
  574 + local uids = {}
  575 + for uid, _ in pairs(role.runeBag) do
  576 + table.insert(uids, uid)
  577 + end
  578 + role:delRunes(uids, {log = {desc = "gm"}})
  579 +
  580 + return "成功"
  581 +end
  582 +
542 function _M.helpRpc(agent, data) 583 function _M.helpRpc(agent, data)
543 SendPacket(actionCodes.Gm_helpRpc, MsgPack.pack({help = helpDes})) 584 SendPacket(actionCodes.Gm_helpRpc, MsgPack.pack({help = helpDes}))
544 return true 585 return true
@@ -546,11 +587,23 @@ end @@ -546,11 +587,23 @@ end
546 587
547 function _M.test(role, pms) 588 function _M.test(role, pms)
548 local id = tonum(pms.pm1, 0) 589 local id = tonum(pms.pm1, 0)
  590 + local actid = nil
  591 + if id > 100 then
  592 + actid = tonum(pms.pm2, 0)
  593 + end
549 --local hero = require ("actions.HeroAction") 594 --local hero = require ("actions.HeroAction")
550 --hero.unlockPoolRpc({role = role}, MsgPack.pack({type = id})) 595 --hero.unlockPoolRpc({role = role}, MsgPack.pack({type = id}))
551 596
552 --role:sendMail(13, nil, "1=2", {111}) 597 --role:sendMail(13, nil, "1=2", {111})
553 - dump(redisproxy:zrevrange("rank:tower", 0 , 10, "WITHSCORES")) 598 + local file = io.open("draw_hero_"..id..".csv", "a")
  599 + for i=1, 10000 do
  600 + local heroIds = _M.drawHero(role, id, actid)
  601 + for k, v in ipairs(heroIds) do
  602 + print((i - 1)* 10 + k, v)
  603 + file:write(v.."\n")
  604 + end
  605 + end
  606 + io.close(file)
554 return "成功" 607 return "成功"
555 end 608 end
556 609
@@ -559,6 +612,12 @@ function _M.ayncPurchase(role, params) @@ -559,6 +612,12 @@ function _M.ayncPurchase(role, params)
559 return role:handlePurchase(params) or "" 612 return role:handlePurchase(params) or ""
560 end 613 end
561 614
  615 +-- 获取订单号
  616 +function _M.getPurchaseOrder(role, params)
  617 + return role:getPurchaseOrderByPlatform(params) or ""
  618 +end
  619 +
  620 +
562 function _M.cz(role, pms) 621 function _M.cz(role, pms)
563 local id = tonum(pms.pm1) 622 local id = tonum(pms.pm1)
564 local csvData = csvdb["shop_rechargeCsv"][id] 623 local csvData = csvdb["shop_rechargeCsv"][id]
@@ -575,5 +634,270 @@ function _M.cz(role, pms) @@ -575,5 +634,270 @@ function _M.cz(role, pms)
575 return "指令成功" 634 return "指令成功"
576 end 635 end
577 636
  637 +function _M.drawHero(role, t, act)
  638 + local btype = t -- 1 2 3 4 5 卡池类型 4新手卡池 5心愿卡池
  639 + local subType = 1-- 定向卡池需要传 子类型
  640 + local drawType = 2 -- 1 单抽 2 十连
  641 + if btype ~= 1 then
  642 + subType = 1
  643 + end
  644 +
  645 + local actid = act
  646 + -- 另开活动卡池
  647 + if actid then
  648 + --if not role.activity:isOpenById(actid, "ActHeroPool") then return end
  649 + local cfg = csvdb["activity_ctrlCsv"][actid]
  650 + if not cfg then return end
  651 +
  652 + btype = cfg.condition
  653 + end
  654 +
  655 + local buildTypeData = csvdb["build_typeCsv"][btype]
  656 + if not buildTypeData then return 2 end
  657 +
  658 + local drawCount = {1, 10} -- 抽取次数
  659 + if not drawCount[drawType] then return 3 end
  660 +
  661 + local draw_floor_back_counts = globalCsv.draw_floor_back_counts[btype]
  662 + local floorHeroCount = role:getProperty("floorHero")[btype] or 0
  663 +
  664 + -- 抽取的池子
  665 + local poolMap = buildTypeData["pool"]:toNumMap()
  666 + local poolId = poolMap[subType]
  667 + if not poolId then return 5 end
  668 +
  669 + --TODO 活动覆盖
  670 + local actPoolId = role.activity:getActivityPool(btype, subType)
  671 + if actPoolId ~= 0 then
  672 + poolId = actPoolId
  673 + end
  674 +
  675 + local unitPool = csvdb["build_unitCsv"][poolId]
  676 + if not unitPool then return 7 end
  677 +
  678 + -- 开始抽
  679 + local resultPool = {}
  680 + local function fillDrawPool(isFloorBack)
  681 + local condition = {"rare"}
  682 + local values = {}
  683 +
  684 +
  685 + for idx, field in ipairs(condition) do
  686 + if not values[idx] then
  687 + local lpool = {}
  688 + local curIdx = 1
  689 + while unitPool[field .. "_" .. curIdx] do
  690 + lpool[curIdx] = {unitPool[field .. "_" .. curIdx]}
  691 + curIdx = curIdx + 1
  692 + end
  693 +
  694 + if next(lpool) then
  695 + values[idx] = math.randWeight(lpool, 1)
  696 + end
  697 + end
  698 + end
  699 +
  700 + local weight = 0
  701 + local up_pool = nil
  702 + local rand_v = math.randomInt(1, 100)
  703 + if values[1] == HeroQuality.SR then
  704 + weight = unitPool["up_sr_weight"]
  705 + up_pool = unitPool["up_sr_id"]
  706 + elseif values[1] == HeroQuality.SSR then
  707 + weight = unitPool["up_ssr_weight"]
  708 + up_pool = unitPool["up_ssr_id"]
  709 + if btype == 5 then
  710 + weight = 3 * weight
  711 + end
  712 + end
  713 + --print(poolId, rand_v, weight, up_pool, values[1])
  714 + if rand_v < weight and up_pool then
  715 + up_pool = up_pool:toArray(true, "=")
  716 + if btype == 5 then -- 爱心卡池,使用玩家设置的备选池子
  717 + up_pool = role:getProperty("wishPool")
  718 + up_pool[1] = 408
  719 + up_pool[2] = 409
  720 + up_pool[3] = 410
  721 + end
  722 + for k, v in ipairs(up_pool) do
  723 + resultPool[v] = {1}
  724 + end
  725 + else
  726 + for itemId, oneData in pairs(isFloorBack and csvdb["build_floorCsv"] or csvdb["build_poolCsv"]) do
  727 + local pool_str = "pool_" .. poolId
  728 + if oneData[pool_str] and oneData[pool_str] ~= "" then
  729 + local itemData = csvdb["itemCsv"][itemId]
  730 + while itemData do
  731 + if itemData.type ~= ItemType.Hero then break end
  732 + local heroData = csvdb["unitCsv"][itemData.id - ItemStartId.Hero]
  733 + if not heroData then break end
  734 + local ok = true
  735 + -- 保底是全随机,不用比较类型
  736 + if not isFloorBack then
  737 + for idx, field in ipairs(condition) do
  738 + if heroData[field] ~= values[idx] then ok = false break end
  739 + end
  740 + end
  741 + if up_pool then
  742 + for k, v in ipairs(up_pool) do
  743 + if v == itemData.id then
  744 + ok = false
  745 + break
  746 + end
  747 + end
  748 + end
  749 + if not ok then break end
  750 + if oneData[pool_str] > 0 then
  751 + resultPool[itemId] = {oneData[pool_str]} -- itemId, count, 概率
  752 + end
  753 + break
  754 + end
  755 + end
  756 + end
  757 + end
  758 + end
  759 +
  760 + local guideHero = nil
  761 + if role:getProperty("newerGuide") == "8=1" then
  762 + guideHero = globalCsv.newdraw_hero_item_id or 503
  763 + end
  764 +
  765 + local ssrCount = 0
  766 + local reward = {}
  767 + local logReward = {}
  768 + local result = {}
  769 + for i = 1, drawCount[drawType] do
  770 + floorHeroCount = floorHeroCount + 1
  771 + local isFloorBack = draw_floor_back_counts and floorHeroCount >= draw_floor_back_counts
  772 + resultPool = {}
  773 + fillDrawPool(isFloorBack)
  774 + if not next(resultPool) then
  775 + skynet.error("random pool error, poolId:" .. poolId, isFloorBack)
  776 + return 8
  777 + end
  778 +
  779 + local itemId = math.randWeight(resultPool, 1)
  780 + if guideHero then
  781 + itemId = guideHero
  782 + end
  783 +
  784 + local itemData = csvdb["itemCsv"][itemId]
  785 + if itemData.quality == HeroQuality.SSR then
  786 + ssrCount = ssrCount + 1
  787 + if not guideHero then
  788 + -- 广播获得ssr英雄
  789 + local ntf = {heroId = itemData.id - ItemStartId.Hero, nick = role:getProperty("name")}
  790 + --mcast_util.pub_world(actionCodes.Role_broadGetSSR, MsgPack.pack(ntf))
  791 + end
  792 + end
  793 +
  794 + if btype == 4 and role:getProperty("newerDraw") == 0 then -- 新手卡池
  795 + if itemData.quality == HeroQuality.SSR then
  796 + floorHeroCount = 0
  797 + end
  798 + else
  799 + if itemData.quality >= HeroQuality.SR then
  800 + floorHeroCount = 0
  801 + end
  802 + end
  803 +
  804 + if role:isHaveHero(itemData.id - ItemStartId.Hero) then
  805 + local fragId = itemData.id - ItemStartId.Hero
  806 + local heroData = csvdb["unitCsv"][fragId]
  807 + local count = globalCsv.draw_unit_tofragment[heroData.rare]
  808 + role:award({[fragId] = count}, {log = {desc = "drawHero", int1 = btype, int2 = poolId}})
  809 + logReward[fragId] = (logReward[fragId] or 0) + count
  810 + table.insert(reward, {id = fragId, count = count, from = itemId, fcount = 1})
  811 + else
  812 + role:award({[itemId] = 1}, {log = {desc = "drawHero", int1 = btype, int2 = poolId}})
  813 + logReward[itemId] = (logReward[itemId] or 0) + 1
  814 + table.insert(reward, {id = itemId, count = 1})
  815 + end
  816 + end
  817 +
  818 + if draw_floor_back_counts then
  819 + local floorHero = role:getProperty("floorHero")
  820 + floorHero[btype] = floorHeroCount
  821 + role:setProperty("floorHero", floorHero)
  822 + end
  823 +
  824 + if btype == 4 then
  825 + local newCount = role:getProperty("newerDraw")
  826 + role:updateProperty({field="newerDraw", value = newCount + drawCount[drawType]})
  827 + end
  828 +
  829 + --SendPacket(actionCodes.Hero_drawHeroRpc, MsgPack.pack({reward = reward})) -- 这个 reward 是数组
  830 + for k, v in pairs(reward) do
  831 + local hero = v
  832 + if hero["from"] then
  833 + result[#result+1] = hero["from"]
  834 + else
  835 + result[#result+1] = hero["id"]
  836 + end
  837 + end
  838 +
  839 + local feedbackId = buildTypeData["can_feedback"] or 0
  840 + if feedbackId ~= 0 then
  841 + -- 达到一定次数,给响应奖励
  842 + local oldVal = role:getProperty("repayHero") or 0
  843 + if actid then
  844 + local actData = role.activity:getActData("ActHeroPool")
  845 + oldVal = actData[btype] or 0
  846 + end
  847 + local newVal = oldVal + drawCount[drawType]
  848 + local drawCardReward, val = role:getDrawCardExtraReward(feedbackId, oldVal, newVal)
  849 + -- 空字符穿代表直接给英雄 走以前repayHeroRpc
  850 + if drawCardReward == "" then
  851 + local repayHeroMaxCount = role:getProperty("repayMaxC") or 0
  852 + repayHeroMaxCount = repayHeroMaxCount + 1
  853 +
  854 + role:updateProperty({field = "repayMaxC", value = repayHeroMaxCount})
  855 + local even = repayHeroMaxCount % 2
  856 + local id = 0
  857 + if even == 1 then
  858 + id = math.randWeight(csvdb["build_giftCsv"], "pool_"..feedbackId)
  859 + else
  860 + local giftHeroSet = {}
  861 + for gid, cfg in pairs(csvdb["build_giftCsv"]) do
  862 + if cfg["pool_"..feedbackId] ~= 0 and not role:isHaveHero(gid - ItemStartId.Hero) then
  863 + giftHeroSet[gid] = {1}
  864 + end
  865 + end
  866 + if next(giftHeroSet) then
  867 + id = math.randWeight(giftHeroSet, 1)
  868 + end
  869 + end
  870 + if id == 0 then
  871 + id = math.randWeight(csvdb["build_giftCsv"], "pool_"..feedbackId)
  872 + end
  873 +
  874 + local r,change = {}
  875 + local itemData = csvdb["itemCsv"][id]
  876 + --if itemData.type == ItemType.Hero and role:isHaveHero(itemData.id - ItemStartId.Hero) then
  877 + -- local fragId = itemData.id - ItemStartId.Hero
  878 + -- local heroData = csvdb["unitCsv"][fragId]
  879 + -- local count = globalCsv.draw_unit_tofragment[heroData.rare]
  880 + -- r, change = role:award({[fragId] = count}, {log = {desc = "drawHeroExtraReward"}})
  881 + -- --r = {id = fragId, count = count, from = id, fcount = 1}
  882 + --else
  883 + r, change = role:award({[id] = 1}, {log = {desc = "drawHeroExtraReward"}})
  884 + --end
  885 + SendPacket(actionCodes.Hero_drawHeroExtraRewardNtf, MsgPack.pack(role:packReward(r, change)))
  886 + elseif drawCardReward and drawCardReward ~= "" then
  887 + local r,change = {}
  888 + r, change = role:award(drawCardReward, {log = {desc = "drawHeroExtraReward", int1 = oldVal, int2 = newVal}})
  889 + SendPacket(actionCodes.Hero_drawHeroExtraRewardNtf, MsgPack.pack(role:packReward(r, change)))
  890 + end
  891 + if not actid then
  892 + role:updateProperty({field = "repayHero", value = val})
  893 + else
  894 + local actData = role.activity:getActData("ActHeroPool")
  895 + actData[btype] = val
  896 + role.activity:updateActData("ActHeroPool", actData)
  897 + end
  898 + end
  899 + return result
  900 +end
  901 +
578 902
579 return _M 903 return _M
580 \ No newline at end of file 904 \ No newline at end of file
src/actions/HangAction.lua
@@ -235,6 +235,16 @@ function _M.endBattleRpc(agent, data) @@ -235,6 +235,16 @@ function _M.endBattleRpc(agent, data)
235 return 4 235 return 4
236 end 236 end
237 237
  238 + -- 防作弊
  239 + if not role:checkBattleCheat("hang", {
  240 + id = carbonId,
  241 + isWin = isWin,
  242 + info = msg.info
  243 + }) then
  244 + SendPacket(actionCodes.Hang_endBattleRpc, MsgPack.pack({errorCode = 1}))
  245 + return true
  246 + end
  247 +
238 local reward, change 248 local reward, change
239 if isWin then --win 249 if isWin then --win
240 role:hangFinish(carbonId) 250 role:hangFinish(carbonId)
@@ -581,6 +591,8 @@ function _M.startBonusBattleRpc(agent, data) @@ -581,6 +591,8 @@ function _M.startBonusBattleRpc(agent, data)
581 591
582 local reward, change = bonusWinReward(role, bonusData, 3, count) 592 local reward, change = bonusWinReward(role, bonusData, 3, count)
583 SendPacket(actionCodes.Hang_startBonusBattleRpc, MsgPack.pack({reward = reward, change = change})) 593 SendPacket(actionCodes.Hang_startBonusBattleRpc, MsgPack.pack({reward = reward, change = change}))
  594 +
  595 + role:checkTaskEnter("BonusQuick", {count = count})
584 else 596 else
585 local bTeam = role:getTeamFormatByType(TeamSystemType.BonusBattle) 597 local bTeam = role:getTeamFormatByType(TeamSystemType.BonusBattle)
586 if not next(bTeam) then return 5 end 598 if not next(bTeam) then return 5 end
@@ -607,6 +619,18 @@ function _M.endBonusBattleRpc(agent, data) @@ -607,6 +619,18 @@ function _M.endBonusBattleRpc(agent, data)
607 SendPacket(actionCodes.Hang_endBonusBattleRpc, MsgPack.pack({errorCode = 1})) 619 SendPacket(actionCodes.Hang_endBonusBattleRpc, MsgPack.pack({errorCode = 1}))
608 return true 620 return true
609 end 621 end
  622 + role.__bonusBattleCache = nil
  623 +
  624 + -- 防作弊
  625 + if not role:checkBattleCheat("bonus", {
  626 + id = id,
  627 + isWin = starNum and starNum > 0,
  628 + info = msg.info
  629 + }) then
  630 + SendPacket(actionCodes.Hang_endBonusBattleRpc, MsgPack.pack({errorCode = 1}))
  631 + return true
  632 + end
  633 +
610 local bonusData = csvdb["bonus_battleCsv"][id] 634 local bonusData = csvdb["bonus_battleCsv"][id]
611 635
612 local reward, change = {} 636 local reward, change = {}
src/actions/HeroAction.lua
@@ -617,7 +617,7 @@ function _M.getResetRewardRpc(agent, data) @@ -617,7 +617,7 @@ function _M.getResetRewardRpc(agent, data)
617 if level <= 1 and talent == "" then return end 617 if level <= 1 and talent == "" then return end
618 618
619 local pay = true 619 local pay = true
620 - if level <= 60 then 620 + if level <= 60 or role.activity:isOpen("HeroBackFree") then
621 pay = false 621 pay = false
622 end 622 end
623 623
@@ -663,7 +663,8 @@ function _M.getResetRewardRpc(agent, data) @@ -663,7 +663,8 @@ function _M.getResetRewardRpc(agent, data)
663 663
664 while stage > 0 do 664 while stage > 0 do
665 local curData = csvdb["unit_talent_"..heroCfgId.."Csv"][stage] 665 local curData = csvdb["unit_talent_"..heroCfgId.."Csv"][stage]
666 - for lvl = 1, curTalentLvl - 1 do 666 + local offset = stage == talent:getv(0,1) and curTalentLvl - 1 or #curData
  667 + for lvl = 1, offset do
667 local talentData = curData[lvl] 668 local talentData = curData[lvl]
668 for itemId, count in pairs(talentData.money:toNumMap()) do 669 for itemId, count in pairs(talentData.money:toNumMap()) do
669 reward[itemId] = (reward[itemId] or 0) + count 670 reward[itemId] = (reward[itemId] or 0) + count
@@ -926,6 +927,7 @@ function _M.drawHeroRpc(agent, data) @@ -926,6 +927,7 @@ function _M.drawHeroRpc(agent, data)
926 local itemId = math.randWeight(resultPool, 1) 927 local itemId = math.randWeight(resultPool, 1)
927 if guideHero then 928 if guideHero then
928 itemId = guideHero 929 itemId = guideHero
  930 + guideHero = nil
929 end 931 end
930 932
931 local itemData = csvdb["itemCsv"][itemId] 933 local itemData = csvdb["itemCsv"][itemId]
@@ -974,6 +976,9 @@ function _M.drawHeroRpc(agent, data) @@ -974,6 +976,9 @@ function _M.drawHeroRpc(agent, data)
974 end 976 end
975 977
976 role:checkTaskEnter("DrawHero", {pool = btype, count = drawCount[drawType]}) 978 role:checkTaskEnter("DrawHero", {pool = btype, count = drawCount[drawType]})
  979 + if btype ~= 3 then
  980 + role:checkTaskEnter("DrawHeroNotFriend", {pool = btype, count = drawCount[drawType]})
  981 + end
977 if ssrCount > 0 then 982 if ssrCount > 0 then
978 role:checkTaskEnter("DrawSSR", {count = ssrCount}) 983 role:checkTaskEnter("DrawSSR", {count = ssrCount})
979 end 984 end
src/actions/HttpAction.lua
@@ -147,6 +147,15 @@ function _M.gm_action(query) @@ -147,6 +147,15 @@ function _M.gm_action(query)
147 return status 147 return status
148 end 148 end
149 149
  150 +function _M.query_role(query)
  151 + if not query.uid then return "not found" end
  152 + local user = redisproxy:get(string.format("uid:%s", query.uid))
  153 + if not user then return "not found" end
  154 + local roleId = redisproxy:get(string.format("user:%s", string.upper(user)))
  155 + if not roleId then return "not found" end
  156 + return json.encode({roleId, user})
  157 +end
  158 +
150 function _M.broadcast(query) 159 function _M.broadcast(query)
151 local msg = {} 160 local msg = {}
152 local handle = { 161 local handle = {
src/actions/PvpAction.lua
@@ -372,6 +372,16 @@ function _M.endBattleRpc(agent, data) @@ -372,6 +372,16 @@ function _M.endBattleRpc(agent, data)
372 372
373 if not match then return end 373 if not match then return end
374 374
  375 + -- 防作弊
  376 + if not role:checkBattleCheat("pvpc", {
  377 + isWin = isWin,
  378 + info = msg.info,
  379 + format = _pvpStartBattleCacheC.pvpTC,
  380 + }) then
  381 + SendPacket(actionCodes.Pvp_endBattleRpc, MsgPack.pack({errorCode = 1}))
  382 + return true
  383 + end
  384 +
375 local temp = string.randWeight(csvdb["player_expCsv"][role:getProperty("level")].pvpBonus, true) 385 local temp = string.randWeight(csvdb["player_expCsv"][role:getProperty("level")].pvpBonus, true)
376 local reward, change = role:award({[temp[1]] = temp[2]}, {log = {desc = "pvpBattleC"}}) 386 local reward, change = role:award({[temp[1]] = temp[2]}, {log = {desc = "pvpBattleC"}})
377 local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = 0, 0, 0, 0, -1, -1 387 local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = 0, 0, 0, 0, -1, -1
@@ -652,13 +662,22 @@ function _M.endBattleHRpc(agent, data) @@ -652,13 +662,22 @@ function _M.endBattleHRpc(agent, data)
652 end 662 end
653 end 663 end
654 664
  665 + -- 防作弊
  666 + if not role:checkBattleCheat("pvph", {
  667 + isWin = isWin,
  668 + info = msg.info,
  669 + format = _pvpStartBattleCacheH.pvpTH[#_pvpStartBattleCacheH.result]
  670 + }) then
  671 + SendPacket(actionCodes.Pvp_endBattleHRpc, MsgPack.pack({errorCode = 1}))
  672 + return true
  673 + end
  674 +
655 if winCount >= 2 then 675 if winCount >= 2 then
656 isWin = true 676 isWin = true
657 elseif loseCount >= 2 then 677 elseif loseCount >= 2 then
658 isWin = false 678 isWin = false
659 else -- 没结束 679 else -- 没结束
660 -- 返回继续战斗 680 -- 返回继续战斗
661 -  
662 local key = tostring(math.random()) 681 local key = tostring(math.random())
663 _pvpStartBattleCacheH.key = key 682 _pvpStartBattleCacheH.key = key
664 local round = #_pvpStartBattleCacheH.result + 1 683 local round = #_pvpStartBattleCacheH.result + 1
src/actions/RadioAction.lua
@@ -179,6 +179,7 @@ function _M.finishQuestRpc(agent, data) @@ -179,6 +179,7 @@ function _M.finishQuestRpc(agent, data)
179 msg["heroFaith"] = heroFaithMap 179 msg["heroFaith"] = heroFaithMap
180 SendPacket(actionCodes.Radio_finishQuestRpc, MsgPack.pack(msg)) 180 SendPacket(actionCodes.Radio_finishQuestRpc, MsgPack.pack(msg))
181 181
  182 + role:checkTaskEnter("RadioTaskStart", {heroCnt = #task.heros})
182 183
183 local herolist = {} 184 local herolist = {}
184 for _, heroId in ipairs(task.heros) do 185 for _, heroId in ipairs(task.heros) do
src/actions/RoleAction.lua
@@ -157,6 +157,7 @@ function _M.loginRpc( agent, data ) @@ -157,6 +157,7 @@ function _M.loginRpc( agent, data )
157 SERV_OPEN = redisproxy:hget("autoincrement_set", "server_start") 157 SERV_OPEN = redisproxy:hget("autoincrement_set", "server_start")
158 158
159 role:changeStructVersion() -- 数据结构 版本更新 159 role:changeStructVersion() -- 数据结构 版本更新
  160 + role:getAdvData(true) -- 清掉不合格的数据
160 role:advEndlessSeasonCheck(true) -- 冒险赛季更新检查 161 role:advEndlessSeasonCheck(true) -- 冒险赛季更新检查
161 162
162 -- 跨天登陆事件 163 -- 跨天登陆事件
@@ -165,6 +166,7 @@ function _M.loginRpc( agent, data ) @@ -165,6 +166,7 @@ function _M.loginRpc( agent, data )
165 role.activity:checkActivityStatus(now, false, false) 166 role.activity:checkActivityStatus(now, false, false)
166 role:log("onLogin") 167 role:log("onLogin")
167 end 168 end
  169 + role:checkTaskEnter("Login", {})
168 170
169 redisproxy:zadd(FRIEND_RECOMMEND, now, roleId) 171 redisproxy:zadd(FRIEND_RECOMMEND, now, roleId)
170 172
@@ -586,9 +588,9 @@ function _M.openTimeBoxRpc(agent, data) @@ -586,9 +588,9 @@ function _M.openTimeBoxRpc(agent, data)
586 else 588 else
587 local oldId, process, time = boxL[slot].id, boxL[slot].process, boxL[slot].time 589 local oldId, process, time = boxL[slot].id, boxL[slot].process, boxL[slot].time
588 local unitTime = globalCsv.box_key_time[oldId] * 60 590 local unitTime = globalCsv.box_key_time[oldId] * 60
589 - local doneCnt = math.floor((process + skynet.timex() - time) / unitTime) 591 + local doneCnt = time == 0 and 0 or math.floor((process + skynet.timex() - time) / unitTime)
590 if doneCnt > 0 then 592 if doneCnt > 0 then
591 - reward = role:award({[oldId] = doneCnt}, {log = {desc = "openTimeBox", int1 = slot}}) 593 + reward = role:award({[oldId] = doneCnt}, {log = {desc = "openTimeBox", int1 = slot, int2 = oper}})
592 end 594 end
593 end 595 end
594 local limit = globalCsv.box_key_max[itemId] or 5 596 local limit = globalCsv.box_key_max[itemId] or 5
@@ -606,11 +608,11 @@ function _M.openTimeBoxRpc(agent, data) @@ -606,11 +608,11 @@ function _M.openTimeBoxRpc(agent, data)
606 local itemData = csvdb["itemCsv"][itemId] 608 local itemData = csvdb["itemCsv"][itemId]
607 local unitTime = globalCsv.box_key_time[itemId] * 60 609 local unitTime = globalCsv.box_key_time[itemId] * 60
608 if quick then 610 if quick then
609 - stopTime = time + globalCsv.box_productLine_time * 3600 611 + stopTime = nowTime + quick
610 local cost_pre = globalCsv.box_timeOpen_diamond:toArray(true, "=") 612 local cost_pre = globalCsv.box_timeOpen_diamond:toArray(true, "=")
611 - local costKey = math.ceil((stopTime - nowTime) / (cost_pre[1] * 60)) * cost_pre[2] 613 + local costKey = math.ceil(quick / (cost_pre[1] * 60)) * cost_pre[2]
612 if not role:checkItemEnough({[ItemId.Diamond] = costKey}) then return 5 end 614 if not role:checkItemEnough({[ItemId.Diamond] = costKey}) then return 5 end
613 - role:costItems({[ItemId.Diamond] = costKey}, {log = {desc = "openTimeBox", int1 = slot}}) 615 + role:costItems({[ItemId.Diamond] = costKey}, {log = {desc = "openTimeBox", int1 = slot, int2 = oper}})
614 else 616 else
615 stopTime = math.min(nowTime,time + globalCsv.box_productLine_time * 3600) 617 stopTime = math.min(nowTime,time + globalCsv.box_productLine_time * 3600)
616 end 618 end
@@ -618,7 +620,7 @@ function _M.openTimeBoxRpc(agent, data) @@ -618,7 +620,7 @@ function _M.openTimeBoxRpc(agent, data)
618 620
619 local doneCnt = math.floor((process + stopTime - time) / unitTime) 621 local doneCnt = math.floor((process + stopTime - time) / unitTime)
620 if doneCnt > 0 then 622 if doneCnt > 0 then
621 - reward = role:award({[itemId] = doneCnt}, {log = {desc = "openTimeBox", int1 = slot}}) 623 + reward = role:award({[itemId] = doneCnt}, {log = {desc = "openTimeBox", int1 = slot, int2 = oper}})
622 end 624 end
623 if role:getItemCount(itemId) >= globalCsv.box_key_max[itemId] then 625 if role:getItemCount(itemId) >= globalCsv.box_key_max[itemId] then
624 nowTime = 0 626 nowTime = 0
@@ -687,7 +689,7 @@ function _M.openTimeBoxRpc(agent, data) @@ -687,7 +689,7 @@ function _M.openTimeBoxRpc(agent, data)
687 reward[id] = (reward[id] or 0) + num 689 reward[id] = (reward[id] or 0) + num
688 end 690 end
689 end 691 end
690 - reward, change = role:award(reward, {log = {desc = "openTimeBox", int1 = costId}}) 692 + reward, change = role:award(reward, {log = {desc = "openTimeBox", int1 = costId, int2 = oper}})
691 else 693 else
692 return 694 return
693 end 695 end
@@ -847,6 +849,13 @@ function _M.taskRpc(agent, data) @@ -847,6 +849,13 @@ function _M.taskRpc(agent, data)
847 local reward, change = role:award(taskData.reward, {log = {desc = "finishTask", int1 = taskType, int2 = taskId}}) 849 local reward, change = role:award(taskData.reward, {log = {desc = "finishTask", int1 = taskType, int2 = taskId}})
848 local active = (taskStatus["a"] or 0) + taskData.active 850 local active = (taskStatus["a"] or 0) + taskData.active
849 851
  852 + -- 日常活动完成
  853 + if taskType == 1 then
  854 + role:checkTaskEnter("DailyTask", {pre = (taskStatus["a"] or 0), cur = active})
  855 + else
  856 + role:checkTaskEnter("WeekTask", {pre = (taskStatus["a"] or 0), cur = active})
  857 + end
  858 +
850 role:changeUpdates({ 859 role:changeUpdates({
851 { type = roleField[taskType], field = {"t", taskId}, value = -1 }, 860 { type = roleField[taskType], field = {"t", taskId}, value = -1 },
852 { type = roleField[taskType], field = "a", value = active}, 861 { type = roleField[taskType], field = "a", value = active},
@@ -907,62 +916,96 @@ function _M.achiveRpc(agent, data) @@ -907,62 +916,96 @@ function _M.achiveRpc(agent, data)
907 local taskId = msg.id --任务id 916 local taskId = msg.id --任务id
908 917
909 if not role:isFuncUnlock(FuncUnlock.TaskAchiv) then return end 918 if not role:isFuncUnlock(FuncUnlock.TaskAchiv) then return end
910 -  
911 - local achiveTask = csvdb["achievementCsv"][taskId]  
912 - if not achiveTask then return 1 end  
913 -  
914 local achiveT = role:getProperty("achiveT") 919 local achiveT = role:getProperty("achiveT")
915 local achiveV = role:getProperty("achiveV") 920 local achiveV = role:getProperty("achiveV")
  921 + local fuxRecord = role:getProperty("fuxR") or 0
  922 +
  923 + local groups = {}
  924 +
  925 + if not taskId then
  926 + local awards = {}
  927 + for id, cfg in pairs(csvdb["achievementCsv"]) do
  928 + -- 没领过
  929 + if not achiveV[id] then
  930 + if (achiveT[cfg.type] or 0) >= cfg.condition1 then
  931 + local award = cfg.reward:toNumMap()
  932 + for k, v in pairs(award) do
  933 + awards[k] = (awards[k] or 0) + v
  934 + end
  935 + achiveV[id] = skynet.timex()
  936 + groups[cfg.group] = 1
  937 +
  938 + role:log("achievement", {
  939 + achievement_id = cfg.id, -- 成就id
  940 + achievement_type = cfg.type, -- 成就类型,具体枚举表中成就类型枚举表
  941 + achievement_reward = award, -- 达成成就奖励,json格式记录,{"itemid1":123,"itemid2":12,……….}
  942 + })
  943 + end
  944 + end
  945 + end
  946 + if not next(awards) then
  947 + return 5
  948 + end
  949 + local reward, change = role:award(awards, {log = {desc = "finishAchive", int1 = 0}})
  950 + role:updateProperty({field = "achiveV", value = achiveV})
916 951
917 - if achiveV[taskId] then return 2 end 952 + SendPacket(actionCodes.Role_achiveRpc, MsgPack.pack(role:packReward(reward, change)))
  953 + else
  954 + local achiveTask = csvdb["achievementCsv"][taskId]
  955 + if not achiveTask then return 1 end
918 956
919 - local curStatus = achiveT[achiveTask.type] or 0  
920 - local maxc = achiveTask.condition1 957 + if achiveV[taskId] then return 2 end
921 958
922 - if maxc > curStatus then  
923 - return 3  
924 - end 959 + local curStatus = achiveT[achiveTask.type] or 0
  960 + local maxc = achiveTask.condition1
925 961
926 - local reward, change = role:award(achiveTask.reward, {log = {desc = "finishAchive", int1 = taskId}})  
927 - role:changeUpdates({  
928 - { type = "achiveV", field = taskId, value = skynet.timex() }  
929 - }) 962 + if maxc > curStatus then
  963 + return 3
  964 + end
930 965
931 - -- 复兴奖励  
932 - if csvdb["achievement_groupCsv"][achiveTask.group].bookmark == 3 then  
933 - local overCount = 0  
934 - for tId, status in pairs(achiveV) do  
935 - local tData = csvdb["achievementCsv"][tId]  
936 - if tData then  
937 - local groupData = csvdb["achievement_groupCsv"][tData.group]  
938 - if groupData.bookmark == 3 then  
939 - overCount = overCount + 1 966 + local reward, change = role:award(achiveTask.reward, {log = {desc = "finishAchive", int1 = taskId}})
  967 + role:changeUpdates({
  968 + { type = "achiveV", field = taskId, value = skynet.timex() }
  969 + })
  970 + groups[achiveTask.group] = 1
  971 +
  972 + role:log("achievement", {
  973 + achievement_id = taskId, -- 成就id
  974 + achievement_type = achiveTask.type, -- 成就类型,具体枚举表中成就类型枚举表
  975 + achievement_reward = reward, -- 达成成就奖励,json格式记录,{"itemid1":123,"itemid2":12,……….}
  976 + })
  977 +
  978 + SendPacket(actionCodes.Role_achiveRpc, MsgPack.pack(role:packReward(reward, change)))
  979 + end
  980 +
  981 + for group, _ in pairs(groups) do
  982 + -- 复兴奖励
  983 + if csvdb["achievement_groupCsv"][group].bookmark == 3 then
  984 + local overCount = 0
  985 + local preMaxCount = fuxRecord or 0
  986 + for tId, status in pairs(achiveV) do
  987 + local tData = csvdb["achievementCsv"][tId]
  988 + if tData then
  989 + local groupData = csvdb["achievement_groupCsv"][tData.group]
  990 + if groupData.bookmark == 3 then
  991 + overCount = overCount + 1
  992 + end
940 end 993 end
941 end 994 end
942 - end  
943 -  
944 - for level, pData in pairs(csvdb["achievement_rewardCsv"]) do  
945 - if pData.request == overCount then  
946 - -- 发放奖励  
947 - redisproxy:insertEmail({  
948 - roleId = role:getProperty("id"),  
949 - emailId = 101,  
950 - attachments = pData.reward,  
951 - contentPms = {pData.level},  
952 - })  
953 - elseif pData.request > overCount then  
954 - break 995 + local flag = false
  996 + for level, pData in pairs(csvdb["achievement_rewardCsv"]) do
  997 + if preMaxCount < pData.request and overCount >= pData.request then
  998 + role:sendMail(101, skynet.timex(), pData.reward, {pData.level})
  999 + flag = true
  1000 + end
955 end 1001 end
  1002 + if flag then
  1003 + role:updateProperty({field = "fuxR", value = overCount, notNotify = true})
  1004 + end
  1005 + break
956 end 1006 end
957 end 1007 end
958 -  
959 - role:log("achievement", {  
960 - achievement_id = taskId, -- 成就id  
961 - achievement_type = achiveTask.type, -- 成就类型,具体枚举表中成就类型枚举表  
962 - achievement_reward = reward, -- 达成成就奖励,json格式记录,{"itemid1":123,"itemid2":12,……….}  
963 - })  
964 1008
965 - SendPacket(actionCodes.Role_achiveRpc, MsgPack.pack(role:packReward(reward, change)))  
966 return true 1009 return true
967 end 1010 end
968 1011
@@ -1013,6 +1056,10 @@ function _M.chatRpc(agent, data) @@ -1013,6 +1056,10 @@ function _M.chatRpc(agent, data)
1013 result = 1 1056 result = 1
1014 return 1057 return
1015 end 1058 end
  1059 + if role:getProperty("level") < (globalCsv.chat_level or 15) then
  1060 + result = 3
  1061 + return
  1062 + end
1016 1063
1017 role._worldChatLimit = role._worldChatLimit or {start = 0, count = 0, canSayt = 0} --第一次开始说话时间 从第一次说话次数 能说话的时间 1064 role._worldChatLimit = role._worldChatLimit or {start = 0, count = 0, canSayt = 0} --第一次开始说话时间 从第一次说话次数 能说话的时间
1018 1065
src/actions/StoreAction.lua
@@ -310,6 +310,13 @@ function _M.getFreeChestRpc(agent, data) @@ -310,6 +310,13 @@ function _M.getFreeChestRpc(agent, data)
310 local config = csvdb["shop_rechargeCsv"][id] 310 local config = csvdb["shop_rechargeCsv"][id]
311 if not config then return end 311 if not config then return end
312 312
  313 + --判断是否是活动商品
  314 + if config.activity_id ~= 0 then
  315 + local actCfg = csvdb["activity_ctrlCsv"][config.activity_id]
  316 + if not actCfg then return 2 end
  317 + if not role.activity:isOpenById(config.activity_id, "ActShopGoods") then return 3 end
  318 + end
  319 +
313 local rechargeRecord = role.storeData:getProperty("payR") 320 local rechargeRecord = role.storeData:getProperty("payR")
314 local getCount = (rechargeRecord[id] or 0) 321 local getCount = (rechargeRecord[id] or 0)
315 if getCount >= config.limit then 322 if getCount >= config.limit then
src/actions/TowerAction.lua
@@ -65,6 +65,15 @@ function _M.endBattleRpc(agent, data) @@ -65,6 +65,15 @@ function _M.endBattleRpc(agent, data)
65 local curTower = csvdb["tower_battleCsv"][id] 65 local curTower = csvdb["tower_battleCsv"][id]
66 if not curTower then return 2 end 66 if not curTower then return 2 end
67 67
  68 + -- 防作弊
  69 + if not role:checkBattleCheat("tower", {
  70 + isWin = msg.starNum and msg.starNum > 0,
  71 + info = msg.info
  72 + }) then
  73 + SendPacket(actionCodes.Tower_endBattleRpc, MsgPack.pack({errorCode = 1}))
  74 + return true
  75 + end
  76 +
68 local curCount, nextTime = getUpdateTime(towerInfo.c, towerInfo.t) 77 local curCount, nextTime = getUpdateTime(towerInfo.c, towerInfo.t)
69 78
70 79
@@ -20,8 +20,6 @@ function Adv:ctor(owner) @@ -20,8 +20,6 @@ function Adv:ctor(owner)
20 self.advTask = self.owner:getProperty("advTask") 20 self.advTask = self.owner:getProperty("advTask")
21 self.advMTask = self.owner:getProperty("advMTask") 21 self.advMTask = self.owner:getProperty("advMTask")
22 self.advTaskChange = false -- 任务改变才更新 22 self.advTaskChange = false -- 任务改变才更新
23 -  
24 - self:initByInfo(self.owner:getProperty("advInfo"))  
25 end 23 end
26 24
27 function Adv:mylog(contents) 25 function Adv:mylog(contents)
@@ -36,11 +34,13 @@ function Adv:mylog(contents) @@ -36,11 +34,13 @@ function Adv:mylog(contents)
36 end 34 end
37 35
38 --初始化adv 信息 36 --初始化adv 信息
39 -function Adv:initByInfo(advInfo) 37 +function Adv:initByInfo()
  38 + local advInfo = self.owner:getProperty("advInfo")
40 if not next(advInfo) then return end --还没有 开始新地图 39 if not next(advInfo) then return end --还没有 开始新地图
41 40
42 self.chapterId = advInfo.chapterId 41 self.chapterId = advInfo.chapterId
43 self.level = advInfo.level or 1 42 self.level = advInfo.level or 1
  43 + self.actid = advInfo.actid
44 self.round = advInfo.round or 0 44 self.round = advInfo.round or 0
45 self.score = advInfo.score or {} 45 self.score = advInfo.score or {}
46 self.isRelay = advInfo.isRelay 46 self.isRelay = advInfo.isRelay
@@ -61,10 +61,10 @@ function Adv:initByInfo(advInfo) @@ -61,10 +61,10 @@ function Adv:initByInfo(advInfo)
61 self:initBattle(advInfo) 61 self:initBattle(advInfo)
62 end 62 end
63 -- 找出level 是否存在中继层 63 -- 找出level 是否存在中继层
64 -function Adv:isHaveRelay(level, chapterId) 64 +function Adv:isHaveRelay(level, chapterId, force)
65 level = level or self.level 65 level = level or self.level
66 chapterId = chapterId or self.chapterId 66 chapterId = chapterId or self.chapterId
67 - if level == 1 then return end 67 + if level == 1 and not force then return end
68 68
69 local campsiteCsv = csvdb["adv_chapter_campsiteCsv"][chapterId] 69 local campsiteCsv = csvdb["adv_chapter_campsiteCsv"][chapterId]
70 for _, campsite in ipairs(campsiteCsv) do 70 for _, campsite in ipairs(campsiteCsv) do
@@ -85,6 +85,7 @@ function Adv:initByChapter(params) @@ -85,6 +85,7 @@ function Adv:initByChapter(params)
85 local isEnter = params.isEnter 85 local isEnter = params.isEnter
86 local support = params.support 86 local support = params.support
87 local debugMapId = params.debugMapId 87 local debugMapId = params.debugMapId
  88 + local actid = params.actid
88 89
89 if not self.chapterId then -- 开始新的章节 90 if not self.chapterId then -- 开始新的章节
90 self.chapterId = chapterId 91 self.chapterId = chapterId
@@ -95,6 +96,7 @@ function Adv:initByChapter(params) @@ -95,6 +96,7 @@ function Adv:initByChapter(params)
95 96
96 self.level = level or 1 97 self.level = level or 1
97 self.round = 0 98 self.round = 0
  99 + self.actid = self.actid or actid
98 self.score = self.score or {} 100 self.score = self.score or {}
99 self.lastEnemyId = 1 101 self.lastEnemyId = 1
100 self.mapStack = {1} -- 最后一个为当前的地图 102 self.mapStack = {1} -- 最后一个为当前的地图
@@ -140,12 +142,13 @@ function Adv:initByChapter(params) @@ -140,12 +142,13 @@ function Adv:initByChapter(params)
140 local chapter = self:isEndless() and -1 or self.chapterId 142 local chapter = self:isEndless() and -1 or self.chapterId
141 if not (advRelay[chapter] or {})[self.level] then 143 if not (advRelay[chapter] or {})[self.level] then
142 isNewRelay = true 144 isNewRelay = true
143 - advRelay[chapter] = advRelay[chapter] or {}  
144 - advRelay[chapter][self.level] = 1  
145 - self.owner:updateProperty({field = "advRelay", value = advRelay})  
146 end 145 end
147 end 146 end
148 147
  148 + if self.level == 1 or self.isRelay then
  149 + self:supplyPotion()
  150 + end
  151 +
149 self.maps = {} 152 self.maps = {}
150 self.maps[1] = AdvMap.new(self, 1, mapId, isEnter, isNewRelay) 153 self.maps[1] = AdvMap.new(self, 1, mapId, isEnter, isNewRelay)
151 154
@@ -153,8 +156,6 @@ function Adv:initByChapter(params) @@ -153,8 +156,6 @@ function Adv:initByChapter(params)
153 156
154 self:initLayerTask() 157 self:initLayerTask()
155 158
156 -  
157 -  
158 self:checkTask(Adv.TaskType.Arrive) 159 self:checkTask(Adv.TaskType.Arrive)
159 self:checkAdvUnlock(1, self.level) 160 self:checkAdvUnlock(1, self.level)
160 161
@@ -168,9 +169,24 @@ function Adv:initByChapter(params) @@ -168,9 +169,24 @@ function Adv:initByChapter(params)
168 end 169 end
169 end 170 end
170 171
  172 +function Adv:passAdvRelay()
  173 + local advRelay = self.owner:getProperty("advRelay")
  174 + local chapter = self:isEndless() and -1 or self.chapterId
  175 + if not (advRelay[chapter] or {})[self.level] then
  176 + advRelay[chapter] = advRelay[chapter] or {}
  177 + advRelay[chapter][self.level] = 1
  178 + self.owner:updateProperty({field = "advRelay", value = advRelay})
  179 + local relayData = self:isHaveRelay()
  180 + if relayData and relayData.award ~= "" then
  181 + self:pushBackEvent(AdvBackEventType.RelayReward, {items = self:award(relayData.award:toNumMap(), {log = {desc = "relayReward"}})})
  182 + end
  183 + end
  184 +end
  185 +
171 function Adv:clear() 186 function Adv:clear()
172 self.chapterId = nil 187 self.chapterId = nil
173 self.level = nil 188 self.level = nil
  189 + self.actid = nil
174 self.score = {} 190 self.score = {}
175 self.round = 0 191 self.round = 0
176 self.lastEnemyId = 1 192 self.lastEnemyId = 1
@@ -193,6 +209,7 @@ function Adv:saveDB(notNotify) @@ -193,6 +209,7 @@ function Adv:saveDB(notNotify)
193 advInfo.level = self.level 209 advInfo.level = self.level
194 advInfo.round = self.round 210 advInfo.round = self.round
195 advInfo.score = self.score 211 advInfo.score = self.score
  212 + advInfo.actid = self.actid
196 advInfo.isRelay = self.isRelay 213 advInfo.isRelay = self.isRelay
197 advInfo.lastEId = self.lastEnemyId 214 advInfo.lastEId = self.lastEnemyId
198 advInfo.mstack = self.mapStack 215 advInfo.mstack = self.mapStack
@@ -389,18 +406,24 @@ function Adv:isRunning() @@ -389,18 +406,24 @@ function Adv:isRunning()
389 return false 406 return false
390 end 407 end
391 408
392 --- 强制结束  
393 -function Adv:forceOver(notNotify)  
394 - if self:isRunning() then  
395 - 409 +-- 强制结束 逻辑和adv内部无关
  410 +function Adv:forceOver(notNotify, force)
  411 + if self:isRunning() or force then
396 local advTeam = self.owner:getProperty("advTeam") 412 local advTeam = self.owner:getProperty("advTeam")
397 advTeam.player = nil 413 advTeam.player = nil
398 414
  415 + local advPotionCsv = csvdb["adv_potionCsv"]
  416 + local potionBag = self.owner:getProperty("potionBag")
  417 +
399 local reward = self.owner:getProperty("advItems"):toNumMap() 418 local reward = self.owner:getProperty("advItems"):toNumMap()
400 for itemId, count in pairs(reward) do 419 for itemId, count in pairs(reward) do
401 - reward[itemId] = math.ceil(count * globalCsv.adv_fail_reward_ratio / 100) -- 奖励相当于失败 420 + if advPotionCsv[itemId] then
  421 + potionBag[itemId] = (potionBag[itemId] or 0) + count
  422 + else
  423 + reward[itemId] = math.ceil(count * globalCsv.adv_fail_reward_ratio / 100) -- 奖励相当于失败
  424 + end
402 end 425 end
403 - self.owner:award(reward, {log = {desc = "advOver", int1 = self.chapterId}}) 426 + self.owner:award(reward, {log = {desc = "advOver", int1 = self.chapterId}, notNotify = notNotify})
404 427
405 self:clear() 428 self:clear()
406 self.owner:updateProperties({ 429 self.owner:updateProperties({
@@ -409,6 +432,7 @@ function Adv:forceOver(notNotify) @@ -409,6 +432,7 @@ function Adv:forceOver(notNotify)
409 advItems = "", 432 advItems = "",
410 advAFGet = {}, 433 advAFGet = {},
411 advAFWear = {}, 434 advAFWear = {},
  435 + potionBag = potionBag,
412 }, notNotify) 436 }, notNotify)
413 end 437 end
414 end 438 end
@@ -752,6 +776,10 @@ function Adv:isEndless() @@ -752,6 +776,10 @@ function Adv:isEndless()
752 return AdvCommon.isEndless(self.chapterId) 776 return AdvCommon.isEndless(self.chapterId)
753 end 777 end
754 778
  779 +function Adv:isActivity()
  780 + return self.actid ~= nil
  781 +end
  782 +
755 function Adv:getCurFloorData() 783 function Adv:getCurFloorData()
756 local chapter = self.chapterId % 100 784 local chapter = self.chapterId % 100
757 return (csvdb["adv_chapter_floorCsv"][self.chapterId] or {})[self.level] 785 return (csvdb["adv_chapter_floorCsv"][self.chapterId] or {})[self.level]
@@ -781,17 +809,69 @@ function Adv:over(success, rewardRatio, overType) @@ -781,17 +809,69 @@ function Adv:over(success, rewardRatio, overType)
781 809
782 local score = self.owner:fixAdvScoreChange(self:getScore()) 810 local score = self.owner:fixAdvScoreChange(self:getScore())
783 local scoreInfo = self.score 811 local scoreInfo = self.score
  812 +
  813 + local scoreCoef = chapterData.scoreAward
  814 + local itemId = ItemId.OldCoin
  815 + -- 拾荒活动关卡相关处理
  816 + if self.actid then
  817 + while true do
  818 + if not self.owner.activity:isOpenById(self.actid, "AdvLevel") then
  819 + break
  820 + end
  821 + local actCfg = csvdb["activity_adv_chapterCsv"][self.actid]
  822 + if not actCfg then break end
  823 + actCfg = actCfg[self.chapterId]
  824 + if not actCfg then break end
  825 + local arr = actCfg["transform"]:toArray(true, "=")
  826 + itemId, scoreCoef = arr[1], arr[2]
  827 + local actData = self.owner.activity:getActData("AdvLevel")
  828 +
  829 + -- 计算活动积分up
  830 + local upMap = actCfg["upCharacter"]
  831 + local team = self.owner:getProperty("advTeam")
  832 + local format = self.owner:getTeamHerosInfo(team).heros
  833 + local upVal = 0
  834 + for _, hero in pairs(format) do
  835 + local heroId = hero["type"]
  836 + upVal = upVal + (upMap[heroId] or 0)
  837 + end
  838 + score = math.floor(score * (1 + upVal / 100))
  839 +
  840 + local advInfo = actData[self.chapterId] or {}
  841 + --print("upVal", upVal, score, advInfo["max"], itemId, scoreCoef)
  842 + local maxScore = advInfo["max"] or 0
  843 + local flag = false
  844 + if success then
  845 + advInfo["pass"] = 1
  846 + flag = true
  847 + end
  848 + -- 更新活动最大积分
  849 + if score > maxScore then
  850 + advInfo["max"] = score
  851 + actData[self.chapterId] = advInfo
  852 + flag = true
  853 + end
  854 + if flag then
  855 + self.owner.activity:updateActData("AdvLevel", actData)
  856 + end
  857 + break
  858 + end
  859 + end
784 860
785 - local scoreReward = math.floor(score / chapterData.scoreAward)  
786 - self.owner:award({[ItemId.OldCoin] = scoreReward}, {log = {desc = "advOver", int1 = self.chapterId}}) 861 + local scoreReward = math.floor(score / scoreCoef)
  862 + self.owner:award({[itemId] = scoreReward}, {log = {desc = "advOver", int1 = self.chapterId}})
787 863
788 -- 被动技会影响奖励 864 -- 被动技会影响奖励
789 self.battle.player:triggerPassive(Passive.ADV_OVER, {score = score, level = self.level}) 865 self.battle.player:triggerPassive(Passive.ADV_OVER, {score = score, level = self.level})
790 866
791 local reward = {} 867 local reward = {}
  868 + local advPotionCsv = csvdb["adv_potionCsv"]
  869 + local potionBag = self.owner:getProperty("potionBag")
792 for itemId, count in pairs(self.owner:getProperty("advItems"):toNumMap()) do 870 for itemId, count in pairs(self.owner:getProperty("advItems"):toNumMap()) do
793 local itemCsv = csvdb["itemCsv"][itemId] 871 local itemCsv = csvdb["itemCsv"][itemId]
794 - if not itemCsv then 872 + if advPotionCsv[itemId] then
  873 + potionBag[itemId] = (potionBag[itemId] or 0) + count
  874 + elseif not itemCsv then
795 print("ERROR: no itemId in ItemCsv : ", itemId) 875 print("ERROR: no itemId in ItemCsv : ", itemId)
796 elseif itemCsv.type ~= ItemType.AdvItem then 876 elseif itemCsv.type ~= ItemType.AdvItem then
797 reward[itemId] = math.ceil(count * rewardRatio / 100) 877 reward[itemId] = math.ceil(count * rewardRatio / 100)
@@ -811,25 +891,27 @@ function Adv:over(success, rewardRatio, overType) @@ -811,25 +891,27 @@ function Adv:over(success, rewardRatio, overType)
811 if not self:isEndless() and self.level >= chapterData.limitlevel then 891 if not self:isEndless() and self.level >= chapterData.limitlevel then
812 self.owner:checkTaskEnter("AdvAllPass", {id = self.chapterId}) 892 self.owner:checkTaskEnter("AdvAllPass", {id = self.chapterId})
813 end 893 end
  894 + end
814 895
815 - local roleId = self.owner:getProperty("id")  
816 - local oldMaxScore = tonum(redisproxy:zscore(self.owner:getAdvRankKey(), roleId))  
817 - if score > oldMaxScore then  
818 - local team = self.owner:getProperty("advTeam")  
819 - local curInfo = {  
820 - name = self.owner:getProperty("name"),  
821 - headId = self.owner:getProperty("headId"),  
822 - lv = self.owner:getProperty("level"),  
823 - batteV = self.owner:getTeamBattleValue(team.heros),  
824 - chapter = self.chapterId,  
825 - format = self.owner:getTeamHerosInfo(team).heros,  
826 - }  
827 - redisproxy:pipelining(function (red)  
828 - red:zadd(self.owner:getAdvRankKey(), score, roleId) --更新分数  
829 - red:hset(RANK_ADV_INFO, roleId, MsgPack.pack(curInfo))  
830 - end)  
831 - end 896 +
  897 + local roleId = self.owner:getProperty("id")
  898 + local oldMaxScore = tonum(redisproxy:zscore(self.owner:getAdvRankKey(), roleId))
  899 + if score > oldMaxScore and not self.actid then
  900 + local team = self.owner:getProperty("advTeam")
  901 + local curInfo = {
  902 + name = self.owner:getProperty("name"),
  903 + headId = self.owner:getProperty("headId"),
  904 + lv = self.owner:getProperty("level"),
  905 + batteV = self.owner:getTeamBattleValue(team.heros),
  906 + chapter = self.chapterId,
  907 + format = self.owner:getTeamHerosInfo(team).heros,
  908 + }
  909 + redisproxy:pipelining(function (red)
  910 + red:zadd(self.owner:getAdvRankKey(), score, roleId) --更新分数
  911 + red:hset(RANK_ADV_INFO, roleId, MsgPack.pack(curInfo))
  912 + end)
832 end 913 end
  914 +
833 -- 通关的时候要把引导步骤设定到成就引导 915 -- 通关的时候要把引导步骤设定到成就引导
834 if not self.owner:checkOverGuide(57) then 916 if not self.owner:checkOverGuide(57) then
835 self.owner:saveGuide(57,1,true) 917 self.owner:saveGuide(57,1,true)
@@ -882,6 +964,7 @@ function Adv:over(success, rewardRatio, overType) @@ -882,6 +964,7 @@ function Adv:over(success, rewardRatio, overType)
882 }) 964 })
883 965
884 local chapterId = self.chapterId 966 local chapterId = self.chapterId
  967 + local actid = self.actid
885 self:clear() 968 self:clear()
886 self.owner:checkTaskEnter("AdvScore", {score = score}) 969 self.owner:checkTaskEnter("AdvScore", {score = score})
887 970
@@ -889,6 +972,7 @@ function Adv:over(success, rewardRatio, overType) @@ -889,6 +972,7 @@ function Adv:over(success, rewardRatio, overType)
889 advItems = "", 972 advItems = "",
890 advAFGet = {}, 973 advAFGet = {},
891 advAFWear = {}, 974 advAFWear = {},
  975 + potionBag = potionBag,
892 }) 976 })
893 self:pushBackEvent(AdvBackEventType.End, { 977 self:pushBackEvent(AdvBackEventType.End, {
894 success = success, 978 success = success,
@@ -899,6 +983,7 @@ function Adv:over(success, rewardRatio, overType) @@ -899,6 +983,7 @@ function Adv:over(success, rewardRatio, overType)
899 scoreAward = scoreReward, 983 scoreAward = scoreReward,
900 chapterId = chapterId, 984 chapterId = chapterId,
901 backAdvCount = backAdvCount, 985 backAdvCount = backAdvCount,
  986 + actid = actid
902 }) 987 })
903 end 988 end
904 989
@@ -963,7 +1048,7 @@ function Adv:award(gift, params, backRewardParams) @@ -963,7 +1048,7 @@ function Adv:award(gift, params, backRewardParams)
963 1048
964 local autoUse = {} 1049 local autoUse = {}
965 for itemId, count in pairs(tgift) do 1050 for itemId, count in pairs(tgift) do
966 - if count > 0 then 1051 + if count > 0 and self.battle.player then
967 local buffAdd = self.battle.player:getRewardChange(itemId) 1052 local buffAdd = self.battle.player:getRewardChange(itemId)
968 count = math.floor(math.max(0, (count + buffAdd[0]) * (1 + buffAdd[1]))) --附加 buff 的影响 1053 count = math.floor(math.max(0, (count + buffAdd[0]) * (1 + buffAdd[1]))) --附加 buff 的影响
969 self:checkTask(Adv.TaskType.Item, count, itemId) 1054 self:checkTask(Adv.TaskType.Item, count, itemId)
@@ -973,7 +1058,8 @@ function Adv:award(gift, params, backRewardParams) @@ -973,7 +1058,8 @@ function Adv:award(gift, params, backRewardParams)
973 if globalCsv.adv_auto_useItem[itemId] and count > 0 then 1058 if globalCsv.adv_auto_useItem[itemId] and count > 0 then
974 autoUse[itemId] = count 1059 autoUse[itemId] = count
975 else 1060 else
976 - local origin = items:getv(itemId, 0) 1061 + local transId = globalCsv.adv_item_potion[itemId] or itemId
  1062 + local origin = items:getv(transId, 0)
977 local nums = origin + count 1063 local nums = origin + count
978 1064
979 if csvdb["adv_artifactCsv"][itemId] then -- 获得神器 1065 if csvdb["adv_artifactCsv"][itemId] then -- 获得神器
@@ -983,10 +1069,10 @@ function Adv:award(gift, params, backRewardParams) @@ -983,10 +1069,10 @@ function Adv:award(gift, params, backRewardParams)
983 end 1069 end
984 else 1070 else
985 if nums <= 0 then 1071 if nums <= 0 then
986 - items = items:delk(itemId) 1072 + items = items:delk(transId)
987 nums = 0 1073 nums = 0
988 else 1074 else
989 - items = items:setv(itemId, nums) 1075 + items = items:setv(transId, nums)
990 end 1076 end
991 1077
992 if itemId == 16 and not self.owner:checkOverGuide(51,4) then 1078 if itemId == 16 and not self.owner:checkOverGuide(51,4) then
@@ -1064,6 +1150,7 @@ end @@ -1064,6 +1150,7 @@ end
1064 -- 消耗物品 优先冒险背包 --check 只是检查够不够 1150 -- 消耗物品 优先冒险背包 --check 只是检查够不够
1065 function Adv:cost(item, params, check) 1151 function Adv:cost(item, params, check)
1066 local items = self.owner:getProperty("advItems") 1152 local items = self.owner:getProperty("advItems")
  1153 + local potionCsv = csvdb["adv_potionCsv"]
1067 local less = {} 1154 local less = {}
1068 local advCost = {} 1155 local advCost = {}
1069 for itemId, count in pairs(item) do 1156 for itemId, count in pairs(item) do
@@ -1077,9 +1164,13 @@ function Adv:cost(item, params, check) @@ -1077,9 +1164,13 @@ function Adv:cost(item, params, check)
1077 less[itemId] = -last 1164 less[itemId] = -last
1078 end 1165 end
1079 1166
  1167 + if potionCsv[itemId] and last < 0 then -- 只能使用冒险背包里的药水
  1168 + return
  1169 + end
1080 end 1170 end
1081 if next(less) and not self.owner:checkItemEnough(less) then return end --不够 1171 if next(less) and not self.owner:checkItemEnough(less) then return end --不够
1082 if check then return true end 1172 if check then return true end
  1173 +
1083 self:award(advCost, params) 1174 self:award(advCost, params)
1084 if next(less) then 1175 if next(less) then
1085 self.owner:costItems(less, params) 1176 self.owner:costItems(less, params)
@@ -1087,6 +1178,34 @@ function Adv:cost(item, params, check) @@ -1087,6 +1178,34 @@ function Adv:cost(item, params, check)
1087 return true 1178 return true
1088 end 1179 end
1089 1180
  1181 +-- 补满冒险背包药剂,从药剂背包扣除药水放到冒险背包
  1182 +function Adv:supplyPotion()
  1183 + local potionCsv = csvdb["adv_potionCsv"]
  1184 + local potionBag = self.owner:getProperty("potionBag")
  1185 + local advItems = self.owner:getProperty("advItems")
  1186 + local dishTree = self.owner.dinerData:getProperty("dishTree")
  1187 + for potionId, set in pairs(potionCsv) do
  1188 + local count = potionBag[potionId] or 0
  1189 + if count > 0 then
  1190 + local max = set[dishTree:getv(potionId,1)].limit
  1191 + local old = advItems:getv(potionId,0)
  1192 + local need = max - old
  1193 +
  1194 + if need < count then
  1195 + advItems = advItems:setv(potionId,max)
  1196 + potionBag[potionId] = count - need
  1197 + else
  1198 + advItems = advItems:setv(potionId,old + count)
  1199 + potionBag[potionId] = nil
  1200 + end
  1201 + end
  1202 + end
  1203 + self.owner:updateProperties({
  1204 + advItems = advItems,
  1205 + potionBag = potionBag,
  1206 + })
  1207 +end
  1208 +
1090 --事件点击处理 1209 --事件点击处理
1091 local function clickOut(self, room, block, params, isExit) 1210 local function clickOut(self, room, block, params, isExit)
1092 if self:getCurMap():checkOver() then --检查是否可以出去了 1211 if self:getCurMap():checkOver() then --检查是否可以出去了
@@ -1112,6 +1231,11 @@ local function clickOut(self, room, block, params, isExit) @@ -1112,6 +1231,11 @@ local function clickOut(self, room, block, params, isExit)
1112 else 1231 else
1113 if self.level > (advPass[self.chapterId] or 0) then 1232 if self.level > (advPass[self.chapterId] or 0) then
1114 self.owner:changeUpdates({{type = "advPass", field = self.chapterId, value = self.level}}) 1233 self.owner:changeUpdates({{type = "advPass", field = self.chapterId, value = self.level}})
  1234 +
  1235 + if (self.level >= csvdb["adv_chapterCsv"][self.chapterId].limitlevel) then --关卡结束
  1236 + self.owner:checkTaskEnter("AdvPassFirst", {id = self.chapterId})
  1237 + end
  1238 +
1115 end 1239 end
1116 end 1240 end
1117 1241
@@ -1124,6 +1248,7 @@ local function clickOut(self, room, block, params, isExit) @@ -1124,6 +1248,7 @@ local function clickOut(self, room, block, params, isExit)
1124 end 1248 end
1125 1249
1126 if not self:isEndless() and (self.level >= csvdb["adv_chapterCsv"][self.chapterId].limitlevel) then --关卡结束 1250 if not self:isEndless() and (self.level >= csvdb["adv_chapterCsv"][self.chapterId].limitlevel) then --关卡结束
  1251 + self:passAdvRelay()
1127 self:over(true) 1252 self:over(true)
1128 else 1253 else
1129 self.battle.player:triggerPassive(Passive.DOWN_LAYER) 1254 self.battle.player:triggerPassive(Passive.DOWN_LAYER)
@@ -1168,24 +1293,22 @@ local function clickMonster(self, room, block, params) @@ -1168,24 +1293,22 @@ local function clickMonster(self, room, block, params)
1168 return true 1293 return true
1169 end 1294 end
1170 1295
1171 -local function chooseCommon(self, room, block, chooseData, choose, tag)  
1172 - if not choose then return end  
1173 - if not chooseData or not chooseData["button".. choose .."cond"] then return end  
1174 1296
1175 - local conds = chooseData["button".. choose .."cond"]:toTableArray(true) 1297 +local function checkChooseCondFunc(self, condStr, room, block, tag, chooseData)
  1298 + chooseData = chooseData or {}
1176 local checkCond = { 1299 local checkCond = {
1177 -- 没有条件 1300 -- 没有条件
1178 [0] = function() 1301 [0] = function()
1179 return true 1302 return true
1180 end, 1303 end,
1181 -- 拥有道具 1304 -- 拥有道具
1182 - [1] = function(_, itemId, count) 1305 + [1] = function(itemId, count)
1183 if self:cost({[itemId] = count}, {log = {desc = "chooseEvent", key1 = tag, int1 = chooseData.id}}, true) then 1306 if self:cost({[itemId] = count}, {log = {desc = "chooseEvent", key1 = tag, int1 = chooseData.id}}, true) then
1184 return true 1307 return true
1185 end 1308 end
1186 end, 1309 end,
1187 -- xx角色(todo 队长) 1310 -- xx角色(todo 队长)
1188 - [2] = function(_, heroType) 1311 + [2] = function(heroType)
1189 for slot, heroId in pairs(self.owner:getProperty("advTeam").heros) do 1312 for slot, heroId in pairs(self.owner:getProperty("advTeam").heros) do
1190 local hero = self.owner.heros[heroId] 1313 local hero = self.owner.heros[heroId]
1191 if hero and hero:getProperty("type") == heroType then 1314 if hero and hero:getProperty("type") == heroType then
@@ -1205,38 +1328,38 @@ local function chooseCommon(self, room, block, chooseData, choose, tag) @@ -1205,38 +1328,38 @@ local function chooseCommon(self, room, block, chooseData, choose, tag)
1205 return true 1328 return true
1206 end, 1329 end,
1207 --制定属性 1330 --制定属性
1208 - [4] = function(_, attrType, value) 1331 + [4] = function(attrType, value)
1209 if (self.battle.player[AttsEnumEx[attrType]] or 0) >= value then 1332 if (self.battle.player[AttsEnumEx[attrType]] or 0) >= value then
1210 return true 1333 return true
1211 end 1334 end
1212 end, 1335 end,
1213 -- 提交一个物品 1336 -- 提交一个物品
1214 - [5] = function (_, itemId, count) 1337 + [5] = function (itemId, count)
1215 if self:cost({[itemId] = count}, {log = {desc = "chooseEvent", key1 = tag, int1 = chooseData.id}}) then 1338 if self:cost({[itemId] = count}, {log = {desc = "chooseEvent", key1 = tag, int1 = chooseData.id}}) then
1216 self:backCost({[itemId] = count}) 1339 self:backCost({[itemId] = count})
1217 return true 1340 return true
1218 end 1341 end
1219 end, 1342 end,
1220 -- sp 到达指定值 1343 -- sp 到达指定值
1221 - [6] = function(_, value) 1344 + [6] = function(value)
1222 if self.battle.player.sp >= value then 1345 if self.battle.player.sp >= value then
1223 self.battle.player:changeSp(-value) 1346 self.battle.player:changeSp(-value)
1224 return true 1347 return true
1225 end 1348 end
1226 end, 1349 end,
1227 --7=拥有指定buff指定层数 1350 --7=拥有指定buff指定层数
1228 - [7] = function(_, buffId, layer) 1351 + [7] = function(buffId, layer)
1229 local buff = self.battle.player:getBuffById(buffId) 1352 local buff = self.battle.player:getBuffById(buffId)
1230 if buff and buff:getLayer() >= layer then 1353 if buff and buff:getLayer() >= layer then
1231 return true 1354 return true
1232 end 1355 end
1233 end, 1356 end,
1234 --8=拥有x神器 1357 --8=拥有x神器
1235 - [8] = function(_, artifactId) 1358 + [8] = function(artifactId)
1236 return self:isHaveArtifact(artifactId) 1359 return self:isHaveArtifact(artifactId)
1237 end, 1360 end,
1238 -- 9 = 生命值大于x% 1361 -- 9 = 生命值大于x%
1239 - [9] = function (_, value) 1362 + [9] = function (value)
1240 local cost = value / 100 * self.battle.player.hpMax 1363 local cost = value / 100 * self.battle.player.hpMax
1241 if self.battle.player.hp > cost then 1364 if self.battle.player.hp > cost then
1242 self.battle.player:hurt(cost, nil, {hurtType = 6, buffId = -1}) 1365 self.battle.player:hurt(cost, nil, {hurtType = 6, buffId = -1})
@@ -1244,16 +1367,27 @@ local function chooseCommon(self, room, block, chooseData, choose, tag) @@ -1244,16 +1367,27 @@ local function chooseCommon(self, room, block, chooseData, choose, tag)
1244 end 1367 end
1245 end, 1368 end,
1246 -- 10 = 未获得x神器 1369 -- 10 = 未获得x神器
1247 - [10] = function(_, artifactId) 1370 + [10] = function(artifactId)
1248 return not self:isHaveArtifact(artifactId) 1371 return not self:isHaveArtifact(artifactId)
1249 end, 1372 end,
1250 -- 11 = 地图上没有指定id 的怪 1373 -- 11 = 地图上没有指定id 的怪
1251 - [11] = function(_, monsterId)  
1252 - for _, room in pairs(self:getCurMap().rooms) do  
1253 - for _, block in pairs(room.blocks) do  
1254 - if block:isMonster() then 1374 + [11] = function(monsterId, size)
  1375 + if not size or size == 0 then
  1376 + for _, room in pairs(self:getCurMap().rooms) do
  1377 + for _, block in pairs(room.blocks) do
  1378 + if block:isMonster() then
  1379 + if not monsterId then return false end
  1380 + if block.event.id == monsterId then
  1381 + return false
  1382 + end
  1383 + end
  1384 + end
  1385 + end
  1386 + else
  1387 + for _, cblock in ipairs(self:getCurMap():getBlocksBySize(room.roomId, block.blockId, size)) do
  1388 + if cblock:isMonster() then
1255 if not monsterId then return false end 1389 if not monsterId then return false end
1256 - if block.event.id == monsterId then 1390 + if cblock.event.id == monsterId then
1257 return false 1391 return false
1258 end 1392 end
1259 end 1393 end
@@ -1262,12 +1396,23 @@ local function chooseCommon(self, room, block, chooseData, choose, tag) @@ -1262,12 +1396,23 @@ local function chooseCommon(self, room, block, chooseData, choose, tag)
1262 return true 1396 return true
1263 end, 1397 end,
1264 -- 12 = 地图上没有指定id 的建筑 1398 -- 12 = 地图上没有指定id 的建筑
1265 - [12] = function(_, buildId)  
1266 - for _, room in pairs(self:getCurMap().rooms) do  
1267 - for _, block in pairs(room.blocks) do  
1268 - if block:isBuild() then 1399 + [12] = function(buildId, size)
  1400 + if not size or size == 0 then
  1401 + for _, room in pairs(self:getCurMap().rooms) do
  1402 + for _, block in pairs(room.blocks) do
  1403 + if block:isBuild() then
  1404 + if not buildId then return false end
  1405 + if block.event.id == buildId then
  1406 + return false
  1407 + end
  1408 + end
  1409 + end
  1410 + end
  1411 + else
  1412 + for _, cblock in ipairs(self:getCurMap():getBlocksBySize(room.roomId, block.blockId, size)) do
  1413 + if cblock:isBuild() then
1269 if not buildId then return false end 1414 if not buildId then return false end
1270 - if block.event.id == buildId then 1415 + if cblock.event.id == buildId then
1271 return false 1416 return false
1272 end 1417 end
1273 end 1418 end
@@ -1276,12 +1421,23 @@ local function chooseCommon(self, room, block, chooseData, choose, tag) @@ -1276,12 +1421,23 @@ local function chooseCommon(self, room, block, chooseData, choose, tag)
1276 return true 1421 return true
1277 end, 1422 end,
1278 -- 13 = 地图上没有指定的 选择点 1423 -- 13 = 地图上没有指定的 选择点
1279 - [13] = function(_, chooseId)  
1280 - for _, room in pairs(self:getCurMap().rooms) do  
1281 - for _, block in pairs(room.blocks) do  
1282 - if block:isChoose() then 1424 + [13] = function(chooseId, size)
  1425 + if not size or size == 0 then
  1426 + for _, room in pairs(self:getCurMap().rooms) do
  1427 + for _, block in pairs(room.blocks) do
  1428 + if block:isChoose() then
  1429 + if not chooseId then return false end
  1430 + if block.event.id == chooseId then
  1431 + return false
  1432 + end
  1433 + end
  1434 + end
  1435 + end
  1436 + else
  1437 + for _, cblock in ipairs(self:getCurMap():getBlocksBySize(room.roomId, block.blockId, size)) do
  1438 + if cblock:isChoose() then
1283 if not chooseId then return false end 1439 if not chooseId then return false end
1284 - if block.event.id == chooseId then 1440 + if cblock.event.id == chooseId then
1285 return false 1441 return false
1286 end 1442 end
1287 end 1443 end
@@ -1290,138 +1446,175 @@ local function chooseCommon(self, room, block, chooseData, choose, tag) @@ -1290,138 +1446,175 @@ local function chooseCommon(self, room, block, chooseData, choose, tag)
1290 return true 1446 return true
1291 end, 1447 end,
1292 } 1448 }
1293 - for _, cond in ipairs(conds) do 1449 +
  1450 + local status, count = true, 0
  1451 + for _, cond in ipairs(condStr:toTableArray(true)) do
1294 assert(not cond[1] or checkCond[cond[1]], "error cond, event_" .. (tag or "choose") .. "Csv id :" .. block.event.id) 1452 assert(not cond[1] or checkCond[cond[1]], "error cond, event_" .. (tag or "choose") .. "Csv id :" .. block.event.id)
1295 - if cond[1] and not checkCond[cond[1]](table.unpack(cond)) then return end 1453 + if not checkCond[cond[1]](select(2, table.unpack(cond))) then
  1454 + status = false
  1455 + else
  1456 + count = count + 1
  1457 + end
1296 end 1458 end
1297 -  
1298 - local clearBlock = chooseData.keep ~= 1  
1299 - local effects = chooseData["button".. choose .."effect"]:toTableArray(true)  
1300 - for _, effect in ipairs(effects) do  
1301 - local doEffect = {  
1302 - [1] = function() -- 获得某道具N个  
1303 - local count = effect[3] or 1  
1304 - local reward = {}  
1305 - for i = 1, count do  
1306 - local dropData = csvdb["event_dropCsv"][effect[2]]  
1307 - if dropData then  
1308 - local item = dropData["range"]:randWeight(true)  
1309 - reward[item[1]] = (reward[item[1]] or 0) + item[2]  
1310 - else  
1311 - skynet.error(string.format("[ERROR]: event_dropCsv no id %s in %s id: %s", effect[2], tag, chooseData.id))  
1312 - end  
1313 - end  
1314 - self:award(reward, {log = {desc = "chooseEvent", key1 = tag, int1 = chooseData.id}}, {roomId = room.roomId, blockId = block.blockId})  
1315 - end,  
1316 - [2] = function() --获得冒险buff  
1317 - local layer = effect[3] or 1  
1318 - for i = 1, layer do  
1319 - self.battle.player:addBuff(effect[2])  
1320 - end  
1321 - end,  
1322 - [3] = function() --发现怪物  
1323 - self:getCurMap():addNewMonsterRand(effect[2], {room, block})  
1324 - self:pushBackEvent(AdvBackEventType.Monster, {id = effect[2]})  
1325 - clearBlock = false  
1326 - end,  
1327 - [4] = function() --无事发生  
1328 - end,  
1329 - [5] = function() --5=属性枚举=数值;直接增加玩家属性  
1330 - local attr  
1331 - if effect[3] == 0 then  
1332 - attr = "sp" 1459 + return status, count
  1460 +end
  1461 +
  1462 +local function doChooseEffect(self, effectStr, room, block, tag, chooseData)
  1463 + chooseData = chooseData or {}
  1464 + local clearBlock = true
  1465 + local doEffect = {
  1466 + [1] = function(dropId, count) -- 获得某道具N个
  1467 + count = count or 1
  1468 + local reward = {}
  1469 + for i = 1, count do
  1470 + local dropData = csvdb["event_dropCsv"][dropId]
  1471 + if dropData then
  1472 + local item = dropData["range"]:randWeight(true)
  1473 + reward[item[1]] = (reward[item[1]] or 0) + item[2]
1333 else 1474 else
1334 - attr = AttsEnumEx[effect[3]]  
1335 - if not AdvAttsEnum[attr] then return end 1475 + skynet.error(string.format("[ERROR]: event_dropCsv no id %s in %s id: %s", dropId, tag, chooseData.id))
1336 end 1476 end
1337 - self.battle.player:addBaseAttr(attr, effect[4], effect[2])  
1338 - end,  
1339 - [6] = function() -- 商店  
1340 - block:updateEvent({  
1341 - etype = AdvEventType.Trader,  
1342 - id = effect[2]  
1343 - })  
1344 - self:pushBackEvent(AdvBackEventType.Trader, {id = effect[2]})  
1345 - clearBlock = false  
1346 - end,  
1347 - [7] = function() -- 建筑  
1348 - block:updateEvent({  
1349 - etype = AdvEventType.Build,  
1350 - id = effect[2]  
1351 - })  
1352 - clearBlock = false  
1353 - end,  
1354 - [8] = function() -- 选择  
1355 - block:updateEvent({  
1356 - etype = AdvEventType.Choose,  
1357 - id = effect[2]  
1358 - })  
1359 - clearBlock = false  
1360 - end,  
1361 - [9] = function() -- click  
1362 - block:updateEvent({  
1363 - etype = AdvEventType.Click,  
1364 - id = effect[2]  
1365 - })  
1366 - clearBlock = false  
1367 - end,  
1368 - [10] = function() -- 陷阱  
1369 - block:updateEvent({  
1370 - etype = AdvEventType.Trap,  
1371 - id = effect[2]  
1372 - })  
1373 - clearBlock = false  
1374 - end,  
1375 - [11] = function() -- 获得神器  
1376 - self:waitChooseArtifact() --等待获取神器  
1377 - end,  
1378 - [12] = function()  
1379 - -- buffId  
1380 - local targers = self.battle.player:getTeam(2, nil, nil, true)  
1381 - for _, target in pairs(targers) do  
1382 - target:addBuff(effect[2]) 1477 + end
  1478 + self:award(reward, {log = {desc = "chooseEvent", key1 = tag, int1 = chooseData.id}}, {roomId = room.roomId, blockId = block.blockId})
  1479 + end,
  1480 + [2] = function(buffId, layer) --获得冒险buff
  1481 + self.battle.player:addBuff(buffId, nil, layer or 1)
  1482 + end,
  1483 + [3] = function(id) --发现怪物
  1484 + self:getCurMap():addNewMonsterRand(id, {room, block})
  1485 + self:pushBackEvent(AdvBackEventType.Monster, {id = id})
  1486 + clearBlock = false
  1487 + end,
  1488 + [4] = function() --无事发生
  1489 + end,
  1490 + [5] = function(addType, attrType, value) --5=属性枚举=数值;直接增加玩家属性
  1491 + local attr
  1492 + if attrType == 0 then
  1493 + attr = "sp"
  1494 + else
  1495 + attr = AttsEnumEx[attrType]
  1496 + if not AdvAttsEnum[attr] then return end
  1497 + end
  1498 + self.battle.player:addBaseAttr(attr, value, addType)
  1499 + end,
  1500 + [6] = function(id) -- 商店
  1501 + block:updateEvent({
  1502 + etype = AdvEventType.Trader,
  1503 + id = id
  1504 + })
  1505 + self:pushBackEvent(AdvBackEventType.Trader, {id = id})
  1506 + clearBlock = false
  1507 + end,
  1508 + [7] = function(id) -- 建筑
  1509 + block:updateEvent({
  1510 + etype = AdvEventType.Build,
  1511 + id = id
  1512 + })
  1513 + clearBlock = false
  1514 + end,
  1515 + [8] = function(id) -- 选择
  1516 + block:updateEvent({
  1517 + etype = AdvEventType.Choose,
  1518 + id = id
  1519 + })
  1520 + clearBlock = false
  1521 + end,
  1522 + [9] = function(id) -- click
  1523 + block:updateEvent({
  1524 + etype = AdvEventType.Click,
  1525 + id = id
  1526 + })
  1527 + clearBlock = false
  1528 + end,
  1529 + [10] = function(id) -- 陷阱
  1530 + block:updateEvent({
  1531 + etype = AdvEventType.Trap,
  1532 + id = id
  1533 + })
  1534 + clearBlock = false
  1535 + end,
  1536 + [11] = function() -- 获得神器
  1537 + self:waitChooseArtifact() --等待获取神器
  1538 + end,
  1539 + [12] = function(id)
  1540 + -- buffId
  1541 + local targers = self.battle.player:getTeam(2, nil, nil, true)
  1542 + for _, target in pairs(targers) do
  1543 + target:addBuff(id)
  1544 + end
  1545 + end,
  1546 + [13] = function() -- 显示地图
  1547 + self:getCurMap():showMap()
  1548 + self:backMapShow()
  1549 + end,
  1550 + [14] = function(eventType, eventId, count, stage) -- 指定地块召唤 指定类型的id
  1551 + local change = self:getCurMap():layEventToStage(eventType, eventId, count, stage)
  1552 + for _, one in ipairs(change) do
  1553 + if one[1].roomId == room.roomId and one[2].blockId == block.blockId then
  1554 + clearBlock = false
  1555 + else
  1556 + self:backBlockChange(one[1].roomId, one[2].blockId)
1383 end 1557 end
1384 - end,  
1385 - [13] = function() -- 显示地图  
1386 - self:getCurMap():showMap()  
1387 - self:backMapShow()  
1388 - end,  
1389 - [14] = function() -- 指定地块召唤 指定类型的id  
1390 - local change = self:getCurMap():layEventToStage(effect[2], effect[3], effect[4], effect[5])  
1391 - for _, one in ipairs(change) do  
1392 - if one[1].roomId == room.roomId and one[2].blockId == block.blockId then  
1393 - clearBlock = false  
1394 - else  
1395 - self:backBlockChange(one[1].roomId, one[2].blockId)  
1396 - end 1558 + end
  1559 + end,
  1560 + [15] = function(eventType, eventId, count) -- 移除指定事件
  1561 + local change = self:getCurMap():clearEventById(eventType, eventId, count)
  1562 + for _, one in ipairs(change) do
  1563 + if one[1].roomId == room.roomId and one[2].blockId == block.blockId then
  1564 + clearBlock = false
  1565 + else
  1566 + self:backBlockChange(one[1].roomId, one[2].blockId)
1397 end 1567 end
1398 - end,  
1399 - [15] = function() -- 移除指定事件  
1400 - local change = self:getCurMap():clearEventById(effect[2], effect[3], effect[4])  
1401 - for _, one in ipairs(change) do  
1402 - if one[1].roomId == room.roomId and one[2].blockId == block.blockId then  
1403 - clearBlock = false  
1404 - else  
1405 - self:backBlockChange(one[1].roomId, one[2].blockId)  
1406 - end 1568 + end
  1569 + end,
  1570 + [16] = function(eventTypeF, eventIdF, eventTypeT, eventIdT, count) -- 指定事件转移
  1571 + local change = self:getCurMap():eventChangeToOther(eventTypeF, eventIdF, eventTypeT, eventIdT, count)
  1572 + for _, one in ipairs(change) do
  1573 + if one[1].roomId == room.roomId and one[2].blockId == block.blockId then
  1574 + clearBlock = false
  1575 + else
  1576 + self:backBlockChange(one[1].roomId, one[2].blockId)
1407 end 1577 end
1408 - end,  
1409 - [16] = function() -- 指定事件转移  
1410 - local change = self:getCurMap():eventChangeToOther(effect[2], effect[3], effect[4], effect[5], effect[6])  
1411 - for _, one in ipairs(change) do  
1412 - if one[1].roomId == room.roomId and one[2].blockId == block.blockId then  
1413 - clearBlock = false  
1414 - else  
1415 - self:backBlockChange(one[1].roomId, one[2].blockId)  
1416 - end 1578 + end
  1579 + end,
  1580 + [17] = function(eventId)
  1581 + local diceCsv = csvdb["event_choose_diceCsv"][eventId]
  1582 + if not diceCsv then return end
  1583 + local weight = math.randomInt(1, 12)
  1584 + local sum = 0
  1585 + local needEffect = nil
  1586 + local pool = {}
  1587 + for _, v in ipairs(diceCsv) do
  1588 + local status, okCount = checkChooseCondFunc(self, v.cond, room, block, tag .. " dice", chooseData)
  1589 + pool[#pool + 1] = v.weight + okCount * v.weightUp
  1590 + sum = sum + pool[#pool + 1]
  1591 + if sum >= weight and not needEffect then
  1592 + -- 达成效果
  1593 + needEffect = v.effect
1417 end 1594 end
1418 - end,  
1419 - } 1595 + end
  1596 + if needEffect then
  1597 + self:pushBackEvent(AdvBackEventType.ChooseDice, {id = eventId, pool = pool, result = weight})
  1598 + clearBlock = doChooseEffect(self, needEffect, room, block, tag .. " dice", chooseData)
  1599 + end
  1600 + end,
  1601 + }
  1602 +
  1603 + for _, effect in ipairs(effectStr:toTableArray(true)) do
1420 assert(doEffect[effect[1]], "error effect, event_" .. (tag or "choose") .. "Csv id :" .. (block.event and block.event.id or 0) .. "effect " .. effect[1]) 1604 assert(doEffect[effect[1]], "error effect, event_" .. (tag or "choose") .. "Csv id :" .. (block.event and block.event.id or 0) .. "effect " .. effect[1])
1421 - doEffect[effect[1]]() 1605 + doEffect[effect[1]](select(2, table.unpack(effect)))
1422 end 1606 end
1423 - self:scoreChange(AdvScoreType.Event, chooseData.advScore) --增加加分 1607 + return clearBlock
  1608 +end
  1609 +
1424 1610
  1611 +local function chooseCommon(self, room, block, chooseData, choose, tag)
  1612 + if not choose then return end
  1613 + if not chooseData or not chooseData["button".. choose .."cond"] then return end
  1614 + if not checkChooseCondFunc(self, chooseData["button".. choose .."cond"], room, block, tag, chooseData) then return end
  1615 + local clearBlock = chooseData.keep ~= 1
  1616 + clearBlock = clearBlock and doChooseEffect(self, chooseData["button".. choose .."effect"], room, block, tag, chooseData)
  1617 + self:scoreChange(AdvScoreType.Event, chooseData.advScore) --增加加分
1425 return true, clearBlock 1618 return true, clearBlock
1426 end 1619 end
1427 1620
@@ -1675,12 +1868,6 @@ function Adv:clickBlock(roomId, blockId, params) @@ -1675,12 +1868,6 @@ function Adv:clickBlock(roomId, blockId, params)
1675 if not block.isOpen then 1868 if not block.isOpen then
1676 if self.isRelay or checkAroundBlocks() then --开放 1869 if self.isRelay or checkAroundBlocks() then --开放
1677 self:getCurMap():openBlock(roomId, blockId, true, true) 1870 self:getCurMap():openBlock(roomId, blockId, true, true)
1678 - if self.isRelay and self:getCurMap():isAllOpen() then -- 发放翻开的奖励  
1679 - local relayData = self:isHaveRelay()  
1680 - if relayData and relayData.award ~= "" then  
1681 - self:pushBackEvent(AdvBackEventType.RelayReward, {items = self:award(relayData.award:toNumMap(), {log = {desc = "relayReward"}})})  
1682 - end  
1683 - end  
1684 status = true 1871 status = true
1685 end 1872 end
1686 else 1873 else
@@ -2143,6 +2330,7 @@ function Adv:enemyDead(enemy, escape) @@ -2143,6 +2330,7 @@ function Adv:enemyDead(enemy, escape)
2143 self:checkAchievement(Adv.AchievType.KillBossNoBuff, 1) 2330 self:checkAchievement(Adv.AchievType.KillBossNoBuff, 1)
2144 self:checkAchievement(Adv.AchievType.KillBossWithMWeapon, 1) 2331 self:checkAchievement(Adv.AchievType.KillBossWithMWeapon, 1)
2145 self:checkAchievement(Adv.AchievType.KillBossWithAMWeapon, 1) 2332 self:checkAchievement(Adv.AchievType.KillBossWithAMWeapon, 1)
  2333 + self.owner:checkTaskEnter("AdvKillBoss")
2146 elseif monsterData.type == 3 then 2334 elseif monsterData.type == 3 then
2147 self:checkTask(Adv.TaskType.KillElite, 1, enemyId) 2335 self:checkTask(Adv.TaskType.KillElite, 1, enemyId)
2148 end 2336 end
src/adv/AdvBlock.lua
@@ -60,9 +60,9 @@ function Block:updateEvent(event, isInit) @@ -60,9 +60,9 @@ function Block:updateEvent(event, isInit)
60 end 60 end
61 self:randomEvent() 61 self:randomEvent()
62 end 62 end
63 - self:quickDrop()  
64 63
65 if not isInit and self.isOpen then 64 if not isInit and self.isOpen then
  65 + self:quickDrop()
66 local newet = self:getEventType() 66 local newet = self:getEventType()
67 if oldet ~= newet then 67 if oldet ~= newet then
68 local em = {} 68 local em = {}
src/adv/AdvMap.lua
@@ -272,6 +272,10 @@ function Map:openBlock(roomId, blockId, isPlayer, ignoreBack) @@ -272,6 +272,10 @@ function Map:openBlock(roomId, blockId, isPlayer, ignoreBack)
272 if not ignoreBack then 272 if not ignoreBack then
273 self.adv:backBlockChange(roomId, blockId) 273 self.adv:backBlockChange(roomId, blockId)
274 end 274 end
  275 +
  276 + if self.adv.isRelay and self:isAllOpen() then -- 发放翻开的奖励
  277 + self.adv:passAdvRelay()
  278 + end
275 end 279 end
276 return status 280 return status
277 end 281 end
src/adv/AdvPassive.lua
@@ -532,7 +532,7 @@ function Passive:effect8(dropId) @@ -532,7 +532,7 @@ function Passive:effect8(dropId)
532 end 532 end
533 533
534 --9=直接获得item(可在结算触发时使用) 534 --9=直接获得item(可在结算触发时使用)
535 -function Passive:effect9(itemId, triggerPms, ratio, max) 535 +function Passive:effect9(itemId, triggerPms, ratio, ratio2, max)
536 local cond = nil 536 local cond = nil
537 if self.passiveData.value == 0 then 537 if self.passiveData.value == 0 then
538 cond = triggerPms.score 538 cond = triggerPms.score
@@ -542,7 +542,7 @@ function Passive:effect9(itemId, triggerPms, ratio, max) @@ -542,7 +542,7 @@ function Passive:effect9(itemId, triggerPms, ratio, max)
542 return 542 return
543 end 543 end
544 if not cond then return end 544 if not cond then return end
545 - self.owner.battle.adv:award({[itemId] = math.floor(math.max(0, math.min(max, cond / ratio)))}, {log = {desc = "passive", int1 = self.id}}, {roomId = self.owner.roomId, blockId = self.owner.blockId}) 545 + self.owner.battle.adv:award({[itemId] = math.floor(math.max(0, math.min(max, cond / ratio * ratio2)))}, {log = {desc = "passive", int1 = self.id}}, {roomId = self.owner.roomId, blockId = self.owner.blockId})
546 end 546 end
547 547
548 --10=战斗额外掉落次数 548 --10=战斗额外掉落次数
1 -Subproject commit fb22d12670f863528582d09b9499198350902990 1 +Subproject commit 5c618b16315e74aaa111b3e84dbc4da3f7b3d699
src/models/Activity.lua
@@ -30,6 +30,15 @@ Activity.ActivityType = { @@ -30,6 +30,15 @@ Activity.ActivityType = {
30 ActShopGoods = 25, -- 活动商品 30 ActShopGoods = 25, -- 活动商品
31 31
32 Crisis = 26, -- 宝藏怪活动 32 Crisis = 26, -- 宝藏怪活动
  33 +
  34 + CommonSignIn = 28, --通用签到
  35 + FriendEnergy = 30, -- 好友互赠能量活动
  36 + AdvLevel = 33, -- 拾荒关卡
  37 + BattleCommand = 34, -- 战令活动
  38 + NewSign = 36, -- 活动签到,单独的签到界面
  39 + HeroBackFree = 37, -- 无损耗归还
  40 +
  41 + BattleCommandTask = 38, -- 战令任务活动
33 } 42 }
34 43
35 local function checkActivityType(activityType) 44 local function checkActivityType(activityType)
@@ -73,6 +82,14 @@ Activity.schema = { @@ -73,6 +82,14 @@ Activity.schema = {
73 82
74 act24 = {"table", {}, true}, -- 活动卡池 {id=repaynum} 83 act24 = {"table", {}, true}, -- 活动卡池 {id=repaynum}
75 act26 = {"table", {}}, -- {task = {id = count}, socre = {id = status}} 84 act26 = {"table", {}}, -- {task = {id = count}, socre = {id = status}}
  85 +
  86 + act28 = {"table", {}}, -- 每日活跃签到 {0=day, 1=1,2=1,3=1}
  87 + act30 = {"table", {}}, -- {magic = 0, limit = 0, reward = {id = 1, id = 1}, giveAE = {}, getAE = {}} 奖励字段1表示领取过奖励
  88 +
  89 + act33 = {"table", {}}, -- 拾荒关卡活动 {id={max=最大积分, pass=1}, r=""}
  90 +
  91 + act34 = {"table", {}}, -- 战令记录{unlock = 1, freeR = "", payR = "", lvl = 10, sum = 100}
  92 + act36 = {"table", {}}, -- 每日活跃签到 {0=day, 1=1,2=1,3=1}
76 } 93 }
77 94
78 function Activity:data() 95 function Activity:data()
@@ -91,7 +108,16 @@ function Activity:data() @@ -91,7 +108,16 @@ function Activity:data()
91 act18 = self:getProperty("act18"), 108 act18 = self:getProperty("act18"),
92 act19 = self:getProperty("act19"), 109 act19 = self:getProperty("act19"),
93 act20 = self:getProperty("act20"), 110 act20 = self:getProperty("act20"),
  111 + act24 = self:getProperty("act24"),
94 act26 = self:getProperty("act26"), 112 act26 = self:getProperty("act26"),
  113 +
  114 + act28 = self:getProperty("act28"),
  115 + act30 = self:getProperty("act30"),
  116 +
  117 + act33 = self:getProperty("act33"),
  118 +
  119 + act34 = self:getProperty("act34"),
  120 + act36 = self:getProperty("act36"),
95 } 121 }
96 end 122 end
97 123
@@ -445,8 +471,9 @@ activityFunc[Activity.ActivityType.PayBack] = { @@ -445,8 +471,9 @@ activityFunc[Activity.ActivityType.PayBack] = {
445 -- 英雄帖 471 -- 英雄帖
446 activityFunc[Activity.ActivityType.CalendaTask] = { 472 activityFunc[Activity.ActivityType.CalendaTask] = {
447 ["init"] = function(self, actType, isCrossDay, notify) 473 ["init"] = function(self, actType, isCrossDay, notify)
448 - local calTask = self.owner:getProperty("CalTask") 474 + local calTask = self.owner:getProperty("calTask")
449 calTask = {} 475 calTask = {}
  476 + self.owner:updateProperty({field="calTask", value=calTask})
450 local role = self.owner 477 local role = self.owner
451 local buildL = role.dinerData:getProperty("buildL") 478 local buildL = role.dinerData:getProperty("buildL")
452 local curLevel = buildL:getv(1, 1) 479 local curLevel = buildL:getv(1, 1)
@@ -470,8 +497,111 @@ activityFunc[Activity.ActivityType.CalendaTask] = { @@ -470,8 +497,111 @@ activityFunc[Activity.ActivityType.CalendaTask] = {
470 role:checkTaskEnter("RuneQualityCollect", {}) 497 role:checkTaskEnter("RuneQualityCollect", {})
471 498
472 end, 499 end,
473 - -- ["close"] = function(self, actType, notify)  
474 - -- end, 500 + ["crossDay"] = function(self, actType, notify, actId)
  501 + local actData = self.owner:getProperty("calTask") or {}
  502 + local record = actData["r"] or {}
  503 + local actCfg = csvdb["activity_taskCsv"][actId]
  504 + if not actCfg then return end
  505 + local change = false
  506 + for taskId, cfg in pairs(actCfg) do
  507 + if cfg["resetType"] == 1 then -- 每日重置
  508 + record[taskId] = nil
  509 + actData[taskId] = nil
  510 + change = true
  511 + end
  512 + end
  513 + if change then
  514 + self.owner:updateProperty({field="calTask", value=actData})
  515 + end
  516 + end,
  517 + ["crossWeek"] = function(self, actType, notify, actId)
  518 + local actData = self.owner:getProperty("calTask") or {}
  519 + local record = actData["r"] or {}
  520 + local actCfg = csvdb["activity_taskCsv"][actId]
  521 + if not actCfg then return end
  522 + local change = false
  523 + for taskId, cfg in pairs(actCfg) do
  524 + if cfg["resetType"] == 2 then -- 每周重置
  525 + record[taskId] = nil
  526 + actData[taskId] = nil
  527 + change = true
  528 + end
  529 + end
  530 + if change then
  531 + self.owner:updateProperty({field="calTask", value=actData})
  532 + end
  533 + end,
  534 + ["close"] = function(self, actType, notify)
  535 + self.owner:updateProperty({field="calTask", value={}})
  536 + end,
  537 +}
  538 +
  539 +-- 活动任务 仅供春节活动使用 防冲突
  540 +activityFunc[Activity.ActivityType.BattleCommandTask] = {
  541 + ["init"] = function(self, actType, isCrossDay, notify)
  542 + local bcTask = self.owner:getProperty("bcTask")
  543 + bcTask = {}
  544 + self.owner:updateProperty({field="bcTask", value=bcTask})
  545 + local role = self.owner
  546 + local buildL = role.dinerData:getProperty("buildL")
  547 + local curLevel = buildL:getv(1, 1)
  548 + role:checkTaskEnter("DinerLevelUp", {level = curLevel})
  549 +
  550 + role:checkTaskEnter("HeroLvlCollect", {})
  551 + role:checkTaskEnter("HeroQualityCollect", {})
  552 +
  553 + local curPopular = role.dinerData:getProperty("popular")
  554 + role:checkTaskEnter("DinerPopular", {count = curPopular})
  555 +
  556 + local rLevel = role:getProperty("level")
  557 + role:checkTaskEnter("RoleLevelUp", {level = rLevel})
  558 +
  559 + local towerInfo = role:getProperty("towerInfo")
  560 + role:checkTaskEnter("TowerPass", {level = towerInfo.l})
  561 + --"PvpWin"
  562 + --role:checkTaskEnter("HangPass", {id = 0})
  563 + role:checkCalendaTask(true, 15, 3)
  564 + role:checkTaskEnter("HeroStarCollect", {})
  565 + role:checkTaskEnter("RuneQualityCollect", {})
  566 +
  567 + end,
  568 + ["crossDay"] = function(self, actType, notify, actId)
  569 + local actData = self.owner:getProperty("bcTask") or {}
  570 + local record = actData["r"] or {}
  571 + local actCfg = csvdb["activity_taskCsv"][actId]
  572 + if not actCfg then return end
  573 + local change = false
  574 + for taskId, cfg in pairs(actCfg) do
  575 + if cfg["resetType"] == 1 then -- 每日充值
  576 + record[taskId] = nil
  577 + actData[taskId] = nil
  578 + change = true
  579 + end
  580 + end
  581 + if change then
  582 + self.owner:updateProperty({field="bcTask", value=actData})
  583 + end
  584 + end,
  585 + ["crossWeek"] = function(self, actType, notify, actId)
  586 + local actData = self.owner:getProperty("bcTask") or {}
  587 + local record = actData["r"] or {}
  588 + local actCfg = csvdb["activity_taskCsv"][actId]
  589 + if not actCfg then return end
  590 + local change = false
  591 + for taskId, cfg in pairs(actCfg) do
  592 + if cfg["resetType"] == 2 then -- 每周重置
  593 + record[taskId] = nil
  594 + actData[taskId] = nil
  595 + change = true
  596 + end
  597 + end
  598 + if change then
  599 + self.owner:updateProperty({field="bcTask", value=actData})
  600 + end
  601 + end,
  602 + ["close"] = function(self, actType, notify)
  603 + self.owner:updateProperty({field="bcTask", value={}})
  604 + end,
475 } 605 }
476 606
477 -- 兑换 607 -- 兑换
@@ -481,6 +611,9 @@ activityFunc[Activity.ActivityType.Exchange] = { @@ -481,6 +611,9 @@ activityFunc[Activity.ActivityType.Exchange] = {
481 actData[actId] = {} 611 actData[actId] = {}
482 self:updateActData(actType, actData, not notify) 612 self:updateActData(actType, actData, not notify)
483 end, 613 end,
  614 + ["login"] = function(self, actType, actId)
  615 + activityFunc[Activity.ActivityType.Exchange]["crossDay"](self, actType, true, actId)
  616 + end,
484 ["crossDay"] = function(self, actType, notify, actId) 617 ["crossDay"] = function(self, actType, notify, actId)
485 local actData = self:getActData(actType) or {} 618 local actData = self:getActData(actType) or {}
486 local lastTs = actData["ts"] or 0 619 local lastTs = actData["ts"] or 0
@@ -489,14 +622,14 @@ activityFunc[Activity.ActivityType.Exchange] = { @@ -489,14 +622,14 @@ activityFunc[Activity.ActivityType.Exchange] = {
489 if not cfg then return end 622 if not cfg then return end
490 local refreshTimes = cfg.condition2:toArray(false, "=") 623 local refreshTimes = cfg.condition2:toArray(false, "=")
491 for i = 1, #refreshTimes do 624 for i = 1, #refreshTimes do
492 - local rt = toUnixtime(refreshTimes[1]..string_format("%02x", RESET_TIME)) 625 + local rt = toUnixtime(refreshTimes[i]..string_format("%02x", RESET_TIME))
493 if timeNow >= rt and rt > lastTs then 626 if timeNow >= rt and rt > lastTs then
494 lastTs = rt 627 lastTs = rt
495 actData = {} 628 actData = {}
496 end 629 end
497 end 630 end
498 - if next(actData) then  
499 - actData["ts"] = lastTs 631 + if not next(actData) then
  632 + actData["ts"] = timeNow
500 self:updateActData(actType, actData, not notify) 633 self:updateActData(actType, actData, not notify)
501 end 634 end
502 end, 635 end,
@@ -525,6 +658,12 @@ activityFunc[Activity.ActivityType.ActHeroPool] = { @@ -525,6 +658,12 @@ activityFunc[Activity.ActivityType.ActHeroPool] = {
525 local actData = self:getActData(actType) 658 local actData = self:getActData(actType)
526 local cfg = csvdb["activity_ctrlCsv"][actId] 659 local cfg = csvdb["activity_ctrlCsv"][actId]
527 if not cfg then return end 660 if not cfg then return end
  661 + -- 保底次数转换成万能碎片
  662 + --local count = math.ceil(((actData[cfg.condition] or 0) / 100) * 60)
  663 + --if count > 0 then
  664 + -- local gift = {[723] = count}
  665 + -- self.owner:sendMail(MailId.ActivityPoolRet, nil, gift, {})
  666 + --end
528 actData[cfg.condition] = nil 667 actData[cfg.condition] = nil
529 self:updateActData(actType, actData, not notify) 668 self:updateActData(actType, actData, not notify)
530 end, 669 end,
@@ -599,6 +738,18 @@ function Activity:refreshDailyData(notify) @@ -599,6 +738,18 @@ function Activity:refreshDailyData(notify)
599 end 738 end
600 end 739 end
601 740
  741 +function Activity:refreshWeekData(notify)
  742 + for actId, status in pairs(self._isOpen) do
  743 + local actData = csvdb["activity_ctrlCsv"][actId]
  744 + if status and actData then
  745 + local actType = actData.showType
  746 + if activityFunc[actType] and activityFunc[actType]['crossWeek'] then
  747 + activityFunc[actType]["crossWeek"](self, actType, notify, actId)
  748 + end
  749 + end
  750 + end
  751 +end
  752 +
602 function Activity:checkActivity(notNotify, activityType, ...) 753 function Activity:checkActivity(notNotify, activityType, ...)
603 if not activityType then return end 754 if not activityType then return end
604 if not self:isOpen(activityType) then return end 755 if not self:isOpen(activityType) then return end
@@ -698,7 +849,7 @@ function Activity:recycleActItem(actId) @@ -698,7 +849,7 @@ function Activity:recycleActItem(actId)
698 local itemCount = role:getItemCount(fromId) 849 local itemCount = role:getItemCount(fromId)
699 if itemCount > 0 then 850 if itemCount > 0 then
700 costs[fromId] = (costs[fromId] or 0) + itemCount 851 costs[fromId] = (costs[fromId] or 0) + itemCount
701 - gift[toId] = toNum * itemCount 852 + gift[toId] = (gift[toId] or 0) + toNum * itemCount
702 end 853 end
703 end 854 end
704 if next(costs) then 855 if next(costs) then
@@ -762,7 +913,46 @@ activityFunc[Activity.ActivityType.ActShopGoods] = { @@ -762,7 +913,46 @@ activityFunc[Activity.ActivityType.ActShopGoods] = {
762 end, 913 end,
763 } 914 }
764 915
  916 +activityFunc[Activity.ActivityType.FriendEnergy] = {
  917 + ["init"] = function (self, actType, isCrossDay, notify, actId)
  918 + local data = {magic = 0, limit = 0, reward = {}, giveAE = {}, getAE = {}, new = self:getActFriendNew()}
  919 + self:updateActData(actType, data, not notify)
  920 + end,
  921 + ["login"] = function (self, actType)
  922 + local actData = self:getActData(actType) or {}
  923 + actData.new = self:getActFriendNew()
  924 + self:updateActData(actType, actData, not notify)
  925 + end,
  926 + ["crossDay"] = function(self, actType, notify)
  927 + local actData = self:getActData(actType)
  928 + actData.limit = 0
  929 + actData.giveAE = {}
  930 + actData.getAE = {}
  931 + self:updateActData(actType, actData, not notify)
  932 + end,
  933 + ["close"] = function (self, actType, notify, actId)
  934 + redisproxy:del(FRIEND_ENERGY:format(self.owner:getProperty("id")))
  935 + end
  936 +}
  937 +
  938 +function Activity:getActFriendNew()
  939 + local roleId = self.owner:getProperty("id")
  940 + local friendIds = {}
  941 + local friends = redisproxy:hgetall(FRIEND_KEY:format(roleId))
  942 + for i = 1, #friends , 2 do
  943 + local objId = tonumber(friends[i])
  944 + friendIds[objId] = 1
  945 + end
765 946
  947 + local ids = {}
  948 + local members = redisproxy:smembers(FRIEND_ENERGY:format(roleId))
  949 + for _, id in pairs(members) do
  950 + if friendIds[tonumber(id)] then
  951 + ids[tonumber(id)] = 1
  952 + end
  953 + end
  954 + return ids
  955 +end
766 956
767 activityFunc[Activity.ActivityType.Crisis] = { 957 activityFunc[Activity.ActivityType.Crisis] = {
768 ["check"] = function(self, actType, notify, atype, count) -- 检查 958 ["check"] = function(self, actType, notify, atype, count) -- 检查
@@ -775,25 +965,27 @@ activityFunc[Activity.ActivityType.Crisis] = { @@ -775,25 +965,27 @@ activityFunc[Activity.ActivityType.Crisis] = {
775 for id, actSet in pairs(actCsv) do 965 for id, actSet in pairs(actCsv) do
776 if actSet.type == atype then 966 if actSet.type == atype then
777 local status = actData.task[id] or 0 967 local status = actData.task[id] or 0
778 - status = status + count  
779 - if status >= actSet.condition1 then  
780 - local reward  
781 - if actSet.loop == 1 then  
782 - local rcount = math.floor(status / actSet.condition1)  
783 - reward = actSet.reward:toNumMap()  
784 - for itemId, itemC in pairs(reward) do  
785 - reward[itemId] = itemC * rcount 968 + if status ~= -1 then
  969 + status = status + count
  970 + if status >= actSet.condition1 then
  971 + local reward
  972 + if actSet.loop == 1 then
  973 + local rcount = math.floor(status / actSet.condition1)
  974 + reward = actSet.reward:toNumMap()
  975 + for itemId, itemC in pairs(reward) do
  976 + reward[itemId] = itemC * rcount
  977 + end
  978 + status = status % actSet.condition1
  979 + else
  980 + reward = actSet.reward
  981 + status = -1
786 end 982 end
787 - status = status % actSet.condition1  
788 - else  
789 - reward = actSet.reward  
790 - status = -1  
791 - end  
792 983
793 - self.owner:award(reward, {log = {desc = "activity_crisis"}, notNotify = not notify}) 984 + self.owner:award(reward, {log = {desc = "activity_crisis"}, notNotify = not notify})
  985 + end
  986 + actData.task[id] = status
  987 + change = true
794 end 988 end
795 - actData.task[id] = status  
796 - change = true  
797 end 989 end
798 end 990 end
799 if change then 991 if change then
@@ -804,4 +996,185 @@ activityFunc[Activity.ActivityType.Crisis] = { @@ -804,4 +996,185 @@ activityFunc[Activity.ActivityType.Crisis] = {
804 end, 996 end,
805 } 997 }
806 998
  999 +activityFunc[Activity.ActivityType.CommonSignIn] = {
  1000 + ["init"] = function(self, actType, isCrossDay, notify, actId)
  1001 + if not isCrossDay then
  1002 + activityFunc[Activity.ActivityType.CommonSignIn]["crossDay"](self, actType, notify, actId)
  1003 + end
  1004 + end,
  1005 + ["crossDay"] = function(self, actType, notify, actId)
  1006 + local actCfg = csvdb["activity_ctrlCsv"][actId]
  1007 + if not actCfg then return end
  1008 + local conArr = actCfg.condition2:toArray(true, "=")
  1009 + -- 0 登录即可, 1 达到指定活跃度
  1010 + if conArr[1] ~= 0 then
  1011 + return
  1012 + end
  1013 + local curData = self:getActData(actType) or {}
  1014 + curData[0] = (curData[0] or 0) + 1
  1015 + self:updateActData(actType, curData, not notify)
  1016 + end,
  1017 + ["check"] = function(self, actType, notify, pre, cur) -- 检查
  1018 + local isOpen, actId = self:isOpen(actType)
  1019 + local actData = self:getActData(actType) or {}
  1020 + local actCfg = csvdb["activity_ctrlCsv"][actId]
  1021 + if not actCfg then return end
  1022 + local conArr = actCfg.condition2:toArray(true, "=")
  1023 + -- 0 登录即可, 1 达到指定活跃度
  1024 + if conArr[1] ~= 1 then
  1025 + return
  1026 + end
  1027 + local val = conArr[2] or 0
  1028 + if pre < val and cur >= val then
  1029 + actData[0] = (actData[0] or 0) + 1
  1030 + self:updateActData(actType, actData, not notify)
  1031 + end
  1032 + end,
  1033 +}
  1034 +
  1035 +activityFunc[Activity.ActivityType.BattleCommand] = {
  1036 + ["init"] = function (self, actType, isCrossDay, notify, actId)
  1037 + local data = {unlock = 0, freeR = "", payR = "", lvl = 0, sum = 0, week = 0}
  1038 + self:updateActData(actType, data, not notify)
  1039 + end,
  1040 + ["check"] = function(self, actType, notify, id, count) -- 检查 itemid, count
  1041 + local isOpen, actId = self:isOpen(actType)
  1042 + local actData = self:getActData(actType) or {}
  1043 + local actCfg = csvdb["activity_ctrlCsv"][actId]
  1044 + if not actCfg then return end
  1045 + if actCfg.condition1 == "" then return end
  1046 + local arr = actCfg.condition2:toArray(true, "=")
  1047 + local itemIdWeek, itemIdNormal, limit = arr[1], arr[2], arr[3]
  1048 + if (itemIdWeek == id or itemIdNormal == id) and count > 0 then
  1049 + if itemIdWeek == id then
  1050 + if (actData["week"] or 0) >= limit then
  1051 + return
  1052 + end
  1053 + local old = actData["week"] or 0
  1054 + actData["week"] = math.min(old + count, limit)
  1055 + count = actData["week"] - old
  1056 + end
  1057 + local total = actData["sum"] + count
  1058 + local curLvl = actData["lvl"] or 0
  1059 + if actCfg.condition == 1 then -- 代表sum需要转换为等级
  1060 + local bpCfg = csvdb["activity_battlepass_rewardCsv"][actId]
  1061 + if not bpCfg then return end
  1062 + for i = 1, #bpCfg do
  1063 + local cfg = bpCfg[i]
  1064 + if cfg["type"] > curLvl then
  1065 + if total < cfg["condition"] then break end
  1066 + total = total - cfg["condition"]
  1067 + curLvl = curLvl + 1
  1068 + end
  1069 + end
  1070 + actData["lvl"] = curLvl
  1071 + actData["sum"] = total
  1072 + end
  1073 +
  1074 + self:updateActData(actType, actData)
  1075 + end
  1076 + end,
  1077 + ["crossWeek"] = function(self, actType, notify, actId)
  1078 + local actData = self:getActData(actType) or {}
  1079 + actData["week"] = 0
  1080 + self:updateActData(actType, actData, true)
  1081 + end,
  1082 +}
  1083 +
  1084 +
  1085 +activityFunc[Activity.ActivityType.NewSign] = {
  1086 + -- ["check"] = function(self, actType, notify) -- 检查
  1087 + -- end,
  1088 + ["init"] = function(self, actType, isCrossDay, notify)
  1089 + if not isCrossDay then
  1090 + activityFunc[Activity.ActivityType.NewSign]["crossDay"](self, actType, notify)
  1091 + end
  1092 + end,
  1093 + -- ["close"] = function(self, actType, notify)
  1094 + -- end,
  1095 + ["crossDay"] = function(self, actType, notify)
  1096 + local curData = self:getActData(actType)
  1097 + curData[0] = (curData[0] or 0) + 1
  1098 + local actData = csvdb["activity_signInCsv"][48] or {}
  1099 + if curData[0] > #actData then return end -- 满了就忽略了
  1100 +
  1101 + -- 没满更新一下
  1102 + self:updateActData(actType, curData, not notify)
  1103 + end,
  1104 +}
  1105 +
  1106 +local function closeActAdvHang(role, chapterId)
  1107 + local advHang = role:getProperty("advHang")
  1108 + local info = advHang[chapterId]
  1109 + if not info then return end
  1110 +
  1111 + local index = info.index or 1
  1112 + local chapterData = csvdb["adv_chapter_campsiteCsv"][chapterId]
  1113 + if not chapterData then return end
  1114 + local campSiteData = chapterData[info.campId or 2]
  1115 + if not campSiteData then return 1 end
  1116 + if campSiteData.idleReward_1 == "" and campSiteData.idleReward_2 == "" then return 2 end --没有奖励 没有挂机
  1117 +
  1118 + local adv_idle_time = globalCsv.adv_idle_time[index]
  1119 + local adv_idle_energy = globalCsv.adv_idle_energy[index]
  1120 + local adv_idle_reward_coef = globalCsv.adv_idle_reward[index]
  1121 + if not adv_idle_time or not adv_idle_energy or not adv_idle_reward_coef then
  1122 + return 2
  1123 + end
  1124 + adv_idle_time = adv_idle_time * 60
  1125 +
  1126 + local reward, isFull, change, heroFaithMap
  1127 + local heroCnt = 0
  1128 + if skynet.timex() >= info.time then
  1129 + -- 增加英雄信赖
  1130 + local exp = info.duration / 60
  1131 + heroFaithMap = {}
  1132 + for _, heroId in pairs(info.format.heros) do
  1133 + local curFaith = role:addHeroFaith(heroId, exp)
  1134 + heroFaithMap[heroId] = curFaith
  1135 + heroCnt = heroCnt + 1
  1136 + end
  1137 +
  1138 + local totalReward = campSiteData.idleReward_1 .. " " .. campSiteData.idleReward_2
  1139 +
  1140 + local idleReward = totalReward:toNumMap()
  1141 + for itemId, count in pairs(idleReward) do
  1142 + idleReward[itemId] = count * adv_idle_reward_coef
  1143 + end
  1144 + reward, change = role:award(idleReward, {log = {desc = "advHang", int1 = chapterId}})
  1145 + end
  1146 +
  1147 + role:changeUpdates({{type = "advHang", field = chapterId, value = nil}})
  1148 +
  1149 + role:mylog("adv_action", {desc = "endHang", int1 = chapterId, short1 = 2})
  1150 +
  1151 + role:checkTaskEnter("AdvHang", {})
  1152 + role:checkTaskEnter("AdvHangHeroCnt", {count = heroCnt})
  1153 +end
  1154 +
  1155 +activityFunc[Activity.ActivityType.AdvLevel] = {
  1156 + -- ["check"] = function(self, actType, notify) -- 检查
  1157 + -- end,
  1158 + ["init"] = function(self, actType, isCrossDay, notify)
  1159 + end,
  1160 + ["close"] = function(self, actType, notify, actid)
  1161 + local actCfg = csvdb["activity_adv_chapterCsv"][actid]
  1162 + if not actCfg then return end
  1163 + for chapterId, _ in ipairs(actCfg) do
  1164 + local advPass = self.owner:getProperty("advPass")
  1165 + advPass[chapterId] = nil
  1166 + self.owner:updateProperty({field="advPass", value=advPass})
  1167 +
  1168 + -- 关闭活动代理拾荒
  1169 + closeActAdvHang(chapterId)
  1170 + end
  1171 + -- 强制关闭活动拾荒关卡
  1172 + local adv = self.owner:getAdvData()
  1173 + if adv:isRunning() and adv:isActivity() then
  1174 + adv:forceOver()
  1175 + end
  1176 +
  1177 + end,
  1178 +}
  1179 +
807 return Activity 1180 return Activity
src/models/HeroPlugin.lua
@@ -53,22 +53,25 @@ function HeroPlugin.bind(Hero) @@ -53,22 +53,25 @@ function HeroPlugin.bind(Hero)
53 local talentAttrS = {} 53 local talentAttrS = {}
54 54
55 -- 四个基础属性 55 -- 四个基础属性
56 - local curData = csvdb["unit_talentCsv"][talent:getv(0, 1)]  
57 - local curTalentLvl = 0  
58 - if not curData then -- 已经满阶段了  
59 - local cfgName = "unit_talent_"..heroCfgId.."Csv"  
60 - curData = csvdb[cfgName][#csvdb[cfgName]]  
61 - else  
62 - curTalentLvl = talent:getv(1, 1)  
63 - end  
64 - for lvl, cfg in pairs(curData) do  
65 - if lvl < curTalentLvl or curTalentLvl == 0 then  
66 - if cfg.effect ~= 99 then  
67 - local curVal = talentAttrS[cfg.effect] or 0  
68 - if curVal < cfg.strength then  
69 - talentAttrS[cfg.effect] = cfg.strength 56 + local cfgName = "unit_talent_"..heroCfgId.."Csv"
  57 + local curRank = talent:getv(0, 1)
  58 + local curLv = talent:getv(1,1) - 1
  59 + for i, value in ipairs(csvdb[cfgName]) do
  60 + if i <= curRank then
  61 + for lv, cfg in ipairs(value) do
  62 + if i < curRank or lv <= curLv then
  63 + if cfg.effect ~= 99 then
  64 + if not talentAttrS[cfg.effect] then
  65 + talentAttrS[AttsEnumEx[cfg.effect]] = 0
  66 + end
  67 + talentAttrS[AttsEnumEx[cfg.effect]] = cfg.strength
  68 + end
  69 + else
  70 + break
70 end 71 end
71 end 72 end
  73 + else
  74 + break
72 end 75 end
73 end 76 end
74 77
@@ -85,7 +88,7 @@ function HeroPlugin.bind(Hero) @@ -85,7 +88,7 @@ function HeroPlugin.bind(Hero)
85 for lvl = 1, #faithConfig do 88 for lvl = 1, #faithConfig do
86 if faith >= faithConfig[lvl].exp then 89 if faith >= faithConfig[lvl].exp then
87 local add = faithConfig[lvl]["position_"..unitData.position]:toArray(true, "=") 90 local add = faithConfig[lvl]["position_"..unitData.position]:toArray(true, "=")
88 - faithAttr[add[1]] = (faithAttr[add[1]] or 0) + add[2] 91 + faithAttr[AttsEnumEx[add[1]]] = (faithAttr[AttsEnumEx[add[1]]] or 0) + add[2]
89 end 92 end
90 end 93 end
91 for _, attrName in pairs(AttsEnumEx) do 94 for _, attrName in pairs(AttsEnumEx) do
src/models/Role.lua
@@ -53,10 +53,11 @@ Role.schema = { @@ -53,10 +53,11 @@ Role.schema = {
53 banTime = {"number", 0}, 53 banTime = {"number", 0},
54 banType = {"number", 0}, 54 banType = {"number", 0},
55 heartWarning = {"number", 0}, 55 heartWarning = {"number", 0},
  56 + cheatCount = {"number", 0},
56 ltime = {"number", 0}, -- 最后登录时间 57 ltime = {"number", 0}, -- 最后登录时间
57 ctime = {"number", skynet.timex()}, -- 创建时间 58 ctime = {"number", skynet.timex()}, -- 创建时间
58 ignoreMt = {"number", 0}, -- 忽略维护拦截 59 ignoreMt = {"number", 0}, -- 忽略维护拦截
59 - sversion = {"number", globalCsv.StructVersion or 0}, -- 重整数据版本 60 + sversion = {"number", STRUCT_VERSION or 0}, -- 重整数据版本
60 timeReset = {"table", {}}, --重置轮回记录 61 timeReset = {"table", {}}, --重置轮回记录
61 diamond = {"number", 0}, 62 diamond = {"number", 0},
62 reDiamond = {"number", 0}, 63 reDiamond = {"number", 0},
@@ -154,6 +155,7 @@ Role.schema = { @@ -154,6 +155,7 @@ Role.schema = {
154 155
155 achiveT = {"table", {}}, -- 成就计数统计 achivement_type {id = status} 156 achiveT = {"table", {}}, -- 成就计数统计 achivement_type {id = status}
156 achiveV = {"table", {}}, -- 成就领奖统计 achivement {id = status} 157 achiveV = {"table", {}}, -- 成就领奖统计 achivement {id = status}
  158 + fuxR = {"number", 0}, -- 复兴成就最大完成数量
157 159
158 rechargeF = {"table", {}}, -- 是否首次充值某一项 -- —{[id] = 1} -- 不存在就是没有充值过 160 rechargeF = {"table", {}}, -- 是否首次充值某一项 -- —{[id] = 1} -- 不存在就是没有充值过
159 dinerS = {"table", {}}, -- 美食币商城 购买记录 {[id] = count} 161 dinerS = {"table", {}}, -- 美食币商城 购买记录 {[id] = count}
@@ -182,6 +184,7 @@ Role.schema = { @@ -182,6 +184,7 @@ Role.schema = {
182 feedback = {"table", {}}, -- 反馈相关信息 {flag = false, count = 0} flag是否评论过,count 提示次数 184 feedback = {"table", {}}, -- 反馈相关信息 {flag = false, count = 0} flag是否评论过,count 提示次数
183 185
184 calTask = {"table", {}}, -- 英雄令活动 日历任务活动 186 calTask = {"table", {}}, -- 英雄令活动 日历任务活动
  187 + bcTask = {"table", {}}, -- 英雄令活动 日历任务活动 临时使用
185 radioTask = {"table", {}}, -- 电台任务 {id = {time=end_ts,heros=heros}} 表crusadeCsv 188 radioTask = {"table", {}}, -- 电台任务 {id = {time=end_ts,heros=heros}} 表crusadeCsv
186 } 189 }
187 190
@@ -355,6 +358,7 @@ function Role:data() @@ -355,6 +358,7 @@ function Role:data()
355 advSup = self:getProperty("advSup"), 358 advSup = self:getProperty("advSup"),
356 advC = self:getProperty("advC"), 359 advC = self:getProperty("advC"),
357 advCT = self:getProperty("advCT"), 360 advCT = self:getProperty("advCT"),
  361 + advRelay = self:getProperty("advRelay"),
358 362
359 hangPass = self:getProperty("hangPass"), 363 hangPass = self:getProperty("hangPass"),
360 hangGift = self:getProperty("hangGift"), 364 hangGift = self:getProperty("hangGift"),
@@ -408,6 +412,7 @@ function Role:data() @@ -408,6 +412,7 @@ function Role:data()
408 feedback = self:getProperty("feedback"), 412 feedback = self:getProperty("feedback"),
409 ctime = self:getProperty("ctime"), 413 ctime = self:getProperty("ctime"),
410 calTask = self:getProperty("calTask"), 414 calTask = self:getProperty("calTask"),
  415 + bcTask = self:getProperty("bcTask"),
411 radioTask = self:getProperty("radioTask"), 416 radioTask = self:getProperty("radioTask"),
412 } 417 }
413 end 418 end
src/models/RoleBattle.lua
@@ -21,13 +21,153 @@ local BattleType = { @@ -21,13 +21,153 @@ local BattleType = {
21 21
22 RoleBattle.bind = function (Role) 22 RoleBattle.bind = function (Role)
23 23
  24 +local checkCheatAttrs = {
  25 + ["hp"] = 1,
  26 + ["atk"] = 1,
  27 + ["def"] = 1,
  28 + ["hit"] = 1,
  29 + ["miss"] = 1,
  30 + ["crit"] = 1,
  31 + ["atkSpeed"] = 1,
  32 + ["critHurt"] = 1,
  33 + -- ["vampire"] = 1,
  34 + -- ["pierce"] = 1,
  35 +}
24 36
25 --- TODO 检查战斗是否作弊  
26 -local function checkBattleCheat()  
27 - 37 +local function checkOneCheat(selfTeamClient, selfTeamServer, enemyClient, enemyServer)
  38 + if not selfTeamClient or type(selfTeamClient) ~= "table" then return end
  39 + for unitType, clientInfo in pairs(selfTeamClient) do
  40 + local serverInfo = selfTeamServer[unitType]
  41 + if not serverInfo then return end
  42 + for attr, pm in pairs(checkCheatAttrs) do
  43 + if not clientInfo[attr] then return end
  44 + end
  45 + local b1 = ((clientInfo["hp"] + clientInfo["def"] * 7 + clientInfo["miss"] * 4) * (clientInfo["atk"] * 4 + clientInfo["hit"] * 2) * (1 + clientInfo["crit"]/100 * clientInfo["critHurt"]/100) * clientInfo["atkSpeed"] / 600000) ^ 0.8
  46 + local b2 = ((serverInfo["hp"] + serverInfo["def"] * 7 + serverInfo["miss"] * 4) * (serverInfo["atk"] * 4 + serverInfo["hit"] * 2) * (1 + serverInfo["crit"]/100 * serverInfo["critHurt"]/100) * serverInfo["atkSpeed"] / 600000) ^ 0.8
  47 + if b1 >= b2 * 2 then
  48 + return
  49 + end
  50 + end
  51 + return true
28 end 52 end
29 53
  54 +-- local function getRobotAttrs(info, strength)
  55 +-- strength = strength or 10000
  56 +-- local unitData = csvdb["unitCsv"][info.unitType]
  57 +-- local enemy = {}
  58 +-- for arr, _ in pairs(checkCheatAttrs) do
  59 +-- enemy[arr] = unitData[attr] * info[attr] * strength / 10000
  60 +-- end
  61 +-- return enemy
  62 +-- end
  63 +
  64 +-- --通过配表构建敌人队伍 通用
  65 +-- function BattleEnter:packBattleEnemyCommon( carbonData )
  66 +-- local enemys = {}
  67 +-- local monsterSet = csvdb[carbonData.monster:match("/([^/]*)$") .. "Csv"]
  68 +-- for phase = 1, #monsterSet do
  69 +-- local allEnemys = table.values(monsterSet[phase])
  70 +-- table.sort(allEnemys, function(a, b) return a.id < b.id end)
  71 +-- local heros = {}
  72 +-- for idx, enemy in ipairs(allEnemys) do
  73 +-- local info = getRobotAttrs(enemy, carbonData.strength)
  74 +-- enemys[idx] = info
  75 +-- end
  76 +-- break
  77 +-- end
  78 +-- return enemys
  79 +-- end
  80 +
  81 +-- 检查战斗是否作弊
  82 +function Role:checkBattleCheat(battleType, params)
  83 + if not params.isWin then return true end
  84 + local clientInfo = params.info or {}
  85 +
  86 + if not BattleType[battleType] then
  87 + print(string.format("NO find battleType: %s", battleType))
  88 + return true
  89 + end
  90 + local selfTeamServer = {}
  91 + local enemyServer = {}
  92 +
  93 + local cheat = {}
  94 + cheat["hang"] = function()
  95 + local team = self:getTeamBattleInfo(self:getTeamFormatByType(TeamSystemType.Hang))
  96 + for slot, hero in pairs(team.heros) do
  97 + local temp = {}
  98 + for arr, _ in pairs(checkCheatAttrs) do
  99 + temp[arr] = hero[arr]
  100 + end
  101 + selfTeamServer[hero.type] = temp
  102 + end
  103 + -- local carbonData = csvdb["idle_battleCsv"][params.id]
  104 + -- enemyServer = packBattleEnemyCommon(carbonData)
  105 + end
  106 + cheat["tower"] = function()
  107 + local team = self:getTeamBattleInfo(self:getTeamFormatByType(TeamSystemType.Tower))
  108 + for slot, hero in pairs(team.heros) do
  109 + local temp = {}
  110 + for arr, _ in pairs(checkCheatAttrs) do
  111 + temp[arr] = hero[arr]
  112 + end
  113 + selfTeamServer[hero.type] = temp
  114 + end
  115 + -- local carbonData = csvdb["tower_battleCsv"][params.id]
  116 + -- enemyServer = packBattleEnemyCommon(carbonData)
  117 + end
  118 + cheat["bonus"] = function()
  119 + local team = self:getTeamBattleInfo(self:getTeamFormatByType(TeamSystemType.BonusBattle))
  120 + for slot, hero in pairs(team.heros) do
  121 + local temp = {}
  122 + for arr, _ in pairs(checkCheatAttrs) do
  123 + temp[arr] = hero[arr]
  124 + end
  125 + selfTeamServer[hero.type] = temp
  126 + end
  127 + -- local carbonData = csvdb["bonus_battleCsv"][params.id]
  128 + -- enemyServer = packBattleEnemyCommon(carbonData)
  129 + end
  130 + cheat["pvpc"] = function()
  131 + if not params.format then return end
  132 + local team = self:getTeamBattleInfo(params.format)
  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 + end
  141 + cheat["pvph"] = cheat["pvpc"]
  142 + cheat["act_battle"] = cheat["pvpc"]
  143 +
  144 + cheat[battleType]()
  145 +
  146 + local status = checkOneCheat(clientInfo.selfAttr, selfTeamServer, clientInfo.enemyAttr, enemyServer)
  147 + if not status then
  148 + -- local cheatCount = self:getProperty("cheatCount")
  149 + -- cheatCount = cheatCount + 1
  150 + -- self:setProperty("cheatCount", cheatCount)
  151 +
  152 + local result = {clientSelf = {}, serverSelf = {}}
  153 + for k , v in pairs(clientInfo.selfAttr or {}) do
  154 + result.clientSelf[tostring(k)] = v
  155 + end
  156 + for k , v in pairs(selfTeamServer) do
  157 + result.serverSelf[tostring(k)] = v
  158 + end
  159 + result = json.encode(result)
  160 + self:mylog("cheat", {desc = battleType, int1 = 1, text1 = result})
30 161
  162 + -- for _, v in ipairs(globalCsv.cheat_check) do
  163 + -- if cheatCount == v[1] then
  164 + -- self:setBan(v[2] / 86400, 5)
  165 + -- break
  166 + -- end
  167 + -- end
  168 + end
  169 + return true
  170 +end
31 171
32 function Role:checkBattle(battleType, params) 172 function Role:checkBattle(battleType, params)
33 local clientInfo = params.info or {} 173 local clientInfo = params.info or {}
src/models/RoleChangeStruct.lua
@@ -31,6 +31,7 @@ local awardGift = createVersionFunc(VersionType.Override ,function(role, params) @@ -31,6 +31,7 @@ local awardGift = createVersionFunc(VersionType.Override ,function(role, params)
31 print("awardGift" .. " >>> " .. params) 31 print("awardGift" .. " >>> " .. params)
32 end) 32 end)
33 33
  34 +
34 local bugFixSuduku = createVersionFunc(VersionType.DoOnly, function(role, params) 35 local bugFixSuduku = createVersionFunc(VersionType.DoOnly, function(role, params)
35 local sudoku = role:getProperty("sudoku") 36 local sudoku = role:getProperty("sudoku")
36 local phase = sudoku[-1] or 1 37 local phase = sudoku[-1] or 1
@@ -48,11 +49,38 @@ local bugFixSuduku = createVersionFunc(VersionType.DoOnly, function(role, params @@ -48,11 +49,38 @@ local bugFixSuduku = createVersionFunc(VersionType.DoOnly, function(role, params
48 end 49 end
49 end) 50 end)
50 51
  52 +local bugFixRune = createVersionFunc(VersionType.DoOnly, function(role, params)
  53 + local had = false
  54 + for id, rune in pairs(role.runeBag) do
  55 + if math.floor(rune:getProperty("id") / 1000) == 16 then
  56 + local attrs = rune:getProperty("attrs")
  57 + local atk = attrs:getv(2, 0)
  58 + if atk ~= 0 then
  59 + attrs = attrs:delk(2):setv(1, atk)
  60 + had = true
  61 + rune:setProperty("attrs",attrs)
  62 + end
  63 + end
  64 + end
  65 + if had then
  66 + -- 补偿
  67 + end
  68 +end)
  69 +
  70 +-- 清除 player 消失 的冒险
  71 +local bugFixAdvPlayer = createVersionFunc(VersionType.Override, function(role, params)
  72 + if role:getAdvData():isRunning() and not role:getProperty("advTeam").player then
  73 + role:getAdvData():forceOver(true)
  74 + end
  75 +end)
  76 +
51 ---------------------版本方法 end ---------------------- 77 ---------------------版本方法 end ----------------------
52 78
53 -- version 罗列start 79 -- version 罗列start
54 local versionList = {} -- version 列表 80 local versionList = {} -- version 列表
55 versionList[1] = {bugFixSuduku, {}} 81 versionList[1] = {bugFixSuduku, {}}
  82 +versionList[2] = {bugFixRune, {}}
  83 +versionList[3] = {bugFixAdvPlayer, {}}
56 -- versionList[2] = {clearActivity, {5, 7}} 84 -- versionList[2] = {clearActivity, {5, 7}}
57 -- versionList[3] = {changeStructF, "test1"} 85 -- versionList[3] = {changeStructF, "test1"}
58 -- versionList[4] = {changeStructF, "test2"} 86 -- versionList[4] = {changeStructF, "test2"}
@@ -69,11 +97,11 @@ function RoleChangeStruct.bind(Role) @@ -69,11 +97,11 @@ function RoleChangeStruct.bind(Role)
69 97
70 function Role:changeStructVersion() 98 function Role:changeStructVersion()
71 local curVersion = self:getProperty("sversion") 99 local curVersion = self:getProperty("sversion")
72 - if not globalCsv.StructVersion or curVersion >= globalCsv.StructVersion then return end 100 + if not STRUCT_VERSION or curVersion >= STRUCT_VERSION then return end
73 101
74 local jumpVersion = {} 102 local jumpVersion = {}
75 local versionTemp = {} 103 local versionTemp = {}
76 - for version = curVersion + 1, globalCsv.StructVersion do 104 + for version = curVersion + 1, STRUCT_VERSION do
77 local versionData = versionList[version] 105 local versionData = versionList[version]
78 if versionData then 106 if versionData then
79 if versionData[1].vType == VersionType.DoOnly then 107 if versionData[1].vType == VersionType.DoOnly then
@@ -106,7 +134,7 @@ function RoleChangeStruct.bind(Role) @@ -106,7 +134,7 @@ function RoleChangeStruct.bind(Role)
106 end 134 end
107 end 135 end
108 136
109 - for version = curVersion + 1, globalCsv.StructVersion do 137 + for version = curVersion + 1, STRUCT_VERSION do
110 if not jumpVersion[version] then 138 if not jumpVersion[version] then
111 local versionData = versionList[version] 139 local versionData = versionList[version]
112 if versionData[1].vType == VersionType.DoOnly or versionData[1].vType == VersionType.Override then 140 if versionData[1].vType == VersionType.DoOnly or versionData[1].vType == VersionType.Override then
@@ -116,7 +144,7 @@ function RoleChangeStruct.bind(Role) @@ -116,7 +144,7 @@ function RoleChangeStruct.bind(Role)
116 end 144 end
117 end 145 end
118 end 146 end
119 - self:setProperty("sversion", globalCsv.StructVersion) 147 + self:setProperty("sversion", STRUCT_VERSION)
120 end 148 end
121 149
122 end 150 end
src/models/RoleLog.lua
@@ -51,6 +51,12 @@ local ItemReason = { @@ -51,6 +51,12 @@ local ItemReason = {
51 actBattle = 135, -- 活动关卡 51 actBattle = 135, -- 活动关卡
52 actMilestone = 136, -- 活动关卡boss伤害里程碑 52 actMilestone = 136, -- 活动关卡boss伤害里程碑
53 worldBossReward = 137, -- 世界boss翻牌奖励 53 worldBossReward = 137, -- 世界boss翻牌奖励
  54 + commonSign = 138, -- 每日活跃签到
  55 + actFriendHelp = 139,-- 好友能量互助活动
  56 + actBattleCommand = 140, -- 活动战令
  57 + actBuyBpLevel = 141, -- 购买活动战令等级
  58 + newSign = 142,-- 新的活动签到
  59 + advLevelStage = 143, -- 拾荒活动阶段奖励
54 60
55 61
56 advHang = 301, -- 拾荒挂机 62 advHang = 301, -- 拾荒挂机
@@ -92,6 +98,7 @@ local ItemReason = { @@ -92,6 +98,7 @@ local ItemReason = {
92 actPaySign = 1008, -- 活动付费签到 98 actPaySign = 1008, -- 活动付费签到
93 calendaTask = 1009, -- 英雄帖 99 calendaTask = 1009, -- 英雄帖
94 actMilecrisis = 1010, -- 物资危机 100 actMilecrisis = 1010, -- 物资危机
  101 + battleCommandTask = 1011, -- 将军令任务
95 102
96 -- 餐厅 103 -- 餐厅
97 greenHourse = 1101, -- 食材获得 104 greenHourse = 1101, -- 食材获得
@@ -122,6 +129,7 @@ local ItemReason = { @@ -122,6 +129,7 @@ local ItemReason = {
122 129
123 -- pvp 130 -- pvp
124 pvpCHead = 1301, -- pvp 跨服竞技场头像 131 pvpCHead = 1301, -- pvp 跨服竞技场头像
  132 + crossPvpBet = 1302, -- 竞猜
125 133
126 --adv 134 --adv
127 chooseEvent = 1351, -- 冒险选择 135 chooseEvent = 1351, -- 冒险选择
@@ -591,6 +599,7 @@ local LogType = { @@ -591,6 +599,7 @@ local LogType = {
591 guide = "common", 599 guide = "common",
592 newdevice = "common", 600 newdevice = "common",
593 cbback = "common", 601 cbback = "common",
  602 + cheat = "common",
594 603
595 in_item = "common", 604 in_item = "common",
596 out_item = "common", 605 out_item = "common",
@@ -875,4 +884,4 @@ function RoleLog.bind(Role) @@ -875,4 +884,4 @@ function RoleLog.bind(Role)
875 884
876 885
877 end 886 end
878 -return RoleLog  
879 \ No newline at end of file 887 \ No newline at end of file
  888 +return RoleLog
src/models/RolePlugin.lua
@@ -131,7 +131,19 @@ function RolePlugin.bind(Role) @@ -131,7 +131,19 @@ function RolePlugin.bind(Role)
131 self:addItem(pms) 131 self:addItem(pms)
132 end 132 end
133 end, 133 end,
  134 + [ItemType.Potion] = function ()
  135 + self:addPotion({id = itemId, count = count, notNotify = pms.notNotify, log = pms.log})
  136 + end,
134 } 137 }
  138 +
  139 + if count > 0 then
  140 + local itemCfg = csvdb["itemCsv"][itemId]
  141 + local itemType = 0
  142 + if itemCfg then
  143 + itemType = itemCfg.type
  144 + end
  145 + self:checkTaskEnter("AddItem", {id = itemId, count = count, type = itemType})
  146 + end
135 -- 对数量筛查 147 -- 对数量筛查
136 count = checkItemCount(self, itemId, count) 148 count = checkItemCount(self, itemId, count)
137 if count ~= 0 then 149 if count ~= 0 then
@@ -286,10 +298,41 @@ function RolePlugin.bind(Role) @@ -286,10 +298,41 @@ function RolePlugin.bind(Role)
286 print("addPlayExp no log ", debug.traceback()) 298 print("addPlayExp no log ", debug.traceback())
287 end 299 end
288 300
289 - self:updateProperties({level = level, exp = newExp}) 301 + self:updateProperties({level = level, exp = newExp}, params.notNotify)
290 self:changeCrossServerPvpSelfInfo("level") 302 self:changeCrossServerPvpSelfInfo("level")
291 end 303 end
292 304
  305 + function Role:addPotion(params)
  306 + dump(params)
  307 + local pId = globalCsv.adv_item_potion[params.id]
  308 + local potionBag = self:getProperty("potionBag")
  309 + local origin = potionBag[pId] or 0
  310 + local nums = origin + params.count
  311 + potionBag[pId] = nums
  312 +
  313 + self:logItems(params.id, origin, nums, params.log)
  314 + if params.log then
  315 + local log = clone(params.log)
  316 + if log["cint1"] or log["cint2"] then
  317 + print("addItem error log have cint1 or cint2 ", debug.traceback())
  318 + end
  319 + log["cint1"] = params.id
  320 + log["cint2"] = math.abs(params.count)
  321 + if params.count <= 0 then
  322 + self:mylog("out_item", log)
  323 + else
  324 + self:mylog("in_item", log)
  325 + end
  326 + else
  327 + print("addItem no log ", debug.traceback())
  328 + end
  329 +
  330 + self:updateProperty({field = "potionBag", value = potionBag})
  331 + if not params.notNotify then
  332 + SendPacket(actionCodes.Role_updateItems, MsgPack.pack({[params.id] = params.count}))
  333 + end
  334 + end
  335 +
293 function Role:addItem(params) 336 function Role:addItem(params)
294 params = params or {} 337 params = params or {}
295 params.count = math.floor(params.count or 0) 338 params.count = math.floor(params.count or 0)
@@ -387,7 +430,7 @@ function RolePlugin.bind(Role) @@ -387,7 +430,7 @@ function RolePlugin.bind(Role)
387 end 430 end
388 431
389 if update then 432 if update then
390 - self:updateProperty({field = "boxL", value = boxL}) 433 + self:updateProperty({field = "boxL", value = boxL, notNotify = pms.notNotify})
391 end 434 end
392 end 435 end
393 436
@@ -481,6 +524,8 @@ function RolePlugin.bind(Role) @@ -481,6 +524,8 @@ function RolePlugin.bind(Role)
481 end 524 end
482 525
483 self:notifyUpdateProperty("diamond", self:getAllDiamond()) 526 self:notifyUpdateProperty("diamond", self:getAllDiamond())
  527 +
  528 + self:checkTaskEnter("CostDiamond", {count = count})
484 return true 529 return true
485 end 530 end
486 531
@@ -804,9 +849,16 @@ function RolePlugin.bind(Role) @@ -804,9 +849,16 @@ function RolePlugin.bind(Role)
804 return runeSet 849 return runeSet
805 end 850 end
806 851
807 - function Role:getAdvData() 852 + function Role:getAdvData(notNotify)
808 if not self.advData then 853 if not self.advData then
809 self.advData = require("adv.Adv").new(self) 854 self.advData = require("adv.Adv").new(self)
  855 + local status, err = pcall(function()
  856 + self.advData:initByInfo()
  857 + end)
  858 + if not status then
  859 + self.advData:forceOver(notNotify, true)
  860 + skynet.error("getAdvData error adv initByInfo " .. err)
  861 + end
810 end 862 end
811 return self.advData 863 return self.advData
812 end 864 end
@@ -830,7 +882,6 @@ function RolePlugin.bind(Role) @@ -830,7 +882,6 @@ function RolePlugin.bind(Role)
830 self:setProperty("heartWarning", heartWarning) 882 self:setProperty("heartWarning", heartWarning)
831 if heartWarning == 50 then 883 if heartWarning == 50 then
832 self:setBan(30, 1) --封禁 30天 884 self:setBan(30, 1) --封禁 30天
833 - self:sendGmMsg("server_accountBanned_inGame_1")  
834 return 885 return
835 end 886 end
836 if heartWarning < 50 and heartWarning % 5 == 0 then 887 if heartWarning < 50 and heartWarning % 5 == 0 then
@@ -843,21 +894,52 @@ function RolePlugin.bind(Role) @@ -843,21 +894,52 @@ function RolePlugin.bind(Role)
843 time = time or 0 894 time = time or 0
844 banType = banType or 0 895 banType = banType or 0
845 local now = skynet.timex() 896 local now = skynet.timex()
846 - if time == 0 then 897 + if time <= 0 then
847 self:setProperty("banTime", 0) 898 self:setProperty("banTime", 0)
848 self:setProperty("banType", 0) 899 self:setProperty("banType", 0)
849 self:setProperty("heartWarning", 0) 900 self:setProperty("heartWarning", 0)
850 -  
851 self:mylog("role_action", {desc = "ban_rm"}) 901 self:mylog("role_action", {desc = "ban_rm"})
852 else 902 else
853 - self:setProperty("banTime", now + 86400 * time) 903 + self:sendGmMsg(globalCsv.ban_tips[banType] or globalCsv.ban_tips[0])
  904 + self:setProperty("banTime", math.ceil(now + 86400 * time))
854 self:setProperty("banType", banType) 905 self:setProperty("banType", banType)
855 - self:mylog("role_action", {desc = "ban", int1 = time, int2 = banType}) 906 + self:resetRank()
  907 + self:mylog("role_action", {desc = "ban", int1 = math.ceil(time), int2 = banType})
856 end 908 end
857 end 909 end
858 910
  911 + -- 清掉所有排行榜
  912 + function Role:resetRank()
  913 + local roleId = self:getProperty("id")
  914 + redisproxy:pipelining(function (red)
  915 + red:zrem(RANK_TOWER, roleId)
  916 + for _, rk in pairs(RANK_ADV) do
  917 + red:zrem(rk, roleId)
  918 + end
  919 + for _, rk in pairs(RANK_DINER) do
  920 + red:zrem(rk, roleId)
  921 + end
  922 + for _, rk in pairs(RANK_PVP_COMMON_KEY) do
  923 + red:zrem(rk, roleId)
  924 + end
  925 + for _, rk in pairs(RANK_PVP_HIGHT_KEY) do
  926 + red:zrem(rk, roleId)
  927 + end
  928 + for _, ct in pairs(RANK_TYPE) do
  929 + red:zrem(RANK_COMMON .. ct, roleId)
  930 + end
  931 + end)
  932 + end
  933 +
859 function Role:sendGmMsg(text, isNotKey) 934 function Role:sendGmMsg(text, isNotKey)
860 SendPacket(actionCodes.Sys_maintainNotice, MsgPack.pack({ body = text, iskey = not isNotKey})) 935 SendPacket(actionCodes.Sys_maintainNotice, MsgPack.pack({ body = text, iskey = not isNotKey}))
  936 +
  937 + local agent = datacenter.get("agent", self:getProperty("id"))
  938 + if agent then
  939 + skynet.timeout(50, function ()
  940 + skynet.call(agent.gate_serv, "lua", "forcekick", agent.fd)
  941 + end)
  942 + end
861 end 943 end
862 944
863 -- function Role:getHeroActiveRelationData(heros) 945 -- function Role:getHeroActiveRelationData(heros)
@@ -1470,6 +1552,7 @@ function RolePlugin.bind(Role) @@ -1470,6 +1552,7 @@ function RolePlugin.bind(Role)
1470 return function (now, role) 1552 return function (now, role)
1471 if name == "email" and role.sendMailFlag then 1553 if name == "email" and role.sendMailFlag then
1472 last_breath = now + sec 1554 last_breath = now + sec
  1555 + role.sendMailFlag = false
1473 return true 1556 return true
1474 end 1557 end
1475 if now >= last_breath then 1558 if now >= last_breath then
@@ -1505,8 +1588,15 @@ function RolePlugin.bind(Role) @@ -1505,8 +1588,15 @@ function RolePlugin.bind(Role)
1505 end) 1588 end)
1506 for _, data in ipairs(redret) do 1589 for _, data in ipairs(redret) do
1507 local email = tarr2tab(data) 1590 local email = tarr2tab(data)
1508 - if tonum(email.createtime) > self:getProperty("ctime")  
1509 - and ( not email.mid or tonum(email.mid) == mid ) 1591 + -- 0 需要判斷創角時間小於郵件創建時間 1 只需要在時間段內登陸即可領取
  1592 + local delayType = tonum(email.delayType)
  1593 + local flag = false
  1594 + if delayType == 1 then
  1595 + flag = skynet.timex() > tonum(email.createtime)
  1596 + else
  1597 + flag = tonum(email.createtime) > self:getProperty("ctime")
  1598 + end
  1599 + if flag and ( not email.mid or tonum(email.mid) == mid )
1510 and ( not email.endtime or tonum(email.endtime) > now )then 1600 and ( not email.endtime or tonum(email.endtime) > now )then
1511 return true 1601 return true
1512 end 1602 end
@@ -1543,7 +1633,6 @@ function RolePlugin.bind(Role) @@ -1543,7 +1633,6 @@ function RolePlugin.bind(Role)
1543 if table.pack(next(newReward))[2] >= divisionData.limit then 1633 if table.pack(next(newReward))[2] >= divisionData.limit then
1544 return true 1634 return true
1545 end 1635 end
1546 -  
1547 end 1636 end
1548 1637
1549 local events = {} 1638 local events = {}
@@ -1596,8 +1685,34 @@ function RolePlugin.bind(Role) @@ -1596,8 +1685,34 @@ function RolePlugin.bind(Role)
1596 self:updateProperty({field = "redp", value = redp}) 1685 self:updateProperty({field = "redp", value = redp})
1597 end 1686 end
1598 1687
  1688 + -- 网页支付获取订单号
  1689 + function Role:getPurchaseOrderByPlatform(params)
  1690 + local checkPlatform = {
  1691 + ["mycard"] = "mycard_product_id",
  1692 + }
  1693 + local pidField = checkPlatform[params.payMode or ""]
  1694 + if not pidField or not params.product_id or params.product_id == "" then
  1695 + return "no product"
  1696 + end
  1697 +
  1698 + for k , v in pairs(csvdb["shop_rechargeCsv"]) do
  1699 + if not v[pidField] then return "no product" end
  1700 + if v[pidField] == params.product_id then
  1701 + if v.twd ~= tonumber(params.money) then
  1702 + return "error money"
  1703 + end
  1704 + -- 发现需要的id
  1705 + local partnerOrderId = self:getPurchaseOrder(k, params.transactionId)
  1706 + if partnerOrderId == "" then
  1707 + return "no product"
  1708 + end
  1709 + return json.encode({order = partnerOrderId})
  1710 + end
  1711 + end
  1712 + end
  1713 +
1599 -- 获取充值订单号 1714 -- 获取充值订单号
1600 - function Role:getPurchaseOrder(rechargeId) 1715 + function Role:getPurchaseOrder(rechargeId, transactionId)
1601 local roleId = self:getProperty("id") 1716 local roleId = self:getProperty("id")
1602 local rechargeData = csvdb["shop_rechargeCsv"][rechargeId] 1717 local rechargeData = csvdb["shop_rechargeCsv"][rechargeId]
1603 if not rechargeData then 1718 if not rechargeData then
@@ -1634,6 +1749,7 @@ function RolePlugin.bind(Role) @@ -1634,6 +1749,7 @@ function RolePlugin.bind(Role)
1634 order = partnerOrderId, 1749 order = partnerOrderId,
1635 rechargeId = rechargeId, 1750 rechargeId = rechargeId,
1636 createTime = skynet.timex(), 1751 createTime = skynet.timex(),
  1752 + transactionId = transactionId,
1637 }) 1753 })
1638 order:create() 1754 order:create()
1639 -- 正在进行中的订单 缓存 1755 -- 正在进行中的订单 缓存
@@ -1666,6 +1782,9 @@ function RolePlugin.bind(Role) @@ -1666,6 +1782,9 @@ function RolePlugin.bind(Role)
1666 local dataSet = csvdb["shop_rechargeCsv"][rechargeId] 1782 local dataSet = csvdb["shop_rechargeCsv"][rechargeId]
1667 1783
1668 if orderObject:getProperty("finishTime") > 0 then 1784 if orderObject:getProperty("finishTime") > 0 then
  1785 + skynet.error(string.format("[recharge] is a finish order cpOrder: %s, platformOrder : %s, hadPlatformOrder: %s, id: %s, overTime : %s",
  1786 + partnerOrderStr, platformOrder, orderObject:getProperty("transactionId"), rechargeId, orderObject:getProperty("finishTime")
  1787 + ))
1669 return false, "finsh" 1788 return false, "finsh"
1670 end 1789 end
1671 1790
@@ -1709,12 +1828,13 @@ function RolePlugin.bind(Role) @@ -1709,12 +1828,13 @@ function RolePlugin.bind(Role)
1709 request.product_id = data.product_id 1828 request.product_id = data.product_id
1710 request.pay_time = data.pay_time 1829 request.pay_time = data.pay_time
1711 request.transactionId = data.order_no 1830 request.transactionId = data.order_no
  1831 + request.extension_info = data.extension_info
  1832 + request.is_mycard = 1
1712 ]] 1833 ]]
1713 function Role:handlePurchase(params) 1834 function Role:handlePurchase(params)
1714 local roleId = self:getProperty("id") 1835 local roleId = self:getProperty("id")
1715 local partnerOrderStr = params.order 1836 local partnerOrderStr = params.order
1716 1837
1717 -  
1718 local status, back = self:updatePurchaseOrder(partnerOrderStr, params.transactionId, "finsh") 1838 local status, back = self:updatePurchaseOrder(partnerOrderStr, params.transactionId, "finsh")
1719 if not status then 1839 if not status then
1720 if back == "finsh" then 1840 if back == "finsh" then
@@ -1725,7 +1845,7 @@ function RolePlugin.bind(Role) @@ -1725,7 +1845,7 @@ function RolePlugin.bind(Role)
1725 end 1845 end
1726 local rechargeId = back 1846 local rechargeId = back
1727 local rechargeData = csvdb["shop_rechargeCsv"][rechargeId] 1847 local rechargeData = csvdb["shop_rechargeCsv"][rechargeId]
1728 - if rechargeData.rmb ~= tonumber(params.amount) then 1848 + if (params.is_mycard and rechargeData.twd ~= tonumber(params.amount)) or (not params.is_mycard and rechargeData.rmb ~= tonumber(params.amount)) then
1729 skynet.error(string.format("[recharge] fake order: %s, roleId: %d, order: %s, rmb %s, get %s", 1849 skynet.error(string.format("[recharge] fake order: %s, roleId: %d, order: %s, rmb %s, get %s",
1730 params.transactionId, roleId, partnerOrderStr, rechargeData.rmb, params.amount 1850 params.transactionId, roleId, partnerOrderStr, rechargeData.rmb, params.amount
1731 )) 1851 ))
@@ -1740,6 +1860,10 @@ function RolePlugin.bind(Role) @@ -1740,6 +1860,10 @@ function RolePlugin.bind(Role)
1740 }) 1860 })
1741 1861
1742 if not status then 1862 if not status then
  1863 + if params.extension_info == "mycard_web" then
  1864 + -- todo 发邮件
  1865 + skynet.error("mycard_web " .. params.order)
  1866 + end
1743 SendPacket(actionCodes.Store_ayncPurchaseRpc, MsgPack.pack({ order = partnerOrderStr, 1867 SendPacket(actionCodes.Store_ayncPurchaseRpc, MsgPack.pack({ order = partnerOrderStr,
1744 result = "success", reward = reward})) 1868 result = "success", reward = reward}))
1745 end 1869 end
@@ -1773,7 +1897,7 @@ function RolePlugin.bind(Role) @@ -1773,7 +1897,7 @@ function RolePlugin.bind(Role)
1773 self:gainDiamond({count = diamondCount, isRecharge = true, log = {desc = "recharge", int1 = id}}) 1897 self:gainDiamond({count = diamondCount, isRecharge = true, log = {desc = "recharge", int1 = id}})
1774 elseif rechargeData.shop == 2 then --通行证商店 1898 elseif rechargeData.shop == 2 then --通行证商店
1775 reward, _ = self:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}}) 1899 reward, _ = self:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}})
1776 - self.storeData:onBuyCard(rechargeData.type, rechargeData.time, rechargeData.id) 1900 + self.storeData:onBuyCard(rechargeData.type, rechargeData.time, rechargeData.id, rechargeData.activity_id)
1777 elseif rechargeData.shop == 3 then -- 礼包商店 1901 elseif rechargeData.shop == 3 then -- 礼包商店
1778 reward, _ = self:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}}) 1902 reward, _ = self:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}})
1779 else 1903 else
@@ -2013,6 +2137,15 @@ function RolePlugin.bind(Role) @@ -2013,6 +2137,15 @@ function RolePlugin.bind(Role)
2013 return {list = list, rank = rank} 2137 return {list = list, rank = rank}
2014 end 2138 end
2015 2139
  2140 + function Role:addHeroFaith(heroId, exp)
  2141 + local hero = self.heros[heroId]
  2142 + if not hero then
  2143 + return
  2144 + end
  2145 +
  2146 + hero:addHeroFaith(exp)
  2147 + return hero:getProperty("faith")
  2148 + end
2016 2149
2017 end 2150 end
2018 2151
src/models/RolePvp.lua
@@ -9,7 +9,7 @@ local PVP_RANK_TIME_SORT_PRECISION = 360 -- 时间精度 每6分钟忽略差异 @@ -9,7 +9,7 @@ local PVP_RANK_TIME_SORT_PRECISION = 360 -- 时间精度 每6分钟忽略差异
9 local PVP_RANK_BASE_SCORE = globalCsv.pvp_base_score -- 初始积分 9 local PVP_RANK_BASE_SCORE = globalCsv.pvp_base_score -- 初始积分
10 10
11 -- 匹配规则改为以排名来匹配 11 -- 匹配规则改为以排名来匹配
12 -local PVP_GET_ROBOT_SCORE = 2400 -- 2400分以下低档位匹配机器人 12 +local PVP_GET_ROBOT_SCORE = 1300 -- 1300分以下低档位匹配机器人
13 local PRE_RANGE_COUNT = 20 -- 每个档位人数 13 local PRE_RANGE_COUNT = 20 -- 每个档位人数
14 local NEED_MATCH = 3 --匹配到多少人 14 local NEED_MATCH = 3 --匹配到多少人
15 15
@@ -73,7 +73,7 @@ function Role:changePvpScoreCommon(matchId, isWin) @@ -73,7 +73,7 @@ function Role:changePvpScoreCommon(matchId, isWin)
73 if isWin then 73 if isWin then
74 local scoreChange = math.ceil(60 / (1 + 10 ^ ((myScore - matchScore) / 400))) 74 local scoreChange = math.ceil(60 / (1 + 10 ^ ((myScore - matchScore) / 400)))
75 myScore = myScore + scoreChange 75 myScore = myScore + scoreChange
76 - matchScore = matchScore - math.ceil(scoreChange / 3) -- 防守方失败时,扣分减为原来的1/3 76 + matchScore = matchScore - math.ceil(scoreChange / 3 * 2) -- 防守方失败时,扣分减为原来的2/3
77 else 77 else
78 local scoreChange = math.ceil(60 / (1 + 10 ^ ((matchScore - myScore) / 400))) 78 local scoreChange = math.ceil(60 / (1 + 10 ^ ((matchScore - myScore) / 400)))
79 myScore = myScore - scoreChange 79 myScore = myScore - scoreChange
@@ -139,7 +139,7 @@ function Role:changePvpScoreHigh(matchId, isWin) @@ -139,7 +139,7 @@ function Role:changePvpScoreHigh(matchId, isWin)
139 if isWin then 139 if isWin then
140 local scoreChange = math.ceil(50 / (1 + 10 ^ ((myScore - matchScore) / 1000))) 140 local scoreChange = math.ceil(50 / (1 + 10 ^ ((myScore - matchScore) / 1000)))
141 myScore = myScore + scoreChange 141 myScore = myScore + scoreChange
142 - matchScore = matchScore - math.ceil(scoreChange / 3) -- 防守方失败时,扣分减为原来的1/3 142 + matchScore = matchScore - math.ceil(scoreChange / 3 * 2) -- 防守方失败时,扣分减为原来的2/3
143 else 143 else
144 local scoreChange = math.ceil(50 / (1 + 10 ^ ((matchScore - myScore) / 1000))) 144 local scoreChange = math.ceil(50 / (1 + 10 ^ ((matchScore - myScore) / 1000)))
145 myScore = myScore - scoreChange 145 myScore = myScore - scoreChange
@@ -521,7 +521,7 @@ function Role:changeCrossServerPvpSelfInfo(cType) @@ -521,7 +521,7 @@ function Role:changeCrossServerPvpSelfInfo(cType)
521 change[cType] = self:getProperty(cType) 521 change[cType] = self:getProperty(cType)
522 elseif cType == "format" then 522 elseif cType == "format" then
523 -- 是否过了时间 523 -- 是否过了时间
524 - local crossTime = skynet.timex() - self:getTimeResetStartTime(TimeReset.PvpCross) 524 + local crossTime = skynet.timex() - self:getTimeResetStartTime(TimeReset.PvpCross) + RESET_TIME * 3600
525 local aday = 3600 * 24 525 local aday = 3600 * 24
526 local day = math.ceil(crossTime / aday) -- 当前是第几个比赛日 526 local day = math.ceil(crossTime / aday) -- 当前是第几个比赛日
527 local ctime = crossTime % aday -- 当前在本天 经过多少时间 527 local ctime = crossTime % aday -- 当前在本天 经过多少时间
@@ -530,7 +530,7 @@ function Role:changeCrossServerPvpSelfInfo(cType) @@ -530,7 +530,7 @@ function Role:changeCrossServerPvpSelfInfo(cType)
530 return 530 return
531 end 531 end
532 change.battleV = self:getProperty("pvpTBVH") 532 change.battleV = self:getProperty("pvpTBVH")
533 - change.heros = self:getProperty("pvpTSH") 533 + change.team = self:getProperty("pvpTSH")
534 change.battleInfo = self:getProperty("pvpTBH") 534 change.battleInfo = self:getProperty("pvpTBH")
535 end 535 end
536 536
@@ -615,7 +615,7 @@ end @@ -615,7 +615,7 @@ end
615 615
616 function Role:setCrossServerPvpBet(idx) 616 function Role:setCrossServerPvpBet(idx)
617 if not self:isTimeResetOpen(TimeReset.PvpCross) then return false , 1 end 617 if not self:isTimeResetOpen(TimeReset.PvpCross) then return false , 1 end
618 - local crossTime = skynet.timex() - self:getTimeResetStartTime(TimeReset.PvpCross) 618 + local crossTime = skynet.timex() - self:getTimeResetStartTime(TimeReset.PvpCross) + RESET_TIME * 3600
619 local aday = 3600 * 24 619 local aday = 3600 * 24
620 local day = math.ceil(crossTime / aday) -- 当前是第几个比赛日 620 local day = math.ceil(crossTime / aday) -- 当前是第几个比赛日
621 local ctime = crossTime % aday -- 当前在本天 经过多少时间 621 local ctime = crossTime % aday -- 当前在本天 经过多少时间
src/models/RoleTask.lua
@@ -15,6 +15,7 @@ local TaskType = { @@ -15,6 +15,7 @@ local TaskType = {
15 HeroLvlCollect = 10, -- 英雄等级收集进度 15 HeroLvlCollect = 10, -- 英雄等级收集进度
16 HeroQualityCollect = 11, -- 英雄品质收集进度 16 HeroQualityCollect = 11, -- 英雄品质收集进度
17 HeroStarCollect = 12, -- 英雄星级收集进度 17 HeroStarCollect = 12, -- 英雄星级收集进度
  18 + DrawHeroNotFriend = 13, -- 非友情招募 -- count
18 19
19 --装备相关 20 --装备相关
20 AddEquip = 101, -- 获得装备 - equipId rarity 21 AddEquip = 101, -- 获得装备 - equipId rarity
@@ -34,6 +35,7 @@ local TaskType = { @@ -34,6 +35,7 @@ local TaskType = {
34 HangBattle = 304, -- 挂机战斗 - id 35 HangBattle = 304, -- 挂机战斗 - id
35 HangGetGold = 305, -- 挂机获得齿轮 - count 36 HangGetGold = 305, -- 挂机获得齿轮 - count
36 BonusPass = 306, -- 奖励副本通关 - id count 37 BonusPass = 306, -- 奖励副本通关 - id count
  38 + BonusQuick = 307, -- 奖励关卡扫荡 -- id count
37 39
38 -- 冒险相关 40 -- 冒险相关
39 AdvPass = 401, -- 冒险通过关 - id level score 41 AdvPass = 401, -- 冒险通过关 - id level score
@@ -50,6 +52,10 @@ local TaskType = { @@ -50,6 +52,10 @@ local TaskType = {
50 AdvHang = 412, -- 代理拾荒次数 52 AdvHang = 412, -- 代理拾荒次数
51 AdvMineKill = 413, -- 宝藏怪击杀 53 AdvMineKill = 413, -- 宝藏怪击杀
52 AdvMineLayer = 414, -- 宝藏洞激活 54 AdvMineLayer = 414, -- 宝藏洞激活
  55 + AdvKillBoss = 415, -- 拾荒击杀boss
  56 + AdvHangHeroCnt = 416, -- 拾荒人数
  57 + AdvCostPower = 417, -- 消耗体力
  58 + AdvPassFirst = 418, -- 冒险首次通关 - id
53 59
54 --爬塔相关 60 --爬塔相关
55 TowerPass = 501, -- 爬塔通关 - level 61 TowerPass = 501, -- 爬塔通关 - level
@@ -91,6 +97,13 @@ local TaskType = { @@ -91,6 +97,13 @@ local TaskType = {
91 SignIn = 901, -- 签到 97 SignIn = 901, -- 签到
92 Pay = 902, -- 充值 98 Pay = 902, -- 充值
93 ShopAll = 903, -- 在任意商店购买 99 ShopAll = 903, -- 在任意商店购买
  100 + DailyTask = 904, -- 完成每日活跃任务
  101 + RadioTaskStart = 905, -- 电台任务开始
  102 + FinishSpeTask = 906, -- 指定任务完成
  103 + AddItem = 907, -- 获得道具
  104 + Login = 908, -- 登入
  105 + CostDiamond = 909, -- 消耗钻石
  106 + WeekTask = 910, -- 完成每周活跃任务
94 107
95 --功能未实现 todo 108 --功能未实现 todo
96 AdvShop = 1002, -- 冒险商城 109 AdvShop = 1002, -- 冒险商城
@@ -231,6 +244,8 @@ local ActivityListener = { @@ -231,6 +244,8 @@ local ActivityListener = {
231 [TaskType.Pay] = {{Activity.ActivityType.PayBack, f("twd")}}, 244 [TaskType.Pay] = {{Activity.ActivityType.PayBack, f("twd")}},
232 [TaskType.AdvMineKill] = {{Activity.ActivityType.Crisis, 1}}, 245 [TaskType.AdvMineKill] = {{Activity.ActivityType.Crisis, 1}},
233 [TaskType.AdvMineLayer] = {{Activity.ActivityType.Crisis, 2}}, 246 [TaskType.AdvMineLayer] = {{Activity.ActivityType.Crisis, 2}},
  247 + [TaskType.DailyTask] = {{Activity.ActivityType.CommonSignIn, f("pre"), f("cur")}},
  248 + [TaskType.AddItem] = {{Activity.ActivityType.BattleCommand, f("id"), f("count")}},
234 } 249 }
235 } 250 }
236 251
@@ -240,7 +255,7 @@ local StoreListener = { @@ -240,7 +255,7 @@ local StoreListener = {
240 [TaskType.HangPass] = {{TriggerEventType.HangPass, f("id")}}, 255 [TaskType.HangPass] = {{TriggerEventType.HangPass, f("id")}},
241 [TaskType.RoleLevelUp] = {{TriggerEventType.LevelUp, f("level")}}, 256 [TaskType.RoleLevelUp] = {{TriggerEventType.LevelUp, f("level")}},
242 [TaskType.TowerPass] = {{TriggerEventType.TowerPass, f("level")}}, 257 [TaskType.TowerPass] = {{TriggerEventType.TowerPass, f("level")}},
243 - [TaskType.AdvPass] = {{TriggerEventType.AdvPass, f("id")}}, 258 + [TaskType.AdvPassFirst] = {{TriggerEventType.AdvPass, f("id")}},
244 [TaskType.AddHero] = {{TriggerEventType.AddNewHero, f("heroType")}, {TriggerEventType.SSRCount, f("ssrCount")}}, 259 [TaskType.AddHero] = {{TriggerEventType.AddNewHero, f("heroType")}, {TriggerEventType.SSRCount, f("ssrCount")}},
245 } 260 }
246 } 261 }
@@ -268,9 +283,29 @@ local CalendaTaskListener = { @@ -268,9 +283,29 @@ local CalendaTaskListener = {
268 [TaskType.HangGet]= {{18, 3, f("reward")}}, 283 [TaskType.HangGet]= {{18, 3, f("reward")}},
269 [TaskType.RuneQualityCollect]= {{19, 3}}, 284 [TaskType.RuneQualityCollect]= {{19, 3}},
270 [TaskType.OpenBox]= {{20, 3, f("count"), f("quality")}}, 285 [TaskType.OpenBox]= {{20, 3, f("count"), f("quality")}},
  286 + [TaskType.RadioTaskStart] = {{21, 1}, {22, 3, f("heroCnt")}},
  287 + [TaskType.BonusQuick] = {{23, 1, f("count")}},
  288 + [TaskType.AdvHangHeroCnt] = {{24, 3, f("count")}},
  289 + [TaskType.AdvKillBoss] = {{25, 1}},
  290 + [TaskType.AdvMineKill] = {{26, 1}},
  291 + [TaskType.PvpBattle] = {{27, 1}},
  292 + [TaskType.FinishSpeTask] = {{28, 3, f("taskId"), f("actId")}},
  293 + [TaskType.Login] = {{29, 1}},
  294 + [TaskType.DailyTask] = {{30, 2, f("cur")}},
  295 + [TaskType.WeekTask] = {{31, 2, f("cur")}},
  296 + [TaskType.MakeFood] = {{32, 1, f("count")}},
  297 + [TaskType.AddItem] = {{33, 3, f("type"), f("count")}},
  298 + [TaskType.CostDiamond] = {{34, 1, f("count")}},
  299 + [TaskType.DrawHeroNotFriend] = {{35, 1, f("count")}},
  300 + [TaskType.AdvCostPower] = {{36, 1, f("count")}},
271 } 301 }
272 } 302 }
273 303
  304 +local BattleCommandTaskListener = {
  305 + func = "checkBattleCommandTask",
  306 + listen = CalendaTaskListener["listen"]
  307 +}
  308 +
274 local TaskListeners = { 309 local TaskListeners = {
275 StoryListener, 310 StoryListener,
276 CommonListener, 311 CommonListener,
@@ -279,6 +314,7 @@ local TaskListeners = { @@ -279,6 +314,7 @@ local TaskListeners = {
279 ActivityListener, 314 ActivityListener,
280 StoreListener, 315 StoreListener,
281 CalendaTaskListener, 316 CalendaTaskListener,
  317 + BattleCommandTaskListener,
282 } 318 }
283 319
284 local RoleTask = {} 320 local RoleTask = {}
@@ -607,15 +643,136 @@ function RoleTask.bind(Role) @@ -607,15 +643,136 @@ function RoleTask.bind(Role)
607 end 643 end
608 644
609 function Role:checkCalendaTask(notNotify, mainType, subType, param1, param2) 645 function Role:checkCalendaTask(notNotify, mainType, subType, param1, param2)
610 - --print("check calenda taskl", mainType, subType, param1, param2) 646 + --print("check calenda task", mainType, subType, param1, param2)
  647 + local actEnum = "CalendaTask"
  648 + local keyName = "calTask"
  649 + if not self.activity then return end
  650 + local open, actId = self.activity:isOpen(actEnum)
  651 + local actData = csvdb["activity_ctrlCsv"][actId]
  652 + if not actData then return end
  653 + if not open then return end
  654 +
  655 + local change = false
  656 + local calTask = self:getProperty(keyName) or {}
  657 + param1 = param1 or 1
  658 +
  659 + local cid = actData.condition
  660 + for k, taskList in pairs(csvdb["activity_taskCsv"]) do
  661 + if k == cid then
  662 + for id, cfg in pairs(taskList) do
  663 + if cfg.type == mainType then
  664 + if subType == 1 then -- 增加数值
  665 + calTask[id] = (calTask[id] or 0) + param1
  666 + elseif subType == 2 then -- 直接赋值
  667 + calTask[id] = param1
  668 + elseif subType == 3 then -- 自定义类型
  669 + if cfg.type == 7 then -- 英雄品质收集进度
  670 + local count = 0
  671 + for _, hero in pairs(self.heros) do
  672 + local unitData = csvdb["unitCsv"][hero:getProperty("type")]
  673 + if unitData then
  674 + if cfg.condition2 <= unitData.rare then
  675 + count = count + 1
  676 + end
  677 + end
  678 + end
  679 + if (calTask[id] or 0) < count then
  680 + calTask[id] = count
  681 + end
  682 + elseif cfg.type == 5 then -- 英雄等级收集进度
  683 + local count = 0
  684 + for _, hero in pairs(self.heros) do
  685 + if cfg.condition2 <= hero:getProperty("level") then
  686 + count = count + 1
  687 + end
  688 + end
  689 + if (calTask[id] or 0) < count then
  690 + calTask[id] = count
  691 + end
  692 + elseif cfg.type == 16 then -- 英雄星级收集进度
  693 + local count = 0
  694 + for _, hero in pairs(self.heros) do
  695 + if cfg.condition2 <= hero:getProperty("wakeL") then
  696 + count = count + 1
  697 + end
  698 + end
  699 + if (calTask[id] or 0) < count then
  700 + calTask[id] = count
  701 + end
  702 + elseif cfg.type == 18 then -- 挂机累计收获id,y个
  703 + for rid, v in pairs(param1) do
  704 + if cfg.condition2 == rid then
  705 + calTask[id] = (calTask[id] or 0) + v
  706 + end
  707 + end
  708 + elseif cfg.type == 19 then -- x名英雄装备y品质以上符文套装
  709 + local count = 0
  710 + for _, hero in pairs(self.heros) do
  711 + local rcount = 0
  712 + for _,uid in pairs(hero:getRunes()) do
  713 + if uid > 0 then
  714 + local runeData = self.runeBag[uid]
  715 + if runeData then
  716 + local csvData = csvdb["runeCsv"][runeData:getProperty("type")][runeData:getProperty("id")]
  717 +
  718 + if csvData and cfg.condition2 <= csvData.rarity then
  719 + rcount = rcount + 1
  720 + end
  721 + end
  722 + end
  723 + end
  724 + if rcount == 6 then
  725 + count = count + 1
  726 + end
  727 + end
  728 + calTask[id] = count
  729 + elseif cfg.type == 20 then -- 开启x品质时钟箱子
  730 + if cfg.condition2 <= (param2 or 0) then
  731 + calTask[id] = (calTask[id] or 0) + param1
  732 + end
  733 + elseif cfg.type == 15 then -- 通关关卡
  734 + if (calTask[id] or 0) == 0 then
  735 + local hangPass = self:getProperty("hangPass")
  736 + local diff = math.floor(cfg.condition2 / 10000)
  737 + if (hangPass[diff] or 0) >= cfg.condition1 then
  738 + calTask[id] = 1
  739 + end
  740 + end
  741 + elseif cfg.type == 22 then -- 电台任务出勤人数
  742 + calTask[id] = (calTask[id] or 0) + (param1 or 0)
  743 + elseif cfg.type == 24 then -- 代理拾荒出勤人数
  744 + calTask[id] = (calTask[id] or 0) + (param1 or 0)
  745 + elseif cfg.type == 28 then -- 完成指定任务
  746 + --print(actId,param2, cfg.condition2, param1)
  747 + if actId == param2 and cfg.condition2 == param1 then
  748 + calTask[id] = (calTask[id] or 0) + 1
  749 + end
  750 + elseif cfg.type == 33 then -- 获得指定类型道具多少个
  751 + if cfg.condition2 == param1 then
  752 + calTask[id] = (calTask[id] or 0) + (param2 or 0)
  753 + end
  754 + end
  755 + end
  756 + end
  757 + end
  758 + end
  759 + end
  760 + self:updateProperty({field = keyName, value = calTask, notNotify = notNotify})
  761 + --dump(calTask)
  762 + end
  763 +
  764 + function Role:checkBattleCommandTask(notNotify, mainType, subType, param1, param2)
  765 + --print("check battle command task", mainType, subType, param1, param2)
  766 + local actEnum = "BattleCommandTask"
  767 + local keyName = "bcTask"
611 if not self.activity then return end 768 if not self.activity then return end
612 - local open, actId = self.activity:isOpen("CalendaTask") 769 + local open, actId = self.activity:isOpen(actEnum)
613 local actData = csvdb["activity_ctrlCsv"][actId] 770 local actData = csvdb["activity_ctrlCsv"][actId]
614 if not actData then return end 771 if not actData then return end
615 if not open then return end 772 if not open then return end
616 773
617 local change = false 774 local change = false
618 - local calTask = self:getProperty("calTask") or {} 775 + local calTask = self:getProperty(keyName) or {}
619 param1 = param1 or 1 776 param1 = param1 or 1
620 777
621 local cid = actData.condition 778 local cid = actData.condition
@@ -690,7 +847,7 @@ function RoleTask.bind(Role) @@ -690,7 +847,7 @@ function RoleTask.bind(Role)
690 calTask[id] = count 847 calTask[id] = count
691 elseif cfg.type == 20 then -- 开启x品质时钟箱子 848 elseif cfg.type == 20 then -- 开启x品质时钟箱子
692 if cfg.condition2 <= (param2 or 0) then 849 if cfg.condition2 <= (param2 or 0) then
693 - calTask[id] = (calTask[id] or 0) + param2 850 + calTask[id] = (calTask[id] or 0) + param1
694 end 851 end
695 elseif cfg.type == 15 then -- 通关关卡 852 elseif cfg.type == 15 then -- 通关关卡
696 if (calTask[id] or 0) == 0 then 853 if (calTask[id] or 0) == 0 then
@@ -700,16 +857,29 @@ function RoleTask.bind(Role) @@ -700,16 +857,29 @@ function RoleTask.bind(Role)
700 calTask[id] = 1 857 calTask[id] = 1
701 end 858 end
702 end 859 end
  860 + elseif cfg.type == 22 then -- 电台任务出勤人数
  861 + calTask[id] = (calTask[id] or 0) + (param1 or 0)
  862 + elseif cfg.type == 24 then -- 代理拾荒出勤人数
  863 + calTask[id] = (calTask[id] or 0) + (param1 or 0)
  864 + elseif cfg.type == 28 then -- 完成指定任务
  865 + --print(actId,param2, cfg.condition2, param1)
  866 + if actId == param2 and cfg.condition2 == param1 then
  867 + calTask[id] = (calTask[id] or 0) + 1
  868 + end
  869 + elseif cfg.type == 33 then -- 获得指定类型道具多少个
  870 + if cfg.condition2 == param1 then
  871 + calTask[id] = (calTask[id] or 0) + (param2 or 0)
  872 + end
703 end 873 end
704 end 874 end
705 end 875 end
706 end 876 end
707 end 877 end
708 end 878 end
709 - self:updateProperty({field = "calTask", value = calTask, notNotify = notNotify}) 879 + self:updateProperty({field = keyName, value = calTask, notNotify = notNotify})
710 --dump(calTask) 880 --dump(calTask)
711 end 881 end
712 882
713 end 883 end
714 884
715 -return RoleTask  
716 \ No newline at end of file 885 \ No newline at end of file
  886 +return RoleTask
src/models/RoleTimeReset.lua
@@ -23,6 +23,11 @@ ResetFunc[&quot;CrossDay&quot;] = function(self, notify, response, now) @@ -23,6 +23,11 @@ ResetFunc[&quot;CrossDay&quot;] = function(self, notify, response, now)
23 end 23 end
24 self:setProperty("advMine", advMine) 24 self:setProperty("advMine", advMine)
25 25
  26 + local ltime = self:getProperty("ltime")
  27 + if isCrossMonth(ltime, now) then
  28 + self.storeData:resetStoreReored(3) --商店跨月重置 time_reset表关联id
  29 + end
  30 +
26 response.dTask = {} 31 response.dTask = {}
27 response.advSup = self:getProperty("advSup") 32 response.advSup = self:getProperty("advSup")
28 self:log("onLogin") 33 self:log("onLogin")
@@ -41,13 +46,8 @@ ResetFunc[&quot;CrossWeek&quot;] = function(self, notify, response) @@ -41,13 +46,8 @@ ResetFunc[&quot;CrossWeek&quot;] = function(self, notify, response)
41 46
42 response.wTask = {} 47 response.wTask = {}
43 response.dinerS = {} 48 response.dinerS = {}
44 -end  
45 49
46 -ResetFunc["CrossMonth"] = function(self, notify, response)  
47 - local ltime = self:getProperty("ltime")  
48 - if isCrossMonth(ltime, skynet.timex()) then  
49 - self.storeData:resetStoreReored(3) --商店跨月重置 time_reset表关联id  
50 - end 50 + self.activity:refreshWeekData(notify)
51 end 51 end
52 52
53 53
@@ -89,13 +89,10 @@ function Role:updateTimeReset(now, notify) @@ -89,13 +89,10 @@ function Role:updateTimeReset(now, notify)
89 ResetFunc[funcName](self, notify, response, now) 89 ResetFunc[funcName](self, notify, response, now)
90 resetMode[funcName] = true 90 resetMode[funcName] = true
91 end 91 end
92 - if needResetId[resetId] then  
93 - -- 充值商城购买记录  
94 - self.storeData:resetStoreReored(resetId)  
95 - end  
96 end 92 end
97 93
98 for resetId, round in pairs(needResetId) do 94 for resetId, round in pairs(needResetId) do
  95 + self.storeData:resetStoreReored(resetId)
99 timeReset[resetId] = round 96 timeReset[resetId] = round
100 end 97 end
101 self:setProperties({timeReset = timeReset, ltime = now}) 98 self:setProperties({timeReset = timeReset, ltime = now})
src/models/Store.lua
@@ -186,7 +186,7 @@ end @@ -186,7 +186,7 @@ end
186 186
187 187
188 -- 购买通行证 188 -- 购买通行证
189 -function Store:onBuyCard(type, duration, id) 189 +function Store:onBuyCard(type, duration, id, actid)
190 local timeNow = skynet.timex() 190 local timeNow = skynet.timex()
191 if type == CardType.NormalMonthCard then 191 if type == CardType.NormalMonthCard then
192 if self:isMonthCardExpire() then 192 if self:isMonthCardExpire() then
@@ -221,6 +221,18 @@ function Store:onBuyCard(type, duration, id) @@ -221,6 +221,18 @@ function Store:onBuyCard(type, duration, id)
221 info["flag"] = 1 221 info["flag"] = 1
222 bpInfo[index] = info 222 bpInfo[index] = info
223 self:updateProperty({field = "bpInfo", value = bpInfo}) 223 self:updateProperty({field = "bpInfo", value = bpInfo})
  224 + elseif type == CardType.ActBattleCommandCard then
  225 + if not self.owner.activity:isOpenById(actid, "ActShopGoods") then
  226 + return
  227 + end
  228 + local actCfg = csvdb["activity_ctrlCsv"][actid]
  229 + if not actCfg then return end
  230 + local actData = self.owner.activity:getActData("BattleCommand") or {}
  231 + actData["unlock"] = 1
  232 + if actCfg.condition ~= 0 then
  233 + actData["lvl"] = (actData["lvl"] or 0) + actCfg.condition
  234 + end
  235 + self.owner.activity:updateActData("BattleCommand", actData)
224 end 236 end
225 end 237 end
226 238
src/services/globald.lua
@@ -69,7 +69,8 @@ local function mailQuene() @@ -69,7 +69,8 @@ local function mailQuene()
69 "attachments", email.attachments, 69 "attachments", email.attachments,
70 "endtime", email.endTime, 70 "endtime", email.endTime,
71 "mid", email.mid, 71 "mid", email.mid,
72 - "timestamp", now 72 + "timestamp", now,
  73 + "delayType", email.delayType
73 ) 74 )
74 else 75 else
75 redisproxy:hmset(string_format("globalEmail:%s", gid), 76 redisproxy:hmset(string_format("globalEmail:%s", gid),
@@ -80,7 +81,8 @@ local function mailQuene() @@ -80,7 +81,8 @@ local function mailQuene()
80 "content", email.content, 81 "content", email.content,
81 "attachments", email.attachments, 82 "attachments", email.attachments,
82 "endtime", email.endTime, 83 "endtime", email.endTime,
83 - "timestamp", now 84 + "timestamp", now,
  85 + "delayType", email.delayType
84 ) 86 )
85 end 87 end
86 end 88 end
src/services/httpweb.lua
@@ -41,8 +41,10 @@ local port = ... @@ -41,8 +41,10 @@ local port = ...
41 port = tonumber(port) 41 port = tonumber(port)
42 42
43 local key = "zhaolu1234dangge" 43 local key = "zhaolu1234dangge"
44 -local function response(id, ...)  
45 - local ok, err = httpd.write_response(sockethelper.writefunc(id), ...) 44 +local function response(id, code, body)
  45 + local ok, err = httpd.write_response(sockethelper.writefunc(id), code, body, {
  46 + ["Connection"] = "Close",
  47 + })
46 if not ok then 48 if not ok then
47 -- if err == sockethelper.socket_error , that means socket closed. 49 -- if err == sockethelper.socket_error , that means socket closed.
48 skynet.error(string.format("fd = %d, %s", id, err)) 50 skynet.error(string.format("fd = %d, %s", id, err))
src/services/pvpd.lua
@@ -84,7 +84,7 @@ function CMD.updateRoleInfo(change) @@ -84,7 +84,7 @@ function CMD.updateRoleInfo(change)
84 CMD.refreshRoleInfo(change) 84 CMD.refreshRoleInfo(change)
85 local pvpd = cluster.query("center", "pvpd") 85 local pvpd = cluster.query("center", "pvpd")
86 if pvpd then 86 if pvpd then
87 - pcall(cluster.call, "center", pvpd, "updateRoleInfo", change) 87 + pcall(cluster.send, "center", pvpd, "updateRoleInfo", change)
88 end 88 end
89 end 89 end
90 90
@@ -92,7 +92,7 @@ local function getDayAndTime() @@ -92,7 +92,7 @@ local function getDayAndTime()
92 local startTime = getStartTime() 92 local startTime = getStartTime()
93 local now = skynet.timex() 93 local now = skynet.timex()
94 94
95 - local crossTime = now - startTime 95 + local crossTime = now - startTime + RESET_TIME * 3600
96 local aday = 3600 * 24 96 local aday = 3600 * 24
97 local day = math.ceil(crossTime / aday) -- 当前是第几个比赛日 97 local day = math.ceil(crossTime / aday) -- 当前是第几个比赛日
98 local ctime = crossTime % aday -- 当前在本天 经过多少时间 98 local ctime = crossTime % aday -- 当前在本天 经过多少时间
src/utils/CommonFunc.lua
@@ -100,7 +100,7 @@ end @@ -100,7 +100,7 @@ end
100 -- 判断是不是同一个月 100 -- 判断是不是同一个月
101 function isCrossMonth(target, now) 101 function isCrossMonth(target, now)
102 now = now or skynet.timex() 102 now = now or skynet.timex()
103 - local tarTm = os.date("*t", target) 103 + local tarTm = os.date("*t", target - RESET_TIME * 3600)
104 local nowTm = os.date("*t", now - RESET_TIME * 3600) 104 local nowTm = os.date("*t", now - RESET_TIME * 3600)
105 if tarTm.year == nowTm.year and tarTm.month == nowTm.month then 105 if tarTm.year == nowTm.year and tarTm.month == nowTm.month then
106 return false 106 return false