Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove table buff/debuff for medicine #39598

Merged
merged 1 commit into from
Apr 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/consumption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1102,7 +1102,8 @@ void Character::modify_morale( item &food, const int nutr )

// Morale bonus for eating unspoiled food with chair/table nearby
// Does not apply to non-ingested consumables like bandages or drugs
if( !food.rotten() && !food.has_flag( flag_ALLERGEN_JUNK ) && !food.has_flag( "NO_INGEST" ) ) {
if( !food.rotten() && !food.has_flag( flag_ALLERGEN_JUNK ) && !food.has_flag( "NO_INGEST" ) &&
food.get_comestible()->comesttype != "MED" ) {
if( g->m.has_nearby_chair( pos(), 1 ) && g->m.has_nearby_table( pos(), 1 ) ) {
if( has_trait( trait_TABLEMANNERS ) ) {
rem_morale( MORALE_ATE_WITHOUT_TABLE );
Expand Down
73 changes: 46 additions & 27 deletions tests/modify_morale_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,24 @@ TEST_CASE( "dining with table and chair", "[food][modify_morale][table][chair]"
REQUIRE( bread.is_fresh() );
REQUIRE_FALSE( bread.has_flag( flag_ALLERGEN_JUNK ) );

// Table/chair morale effects should not apply to non-ingestibles
item bandage( "bandages" );
item cig( "cig" );
REQUIRE( bandage.has_flag( "NO_INGEST" ) );
REQUIRE( cig.has_flag( "NO_INGEST" ) );
// Much of the below code is to support the "Rigid Table Manners" trait, notoriously prone to
// causing unexpected morale effects from bandages, aspirin, cigs etc. (#38698, #39580)
// Table-related morale effects should not apply to any of the following items:
const std::vector<std::string> no_table_eating_bonus = {
{
"aspirin",
"bandages",
"caffeine",
"cig",
"codeine",
"crack",
"dayquil",
"disinfectant",
"joint",
"oxycodone",
"weed"
}
};

GIVEN( "no table or chair are nearby" ) {
REQUIRE_FALSE( g->m.has_nearby_table( dummy.pos(), 1 ) );
Expand All @@ -111,23 +124,20 @@ TEST_CASE( "dining with table and chair", "[food][modify_morale][table][chair]"
dummy.toggle_trait( trait_TABLEMANNERS );
REQUIRE( dummy.has_trait( trait_TABLEMANNERS ) );

THEN( "they get a morale penalty for eating without a table" ) {
THEN( "they get a morale penalty for eating food without a table" ) {
dummy.clear_morale();
dummy.modify_morale( bread );
CHECK( dummy.has_morale( MORALE_ATE_WITHOUT_TABLE ) <= -2 );
}

THEN( "they do not get a morale penalty for applying a bandage without a table" ) {
// Regression test for #38698
dummy.clear_morale();
dummy.modify_morale( bandage );
CHECK_FALSE( dummy.has_morale( MORALE_ATE_WITHOUT_TABLE ) );
}
for( std::string item_name : no_table_eating_bonus ) {
item test_item( item_name );

THEN( "they do not get a morale penalty for smoking a cigarette without a table" ) {
dummy.clear_morale();
dummy.modify_morale( cig );
CHECK_FALSE( dummy.has_morale( MORALE_ATE_WITHOUT_TABLE ) );
THEN( "they get no morale penalty for using " + item_name + " at a table" ) {
dummy.clear_morale();
dummy.modify_morale( test_item );
CHECK_FALSE( dummy.has_morale( MORALE_ATE_WITHOUT_TABLE ) );
}
}
}
}
Expand All @@ -146,6 +156,16 @@ TEST_CASE( "dining with table and chair", "[food][modify_morale][table][chair]"
dummy.modify_morale( bread );
CHECK( dummy.has_morale( MORALE_ATE_WITH_TABLE ) >= 1 );
}

for( std::string item_name : no_table_eating_bonus ) {
item test_item( item_name );

THEN( "they get no morale bonus for using " + item_name + " at a table" ) {
dummy.clear_morale();
dummy.modify_morale( test_item );
CHECK_FALSE( dummy.has_morale( MORALE_ATE_WITH_TABLE ) );
}
}
}

AND_GIVEN( "character has strict table manners" ) {
Expand All @@ -158,17 +178,14 @@ TEST_CASE( "dining with table and chair", "[food][modify_morale][table][chair]"
CHECK( dummy.has_morale( MORALE_ATE_WITH_TABLE ) >= 3 );
}

THEN( "they do not get a morale bonus for applying a bandage with a table" ) {
// Regression test for #38698
dummy.clear_morale();
dummy.modify_morale( bandage );
CHECK_FALSE( dummy.has_morale( MORALE_ATE_WITH_TABLE ) );
}
for( std::string item_name : no_table_eating_bonus ) {
item test_item( item_name );

THEN( "they do not get a morale bonus for smoking a cigarette with a table" ) {
dummy.clear_morale();
dummy.modify_morale( cig );
CHECK_FALSE( dummy.has_morale( MORALE_ATE_WITH_TABLE ) );
THEN( "they get no morale bonus for using " + item_name + " at a table" ) {
dummy.clear_morale();
dummy.modify_morale( test_item );
CHECK_FALSE( dummy.has_morale( MORALE_ATE_WITH_TABLE ) );
}
}
}
}
Expand Down Expand Up @@ -205,12 +222,14 @@ TEST_CASE( "eating hot food", "[food][modify_morale][hot]" )
}
}


TEST_CASE( "drugs", "[food][modify_morale][drug]" )
{
avatar dummy;
std::pair<int, int> fun;

std::vector<std::string> drugs_to_test = {

const std::vector<std::string> drugs_to_test = {
{
"gum",
"caff_gum",
Expand Down