예제 #1
0
        public char IsSmallGameOver(SmallField field)
        {
            int width = SmallField.Width, height = SmallField.Height;

            char[,] currentField = new char[height, width];
            bool hasNol = false;

            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < width; j++)
                {
                    currentField[i, j] = field.GetSymbol(j, i);
                    if (currentField[i, j] == Field.Nol)
                    {
                        hasNol = true;
                    }
                }
            }
            char symbol = GetWinSymbol(currentField);

            if (hasNol == false)
            {
                if (symbol == Field.Nol)
                {
                    field.SetSymbol(Field.Nor);
                }
                field.SetFull();
                return(symbol);
            }
            if (field.GetSymbol() == Field.Nol)
            {
                field.SetSymbol(symbol);
            }
            return(symbol);
        }
예제 #2
0
 public BigField()
 {
     symbol      = Nol;
     this._field = new SmallField[Height, Width];
     for (int i = 0; i < Height; i++)
     {
         for (int j = 0; j < Width; j++)
         {
             _field [i, j] = new SmallField();
         }
     }
 }
예제 #3
0
        public override void Update(BigField field)
        {
            this._field = field;
            StringBuilder[] lines = new StringBuilder[BigField.Height * SmallField.Height + 3];
            for (int i = 0; i < lines.Length; i++)
            {
                lines[i] = new StringBuilder();
            }
            int last = field.GetLastField();

            for (int i = 0; i < BigField.Height; i++)
            {
                for (int j = 0; j < BigField.Width; j++)
                {
                    SmallField smallField = field.GetField(j, i);
                    for (int ii = 0; ii < SmallField.Height; ii++)
                    {
                        for (int jj = 0; jj < SmallField.Width; jj++)
                        {
                            CharField charField = smallField.GetField(jj, ii);
                            lines [i * BigField.Height + ii].Append(charField.GetSymbol());
                        }
                        if (i == last / BigField.Width && j == last % BigField.Width && last != -1)
                        {
                            lines[i * BigField.Height + ii].Append('|');
                        }
                        else if (smallField.GetSymbol() != Field.Nol)
                        {
                            lines[i * BigField.Height + ii].Append('#');
                        }
                        else
                        {
                            lines[i * BigField.Height + ii].Append(' ');
                        }
                    }
                }
            }
            for (int i = 0; i < BigField.Height; i++)
            {
                for (int j = 0; j < SmallField.Height; j++)
                {
                    Console.WriteLine(lines[i * BigField.Height + j].ToString());
                }
                Console.WriteLine();
            }
        }
예제 #4
0
        public virtual void SetSymbol(int bigFieldX, int bigFieldY, int smallFieldX, int smallFieldY)
        {
            int lastField  = _field.GetLastField();
            int lastFieldX = lastField % BigField.Width;
            int lastFieldY = lastField / BigField.Height;

            if ((bigFieldX == lastFieldX && bigFieldY == lastFieldY) || (lastField == -1))
            {
                SmallField current = _field.GetField(bigFieldX, bigFieldY);
                _field.SetSymbol(bigFieldX, bigFieldY, smallFieldX, smallFieldY, _symbols[_count % _symbols.Length]);
                IsSmallGameOver(current);
                IsGameOver();
                _count++;
                _view.Update(_field);
            }
            else
            {
                Console.WriteLine("WHAAAAT!");
            }
        }