Relations syntax
Posted: Mon May 15, 2023 9:18 am
In the rulesets, requirements mostly test properties of a specific game object (e.g. if unit vetranship is at least 2), or, rarely, relations between game objects of different nature within the context (e.g. if the tile is the center of the city). The exception is Local-ranged "DiplRel" that tests states between the player and another player.
I propose to generalize the concept of relation as a rule that tests a boolean/tristate function of two contexts. Mostly it is for use in action enablers but also for effects (the 2nd context has the player filled) and probably somewhere else. Relations shall live in "rels" vectors that behave mostly like "reqs" vectors.
Columns in "rels" should have captions "type" (the type of relation, e.g. "Dipl" or "MapDist"), "value" (that what is confusingly "name" for reqs - e.g. "War" or 10), "op" (comparison operator, defaults to "=", negation is made switching "=" to "!=", ">" to "<=" etc.), and two columns of the source entities, that in action enablers are naturally "actor_range" and "target_range" (maybe "range" is also an obscure word that should be changed).
The ranges should be more specific and developed than ranges of requirements. The base of them shall be the fields of context object ("Player", "Unit", "Extra" etc.) but functions should be possible like "Player.PrimaryCapital" or "Unit.Tile.City.Nationalities", I have described stuff like that in an old proposal. Each function spawns either an entity or an array of entities of some type (that should conform for actor and target sources).
Types of realations may be:
Dipl (Player)
What is local "DiplRel". You may use comparison to test that the players have e.g. at least armistice.
MapDist, RealMapDist, DistSq (Tile)
To e.g. unhardcode minimal trading distance.
Size, Veteran, Score... (various)
Integer parameters, "value" considered to be a difference. Maybe we can compare culture of a nation to culture of a city?
Idem (value dependent?)
If the source objects are similar on some criterium. E.g., "value"="City" means that the source cities are the same city (to make visible the ban of establishing trade route to home city etc.), and "value"="NationGroup" means that the players belong to the same nation group. Comparison operators may specify should all source objects in actor source array have identical pair in the target source array, or only some of them, or something of the set-theory operations.
I propose to generalize the concept of relation as a rule that tests a boolean/tristate function of two contexts. Mostly it is for use in action enablers but also for effects (the 2nd context has the player filled) and probably somewhere else. Relations shall live in "rels" vectors that behave mostly like "reqs" vectors.
Columns in "rels" should have captions "type" (the type of relation, e.g. "Dipl" or "MapDist"), "value" (that what is confusingly "name" for reqs - e.g. "War" or 10), "op" (comparison operator, defaults to "=", negation is made switching "=" to "!=", ">" to "<=" etc.), and two columns of the source entities, that in action enablers are naturally "actor_range" and "target_range" (maybe "range" is also an obscure word that should be changed).
The ranges should be more specific and developed than ranges of requirements. The base of them shall be the fields of context object ("Player", "Unit", "Extra" etc.) but functions should be possible like "Player.PrimaryCapital" or "Unit.Tile.City.Nationalities", I have described stuff like that in an old proposal. Each function spawns either an entity or an array of entities of some type (that should conform for actor and target sources).
Types of realations may be:
Dipl (Player)
What is local "DiplRel". You may use comparison to test that the players have e.g. at least armistice.
MapDist, RealMapDist, DistSq (Tile)
To e.g. unhardcode minimal trading distance.
Size, Veteran, Score... (various)
Integer parameters, "value" considered to be a difference. Maybe we can compare culture of a nation to culture of a city?
Idem (value dependent?)
If the source objects are similar on some criterium. E.g., "value"="City" means that the source cities are the same city (to make visible the ban of establishing trade route to home city etc.), and "value"="NationGroup" means that the players belong to the same nation group. Comparison operators may specify should all source objects in actor source array have identical pair in the target source array, or only some of them, or something of the set-theory operations.