Commit 5fb0ac5f8479836986df73bdd5a79d373c482a5d
1 parent
ac57fc89
海港贸易相关bug修复
Showing
2 changed files
with
20 additions
and
16 deletions
Show diff stats
src/actions/SeaportAction.lua
... | ... | @@ -26,10 +26,10 @@ function _M.donateRpc(agent, data) |
26 | 26 | if itemId == 0 or itemCount == 0 then return 0 end |
27 | 27 | if role:getItemCount(itemId) < itemCount then return 1 end |
28 | 28 | local DonateCsv = csvdb["seaport_purchaseCsv"] |
29 | - if DonateCsv[phase] or not DonateCsv[phase][id] then return 2 end | |
29 | + if not DonateCsv[phase] or not DonateCsv[phase][id] then return 2 end | |
30 | 30 | |
31 | 31 | local data = DonateCsv[phase][id] |
32 | - local needs = data.need_item:toArray("=",true) | |
32 | + local needs = data.need_item:toArray(true,"=") | |
33 | 33 | if itemId ~= needs[1] then return 3 end |
34 | 34 | if itemCount % needs[2] ~= 0 then return 4 end |
35 | 35 | |
... | ... | @@ -230,27 +230,31 @@ function _M.shopRpc(agent, data) |
230 | 230 | local id = msg.id or 0 |
231 | 231 | local count = msg.count or 1 |
232 | 232 | |
233 | - local seaport = role:getProperty{"seaport"} | |
234 | - local shop = seaport.shop or {} | |
235 | - | |
236 | - if (shop[id] or 0) >= data.limit then return 1 end | |
237 | - | |
238 | 233 | local shopCsv = {} |
239 | 234 | local dataSet = csvdb["shop_normalCsv"] |
240 | - for _, data in pairs(dataSet) do | |
241 | - if data.shop == 5 then | |
242 | - shopCsv[data.id] = data | |
235 | + for _, datat in pairs(dataSet) do | |
236 | + if datat.shop == 5 then | |
237 | + shopCsv[datat.id] = datat | |
243 | 238 | end |
244 | 239 | end |
240 | + local sdata = shopCsv[id] | |
241 | + | |
242 | + if not sdata then return 2 end | |
245 | 243 | |
246 | - local data = shopCsv[id] | |
247 | - if not data then return 2 end | |
244 | + local seaport = role:getProperty("seaport") | |
245 | + local shop = seaport.shop or {} | |
246 | + | |
247 | + if (shop[id] or 0) >= sdata.limit then return 1 end | |
248 | + | |
249 | + | |
250 | + | |
251 | + | |
248 | 252 | |
249 | - if role:getItemCount(data.icon) < data.cost * count then return 3 end | |
253 | + if role:getItemCount(sdata.icon) < sdata.cost * count then return 3 end | |
250 | 254 | |
251 | - role:costItems({[data.icon] = data.cost * count}, {log = {desc = "seaportShop", int1 = id, int2 = count}}) | |
255 | + role:costItems({[sdata.icon] = sdata.cost * count}, {log = {desc = "seaportShop", int1 = id, int2 = count}}) | |
252 | 256 | |
253 | - local itemReward = data.gift:toNumMap() | |
257 | + local itemReward = sdata.gift:toNumMap() | |
254 | 258 | for itemId, value in pairs(itemReward) do |
255 | 259 | itemReward[itemId] = value * count |
256 | 260 | end | ... | ... |
src/models/RolePlugin.lua