I am programming in Python. In Python 2 and 3, it is considered valid to combine two value conditionals together like this:
if 0 < x < 10: print "x is a positive single digit."
Taking this into account, I defined a function in Sarven Brawl that would return any enemies within a certain position:
def findByPos(lowX, hiX,lowY,hiY): return [e for e in self.findEnemies() if lowX < e.pos.x < hiX and lowY < e.pos.y < hiY]
I then used it like this:
enemy = self.findNearest(findByPos(30,96,60,80))
This should have returned all enemies inside the center canyon, while ignoring one ones outside. However, my hero proceeded to try to attack a scout on the outside:
I fixed this error by breaking up the comparisons into individual statements, but can someone provide an explanation for this lack of functionality?