diff --git a/src/GlobalVar.lua b/src/GlobalVar.lua index 380514d..abb5de6 100644 --- a/src/GlobalVar.lua +++ b/src/GlobalVar.lua @@ -375,6 +375,7 @@ MailId = { RechargeBack = 3001, DrawCode = 3002, + ActRadoTaskReward = 3003, } TriggerEventType = { diff --git a/src/models/Activity.lua b/src/models/Activity.lua index e545f25..19c9caa 100644 --- a/src/models/Activity.lua +++ b/src/models/Activity.lua @@ -40,6 +40,7 @@ Activity.ActivityType = { BattleCommandTask = 38, -- 战令任务活动 NewUserTask = 41, -- 新用户任务 + RadioTask = 43, -- 活动电台任务 } local function checkActivityType(activityType) @@ -1353,4 +1354,95 @@ activityFunc[Activity.ActivityType.AdvLevel] = { end, } +-- 获取英雄大成功率 +local function getHeroCoef(hero, condition) + -- 基础概率 + local rareMap = {[HeroQuality.N] = 10, [HeroQuality.R] = 10, [HeroQuality.SR] = 15, [HeroQuality.SSR] = 20} + local rare = hero:getRare() + local result = 0 + for _, it in ipairs(condition:toTableArray(true)) do + local type = it[1] + local value = it[2] + local add = it[3] + if type == 1 then -- 种族加成 + if hero:getCamp() == value then + result = result + add + end + elseif type == 2 then -- 定位加成 + if hero:getPosition() == value then + result = result + add + end + end + end + + return result + (rareMap[rare] or 0) +end + +local function getActRadioTaskReward(role, id, task) + local config = csvdb["crusadeCsv"][id] + if not config then return 2 end + local carbonData = csvdb["idle_battleCsv"][config.unlock] + if not carbonData then return 3 end + -- get heros + local totalCoef = 0 + local exp = config.time / 60 + for _, heroId in ipairs(task.heros) do + local hero = role.heros[heroId] + if hero then + totalCoef = totalCoef + getHeroCoef(hero, config.success) + -- 增加英雄信赖 + hero:addHeroFaith(exp) + end + end + -- send award + local bigSuccess = false + local result = math.randomInt(0, 100) + if result < totalCoef then + bigSuccess = true + end + local money = math.ceil(carbonData.money / 5) * config.time * config.money_clear + local exp = math.ceil(carbonData.exp / 5) * config.time * config.exp_clear + local itemReward = config.item_clear_special:toNumMap() + itemReward[ItemId.Gold] = (itemReward[ItemId.Gold] or 0) + money + itemReward[ItemId.Exp] = (itemReward[ItemId.Exp] or 0) + exp + if bigSuccess then + for key, value in pairs(itemReward) do + itemReward[key] = math.ceil(1.5 * value) + end + end + + return itemReward +end + + +activityFunc[Activity.ActivityType.RadioTask] = { + -- ["check"] = function(self, actType, notify) -- 检查 + -- end, + ["init"] = function(self, actType, isCrossDay, notify) + end, + ["close"] = function(self, actType, notify, actid) + local radioTask = self.owner:getProperty("radioTask") + local result = {} + for id, task in pairs(radioTask) do + -- check id + local config = csvdb["crusadeCsv"][id] + if config then + if config.actid == actid then + radioTask[id] = nil + + if not task then return 4 end + if skynet.timex() < task.time then return 5 end + + local reward = getActRadioTaskReward(self.owner, id, task) + for k, v in pairs(reward) do + result[k] = (result[k] or 0) + v + end + end + end + end + self.owner:sendMail(MailId.ActRadoTaskReward, nil, result, nil) + self.owner:updateProperty({field="radioTask", value=radioTask, notNotify = true}) + end, +} + return Activity -- libgit2 0.21.2