Example #1
0
 public ConsoleView(BigField field)
 {
     this._field = field;
     _thread     = new Thread(this.Read);
     _thread.Start();
     Console.WriteLine("Game started. First is X!");
 }
Example #2
0
        public static void Main(string[] args)
        {
            BigField           field      = new BigField();
            ConsoleView        view       = new ConsoleView(field);
            BigFieldController controller = new BigFieldController(view, field);

            controller.NewGame();
        }
Example #3
0
 public BigFieldController(View view, BigField field)
 {
     this._view            = view;
     this._view.SetSymbol += this.SetSymbol;
     this._view.NewGame   += this.NewGame;
     _symbols              = new char[2] {
         Field.Tic, Field.Tac
     };
     this._field = field;
 }
Example #4
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();
            }
        }
Example #5
0
 public void NewGame()
 {
     _count = 0;
     _field = new BigField();
     _view.Update(_field);
 }
Example #6
0
 public abstract void Update(BigField field);