Page MenuHomeWildfire Games

fix misleading or wrong technology affect tags
Changes PlannedPublic

Authored by bb on Oct 22 2017, 9:42 PM.

Details

Reviewers
leper
Summary

As proposed by @leper in D869 the use of ["foo bar"] in MatchesClassList is misleading as it actually means ["foo+bar"], [["foo", "bar"]] or "foo+bar". This has already fooled me in D859. For changing this behaviour, we first need to remove all the instances it is used, here is the bulk for the techs.

Now changing ["foo bar"] into [["foo", "bar"]] since that is the most optimised way in MatchesClassList, could also become "foo+bar" or whatever.

(for some reason phab is removing newlines, that is not intended, when adding them back manually phab complains about linting :/ )

Test Plan

Make sure all nstances of the techs with a loose affects tag (so not one in the modifications) are changed.
Notice no change in outcome (except the 1 which is clearly wrong, another proof its misleading...)

Event Timeline

bb created this revision.Oct 22 2017, 9:42 PM
Owners added a subscriber: Restricted Owners Package.Oct 22 2017, 9:42 PM
bb edited the summary of this revision. (Show Details)Oct 22 2017, 9:42 PM
bb added inline comments.
binaries/data/mods/public/simulation/data/technologies/attack_champions_elite.json
19–20

this must be wrong...

Vulcan added a subscriber: Vulcan.Oct 22 2017, 9:43 PM

Build is green

Updating workspaces...
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (307 tests)...................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (307 tests)...................................................................................................................................................................................................................................................................................................................OK!
Checking XML files...

http://jenkins-master:8080/job/phabricator/2151/ for more details.

Executing section Default...
Executing section Source...
Executing section JS...
Executing section XML GUI...

http://jenkins-master:8080/job/phabricator_lint/619/ for more details.

fatherbushido added inline comments.
binaries/data/mods/public/simulation/data/technologies/attack_champions_elite.json
19–20

(rP19939 can perhaps help you)

leper accepted this revision.Oct 25 2017, 6:41 PM

Diff looks ok. That one template seems broken, but that should be fixed in another diff. (If you include that hunk in this one is up to you.)

binaries/data/mods/public/simulation/data/technologies/carthaginians/special_exploration.json
11

I'm wondering if we shouldn't require 2 level nested arrays in any case, but meh.

This revision is now accepted and ready to land.Oct 25 2017, 6:41 PM
bb added a comment.Oct 25 2017, 9:28 PM

Indeed that hunk should be left out, since @fatherbusido noticed the code is broken in that case (and that should go in a seperate diff).

thx for the review!

Nescio added a subscriber: Nescio.Oct 25 2017, 9:41 PM

In other parts of those files (e.g. “requirements” the convention seems to be to alternate [brackets] and {braces}, therefore I'm wondering why it's brackets within brackets for affects, e.g. "affects": [ ["Infantry", "Advanced"] ],
And does this change also affects the “affects” within “modifications”?

By the way, what is now the OR operator? Simply a space, without a comma?

In D977#38358, @Nescio wrote:

In other parts of those files (e.g. “requirements” the convention seems to be to alternate [brackets] and {braces}, therefore I'm wondering why it's brackets within brackets for affects, e.g. "affects": [ ["Infantry", "Advanced"] ],

  • indicates an array, [[],[]] is an array of arrays. requirements needs objects, that for some of the possibilities take arrays of requirements (so again objects).

And does this change also affects the “affects” within “modifications”?

Same thing applies to that, all of those end up in the same function (MatchStringList, see the commit/diff referenced in the description).

By the way, what is now the OR operator? Simply a space, without a comma?

Same as the old one. ("A B" or [["A"], ["B"]])

What is changed (or going to change here) is a confusing syntax that might be read as OR, but is actually AND due to how the above mentioned function works. Basically requirements need to be specified in disjunctive normal form. Then only thing that is slightly confusing is that some places support only strings, so those are split into arrays of arrays, and others support arrays, so use them since that does not require splitting. The confusing syntax is mixing the two, and allows syntax that would mean something different without [] and just makes the whole thing harder to grasp.

bb added a comment.Oct 25 2017, 10:10 PM

according to some post by fatherbushido the modification support is broken. For the documentation of the classes strings see the MatchesClassList function in templates.js (its like two elements in the first scope is OR so "foo bar"==["foo", "bar"], in the second AND, so "foo+bar"==[["foo", "bar"]])

Thank you for your reply; now I'm confused, unfortunately.
How to write down OR and AND right now (before these changes), and what will they be (after these changes)?

bb added a comment.Oct 25 2017, 11:09 PM

OR can be written like "foo+bar" or [["foo"],["bar"]] or ["foo", "bar"]. (all those are equivalent)
AND can be written like "foo bar" or ["foo+bar"] or [["foo", "bar"]]. (all those are equivalent)

Also notice that this patch doesn't change the execution (ignoring that one template with comments), it only removes some misleading cases of ["foo bar"] with in the current code that is equal to "foo bar", but that is not obvious so should be avoided/removed.

Thank you for the clarification. So all those instances work right now (before these changes) and will remain unchanged (afterwards)?

In D977#38383, @bb wrote:

OR can be written like "foo+bar" or [["foo"],["bar"]] or ["foo", "bar"]. (all those are equivalent)

"foo+bar" is foo AND bar. The other two are correct.

AND can be written like "foo bar" or ["foo+bar"] or [["foo", "bar"]]. (all those are equivalent)

"foo bar" is foo OR bar. The other two are correct.

Also notice that this patch doesn't change the execution (ignoring that one template with comments), it only removes some misleading cases of ["foo bar"] with in the current code that is equal to "foo bar", but that is not obvious so should be avoided/removed.

Except in the current code ["foo bar"] is equivalent to "foo+bar", which means we have with the same meaning as + in one case, but not in any of the others.

Guess this just shows how confusing this is.

To help with figuring out how this works (or should): The outer "layer" (be that items in the first level array, or parts of strings separated by ) is combined with OR, the inner layer with AND.

bb planned changes to this revision.Oct 28 2017, 6:15 PM

The revision isn't complete due to some matching problems between the modification.affects and the affects tag. This we need to fix before.