Esempio n. 1
0
		public void SendTo(LetterBox letterBox)
		{
			if (letterBox == null)
			{
				throw new ArgumentNullException("letterBox");
			}
			letterBox.PutInto(this);
		}
Esempio n. 2
0
        public Game(List<string> playerNames, BaseController controller)
        {
            if (playerNames == null)
            {
                throw new ArgumentNullException("playerNames");
            }
            else if (controller == null)
            {
                throw new ArgumentNullException("controller");
            }
            else if (controller.Game != null)
            {
                throw new ArgumentException("The controller is already bound.", "controller");
            }

            int numPlayers = playerNames.Count;
            if (numPlayers != 2)
            {
                //TODO: support game among more than 2 players
                throw new NotSupportedException("Battle of more than two players are not supported.");
            }

            m_players = new Player[numPlayers];
            for (int i = 0; i < numPlayers; ++i)
            {
                m_players[i] = new Player(playerNames[i], i, this);
            }

            controller.Game = this;

            CurrentPhase = "";

            Players = m_players.ToIndexable();
            Random = new Random(controller.GetRandomSeed());
            Controller = controller;
            LetterBox = new Messaging.LetterBox();
        }
 /// <summary>
 /// Construct a message text-handler map for message handling.
 /// </summary>
 private void InitializeMessaging(bool syncMode)
 {
     m_letterBox = syncMode ? null : new Messaging.LetterBox();
 }