Skip to content

Commit

Permalink
Adjust for smoothing weary intake/tracker
Browse files Browse the repository at this point in the history
This adjusts expected test values to the (quite consistent) ones for
the altered weary intake/tracker. It also does the weary.tracker
adjustment in a less-perfectionistic (but more-functional) way.
  • Loading branch information
actual-nh committed Feb 11, 2021
1 parent db03ee5 commit 028b0f0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5690,17 +5690,17 @@ void Character::try_reduce_weariness( const float exertion )
weary.tick_counter++;
if( exertion == NO_EXERCISE ) {
weary.low_activity_ticks++;
// Recover twice as fast at rest
// Recover twice as fast if asleep
if( in_sleep_state() ) {
weary.low_activity_ticks++;
}
}

const float recovery_mult = get_option<float>( "WEARY_RECOVERY_MULT" );
const int bmr = base_bmr();

while( weary.low_activity_ticks >= 6 ) {
if( weary.low_activity_ticks >= 6 ) {
int reduction = weary.tracker;
const int bmr = base_bmr();
// 1/20 of whichever's bigger
if( bmr > reduction ) {
reduction = bmr * recovery_mult;
Expand Down
10 changes: 5 additions & 5 deletions tests/weary_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ TEST_CASE( "weary_assorted_tasks", "[weary][activities]" )
CHECK( guy.weariness_level() == 1 );
}

SECTION( "Heavy tasks - Digging Pits 8 hours:" ) {
SECTION( "Heavy tasks - Digging Pits 8 hours" ) {
clear_avatar();
INFO( guy.debug_weary_info() );
weariness_events info = do_activity( soldier_8h );
Expand All @@ -77,7 +77,7 @@ TEST_CASE( "weary_assorted_tasks", "[weary][activities]" )
CHECK( guy.weariness_level() == 4 );
}

SECTION( "Heavy tasks - Digging Pits 12 hours:" ) {
SECTION( "Heavy tasks - Digging Pits 12 hours" ) {
clear_avatar();
INFO( guy.debug_weary_info() );
weariness_events info = do_activity( soldier_12h );
Expand Down Expand Up @@ -133,7 +133,7 @@ TEST_CASE( "weary_recovery", "[weary][activities]" )
INFO( guy.debug_weary_info() );
REQUIRE( !info.empty() );
CHECK( info.transition_minutes( 4, 3, 520_minutes ) == Approx( 520 ).margin( 5 ) );
CHECK( info.transition_minutes( 3, 2, 670_minutes ) == Approx( 670 ).margin( 5 ) );
CHECK( info.transition_minutes( 3, 2, 640_minutes ) == Approx( 640 ).margin( 5 ) );
CHECK( info.transition_minutes( 1, 0, 0_minutes ) > ( 8 * 60 ) ); // should be INT_MAX
CHECK( info.transition_minutes( 2, 1, 0_minutes ) > ( 8 * 60 ) );
CHECK( info.transition_minutes( 1, 2, 16_hours ) <= ( 8 * 60 ) );
Expand Down Expand Up @@ -189,8 +189,8 @@ TEST_CASE( "weary_24h_tasks", "[weary][activities]" )
CHECK( info.transition_minutes( 2, 3, 360_minutes ) == Approx( 360 ).margin( 5 ) );
CHECK( info.transition_minutes( 3, 4, 470_minutes ) == Approx( 470 ).margin( 5 ) );
CHECK( info.transition_minutes( 4, 5, 595_minutes ) == Approx( 595 ).margin( 5 ) );
CHECK( info.transition_minutes( 5, 6, 730_minutes ) == Approx( 730 ).margin( 5 ) );
CHECK( info.transition_minutes( 6, 7, 835_minutes ) == Approx( 835 ).margin( 5 ) );
CHECK( info.transition_minutes( 5, 6, 740_minutes ) == Approx( 740 ).margin( 5 ) );
CHECK( info.transition_minutes( 6, 7, 845_minutes ) == Approx( 845 ).margin( 5 ) );
CHECK( info.transition_minutes( 7, 8, 915_minutes ) == Approx( 915 ).margin( 10 ) );
CHECK( !info.have_weary_decrease() );
// TODO: You should collapse from this - currently we
Expand Down

0 comments on commit 028b0f0

Please sign in to comment.