未验证 提交 d892fd8f 编写于 作者: E Eric Pierce 提交者: GitHub

Fix non-rigid info display for non-armor (#54418)

When a container is non-rigid, and is also not wearable as
clothing/armor, show its non-rigidity in the iteminfo panel.

Include test case and test condom. Co-authored by @dseguin
上级 3a0641e5
......@@ -1288,6 +1288,31 @@
],
"properties": [ [ "burst_when_filled", "75" ] ]
},
{
"id": "test_condom",
"type": "GENERIC",
"category": "container",
"name": { "str": "test condom" },
"description": "This condom is only for testing, and should not be used as a birth control device.",
"weight": "5 g",
"volume": "15 ml",
"price": 0,
"price_postapoc": 25,
"to_hit": -5,
"material": [ "plastic" ],
"symbol": ")",
"color": "white",
"pocket_data": [
{
"pocket_type": "CONTAINER",
"watertight": true,
"max_contains_volume": "3750 ml",
"max_contains_weight": "7 kg",
"max_item_length": "26 cm"
}
],
"properties": [ [ "burst_when_filled", "75" ] ]
},
{
"id": "test_can_drink",
"type": "GENERIC",
......
......@@ -4819,6 +4819,7 @@ void item::final_info( std::vector<iteminfo> &info, const iteminfo_query *parts,
insert_separation_line( info );
if( parts->test( iteminfo_parts::BASE_RIGIDITY ) ) {
bool not_rigid = false;
if( const islot_armor *t = find_armor_data() ) {
bool any_encumb_increase = std::any_of( t->data.begin(), t->data.end(),
[]( const armor_portion_data & data ) {
......@@ -4828,12 +4829,14 @@ void item::final_info( std::vector<iteminfo> &info, const iteminfo_query *parts,
info.emplace_back( "BASE",
_( "* This item is <info>not rigid</info>. Its"
" volume and encumbrance increase with contents." ) );
} else if( !contents.all_pockets_rigid() ) {
info.emplace_back( "BASE",
_( "* This item is <info>not rigid</info>. Its"
" volume increases with contents." ) );
not_rigid = true;
}
}
if( !not_rigid && !all_pockets_rigid() ) {
info.emplace_back( "BASE",
_( "* This item is <info>not rigid</info>. Its"
" volume increases with contents." ) );
}
}
if( parts->test( iteminfo_parts::DESCRIPTION_CONDUCTIVITY ) ) {
......
......@@ -422,11 +422,13 @@ TEST_CASE( "item rigidity", "[iteminfo][rigidity]" )
item waterskin( "test_waterskin" );
item backpack( "test_backpack" );
item quiver( "test_quiver" );
item condom( "test_condom" );
SECTION( "rigidity indicator" ) {
REQUIRE_FALSE( waterskin.all_pockets_rigid() );
REQUIRE_FALSE( backpack.all_pockets_rigid() );
REQUIRE_FALSE( quiver.all_pockets_rigid() );
REQUIRE_FALSE( condom.all_pockets_rigid() );
CHECK( item_info_str( waterskin, rigidity ) ==
"--\n"
......@@ -442,6 +444,12 @@ TEST_CASE( "item rigidity", "[iteminfo][rigidity]" )
"--\n"
"* This item is <color_c_cyan>not rigid</color>."
" Its volume and encumbrance increase with contents.\n" );
// Non-armor item - volume increases, but not encumbrance
CHECK( item_info_str( condom, rigidity ) ==
"--\n"
"* This item is <color_c_cyan>not rigid</color>."
" Its volume increases with contents.\n" );
}
SECTION( "encumbrance when empty and full" ) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册