Skip to content

Commit

Permalink
mouth dreams
Browse files Browse the repository at this point in the history
  • Loading branch information
KorGgenT committed Aug 14, 2021
1 parent 3908580 commit 46d0fe6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8988,6 +8988,11 @@ float Character::stamina_move_cost_modifier() const
return stamina_modifier * move_mode->move_speed_mult();
}

float Character::stamina_recovery_breathing_modifier() const
{
return breathing_score();
}

void Character::update_stamina( int turns )
{
static const std::string player_base_stamina_regen_rate( "PLAYER_BASE_STAMINA_REGEN_RATE" );
Expand All @@ -9002,7 +9007,7 @@ void Character::update_stamina( int turns )
mutation_value( stamina_regen_modifier ) + ( mutation_value( "max_stamina_modifier" ) - 1.0f ) );
// But mouth encumbrance interferes, even with mutated stamina.
stamina_recovery += stamina_multiplier * std::max( 1.0f,
base_regen_rate * breathing_score() );
base_regen_rate * stamina_recovery_breathing_modifier() );
stamina_recovery = enchantment_cache->modify_value( enchant_vals::mod::REGEN_STAMINA,
stamina_recovery );
// TODO: recovering stamina causes hunger/thirst/fatigue.
Expand Down
1 change: 1 addition & 0 deletions src/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -2385,6 +2385,7 @@ class Character : public Creature, public visitable
void mod_stamina( int mod );
void burn_move_stamina( int moves );
float stamina_move_cost_modifier() const;
float stamina_recovery_breathing_modifier() const;
/** Regenerates stamina */
void update_stamina( int turns );

Expand Down
2 changes: 1 addition & 1 deletion src/player_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ static std::string get_encumbrance_description( const player &p, const bodypart_
break;
case bp_mouth:
s += _( "<color_magenta>Covering your mouth will make it more difficult to breathe and catch your breath.</color>\n" );
s += mouth_stamina_cost_text( p.breathing_score() );
s += mouth_stamina_cost_text( p.stamina_recovery_breathing_modifier() );
break;
case bp_arm_l:
case bp_arm_r:
Expand Down
11 changes: 9 additions & 2 deletions tests/char_stamina_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,15 +435,22 @@ TEST_CASE( "stamina regen with mouth encumbrance", "[stamina][update][regen][enc
REQUIRE( dummy.encumb( bodypart_id( "mouth" ) ) == 10 );

THEN( "stamina regen is reduced" ) {
CHECK( actual_regen_rate( dummy, turn_moves ) == ( normal_regen_rate - 2 ) * turn_moves );
CAPTURE( dummy.stamina_recovery_breathing_modifier() );
CAPTURE( normal_regen_rate );
CHECK( actual_regen_rate( dummy, turn_moves ) ==
Approx( ( normal_regen_rate * dummy.stamina_recovery_breathing_modifier() ) * turn_moves ).margin(
0.9 ) );

WHEN( "they have even more mouth encumbrance" ) {
// Layering two scarves triples the encumbrance
dummy.wear_item( item( "scarf_fur" ) );
REQUIRE( dummy.encumb( bodypart_id( "mouth" ) ) == 30 );

THEN( "stamina regen is reduced further" ) {
CHECK( actual_regen_rate( dummy, turn_moves ) == ( normal_regen_rate - 6 ) * turn_moves );
CAPTURE( dummy.stamina_recovery_breathing_modifier() );
CHECK( actual_regen_rate( dummy, turn_moves ) ==
Approx( ( normal_regen_rate * dummy.stamina_recovery_breathing_modifier() ) * turn_moves ).margin(
0.9 ) );
}
}
}
Expand Down

0 comments on commit 46d0fe6

Please sign in to comment.