Meta sections for rulesets
Posted: Tue Jul 12, 2022 12:34 pm
i am creating a ruleset, and i commonly find myself basically copypasting sections and changing 1 or 2 things only or always adding the same thing to many similar sections, for instance the nation group requirement that i have for my advances as each belongs to a tech tree, but they share a class, so i have multiple [advance_tech_tree_*] sections with equal reqs field and class.
the idea of a meta section is that they have a section_target property which determines which sections should be affected and they somehow, add equal or similar properties to affected sections. it should be possible to at least choose affected sections by regex on the section name and property value,
and it should be possible to add a property based on other already defined properties i will provide an example
say we have various advances each belonging to a tech class like the following
[advance_tech_tree_1_example]
name = "Tech Tree 1 Example"
class = "Tech Tree 1"
req1 = "None"
req2 = "None"
root_req = "None"
reqs = {"type", "name","range"
"NationGroup","Tech Tree 1","Player"
}
...
if we aim to use the maximum of advances available you will need to write the reqs field 250 times, with meta sections it could for instance be written like this with some variation depending on how meta sections are implemented
[meta_section_tech_tree_1]
section_targets = {"type","target","value2","ruleset"
"Property","class","Tech Tree 1","techs"
}
value_to_add = {"property","property_in_section","type"
"reqs", "reqs","substitute"
}
reqs = {"type", "name","range"
"NationGroup","Tech Tree 1","Player"
}
so instead of writing reqs 250 you write once for each tech tree, for more utility we could make it so a certain sequence of characters substitute for a property so say we wanted to add a nation group req for each tech but they also have other requirements
we could then if $ is the subtitute property symbol write reqs as
reqs = {"type", "name","range","present","quiet"
$reqs
"NationGroup","Tech Tree 1","Player",TRUE,FALSE
}
i believe meta sections would make it easier to maintain and develop rulesets, as you would need to only specify where the rules are different, it could be useful to have a way to exclude sections so maybe there should be a "present" property to the section targets table. however i may be missing another even better alternative to lessen duplication of ruleset definitions if so please mention this even better idea.
the idea of a meta section is that they have a section_target property which determines which sections should be affected and they somehow, add equal or similar properties to affected sections. it should be possible to at least choose affected sections by regex on the section name and property value,
and it should be possible to add a property based on other already defined properties i will provide an example
say we have various advances each belonging to a tech class like the following
[advance_tech_tree_1_example]
name = "Tech Tree 1 Example"
class = "Tech Tree 1"
req1 = "None"
req2 = "None"
root_req = "None"
reqs = {"type", "name","range"
"NationGroup","Tech Tree 1","Player"
}
...
if we aim to use the maximum of advances available you will need to write the reqs field 250 times, with meta sections it could for instance be written like this with some variation depending on how meta sections are implemented
[meta_section_tech_tree_1]
section_targets = {"type","target","value2","ruleset"
"Property","class","Tech Tree 1","techs"
}
value_to_add = {"property","property_in_section","type"
"reqs", "reqs","substitute"
}
reqs = {"type", "name","range"
"NationGroup","Tech Tree 1","Player"
}
so instead of writing reqs 250 you write once for each tech tree, for more utility we could make it so a certain sequence of characters substitute for a property so say we wanted to add a nation group req for each tech but they also have other requirements
we could then if $ is the subtitute property symbol write reqs as
reqs = {"type", "name","range","present","quiet"
$reqs
"NationGroup","Tech Tree 1","Player",TRUE,FALSE
}
i believe meta sections would make it easier to maintain and develop rulesets, as you would need to only specify where the rules are different, it could be useful to have a way to exclude sections so maybe there should be a "present" property to the section targets table. however i may be missing another even better alternative to lessen duplication of ruleset definitions if so please mention this even better idea.