Commit 3b410558960ddfad32aadd3fe5d689e119ff16d6

Authored by zhangqijia
2 parents e7ba6e04 46c63bba

Merge branch 'cn/develop' of 120.26.43.151:wasteland/server into cn/develop

Showing 2 changed files with 93 additions and 1 deletions   Show diff stats
src/GlobalVar.lua
... ... @@ -375,6 +375,7 @@ MailId = {
375 375  
376 376 RechargeBack = 3001,
377 377 DrawCode = 3002,
  378 + ActRadoTaskReward = 3003,
378 379 }
379 380  
380 381 TriggerEventType = {
... ...
src/models/Activity.lua
... ... @@ -40,8 +40,8 @@ Activity.ActivityType = {
40 40  
41 41 BattleCommandTask = 38, -- 战令任务活动
42 42 NewUserTask = 41, -- 新用户任务
43   -
44 43 RegularWorldBoos = 42, -- 常规世界boos
  44 + RadioTask = 43, -- 活动电台任务
45 45 }
46 46  
47 47 local function checkActivityType(activityType)
... ... @@ -1411,4 +1411,95 @@ activityFunc[Activity.ActivityType.AdvLevel] = {
1411 1411 end,
1412 1412 }
1413 1413  
  1414 +-- 获取英雄大成功率
  1415 +local function getHeroCoef(hero, condition)
  1416 + -- 基础概率
  1417 + local rareMap = {[HeroQuality.N] = 10, [HeroQuality.R] = 10, [HeroQuality.SR] = 15, [HeroQuality.SSR] = 20}
  1418 + local rare = hero:getRare()
  1419 + local result = 0
  1420 + for _, it in ipairs(condition:toTableArray(true)) do
  1421 + local type = it[1]
  1422 + local value = it[2]
  1423 + local add = it[3]
  1424 + if type == 1 then -- 种族加成
  1425 + if hero:getCamp() == value then
  1426 + result = result + add
  1427 + end
  1428 + elseif type == 2 then -- 定位加成
  1429 + if hero:getPosition() == value then
  1430 + result = result + add
  1431 + end
  1432 + end
  1433 + end
  1434 +
  1435 + return result + (rareMap[rare] or 0)
  1436 +end
  1437 +
  1438 +local function getActRadioTaskReward(role, id, task)
  1439 + local config = csvdb["crusadeCsv"][id]
  1440 + if not config then return 2 end
  1441 + local carbonData = csvdb["idle_battleCsv"][config.unlock]
  1442 + if not carbonData then return 3 end
  1443 + -- get heros
  1444 + local totalCoef = 0
  1445 + local exp = config.time / 60
  1446 + for _, heroId in ipairs(task.heros) do
  1447 + local hero = role.heros[heroId]
  1448 + if hero then
  1449 + totalCoef = totalCoef + getHeroCoef(hero, config.success)
  1450 + -- 增加英雄信赖
  1451 + hero:addHeroFaith(exp)
  1452 + end
  1453 + end
  1454 + -- send award
  1455 + local bigSuccess = false
  1456 + local result = math.randomInt(0, 100)
  1457 + if result < totalCoef then
  1458 + bigSuccess = true
  1459 + end
  1460 + local money = math.ceil(carbonData.money / 5) * config.time * config.money_clear
  1461 + local exp = math.ceil(carbonData.exp / 5) * config.time * config.exp_clear
  1462 + local itemReward = config.item_clear_special:toNumMap()
  1463 + itemReward[ItemId.Gold] = (itemReward[ItemId.Gold] or 0) + money
  1464 + itemReward[ItemId.Exp] = (itemReward[ItemId.Exp] or 0) + exp
  1465 + if bigSuccess then
  1466 + for key, value in pairs(itemReward) do
  1467 + itemReward[key] = math.ceil(1.5 * value)
  1468 + end
  1469 + end
  1470 +
  1471 + return itemReward
  1472 +end
  1473 +
  1474 +
  1475 +activityFunc[Activity.ActivityType.RadioTask] = {
  1476 + -- ["check"] = function(self, actType, notify) -- 检查
  1477 + -- end,
  1478 + ["init"] = function(self, actType, isCrossDay, notify)
  1479 + end,
  1480 + ["close"] = function(self, actType, notify, actid)
  1481 + local radioTask = self.owner:getProperty("radioTask")
  1482 + local result = {}
  1483 + for id, task in pairs(radioTask) do
  1484 + -- check id
  1485 + local config = csvdb["crusadeCsv"][id]
  1486 + if config then
  1487 + if config.actid == actid then
  1488 + radioTask[id] = nil
  1489 +
  1490 + if not task then return 4 end
  1491 + if skynet.timex() < task.time then return 5 end
  1492 +
  1493 + local reward = getActRadioTaskReward(self.owner, id, task)
  1494 + for k, v in pairs(reward) do
  1495 + result[k] = (result[k] or 0) + v
  1496 + end
  1497 + end
  1498 + end
  1499 + end
  1500 + self.owner:sendMail(MailId.ActRadoTaskReward, nil, result, nil)
  1501 + self.owner:updateProperty({field="radioTask", value=radioTask, notNotify = true})
  1502 + end,
  1503 +}
  1504 +
1414 1505 return Activity
... ...