本文整理汇总了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;
}
示例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 );
}
}
}
}
示例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;
}
}