1
0
forked from 0ad/0ad

add a NOT when checking classes matching, fixes #3611

This was SVN commit r17326.
This commit is contained in:
mimo 2015-11-29 15:59:52 +00:00
parent 814cdd9524
commit 34b0c6d779
2 changed files with 4 additions and 2 deletions

View File

@ -33,6 +33,7 @@ function GetVisibleIdentityClasses(template)
* @param match Either a string in the form
* "Class1 Class2+Class3"
* where spaces are handled as OR and '+'-signs as AND,
* and ! is handled as NOT, thus Class1+!Class2 = Class1 AND NOT Class2
* Or a list in the form
* [["Class1"], ["Class2", "Class3"]]
* where the outer list is combined as OR, and the inner lists are AND-ed
@ -56,7 +57,8 @@ function MatchesClassList(classes, match)
// if the elements are still strings, split them by space or by '+'
if (typeof sublist == "string")
sublist = sublist.split(/[+\s]+/);
if (sublist.every(function(c) { return classes.indexOf(c) != -1; }))
if (sublist.every(c => (c[0] == "!" && classes.indexOf(c.substr(1)) == -1)
|| (c[0] != "!" && classes.indexOf(c) != -1)))
return true;
}

View File

@ -22,7 +22,7 @@
<BuffHeal>0</BuffHeal>
<EjectHealth>0.1</EjectHealth>
<EjectClassesOnDestroy datatype="tokens">Unit</EjectClassesOnDestroy>
<List datatype="tokens">Support</List>
<List datatype="tokens">Support+!Elephant</List>
<LoadingRange>1</LoadingRange>
</GarrisonHolder>
<Health>