diff --git a/src/actions/SeaportAction.lua b/src/actions/SeaportAction.lua index 6f518f2..ed5c882 100644 --- a/src/actions/SeaportAction.lua +++ b/src/actions/SeaportAction.lua @@ -26,10 +26,10 @@ function _M.donateRpc(agent, data) if itemId == 0 or itemCount == 0 then return 0 end if role:getItemCount(itemId) < itemCount then return 1 end local DonateCsv = csvdb["seaport_purchaseCsv"] - if DonateCsv[phase] or not DonateCsv[phase][id] then return 2 end + if not DonateCsv[phase] or not DonateCsv[phase][id] then return 2 end local data = DonateCsv[phase][id] - local needs = data.need_item:toArray("=",true) + local needs = data.need_item:toArray(true,"=") if itemId ~= needs[1] then return 3 end if itemCount % needs[2] ~= 0 then return 4 end @@ -230,27 +230,31 @@ function _M.shopRpc(agent, data) local id = msg.id or 0 local count = msg.count or 1 - local seaport = role:getProperty{"seaport"} - local shop = seaport.shop or {} - - if (shop[id] or 0) >= data.limit then return 1 end - local shopCsv = {} local dataSet = csvdb["shop_normalCsv"] - for _, data in pairs(dataSet) do - if data.shop == 5 then - shopCsv[data.id] = data + for _, datat in pairs(dataSet) do + if datat.shop == 5 then + shopCsv[datat.id] = datat end end + local sdata = shopCsv[id] + + if not sdata then return 2 end - local data = shopCsv[id] - if not data then return 2 end + local seaport = role:getProperty("seaport") + local shop = seaport.shop or {} + + if (shop[id] or 0) >= sdata.limit then return 1 end + + + + - if role:getItemCount(data.icon) < data.cost * count then return 3 end + if role:getItemCount(sdata.icon) < sdata.cost * count then return 3 end - role:costItems({[data.icon] = data.cost * count}, {log = {desc = "seaportShop", int1 = id, int2 = count}}) + role:costItems({[sdata.icon] = sdata.cost * count}, {log = {desc = "seaportShop", int1 = id, int2 = count}}) - local itemReward = data.gift:toNumMap() + local itemReward = sdata.gift:toNumMap() for itemId, value in pairs(itemReward) do itemReward[itemId] = value * count end diff --git a/src/models/RolePlugin.lua b/src/models/RolePlugin.lua index 094699f..e22528b 100644 --- a/src/models/RolePlugin.lua +++ b/src/models/RolePlugin.lua @@ -1352,7 +1352,7 @@ function RolePlugin.bind(Role) result[idx] = {} for i,v in ipairs(temp) do if v then - result[idx][i] = v + result[idx][i] = tonumber(v) end end end -- libgit2 0.21.2