//
//  Terrain.hpp
//  eagle0
//
//  Created by Dan Crosby on 9/15/18.
//  Copyright © 2018 none. All rights reserved.
//

#ifndef EAGLE0_SHARDOK_LIBRARY_MAP_TERRAIN_HPP
#define EAGLE0_SHARDOK_LIBRARY_MAP_TERRAIN_HPP

#include <utility>

#include "src/main/cpp/net/eagle0/shardok/library/map/TileModifier.hpp"
#include "src/main/flatbuffer/net/eagle0/shardok/storage/terrain.hpp"
#include "src/main/protobuf/net/eagle0/shardok/common/terrain.pb.h"

namespace shardok {

using Terrain = net::eagle0::shardok::storage::fb::Terrain;
using TerrainProto = net::eagle0::shardok::common::Terrain;
using TerrainType = net::eagle0::shardok::common::Terrain_Type;

using TerrainType::Terrain_Type_CITY;
using TerrainType::Terrain_Type_FOREST;
using TerrainType::Terrain_Type_HILL;
using TerrainType::Terrain_Type_MOUNTAIN;
using TerrainType::Terrain_Type_NONE;
using TerrainType::Terrain_Type_PLAINS;
using TerrainType::Terrain_Type_RIVER;
using TerrainType::Terrain_Type_STILL_WATER;
using TerrainType::Terrain_Type_SWAMP;
using TerrainType::Terrain_Type_UNKNOWN;

constexpr int kTerrainTypeCount = net::eagle0::shardok::common::Terrain_Type_Type_ARRAYSIZE;

[[nodiscard]] auto AllowsHiding(const Terrain* terrain) -> bool;
[[nodiscard]] auto AllowsHiding(net::eagle0::shardok::storage::fb::Terrain_::Type type) -> bool;
[[nodiscard]] auto AllowsHiding(const net::eagle0::shardok::storage::fb::TileModifier& modifier)
        -> bool;

[[nodiscard]] auto AllowsHiding(const TerrainProto& terrain) -> bool;
[[nodiscard]] auto AllowsHiding(TerrainType type) -> bool;
[[nodiscard]] auto AllowsHiding(const TileModifierProto& modifier) -> bool;

[[nodiscard]] auto AllowsFortification(const Terrain* terrain) -> bool;

[[nodiscard]] auto IsWater(net::eagle0::shardok::storage::fb::Terrain_::Type type) -> bool;
[[nodiscard]] auto IsWater(TerrainType type) -> bool;

[[nodiscard]] auto IsTraversible(const net::eagle0::shardok::storage::fb::Terrain& terrain) -> bool;

[[nodiscard]] auto MakeHexMapTerrain(TerrainType tp, TileModifierProto mod = TileModifierProto())
        -> TerrainProto;
[[nodiscard]] auto MakeHexMapTerrain(
        net::eagle0::shardok::storage::fb::Terrain_::Type tp,
        const net::eagle0::shardok::storage::fb::TileModifier& mod =
                net::eagle0::shardok::storage::fb::TileModifier()) -> Terrain;

}  // namespace shardok

#endif  // EAGLE0_SHARDOK_LIBRARY_MAP_TERRAIN_HPP
