2019-10-08 05:50:32 +02:00
|
|
|
local market = {}
|
|
|
|
|
|
|
|
market.weapons = {
|
|
|
|
["pistol"] = {value = 10, rarity = 1},
|
|
|
|
["submachine-gun"] = {value = 50, rarity = 2},
|
|
|
|
["shotgun"] = {value = 40, rarity = 2},
|
|
|
|
["combat-shotgun"] = {value = 400, rarity = 5},
|
|
|
|
["rocket-launcher"] = {value = 250, rarity = 4},
|
|
|
|
["flamethrower"] = {value = 750, rarity = 6},
|
|
|
|
["land-mine"] = {value = 3, rarity = 5},
|
|
|
|
}
|
|
|
|
|
|
|
|
market.ammo = {
|
|
|
|
["firearm-magazine"] = {value = 3, rarity = 1},
|
|
|
|
["piercing-rounds-magazine"] = {value = 6, rarity = 4},
|
|
|
|
["uranium-rounds-magazine"] = {value = 16, rarity = 8},
|
|
|
|
["shotgun-shell"] = {value = 3, rarity = 1},
|
|
|
|
["piercing-shotgun-shell"] = {value = 8, rarity = 5},
|
|
|
|
["cannon-shell"] = {value = 8, rarity = 4},
|
|
|
|
["explosive-cannon-shell"] = {value = 12, rarity = 5},
|
|
|
|
["uranium-cannon-shell"] = {value = 16, rarity = 7},
|
|
|
|
["explosive-uranium-cannon-shell"] = {value = 20, rarity = 8},
|
|
|
|
["artillery-shell"] = {value = 64, rarity = 7},
|
|
|
|
["rocket"] = {value = 4, rarity = 3},
|
|
|
|
["explosive-rocket"] = {value = 12, rarity = 5},
|
|
|
|
["atomic-bomb"] = {value = 5000, rarity = 10},
|
|
|
|
["flamethrower-ammo"] = {value = 20, rarity = 6},
|
|
|
|
}
|
|
|
|
|
|
|
|
market.caspules = {
|
|
|
|
["grenade"] = {value = 8, rarity = 1},
|
|
|
|
["cluster-grenade"] = {value = 24, rarity = 5},
|
|
|
|
["poison-capsule"] = {value = 16, rarity = 6},
|
|
|
|
["slowdown-capsule"] = {value = 8, rarity = 1},
|
|
|
|
["defender-capsule"] = {value = 8, rarity = 1},
|
|
|
|
["distractor-capsule"] = {value = 16, rarity = 5},
|
|
|
|
["destroyer-capsule"] = {value = 24, rarity = 7},
|
|
|
|
["discharge-defense-remote"] = {value = 64, rarity = 6},
|
2019-10-08 19:26:40 +02:00
|
|
|
["artillery-targeting-remote"] = {value = 32, rarity = 7},
|
2019-10-08 05:50:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
market.armor = {
|
|
|
|
["light-armor"] = {value = 25, rarity = 1},
|
|
|
|
["heavy-armor"] = {value = 250, rarity = 4},
|
|
|
|
["modular-armor"] = {value = 750, rarity = 5},
|
|
|
|
["power-armor"] = {value = 2500, rarity = 6},
|
|
|
|
["power-armor-mk2"] = {value = 20000, rarity = 10},
|
|
|
|
}
|
|
|
|
|
|
|
|
market.equipment = {
|
|
|
|
["solar-panel-equipment"] = {value = 240, rarity = 3},
|
|
|
|
["fusion-reactor-equipment"] = {value = 9000, rarity = 7},
|
|
|
|
["energy-shield-equipment"] = {value = 400, rarity = 6},
|
|
|
|
["energy-shield-mk2-equipment"] = {value = 4000, rarity = 8},
|
|
|
|
["battery-equipment"] = {value = 160, rarity = 2},
|
|
|
|
["battery-mk2-equipment"] = {value = 2000, rarity = 8},
|
|
|
|
["personal-laser-defense-equipment"] = {value = 2500, rarity = 7},
|
|
|
|
["discharge-defense-equipment"] = {value = 2000, rarity = 5},
|
|
|
|
["belt-immunity-equipment"] = {value = 500, rarity = 1},
|
|
|
|
["exoskeleton-equipment"] = {value = 1000, rarity = 3},
|
|
|
|
["personal-roboport-equipment"] = {value = 500, rarity = 4},
|
|
|
|
["personal-roboport-mk2-equipment"] = {value = 5000, rarity = 8},
|
|
|
|
["night-vision-equipment"] = {value = 250, rarity = 1},
|
|
|
|
}
|
|
|
|
|
|
|
|
market.defense = {
|
|
|
|
["stone-wall"] = {value = 4, rarity = 1},
|
|
|
|
["gate"] = {value = 8, rarity = 1},
|
|
|
|
["repair-pack"] = {value = 10, rarity = 1},
|
|
|
|
["gun-turret"] = {value = 64, rarity = 1},
|
|
|
|
["laser-turret"] = {value = 1024, rarity = 7},
|
|
|
|
["flamethrower-turret"] = {value = 2048, rarity = 6},
|
|
|
|
["artillery-turret"] = {value = 8192, rarity = 8},
|
|
|
|
["rocket-silo"] = {value = 64000, rarity = 10},
|
|
|
|
}
|
|
|
|
|
|
|
|
market.logistic = {
|
|
|
|
["wooden-chest"] = {value = 3, rarity = 1},
|
|
|
|
["iron-chest"] = {value = 10, rarity = 2},
|
|
|
|
["steel-chest"] = {value = 24, rarity = 3},
|
|
|
|
["storage-tank"] = {value = 32, rarity = 4},
|
|
|
|
["transport-belt"] = {value = 4, rarity = 1},
|
|
|
|
["fast-transport-belt"] = {value = 8, rarity = 4},
|
|
|
|
["express-transport-belt"] = {value = 24, rarity = 7},
|
|
|
|
["underground-belt"] = {value = 8, rarity = 1},
|
|
|
|
["fast-underground-belt"] = {value = 32, rarity = 4},
|
|
|
|
["express-underground-belt"] = {value = 64, rarity = 7},
|
|
|
|
["splitter"] = {value = 16, rarity = 1},
|
|
|
|
["fast-splitter"] = {value = 48, rarity = 4},
|
|
|
|
["express-splitter"] = {value = 128, rarity = 7},
|
|
|
|
["burner-inserter"] = {value = 4, rarity = 1},
|
|
|
|
["inserter"] = {value = 8, rarity = 1},
|
|
|
|
["long-handed-inserter"] = {value = 12, rarity = 2},
|
|
|
|
["fast-inserter"] = {value = 16, rarity = 4},
|
|
|
|
["filter-inserter"] = {value = 24, rarity = 5},
|
|
|
|
["stack-inserter"] = {value = 96, rarity = 6},
|
|
|
|
["stack-filter-inserter"] = {value = 128, rarity = 7},
|
|
|
|
["small-electric-pole"] = {value = 2, rarity = 1},
|
|
|
|
["medium-electric-pole"] = {value = 12, rarity = 4},
|
|
|
|
["big-electric-pole"] = {value = 24, rarity = 5},
|
|
|
|
["substation"] = {value = 96, rarity = 8},
|
|
|
|
["pipe"] = {value = 2, rarity = 1},
|
|
|
|
["pipe-to-ground"] = {value = 8, rarity = 1},
|
|
|
|
["pump"] = {value = 16, rarity = 4},
|
|
|
|
["logistic-robot"] = {value = 32, rarity = 5},
|
|
|
|
["construction-robot"] = {value = 32, rarity = 5},
|
|
|
|
["logistic-chest-active-provider"] = {value = 128, rarity = 7},
|
|
|
|
["logistic-chest-passive-provider"] = {value = 128, rarity = 6},
|
|
|
|
["logistic-chest-storage"] = {value = 128, rarity = 6},
|
|
|
|
["logistic-chest-buffer"] = {value = 128, rarity = 7},
|
|
|
|
["logistic-chest-requester"] = {value = 128, rarity = 7},
|
|
|
|
["roboport"] = {value = 4096, rarity = 8},
|
|
|
|
}
|
|
|
|
|
|
|
|
market.vehicles = {
|
|
|
|
["rail"] = {value = 4, rarity = 1},
|
|
|
|
["train-stop"] = {value = 32, rarity = 3},
|
|
|
|
["rail-signal"] = {value = 8, rarity = 5},
|
|
|
|
["rail-chain-signal"] = {value = 8, rarity = 5},
|
|
|
|
["locomotive"] = {value = 640, rarity = 4},
|
|
|
|
["cargo-wagon"] = {value = 320, rarity = 4},
|
|
|
|
["fluid-wagon"] = {value = 480, rarity = 5},
|
|
|
|
["artillery-wagon"] = {value = 8192, rarity = 9},
|
|
|
|
["car"] = {value = 96, rarity = 1},
|
|
|
|
["tank"] = {value = 2048, rarity = 7},
|
|
|
|
}
|
|
|
|
|
|
|
|
market.wire = {
|
|
|
|
["small-lamp"] = {value = 4, rarity = 1},
|
|
|
|
["red-wire"] = {value = 4, rarity = 1},
|
|
|
|
["green-wire"] = {value = 4, rarity = 1},
|
|
|
|
["arithmetic-combinator"] = {value = 16, rarity = 1},
|
|
|
|
["decider-combinator"] = {value = 16, rarity = 1},
|
|
|
|
["constant-combinator"] = {value = 16, rarity = 1},
|
|
|
|
["power-switch"] = {value = 16, rarity = 1},
|
|
|
|
["programmable-speaker"] = {value = 24, rarity = 1},
|
|
|
|
}
|
|
|
|
|
|
|
|
local function get_types()
|
|
|
|
local types = {}
|
|
|
|
for k, v in pairs(market) do
|
|
|
|
types[#types + 1] = k
|
|
|
|
end
|
|
|
|
return types
|
|
|
|
end
|
|
|
|
|
|
|
|
local function get_market_item_list(market_types, rarity)
|
|
|
|
if rarity < 1 then rarity = 1 end
|
|
|
|
local list = {}
|
|
|
|
for _, market_type in pairs(market_types) do
|
|
|
|
for k, item in pairs(market[market_type]) do
|
|
|
|
if item.rarity <= rarity then
|
|
|
|
local price = math.random(math.floor(item.value * 0.75), math.floor(item.value * 1.25))
|
|
|
|
if price < 1 then price = 1 end
|
2019-10-08 19:26:40 +02:00
|
|
|
if price > 64000 then price = 64000 end
|
2019-10-08 05:50:32 +02:00
|
|
|
list[#list + 1] = {price = {{"coin", price}}, offer = {type = 'give-item', item = k}}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if #list == 0 then return false end
|
|
|
|
return list
|
|
|
|
end
|
|
|
|
|
|
|
|
local function get_random_market_item_list(rarity)
|
|
|
|
local types = get_types()
|
|
|
|
table.shuffle_table(types)
|
|
|
|
for i = 1, #types, 1 do
|
|
|
|
local items = get_market_item_list({types[i]}, rarity)
|
|
|
|
if items then return items end
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
function random_type_market(surface, position, rarity)
|
|
|
|
local types = get_types()
|
|
|
|
table.shuffle_table(types)
|
|
|
|
local types = {types[1], types[2]}
|
|
|
|
local items = get_market_item_list({types[1], types[2]}, rarity)
|
|
|
|
if not items then return end
|
|
|
|
if #items > 0 then table.shuffle_table(items) end
|
|
|
|
local market = surface.create_entity({name = "market", position = position})
|
2019-10-08 19:26:40 +02:00
|
|
|
for i = 1, math.random(5, 10), 1 do
|
2019-10-08 06:54:42 +02:00
|
|
|
if not items[i] then break end
|
|
|
|
market.add_market_item(items[i])
|
2019-10-08 05:50:32 +02:00
|
|
|
end
|
|
|
|
return market
|
|
|
|
end
|
|
|
|
|
|
|
|
function super_market(surface, position, rarity)
|
|
|
|
|
|
|
|
end
|