ScummVM API documentation
game_clock.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef NUVIE_CORE_GAME_CLOCK_H
23 #define NUVIE_CORE_GAME_CLOCK_H
24 
25 #include "ultima/nuvie/core/nuvie_defs.h"
26 
27 namespace Ultima {
28 namespace Nuvie {
29 
30 #define GAMECLOCK_TICKS_PER_MINUTE 4
31 
32 #define GAMECLOCK_NUM_TIMERS 16
33 
34 #define GAMECLOCK_TIMER_U6_LIGHT 0
35 #define GAMECLOCK_TIMER_U6_INFRAVISION 1
36 #define GAMECLOCK_TIMER_U6_STORM 13
37 #define GAMECLOCK_TIMER_U6_TIME_STOP 14
38 #define GAMECLOCK_TIMER_U6_ECLIPSE 15
39 
40 #define GAMECLOCK_TIMER_MD_BLUE_BERRY 16*3
41 
42 class Configuration;
43 class NuvieIO;
44 
45 class GameClock {
46  nuvie_game_t game_type;
47 
48  uint16 minute;
49  uint8 hour;
50  uint8 day;
51  uint8 month;
52  uint16 year;
53  uint8 day_of_week;
54 
55  uint32 move_counter; // player steps taken since start
56  uint32 time_counter; // game minutes
57 // uint32 tick_counter; // moves/turns since last minute
58 
59  char date_string[11];
60  char time_string[11];
61 
62 //bool active; // clock is active and running (false = paused)
63 
64  Common::Array<uint8> timers;
65  uint8 num_timers;
66 
67  uint8 rest_counter; //hours until the party will heal again while resting.
68 
69 public:
70 
71  GameClock(nuvie_game_t type);
72  ~GameClock();
73 
74  bool load(NuvieIO *objlist);
75  bool save(NuvieIO *objlist);
76 
77 //void set_active(bool state) { active = state; }
78 //bool get_active() { return(active); }
79 
80  void inc_move_counter();
81  void inc_move_counter_by_a_minute();
82 
83  void advance_to_next_hour();
84 
85  void inc_minute(uint16 amount = 1);
86  void inc_hour();
87  void inc_day();
88  void inc_month();
89  void inc_year();
90 
91  uint32 get_move_count() const;
92 
93  const char *get_time_of_day_string();
94 
95  uint8 get_hour() const;
96  uint8 get_minute() const;
97 
98  uint8 get_day() const;
99  uint8 get_month() const;
100  uint16 get_year() const;
101  uint8 get_day_of_week() const;
102 
103  const char *get_date_string();
104  const char *get_time_string();
105 
106  uint8 get_rest_counter() const;
107  void set_rest_counter(uint8 value) {
108  rest_counter = value;
109  }
110 
111  uint32 get_ticks() const {
112  return SDL_GetTicks(); // milliseconds since start
113  }
114  uint32 get_game_ticks() const {
115  return time_counter;
116  }
117 // uint32 get_time() { return(time_counter); } // get_game_ticks() is preferred
118  uint32 get_turn() const {
119  return move_counter;
120  }
121 
122  void set_timer(uint8 timer_num, uint8 val);
123  uint8 get_timer(uint8 timer_num) const;
124  void update_timers(uint8 amount);
125 
126 //MD berry counters
127  uint8 get_purple_berry_counter(uint8 actor_num) const {
128  return get_timer(actor_num * 3);
129  }
130  uint8 get_green_berry_counter(uint8 actor_num) const {
131  return get_timer(actor_num * 3 + 1);
132  }
133  uint8 get_brown_berry_counter(uint8 actor_num) const {
134  return get_timer(actor_num * 3 + 2);
135  }
136 
137 protected:
138 
139  void init();
140  inline void update_day_of_week();
141 
142 private:
143  void load_U6_timers(NuvieIO *objlist);
144  void load_MD_timers(NuvieIO *objlist);
145  void save_U6_timers(NuvieIO *objlist);
146  void save_MD_timers(NuvieIO *objlist);
147 };
148 
149 } // End of namespace Nuvie
150 } // End of namespace Ultima
151 
152 #endif
Definition: game_clock.h:45
uint32 get_game_ticks() const
Definition: game_clock.h:114
Definition: detection.h:27
Definition: nuvie_io.h:32