Skip to content

Commit

Permalink
Give more weary info; calories a bit less
Browse files Browse the repository at this point in the history
Give more detailed information on weariness (tracker and intake),
to try to figure out why keeps going up and down during tests.

Since the "healthy" stored calories are at bmi 25, put calories
to healthy minus debug_nutrition, to prevent going over.
  • Loading branch information
actual-nh committed Jan 19, 2021
1 parent b26c431 commit b897540
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 6 deletions.
10 changes: 10 additions & 0 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5052,6 +5052,16 @@ std::string Character::debug_weary_info() const
healthy_calories, fatigue, morale, weight, bmi );
}

int Character::weary_tracker() const
{
return weary.tracker;
}

int Character::weary_intake() const
{
return weary.intake;
}

void weariness_tracker::clear()
{
tracker = 0;
Expand Down
2 changes: 2 additions & 0 deletions src/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -2692,6 +2692,8 @@ class Character : public Creature, public visitable
int weariness_level() const;
int weary_threshold() const;
int weariness() const;
int weary_tracker() const;
int weary_intake() const;
float activity_level() const;
float exertion_adjusted_move_multiplier( float level = -1.0f ) const;
void try_reduce_weariness( float exertion );
Expand Down
14 changes: 10 additions & 4 deletions tests/activity_scheduling_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,10 @@ weariness_events do_activity( tasklist tasks )
if( new_weariness != weariness_lvl ) {
int new_weary = guy.weariness();
int new_thresh = guy.weary_threshold();
int new_tracker = guy.weary_tracker();
int new_intake = guy.weary_intake();
activity_log.log( weariness_lvl, new_weariness, spent,
new_weary, new_thresh );
new_weary, new_thresh, new_tracker, new_intake );
weariness_lvl = new_weariness;
}
}
Expand Down Expand Up @@ -171,14 +173,17 @@ time_duration tasklist::duration()
}

void weariness_events::log( const int old_level, const int new_level, const time_duration &when,
const int new_weariness, const int new_threshold )
const int new_weariness, const int new_threshold,
const int new_tracker, const int new_intake )
{
weary_transition added;
added.from = old_level;
added.to = new_level;
added.minutes = to_minutes<int>( when );
added.new_weariness = new_weariness;
added.new_threshold = new_threshold;
added.new_tracker = new_tracker;
added.new_intake = new_intake;

transitions.insert( transitions.end(), added );
}
Expand All @@ -202,9 +207,10 @@ std::string weariness_events::summarize() const
{
std::string buffer;
for( const weary_transition &change : transitions ) {
buffer += string_format( "Transition: Weariness lvl from %d to %d at %d min (W %d Th %d)\n",
buffer += string_format( "Transition: Weariness lvl from %d to %d at %d min (W %d Th %d Tr %d In %d)\n",
change.from, change.to, change.minutes,
change.new_weariness, change.new_threshold );
change.new_weariness, change.new_threshold,
change.new_tracker, change.new_intake );
}
return buffer;
}
Expand Down
4 changes: 3 additions & 1 deletion tests/activity_scheduling_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,15 @@ struct weariness_events {
int to = 0;
int new_weariness = 0;
int new_threshold = 0;
int new_tracker = 0;
int new_intake = 0;
};

std::vector<weary_transition> transitions;

public:
void log( int old_level, int new_level, const time_duration &when,
int new_weariness, int new_threshold );
int new_weariness, int new_threshold, int new_tracker, int new_intake );

// Return the first time a transition between `from` and `to` occurs, in minutes
// if around = 0_seconds or equivalent, otherwise return the time closest to around
Expand Down
4 changes: 3 additions & 1 deletion tests/player_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ void clear_character( player &dummy )
// This sets HP to max, clears addictions and morale,
// and sets hunger, thirst, fatigue and such to zero
dummy.environmental_revert_effect();
dummy.set_stored_kcal( dummy.get_healthy_kcal() ); // But not stored kcal
// However, the above does not set stored kcal;
// 2170 is calories of debug_nutrition
dummy.set_stored_kcal( dummy.get_healthy_kcal() - 2170 );

dummy.empty_skills();
dummy.martial_arts_data->clear_styles();
Expand Down

0 comments on commit b897540

Please sign in to comment.