-
Notifications
You must be signed in to change notification settings - Fork 17
/
GameClock.h
141 lines (105 loc) · 3.52 KB
/
GameClock.h
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#ifndef __GameClock_h__
#define __GameClock_h__
/*
* GameClock.h
* Nuvie
*
* Created by Eric Fry on Fri May 02 2003.
* Copyright (c) 2003. All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include <vector>
#include "SDL.h"
#include "nuvieDefs.h"
using std::vector;
#define GAMECLOCK_TICKS_PER_MINUTE 4
#define GAMECLOCK_NUM_TIMERS 16
#define GAMECLOCK_TIMER_U6_LIGHT 0
#define GAMECLOCK_TIMER_U6_INFRAVISION 1
#define GAMECLOCK_TIMER_U6_STORM 13
#define GAMECLOCK_TIMER_U6_TIME_STOP 14
#define GAMECLOCK_TIMER_U6_ECLIPSE 15
#define GAMECLOCK_TIMER_MD_BLUE_BERRY 16*3
class Configuration;
class NuvieIO;
class GameClock
{
Configuration *config;
nuvie_game_t game_type;
uint16 minute;
uint8 hour;
uint8 day;
uint8 month;
uint16 year;
uint8 day_of_week;
uint32 move_counter; // player steps taken since start
uint32 time_counter; // game minutes
// uint32 tick_counter; // moves/turns since last minute
char date_string[11];
char time_string[11];
//bool active; // clock is active and running (false = paused)
vector<uint8> timers;
uint8 num_timers;
uint8 rest_counter; //hours until the party will heal again while resting.
public:
GameClock(Configuration *cfg, nuvie_game_t type);
~GameClock();
bool load(NuvieIO *objlist);
bool save(NuvieIO *objlist);
//void set_active(bool state) { active = state; }
//bool get_active() { return(active); }
void inc_move_counter();
void inc_move_counter_by_a_minute();
void advance_to_next_hour();
void inc_minute(uint16 amount=1);
void inc_hour();
void inc_day();
void inc_month();
void inc_year();
uint32 get_move_count();
const char *get_time_of_day_string();
uint8 get_hour();
uint8 get_minute();
uint8 get_day();
uint8 get_month();
uint16 get_year();
uint8 get_day_of_week();
char *get_date_string();
char *get_time_string();
uint8 get_rest_counter();
void set_rest_counter(uint8 value) { rest_counter = value; }
uint32 get_ticks() { return(SDL_GetTicks()); } // milliseconds since start
uint32 get_game_ticks() { return(time_counter/**GAMECLOCK_TICKS_PER_MINUTE+tick_counter*/); }
// uint32 get_time() { return(time_counter); } // get_game_ticks() is preferred
uint32 get_turn() { return(move_counter); }
void set_timer(uint8 timer_num, uint8 val);
uint8 get_timer(uint8 timer_num);
void update_timers(uint8 amount);
//MD berry counters
uint8 get_purple_berry_counter(uint8 actor_num) { return get_timer(actor_num*3); }
uint8 get_green_berry_counter(uint8 actor_num) { return get_timer(actor_num*3+1); }
uint8 get_brown_berry_counter(uint8 actor_num) { return get_timer(actor_num*3+2); }
protected:
void init();
inline void update_day_of_week();
private:
void load_U6_timers(NuvieIO *objlist);
void load_MD_timers(NuvieIO *objlist);
void save_U6_timers(NuvieIO *objlist);
void save_MD_timers(NuvieIO *objlist);
};
#endif /* __GameClock_h__ */