// This is just a bullshit website for personal use

class MDC
{
	protected bool m_IsSleeping;

	protected int m_Age;

	protected string m_Location;
	protected string m_Name;

	protected array<ShitToFix> m_Jobs = new array<ShitToFix>();
	protected ShitToFix m_LastJob;

	protected Timer m_SleepTimer = new Timer();
	protected Timer m_WorkTimer = new Timer();

	void MDC()
	{
		m_Age = 36;
		m_Location = "UK";
		m_Name = "Michael Cullen";
	
		SetSleeping(false);
	}

	int GetAge() { return m_Age }
	string GetLocation() { return m_Location }
	string GetName() { return m_Name }

	void OnReceiveDM(ShitToFix problem)
	{
		if (m_Jobs.Find(problem) < 0)
			m_Jobs.Insert(problem);
		else
			Print("Fuck off.");
	}

	void SetSleeping(bool state)
	{
		m_IsSleeping = state;
		m_IsWorking = !state;

		if (state)
		{
			m_WorkTimer.Run(1, this, "UpdateWork")
		
			if (m_SleepTimer.IsRunning())
				m_SleepTimer.Stop();
		}
		else
		{
			m_SleepTimer.Run(1, this, "UpdateSleep");

			if (m_WorkTimer.IsRunning())
				m_WorkTimer.Stop();
		}
	}

	void UpdateSleep()
	{
		if (m_Jobs.Count() == 0)
		{
			SetSleeping(true);
		}
	}

	void UpdateWork()
	{
		if (m_Jobs.Count() > 0)
		{
			if (IsSleeping())
				SetSleeping(false);

			if (m_Jobs[0] != m_LastJob)
			{
				GetLife().ProcessWork(job);
			}
			else
			{
				if (m_Jobs[0].IsFinished())
					m_Jobs.Remove(0);
			}
		}
		else
		{
			if (!IsSleeping())
				SetSleeping(true);
		}
	}
}