-
Notifications
You must be signed in to change notification settings - Fork 79
Danger Ores: shared main-ores factory, standardized numbers (A-F), fluent API (G) #1573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
grilledham
merged 31 commits into
Refactorio:develop
from
lex:danger-ore-shared-ore-config
Jul 10, 2026
Merged
Changes from 22 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
babe294
Tetrominoes: use shared vanilla_ores_stone ore config
lex d3feca1
Voronoi: use shared vanilla_ores_stone ore config
lex c7fc424
Tetrominoes: enforce the 4-ore minimum at map creation
lex 032d702
Voronoi: enforce the 4-ore minimum at map creation
lex 2448123
Derive 3way_ores from x_cross_ores
lex 732f46b
Add ore config test suite
lex ebf07f4
Danger Ores: add a factory for the standard main-ore configs
lex d82dd74
Danger Ores: derive vanilla_ores from the main-ores factory
lex 22532c2
Danger Ores: derive vanilla_ores_one_direction from the factory
lex ab8c633
Danger Ores: derive vanilla_ores_landfill from the factory
lex c62c175
Danger Ores: derive one_direction_ores_xmas from the factory
lex 325aa7a
Danger Ores: derive x_cross_ores from the factory
lex b5d9ceb
Danger Ores: derive vanilla_ores_gridlocked from the factory
lex 72708e0
Danger Ores: derive joker_starter_area from the factory
lex 54e1694
Danger Ores: derive poor_mans_coal_fields_ores from the factory
lex cead7e5
Danger Ores: build the vanilla_ores_stone stone entry via the factory
lex dd7f5e0
Danger Ores: cover the main-ores factory in the config test suite
lex e6740b5
Danger Ores: silence unused stub argument in ore config tests
lex 2925479
Danger Ores: fold the coal-rich mix into the canonical coal mix
lex 4f86de2
Danger Ores: standardize richness curves on the vanilla pair
lex 06e1dd2
Danger Ores: retire the redundant ore config files
lex 76b2bee
Danger Ores: joker starter coal joins the standard richness budget
lex d751371
Danger Ores: fluent API for the main-ores factory
lex 69bbe6c
Danger Ores: express the standard configs through the fluent API
lex ac71c95
Danger Ores: complete the fluent API, use utils.table's deep_copy
lex 2491ec8
Danger Ores: restore the Joker starter's low coal budget
lex ea42815
Danger Ores: xmas tree keeps default tiles minus grass-4
lex b5806cf
Danger Ores: add :change_mix to the fluent API
lex 912bf06
Danger Ores: express the all-coal config through the fluent API
lex a6b31ea
Danger Ores: express the scrap config through the fluent API
lex ab6a01c
Danger Ores: named arguments for the fluent curve shorthands
lex File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,92 +1,30 @@ | ||
| -- The Joker starter area: canonical mixes with time-budgeted richness -- each patch | ||
| -- holds roughly a day of a single electric mining drill's output. Plus a token | ||
| -- super-rich uranium entry. | ||
| local b = require 'map_gen.shared.builders' | ||
| local Factory = require 'map_gen.maps.danger_ores.config.main_ores_factory' | ||
|
|
||
| local mine_speed = 0.5 / 10 -- 0.5 ore/s per electric mining drill | ||
| local low = 60 * 60 * 4 * mine_speed -- 4h | ||
| local medium = 60 * 60 * 24 * mine_speed -- 24h | ||
|
|
||
| local low_value = b.exponential_value(low, 0.07, 1.45) | ||
| local medium_value = b.exponential_value(medium, 0.07, 1.45) | ||
|
|
||
| return { | ||
| { | ||
| name = 'copper-ore', | ||
| tiles = { | ||
| [1] = 'red-desert-0', | ||
| [2] = 'red-desert-1', | ||
| [3] = 'red-desert-2', | ||
| [4] = 'red-desert-3' | ||
| }, | ||
| start = 1, | ||
| weight = 1, | ||
| ratios = { | ||
| {resource = b.resource(b.full_shape, 'iron-ore', medium_value), weight = 15}, | ||
| {resource = b.resource(b.full_shape, 'copper-ore', medium_value), weight = 70}, | ||
| {resource = b.resource(b.full_shape, 'stone', medium_value), weight = 10}, | ||
| {resource = b.resource(b.full_shape, 'coal', medium_value), weight = 5} | ||
| } | ||
| }, | ||
| { | ||
| name = 'coal', | ||
| tiles = { | ||
| [1] = 'dirt-1', | ||
| [2] = 'dirt-2', | ||
| [3] = 'dirt-3', | ||
| [4] = 'dirt-4', | ||
| [5] = 'dirt-5', | ||
| [6] = 'dirt-6', | ||
| [7] = 'dirt-7' | ||
| }, | ||
| start = 1, | ||
| weight = 1, | ||
| ratios = { | ||
| {resource = b.resource(b.full_shape, 'iron-ore', low_value), weight = 18}, | ||
| {resource = b.resource(b.full_shape, 'copper-ore', low_value), weight = 9}, | ||
| {resource = b.resource(b.full_shape, 'stone', low_value), weight = 8}, | ||
| {resource = b.resource(b.full_shape, 'coal', low_value), weight = 65} | ||
| } | ||
| }, | ||
| { | ||
| name = 'iron-ore', | ||
| tiles = { | ||
| [1] = 'grass-1', | ||
| [2] = 'grass-2', | ||
| [3] = 'grass-3', | ||
| [4] = 'grass-4' | ||
| }, | ||
| start = 1, | ||
| weight = 1, | ||
| ratios = { | ||
| {resource = b.resource(b.full_shape, 'iron-ore', medium_value), weight = 75}, | ||
| {resource = b.resource(b.full_shape, 'copper-ore', medium_value), weight = 13}, | ||
| {resource = b.resource(b.full_shape, 'stone', medium_value), weight = 7}, | ||
| {resource = b.resource(b.full_shape, 'coal', medium_value), weight = 5} | ||
| } | ||
| }, | ||
| { | ||
| name = 'stone', | ||
| tiles = { | ||
| [1] = 'sand-1', | ||
| [2] = 'sand-2', | ||
| [3] = 'sand-3' | ||
| }, | ||
| start = 1, | ||
| weight = 1, | ||
| ratios = { | ||
| {resource = b.resource(b.full_shape, 'iron-ore', medium_value), weight = 25}, | ||
| {resource = b.resource(b.full_shape, 'copper-ore', medium_value), weight = 10}, | ||
| {resource = b.resource(b.full_shape, 'stone', medium_value), weight = 60}, | ||
| {resource = b.resource(b.full_shape, 'coal', medium_value), weight = 5} | ||
| } | ||
| }, | ||
| { | ||
| name = 'uranium-ore', | ||
| start = 1, | ||
| weight = 1, | ||
| ratios = { | ||
| { | ||
| resource = b.resource(b.full_shape, 'uranium-ore', function() return 1e6 end), | ||
| weight = 1 | ||
| }, | ||
| local config = Factory.main_ores { | ||
| ores = {'copper-ore', 'coal', 'iron-ore', 'stone'}, | ||
| start = 1, | ||
| value = medium_value | ||
| } | ||
|
|
||
| config[#config + 1] = { | ||
| name = 'uranium-ore', | ||
| start = 1, | ||
| weight = 1, | ||
| ratios = { | ||
| { | ||
| resource = b.resource(b.full_shape, 'uranium-ore', function() return 1e6 end), | ||
| weight = 1 | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return config | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| -- Factory for the standard danger-ores main-ore configs. Most of them use the same | ||
| -- per-ore floor tiles and the same dominant+minor resource mixes, differing only in | ||
| -- richness curves, ore order, entry weights or tile skins. This module holds those | ||
| -- canonical numbers once; each config composes its entries from here. | ||
| local b = require 'map_gen.shared.builders' | ||
|
|
||
| local Public = {} | ||
|
|
||
| -- Per-ore floor tiles. | ||
| local tile_sets = { | ||
| ['iron-ore'] = {'grass-1', 'grass-2', 'grass-3', 'grass-4'}, | ||
| ['copper-ore'] = {'red-desert-0', 'red-desert-1', 'red-desert-2', 'red-desert-3'}, | ||
| ['coal'] = {'dirt-1', 'dirt-2', 'dirt-3', 'dirt-4', 'dirt-5', 'dirt-6', 'dirt-7'}, | ||
| ['stone'] = {'sand-1', 'sand-2', 'sand-3'} | ||
| } | ||
|
|
||
| -- Dominant + minor mixes as {resource name, ratio weight} pairs, in canonical order. | ||
| local mixes = { | ||
| ['iron-ore'] = {{'iron-ore', 75}, {'copper-ore', 13}, {'stone', 7}, {'coal', 5}}, | ||
| ['copper-ore'] = {{'iron-ore', 15}, {'copper-ore', 70}, {'stone', 10}, {'coal', 5}}, | ||
| ['coal'] = {{'iron-ore', 18}, {'copper-ore', 9}, {'stone', 8}, {'coal', 65}}, | ||
| ['stone'] = {{'iron-ore', 25}, {'copper-ore', 10}, {'stone', 60}, {'coal', 5}} | ||
| } | ||
| Public.mixes = mixes | ||
|
|
||
| local function copy_array(array) | ||
| local copy = {} | ||
| for i, v in ipairs(array) do | ||
| copy[i] = v | ||
| end | ||
| return copy | ||
| end | ||
|
RedRafe marked this conversation as resolved.
Outdated
|
||
|
|
||
| -- Fresh copy per call: the runtime must never share mutable tables between entries. | ||
| function Public.tiles(ore_name) | ||
| return copy_array(tile_sets[ore_name]) | ||
| end | ||
|
|
||
| -- Build a ratios table from a mix. make_resource(resource_name) -> resource shape. | ||
| function Public.ratios(mix_name, make_resource) | ||
| local ratios = {} | ||
| for i, mix in ipairs(mixes[mix_name]) do | ||
| ratios[i] = {resource = make_resource(mix[1]), weight = mix[2]} | ||
| end | ||
| return ratios | ||
| end | ||
|
|
||
| -- The common case: plain full-shape resources with one richness curve. | ||
| function Public.full_shape_resource(value) | ||
| return function(resource_name) | ||
| return b.resource(b.full_shape, resource_name, value) | ||
| end | ||
| end | ||
|
|
||
| -- One main-ore entry. params: name (required), start (required), and either value or | ||
| -- make_resource; mix (defaults to name), tiles (defaults to the ore's tile set) and | ||
| -- weight (defaults to 1) optional. | ||
| function Public.entry(params) | ||
| local name = params.name | ||
| local make_resource = params.make_resource | ||
| if not make_resource then | ||
| assert(params.value, 'main_ores_factory.entry: either value or make_resource is required') | ||
| make_resource = Public.full_shape_resource(params.value) | ||
| end | ||
| return { | ||
| name = name, | ||
| tiles = params.tiles or Public.tiles(name), | ||
| start = params.start, | ||
| weight = params.weight or 1, | ||
| ratios = Public.ratios(params.mix or name, make_resource) | ||
| } | ||
| end | ||
|
|
||
| -- A whole main-ores config in one call. ores is an array of ore names or per-entry | ||
| -- params tables; start/value/weight/tiles/make_resource act as defaults for every entry. | ||
| function Public.main_ores(params) | ||
| local config = {} | ||
| for i, ore in ipairs(params.ores) do | ||
| if type(ore) == 'string' then | ||
| ore = {name = ore} | ||
| end | ||
| config[i] = Public.entry { | ||
| name = ore.name, | ||
| mix = ore.mix, | ||
| tiles = ore.tiles or (params.tiles and copy_array(params.tiles)), | ||
| start = ore.start or params.start, | ||
| value = ore.value or params.value, | ||
| weight = ore.weight or params.weight, | ||
| make_resource = ore.make_resource or params.make_resource | ||
| } | ||
| end | ||
| return config | ||
| end | ||
|
|
||
| return Public | ||
74 changes: 0 additions & 74 deletions
74
map_gen/maps/danger_ores/config/one_direction_ores_xmas.lua
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.