Skip to content

Commit

Permalink
Remove food monotony penalty from junk foods and psychoactives (#38928)
Browse files Browse the repository at this point in the history
  • Loading branch information
Soadreqm authored Apr 2, 2020
1 parent 319710b commit a4f5758
Showing 1 changed file with 13 additions and 5 deletions.
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

0 comments on commit a4f5758

Please sign in to comment.