long visitable<Character>::charges_of( const std::string &what, int limit ) const { auto self = static_cast<const Character *>( this ); auto p = dynamic_cast<const player *>( self ); if( what == "toolset") { if( p && p->has_active_bionic( "bio_tools" ) ) { return std::min( p->power_level, limit ); } else { return 0; } } if( what == "UPS" ) { long qty = 0; qty += charges_of( "UPS_off" ); qty += charges_of( "adv_UPS_off" ) / 0.6; if ( p && p->has_active_bionic( "bio_ups" ) ) { qty += p->power_level * 10; } return std::min( qty, long( limit ) ); } return charges_of_internal( *this, what, limit ); }
long visitable<inventory>::charges_of( const std::string &what, int limit ) const { const auto &binned = static_cast<const inventory *>( this )->get_binned_items(); const auto iter = binned.find( what ); if( iter == binned.end() ) { return 0; } long res = 0; for( const item *it : iter->second ) { res += charges_of_internal( *it, what, limit ); if( res >= limit ) { break; } } return std::min<long>( limit, res ); }
long visitable<T>::charges_of( const std::string &what, int limit ) const { return charges_of_internal( *this, what, limit ); }