private function getDirectionToMove($railType, $candidateDirection)
{
switch ($railType) {
case Rail::STRAIGHT_NORTH_SOUTH:
case Rail::SLOPED_ASCENDING_NORTH:
case Rail::SLOPED_ASCENDING_SOUTH:
switch ($candidateDirection) {
case Entity::NORTH:
case Entity::SOUTH:
return $candidateDirection;
}
break;
case Rail::STRAIGHT_EAST_WEST:
case Rail::SLOPED_ASCENDING_EAST:
case Rail::SLOPED_ASCENDING_WEST:
switch ($candidateDirection) {
case Entity::WEST:
case Entity::EAST:
return $candidateDirection;
}
break;
case Rail::CURVED_SOUTH_EAST:
switch ($candidateDirection) {
case Entity::SOUTH:
case Entity::EAST:
return $candidateDirection;
case Entity::NORTH:
return $this->checkForTurn($candidateDirection, Entity::EAST);
case Entity::WEST:
return $this->checkForTurn($candidateDirection, Entity::SOUTH);
}
break;
case Rail::CURVED_SOUTH_WEST:
switch ($candidateDirection) {
case Entity::SOUTH:
case Entity::WEST:
return $candidateDirection;
case Entity::NORTH:
return $this->checkForTurn($candidateDirection, Entity::WEST);
case Entity::EAST:
return $this->checkForTurn($candidateDirection, Entity::SOUTH);
}
break;
case Rail::CURVED_NORTH_WEST:
switch ($candidateDirection) {
case Entity::NORTH:
case Entity::WEST:
return $candidateDirection;
case Entity::SOUTH:
return $this->checkForTurn($candidateDirection, Entity::WEST);
case Entity::EAST:
return $this->checkForTurn($candidateDirection, Entity::NORTH);
}
break;
case Rail::CURVED_NORTH_EAST:
switch ($candidateDirection) {
case Entity::NORTH:
case Entity::EAST:
return $candidateDirection;
case Entity::SOUTH:
return $this->checkForTurn($candidateDirection, Entity::EAST);
case Entity::WEST:
return $this->checkForTurn($candidateDirection, Entity::NORTH);
}
break;
}
return -1;
}