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/shared/std/containers.h"
26 
27 #include "ultima/nuvie/core/nuvie_defs.h"
28 
29 namespace Ultima {
30 namespace Nuvie {
31 
32 #define GAMECLOCK_TICKS_PER_MINUTE 4
33 
34 #define GAMECLOCK_NUM_TIMERS 16
35 
36 #define GAMECLOCK_TIMER_U6_LIGHT 0
37 #define GAMECLOCK_TIMER_U6_INFRAVISION 1
38 #define GAMECLOCK_TIMER_U6_STORM 13
39 #define GAMECLOCK_TIMER_U6_TIME_STOP 14
40 #define GAMECLOCK_TIMER_U6_ECLIPSE 15
41 
42 #define GAMECLOCK_TIMER_MD_BLUE_BERRY 16*3
43 
44 class Configuration;
45 class NuvieIO;
46 
47 class GameClock {
48  nuvie_game_t game_type;
49 
50  uint16 minute;
51  uint8 hour;
52  uint8 day;
53  uint8 month;
54  uint16 year;
55  uint8 day_of_week;
56 
57  uint32 move_counter; // player steps taken since start
58  uint32 time_counter; // game minutes
59 // uint32 tick_counter; // moves/turns since last minute
60 
61  char date_string[11];
62  char time_string[11];
63 
64 //bool active; // clock is active and running (false = paused)
65 
66  Common::Array<uint8> timers;
67  uint8 num_timers;
68 
69  uint8 rest_counter; //hours until the party will heal again while resting.
70 
71 public:
72 
73  GameClock(nuvie_game_t type);
74  ~GameClock();
75 
76  bool load(NuvieIO *objlist);
77  bool save(NuvieIO *objlist);
78 
79 //void set_active(bool state) { active = state; }
80 //bool get_active() { return(active); }
81 
82  void inc_move_counter();
83  void inc_move_counter_by_a_minute();
84 
85  void advance_to_next_hour();
86 
87  void inc_minute(uint16 amount = 1);
88  void inc_hour();
89  void inc_day();
90  void inc_month();
91  void inc_year();
92 
93  uint32 get_move_count() const;
94 
95  const char *get_time_of_day_string();
96 
97  uint8 get_hour() const;
98  uint8 get_minute() const;
99 
100  uint8 get_day() const;
101  uint8 get_month() const;
102  uint16 get_year() const;
103  uint8 get_day_of_week() const;
104 
105  const char *get_date_string();
106  const char *get_time_string();
107 
108  uint8 get_rest_counter() const;
109  void set_rest_counter(uint8 value) {
110  rest_counter = value;
111  }
112 
113  uint32 get_ticks() const {
114  return SDL_GetTicks(); // milliseconds since start
115  }
116  uint32 get_game_ticks() const {
117  return time_counter;
118  }
119 // uint32 get_time() { return(time_counter); } // get_game_ticks() is preferred
120  uint32 get_turn() const {
121  return move_counter;
122  }
123 
124  void set_timer(uint8 timer_num, uint8 val);
125  uint8 get_timer(uint8 timer_num) const;
126  void update_timers(uint8 amount);
127 
128 //MD berry counters
129  uint8 get_purple_berry_counter(uint8 actor_num) const {
130  return get_timer(actor_num * 3);
131  }
132  uint8 get_green_berry_counter(uint8 actor_num) const {
133  return get_timer(actor_num * 3 + 1);
134  }
135  uint8 get_brown_berry_counter(uint8 actor_num) const {
136  return get_timer(actor_num * 3 + 2);
137  }
138 
139 protected:
140 
141  void init();
142  inline void update_day_of_week();
143 
144 private:
145  void load_U6_timers(NuvieIO *objlist);
146  void load_MD_timers(NuvieIO *objlist);
147  void save_U6_timers(NuvieIO *objlist);
148  void save_MD_timers(NuvieIO *objlist);
149 };
150 
151 } // End of namespace Nuvie
152 } // End of namespace Ultima
153 
154 #endif
Definition: game_clock.h:47
uint32 get_game_ticks() const
Definition: game_clock.h:116
Definition: detection.h:27
Definition: nuvie_io.h:32