using System;
using Server.Misc;
using Server.Mobiles;

namespace Server
{
	class ValidSettings
	{
		// This file enforces some cap limites for some settings in Settings.cs
		public static double ServerSaveMinutes()
		{
			if (Settings.S_ServerSaveMinutes > 240)
			{
				Settings.S_ServerSaveMinutes = 240.0;
			}
			else if ( Settings.S_ServerSaveMinutes < 5 )
			{
				Settings.S_ServerSaveMinutes = 5.0;
			}
			return Settings.S_ServerSaveMinutes;
		}

		public static double DeleteDaysDelay()
		{
			if (Settings.S_DeleteDaysDelay > 14)
			{
				Settings.S_DeleteDaysDelay = 14;
			}
			else if ( Settings.S_DeleteDaysDelay < 1 )
			{
				Settings.S_DeleteDaysDelay = 1;
			}
			return Settings.S_DeleteDaysDelay;
		}

		public static double CorpseDecay()
		{
			if ( Settings.S_CorpseDecay < 1 )
			{
				Settings.S_CorpseDecay = 0;
			}
			return (double)Settings.S_CorpseDecay;
		}

		public static double BoneDecay()
		{
			if ( Settings.S_BoneDecay < 1 )
			{
				Settings.S_BoneDecay = 0;
			}
			return (double)Settings.S_BoneDecay;
		}

		public static double StatGain()
		{
			if ( Settings.S_StatGain > 50 )
			{
				Settings.S_StatGain = 50.0;
			}
			else if ( Settings.S_StatGain < 10 )
			{
				Settings.S_StatGain = 10.0;
			}
			return Settings.S_StatGain;
		}

		public static TimeSpan StatGainDelay()
		{
			if ( Settings.S_StatGainDelay > 60 )
			{
				Settings.S_StatGainDelay = 60.0;
			}
			else if ( Settings.S_StatGainDelay < 5 )
			{
				Settings.S_StatGainDelay = 5.0;
			}
			return TimeSpan.FromMinutes( Settings.S_StatGainDelay );
		}

		public static double SkillGain()
		{
			int skill = 0;
			if ( Settings.S_SkillGain > 10 )
				skill = 10;
			if ( Settings.S_SkillGain < 1 )
				skill = 0;
			return skill * 0.1;
		}

		public static int StartingGold()
		{
			int min = Settings.S_MinGold;
			int max = Settings.S_MaxGold;
			if ( min > max )
				min = max;
			int gold = Utility.RandomMinMax(min, max);
			if ( gold < 0 )
				gold = 0;
			if ( gold > 10000 )
				gold = 10000;
			return gold;
		}

	}
}
