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