Commit 98be031a95ed3dd5bee1ad553e5237d256c9d259
1 parent
c3c1b7e0
新年活动
Showing
9 changed files
with
159 additions
and
12 deletions
Show diff stats
src/ProtocolCode.lua
| ... | ... | @@ -234,6 +234,8 @@ actionCodes = { |
| 234 | 234 | Activity_battleCommandRpc = 668, |
| 235 | 235 | Activity_actCalendaTmpTaskRpc = 669, |
| 236 | 236 | Activity_newSignRpc = 670, |
| 237 | + Activity_advLevelRpc = 671, | |
| 238 | + Activity_buyBattleCommandLvlRpc = 672, | |
| 237 | 239 | |
| 238 | 240 | Radio_startQuestRpc = 700, |
| 239 | 241 | Radio_finishQuestRpc = 701, | ... | ... |
src/actions/ActivityAction.lua
| ... | ... | @@ -1152,6 +1152,7 @@ function _M.battleCommandRpc(agent, data) |
| 1152 | 1152 | local actid = msg.actid -- 活动id |
| 1153 | 1153 | local index = msg.index -- 领取的阶段id |
| 1154 | 1154 | local pay = msg.pay -- 是否是超级奖励 |
| 1155 | + print(actid, index, pay) | |
| 1155 | 1156 | |
| 1156 | 1157 | if not role.activity:isOpenById(actid, "BattleCommand") then return 1 end |
| 1157 | 1158 | local actCtrlData = csvdb["activity_ctrlCsv"][actid] |
| ... | ... | @@ -1167,7 +1168,7 @@ function _M.battleCommandRpc(agent, data) |
| 1167 | 1168 | bpCfg = bpCfg[index] |
| 1168 | 1169 | if not bpCfg then return 4 end |
| 1169 | 1170 | |
| 1170 | - if (actData["lvl"] or 0) < bpCfg["typeId"] then return 5 end | |
| 1171 | + if (actData["lvl"] or 0) < bpCfg["type"] then return 5 end | |
| 1171 | 1172 | |
| 1172 | 1173 | local record = "" |
| 1173 | 1174 | if pay then |
| ... | ... | @@ -1179,7 +1180,7 @@ function _M.battleCommandRpc(agent, data) |
| 1179 | 1180 | local flag = string.char(string.getbit(record, index)) |
| 1180 | 1181 | |
| 1181 | 1182 | if flag == "1" then |
| 1182 | - return 4 | |
| 1183 | + return 6 | |
| 1183 | 1184 | end |
| 1184 | 1185 | |
| 1185 | 1186 | record = string.setbit(record, index) |
| ... | ... | @@ -1204,6 +1205,7 @@ function _M.buyBattleCommandLvlRpc(agent, data) |
| 1204 | 1205 | local role = agent.role |
| 1205 | 1206 | local msg = MsgPack.unpack(data) |
| 1206 | 1207 | local actid = msg.actid -- 活动id |
| 1208 | + local count = msg.count | |
| 1207 | 1209 | |
| 1208 | 1210 | if not role.activity:isOpenById(actid, "BattleCommand") then return 1 end |
| 1209 | 1211 | local actCtrlData = csvdb["activity_ctrlCsv"][actid] |
| ... | ... | @@ -1216,13 +1218,13 @@ function _M.buyBattleCommandLvlRpc(agent, data) |
| 1216 | 1218 | local actData = role.activity:getActData("BattleCommand") or {} |
| 1217 | 1219 | |
| 1218 | 1220 | local curLvl = actData["lvl"] or 0 |
| 1219 | - local nextLvl = curLvl + 1 | |
| 1221 | + local nextLvl = curLvl + count | |
| 1220 | 1222 | if curLvl >= bpCfg[#bpCfg]["type"] then return 4 end |
| 1221 | 1223 | local cost = 0 |
| 1222 | 1224 | for i = 1, #bpCfg do |
| 1223 | 1225 | local cfg = bpCfg[i] |
| 1224 | - if cfg["type"] == curLvl then | |
| 1225 | - cost = cfg["cost"] | |
| 1226 | + if cfg["type"] > curLvl and cfg["type"] <= nextLvl then | |
| 1227 | + cost = cost + cfg["cost"] | |
| 1226 | 1228 | break |
| 1227 | 1229 | end |
| 1228 | 1230 | end |
| ... | ... | @@ -1267,4 +1269,41 @@ function _M.newSignRpc(agent, data) |
| 1267 | 1269 | return true |
| 1268 | 1270 | end |
| 1269 | 1271 | |
| 1272 | +-- 活动拾荒领取阶段奖励 | |
| 1273 | +function _M.advLevelRpc(agent, data) | |
| 1274 | + local role = agent.role | |
| 1275 | + local msg = MsgPack.unpack(data) | |
| 1276 | + local actid = msg.actid | |
| 1277 | + local index = msg.index | |
| 1278 | + | |
| 1279 | + if not role.activity:isOpenById(actid, "AdvLevel") then return 1 end | |
| 1280 | + | |
| 1281 | + local actCfg = csvdb["activity_stagesAwardCsv"][actid] | |
| 1282 | + if not actCfg then return 2 end | |
| 1283 | + actCfg = actCfg[index] | |
| 1284 | + if not actCfg then return 3 end | |
| 1285 | + | |
| 1286 | + local actData = role.activity:getActData("AdvLevel") or {} | |
| 1287 | + local record = actData["r"] | |
| 1288 | + local flag = string.char(string.getbit(record, index)) | |
| 1289 | + | |
| 1290 | + if flag == "1" then return 4 end | |
| 1291 | + | |
| 1292 | + local chapters = actCfg["condition2"]:toArray(true, "=") | |
| 1293 | + local totalVal = 0 | |
| 1294 | + for i = 1, #chapters do | |
| 1295 | + local cid = chapters[i] | |
| 1296 | + totalVal = totalVal + (actData[cid] or 0) | |
| 1297 | + end | |
| 1298 | + if totalVal < actCfg["condition1"] then return 5 end | |
| 1299 | + | |
| 1300 | + actData["r"] = string.setbit(record, index) | |
| 1301 | + role.activity:updateActData("AdvLevel", actData) | |
| 1302 | + | |
| 1303 | + local reward, change = role:award(actCfg.reward, {log = {desc = "advLevelStage", int1 = actid, int2 = index}}) | |
| 1304 | + | |
| 1305 | + SendPacket(actionCodes.Activity_advLevelRpc, MsgPack.pack(role:packReward(reward, change))) | |
| 1306 | + return true | |
| 1307 | +end | |
| 1308 | + | |
| 1270 | 1309 | return _M | ... | ... |
src/actions/AdvAction.lua
| ... | ... | @@ -86,6 +86,7 @@ function _M.startAdvRpc( agent, data ) |
| 86 | 86 | local role = agent.role |
| 87 | 87 | local msg = MsgPack.unpack(data) |
| 88 | 88 | local chapterId = msg.chapterId --关卡id |
| 89 | + local actid = msg.actid --活动id | |
| 89 | 90 | local layer = msg.layer or 1 --选择层数 |
| 90 | 91 | --local format = msg.format --编队 |
| 91 | 92 | local supportIdx = msg.supportIdx --选择的支援效果 |
| ... | ... | @@ -96,6 +97,36 @@ function _M.startAdvRpc( agent, data ) |
| 96 | 97 | local advHang = role:getProperty("advHang") |
| 97 | 98 | -- if advHang[chapterId] then return 9 end --正在挂机 |
| 98 | 99 | |
| 100 | + -- 检查活动正确性 | |
| 101 | + if actid then | |
| 102 | + if not role.activity:isOpenById(actid, "AdvLevel") then | |
| 103 | + return 20 | |
| 104 | + end | |
| 105 | + local actCfg = csvdb["activity_adv_chapterCsv"][actid] | |
| 106 | + if not actCfg then return 21 end | |
| 107 | + actCfg = actCfg[chapterId] | |
| 108 | + if not actCfg then return 22 end | |
| 109 | + | |
| 110 | + local st = toUnixtime(actCfg["unlockTime"]..string_format("%02x", RESET_TIME)) | |
| 111 | + if st > skynet.timex() then return 23 end | |
| 112 | + | |
| 113 | + if actCfg["prepose"] ~= "" then | |
| 114 | + local type, cid = actCfg["prepose"]:toArray(true, "=") | |
| 115 | + if type == 1 then | |
| 116 | + local actData = role.activity:getActData("ChallengeLevel") | |
| 117 | + local battleInfo = actData[cid] or {} | |
| 118 | + if (battleInfo["star"] or 0) == 0 then | |
| 119 | + return 24 | |
| 120 | + end | |
| 121 | + elseif type == 2 then | |
| 122 | + local actData = role.activity:getActData("AdvLevel") | |
| 123 | + local advInfo = actData[cid] or {} | |
| 124 | + if not advInfo["pass"] then | |
| 125 | + return 25 | |
| 126 | + end | |
| 127 | + end | |
| 128 | + end | |
| 129 | + end | |
| 99 | 130 | |
| 100 | 131 | local chapterData = csvdb["adv_chapterCsv"][chapterId] |
| 101 | 132 | if not chapterData or layer < 1 then return 1 end |
| ... | ... | @@ -174,6 +205,7 @@ function _M.startAdvRpc( agent, data ) |
| 174 | 205 | isRelay = layer ~= 1, |
| 175 | 206 | isEnter = true, |
| 176 | 207 | support = support, |
| 208 | + actid = actid | |
| 177 | 209 | }) |
| 178 | 210 | role:checkTaskEnter("AdvStart", {id = chapterId}) |
| 179 | 211 | role:checkTaskEnter("AdvStartSelf", {id = chapterId}) | ... | ... |
src/adv/Adv.lua
| ... | ... | @@ -41,6 +41,7 @@ function Adv:initByInfo(advInfo) |
| 41 | 41 | |
| 42 | 42 | self.chapterId = advInfo.chapterId |
| 43 | 43 | self.level = advInfo.level or 1 |
| 44 | + self.actid = advInfo.actid | |
| 44 | 45 | self.round = advInfo.round or 0 |
| 45 | 46 | self.score = advInfo.score or {} |
| 46 | 47 | self.isRelay = advInfo.isRelay |
| ... | ... | @@ -85,6 +86,7 @@ function Adv:initByChapter(params) |
| 85 | 86 | local isEnter = params.isEnter |
| 86 | 87 | local support = params.support |
| 87 | 88 | local debugMapId = params.debugMapId |
| 89 | + local actid = params.actid | |
| 88 | 90 | |
| 89 | 91 | if not self.chapterId then -- 开始新的章节 |
| 90 | 92 | self.chapterId = chapterId |
| ... | ... | @@ -95,6 +97,7 @@ function Adv:initByChapter(params) |
| 95 | 97 | |
| 96 | 98 | self.level = level or 1 |
| 97 | 99 | self.round = 0 |
| 100 | + self.actid = self.actid or actid | |
| 98 | 101 | self.score = self.score or {} |
| 99 | 102 | self.lastEnemyId = 1 |
| 100 | 103 | self.mapStack = {1} -- 最后一个为当前的地图 |
| ... | ... | @@ -175,6 +178,7 @@ end |
| 175 | 178 | function Adv:clear() |
| 176 | 179 | self.chapterId = nil |
| 177 | 180 | self.level = nil |
| 181 | + self.actid = 0 | |
| 178 | 182 | self.score = {} |
| 179 | 183 | self.round = 0 |
| 180 | 184 | self.lastEnemyId = 1 |
| ... | ... | @@ -197,6 +201,7 @@ function Adv:saveDB(notNotify) |
| 197 | 201 | advInfo.level = self.level |
| 198 | 202 | advInfo.round = self.round |
| 199 | 203 | advInfo.score = self.score |
| 204 | + advInfo.actid = self.actid | |
| 200 | 205 | advInfo.isRelay = self.isRelay |
| 201 | 206 | advInfo.lastEId = self.lastEnemyId |
| 202 | 207 | advInfo.mstack = self.mapStack |
| ... | ... | @@ -793,9 +798,55 @@ function Adv:over(success, rewardRatio, overType) |
| 793 | 798 | |
| 794 | 799 | local score = self.owner:fixAdvScoreChange(self:getScore()) |
| 795 | 800 | local scoreInfo = self.score |
| 801 | + | |
| 802 | + local scoreCoef = chapterData.scoreAward | |
| 803 | + local itemId = ItemId.OldCoin | |
| 804 | + -- 拾荒活动关卡相关处理 | |
| 805 | + if self.actid then | |
| 806 | + while true do | |
| 807 | + if not self.owner.activity:isOpenById(self.actid, "AdvLevel") then | |
| 808 | + break | |
| 809 | + end | |
| 810 | + local actCfg = csvdb["activity_adv_chapterCsv"][self.actid] | |
| 811 | + if not actCfg then break end | |
| 812 | + actCfg = actCfg[self.chapterId] | |
| 813 | + if not actCfg then break end | |
| 814 | + itemId, scoreCoef = actCfg["transform"]:toArray(true, "=") | |
| 815 | + local actData = self.owner.activity:getActData("AdvLevel") | |
| 816 | + | |
| 817 | + -- 计算活动积分up | |
| 818 | + local upMap = actCfg["upCharacter"] | |
| 819 | + local team = self.owner:getProperty("advTeam") | |
| 820 | + local format = self.owner:getTeamHerosInfo(team).heros | |
| 821 | + local upVal = 0 | |
| 822 | + for _, hero in pairs(format) do | |
| 823 | + local heroId = hero["type"] | |
| 824 | + upVal = upVal + (upMap[heroId] or 0) | |
| 825 | + end | |
| 826 | + score = math.floor(score * (1 + upVal / 100)) | |
| 827 | + | |
| 828 | + local advInfo = actData[self.chapterId] or {} | |
| 829 | + local maxScore = advInfo["max"] or 0 | |
| 830 | + local flag = false | |
| 831 | + if success then | |
| 832 | + advInfo["pass"] = 1 | |
| 833 | + flag = true | |
| 834 | + end | |
| 835 | + -- 更新活动最大积分 | |
| 836 | + if score > maxScore then | |
| 837 | + advInfo["max"] = score | |
| 838 | + actData[self.chapterId] = advInfo | |
| 839 | + flag = true | |
| 840 | + end | |
| 841 | + if flag then | |
| 842 | + self.owner.activity:updateActData("AdvLevel", actData) | |
| 843 | + end | |
| 844 | + break | |
| 845 | + end | |
| 846 | + end | |
| 796 | 847 | |
| 797 | - local scoreReward = math.floor(score / chapterData.scoreAward) | |
| 798 | - self.owner:award({[ItemId.OldCoin] = scoreReward}, {log = {desc = "advOver", int1 = self.chapterId}}) | |
| 848 | + local scoreReward = math.floor(score / scoreCoef) | |
| 849 | + self.owner:award({[itemId] = scoreReward}, {log = {desc = "advOver", int1 = self.chapterId}}) | |
| 799 | 850 | |
| 800 | 851 | -- 被动技会影响奖励 |
| 801 | 852 | self.battle.player:triggerPassive(Passive.ADV_OVER, {score = score, level = self.level}) |
| ... | ... | @@ -832,7 +883,7 @@ function Adv:over(success, rewardRatio, overType) |
| 832 | 883 | |
| 833 | 884 | local roleId = self.owner:getProperty("id") |
| 834 | 885 | local oldMaxScore = tonum(redisproxy:zscore(self.owner:getAdvRankKey(), roleId)) |
| 835 | - if score > oldMaxScore then | |
| 886 | + if score > oldMaxScore and not self.actid then | |
| 836 | 887 | local team = self.owner:getProperty("advTeam") |
| 837 | 888 | local curInfo = { |
| 838 | 889 | name = self.owner:getProperty("name"), |
| ... | ... | @@ -918,6 +969,7 @@ function Adv:over(success, rewardRatio, overType) |
| 918 | 969 | scoreAward = scoreReward, |
| 919 | 970 | chapterId = chapterId, |
| 920 | 971 | backAdvCount = backAdvCount, |
| 972 | + actid = self.actid | |
| 921 | 973 | }) |
| 922 | 974 | end |
| 923 | 975 | ... | ... |
src/models/Activity.lua
| ... | ... | @@ -86,6 +86,8 @@ Activity.schema = { |
| 86 | 86 | act28 = {"table", {}}, -- 每日活跃签到 {0=day, 1=1,2=1,3=1} |
| 87 | 87 | act30 = {"table", {}}, -- {magic = 0, limit = 0, reward = {id = 1, id = 1}, giveAE = {}, getAE = {}} 奖励字段1表示领取过奖励 |
| 88 | 88 | |
| 89 | + act33 = {"table", {}}, -- 拾荒关卡活动 {id={max=最大积分, pass=1}, r=""} | |
| 90 | + | |
| 89 | 91 | act34 = {"table", {}}, -- 战令记录{unlock = 1, freeR = "", payR = "", lvl = 10, sum = 100} |
| 90 | 92 | act36 = {"table", {}}, -- 每日活跃签到 {0=day, 1=1,2=1,3=1} |
| 91 | 93 | } |
| ... | ... | @@ -112,6 +114,8 @@ function Activity:data() |
| 112 | 114 | act28 = self:getProperty("act28"), |
| 113 | 115 | act30 = self:getProperty("act30"), |
| 114 | 116 | |
| 117 | + act33 = self:getProperty("act33"), | |
| 118 | + | |
| 115 | 119 | act34 = self:getProperty("act34"), |
| 116 | 120 | act36 = self:getProperty("act36"), |
| 117 | 121 | } |
| ... | ... | @@ -975,6 +979,7 @@ activityFunc[Activity.ActivityType.BattleCommand] = { |
| 975 | 979 | self:updateActData(actType, data, not notify) |
| 976 | 980 | end, |
| 977 | 981 | ["check"] = function(self, actType, notify, id, count) -- 检查 itemid, count |
| 982 | + print("babababa", id, count) | |
| 978 | 983 | local isOpen, actId = self:isOpen(actType) |
| 979 | 984 | local actData = self:getActData(actType) or {} |
| 980 | 985 | local actCfg = csvdb["activity_ctrlCsv"][actId] |
| ... | ... | @@ -1026,4 +1031,20 @@ activityFunc[Activity.ActivityType.NewSign] = { |
| 1026 | 1031 | end, |
| 1027 | 1032 | } |
| 1028 | 1033 | |
| 1034 | +activityFunc[Activity.ActivityType.AdvLevel] = { | |
| 1035 | + -- ["check"] = function(self, actType, notify) -- 检查 | |
| 1036 | + -- end, | |
| 1037 | + ["init"] = function(self, actType, isCrossDay, notify) | |
| 1038 | + end, | |
| 1039 | + ["close"] = function(self, actType, notify, actid) | |
| 1040 | + local actCfg = csvdb["activity_adv_chapterCsv"][actid] | |
| 1041 | + if not actCfg then return end | |
| 1042 | + for chapterId, _ in ipairs(actCfg) do | |
| 1043 | + local advPass = self.owner:getProperty("advPass") | |
| 1044 | + advPass[chapterId] = nil | |
| 1045 | + self.owner:updateProperty({field="advPass", value=advPass}) | |
| 1046 | + end | |
| 1047 | + end, | |
| 1048 | +} | |
| 1049 | + | |
| 1029 | 1050 | return Activity | ... | ... |
src/models/RoleLog.lua
src/models/Store.lua
| ... | ... | @@ -222,17 +222,17 @@ function Store:onBuyCard(type, duration, id, actid) |
| 222 | 222 | bpInfo[index] = info |
| 223 | 223 | self:updateProperty({field = "bpInfo", value = bpInfo}) |
| 224 | 224 | elseif type == CardType.ActBattleCommandCard then |
| 225 | - if not self.owner.activity:isOpenById(actid, "BattleCommand") then | |
| 225 | + if not self.owner.activity:isOpenById(actid, "ActShopGoods") then | |
| 226 | 226 | return |
| 227 | 227 | end |
| 228 | 228 | local actCfg = csvdb["activity_ctrlCsv"][actid] |
| 229 | 229 | if not actCfg then return end |
| 230 | 230 | local actData = self.owner.activity:getActData("BattleCommand") or {} |
| 231 | - if actData["unlock"] == 1 then return end | |
| 232 | 231 | actData["unlock"] = 1 |
| 233 | 232 | if actCfg.condition ~= 0 then |
| 234 | 233 | actData["lvl"] = (actData["lvl"] or 0) + actCfg.condition |
| 235 | 234 | end |
| 235 | + self.owner.activity:updateActData("BattleCommand", actData) | |
| 236 | 236 | end |
| 237 | 237 | end |
| 238 | 238 | ... | ... |