//
// Created by Dan Crosby on 4/14/21.
//

#ifndef EAGLE0_SHARDOK_LIBRARY_UTIL_HEX_CUBE_UTILS_HPP
#define EAGLE0_SHARDOK_LIBRARY_UTIL_HEX_CUBE_UTILS_HPP

#include <vector>

#include "src/main/cpp/net/eagle0/shardok/library/map/Coordinates.hpp"

namespace shardok {

struct Cube {
    int16_t x;
    int16_t y;
    int16_t z;

    Cube() : x(0), y(0), z(0) {}
    Cube(const int16_t x, const int16_t y, const int16_t z) : x(x), y(y), z(z) {}
};

[[nodiscard]] auto OffsetToCube(const Coords &c) -> Cube;

[[nodiscard]] auto CubeToOffset(const Cube &cube) -> Coords;

[[nodiscard]] static inline auto CubeDistance(const Cube &c1, const Cube &c2) -> int {
    return (abs(c1.x - c2.x) + abs(c1.y - c2.y) + abs(c1.z - c2.z)) / 2;
}

[[nodiscard]] auto CubesWithinDistance(const Cube &c1, int distance) -> std::vector<Cube>;
[[nodiscard]] auto CubesWithExactDistance(const Cube &c1, int distance) -> std::vector<Cube>;

// Returns all the hexes that are on the line between c1 and c2, including the endpoints.
// In a case where the line passes exactly between two hexes, includes BOTH hexes.
[[nodiscard]] auto CubeLineInclusive(const Cube &c1, const Cube &c2) -> std::vector<Cube>;

}  // namespace shardok

#endif  // EAGLE0_SHARDOK_LIBRARY_UTIL_HEX_CUBE_UTILS_HPP
