//
// Created by Dan Crosby on 4/16/22.
//

#include "BattalionTypeRegistrar.hpp"

#include "src/main/cpp/net/eagle0/common/FilesystemUtils.hpp"
#include "src/main/cpp/net/eagle0/common/TsvParser.hpp"
#include "src/main/cpp/net/eagle0/shardok/library/BattalionType.hpp"

namespace shardok {
void BattalionTypeRegistrar::RegisterBattalionTypes(SettingsSetter& setter) {
    const string battalionTypesPath =
            FilesystemUtils::StaticShardokFilesDirectory() + "battalionTypes.tsv";
    TsvParser parser;
    const string tsv = string(byte_vector::FromPath(battalionTypesPath));
    const auto battalionMaps = parser.ParseColumnEntryTsv(tsv);
    for (const std::unordered_map<string, string>& map : battalionMaps) {
        setter.RegisterBattalionType(BattalionType::NewBattalionTypeFromMap(map));
    }
}
}  // namespace shardok
