Advanced "present" field of requirements

What would you like to see in Freeciv? Do you have a good idea what should be improved or how?
Ignatus
Hardened
Posts: 220
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Advanced "present" field of requirements

Postby Ignatus » Wed Jun 19, 2019 6:42 pm

The idea is to make requirement mechanism more flexible without changing much. In 2.6 "present" field can be only TRUE (default: there is one in the range that conforms to the requirement) or FALSE (there is none in the range). I suggest allowing some other values:
  • "all" - all items in the range must conform to the requirement. Thus,

    Code: Select all

    "Building", "EcclesiasticalPalace", "Alliance", "all"
    requires that every player in the alliance has a small wonder "Ecclesiastical palace".
  • nn (a number) - exactly this number of items in the range accomplish the requirement. For example, to build a water pp, require that the city is in the middle of a river (at least so it shall work on a rectangular map):

    Code: Select all

    "Extra", "River", "CAdjacent", 3
    "Extra", "River", "Local"
  • -nn - exactly this number of items does not accomplish this. E.g. in a city effect definition

    Code: Select all

    "DiplRel", "IsForeign", "Traderoute", -1

    line shall mean that the effect works only if all cities that one trades with (read, except itself) are foreign.
  • "nn%", "-nn%" - the requirement (not) works for that part of the region (nn compared to int(n_[not_]works*100/n_total), so there is some gap).
  • "[>|>=|<|<=][-]nn[%]" - generalized format of if the number of (not) accomplished requirements is greater, greater or equal etc. to a given amount or percentage. For example, let's move into the vector InspirePartisans requirement of at least citizen.partisans_pct (let it be 50) of the city must be natives (assuming that we also allowed "City" range for DiplRel to check citizens' nationalities relative to the player):

    Code: Select all

    "DiplRel", "IsForeign", "City", ">=50%"
Implementing this won't require a great amount of code or break existing ruleset syntax.