//
// Created by Dan Crosby on 10/13/22.
//

#ifndef EAGLE0_FIXEDACTIONPOINTDISTANCES_HPP
#define EAGLE0_FIXEDACTIONPOINTDISTANCES_HPP

#include <utility>
#include <vector>

#include "src/main/cpp/net/eagle0/shardok/library/BattalionType.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/action_point_distances/ActionPointDistances.hpp"

namespace shardok {

using std::vector;
using BattalionTypeSPtr = std::shared_ptr<const BattalionType>;

class FixedActionPointDistances final : public ActionPointDistances {
private:
    vector<vector<DIST_T>> distances;

    // Private constructor - use Create factory method instead
    explicit FixedActionPointDistances(const HexMap *map, int columnCount);

public:
    // Factory method to create FixedActionPointDistances
    static auto Create(
            const HexMap *map,
            const BattalionTypeSPtr &battalionType,
            bool includeBravingWater,
            int braveWaterActionPointCost = -1) -> std::shared_ptr<FixedActionPointDistances>;

    ~FixedActionPointDistances() override = default;

    [[nodiscard]] auto Distance(const int fromIndex, const int toIndex) const -> DIST_T override {
        return distances[fromIndex][toIndex];
    }

    [[nodiscard]] auto Distance(const Coords &from, const Coords &to) const -> DIST_T override {
        return Distance(ToIndex(from), ToIndex(to));
    }
};

}  // namespace shardok

#endif  // EAGLE0_FIXEDACTIONPOINTDISTANCES_HPP
