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 food monotony penalty from junk foods and psychoactives #38928

Merged
merged 5 commits into from
Apr 2, 2020
Merged
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
18 changes: 13 additions & 5 deletions src/item_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1841,31 +1841,39 @@ void Item_factory::load( islot_comestible &slot, const JsonObject &jo, const std
assign( jo, "cooks_like", slot.cooks_like, strict );
assign( jo, "smoking_result", slot.smoking_result, strict );

bool is_junkfood = false;
if( jo.has_member( "primary_material" ) ) {
std::string mat = jo.get_string( "primary_material" );
slot.specific_heat_solid = material_id( mat )->specific_heat_solid();
slot.specific_heat_liquid = material_id( mat )->specific_heat_liquid();
slot.latent_heat = material_id( mat )->latent_heat();
is_junkfood = is_junkfood || mat == "junk";
} else if( jo.has_member( "material" ) ) {
float specific_heat_solid = 0;
float specific_heat_liquid = 0;
float latent_heat = 0;

for( auto &m : jo.get_tags( "material" ) ) {
for( const std::string &m : jo.get_tags( "material" ) ) {
specific_heat_solid += material_id( m )->specific_heat_solid();
specific_heat_liquid += material_id( m )->specific_heat_liquid();
latent_heat += material_id( m )->latent_heat();
is_junkfood = is_junkfood || m == "junk";
}
// Average based on number of materials.
slot.specific_heat_liquid = specific_heat_liquid / jo.get_tags( "material" ).size();
slot.specific_heat_solid = specific_heat_solid / jo.get_tags( "material" ).size();
slot.latent_heat = latent_heat / jo.get_tags( "material" ).size();
}

if( is_junkfood ) { // Junk food never gets old by default, but this can still be overriden.
bool is_not_boring = false;
if( jo.has_member( "primary_material" ) ) {
std::string mat = jo.get_string( "primary_material" );
is_not_boring = is_not_boring || mat == "junk";
}
if( jo.has_member( "material" ) ) {
for( const std::string &m : jo.get_tags( "material" ) ) {
is_not_boring = is_not_boring || m == "junk";
}
}
// Junk food never gets old by default, but this can still be overriden.
if( is_not_boring ) {
slot.monotony_penalty = 0;
}
assign( jo, "monotony_penalty", slot.monotony_penalty, strict );
Expand Down