Commit 21581e1fa1dcf2cf37dca88c975bb0c40ee704e6
1 parent
3f14b267
新增 电台类活动
Showing
2 changed files
with
93 additions
and
0 deletions
Show diff stats
src/GlobalVar.lua
src/models/Activity.lua
@@ -40,6 +40,7 @@ Activity.ActivityType = { | @@ -40,6 +40,7 @@ Activity.ActivityType = { | ||
40 | 40 | ||
41 | BattleCommandTask = 38, -- 战令任务活动 | 41 | BattleCommandTask = 38, -- 战令任务活动 |
42 | NewUserTask = 41, -- 新用户任务 | 42 | NewUserTask = 41, -- 新用户任务 |
43 | + RadioTask = 43, -- 活动电台任务 | ||
43 | } | 44 | } |
44 | 45 | ||
45 | local function checkActivityType(activityType) | 46 | local function checkActivityType(activityType) |
@@ -1353,4 +1354,95 @@ activityFunc[Activity.ActivityType.AdvLevel] = { | @@ -1353,4 +1354,95 @@ activityFunc[Activity.ActivityType.AdvLevel] = { | ||
1353 | end, | 1354 | end, |
1354 | } | 1355 | } |
1355 | 1356 | ||
1357 | +-- 获取英雄大成功率 | ||
1358 | +local function getHeroCoef(hero, condition) | ||
1359 | + -- 基础概率 | ||
1360 | + local rareMap = {[HeroQuality.N] = 10, [HeroQuality.R] = 10, [HeroQuality.SR] = 15, [HeroQuality.SSR] = 20} | ||
1361 | + local rare = hero:getRare() | ||
1362 | + local result = 0 | ||
1363 | + for _, it in ipairs(condition:toTableArray(true)) do | ||
1364 | + local type = it[1] | ||
1365 | + local value = it[2] | ||
1366 | + local add = it[3] | ||
1367 | + if type == 1 then -- 种族加成 | ||
1368 | + if hero:getCamp() == value then | ||
1369 | + result = result + add | ||
1370 | + end | ||
1371 | + elseif type == 2 then -- 定位加成 | ||
1372 | + if hero:getPosition() == value then | ||
1373 | + result = result + add | ||
1374 | + end | ||
1375 | + end | ||
1376 | + end | ||
1377 | + | ||
1378 | + return result + (rareMap[rare] or 0) | ||
1379 | +end | ||
1380 | + | ||
1381 | +local function getActRadioTaskReward(role, id, task) | ||
1382 | + local config = csvdb["crusadeCsv"][id] | ||
1383 | + if not config then return 2 end | ||
1384 | + local carbonData = csvdb["idle_battleCsv"][config.unlock] | ||
1385 | + if not carbonData then return 3 end | ||
1386 | + -- get heros | ||
1387 | + local totalCoef = 0 | ||
1388 | + local exp = config.time / 60 | ||
1389 | + for _, heroId in ipairs(task.heros) do | ||
1390 | + local hero = role.heros[heroId] | ||
1391 | + if hero then | ||
1392 | + totalCoef = totalCoef + getHeroCoef(hero, config.success) | ||
1393 | + -- 增加英雄信赖 | ||
1394 | + hero:addHeroFaith(exp) | ||
1395 | + end | ||
1396 | + end | ||
1397 | + -- send award | ||
1398 | + local bigSuccess = false | ||
1399 | + local result = math.randomInt(0, 100) | ||
1400 | + if result < totalCoef then | ||
1401 | + bigSuccess = true | ||
1402 | + end | ||
1403 | + local money = math.ceil(carbonData.money / 5) * config.time * config.money_clear | ||
1404 | + local exp = math.ceil(carbonData.exp / 5) * config.time * config.exp_clear | ||
1405 | + local itemReward = config.item_clear_special:toNumMap() | ||
1406 | + itemReward[ItemId.Gold] = (itemReward[ItemId.Gold] or 0) + money | ||
1407 | + itemReward[ItemId.Exp] = (itemReward[ItemId.Exp] or 0) + exp | ||
1408 | + if bigSuccess then | ||
1409 | + for key, value in pairs(itemReward) do | ||
1410 | + itemReward[key] = math.ceil(1.5 * value) | ||
1411 | + end | ||
1412 | + end | ||
1413 | + | ||
1414 | + return itemReward | ||
1415 | +end | ||
1416 | + | ||
1417 | + | ||
1418 | +activityFunc[Activity.ActivityType.RadioTask] = { | ||
1419 | + -- ["check"] = function(self, actType, notify) -- 检查 | ||
1420 | + -- end, | ||
1421 | + ["init"] = function(self, actType, isCrossDay, notify) | ||
1422 | + end, | ||
1423 | + ["close"] = function(self, actType, notify, actid) | ||
1424 | + local radioTask = self.owner:getProperty("radioTask") | ||
1425 | + local result = {} | ||
1426 | + for id, task in pairs(radioTask) do | ||
1427 | + -- check id | ||
1428 | + local config = csvdb["crusadeCsv"][id] | ||
1429 | + if config then | ||
1430 | + if config.actid == actid then | ||
1431 | + radioTask[id] = nil | ||
1432 | + | ||
1433 | + if not task then return 4 end | ||
1434 | + if skynet.timex() < task.time then return 5 end | ||
1435 | + | ||
1436 | + local reward = getActRadioTaskReward(self.owner, id, task) | ||
1437 | + for k, v in pairs(reward) do | ||
1438 | + result[k] = (result[k] or 0) + v | ||
1439 | + end | ||
1440 | + end | ||
1441 | + end | ||
1442 | + end | ||
1443 | + self.owner:sendMail(MailId.ActRadoTaskReward, nil, result, nil) | ||
1444 | + self.owner:updateProperty({field="radioTask", value=radioTask, notNotify = true}) | ||
1445 | + end, | ||
1446 | +} | ||
1447 | + | ||
1356 | return Activity | 1448 | return Activity |