本文整理汇总了C++中player::can_consume方法的典型用法代码示例。如果您正苦于以下问题:C++ player::can_consume方法的具体用法?C++ player::can_consume怎么用?C++ player::can_consume使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类player
的用法示例。
在下文中一共展示了player::can_consume方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_consumable_ammo
void test_consumable_ammo( player &p, std::string &itemname, bool when_empty, bool when_full )
{
item it = item( itemname, 0, 0 ) ;
it.ammo_unset();
INFO( "consume \'" + it.tname() + "\' with " + std::to_string( it.ammo_remaining() ) + " charges" );
REQUIRE( p.can_consume( it ) == when_empty );
it.ammo_set( it.ammo_type()->default_ammotype(), -1 ); // -1 -> full
INFO( "consume \'" + it.tname() + "\' with " + std::to_string( it.ammo_remaining() ) + " charges" );
REQUIRE( p.can_consume( it ) == when_full );
}
示例2: test_consumable_charges
void test_consumable_charges( player &p, std::string &itemname, bool when_none, bool when_max )
{
item it = item( itemname, 0, 0 ) ;
INFO( "\'" + it.tname() + "\' is count-by-charges" );
CHECK( it.count_by_charges() );
it.charges = 0;
INFO( "consume \'" + it.tname() + "\' with " + std::to_string( it.charges ) + " charges" );
REQUIRE( p.can_consume( it ) == when_none );
it.charges = LONG_MAX;
INFO( "consume \'" + it.tname() + "\' with " + std::to_string( it.charges ) + " charges" );
REQUIRE( p.can_consume( it ) == when_max );
}