mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-20 03:29:47 +02:00
wip map
This commit is contained in:
parent
2840367b0a
commit
383aeb787c
181
maps/expanse/functions.lua
Normal file
181
maps/expanse/functions.lua
Normal file
@ -0,0 +1,181 @@
|
||||
local Price_raffle = require 'maps.expanse.price_raffle'
|
||||
local Public = {}
|
||||
|
||||
local price_modifiers = {
|
||||
["unit-spawner"] = -128,
|
||||
["unit"] = -16,
|
||||
["turret"] = -128,
|
||||
["tree"] = -8,
|
||||
["simple-entity"] = -12,
|
||||
["cliff"] = -32,
|
||||
["water"] = -4,
|
||||
["water-green"] = -4,
|
||||
["deepwater"] = -4,
|
||||
["deepwater-green"] = -4,
|
||||
["water-mud"] = -6,
|
||||
["water-shallow"] = -6,
|
||||
}
|
||||
|
||||
local function get_cell_value(expanse, left_top)
|
||||
local square_size = expanse.square_size
|
||||
local value = square_size ^ 2
|
||||
value = value * 8
|
||||
|
||||
local source_surface = game.surfaces[expanse.source_surface]
|
||||
local area = {{left_top.x, left_top.y}, {left_top.x + square_size, left_top.y + square_size}}
|
||||
local entities = source_surface.find_entities(area)
|
||||
local tiles = source_surface.find_tiles_filtered({area = area})
|
||||
|
||||
for _, tile in pairs(tiles) do
|
||||
if price_modifiers[tile.name] then
|
||||
value = value - price_modifiers[tile.name]
|
||||
end
|
||||
end
|
||||
|
||||
local distance = math.sqrt(left_top.x ^ 2 + left_top.y ^ 2)
|
||||
local value = value * (distance * 0.01)
|
||||
|
||||
for _, entity in pairs(entities) do
|
||||
if price_modifiers[entity.type] then
|
||||
value = value - price_modifiers[entity.type]
|
||||
end
|
||||
if entity.type == "resource" then
|
||||
if entity.name == "crude-oil" then
|
||||
value = value + (entity.amount * 0.01)
|
||||
else
|
||||
value = value + (entity.amount * 0.1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
value = math.floor(value)
|
||||
if value < 16 then value = 16 end
|
||||
|
||||
return value
|
||||
end
|
||||
|
||||
local function get_left_top(expanse, position)
|
||||
local vectors = {{-1, 0}, {1, 0}, {0, 1}, {0, -1}}
|
||||
table.shuffle_table(vectors)
|
||||
|
||||
local surface = game.surfaces.expanse
|
||||
|
||||
local vector = false
|
||||
for _, v in pairs(vectors) do
|
||||
local tile = surface.get_tile({position.x + v[1], position.y + v[2]})
|
||||
if tile.name == "out-of-map" then
|
||||
vector = v
|
||||
break
|
||||
end
|
||||
end
|
||||
if not vector then return end
|
||||
|
||||
local left_top = {x = position.x + vector[1], y = position.y + vector[2]}
|
||||
left_top.x = left_top.x - left_top.x % expanse.square_size
|
||||
left_top.y = left_top.y - left_top.y % expanse.square_size
|
||||
|
||||
return left_top
|
||||
end
|
||||
|
||||
local function is_container_position_valid(expanse, position)
|
||||
if game.tick == 0 then return true end
|
||||
|
||||
local left_top = get_left_top(expanse, position)
|
||||
if not left_top then return false end
|
||||
|
||||
if game.surfaces.expanse.count_entities_filtered({name = "logistic-chest-requester", force = "neutral", area = {{left_top.x - 1, left_top.y - 1}, {left_top.x + expanse.square_size + 1, left_top.y + expanse.square_size + 1}}}) > 0 then
|
||||
return false
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
function Public.expand(expanse, left_top)
|
||||
local source_surface = game.surfaces[expanse.source_surface]
|
||||
if not source_surface then return end
|
||||
source_surface.request_to_generate_chunks({x = 0, y = 0}, 3)
|
||||
source_surface.force_generate_chunk_requests()
|
||||
|
||||
local square_size = expanse.square_size
|
||||
local area = {{left_top.x, left_top.y}, {left_top.x + square_size, left_top.y + square_size}}
|
||||
local surface = game.surfaces.expanse
|
||||
|
||||
source_surface.clone_area({
|
||||
source_area = area,
|
||||
destination_area = area,
|
||||
destination_surface = surface,
|
||||
clone_tiles = true,
|
||||
clone_entities = true,
|
||||
clone_decoratives = true,
|
||||
clear_destination_entities = false,
|
||||
clear_destination_decoratives = true,
|
||||
expand_map = true,
|
||||
})
|
||||
|
||||
for _, e in pairs(source_surface.find_entities(area)) do e.destroy() end
|
||||
|
||||
local positions = {
|
||||
{x = left_top.x + math.random(1, square_size - 2), y = left_top.y},
|
||||
{x = left_top.x, y = left_top.y + math.random(1, square_size - 2)},
|
||||
{x = left_top.x + math.random(1, square_size - 2), y = left_top.y + (square_size - 1)},
|
||||
{x = left_top.x + (square_size - 1), y = left_top.y + math.random(1, square_size - 2)},
|
||||
}
|
||||
|
||||
for _, position in pairs(positions) do
|
||||
if is_container_position_valid(expanse, position) then
|
||||
local e = surface.create_entity({name = "logistic-chest-requester", position = position, force = "neutral"})
|
||||
e.destructible = false
|
||||
e.minable = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function init_container(expanse, entity)
|
||||
local left_top = get_left_top(expanse, entity.position)
|
||||
if not left_top then return end
|
||||
|
||||
local cell_value = get_cell_value(expanse, left_top)
|
||||
game.print(cell_value)
|
||||
|
||||
local containers = expanse.containers
|
||||
containers[entity.unit_number] = {entity = entity, left_top = left_top, price = Price_raffle.roll(cell_value, 30)}
|
||||
end
|
||||
|
||||
function Public.set_container(expanse, entity)
|
||||
if not expanse.containers[entity.unit_number] then init_container(expanse, entity) end
|
||||
|
||||
local container = expanse.containers[entity.unit_number]
|
||||
|
||||
local inventory = container.entity.get_inventory(defines.inventory.chest)
|
||||
|
||||
for key, item_stack in pairs(container.price) do
|
||||
local count_removed = inventory.remove(item_stack)
|
||||
container.price[key].count = container.price[key].count - count_removed
|
||||
if container.price[key].count <= 0 then
|
||||
table.remove(container.price, key)
|
||||
end
|
||||
end
|
||||
|
||||
if #container.price == 0 then
|
||||
Public.expand(expanse, container.left_top)
|
||||
expanse.containers[entity.unit_number] = nil
|
||||
if not inventory.is_empty() then
|
||||
for name, count in pairs(inventory.get_contents()) do
|
||||
entity.surface.spill_item_stack(entity.position, {name = name, count = count}, true, nil, false)
|
||||
end
|
||||
end
|
||||
entity.destructible = true
|
||||
entity.die()
|
||||
return
|
||||
end
|
||||
|
||||
for slot = 1, 30, 1 do
|
||||
entity.clear_request_slot(slot)
|
||||
end
|
||||
|
||||
for slot, item_stack in pairs(container.price) do
|
||||
container.entity.set_request_slot(item_stack, slot)
|
||||
end
|
||||
end
|
||||
|
||||
return Public
|
122
maps/expanse/main.lua
Normal file
122
maps/expanse/main.lua
Normal file
@ -0,0 +1,122 @@
|
||||
local Event = require 'utils.event'
|
||||
local Functions = require 'maps.expanse.functions'
|
||||
local Global = require 'utils.global'
|
||||
|
||||
local math_round = math.round
|
||||
|
||||
local expanse = {}
|
||||
Global.register(
|
||||
expanse,
|
||||
function(tbl)
|
||||
expanse = tbl
|
||||
end
|
||||
)
|
||||
|
||||
local function reset()
|
||||
expanse.containers = {}
|
||||
expanse.source_surface = 1
|
||||
expanse.square_size = 9
|
||||
|
||||
local map_gen_settings = {
|
||||
["water"] = 0,
|
||||
["starting_area"] = 1,
|
||||
["cliff_settings"] = {cliff_elevation_interval = 0, cliff_elevation_0 = 0},
|
||||
["default_enable_all_autoplace_controls"] = false,
|
||||
["autoplace_settings"] = {
|
||||
["entity"] = {treat_missing_as_default = false},
|
||||
["tile"] = {treat_missing_as_default = false},
|
||||
["decorative"] = {treat_missing_as_default = false},
|
||||
},
|
||||
autoplace_controls = {
|
||||
["coal"] = {frequency = 0, size = 0, richness = 0},
|
||||
["stone"] = {frequency = 0, size = 0, richness = 0},
|
||||
["copper-ore"] = {frequency = 0, size = 0, richness = 0},
|
||||
["iron-ore"] = {frequency = 0, size = 0, richness = 0},
|
||||
["uranium-ore"] = {frequency = 0, size = 0, richness = 0},
|
||||
["crude-oil"] = {frequency = 0, size = 0, richness = 0},
|
||||
["trees"] = {frequency = 0, size = 0, richness = 0},
|
||||
["enemy-base"] = {frequency = 0, size = 0, richness = 0}
|
||||
},
|
||||
}
|
||||
game.create_surface("expanse", map_gen_settings)
|
||||
|
||||
local source_surface = game.surfaces[expanse.source_surface]
|
||||
source_surface.request_to_generate_chunks({x = 0, y = 0}, 4)
|
||||
source_surface.force_generate_chunk_requests()
|
||||
|
||||
local surface = game.surfaces.expanse
|
||||
surface.request_to_generate_chunks({x = 0, y = 0}, 4)
|
||||
surface.force_generate_chunk_requests()
|
||||
|
||||
for _, player in pairs(game.players) do
|
||||
player.teleport({-4, -4}, source_surface)
|
||||
end
|
||||
|
||||
Functions.expand(expanse, {x = 0, y = 0})
|
||||
|
||||
for _, player in pairs(game.players) do
|
||||
player.teleport(surface.find_non_colliding_position("character", {expanse.square_size * 0.5, expanse.square_size * 0.5}, 8, 0.5), surface)
|
||||
end
|
||||
end
|
||||
|
||||
local function on_chunk_generated(event)
|
||||
if event.surface.name ~= "expanse" then return end
|
||||
local left_top = event.area.left_top
|
||||
local tiles = {}
|
||||
local i = 1
|
||||
|
||||
if left_top.x == 0 and left_top.y == 0 then
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
if x >= expanse.square_size or y >= expanse.square_size then
|
||||
tiles[i] = {name = "out-of-map", position = {left_top.x + x, left_top.y + y}}
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
tiles[i] = {name = "out-of-map", position = {left_top.x + x, left_top.y + y}}
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
event.surface.set_tiles(tiles, true)
|
||||
end
|
||||
|
||||
local function on_gui_opened(event)
|
||||
local entity = event.entity
|
||||
if not entity then return end
|
||||
if not entity.valid then return end
|
||||
if not entity.unit_number then return end
|
||||
if entity.force.index ~= 3 then return end
|
||||
Functions.set_container(expanse, entity)
|
||||
end
|
||||
|
||||
local function on_gui_closed(event)
|
||||
local entity = event.entity
|
||||
if not entity then return end
|
||||
if not entity.valid then return end
|
||||
if not entity.unit_number then return end
|
||||
if entity.force.index ~= 3 then return end
|
||||
Functions.set_container(expanse, entity)
|
||||
end
|
||||
|
||||
local function on_player_joined_game(event)
|
||||
local player = game.players[event.player_index]
|
||||
if player.online_time == 0 then
|
||||
local surface = game.surfaces.expanse
|
||||
player.teleport(surface.find_non_colliding_position("character", {expanse.square_size * 0.5, expanse.square_size * 0.5}, 32, 0.5), surface)
|
||||
end
|
||||
end
|
||||
|
||||
local function on_init(event)
|
||||
reset()
|
||||
end
|
||||
|
||||
Event.on_init(on_init)
|
||||
Event.add(defines.events.on_gui_opened, on_gui_opened)
|
||||
Event.add(defines.events.on_gui_closed, on_gui_closed)
|
||||
Event.add(defines.events.on_chunk_generated, on_chunk_generated)
|
||||
Event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
288
maps/expanse/price_raffle.lua
Normal file
288
maps/expanse/price_raffle.lua
Normal file
@ -0,0 +1,288 @@
|
||||
--[[
|
||||
roll(budget, max_slots, blacklist) returns a table with item-stacks
|
||||
budget - the total value of the item stacks combined
|
||||
max_slots - the maximum amount of item stacks to return
|
||||
blacklist - optional list of item names that can not be rolled. example: {["substation"] = true, ["roboport"] = true,}
|
||||
]]
|
||||
|
||||
local Public = {}
|
||||
|
||||
local table_shuffle_table = table.shuffle_table
|
||||
local table_insert = table.insert
|
||||
local table_remove = table.remove
|
||||
local math_random = math.random
|
||||
local math_floor = math.floor
|
||||
|
||||
local item_worths = {
|
||||
["wooden-chest"] = 4,
|
||||
["iron-chest"] = 8,
|
||||
["steel-chest"] = 64,
|
||||
["storage-tank"] = 64,
|
||||
["transport-belt"] = 4,
|
||||
["fast-transport-belt"] = 16,
|
||||
["express-transport-belt"] = 64,
|
||||
["underground-belt"] = 16,
|
||||
["fast-underground-belt"] = 64,
|
||||
["express-underground-belt"] = 256,
|
||||
["splitter"] = 16,
|
||||
["fast-splitter"] = 64,
|
||||
["express-splitter"] = 256,
|
||||
["burner-inserter"] = 2,
|
||||
["inserter"] = 8,
|
||||
["long-handed-inserter"] = 16,
|
||||
["fast-inserter"] = 32,
|
||||
["filter-inserter"] = 40,
|
||||
["stack-inserter"] = 128,
|
||||
["stack-filter-inserter"] = 160,
|
||||
["small-electric-pole"] = 4,
|
||||
["medium-electric-pole"] = 32,
|
||||
["big-electric-pole"] = 64,
|
||||
["substation"] = 256,
|
||||
["pipe"] = 1,
|
||||
["pipe-to-ground"] = 15,
|
||||
["pump"] = 32,
|
||||
["rail"] = 8,
|
||||
["train-stop"] = 64,
|
||||
["rail-signal"] = 16,
|
||||
["rail-chain-signal"] = 16,
|
||||
["locomotive"] = 512,
|
||||
["cargo-wagon"] = 256,
|
||||
["fluid-wagon"] = 256,
|
||||
["artillery-wagon"] = 16384,
|
||||
["car"] = 128,
|
||||
["tank"] = 4096,
|
||||
["logistic-robot"] = 256,
|
||||
["construction-robot"] = 256,
|
||||
["logistic-chest-active-provider"] = 256,
|
||||
["logistic-chest-passive-provider"] = 256,
|
||||
["logistic-chest-storage"] = 256,
|
||||
["logistic-chest-buffer"] = 512,
|
||||
["logistic-chest-requester"] = 512,
|
||||
["roboport"] = 2048,
|
||||
["small-lamp"] = 16,
|
||||
["red-wire"] = 4,
|
||||
["green-wire"] = 4,
|
||||
["arithmetic-combinator"] = 16,
|
||||
["decider-combinator"] = 16,
|
||||
["constant-combinator"] = 16,
|
||||
["power-switch"] = 16,
|
||||
["programmable-speaker"] = 32,
|
||||
["stone-brick"] = 2,
|
||||
["concrete"] = 4,
|
||||
["hazard-concrete"] = 4,
|
||||
["refined-concrete"] = 16,
|
||||
["refined-hazard-concrete"] = 16,
|
||||
["cliff-explosives"] = 256,
|
||||
["repair-pack"] = 8,
|
||||
["boiler"] = 8,
|
||||
["steam-engine"] = 32,
|
||||
["solar-panel"] = 64,
|
||||
["accumulator"] = 64,
|
||||
["nuclear-reactor"] = 8192,
|
||||
["heat-pipe"] = 128,
|
||||
["heat-exchanger"] = 256,
|
||||
["steam-turbine"] = 256,
|
||||
["burner-mining-drill"] = 8,
|
||||
["electric-mining-drill"] = 32,
|
||||
["offshore-pump"] = 16,
|
||||
["pumpjack"] = 64,
|
||||
["stone-furnace"] = 4,
|
||||
["steel-furnace"] = 64,
|
||||
["electric-furnace"] = 256,
|
||||
["assembling-machine-1"] = 32,
|
||||
["assembling-machine-2"] = 128,
|
||||
["assembling-machine-3"] = 512,
|
||||
["oil-refinery"] = 256,
|
||||
["chemical-plant"] = 128,
|
||||
["centrifuge"] = 2048,
|
||||
["lab"] = 64,
|
||||
["beacon"] = 512,
|
||||
["speed-module"] = 128,
|
||||
["speed-module-2"] = 512,
|
||||
["speed-module-3"] = 2048,
|
||||
["effectivity-module"] = 128,
|
||||
["effectivity-module-2"] = 512,
|
||||
["effectivity-module-3"] = 2048,
|
||||
["productivity-module"] = 128,
|
||||
["productivity-module-2"] = 512,
|
||||
["productivity-module-3"] = 2048,
|
||||
["iron-plate"] = 1,
|
||||
["copper-plate"] = 1,
|
||||
["solid-fuel"] = 16,
|
||||
["steel-plate"] = 8,
|
||||
["plastic-bar"] = 8,
|
||||
["sulfur"] = 4,
|
||||
["battery"] = 16,
|
||||
["explosives"] = 4,
|
||||
["crude-oil-barrel"] = 8,
|
||||
["heavy-oil-barrel"] = 16,
|
||||
["light-oil-barrel"] = 16,
|
||||
["lubricant-barrel"] = 16,
|
||||
["petroleum-gas-barrel"] = 16,
|
||||
["sulfuric-acid-barrel"] = 16,
|
||||
["water-barrel"] = 4,
|
||||
["copper-cable"] = 1,
|
||||
["iron-stick"] = 1,
|
||||
["iron-gear-wheel"] = 2,
|
||||
["empty-barrel"] = 4,
|
||||
["electronic-circuit"] = 4,
|
||||
["advanced-circuit"] = 16,
|
||||
["processing-unit"] = 128,
|
||||
["engine-unit"] = 8,
|
||||
["electric-engine-unit"] = 64,
|
||||
["flying-robot-frame"] = 128,
|
||||
["satellite"] = 32768,
|
||||
["rocket-control-unit"] = 256,
|
||||
["low-density-structure"] = 64,
|
||||
["rocket-fuel"] = 256,
|
||||
["nuclear-fuel"] = 1024,
|
||||
["uranium-235"] = 1024,
|
||||
["uranium-238"] = 32,
|
||||
["uranium-fuel-cell"] = 128,
|
||||
["automation-science-pack"] = 4,
|
||||
["logistic-science-pack"] = 16,
|
||||
["military-science-pack"] = 64,
|
||||
["chemical-science-pack"] = 128,
|
||||
["production-science-pack"] = 256,
|
||||
["utility-science-pack"] = 256,
|
||||
["space-science-pack"] = 512,
|
||||
["pistol"] = 4,
|
||||
["submachine-gun"] = 32,
|
||||
["shotgun"] = 16,
|
||||
["combat-shotgun"] = 256,
|
||||
["rocket-launcher"] = 128,
|
||||
["flamethrower"] = 512,
|
||||
["land-mine"] = 8,
|
||||
["firearm-magazine"] = 4,
|
||||
["piercing-rounds-magazine"] = 8,
|
||||
["uranium-rounds-magazine"] = 64,
|
||||
["shotgun-shell"] = 4,
|
||||
["piercing-shotgun-shell"] = 16,
|
||||
["cannon-shell"] = 8,
|
||||
["explosive-cannon-shell"] = 16,
|
||||
["uranium-cannon-shell"] = 64,
|
||||
["explosive-uranium-cannon-shell"] = 64,
|
||||
["artillery-shell"] = 128,
|
||||
["rocket"] = 8,
|
||||
["explosive-rocket"] = 8,
|
||||
["atomic-bomb"] = 16384,
|
||||
["flamethrower-ammo"] = 32,
|
||||
["grenade"] = 16,
|
||||
["cluster-grenade"] = 64,
|
||||
["poison-capsule"] = 64,
|
||||
["slowdown-capsule"] = 16,
|
||||
["defender-capsule"] = 16,
|
||||
["distractor-capsule"] = 128,
|
||||
["destroyer-capsule"] = 256,
|
||||
["light-armor"] = 32,
|
||||
["heavy-armor"] = 256,
|
||||
["modular-armor"] = 1024,
|
||||
["power-armor"] = 4096,
|
||||
["power-armor-mk2"] = 32768,
|
||||
["solar-panel-equipment"] = 256,
|
||||
["fusion-reactor-equipment"] = 8192,
|
||||
["energy-shield-equipment"] = 512,
|
||||
["energy-shield-mk2-equipment"] = 4096,
|
||||
["battery-equipment"] = 128,
|
||||
["battery-mk2-equipment"] = 2048,
|
||||
["personal-laser-defense-equipment"] = 2048,
|
||||
["discharge-defense-equipment"] = 2048,
|
||||
["discharge-defense-remote"] = 32,
|
||||
["belt-immunity-equipment"] = 256,
|
||||
["exoskeleton-equipment"] = 1024,
|
||||
["personal-roboport-equipment"] = 512,
|
||||
["personal-roboport-mk2-equipment"] = 4096,
|
||||
["night-vision-equipment"] = 256,
|
||||
["stone-wall"] = 8,
|
||||
["gate"] = 16,
|
||||
["gun-turret"] = 64,
|
||||
["laser-turret"] = 1024,
|
||||
["flamethrower-turret"] = 2048,
|
||||
["artillery-turret"] = 8192,
|
||||
["radar"] = 32,
|
||||
["rocket-silo"] = 65536,
|
||||
}
|
||||
|
||||
local item_names = {}
|
||||
for k, v in pairs(item_worths) do table_insert(item_names, k) end
|
||||
local size_of_item_names = #item_names
|
||||
|
||||
local function get_raffle_keys()
|
||||
local raffle_keys = {}
|
||||
for i = 1, size_of_item_names, 1 do
|
||||
raffle_keys[i] = i
|
||||
end
|
||||
table_shuffle_table(raffle_keys)
|
||||
return raffle_keys
|
||||
end
|
||||
|
||||
function Public.roll_item_stack(remaining_budget, blacklist)
|
||||
if remaining_budget <= 0 then return end
|
||||
local raffle_keys = get_raffle_keys()
|
||||
local item_name = false
|
||||
local item_worth = 0
|
||||
for _, index in pairs(raffle_keys) do
|
||||
item_name = item_names[index]
|
||||
item_worth = item_worths[item_name]
|
||||
if not blacklist[item_name] and item_worth <= remaining_budget then break end
|
||||
end
|
||||
|
||||
local stack_size = game.item_prototypes[item_name].stack_size * 16
|
||||
|
||||
local item_count = 1
|
||||
|
||||
for c = 1, math_random(1, stack_size), 1 do
|
||||
local price = c * item_worth
|
||||
if price <= remaining_budget then
|
||||
item_count = c
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
return {name = item_name, count = item_count}
|
||||
end
|
||||
|
||||
local function roll_item_stacks(remaining_budget, max_slots, blacklist)
|
||||
local item_stack_set = {}
|
||||
local item_stack_set_worth = 0
|
||||
|
||||
for i = 1, max_slots, 1 do
|
||||
if remaining_budget <= 0 then break end
|
||||
local item_stack = Public.roll_item_stack(remaining_budget, blacklist)
|
||||
item_stack_set[i] = item_stack
|
||||
remaining_budget = remaining_budget - item_stack.count * item_worths[item_stack.name]
|
||||
item_stack_set_worth = item_stack_set_worth + item_stack.count * item_worths[item_stack.name]
|
||||
end
|
||||
|
||||
return item_stack_set, item_stack_set_worth
|
||||
end
|
||||
|
||||
function Public.roll(budget, max_slots, blacklist)
|
||||
if not budget then return end
|
||||
if not max_slots then return end
|
||||
|
||||
local b
|
||||
if not blacklist then
|
||||
b = {}
|
||||
else
|
||||
b = blacklist
|
||||
end
|
||||
|
||||
budget = math_floor(budget)
|
||||
if budget == 0 then return end
|
||||
|
||||
local final_stack_set
|
||||
local final_stack_set_worth = 0
|
||||
|
||||
for attempt = 1, 5, 1 do
|
||||
local item_stack_set, item_stack_set_worth = roll_item_stacks(budget, max_slots, b)
|
||||
if item_stack_set_worth > final_stack_set_worth or item_stack_set_worth == budget then
|
||||
final_stack_set = item_stack_set
|
||||
final_stack_set_worth = item_stack_set_worth
|
||||
end
|
||||
end
|
||||
return final_stack_set
|
||||
end
|
||||
|
||||
return Public
|
Loading…
x
Reference in New Issue
Block a user