public void Setup() { this.renderer = new ConsoleRenderer(); this.field = new GameField(2, 2); this.fieldMemoryManager = new FieldMemoryManager(); this.balloonsFactory = new BalloonsFactory(); this.field[0, 0] = new BalloonOne(); this.field[0, 1] = new BalloonTwo(); this.field[1, 0] = new BalloonThree(); this.field[1, 1] = new BalloonFour(); }
public ICommand ProcessCommand( string commandString, IRenderer renderer, IGameField field, IFieldMemoryManager fieldMemoryManager, IBalloonsFactory balloonsFactory) { var commandParts = this.SplitCommandString(commandString); string commandName = commandParts[0]; int rowPosition = -1; int colPosition = -1; if (commandParts.Length == 3) { bool rowAndColumnPopulated = !(string.IsNullOrWhiteSpace(commandParts[1]) && string.IsNullOrWhiteSpace(commandParts[2])); bool rowAsInteger = int.TryParse(commandParts[1], out rowPosition); bool columnAsInteger = int.TryParse(commandParts[2], out colPosition); if (rowAndColumnPopulated && rowAsInteger && columnAsInteger) { rowPosition--; colPosition--; } else { rowPosition = InvalidRowAndColumnPosition; colPosition = InvalidRowAndColumnPosition; } } switch (commandName) { case "pop": { return new PopBalloonsCommand(balloonsFactory, field, rowPosition, colPosition); } case "top": { return new TopScoresCommand(renderer); } case "save": { return new SaveCommand(fieldMemoryManager, field); } case "restore": { return new RestoreCommand(fieldMemoryManager, field); } case "help": { return new HelpCommand(renderer); } case "exit": { return new ExitCommand(renderer); } default: { throw new InvalidOperationException("Invalid command request!"); } } }
public void Setup() { this.renderer = new ConsoleRenderer(); this.field = new GameField(5, 5); this.fieldMemoryManager = new FieldMemoryManager(); this.balloonsFactory = new BalloonsFactory(); }
public SaveCommand(IFieldMemoryManager fieldMemoryManager, IGameField field) { this.field = field; this.fieldMemoryManager = fieldMemoryManager; this.Name = "save"; }
public BalloonsGameEngine FieldMemoryManager(IFieldMemoryManager fieldMemoryManager) { this.engineContext.FieldMemoryManager = fieldMemoryManager; return this; }
public RestoreCommand(IFieldMemoryManager fieldMemorizerManager, IGameField field) { this.field = field; this.fieldMemorizerManager = fieldMemorizerManager; this.Name = "restore"; }