1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-02-03 13:12:11 +02:00

207 lines
7.8 KiB
Lua
Raw Normal View History

2021-10-13 09:21:53 +01:00
local Memory = require 'maps.pirates.memory'
2022-03-19 21:20:55 +00:00
-- local Roles = require 'maps.pirates.roles.roles'
2022-03-07 09:50:25 +00:00
local CoreData = require 'maps.pirates.coredata'
2021-10-13 09:21:53 +01:00
local Classes = require 'maps.pirates.roles.classes'
2022-03-19 21:20:55 +00:00
-- local Crew = require 'maps.pirates.crew'
-- local Boats = require 'maps.pirates.structures.boats.boats'
-- local Dock = require 'maps.pirates.surfaces.dock'
2021-10-13 09:21:53 +01:00
local Balance = require 'maps.pirates.balance'
local Common = require 'maps.pirates.common'
local Utils = require 'maps.pirates.utils_local'
local Math = require 'maps.pirates.math'
local Upgrades = require 'maps.pirates.boat_upgrades'
2022-03-19 21:20:55 +00:00
local _inspect = require 'utils.inspect'.inspect
2021-10-13 09:21:53 +01:00
2022-03-19 21:20:55 +00:00
-- local Upgrades = require 'maps.pirates.boat_upgrades'
2021-10-13 09:21:53 +01:00
local Public = {}
2022-02-26 23:33:19 +00:00
2021-10-13 09:21:53 +01:00
Public.market_barters = {
{price = {{'iron-plate', 300}}, offer = {type = 'give-item', item = 'copper-plate', count = 500}},
{price = {{'copper-plate', 300}}, offer = {type = 'give-item', item = 'iron-plate', count = 500}},
--repeating these:
{price = {{'iron-plate', 300}}, offer = {type = 'give-item', item = 'copper-plate', count = 500}},
{price = {{'copper-plate', 300}}, offer = {type = 'give-item', item = 'iron-plate', count = 500}},
2022-03-13 01:44:32 +00:00
{price = {{'steel-plate', 40}}, offer = {type = 'give-item', item = 'copper-plate', count = 500}},
{price = {{'steel-plate', 40}}, offer = {type = 'give-item', item = 'iron-plate', count = 500}},
2022-02-28 16:36:46 +00:00
{price = {{'raw-fish', 50}}, offer = {type = 'give-item', item = 'coal', count = 500}},
{price = {{'raw-fish', 50}}, offer = {type = 'give-item', item = 'iron-plate', count = 750}},
{price = {{'raw-fish', 50}}, offer = {type = 'give-item', item = 'copper-plate', count = 750}},
{price = {{'raw-fish', 50}}, offer = {type = 'give-item', item = 'steel-plate', count = 125}},
2021-10-13 09:21:53 +01:00
2021-10-24 15:27:57 +01:00
{price = {{'wood', 200}}, offer = {type = 'give-item', item = 'coin', count = 250}},
2021-10-13 09:21:53 +01:00
--TODO: add more complex trades
}
2022-02-26 23:33:19 +00:00
Public.market_permanent_offers = {
2022-04-29 17:43:46 +01:00
{price = {{'pistol', 1}}, offer = {type = 'give-item', item = 'coin', count = 450}},
2022-03-17 01:40:18 +00:00
{price = {{'coin', 2400}}, offer = {type = 'give-item', item = 'iron-ore', count = 800}},
{price = {{'coin', 2400}}, offer = {type = 'give-item', item = 'copper-ore', count = 800}},
2022-03-08 23:36:03 +00:00
{price = {{'coin', 3000}}, offer = {type = 'give-item', item = 'crude-oil-barrel', count = 100}},
2022-03-13 18:19:59 +00:00
{price = {{'coin', 2500}}, offer = {type = 'give-item', item = 'fast-loader', count = 1}},
2022-03-03 00:19:20 +00:00
{price = {{'coin', 5000}}, offer = {type = 'give-item', item = 'beacon', count = 2}},
2022-03-07 18:41:42 +00:00
{price = {{'coin', 2800}}, offer = {type = 'give-item', item = 'speed-module-2', count = 2}},
2022-02-26 23:33:19 +00:00
}
-- cheap but one-off
Public.market_sales = {
2022-03-08 23:36:03 +00:00
{price = {{'coin', 2000}}, offer = {type = 'give-item', item = 'coal', count = 900}},
{price = {{'coin', 2000}}, offer = {type = 'give-item', item = 'piercing-rounds-magazine', count = 75}},
{price = {{'coin', 2000}}, offer = {type = 'give-item', item = 'uranium-rounds-magazine', count = 30}},
2022-03-11 22:53:36 +00:00
{price = {{'coin', 2000}}, offer = {type = 'give-item', item = 'piercing-shotgun-shell', count = 50}},
2022-03-08 23:36:03 +00:00
{price = {{'coin', 2000}}, offer = {type = 'give-item', item = 'raw-fish', count = 300}},
2022-03-13 01:44:32 +00:00
{price = {{'coin', 2000}}, offer = {type = 'give-item', item = 'laser-turret', count = 1}},
2022-03-08 23:36:03 +00:00
{price = {{'coin', 2000}}, offer = {type = 'give-item', item = 'vehicle-machine-gun', count = 3}},
2022-03-09 21:39:47 +00:00
{price = {{'coin', 3000}}, offer = {type = 'give-item', item = 'modular-armor', count = 1}},
2022-03-08 23:36:03 +00:00
{price = {{'coin', 2000}}, offer = {type = 'give-item', item = 'distractor-capsule', count = 20}},
{price = {{'coin', 2000}}, offer = {type = 'give-item', item = 'poison-capsule', count = 20}},
{price = {{'coin', 2000}}, offer = {type = 'give-item', item = 'slowdown-capsule', count = 20}},
{price = {{'coin', 2000}}, offer = {type = 'give-item', item = 'coin', count = 4000}},
2022-03-11 22:53:36 +00:00
{price = {{'coin', 2000}}, offer = {type = 'give-item', item = 'roboport', count = 1}},
2022-03-14 21:38:44 +00:00
{price = {{'coin', 2000}}, offer = {type = 'give-item', item = 'construction-robot', count = 10}},
2022-03-17 01:40:18 +00:00
{price = {{'coin', 2000}}, offer = {type = 'give-item', item = 'logistic-chest-passive-provider', count = 2}},
{price = {{'coin', 2000}}, offer = {type = 'give-item', item = 'logistic-robot', count = 2}},
2022-02-26 23:33:19 +00:00
}
2021-10-13 09:21:53 +01:00
2022-03-17 01:40:18 +00:00
-- function Public.dock_generate_offers(how_many_barters, how_many_sales)
-- local ret = {}
-- local toaddcount
-- local barterscopy = Utils.deepcopy(Public.market_barters)
-- toaddcount = how_many_barters
-- while toaddcount>0 and #barterscopy > 0 do
-- local index = Math.random(#barterscopy)
-- local toadd = barterscopy[index]
-- ret[#ret + 1] = toadd
-- for i = index, #barterscopy - 1 do
-- barterscopy[i] = barterscopy[i+1]
-- end
-- barterscopy[#barterscopy] = nil
-- toaddcount = toaddcount - 1
-- end
-- for _, offer in pairs(Public.market_permanent_offers) do
-- ret[#ret + 1] = offer
-- end
-- local salescopy = Utils.deepcopy(Public.market_sales)
-- toaddcount = how_many_sales
-- while toaddcount>0 and #salescopy > 0 do
-- local index = Math.random(#salescopy)
-- local toadd = salescopy[index]
-- ret[#ret + 1] = toadd
-- for i = index, #salescopy - 1 do
-- salescopy[i] = salescopy[i+1]
-- end
-- salescopy[#salescopy] = nil
-- toaddcount = toaddcount - 1
-- end
2022-03-19 21:20:55 +00:00
2021-10-13 09:21:53 +01:00
2022-03-17 01:40:18 +00:00
-- return ret
-- end
2021-10-13 09:21:53 +01:00
2022-03-07 18:41:42 +00:00
function Public.create_dock_markets(surface, p)
local destination = Common.current_destination()
2021-10-13 09:21:53 +01:00
if not (surface and p) then return end
2022-03-07 18:41:42 +00:00
local e
2022-03-19 21:20:55 +00:00
e = surface.create_entity{name = 'market', position = {x = p.x - 22, y = p.y - 1}}
if e and e.valid then
e.minable = false
e.rotatable = false
e.destructible = false
e.add_market_item{price = {{'coin', 1000}}, offer = {type = 'give-item', item = 'artillery-turret', count = 1}}
local upgrade_for_sale = Common.current_destination().static_params.upgrade_for_sale
if upgrade_for_sale then
e.add_market_item(Upgrades.market_offer_form[upgrade_for_sale])
end
destination.dynamic_data.dock_captains_market = e
end
2022-03-07 18:41:42 +00:00
e = surface.create_entity{name = 'market', position = {x = p.x - 7, y = p.y}}
if e and e.valid then
e.minable = false
e.rotatable = false
e.destructible = false
2022-03-19 21:20:55 +00:00
2022-03-07 18:41:42 +00:00
for _, offer in pairs(Public.market_permanent_offers) do
e.add_market_item(offer)
end
end
2022-03-19 21:20:55 +00:00
2022-03-07 18:41:42 +00:00
e = surface.create_entity{name = 'market', position = {x = p.x, y = p.y - 1}}
if e and e.valid then
e.minable = false
e.rotatable = false
e.destructible = false
2021-10-13 09:21:53 +01:00
2022-03-07 18:41:42 +00:00
local toaddcount
2022-03-19 21:20:55 +00:00
2022-03-07 18:41:42 +00:00
local salescopy = Utils.deepcopy(Public.market_sales)
toaddcount = 3
while toaddcount>0 and #salescopy > 0 do
local index = Math.random(#salescopy)
local offer = salescopy[index]
e.add_market_item(offer)
for i = index, #salescopy - 1 do
salescopy[i] = salescopy[i+1]
2021-10-13 09:21:53 +01:00
end
2022-03-07 18:41:42 +00:00
salescopy[#salescopy] = nil
toaddcount = toaddcount - 1
end
2022-03-07 09:50:25 +00:00
2022-03-07 18:41:42 +00:00
-- new class offerings:
if destination.static_params.class_for_sale then
e.add_market_item{price={{'coin', Balance.class_cost()}}, offer={type="nothing", effect_description = 'Purchase the class ' .. Classes.display_form[destination.static_params.class_for_sale] .. '.'}}
-- destination.dynamic_data.market_class_offer_rendering = rendering.draw_text{
-- text = 'Class available: ' .. Classes.display_form[destination.static_params.class_for_sale],
-- surface = surface,
-- target = Utils.psum{e.position, {x = 0, y = -4}},
-- color = CoreData.colors.renderingtext_green,
-- scale = 2.5,
-- font = 'default-game',
-- alignment = 'center'
-- }
2022-03-07 18:41:42 +00:00
end
end
2022-03-19 21:20:55 +00:00
2022-03-07 18:41:42 +00:00
e = surface.create_entity{name = 'market', position = {x = p.x + 7, y = p.y}}
if e and e.valid then
e.minable = false
e.rotatable = false
e.destructible = false
local toaddcount
2022-03-19 21:20:55 +00:00
2022-03-07 18:41:42 +00:00
local barterscopy = Utils.deepcopy(Public.market_barters)
toaddcount = 2
while toaddcount>0 and #barterscopy>0 do
local index = Math.random(#barterscopy)
local offer = barterscopy[index]
e.add_market_item(offer)
for i = index, #barterscopy - 1 do
barterscopy[i] = barterscopy[i+1]
2022-03-07 09:50:25 +00:00
end
2022-03-07 18:41:42 +00:00
barterscopy[#barterscopy] = nil
toaddcount = toaddcount - 1
2021-10-13 09:21:53 +01:00
end
end
end
return Public