782ee57d
 
  测试
 
多编队功能
 | 
1
2 
 | 
  local _M = {}
  
 
 | 
16634605
 
  测试
 
多队挂机,天赋道具合成
 | 
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 
 | 
  -- 获取英雄大成功率
  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
 
 | 
782ee57d
 
  测试
 
多编队功能
 | 
23 
 | 
  
 
 | 
16634605
 
  测试
 
多队挂机,天赋道具合成
 | 
24 
 | 
      return result + (rareMap[rare] or 0)
 
 | 
782ee57d
 
  测试
 
多编队功能
 | 
25
26 
 | 
  end
  
 
 | 
16634605
 
  测试
 
多队挂机,天赋道具合成
 | 
27
28
29
30
31
32
33
34
35 
 | 
  local function getQuestMax(role)
      local count = 0
      for _, carbonId in ipairs(globalCsv.crusade_team_unlock or {}) do
          if role:checkHangPass(carbonId) then
              count = count + 1
          end
      end
  
      return count + (globalCsv.cursade_team_count_initial or 0)
 
 | 
782ee57d
 
  测试
 
多编队功能
 | 
36
37
38
39
40
41
42
43 
 | 
  end
  
  function _M.startQuestRpc(agent, data)
  	local role = agent.role
  	local msg = MsgPack.unpack(data)
  	local id = msg.id
  	local heros = msg.heros
      local result = {}
 
 | 
16634605
 
  测试
 
多队挂机,天赋道具合成
 | 
44
45
46
47 
 | 
      local radioTask = role:getProperty("radioTask")
      if table.numbers(radioTask) >= getQuestMax(role) then
          return 1
      end
 
 | 
782ee57d
 
  测试
 
多编队功能
 | 
48 
 | 
      --  check id
 
 | 
16634605
 
  测试
 
多队挂机,天赋道具合成
 | 
49
50
51
52 
 | 
      local config = csvdb["crusadeCsv"][id]
      if not config then return 2 end
      if not role:checkHangPass(config.unlock) then return 3 end
      if radioTask[id] then return 4 end
 
 | 
782ee57d
 
  测试
 
多编队功能
 | 
53 
 | 
      --  check hero
 
 | 
16634605
 
  测试
 
多队挂机,天赋道具合成
 | 
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96 
 | 
      --1=指定等级=人数
      --2=指定稀有度=人数 
      --3=人数
      local needHeroCnt = 0
      local lvlMap = {}
      local rareMap = {}
      for _, it in ipairs(config.condition:toTableArray(true)) do
          local type = it[1]
          if type == 1 then
              lvlMap[1] = it[2]
              lvlMap[2] = it[3]
          elseif type == 2 then
              rareMap[1] = it[2]
              rareMap[2] = it[3]
          elseif type == 3 then
              needHeroCnt = it[2]
          end
      end
      for _, heroId in ipairs(heros) do
          local hero = role.heros[heroId]
          if hero then
              needHeroCnt = needHeroCnt - 1
              if next(lvlMap) then
                  if hero:getProperty("level") >= lvlMap[1] then
                      lvlMap[2] = lvlMap[2] - 1
                      if lvlMap[2] <= 0 then
                          lvlMap = {}
                      end
                  end
              end
              if next(rareMap) then
                  if hero:getRare() >= rareMap[1] then
                      rareMap[2] = rareMap[2] - 1
                  end
                      if rareMap[2] <= 0 then
                          rareMap = {}
                      end
              end
          end
      end
      if needHeroCnt > 0 or next(rareMap) or next(lvlMap) then
          return 5
      end
 
 | 
782ee57d
 
  测试
 
多编队功能
 | 
97 
 | 
      -- start quest, set finish time
 
 | 
16634605
 
  测试
 
多队挂机,天赋道具合成
 | 
98
99
100
101
102 
 | 
      local taskData = {}
      taskData["time"] = skynet.timex() + config.time
      taskData["heros"] = heros
      radioTask[id] = taskData
      role:updateProperty({field="radioTask", value=radioTask, notNotify=true})
 
 | 
782ee57d
 
  测试
 
多编队功能
 | 
103 
 | 
  
 
 | 
16634605
 
  测试
 
多队挂机,天赋道具合成
 | 
104 
 | 
  	SendPacket(actionCodes.Radio_startQuestRpc, MsgPack.pack({id=id, task=taskData}))
 
 | 
782ee57d
 
  测试
 
多编队功能
 | 
105
106
107
108
109
110
111 
 | 
  	return true
  end
  
  function _M.finishQuestRpc(agent, data)
  	local role = agent.role
  	local msg = MsgPack.unpack(data)
  	local id = msg.id
 
 | 
782ee57d
 
  测试
 
多编队功能
 | 
112 
 | 
      -- check finish time
 
 | 
16634605
 
  测试
 
多队挂机,天赋道具合成
 | 
113
114
115
116 
 | 
      local radioTask = role:getProperty("radioTask")
      local task = radioTask[id]
      if not task then return 1 end
      if skynet.timex() < task.time then return 2 end
 
 | 
782ee57d
 
  测试
 
多编队功能
 | 
117 
 | 
      --  check id
 
 | 
16634605
 
  测试
 
多队挂机,天赋道具合成
 | 
118
119
120
121 
 | 
      local config = csvdb["crusadeCsv"][id]
      if not config then return 3 end
      local carbonData = csvdb["idle_battleCsv"][config.unlock]
      if not carbonData then return 4 end
 
 | 
782ee57d
 
  测试
 
多编队功能
 | 
122 
 | 
      --  get heros
 
 | 
16634605
 
  测试
 
多队挂机,天赋道具合成
 | 
123 
 | 
      local totalCoef = 0
 
 | 
8efb24c9
 
  测试
 
天赋系统属性加成改为百分比
 | 
124 
 | 
      local exp = config.time / 60
 
 | 
4f7cffe5
 
  测试
 
多队挂机任务取消功能,累充奖励
 | 
125 
 | 
      local heroFaithMap = {}
 
 | 
16634605
 
  测试
 
多队挂机,天赋道具合成
 | 
126
127
128
129 
 | 
      for _, heroId in ipairs(task.heros) do
          local hero = role.heros[heroId]
          if hero then
              totalCoef = totalCoef + getHeroCoef(hero, config.success)
 
 | 
8efb24c9
 
  测试
 
天赋系统属性加成改为百分比
 | 
130
131
132 
 | 
              -- 增加英雄信赖
              hero:addHeroFaith(exp)
              heroFaithMap[heroId] = hero:getProperty("faith")
 
 | 
16634605
 
  测试
 
多队挂机,天赋道具合成
 | 
133
134 
 | 
          end
      end
 
 | 
782ee57d
 
  测试
 
多编队功能
 | 
135 
 | 
      -- send award
 
 | 
16634605
 
  测试
 
多队挂机,天赋道具合成
 | 
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155 
 | 
      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
  
      local r, change = role:award(itemReward, {log = {desc = "radioQuest", int1 = id}})
      
      radioTask[id] = nil
      role:updateProperty({field="radioTask", value=radioTask, notNotify = true})
 
 | 
782ee57d
 
  测试
 
多编队功能
 | 
156 
 | 
  
 
 | 
16634605
 
  测试
 
多队挂机,天赋道具合成
 | 
157
158
159 
 | 
      local msg = role:packReward(r, change)
      msg["big"] = bigSuccess
      msg["id"] = id
 
 | 
8efb24c9
 
  测试
 
天赋系统属性加成改为百分比
 | 
160 
 | 
      msg["heroFaith"] = heroFaithMap
 
 | 
16634605
 
  测试
 
多队挂机,天赋道具合成
 | 
161 
 | 
  	SendPacket(actionCodes.Radio_finishQuestRpc, MsgPack.pack(msg))
 
 | 
782ee57d
 
  测试
 
多编队功能
 | 
162
163
164 
 | 
  	return true
  end
  
 
 | 
4f7cffe5
 
  测试
 
多队挂机任务取消功能,累充奖励
 | 
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180 
 | 
  function _M.cancelQuestRpc(agent, data)
  	local role = agent.role
  	local msg = MsgPack.unpack(data)
  	local id = msg.id
      -- check finish time
      local radioTask = role:getProperty("radioTask")
      local task = radioTask[id]
      if not task then return 1 end
      if skynet.timex() > task.time then return 2 end
      radioTask[id] = nil
      role:updateProperty({field="radioTask", value=radioTask, notNotify = true})
  
      SendPacket(actionCodes.Radio_cancelQuestRpc, MsgPack.pack({id = id}))
      return true
  end
  
 
 | 
782ee57d
 
  测试
 
多编队功能
 | 
181 
 | 
  return _M
 
 |