//
// Created by Dan Crosby on 4/7/24.
//

#ifndef HEXMAPHASHER_HPP
#define HEXMAPHASHER_HPP

#include "src/main/flatbuffer/net/eagle0/shardok/storage/hex_map.hpp"

// Uses Dijkstra's algorithm to calculate the distance from a tile to all other tiles
// for a particular battalion type.

namespace shardok {
using HexMap = net::eagle0::shardok::storage::fb::HexMap;

auto GetModifierHash(const HexMap* map) -> uint64_t;

// Helper function to compute modifier byte for consistent hashing
// Excludes ice from hash since AI pathfinding should ignore ice
// Compact bit layout: bridge=bit0, fire=bit1, snow=bit2
template<typename TileModifier>
auto ComputeModifierByte(const TileModifier& modifier) -> int8_t {
    return static_cast<int8_t>(
            modifier.bridge().present() | modifier.fire().present() << 1 |
            modifier.snow().present() << 2);
}

// Overload for protobuf modifier
template<typename ProtoModifier>
auto ComputeModifierByteProto(const ProtoModifier& modifier) -> int8_t {
    return static_cast<int8_t>(
            modifier.has_bridge() | modifier.has_fire() << 1 | modifier.has_snow() << 2);
}

}  // namespace shardok

#endif  // HEXMAPHASHER_HPP
