//
//  AmbushOdds.cpp
//  eagle0
//
//  Created by Dan Crosby on 8/11/18.
//  Copyright © 2018 none. All rights reserved.
//

#include "src/main/cpp/net/eagle0/shardok/library/command_factories/ambush_odds/AmbushOdds.hpp"

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

namespace shardok {

static inline auto StealthTerrainModifier(const Terrain& terrain, const SettingsGetter& settings)
        -> int {
    switch (terrain.type()) {
        case net::eagle0::shardok::storage::fb::Terrain_::Type_FOREST:
            return settings.Backing().stealth_forest_modifier();
        case net::eagle0::shardok::storage::fb::Terrain_::Type_SWAMP:
            return settings.Backing().stealth_swamp_modifier();

        case net::eagle0::shardok::storage::fb::Terrain_::Type_STILL_WATER:
        case net::eagle0::shardok::storage::fb::Terrain_::Type_RIVER:
            return settings.Backing().stealth_water_modifier();

        default: return 0;
    }
}

auto AmbushOdds::GetAmbushOdds(
        const SettingsGetter& settings,
        const Terrain& targetTerrain,
        double agility,
        double intelligence) -> PercentileRollOdds {
    return MakeOdds(
            settings.Backing().ambush_base_odds(),
            StealthTerrainModifier(targetTerrain, settings),
            0 /* weather */,
            0 /* wind */,
            {agility, agility, intelligence});
}

}  // namespace shardok
