Esempio n. 1
0
        public IGameField Generate(Predicate <CellPosition> canUseCell)
        {
            if (!IsBuilderCorrect())
            {
                throw new InvalidOperationException("Builder contains incorrect ships");
            }
            var allShips = builder.ShipsLeft.SelectMany(x => Enumerable.Repeat(x.Key, x.Value)).ToList();

            TryAddAllShips(allShips, canUseCell);
            return(builder.Build());
        }
Esempio n. 2
0
        private void StartGameHandle(object sender, RoutedEventArgs e)
        {
            var me = builder.Build();

            if (me == null)
            {
                MessageBox.Show(this, "Поле заполнено некорректно!");
                return;
            }
            builder = null;

            //TODO Make with Ninject
            controller = new GameController(new RandomPlayer(me), container.Get <IPlayer>());
            HideGroup(BuilderElements);
            ShowGroup(GameFieldElements);
            UpdateGameFields();
            UpdateCurrentPlayerStatus();
        }