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


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

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


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

示例1: if

std::list<act_item> convert_to_items( const player &p, const drop_indexes &drop,
                                      int min_pos, int max_pos )
{
    std::list<act_item> res;

    for( const auto &rec : drop ) {
        const auto pos = rec.first;
        const auto count = rec.second;

        if( pos < min_pos || pos > max_pos ) {
            continue;
        } else if( pos >= 0 ) {
            int obtained = 0;
            for( const auto &it : p.inv.const_stack( pos ) ) {
                if( obtained >= count ) {
                    break;
                }
                const int qty = it.count_by_charges() ? std::min<int>( it.charges, count - obtained ) : 1;
                obtained += qty;
                res.emplace_back( &it, qty, 100 ); // TODO: Use a calculated cost
            }
        } else {
            res.emplace_back( &p.i_at( pos ), count, ( pos == -1 ) ? 0 : 100 ); // TODO: Use a calculated cost
        }
    }

    return res;
}
开发者ID:CleverRaven,项目名称:Cataclysm-DDA,代码行数:28,代码来源:activity_item_handling.cpp

示例2: remove_dropping_items

void inventory_drop_selector::remove_dropping_items( player &dummy ) const
{
    std::map<item *, int> dummy_dropping;

    for( const auto &elem : dropping ) {
        dummy_dropping[&dummy.i_at( u.get_item_position( elem.first ) )] = elem.second;
    }
    for( auto &elem : dummy_dropping ) {
        if( elem.first->count_by_charges() ) {
            elem.first->mod_charges( -elem.second );
        } else {
            const int pos = dummy.get_item_position( elem.first );
            for( int i = 0; i < elem.second; ++i ) {
                dummy.i_rem( pos );
            }
        }
    }
}
开发者ID:Nhatorama,项目名称:Cataclysm-DDA,代码行数:18,代码来源:inventory_ui.cpp

示例3: move_item

void move_item( player &p, int pos, inventory_location from, inventory_location to )
{
    switch( from ) {
        case GROUND:
            switch( to ) {
                case GROUND:
                default:
                    FAIL( "unimplemented" );
                    break;
                case INVENTORY:
                    pick_up_from_feet( p, pos );
                    break;
                case WORN:
                    wear_from_feet( p, pos );
                    break;
                case WIELDED_OR_WORN:
                    if( p.weapon.is_null() ) {
                        wield_from_feet( p, pos );
                    } else {
                        // since we can only wield one item, wear the item instead
                        wear_from_feet( p, pos );
                    }
                    break;
            }
            break;
        case INVENTORY:
            switch( to ) {
                case GROUND:
                    drop_at_feet( p, pos );
                    break;
                case INVENTORY:
                default:
                    FAIL( "unimplemented" );
                    break;
                case WORN:
                    p.wear( pos, false );
                    break;
                case WIELDED_OR_WORN:
                    if( p.weapon.is_null() ) {
                        p.wield( p.i_at( pos ) );
                    } else {
                        // since we can only wield one item, wear the item instead
                        p.wear( pos, false );
                    }
                    break;
            }
            break;
        case WORN:
            switch( to ) {
                case GROUND:
                    drop_at_feet( p, -2 - pos );
                    break;
                case INVENTORY:
                    p.takeoff( -2 - pos );
                    break;
                case WORN:
                case WIELDED_OR_WORN:
                default:
                    FAIL( "unimplemented" );
                    break;
            }
            break;
        case WIELDED_OR_WORN:
            switch( to ) {
                case GROUND:
                    drop_at_feet( p, -1 - pos );
                    if( pos == 0 && !p.worn.empty() ) {
                        // wield the first worn item
                        p.wield( p.i_at( -2 ) );
                    }
                    break;
                case INVENTORY:
                    if( pos == 0 ) {
                        p.i_add( p.i_rem( -1 ) );
                    } else {
                        p.takeoff( -1 - pos );
                    }
                    if( pos == 0 && !p.worn.empty() ) {
                        // wield the first worn item
                        p.wield( p.i_at( -2 ) );
                    }
                    break;
                case WORN:
                case WIELDED_OR_WORN:
                default:
                    FAIL( "unimplemented" );
                    break;
            }
            break;
        default:
            FAIL( "unimplemented" );
            break;
    }
}
开发者ID:BevapDin,项目名称:Cataclysm-DDA,代码行数:94,代码来源:invlet_test.cpp


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