Commit 1663460594b058c17c9d4eda37410cd03be7e579
1 parent
96d591f7
多队挂机,天赋道具合成
Showing
7 changed files
with
157 additions
and
18 deletions
Show diff stats
src/ProtocolCode.lua
... | ... | @@ -99,6 +99,7 @@ actionCodes = { |
99 | 99 | Hero_unlockPoolRpc = 222, |
100 | 100 | Hero_changeCrown = 223, |
101 | 101 | Hero_drawHeroExtraRewardNtf = 224, |
102 | + Hero_itemComposeRpc = 225, | |
102 | 103 | |
103 | 104 | Hang_startRpc = 251, |
104 | 105 | Hang_checkRpc = 252, |
... | ... | @@ -217,9 +218,8 @@ actionCodes = { |
217 | 218 | Activity_actCalendaTaskRpc = 655, |
218 | 219 | Activity_actPaySignRpc = 656, |
219 | 220 | |
220 | - Radio_listRpc = 700, -- 获取电台讨伐任务列表 | |
221 | - Radio_startQuestRpc = 701, | |
222 | - Radio_finishQuestRpc = 702, | |
221 | + Radio_startQuestRpc = 700, | |
222 | + Radio_finishQuestRpc = 701, | |
223 | 223 | } |
224 | 224 | |
225 | 225 | rpcResponseBegin = 10000 | ... | ... |
src/actions/HeroAction.lua
... | ... | @@ -1038,4 +1038,23 @@ function _M.changeCrown(agent, data) |
1038 | 1038 | return true |
1039 | 1039 | end |
1040 | 1040 | |
1041 | +function _M.itemComposeRpc(agent, data) | |
1042 | + local role = agent.role | |
1043 | + local msg = MsgPack.unpack(data) | |
1044 | + | |
1045 | + local itemId = msg.id | |
1046 | + local count = msg.count | |
1047 | + if not csvdb["itemCsv"][itemId] then return 1 end | |
1048 | + local config = csvdb["item_processCsv"][itemId] | |
1049 | + if not config then return 2 end | |
1050 | + | |
1051 | + local cost = config.cost:toNumMap() | |
1052 | + if not role:checkItemEnough(cost) then return 2 end | |
1053 | + role:costItems(cost, {log = {desc = "itemCompose", int1 = itemId, int2 = count}}) | |
1054 | + role:award({[itemId] = count}, {log = {desc = "itemCompose"}}) | |
1055 | + | |
1056 | + SendPacket(actionCodes.Hero_itemComposeRpc, "") | |
1057 | + return true | |
1058 | +end | |
1059 | + | |
1041 | 1060 | return _M | ... | ... |
src/actions/RadioAction.lua
1 | 1 | local _M = {} |
2 | 2 | |
3 | -function _M.listRpc(agent, data) | |
4 | - local role = agent.role | |
5 | - local roleId = role:getProperty("id") | |
6 | - local now = skynet.timex() | |
7 | - local result = {} | |
8 | - | |
3 | +-- 获取英雄大成功率 | |
4 | +local function getHeroCoef(hero, condition) | |
5 | + -- 基础概率 | |
6 | + local rareMap = {[HeroQuality.N] = 10, [HeroQuality.R] = 10, [HeroQuality.SR] = 15, [HeroQuality.SSR] = 20} | |
7 | + local rare = hero:getRare() | |
8 | + local result = 0 | |
9 | + for _, it in ipairs(condition:toTableArray(true)) do | |
10 | + local type = it[1] | |
11 | + local value = it[2] | |
12 | + local add = it[3] | |
13 | + if type == 1 then -- 种族加成 | |
14 | + if hero:getCamp() == value then | |
15 | + result = result + add | |
16 | + end | |
17 | + elseif type == 2 then -- 定位加成 | |
18 | + if hero:getPosition() == value then | |
19 | + result = result + add | |
20 | + end | |
21 | + end | |
22 | + end | |
9 | 23 | |
10 | - SendPacket(actionCodes.Email_listRpc, MsgPack.pack({list = result})) | |
11 | - return true | |
24 | + return result + (rareMap[rare] or 0) | |
12 | 25 | end |
13 | 26 | |
14 | --- 获取英雄大成功率 | |
15 | -local function getHeroCoef() | |
16 | - return 0 | |
27 | +local function getQuestMax(role) | |
28 | + local count = 0 | |
29 | + for _, carbonId in ipairs(globalCsv.crusade_team_unlock or {}) do | |
30 | + if role:checkHangPass(carbonId) then | |
31 | + count = count + 1 | |
32 | + end | |
33 | + end | |
34 | + | |
35 | + return count + (globalCsv.cursade_team_count_initial or 0) | |
17 | 36 | end |
18 | 37 | |
19 | 38 | function _M.startQuestRpc(agent, data) |
... | ... | @@ -22,11 +41,67 @@ function _M.startQuestRpc(agent, data) |
22 | 41 | local id = msg.id |
23 | 42 | local heros = msg.heros |
24 | 43 | local result = {} |
44 | + local radioTask = role:getProperty("radioTask") | |
45 | + if table.numbers(radioTask) >= getQuestMax(role) then | |
46 | + return 1 | |
47 | + end | |
25 | 48 | -- check id |
49 | + local config = csvdb["crusadeCsv"][id] | |
50 | + if not config then return 2 end | |
51 | + if not role:checkHangPass(config.unlock) then return 3 end | |
52 | + if radioTask[id] then return 4 end | |
26 | 53 | -- check hero |
54 | + --1=指定等级=人数 | |
55 | + --2=指定稀有度=人数 | |
56 | + --3=人数 | |
57 | + local needHeroCnt = 0 | |
58 | + local lvlMap = {} | |
59 | + local rareMap = {} | |
60 | + for _, it in ipairs(config.condition:toTableArray(true)) do | |
61 | + local type = it[1] | |
62 | + if type == 1 then | |
63 | + lvlMap[1] = it[2] | |
64 | + lvlMap[2] = it[3] | |
65 | + elseif type == 2 then | |
66 | + rareMap[1] = it[2] | |
67 | + rareMap[2] = it[3] | |
68 | + elseif type == 3 then | |
69 | + needHeroCnt = it[2] | |
70 | + end | |
71 | + end | |
72 | + for _, heroId in ipairs(heros) do | |
73 | + local hero = role.heros[heroId] | |
74 | + if hero then | |
75 | + needHeroCnt = needHeroCnt - 1 | |
76 | + if next(lvlMap) then | |
77 | + if hero:getProperty("level") >= lvlMap[1] then | |
78 | + lvlMap[2] = lvlMap[2] - 1 | |
79 | + if lvlMap[2] <= 0 then | |
80 | + lvlMap = {} | |
81 | + end | |
82 | + end | |
83 | + end | |
84 | + if next(rareMap) then | |
85 | + if hero:getRare() >= rareMap[1] then | |
86 | + rareMap[2] = rareMap[2] - 1 | |
87 | + end | |
88 | + if rareMap[2] <= 0 then | |
89 | + rareMap = {} | |
90 | + end | |
91 | + end | |
92 | + end | |
93 | + end | |
94 | + if needHeroCnt > 0 or next(rareMap) or next(lvlMap) then | |
95 | + return 5 | |
96 | + end | |
27 | 97 | -- start quest, set finish time |
98 | + local taskData = {} | |
99 | + taskData["time"] = skynet.timex() + config.time | |
100 | + taskData["heros"] = heros | |
101 | + radioTask[id] = taskData | |
102 | + role:updateProperty({field="radioTask", value=radioTask, notNotify=true}) | |
28 | 103 | |
29 | - SendPacket(actionCodes.Email_listRpc, MsgPack.pack({list = result})) | |
104 | + SendPacket(actionCodes.Radio_startQuestRpc, MsgPack.pack({id=id, task=taskData})) | |
30 | 105 | return true |
31 | 106 | end |
32 | 107 | |
... | ... | @@ -34,13 +109,50 @@ function _M.finishQuestRpc(agent, data) |
34 | 109 | local role = agent.role |
35 | 110 | local msg = MsgPack.unpack(data) |
36 | 111 | local id = msg.id |
37 | - local result = {} | |
38 | 112 | -- check finish time |
113 | + local radioTask = role:getProperty("radioTask") | |
114 | + local task = radioTask[id] | |
115 | + if not task then return 1 end | |
116 | + if skynet.timex() < task.time then return 2 end | |
39 | 117 | -- check id |
118 | + local config = csvdb["crusadeCsv"][id] | |
119 | + if not config then return 3 end | |
120 | + local carbonData = csvdb["idle_battleCsv"][config.unlock] | |
121 | + if not carbonData then return 4 end | |
40 | 122 | -- get heros |
123 | + local totalCoef = 0 | |
124 | + for _, heroId in ipairs(task.heros) do | |
125 | + local hero = role.heros[heroId] | |
126 | + if hero then | |
127 | + totalCoef = totalCoef + getHeroCoef(hero, config.success) | |
128 | + end | |
129 | + end | |
41 | 130 | -- send award |
131 | + local bigSuccess = false | |
132 | + local result = math.randomInt(0, 100) | |
133 | + if result < totalCoef then | |
134 | + bigSuccess = true | |
135 | + end | |
136 | + local money = math.ceil(carbonData.money / 5) * config.time * config.money_clear | |
137 | + local exp = math.ceil(carbonData.exp / 5) * config.time * config.exp_clear | |
138 | + local itemReward = config.item_clear_special:toNumMap() | |
139 | + itemReward[ItemId.Gold] = (itemReward[ItemId.Gold] or 0) + money | |
140 | + itemReward[ItemId.Exp] = (itemReward[ItemId.Exp] or 0) + exp | |
141 | + if bigSuccess then | |
142 | + for key, value in pairs(itemReward) do | |
143 | + itemReward[key] = math.ceil(1.5 * value) | |
144 | + end | |
145 | + end | |
146 | + | |
147 | + local r, change = role:award(itemReward, {log = {desc = "radioQuest", int1 = id}}) | |
148 | + | |
149 | + radioTask[id] = nil | |
150 | + role:updateProperty({field="radioTask", value=radioTask, notNotify = true}) | |
42 | 151 | |
43 | - SendPacket(actionCodes.Email_listRpc, MsgPack.pack({list = result})) | |
152 | + local msg = role:packReward(r, change) | |
153 | + msg["big"] = bigSuccess | |
154 | + msg["id"] = id | |
155 | + SendPacket(actionCodes.Radio_finishQuestRpc, MsgPack.pack(msg)) | |
44 | 156 | return true |
45 | 157 | end |
46 | 158 | ... | ... |
src/models/Hero.lua
... | ... | @@ -115,4 +115,8 @@ function Hero:getRare() |
115 | 115 | return csvdb["unitCsv"][self:getProperty("type")].rare |
116 | 116 | end |
117 | 117 | |
118 | +function Hero:getPosition() | |
119 | + return csvdb["unitCsv"][self:getProperty("type")].position | |
120 | +end | |
121 | + | |
118 | 122 | return Hero |
119 | 123 | \ No newline at end of file | ... | ... |
src/models/Role.lua
... | ... | @@ -181,6 +181,7 @@ Role.schema = { |
181 | 181 | feedback = {"table", {}}, -- 反馈相关信息 {flag = false, count = 0} flag是否评论过,count 提示次数 |
182 | 182 | |
183 | 183 | calTask = {"table", {}}, -- 英雄令活动 日历任务活动 |
184 | + radioTask = {"table", {}}, -- 电台任务 {id = {time=end_ts,heros=heros}} 表crusadeCsv | |
184 | 185 | } |
185 | 186 | |
186 | 187 | |
... | ... | @@ -406,6 +407,7 @@ function Role:data() |
406 | 407 | feedback = self:getProperty("feedback"), |
407 | 408 | ctime = self:getProperty("ctime"), |
408 | 409 | calTask = self:getProperty("calTask"), |
410 | + radioTask = self:getProperty("radioTask"), | |
409 | 411 | } |
410 | 412 | end |
411 | 413 | ... | ... |
src/models/RoleLog.lua