public ConsoleView(BigField field) { this._field = field; _thread = new Thread(this.Read); _thread.Start(); Console.WriteLine("Game started. First is X!"); }
public static void Main(string[] args) { BigField field = new BigField(); ConsoleView view = new ConsoleView(field); BigFieldController controller = new BigFieldController(view, field); controller.NewGame(); }
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; }
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(); } }
public void NewGame() { _count = 0; _field = new BigField(); _view.Update(_field); }
public abstract void Update(BigField field);