Skip to content

Commit

Permalink
Merge pull request #72783 from RenechCDDA/food_monotony_test
Browse files Browse the repository at this point in the history
Fix food fun reduction test not actually having any reduction
  • Loading branch information
I-am-Erk authored Apr 4, 2024
2 parents 9b661f1 + 9236393 commit 1b74c65
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
10 changes: 10 additions & 0 deletions data/mods/TEST_DATA/items.json
Original file line number Diff line number Diff line change
Expand Up @@ -4919,5 +4919,15 @@
"//": "Do not use calcium, iron or vitamin C! Those are calculated as RDAs, and you only get 96% of the listed value! No, that doesn't make any sense! But that's how it is. So use a normal vitamin. This is for a camp test, not a vitamin test...",
"vitamins": [ [ "mutant_toxin", 100 ], [ "mutagen", 200 ] ],
"melee_damage": { "bash": 1 }
},
{
"type": "COMESTIBLE",
"id": "toastem_test",
"name": { "str": "toast-em" },
"copy-from": "toastem",
"//": "toastem copy with a different material + manual values so monotony penalty is sure to apply",
"material": [ "foodplace_foodstuff" ],
"fun": 20,
"monotony_penalty": 4
}
]
3 changes: 2 additions & 1 deletion doc/JSON_INFO.md
Original file line number Diff line number Diff line change
Expand Up @@ -3933,7 +3933,8 @@ CBMs can be defined like this:
"healthy" : -2, // Health effects (used for sickness chances)
"addiction_potential" : 80, // Default strength for this item to cause addictions
"addiction_type" : [ "crack", { "addiction": "cocaine", "potential": 5 } ], // Addiction types (if no potential is given, the "addiction_potential" field is used to determine the strength of that addiction)
"monotony_penalty" : 0, // (Optional, default: 2) Fun is reduced by this number for each one you've consumed in the last 48 hours.
"monotony_penalty" : 0, // (Optional, default: 2 or 0 depending on material) Fun is reduced by this number for each one you've consumed in the last 48 hours.
// Comestibles with any material of junk food (id: "junk") default to 0. All other comestibles default to 2 when unspecified.
// Can't drop fun below 0, unless the comestible also has the "NEGATIVE_MONOTONY_OK" flag.
"calories" : 0, // Hunger satisfied (in kcal)
"nutrition" : 0, // Hunger satisfied (OBSOLETE)
Expand Down
5 changes: 4 additions & 1 deletion tests/food_fun_for_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,13 +367,16 @@ TEST_CASE( "fun_for_food_eaten_too_often", "[fun_for][food][monotony]" )
std::pair<int, int> actual_fun;

// A big box of tasty toast-ems
item toastem( "toastem", calendar::turn, 10 );
item toastem( "toastem_test", calendar::turn, 10 );
REQUIRE( toastem.is_comestible() );

// Base fun value and monotony penalty for toast-em
int toastem_fun = toastem.get_comestible_fun();
int toastem_penalty = toastem.get_comestible()->monotony_penalty;

REQUIRE( toastem_fun > 0 );
REQUIRE( toastem_penalty > 0 );

// Will do 2 rounds of penalty testing, so base fun needs to be at least 2x that
REQUIRE( toastem_fun > 2 * toastem_penalty );

Expand Down

0 comments on commit 1b74c65

Please sign in to comment.