コード例 #1
0
    bool sort_compare( const item_location &lhs, const item_location &rhs ) const override {
        const auto a = get_odds( lhs );
        const auto b = get_odds( rhs );

        if( a.first > b.first || ( a.first == b.first && a.second < b.second ) ) {
            return true;
        }

        return inventory_selector_preset::sort_compare( lhs, rhs );
    }
コード例 #2
0
        gunmod_inventory_preset( const player &p, const item &gunmod ) : p( p ), gunmod( gunmod ) {
            append_cell( [ this ]( const item_location & loc ) {
                const auto odds = get_odds( loc );

                if( odds.first >= 100 ) {
                    return string_format( "<color_light_green>%s</color>", _( "always" ) );
                }

                return string_format( "<color_light_green>%d%%</color>", odds.first );
            }, _( "SUCCESS CHANCE" ) );

            append_cell( [ this ]( const item_location & loc ) {
                return good_bad_none( get_odds( loc ).second );
            }, _( "DAMAGE RISK" ) );
        }
コード例 #3
0
    std::string get_denial( const item_location &loc ) const override {
        std::string incompatability;

        if( !loc->gunmod_compatible( gunmod, &incompatability ) ) {
            return incompatability;
        }

        if( !p.meets_requirements( gunmod, *loc ) ) {
            return string_format( _( "requires at least %s" ),
                                  p.enumerate_unmet_requirements( gunmod, *loc ).c_str() );
        }

        if( get_odds( loc ).first <= 0 ) {
            return _( "is too difficult for you to modify" );
        }

        return std::string();
    }
コード例 #4
0
        std::string get_denial( const item_location &loc ) const override {
            const auto ret = loc->is_gunmod_compatible( gunmod );

            if( !ret.success() ) {
                return ret.str();
            }

            if( !p.meets_requirements( gunmod, *loc ) ) {
                return string_format( _( "requires at least %s" ),
                                      p.enumerate_unmet_requirements( gunmod, *loc ).c_str() );
            }

            if( get_odds( loc ).first <= 0 ) {
                return _( "is too difficult for you to modify" );
            }

            return std::string();
        }