Exemple #1
0
        /// <summary>
        /// Új tábla létrehozása.
        /// </summary>
        private void GenerateTable()
        {
            DeleteBoard();
            _menuFileSaveGame.Enabled = true;

            _gameDisplayTable.RowCount = _gameDisplayTable.ColumnCount = _model.GetSize;
            gameBoard = new Button[_model.GetSize, _model.GetSize];
            for (Int32 i = 0; i < _model.GetSize; i++)
            {
                for (Int32 j = 0; j < _model.GetSize; j++)
                {
                    gameBoard[i, j]             = new Button();
                    gameBoard[i, j].TextAlign   = ContentAlignment.MiddleCenter;
                    gameBoard[i, j].Size        = new Size(30, 30);
                    gameBoard[i, j].TabIndex    = i * _model.GetSize + j;
                    gameBoard[i, j].Font        = new Font(FontFamily.GenericSansSerif, 12, FontStyle.Bold);
                    gameBoard[i, j].MouseClick += new MouseEventHandler(ButtonGrid_Click);
                    gameBoard[i, j].FlatStyle   = FlatStyle.Flat;
                    if (i == _model.GetSize - 1 || (_model.GetFieldValue(i, j) == Player.NoPlayer && _model.GetFieldValue(i + 1, j) != Player.NoPlayer))
                    {
                        gameBoard[i, j].Enabled = true;
                    }
                    else
                    {
                        gameBoard[i, j].Enabled = false;
                    }
                    _gameDisplayTable.Controls.Add(gameBoard[i, j], j, i);
                }
            }
            SetupTable();
        }
Exemple #2
0
        public void AmobaModel_NewGameTest()
        {
            _model.NewGame(10);

            Assert.AreEqual(0, _model.PlXTime);
            Assert.AreEqual(Player.PlayerX, _model.CurrentPlayer);
            Assert.AreEqual(10, _model.GetSize);

            for (Int32 i = 0; i < 10; i++)
            {
                for (Int32 j = 0; j < 10; j++)
                {
                    Assert.AreEqual(Player.NoPlayer, _model.GetFieldValue(i, j));
                }
            }
        }
Exemple #3
0
 /// <summary>
 /// Tábla frissítése.
 /// </summary>
 private void RefreshTable()
 {
     foreach (AmobaField curr in Fields)
     {
         curr.Text      = _model.GetFieldValue(curr.X, curr.Y) == Player.NoPlayer ? String.Empty : _model.GetFieldValue(curr.X, curr.Y) == Player.PlayerX ? "X" : "O";
         curr.Clickable = _model.IsFieldActive(curr.X, curr.Y);
     }
 }