Adonthell  0.4
gamedate Class Reference

Keeps track of the time the player spent within the game so far. More...

#include <gamedate.h>

Static Public Member Functions

static void update ()
 Update the game date. More...
 
static u_int32 time ()
 Get the current gametime. More...
 
static u_int16 weekday ()
 Get the current weekday. More...
 
static u_int16 day ()
 Returns the current day in the gameworld. More...
 
static u_int16 hour ()
 Return the hour of the current day. More...
 
static u_int16 minute ()
 Return the minute of the current hour. More...
 
static u_int32 parse_time (const std::string &time)
 convert the time string to gametime minutes. More...
 
static bool get_state (igzstream &in)
 Load the state of the gamedate class from disk. More...
 
static void put_state (ogzstream &out)
 Save the state of the gamedate class to disk. More...
 

Detailed Description

Keeps track of the time the player spent within the game so far.

This time span is given in game time minutes, not real time. gamedate further includes functions to retrieve those minutes as day, weekday, hour and minute values.

Definition at line 49 of file gamedate.h.

Member Function Documentation

§ update()

void gamedate::update ( )
static

Update the game date.

Whenever a minute of gametime has passed, a time event will be raised. This function needs to be called from the main loop and uses

Definition at line 40 of file gamedate.cc.

§ time()

static u_int32 gamedate::time ( )
inlinestatic

Get the current gametime.

Returns
gametime in 1/10 minutes since start of the game.

Definition at line 64 of file gamedate.h.

§ weekday()

u_int16 gamedate::weekday ( )
static

Get the current weekday.

Returns
weekday as a number between 0 and DAYS_PER_WEEK - 1

Definition at line 77 of file gamedate.cc.

§ day()

u_int16 gamedate::day ( )
static

Returns the current day in the gameworld.

Returns
number of days spent in the gameworld, beginning with day 0.

Definition at line 83 of file gamedate.cc.

§ hour()

u_int16 gamedate::hour ( )
static

Return the hour of the current day.

Returns
hour of the current day between 0 and HOURS_PER_DAY - 1

Definition at line 92 of file gamedate.cc.

§ minute()

u_int16 gamedate::minute ( )
static

Return the minute of the current hour.

Returns
minute of the current hour between 0 and 59.

Definition at line 98 of file gamedate.cc.

§ parse_time()

u_int32 gamedate::parse_time ( const std::string &  time)
static

convert the time string to gametime minutes.

The time string has the format "<number>X", where X may be (w)eek, (d)ay, (h)our, (m)inute or (t)enth minute. Several such pairs can be concatenated. Valid examples are "1w1d1h", "30m1h" but also "1h1h".

Parameters
timeThe time format string.
Returns
The time represented by the string in minutes.

Definition at line 104 of file gamedate.cc.

§ get_state()

bool gamedate::get_state ( igzstream in)
static

Load the state of the gamedate class from disk.

Parameters
instream to read the state from
Returns
true if the state was successfully retrieved, false otherwise.

Definition at line 61 of file gamedate.cc.

§ put_state()

void gamedate::put_state ( ogzstream out)
static

Save the state of the gamedate class to disk.

Parameters
outstream to write the state to

Definition at line 70 of file gamedate.cc.


The documentation for this class was generated from the following files: