using System;
namespace Duck
{
///
/// Keeps settings loaded from duck_config for usage by the emulator.
///
public static class Config
{
#region Declares
///
/// The default motto that users gain at registration.
///
public static string Registration_Motto;
///
/// The amount of credits that users gain at registration.
///
public static int Registration_Credits;
///
/// The amount of tickets that users gain at registration.
///
public static int Registration_Tickets;
///
/// The amount of films that users gain at registration.
///
public static int Registration_Films;
///
/// Indicates if to log transactions by virtual users. (purchases of items etc)
///
public static bool logTransactions;
///
/// The max amount of rooms to show when opening a category in the Hotel Navigator.
///
public static int Rooms_Navigator_openCategory_maxResults;
///
/// The max amount of rooms to show when searching a guestroom in the Hotel Navigator.
///
public static int Rooms_Navigator_searchGuestroom_maxResults;
///
/// The max amount of guestrooms that a virtual user can have. When this amount is reached, no new rooms can be created until one is destroyed.
///
public static int Rooms_guestRooms_maxPerUser;
///
/// The max amount of rooms that a virtual user can have in it's favorite rooms list. When this amount is reached, no new rooms can be added until one is removed from the list.
///
public static int Rooms_Favorites_maxPerUser;
#endregion
#region Methods
///
/// Initializes various settings from the duck_config table and stores them in this class.
///
public static void Init()
{
IO.WriteLine("Initializing configuration from duck_config...");
Registration_Motto = getStringEntry("users.registration.motto");
Registration_Credits = getNumericEntry("users.registration.credits");
Registration_Tickets = getNumericEntry("users.registration.tickets");
Registration_Films = getNumericEntry("users.registration.films");
logTransactions = (getStringEntry("users.transactions.enabled") == "1");
Rooms_Navigator_openCategory_maxResults = getNumericEntry("rooms.navigator.opencategory.max");
Rooms_Navigator_searchGuestroom_maxResults = getNumericEntry("rooms.navigator.searchguestroom.max");
Rooms_guestRooms_maxPerUser = getNumericEntry("rooms.guestrooms.maxperuser");
Rooms_Favorites_maxPerUser = getNumericEntry("rooms.favorites.maxperuser");
IO.WriteLine("Loaded configuration.");
}
///
/// Gets the value from a config entry in duck_config table, and returns it as a string.
///
/// The key of the config entry.
public static string getStringEntry(string Key)
{
return DB.runRead("SELECT cvalue FROM duck_config WHERE ckey = '" + Key + "'");
}
///
/// Gets the value from a config entry in duck_config table, and returns it as an integer.
///
/// The key of the config entry.
public static int getNumericEntry(string Key)
{
return DB.runRead("SELECT cvalue FROM duck_config WHERE ckey = '" + Key + "'", null);
}
#endregion
}
}