#include "hexagon.h"
#include <cmath>


// METHODS
void Hexagon::display(SDL_Surface *image) const
{
  int x_temp = radius * (sqrt(3.0)/2.0) + x;
  int y_temp = radius/2 + y;
  int x2_temp = x;
  int y2_temp = radius + y;
  if(walls[bottom_right])
    draw_line(image, x_temp, y_temp, x2_temp, y2_temp);
  x_temp = -radius * (sqrt(3.0)/2.0) + x;
  y_temp = radius/2 + y;
  if(walls[bottom_left])
    draw_line(image, x_temp, y_temp, x2_temp, y2_temp);
  x2_temp = -radius * (sqrt(3.0)/2.0) + x;
  y2_temp = -radius/2 + y;
  if(walls[left])
    draw_line(image, x_temp, y_temp, x2_temp, y2_temp);
  x_temp = x;
  y_temp = -radius + y;
  if(walls[top_left])
    draw_line(image, x_temp, y_temp, x2_temp, y2_temp);
  x2_temp = radius * (sqrt(3.0)/2.0) + x;
  y2_temp = -radius/2 + y;
  if(walls[top_right])
    draw_line(image, x_temp, y_temp, x2_temp, y2_temp);
  x_temp = radius * (sqrt(3.0)/2.0) + x;
  y_temp = radius/2 + y;
  if(walls[right])
    draw_line(image, x_temp, y_temp, x2_temp, y2_temp);

}

void Hexagon::setFields(int x, int y, int radius)
{
  this->x = x;
  this->y = y;
  this->radius = radius;
  for(int i = 0; i < NUMBER_OF_WALLS; ++i)
  {
    walls[i] = true;
  }
  visited = false;
}

bool Hexagon::isVisited() const
{
  return visited;
}

bool Hexagon::setVisited(bool visited)
{
  this->visited = visited;
}

void Hexagon::removeWall(direction wichone)
{
  walls[wichone] = false;
}

void Hexagon::getXY(int &x, int &y) const
{
  x = this->x;
  y = this->y;
}
