/*
....[@@@..[@@@..............[@.................. MUD++ is a written from
....[@..[@..[@..[@..[@..[@@@@@....[@......[@.... scratch multi-user swords and
....[@..[@..[@..[@..[@..[@..[@..[@@@@@..[@@@@@.. sorcery game written in C++.
....[@......[@..[@..[@..[@..[@....[@......[@.... This server is an ongoing
....[@......[@..[@@@@@..[@@@@@.................. development project. All
................................................ contributions are welcome.
....Copyright(C).1995.Melvin.Smith.............. Enjoy.
------------------------------------------------------------------------------
Melvin Smith (aka Fusion) msmith@falcon.mercer.peachnet.edu
MUD++ development mailing list mudpp-list@spice.com
------------------------------------------------------------------------------
env.h
*/
#ifndef _ENV_H
#define _ENV_H
#include "random.h"
#include "string.h"
// This is the environment and class which controls
// stuff like weather, time, moon status, and
// temperature.
// Currently, there is only one Environment object
// existing in the game, and it is updated every
// tick (which represents one hour in MUD time).
// A possible enhancment to this could be giving
// each continent its own weather conditions.
// (Raining in one continent, but not another)
// Stuff for time
#define HOURS_PER_DAY 23
#define DAYS_PER_MONTH 28
#define MONTHS_PER_YEAR 14
// Moon periods
#define LUNOS_PERIOD 28
#define CRONOS_PERIOD 16
// 4 seasons
#define SEASON_FALL 0
#define SEASON_WINTER 1
#define SEASON_SPRING 2
#define SEASON_SUMMER 3
// Climate types
#define SEASONAL 0 // Temp is determined by current season
#define COLD_ALL_YEAR 1 // Cold all year round, regardless of season
#define WARM_ALL_YEAR 2 // Warm all year round, regardless of season
#define HOT_ALL_YEAR 3 // Hot all year round, regardless of season
// Temperature types
#define TEMP_COOL 0
#define TEMP_COLD 1
#define TEMP_WARM 2
#define TEMP_HOT 3
// Precipitation types
#define CALM 0
#define BREEZY 1
#define WINDY 2
#define CLOUDY 3
#define RAINING 4
#define LIGHTNING 5 // This define means that there is lightning
// AND rain (not just lightning)
// For getting struck by lightning!
// Humidity types
#define HUMIDITY_LOW 0 // Very dry -- Desert
#define HUMIDITY_MEDIUM 1 // Normal
#define HUMIDITY_HIGH 2 // Very Wet -- Tropical rainfall
class Weather
{
private:
static Random ran;
static const char *temps[];
static const char *precips[];
static const char *precips_cold[];
int humidity_level; // Current humidity level (0-2)
// (Basically, this is the chance
// of rain)
int climate_type; // The type of climate
int current_temp; // The current temp (0-3)
int precipitation; // Is it raining (or snowing)? (0-4)
int fog;
void updateFog();
void sendInfo( int old_precip );
void sendThunder();
public:
Weather()
: humidity_level(HUMIDITY_MEDIUM),
climate_type(SEASONAL), current_temp(TEMP_WARM),
precipitation(CALM), fog(0)
{
}
void update( int );
const String & getWeather();
void setHumidity( int );
void setClimate( int );
int getPrecip();
bool isFoggy()
{
return (bool)( fog );
}
bool isClear()
{
if( precipitation < CLOUDY && !isFoggy() )
return true;
return false;
}
};
class Environment
{
protected:
static const char *seasons[];
static const char *phases[];
static const char *moon_status[];
static const char *time_of_day_normal[];
static const char *time_of_day_cloudy[];
static Random ran;
int hour;
int day;
int month;
int year;
int season;
int moon1_path;
int moon2_path;
void updateSeason();
void updateMoons();
void sendInfo();
public:
Weather weather; //Temporary
Environment()
: hour(0), day(1), month(1), year(150),
season(0), moon1_path(1), moon2_path(1)
{
}
void update( void );
const String & getTime( void );
const String & getWeather( void ) { return weather.getWeather(); }
};
#endif