示例#1
0
        public bool CanPlace(PlayerType playerType, ShipType shipType, Point coordinate, Direction direction)
        {
            var player = this._players[playerType];

            var shipToPlace = player.Ships.Single(x => x.GetType() == shipType.EnumToType());

            return(!shipToPlace.Placed && _playersMaps[playerType].CanPlace(shipToPlace, coordinate, direction));
        }
示例#2
0
        public void Place(PlayerType playerType, ShipType shipType, Point coordinate, Direction direction)
        {
            var player = this._players[playerType];

            var shipToPlace = player.Ships.Single(x => x.GetType() == shipType.EnumToType());

            if (shipToPlace.Placed)
            {
                throw new InvalidOperationException($"{shipType} has already been placed");
            }

            _playersMaps[playerType].Place(shipToPlace, coordinate, direction);
        }