File: activity_tracker.h

package info (click to toggle)
cataclysm-dda 0.H-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 710,808 kB
  • sloc: cpp: 524,019; python: 11,580; sh: 1,228; makefile: 1,169; xml: 507; javascript: 150; sql: 56; exp: 41; perl: 37
file content (55 lines) | stat: -rw-r--r-- 2,044 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#pragma once
#ifndef CATA_SRC_ACTIVITY_TRACKER_H
#define CATA_SRC_ACTIVITY_TRACKER_H

#include "calendar.h"

class JsonObject;
class JsonOut;

class activity_tracker
{
    private:
        float current_activity = 0.0;
        float accumulated_activity = 0.0;
        float previous_activity = 0.0;
        float previous_turn_activity = 0.0;
        time_point current_turn = calendar::turn_zero;
        bool activity_reset = true;
        int num_events = 1;

        // Weariness metadata.
        // Semi-consecutive 5 minute ticks of low activity (or 2.5 if we're sleeping). Float to handle mixed cases.
        float low_activity_ticks = 0.0f;
    public:
        int tracker = 0;
        int intake = 0;
        // Logs activity level. If called multiple times in one turn, will preserve the highest.
        void log_activity( float new_level );
        // Informs the tracker that a new turn has started.
        void new_turn( bool sleeping = false );
        // Resets accumulated activity level.
        void reset_activity_level();
        // Outputs player activity level to a printable string.
        std::string activity_level_str() const;
        // Returns activity level recorded for the current turn.
        float activity( bool sleeping = false ) const;
        // Returns average of activity level for the current period.
        float average_activity() const;
        // Returns the previous turn's activity level until an action is taken on the current turn.
        float instantaneous_activity_level() const;

        int weariness() const;
        void try_reduce_weariness( int bmr, float fatigue_mod, float fatigue_regen_mod );
        void calorie_adjust( int ncal );
        void weary_clear();
        int debug_get_tracker() const;
        void debug_set_tracker( int new_tracker );
        void set_intake( int ncal );
        std::string debug_weary_info() const;

        void serialize( JsonOut &json ) const;
        void deserialize( const JsonObject &jo );
};

#endif // CATA_SRC_ACTIVITY_TRACKER_H