I have been thinking for a while on how I want tech/perk requirements and now I think I have come up with a solution I like, which also is fairly easy to code.
XML contains
- RequiredTechs
- RequiredTechsOR
- RequiredPecks
- RequiredPecksOR
- iNumRequiredOR
1-4 are lists while 5 is an int.
This is put in the code, which is shared between perks and techs meaning techs can require perks and vice versa. Also it only has to be coded once.
The idea being that the required techs/perks really are required. If one of them is missing, the player can't research the tech/perk in question regardless of the other requirements.
The OR techs/perks will then be counted. CanResearch will fail if the combine owned number is below iNumRequiredOR.
I'm thinking something like adding a list for adding arrows as well, though I'm not completely sure. That's a graphical only and not important for game mechanics.
New idea
While writing this a new idea came to light. What if techs and perks are merged into a single CivEffect list
If we fully exploit that, then we can write code like this:
PHP:
<RequiredCivEffects>
<RequiredCivEffect>ERA_X</RequiredCivEffect>
</RequiredCivEffects>
<RequiredCivEffectsOR>
<RequiredCivEffect>TRAIT_BRILLIANT</RequiredCivEffect>
<RequiredCivEffect>TECH_A</RequiredCivEffect>
<RequiredCivEffect>TECH_B</RequiredCivEffect>
</RequiredCivEffectsOR>
<iNumRequiredOR>1</iNumRequiredOR>
This will be a tech, which can be researched when the player reach era X and has either tech A or tech B. However if the player is lucky enough to have TRAIT_BRILLIANT, then it is enough to simply reach era X.
It would also be possible to place the trait requirement in requirements (not OR), in which case it is a tech, which can only be researched by brilliant people. To fully use this, we could make say 3 traits and then ensure that all leaders has precisely one of those, then we can make tech trees of equal size and usefulness for each type of leader, but they wouldn't gain access to precisely the same techs. This could be made into something interesting, particularly with tech/perk trading or spies.
The CivEffect approach would require more or less the same amount of coding to get working (possibly even less because the number of lists is halved). However I would need to make XML reading code to read strings and convert to CivEffect indexes. That would likely be a good idea to add anyway as it can be used elsewhere as well.
There has been talk about affecting research cost if more than enough OR requirements is available. We can add that later if we still want to do that. For now, I just want to figure out the XML layout and the general design strategy.
What do you say? Should we go for the CivEffect list idea? Do you have any other idea, which could make this even better?