static void check_consistency( const std::vector<trait_id> &mvec, const trait_id &mid, const std::string &what ) { for( const auto &m : mvec ) { if( !m.is_valid() ) { debugmsg( "mutation %s refers to undefined %s %s", mid.c_str(), what.c_str(), m.c_str() ); } } }
void debug_menu::wishmutate( player *p ) { uimenu wmenu; int c = 0; for( auto &traits_iter : mutation_branch::get_all() ) { wmenu.addentry( -1, true, -2, "%s", traits_iter.second.name.c_str() ); wmenu.entries[ c ].extratxt.left = 1; wmenu.entries[ c ].extratxt.txt = ""; wmenu.entries[ c ].extratxt.color = c_ltgreen; if( p->has_trait( traits_iter.first ) ) { wmenu.entries[ c ].text_color = c_green; if( p->has_base_trait( traits_iter.first ) ) { wmenu.entries[ c ].extratxt.txt = "T"; } } c++; } wmenu.w_x = 0; wmenu.w_width = TERMX; // disabled due to foldstring crash // ( TERMX - getmaxx(w_terrain) - 30 > 24 ? getmaxx(w_terrain) : TERMX ); wmenu.pad_right = ( wmenu.w_width - 40 ); wmenu.return_invalid = true; wmenu.selected = uistate.wishmutate_selected; wish_mutate_callback cb; cb.p = p; wmenu.callback = &cb; do { wmenu.query(); if( wmenu.ret >= 0 ) { int rc = 0; const trait_id mstr = cb.vTraits[ wmenu.ret ]; const auto &mdata = mstr.obj(); bool threshold = mdata.threshold; bool profession = mdata.profession; //Manual override for the threshold-gaining if( threshold || profession ) { if( p->has_trait( mstr ) ) { do { p->remove_mutation( mstr ); rc++; } while( p->has_trait( mstr ) && rc < 10 ); } else { do { p->set_mutation( mstr ); rc++; } while( !p->has_trait( mstr ) && rc < 10 ); } } else if( p->has_trait( mstr ) ) { do { p->remove_mutation( mstr ); rc++; } while( p->has_trait( mstr ) && rc < 10 ); } else { do { p->mutate_towards( mstr ); rc++; } while( !p->has_trait( mstr ) && rc < 10 ); } cb.msg = string_format( _( "%s Mutation changes: %d" ), mstr.c_str(), rc ); uistate.wishmutate_selected = wmenu.ret; if( rc != 0 ) { for( size_t i = 0; i < cb.vTraits.size(); i++ ) { wmenu.entries[ i ].extratxt.txt = ""; if( p->has_trait( cb.vTraits[ i ] ) ) { wmenu.entries[ i ].text_color = c_green; cb.pTraits[ cb.vTraits[ i ] ] = true; if( p->has_base_trait( cb.vTraits[ i ] ) ) { wmenu.entries[ i ].extratxt.txt = "T"; } } else { wmenu.entries[ i ].text_color = wmenu.text_color; cb.pTraits[ cb.vTraits[ i ] ] = false; } } } } } while( wmenu.keypress != 'q' && wmenu.keypress != KEY_ESCAPE && wmenu.keypress != ' ' ); }