src/main.cpp
/** Print @p assign in a human readable way
 * 
 * @param output Output stream
 * @param assign Assignment of recipes to equipment slots
 */
Print @p assign in a human readable way

@param output Output stream
@param assign Assignment of recipes to equipment slots
Print @p assign in a human readable way @param output Output stream @param assign Assignment of recipes to equipment slots
void print_assignment(std::ostream& output, const recap::assignment& assign)
{
    using namespace recap;
    constexpr int width = 13;
    constexpr int col_count = 6;
    auto print_cell = [&output]() -> std::ostream&
    {
        output << std::left << std::setw(width) << std::setfill(' ');
        return output;
    };
    auto print_sep = [&output]()
    {
        for (std::size_t i = 0; i < width * col_count; ++i)
        {
            output << "-";
        }
        output << std::endl;
    };
    if (assign.cost() >= recipe::MAX_COST)
    {
        output << "No solution." << std::endl;
    }
    else 
    {
        output << "Found solution with cost " << assign.cost() << ": " << std::endl;
        print_sep();
        output << rang::style::bold;
        print_cell() <<  "slot";
        print_cell() << "fire%";
        print_cell() << "cold%";
        print_cell() << "lightning%";
        print_cell() << "chaos%";
        print_cell() << "cost";
        output << rang::style::reset;
        output << std::endl;
        print_sep();
        resistance total = resistance::make_zero(); 
        recipe::cost_t total_cost = 0;
        for (std::size_t i = 0; i < assign.assignments().size(); ++i)
        {
            const auto& recipe = assign.assignments()[i].used_recipe();
            auto slot = assign.assignments()[i].slot();
            print_cell() << to_string(slot);
            print_cell() << recipe.resistances().fire();
            print_cell() << recipe.resistances().cold();
            print_cell() << recipe.resistances().lightning();
            print_cell() << recipe.resistances().chaos();
            print_cell() << recipe.cost();
            output << std::endl;
            total = total + recipe.resistances();
            total_cost += recipe.cost();
        }
        print_sep();
        print_cell() << "";
        print_cell() << total.fire();
        print_cell() << total.cold();
        print_cell() << total.lightning();
        print_cell() << total.chaos();
        print_cell() << total_cost;
        output << std::endl << std::endl;
    }
}
void print_assignment ( std :: ostream & output , const recap :: assignment & assign ) { using namespace recap ; constexpr int width = 13 ; constexpr int col_count = 6 ; auto print_cell = [ & output ] ( ) -> std :: ostream & { output << std :: left << std :: setw ( width ) << std :: setfill ( ' ' ) ; return output ; } ; auto print_sep = [ & output ] ( ) { for ( std :: size_t i = 0 ; i < width * col_count ; ++ i ) { output << " " ; } output << std :: endl ; } ; if ( assign . cost ( ) >= recipe :: MAX_COST ) { output << " " << std :: endl ; } else { output << " " << assign . cost ( ) << " " << std :: endl ; print_sep ( ) ; output << rang :: style :: bold ; print_cell ( ) << " " ; print_cell ( ) << " " ; print_cell ( ) << " " ; print_cell ( ) << " " ; print_cell ( ) << " " ; print_cell ( ) << " " ; output << rang :: style :: reset ; output << std :: endl ; print_sep ( ) ; resistance total = resistance :: make_zero ( ) ; recipe :: cost_t total_cost = 0 ; for ( std :: size_t i = 0 ; i < assign . assignments ( ) . size ( ) ; ++ i ) { const auto & recipe = assign . assignments ( ) [ i ] . used_recipe ( ) ; auto slot = assign . assignments ( ) [ i ] . slot ( ) ; print_cell ( ) << to_string ( slot ) ; print_cell ( ) << recipe . resistances ( ) . fire ( ) ; print_cell ( ) << recipe . resistances ( ) . cold ( ) ; print_cell ( ) << recipe . resistances ( ) . lightning ( ) ; print_cell ( ) << recipe . resistances ( ) . chaos ( ) ; print_cell ( ) << recipe . cost ( ) ; output << std :: endl ; total = total + recipe . resistances ( ) ; total_cost += recipe . cost ( ) ; } print_sep ( ) ; print_cell ( ) << " " ; print_cell ( ) << total . fire ( ) ; print_cell ( ) << total . cold ( ) ; print_cell ( ) << total . lightning ( ) ; print_cell ( ) << total . chaos ( ) ; print_cell ( ) << total_cost ; output << std :: endl << std :: endl ; } }
Print @p assign in a human readable way
Print @p assign in a human readable way
// print table cell // print line separator