//
// Created by Dan Crosby on 3/23/20.
//

#include "OddsFilter.hpp"

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

namespace shardok {

[[nodiscard]] net::eagle0::shardok::api::OddsView OddsFilteredForPlayer(
        const net::eagle0::shardok::storage::Odds &odds,
        PlayerId askingPlayer) {
    net::eagle0::shardok::api::OddsView ov;

    ov.set_base_difficulty(odds.base_difficulty());
    ov.set_terrain_factor(odds.terrain_factor());
    ov.set_weather_factor(odds.weather_factor());
    ov.set_wind_factor(odds.wind_factor());
    ov.set_stat_factor(odds.stat_factor());

    for (const auto &of : odds.other_factors()) {
        const auto api_of = ov.add_other_factors();
        api_of->set_identifier(of.identifier());
        api_of->set_value(of.value());
    }

    ov.set_success_chance(GetSuccessChance(odds));

    return ov;
}

}  // namespace shardok