public void Start() { #region Validation if (_gameStatus != GameStatus.ReadyToStart) { throw new InvalidOperationException("Only game with status 'ReadyToStart' can be started"); } #endregion _gameStatus = GameStatus.InProgress; Field.EmptyCells = _gameLogic.CountEmptyCells(); // Тут можна використати const чи readonly значення if (Field.EmptyCells < 6) { throw new InvalidOperationException("Can't start game,not enought empty cells"); } int generateBigBubbles = 3; int generateSmallBubbles = 3; Cell[] bigBubbles = _bubbleGenerationStrategy.GenerateBigBubbles(Field, generateBigBubbles); PlaceBubblesOnField(bigBubbles); Field.EmptyCells -= generateBigBubbles; Cell[] smallBubbles = _bubbleGenerationStrategy.GenerateSmallBubbles(Field, generateSmallBubbles); PlaceBubblesOnField(smallBubbles); OnScoreChange(this, EventArgs.Empty); OnNextTurn(this, EventArgs.Empty); OnDraw(this, EventArgs.Empty); }
public void Start() { #region Validation if (_gameStatus != GameStatus.ReadyToStart) { throw new InvalidOperationException("Only game with status 'ReadyToStart' can be started"); } #endregion _gameStatus = GameStatus.InProgress; Field.CountEmptyCells(); if (Field.EmptyCells < 2 * _difficulty) { throw new InvalidOperationException("Can't start game! Not enought empty cells"); } Cell[] bigBubbles = _bubbleGenerationStrategy.GenerateBigBubbles(Field, _difficulty); Field.PlaceBubbles(bigBubbles); Field.EmptyCells -= _difficulty; Cell[] smallBubbles = _bubbleGenerationStrategy.GenerateSmallBubbles(Field, _difficulty); Field.PlaceBubbles(smallBubbles); OnDraw(this, EventArgs.Empty); }