Skip to content

Commit

Permalink
fix(balance): changes in perishables (#4357)
Browse files Browse the repository at this point in the history
* fix(balance): changes in perishables

* test change

* another test.

* style(autofix.ci): automated formatting

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
  • Loading branch information
Lamandus and autofix-ci[bot] authored Mar 15, 2024
1 parent 508ea38 commit 18d7d65
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 51 deletions.
2 changes: 1 addition & 1 deletion data/json/items/comestibles/bread.json
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@
"name": "wastebread",
"weight": "60 g",
"color": "white",
"spoils_in": 990,
"spoils_in": "30 days",
"comestible_type": "FOOD",
"symbol": "%",
"quench": -3,
Expand Down
4 changes: 2 additions & 2 deletions data/json/items/comestibles/drink.json
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@
"name": "cranberry juice",
"weight": "250 g",
"color": "magenta",
"spoils_in": "20 d",
"spoils_in": "20 days",
"container": "bottle_plastic",
"comestible_type": "DRINK",
"symbol": "~",
Expand Down Expand Up @@ -663,7 +663,7 @@
"name": { "str_sp": "milk" },
"weight": "258 g",
"color": "white",
"spoils_in": "1 d",
"spoils_in": "1 day",
"container": "jug_plastic",
"comestible_type": "DRINK",
"symbol": "~",
Expand Down
5 changes: 2 additions & 3 deletions data/json/items/comestibles/drink_other.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"comestible_type": "DRINK",
"container": "condiment_bottle_unsealed",
"calories": 21,
"spoils_in": 600,
"spoils_in": "15 days",
"charges": 16,
"fun": -1,
"phase": "liquid"
Expand All @@ -102,7 +102,7 @@
"container": "condiment_bottle_unsealed",
"fun": -1,
"calories": 10,
"spoils_in": 600,
"spoils_in": "15 days",
"charges": 48,
"phase": "liquid",
"vitamins": [ [ "iron", 2 ] ]
Expand Down Expand Up @@ -134,7 +134,6 @@
"type": "COMESTIBLE",
"symbol": "~",
"color": "brown",
"spoils_in": "180 days",
"name": "peanut butter",
"description": "A brown goo that tastes very little like its namesake. It's not bad, but it'll stick to the roof of your mouth.",
"price": "195 cent",
Expand Down
2 changes: 0 additions & 2 deletions data/json/items/comestibles/junkfood.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"name": "toast-em",
"weight": "50 g",
"color": "red",
"spoils_in": "90 days",
"container": "box_small",
"comestible_type": "FOOD",
"symbol": "%",
Expand Down Expand Up @@ -228,7 +227,6 @@
"name": { "str_sp": "s'mores" },
"weight": "180 g",
"color": "brown",
"spoils_in": "90 days",
"container": "bag_plastic",
"comestible_type": "FOOD",
"symbol": "%",
Expand Down
3 changes: 0 additions & 3 deletions data/json/items/comestibles/nuts.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@
"looks_like": "granola",
"weight": "30 g",
"color": "brown",
"spoils_in": "300 days",
"comestible_type": "FOOD",
"symbol": "%",
"calories": 184,
Expand Down Expand Up @@ -318,7 +317,6 @@
"name": { "str_sp": "roasted edamame" },
"weight": "30 g",
"color": "brown",
"spoils_in": "240 days",
"comestible_type": "FOOD",
"symbol": "%",
"healthy": 2,
Expand All @@ -340,7 +338,6 @@
"name": { "str_sp": "roasted soy nuts" },
"weight": "30 g",
"color": "brown",
"spoils_in": "240 days",
"comestible_type": "FOOD",
"symbol": "%",
"healthy": 2,
Expand Down
2 changes: 0 additions & 2 deletions data/json/items/comestibles/other.json
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,6 @@
"symbol": ".",
"color": "yellow",
"healthy": -5,
"spoils_in": "364 days",
"calories": 56,
"description": "Light brown beans, they have many uses, mildly toxic and not recommended, but you could eat them raw.",
"price": "90 cent",
Expand Down Expand Up @@ -590,7 +589,6 @@
"vitamins": [ [ "vitA", 20 ], [ "vitC", 45 ], [ "calcium", 5 ], [ "iron", 5 ] ],
"fun": 5,
"color": "brown",
"spoils_in": "730 days",
"flags": [ "INEDIBLE", "CATTLE" ],
"use_action": "CATTLEFODDER"
},
Expand Down
8 changes: 3 additions & 5 deletions data/json/items/comestibles/raw_fruit.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"name": { "str_sp": "cacao pod" },
"weight": "508 g",
"color": "yellow_yellow",
"spoils_in": "360 days",
"comestible_type": "FOOD",
"symbol": "%",
"quench": 2,
Expand Down Expand Up @@ -160,7 +159,7 @@
"name": { "str_sp": "cranberries" },
"weight": "116 g",
"color": "red",
"spoils_in": 640,
"spoils_in": "12 days",
"comestible_type": "FOOD",
"symbol": "%",
"quench": 2,
Expand Down Expand Up @@ -336,7 +335,7 @@
"name": "grapefruit",
"weight": "246 g",
"color": "yellow",
"spoils_in": 336,
"spoils_in": "5 days",
"comestible_type": "FOOD",
"symbol": "%",
"quench": 18,
Expand Down Expand Up @@ -448,7 +447,6 @@
"name": "coconut",
"weight": "84 g",
"color": "brown",
"spoils_in": "360 days",
"comestible_type": "FOOD",
"symbol": "%",
"quench": 2,
Expand Down Expand Up @@ -587,7 +585,7 @@
"name": "pomegranate",
"weight": "184 g",
"color": "red",
"spoils_in": 336,
"spoils_in": "5 days",
"comestible_type": "FOOD",
"symbol": "%",
"quench": 12,
Expand Down
1 change: 0 additions & 1 deletion data/json/items/comestibles/raw_veggy.json
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,6 @@
"name": "sugar beet",
"weight": "143 g",
"color": "brown",
"spoils_in": "95 days",
"comestible_type": "FOOD",
"symbol": "%",
"calories": 62,
Expand Down
3 changes: 1 addition & 2 deletions data/json/items/comestibles/veggy_dishes.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"name": { "str_sp": "roasted garlic" },
"weight": "18 g",
"color": "white",
"spoils_in": "180 days",
"comestible_type": "FOOD",
"symbol": "%",
"quench": -1,
Expand Down Expand Up @@ -513,7 +512,7 @@
"name": { "str_sp": "pesto" },
"weight": "65 g",
"color": "light_green",
"spoils_in": 144,
"spoils_in": "3 days",
"container": "jar_glass_sealed",
"comestible_type": "FOOD",
"symbol": "%",
Expand Down
2 changes: 1 addition & 1 deletion data/json/items/comestibles/wheat.json
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@
"color": "brown",
"calories": 278,
"fun": 4,
"spoils_in": 420,
"spoils_in": "14 days",
"vitamins": [ [ "vitA", 8 ], [ "calcium", 2 ], [ "iron", 5 ] ],
"flags": [ "EATEN_HOT" ]
},
Expand Down
31 changes: 16 additions & 15 deletions tests/char_edible_rating_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,11 @@ TEST_CASE( "what you can drink with a proboscis", "[can_eat][edible_rating][prob
}

GIVEN( "food that must be chewed" ) {
item &toastem = *item::spawn_temporary( "toastem" );
REQUIRE( toastem.get_comestible()->comesttype == "FOOD" );
item &jihelucake = *item::spawn_temporary( "jihelucake" );
REQUIRE( jihelucake.get_comestible()->comesttype == "FOOD" );

THEN( "they cannot drink it" ) {
expect_cannot_eat( dummy, toastem, expect_reason, edible_rating::inedible_mutation );
expect_cannot_eat( dummy, jihelucake, expect_reason, edible_rating::inedible_mutation );
}
}

Expand Down Expand Up @@ -314,16 +314,17 @@ TEST_CASE( "can eat with nausea", "[will_eat][edible_rating][nausea]" )
{
clear_all_state();
avatar dummy = prepare_avatar();
item &toastem = *item::spawn_temporary( "toastem" );
item &jihelucake = *item::spawn_temporary( "jihelucake" );
const efftype_id effect_nausea( "nausea" );

GIVEN( "character has nausea" ) {
dummy.add_effect( effect_nausea, 10_minutes );
REQUIRE( dummy.has_effect( effect_nausea ) );

THEN( "they can eat food, but it nauseates them" ) {
expect_can_eat( dummy, toastem );
expect_will_eat( dummy, toastem, "You still feel nauseous and will probably puke it all up again.",
expect_can_eat( dummy, jihelucake );
expect_will_eat( dummy, jihelucake,
"You still feel nauseous and will probably puke it all up again.",
edible_rating::nausea );
}
}
Expand Down Expand Up @@ -353,18 +354,18 @@ TEST_CASE( "who will eat rotten food", "[will_eat][edible_rating][rotten]" )
avatar dummy = prepare_avatar();

GIVEN( "food just barely rotten" ) {
item &toastem_rotten = *item::spawn_temporary( "toastem" );
toastem_rotten.set_relative_rot( 1.01 );
REQUIRE( toastem_rotten.rotten() );
item &jihelucake_rotten = *item::spawn_temporary( "jihelucake" );
jihelucake_rotten.set_relative_rot( 1.01 );
REQUIRE( jihelucake_rotten.rotten() );

WHEN( "character is normal" ) {
REQUIRE_FALSE( dummy.has_trait( trait_id( "SAPROPHAGE" ) ) );
REQUIRE_FALSE( dummy.has_trait( trait_id( "SAPROVORE" ) ) );

THEN( "they can eat it, though they are disgusted by it" ) {
expect_can_eat( dummy, toastem_rotten );
expect_can_eat( dummy, jihelucake_rotten );

auto conseq = dummy.will_eat( toastem_rotten, false );
auto conseq = dummy.will_eat( jihelucake_rotten, false );
CHECK( conseq.value() == edible_rating::rotten );
CHECK( conseq.str() == "This is rotten and smells awful!" );
}
Expand All @@ -375,9 +376,9 @@ TEST_CASE( "who will eat rotten food", "[will_eat][edible_rating][rotten]" )
REQUIRE( dummy.has_trait( trait_id( "SAPROVORE" ) ) );

THEN( "they can eat it, and don't mind that it is rotten" ) {
expect_can_eat( dummy, toastem_rotten );
expect_can_eat( dummy, jihelucake_rotten );

auto conseq = dummy.will_eat( toastem_rotten, false );
auto conseq = dummy.will_eat( jihelucake_rotten, false );
CHECK( conseq.value() == edible_rating::edible );
CHECK( conseq.str().empty() );
}
Expand All @@ -388,9 +389,9 @@ TEST_CASE( "who will eat rotten food", "[will_eat][edible_rating][rotten]" )
REQUIRE( dummy.has_trait( trait_id( "SAPROPHAGE" ) ) );

THEN( "they can eat it, but would prefer it to be more rotten" ) {
expect_can_eat( dummy, toastem_rotten );
expect_can_eat( dummy, jihelucake_rotten );

auto conseq = dummy.will_eat( toastem_rotten, false );
auto conseq = dummy.will_eat( jihelucake_rotten, false );
CHECK( conseq.value() == edible_rating::allergy_weak );
CHECK( conseq.str() == "Your stomach won't be happy (not rotten enough)." );
}
Expand Down
28 changes: 14 additions & 14 deletions tests/modify_morale_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ TEST_CASE( "food enjoyability", "[food][modify_morale][fun]" )
std::pair<int, int> fun;

GIVEN( "food with positive fun" ) {
detached_ptr<item> det = item::spawn( "toastem", calendar::start_of_cataclysm,
detached_ptr<item> det = item::spawn( "jihelucake", calendar::start_of_cataclysm,
item::default_charges_tag{} );
item &toastem = *det;
item &jihelucake = *det;
dummy.i_add( std::move( det ) );
fun = dummy.fun_for( toastem );
fun = dummy.fun_for( jihelucake );
REQUIRE( fun.first > 0 );

THEN( "character gets a morale bonus becase it tastes good" ) {
dummy.modify_morale( toastem );
dummy.modify_morale( jihelucake );
CHECK( dummy.get_morale( MORALE_FOOD_GOOD ) >= fun.first );
}
}
Expand Down Expand Up @@ -389,31 +389,31 @@ TEST_CASE( "saprophage character", "[food][modify_morale][saprophage]" )
REQUIRE( dummy.has_trait( trait_SAPROPHAGE ) );

AND_GIVEN( "some rotten chewable food" ) {
detached_ptr<item> det = item::spawn( "toastem", calendar::start_of_cataclysm,
detached_ptr<item> det = item::spawn( "jihelucake", calendar::start_of_cataclysm,
item::default_charges_tag{} );
item &toastem = *det;
item &jihelucake = *det;
dummy.i_add( std::move( det ) );
// food rot > 1.0 is rotten
toastem.set_relative_rot( 1.5 );
REQUIRE( toastem.rotten() );
jihelucake.set_relative_rot( 1.5 );
REQUIRE( jihelucake.rotten() );

THEN( "they enjoy it" ) {
dummy.modify_morale( toastem );
dummy.modify_morale( jihelucake );
CHECK( dummy.get_morale( MORALE_FOOD_GOOD ) > 10 );
}
}

AND_GIVEN( "some fresh chewable food" ) {
detached_ptr<item> det = item::spawn( "toastem", calendar::start_of_cataclysm,
detached_ptr<item> det = item::spawn( "jihelucake", calendar::start_of_cataclysm,
item::default_charges_tag{} );
item &toastem = *det;
item &jihelucake = *det;
dummy.i_add( std::move( det ) );
// food rot < 0.1 is fresh
toastem.set_relative_rot( 0.0 );
REQUIRE( toastem.is_fresh() );
jihelucake.set_relative_rot( 0.0 );
REQUIRE( jihelucake.is_fresh() );

THEN( "they get a morale penalty due to indigestion" ) {
dummy.modify_morale( toastem );
dummy.modify_morale( jihelucake );
CHECK( dummy.get_morale( MORALE_NO_DIGEST ) <= -25 );
}
}
Expand Down

0 comments on commit 18d7d65

Please sign in to comment.