/// <summary> /// A constructor for the class. /// </summary> /// <param name="boardWidth">The board width the constructor uses.</param> /// <param name="boardHeight">The board height the constructor uses.</param> /// <param name="renderer">The interface passed to the constructor.</param> public Game(int boardWidth, int boardHeight, IRenderer renderer) { this.gameBoard = new Gameboard(boardWidth, boardHeight, new RecursivePopStrategy(), new NormalGravityStrategy()); this.score = new Score("anonimous", 0); this.renderer = renderer; }
/// <summary> /// A method used for drawing the gameboard on the console. /// </summary> /// <param name="gameboard">The instance of the Gameboard the method is called upon.</param> public void RenderGameboard(Gameboard gameboard) { Console.ResetColor(); Console.WriteLine(" 0 1 2 3 4 5 6 7 8 9"); Console.WriteLine(" --------------------"); for (int i = 0; i < gameboard.BoardHeight; i++) { Console.Write(i.ToString() + " | "); for (int j = 0; j < gameboard.BoardWidth; j++) { BoardComponent component = gameboard.GetElement(i, j); this.SwitchConsoleColor(component.Color); if (!component.IsActive) { Console.Write('-'); } else { Console.Write("O"); } Console.ResetColor(); Console.Write(" "); } Console.WriteLine("| "); } Console.WriteLine(" --------------------"); this.PrintListOfCommands(); Console.WriteLine("Insert row and column or other command"); }