using System;
using System.Diagnostics;
using nft.core.game;
using nft.core.schedule;
using nft.core;

namespace nft.impl.game
{
	/// <summary>
	/// GameImpl の概要の説明です。
	/// </summary>
	[Serializable]
	public class GameImpl : IGame
	{
        protected Calendar calender;
        protected Clock clock;

		protected string name;
        protected TerrainMapImpl terrains;

        public GameImpl(string name, ITerrainMap map, Calendar cal) {
            if (cal == null) cal = Calendar.ActiveCalendar;
            this.name = name;
            this.calender = cal;
            this.clock = this.calender.CreateNewClock(new Date());
            if (map is TerrainMapImpl)
                this.terrains = (TerrainMapImpl)map;
            else 
                this.terrains = new TerrainMapImpl(map);
        }

        public GameImpl(ITerrainMap map, Calendar cal)
            : this(Core.GetString("game.new_game","NewGame"), map, cal) {
        }

        public TerrainMapImpl TerrainMap {
            get { return terrains; }
        }

		#region IGame メンバ

		public void Start()
		{
			// TODO : this is test code
			for(int i = 0; i<30000; i++ )
			{
				//System.Threading.Thread.Sleep(100);
				clock.Tick(10);
			}
		}

		public void Close()
		{
			// TODO:  GameImpl.Close 実装を追加します。
		}

		public bool Modified
		{
			get
			{
				// TODO:  GameImpl.Modified getter 実装を追加します。
				return false;
			}
		}

		public nft.core.schedule.Clock Clock
		{
			get
			{
				return clock;
			}
		}

		public IClimateController ClimateController
		{
			get
			{
				// TODO:  GameImpl.OverrideTable getter 実装を追加します。
				return null;
			}
		}

		public string Name
		{
			get{ return name; }
			set{ name = value; }
		}

		#endregion
	}
}
