Skip to content

Instantly share code, notes, and snippets.

@devgru
Created August 31, 2010 21:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devgru/559765 to your computer and use it in GitHub Desktop.
Save devgru/559765 to your computer and use it in GitHub Desktop.
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