Skip to content

Commit

Permalink
Apply suggestion
Browse files Browse the repository at this point in the history
Co-authored-by: andrei <[email protected]>
  • Loading branch information
b3brodie and andrei8l authored Dec 14, 2024
1 parent 1931328 commit 2f97b7d
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/math_parser_diag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1114,19 +1114,13 @@ diag_eval_dbl_f spell_exp_for_level_eval( char /* scope */,
std::vector<diag_value> const &params, diag_kwargs const &/* kwargs */ )
{
return[sid = params[0], level = params[1]]( const_dialogue const & d ) -> double {
std::vector<spell_type> all_spells = spell_type::get_all();
auto it = std::find_if( all_spells.begin(), all_spells.end(), [&sid, &d]( const spell_type & obj )
{
return obj.id.c_str() == sid.str( d );
} );
if( it != all_spells.end() )
{
return it->exp_for_level( level.dbl( d ) );
} else
{
throw math::runtime_error( R"(Unknown spell id "%s" for spell_exp_for_level)", sid.str( d ) );
return -1;
std::string sid_str = sid.str( d );
spell_id spell( sid_str );
if( spell.is_valid() ) {
return spell->exp_for_level( level.dbl( d ) );
}

throw math::runtime_error( R"(Unknown spell id "%s" for spell_exp_for_level)", sid_str );
};
}

Expand Down

0 comments on commit 2f97b7d

Please sign in to comment.