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 ); }
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 ); }