Created
August 31, 2010 21:14
-
-
Save devgru/559765 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var testCell = function (current, test) { | |
var actor = current.piece; | |
var target = test.piece; | |
if (current == test && (!current.maze || actor.is('C'))) { | |
return 'empty'; | |
} | |
if (actor.is('M')) { | |
if (Math.max(Math.abs(current.x - test.x), Math.abs(current.y - test.y)) > 2) { | |
return 'tooFar'; | |
} | |
} | |
if (test.isEmpty()) { | |
if (test.maze && !actor.is('C')) { | |
return 'tooCasual'; | |
} else { | |
return 'empty'; | |
} | |
} | |
if (target.color == actor.color) { | |
return 'busy'; | |
} | |
if (actor.is('N')) { | |
return target.dead ? 'interact' : 'busy'; | |
} | |
if (actor.is('P')) { | |
return target.dead ? 'busy' : 'interact'; | |
} | |
if (actor.is('M') && test.maze) { | |
return 'tooCasual'; | |
} | |
if (target.dead || actor.is('R')) { | |
return 'busy'; | |
} else { | |
return 'interact'; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment