Open PLynx01 opened 1 month ago
Finally go for OR multiFilters, then it's already implemented via UniqueType.OnlyAvailable
?
I repeat myself: Complex nested multifilters with and or not
logic are technically no problem, they're only a translation problem. I say *$§$& the translations, allow unreadable filters. It could then be the modders responsibility to make them readable by hiding the unique and providing a good comment unique instead.
But - I also got the feeling there was some work weeks or months ago that had a similar vein, only I can't find it via sources and blame... Ah, scan contributor list until one rings a bell did it: Compare closed pulls by dHannasch - that was tech prereqs too but for unit upgrades. IIRC that pulls chain felt incomplete at the time...
So, yes, good idea IMHO. But divergent solutions to similar usecases should be a no.
That said, my fist idea was to allow an and
ed list or or
ed lists under the prerequisites key without breaking backward compatibility by using custom json serialization. so A and
B would be: "prerequisites":["A","B"]
same as before, A or
B would be: "prerequisites":[["A","B"]]
, A and
(B or
C) = "prerequisites":["A",["B","C"]]
, and (A and
B) or
C = "prerequisites":[["A","C"],["B","C"]]
. In other words, a mix of classic and your first proposal. For translatability of the descriptions - same argument as above.
This is something that pops up once in a while in different contexts. Solving it in one doesn't solve it in another.
The real answer here is IMO an <or>
conditional, which here would lead to only available <when [A] researched> <or> <when B researched>
. Or / and logic acts as code, that is, "a or b and c or d" means "(a) or (b or c) or (d)" which may be unintuitive - but the opposite "a and b or c and d" would be unintuitive the other way round so there's no winning this one.
But this would require some work.
Changing fields for niche cases is rarely ever the answer. Custom json serialization is really the last thing we want, I really hope you're joking
HOWEVER - making this as a multifilter would certainly be easier. And if we want to say "damn the translations full speed ahead, let the nested multifilters flow" we can do that. If you're a mad enough modder to use nested boolean logic, then it's on you to debug it and explain it to your users, and good luck with that.
Custom json serialization is really the last thing we want, I really hope you're joking
Not really. With implements Serializable
the json constructor registering a Serializer is obsolete, the pain less. Here, it's relatively cheap 100% backwards compatibility that doesn't even need future cleanup, can stay.
That said, I assumed the way to go will be existing Uniques anyway, which would make that json a moot point. But coding it for curiosity - that I coudn't resist. And it proved I finally got the hang of it and understood where the Gdx design choices felt so quirky.
an
<or>
conditional
I'd hesitate strongly before doing mandatory positional significance of conditionals. Hmmm.. Maybe if it allows 100% encapsulation inside one conditional processor class, that would be enough plusones to justify...
Before creating
Problem Description
Currently, when modders are specifying multiple prerequisite Techs, all must be researched before the Technology can be researched. Civ 4 in particular has many Techs that have OR in their prerequisites, so it can't be implemented for now.
Related Issue Links
No response
Desired Solution
I think that we can use nested lists. In that case, if at least one list of prerequisite techs is fulfilled, the technology becomes available to research, even if the other lists are not completed.
Example: In Civ 4 the early-game tech "Animal Husbandry" requires Hunting OR Agriculture https://civilization.fandom.com/wiki/AnimalHusbandry(Civ4)
The syntax would be like this:
Alternative Approaches
Alternatively we can transform the "prerequisite" type from List of Strings into an Object:
Something like this:
Additional Context
I posted this issue in order to make sure my PRs won't be rejected after posting them, so I am asking you for your opinion before I begin work on new feature.