当前位置: 首页>>代码示例>>C++>>正文


C++ player::get_str方法代码示例

本文整理汇总了C++中player::get_str方法的典型用法代码示例。如果您正苦于以下问题:C++ player::get_str方法的具体用法?C++ player::get_str怎么用?C++ player::get_str使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在player的用法示例。


在下文中一共展示了player::get_str方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: wield_check_internal

void wield_check_internal( player &dummy, item &the_item, const char *section_text,
                           const std::string &var_name, int expected_cost )
{
    dummy.weapon = dummy.ret_null;
    dummy.set_moves( 1000 );
    int old_moves = dummy.moves;
    dummy.wield( the_item );
    int move_cost = old_moves - dummy.moves;
    if( expected_cost < 0 ) {
        printf( "    wield_check( %s, dummy, %s, %d );\n", section_text, var_name.c_str(), move_cost );
    } else {
        INFO( "Strength:" << dummy.get_str() );
        int max_cost = expected_cost * 1.1f;
        int min_cost = expected_cost * 0.9f;
        CHECK( move_cost <= max_cost );
        CHECK( move_cost >= min_cost );
    }
}
开发者ID:CoderDuan,项目名称:Cataclysm-DDA,代码行数:18,代码来源:wield_times_test.cpp

示例2: place_player

void start_location::place_player( player &u ) const
{
    // Need the "real" map with it's inside/outside cache and the like.
    map &m = g->m;
    // Start us off somewhere in the center of the map
    u.setx( SEEX * int( MAPSIZE / 2 ) + 5 );
    u.sety( SEEY * int( MAPSIZE / 2 ) + 6 );
    u.setz( g->get_levz() );

    m.build_map_cache( m.get_abs_sub().z );
    const bool must_be_inside = flags().count( "ALLOW_OUTSIDE" ) == 0;
    ///\EFFECT_STR allows player to start behind less-bashable furniture and terrain
    const int bash = u.get_str(); // TODO: Allow using items here

    // Remember biggest found location
    // Sometimes it may be impossible to automatically found an ideal location
    // but the player may be more creative than this algorithm and do away with just "good"
    int best_rate = 0;
    // In which attempt did this area get checked?
    // We can overwrite earlier attempts, but not start in them
    int checked[SEEX * MAPSIZE][SEEY * MAPSIZE];
    std::fill_n( &checked[0][0], SEEX * MAPSIZE * SEEY * MAPSIZE, 0 );

    bool found_good_spot = false;
    // Try some random points at start

    int tries = 0;
    const auto check_spot = [&]( const tripoint & pt ) {
        tries++;
        const int rate = rate_location( m, pt, must_be_inside, bash, tries, checked );
        if( best_rate < rate ) {
            best_rate = rate;
            u.setpos( pt );
            if( rate == INT_MAX ) {
                found_good_spot = true;
            }
        }
    };

    while( !found_good_spot && tries < 100 ) {
        tripoint rand_point( ( SEEX * int( MAPSIZE / 2 ) ) + rng( 0, SEEX * 2 ),
                             ( SEEY * int( MAPSIZE / 2 ) ) + rng( 0, SEEY * 2 ),
                             u.posz() );
        check_spot( rand_point );
    }
    // If we haven't got a good location by now, screw it and brute force it
    // This only happens in exotic locations (deep of a science lab), but it does happen
    if( !found_good_spot ) {
        tripoint tmp = u.pos();
        int &x = tmp.x;
        int &y = tmp.y;
        for( x = 0; x < SEEX * MAPSIZE; x++ ) {
            for( y = 0; y < SEEY * MAPSIZE; y++ ) {
                check_spot( tmp );
            }
        }
    }

    if( !found_good_spot ) {
        debugmsg( "Could not find a good starting place for character" );
    }
}
开发者ID:nonymous,项目名称:Cataclysm-DDA,代码行数:62,代码来源:start_location.cpp


注:本文中的player::get_str方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。