Commit eab5a2d455e98fca9b82ab82dce1b7232a8a37a9
1 parent
1e2c5316
feat: 讨伐电台终止派遣改为消耗虹光玉加速
Showing
1 changed file
with
98 additions
and
75 deletions
Show diff stats
src/actions/RadioAction.lua
| @@ -35,6 +35,79 @@ local function getQuestMax(role) | @@ -35,6 +35,79 @@ local function getQuestMax(role) | ||
| 35 | return count + (globalCsv.cursade_team_count_initial or 0) | 35 | return count + (globalCsv.cursade_team_count_initial or 0) |
| 36 | end | 36 | end |
| 37 | 37 | ||
| 38 | +local function getCrusadeReward(role, id) | ||
| 39 | + local radioTask = role:getProperty("radioTask") | ||
| 40 | + local task = radioTask[id] | ||
| 41 | + if not task then return 1 end | ||
| 42 | + -- check id | ||
| 43 | + local config = csvdb["crusadeCsv"][id] | ||
| 44 | + if not config then return 2 end | ||
| 45 | + local carbonData = csvdb["idle_battleCsv"][config.unlock] | ||
| 46 | + if not carbonData then return 3 end | ||
| 47 | + -- get heros | ||
| 48 | + local totalCoef = 0 | ||
| 49 | + local exp = config.time / 60 | ||
| 50 | + local heroFaithMap = {} | ||
| 51 | + for _, heroId in ipairs(task.heros) do | ||
| 52 | + local hero = role.heros[heroId] | ||
| 53 | + if hero then | ||
| 54 | + totalCoef = totalCoef + getHeroCoef(hero, config.success) | ||
| 55 | + -- 增加英雄信赖 | ||
| 56 | + hero:addHeroFaith(exp) | ||
| 57 | + heroFaithMap[heroId] = hero:getProperty("faith") | ||
| 58 | + end | ||
| 59 | + end | ||
| 60 | + -- send award | ||
| 61 | + local bigSuccess = false | ||
| 62 | + local result = math.randomInt(0, 100) | ||
| 63 | + if result < totalCoef then | ||
| 64 | + bigSuccess = true | ||
| 65 | + end | ||
| 66 | + local money = math.ceil(carbonData.money / 5) * config.time * config.money_clear | ||
| 67 | + local exp = math.ceil(carbonData.exp / 5) * config.time * config.exp_clear | ||
| 68 | + local itemReward = config.item_clear_special:toNumMap() | ||
| 69 | + itemReward[ItemId.Gold] = (itemReward[ItemId.Gold] or 0) + money | ||
| 70 | + itemReward[ItemId.Exp] = (itemReward[ItemId.Exp] or 0) + exp | ||
| 71 | + if bigSuccess then | ||
| 72 | + for key, value in pairs(itemReward) do | ||
| 73 | + itemReward[key] = math.ceil(1.5 * value) | ||
| 74 | + end | ||
| 75 | + end | ||
| 76 | + | ||
| 77 | + local r, change = role:award(itemReward, {log = {desc = "radioQuest", int1 = id}}) | ||
| 78 | + | ||
| 79 | + radioTask[id] = nil | ||
| 80 | + role:updateProperty({field="radioTask", value=radioTask, notNotify = true}) | ||
| 81 | + | ||
| 82 | + local msg = role:packReward(r, change) | ||
| 83 | + msg["big"] = bigSuccess | ||
| 84 | + msg["id"] = id | ||
| 85 | + msg["heroFaith"] = heroFaithMap | ||
| 86 | + | ||
| 87 | + role:checkTaskEnter("RadioTaskStart", {heroCnt = #task.heros}) | ||
| 88 | + | ||
| 89 | + local herolist = {} | ||
| 90 | + for _, heroId in ipairs(task.heros) do | ||
| 91 | + local hero = role.heros[heroId] | ||
| 92 | + if hero then | ||
| 93 | + table.insert(herolist, hero:getProperty("type")) | ||
| 94 | + end | ||
| 95 | + end | ||
| 96 | + | ||
| 97 | + -- 讨伐行动 | ||
| 98 | + role:log("punitive_action", { | ||
| 99 | + mission_id = id, --关卡ID | ||
| 100 | + mission_herolist = herolist, -- 英雄ID,排序以玩家出战设置为准,示例:[111, 222, 333, 444, 555] | ||
| 101 | + mission_success_rate = totalCoef, -- 大成功几率 | ||
| 102 | + mission_reward = r, -- 获得奖励,建议使用json格式记录。示例:{ itemid1: 1, itemid2: 3, itemid3: 5} | ||
| 103 | + mission_result = 1, -- 战斗结果(0-无效,1-胜利,2-失败) | ||
| 104 | + mission_roundtime = config.time, -- 完成耗时(秒) | ||
| 105 | + mission_cleartype = 2, -- 1-开始; 2-完成(领取奖励时) | ||
| 106 | + }) | ||
| 107 | + role:mylog("role_action", {desc = "radioTask", int1 = id, short1 = bigSuccess and 1 or 0}) | ||
| 108 | + return msg | ||
| 109 | +end | ||
| 110 | + | ||
| 38 | function _M.startQuestRpc(agent, data) | 111 | function _M.startQuestRpc(agent, data) |
| 39 | local role = agent.role | 112 | local role = agent.role |
| 40 | local msg = MsgPack.unpack(data) | 113 | local msg = MsgPack.unpack(data) |
| @@ -132,76 +205,15 @@ function _M.finishQuestRpc(agent, data) | @@ -132,76 +205,15 @@ function _M.finishQuestRpc(agent, data) | ||
| 132 | -- check finish time | 205 | -- check finish time |
| 133 | local radioTask = role:getProperty("radioTask") | 206 | local radioTask = role:getProperty("radioTask") |
| 134 | local task = radioTask[id] | 207 | local task = radioTask[id] |
| 135 | - if not task then return 1 end | ||
| 136 | - if skynet.timex() < task.time then return 2 end | ||
| 137 | - -- check id | ||
| 138 | - local config = csvdb["crusadeCsv"][id] | ||
| 139 | - if not config then return 3 end | ||
| 140 | - local carbonData = csvdb["idle_battleCsv"][config.unlock] | ||
| 141 | - if not carbonData then return 4 end | ||
| 142 | - -- get heros | ||
| 143 | - local totalCoef = 0 | ||
| 144 | - local exp = config.time / 60 | ||
| 145 | - local heroFaithMap = {} | ||
| 146 | - for _, heroId in ipairs(task.heros) do | ||
| 147 | - local hero = role.heros[heroId] | ||
| 148 | - if hero then | ||
| 149 | - totalCoef = totalCoef + getHeroCoef(hero, config.success) | ||
| 150 | - -- 增加英雄信赖 | ||
| 151 | - hero:addHeroFaith(exp) | ||
| 152 | - heroFaithMap[heroId] = hero:getProperty("faith") | ||
| 153 | - end | ||
| 154 | - end | ||
| 155 | - -- send award | ||
| 156 | - local bigSuccess = false | ||
| 157 | - local result = math.randomInt(0, 100) | ||
| 158 | - if result < totalCoef then | ||
| 159 | - bigSuccess = true | ||
| 160 | - end | ||
| 161 | - local money = math.ceil(carbonData.money / 5) * config.time * config.money_clear | ||
| 162 | - local exp = math.ceil(carbonData.exp / 5) * config.time * config.exp_clear | ||
| 163 | - local itemReward = config.item_clear_special:toNumMap() | ||
| 164 | - itemReward[ItemId.Gold] = (itemReward[ItemId.Gold] or 0) + money | ||
| 165 | - itemReward[ItemId.Exp] = (itemReward[ItemId.Exp] or 0) + exp | ||
| 166 | - if bigSuccess then | ||
| 167 | - for key, value in pairs(itemReward) do | ||
| 168 | - itemReward[key] = math.ceil(1.5 * value) | ||
| 169 | - end | ||
| 170 | - end | ||
| 171 | - | ||
| 172 | - local r, change = role:award(itemReward, {log = {desc = "radioQuest", int1 = id}}) | ||
| 173 | - | ||
| 174 | - radioTask[id] = nil | ||
| 175 | - role:updateProperty({field="radioTask", value=radioTask, notNotify = true}) | ||
| 176 | - | ||
| 177 | - local msg = role:packReward(r, change) | ||
| 178 | - msg["big"] = bigSuccess | ||
| 179 | - msg["id"] = id | ||
| 180 | - msg["heroFaith"] = heroFaithMap | ||
| 181 | - SendPacket(actionCodes.Radio_finishQuestRpc, MsgPack.pack(msg)) | ||
| 182 | - | ||
| 183 | - role:checkTaskEnter("RadioTaskStart", {heroCnt = #task.heros}) | ||
| 184 | - | ||
| 185 | - local herolist = {} | ||
| 186 | - for _, heroId in ipairs(task.heros) do | ||
| 187 | - local hero = role.heros[heroId] | ||
| 188 | - if hero then | ||
| 189 | - table.insert(herolist, hero:getProperty("type")) | ||
| 190 | - end | 208 | + if not task then return 4 end |
| 209 | + if skynet.timex() < task.time then return 5 end | ||
| 210 | + | ||
| 211 | + local reward = getCrusadeReward(role, id) | ||
| 212 | + if type(reward) == "number" then | ||
| 213 | + return reward | ||
| 214 | + else | ||
| 215 | + SendPacket(actionCodes.Radio_finishQuestRpc, MsgPack.pack(reward)) | ||
| 191 | end | 216 | end |
| 192 | - | ||
| 193 | - -- 讨伐行动 | ||
| 194 | - role:log("punitive_action", { | ||
| 195 | - mission_id = id, --关卡ID | ||
| 196 | - mission_herolist = herolist, -- 英雄ID,排序以玩家出战设置为准,示例:[111, 222, 333, 444, 555] | ||
| 197 | - mission_success_rate = totalCoef, -- 大成功几率 | ||
| 198 | - mission_reward = r, -- 获得奖励,建议使用json格式记录。示例:{ itemid1: 1, itemid2: 3, itemid3: 5} | ||
| 199 | - mission_result = 1, -- 战斗结果(0-无效,1-胜利,2-失败) | ||
| 200 | - mission_roundtime = config.time, -- 完成耗时(秒) | ||
| 201 | - mission_cleartype = 2, -- 1-开始; 2-完成(领取奖励时) | ||
| 202 | - }) | ||
| 203 | - role:mylog("role_action", {desc = "radioTask", int1 = id, short1 = bigSuccess and 1 or 0}) | ||
| 204 | - | ||
| 205 | return true | 217 | return true |
| 206 | end | 218 | end |
| 207 | 219 | ||
| @@ -212,12 +224,23 @@ function _M.cancelQuestRpc(agent, data) | @@ -212,12 +224,23 @@ function _M.cancelQuestRpc(agent, data) | ||
| 212 | -- check finish time | 224 | -- check finish time |
| 213 | local radioTask = role:getProperty("radioTask") | 225 | local radioTask = role:getProperty("radioTask") |
| 214 | local task = radioTask[id] | 226 | local task = radioTask[id] |
| 215 | - if not task then return 1 end | ||
| 216 | - if skynet.timex() > task.time then return 2 end | ||
| 217 | - radioTask[id] = nil | ||
| 218 | - role:updateProperty({field="radioTask", value=radioTask, notNotify = true}) | ||
| 219 | - | ||
| 220 | - SendPacket(actionCodes.Radio_cancelQuestRpc, MsgPack.pack({id = id})) | 227 | + if not task then return 4 end |
| 228 | + if skynet.timex() > task.time then return 5 end | ||
| 229 | + | ||
| 230 | + local remainT = task.time - skynet.timex() | ||
| 231 | + if remainT > 0 then | ||
| 232 | + local cost = math.ceil(remainT / 3600) * globalCsv.crusade_quicken | ||
| 233 | + if not role:checkItemEnough({[ItemId.Jade] = cost}) then return 6 end | ||
| 234 | + role:costItems({[ItemId.Jade] = cost}, {log = {desc = "radioQuest", int1 = id}}) | ||
| 235 | + local reward = getCrusadeReward(role, id) | ||
| 236 | + if type(reward) == "number" then | ||
| 237 | + return reward | ||
| 238 | + else | ||
| 239 | + SendPacket(actionCodes.Radio_cancelQuestRpc, MsgPack.pack(reward)) | ||
| 240 | + end | ||
| 241 | + else | ||
| 242 | + SendPacket(actionCodes.Radio_cancelQuestRpc, MsgPack.pack({id = id})) | ||
| 243 | + end | ||
| 221 | return true | 244 | return true |
| 222 | end | 245 | end |
| 223 | 246 |