#ifndef BATTLESHIP_SHIP_H
#define BATTLESHIP_SHIP_H

#include <string>
#include <ostream>
#include <stdint.h>

namespace Battleship{

class Ship{
private:
    uint8_t size;
    int x, y;
    bool horizontal;
    Ship* nextShip;
public:
    Ship(uint8_t size, int x = -1, int y = -1, bool horizontal = true, Ship* nextShip = NULL)
        : size((size)%8), x(x), y(y), horizontal(horizontal), nextShip(nextShip) {};

    Ship(uint8_t size, Ship* nextShip) : size((size)%8), x(-1), y(-1), horizontal(true), nextShip(nextShip) {};

    bool operator<(const Ship& other) { return (y < other.y || (y == other.y && x < other.x)); };

    void setNextShip(Ship* nextShip) { this->nextShip = nextShip; };
    Ship* getNextShip() { return nextShip; };

    int getX() const { return x; };
    int getY() const { return y; };
    bool getHorizontal() const { return horizontal; };
    bool getVertical() const { return !horizontal; };
    uint8_t getShip() const { return size; };

    void setX(int x) { this->x = x; };
    void setY(int y) { this->y = y; };
    void setHorizontal(bool horizontal = true) { this->horizontal = horizontal; };
    void setVertical(bool vertical = true) { this->horizontal = !vertical; };
    void setShip(uint8_t size) { this->size = size; };

    void setShip(std::string ship);
    std::string getShipString() const;
    void printShip(std::ostream& out) const;

};

uint8_t convertToShip(std::string ship);
void deleteLinkedShips(Ship*& ship);

};

#endif // BATTLESHIP_SHIP_H
