Пример #1
0
        public List <string> CheckQuarter(int xStep, int yStep, Position position, ChessboardModel chessboard, bool addNextStep = true)
        {
            var  possibleMovies  = new List <string>();
            bool doNextIteration = false;
            var  colour          = chessboard[position].Piece.Colour;

            do
            {
                position.X += xStep;
                position.Y += yStep;
                TypeOfField typeOfField = chessboard.GetTypeOfField(position);

                if (addNextStep)
                {
                    doNextIteration = DoNextIteration(typeOfField);
                }

                if (IsMovePossible(typeOfField, colour))
                {
                    possibleMovies.Add(position.ToString());
                }
            }while (doNextIteration);

            return(possibleMovies);
        }
Пример #2
0
        public void Should_ConvertTextTypeOfFieldEnumToStringType_Success()
        {
            TypeOfField inputTypeOfField = TypeOfField.Text;

            string result = ConvertHelper.ConvertTypeOfFieldEnumToStringType(inputTypeOfField);

            Assert.AreEqual("string", result);
        }
Пример #3
0
        private int _countNumberOfFieldsdWithGivenType(GameLogic gameLogic, TypeOfField typeOfField)
        {
            var map = gameLogic.Map;
            int numberOfSnakeParts = 0;

            for (int i = 0; i < GameLogic.SIZE; i++)
            {
                for (int j = 0; j < GameLogic.SIZE; j++)
                {
                    if (map[i, j] == typeOfField)
                    {
                        numberOfSnakeParts++;
                    }
                }
            }
            return(numberOfSnakeParts);
        }
Пример #4
0
        private Point _findLocationOfFieldOfGivenType(GameLogic gameLogic, TypeOfField typeOfField)
        {
            Point toReturn = new Point(-1, -1);
            var   map      = gameLogic.Map;

            for (int i = 0; i < GameLogic.SIZE; i++)
            {
                for (int j = 0; j < GameLogic.SIZE; j++)
                {
                    if (map[i, j] == typeOfField)
                    {
                        toReturn = new Point(i, j);
                        return(toReturn);
                    }
                }
            }
            return(toReturn);
        }
Пример #5
0
        private bool DoNextIteration(TypeOfField typeOfField)
        {
            switch (typeOfField)
            {
            case TypeOfField.Empty:
                return(true);

            case TypeOfField.OutOfRange:
                return(false);

            case TypeOfField.WhitePiece:
                return(false);

            case TypeOfField.BlackPiece:
                return(false);

            default:
                throw new ApplicationException("nieznany typ");
            }
        }
Пример #6
0
        private bool IsMovePossible(TypeOfField typeOfField, ColourOfPiece colour)
        {
            switch (typeOfField)
            {
            case TypeOfField.Empty:
                return(true);

            case TypeOfField.OutOfRange:
                return(false);

            case TypeOfField.WhitePiece:
                return(!IsColorTheSame(typeOfField, colour));

            case TypeOfField.BlackPiece:
                return(!IsColorTheSame(typeOfField, colour));

            default:
                throw new ApplicationException("nieznany typ");
            }
        }
Пример #7
0
 private void DrawGameArea(object sender, EventArgs e)
 {
     for (int i = 0; i < _gameLogic.Map.GetLength(0); i++)
     {
         for (int j = 0; j < _gameLogic.Map.GetLength(1); j++)
         {
             TypeOfField typeOfField = _gameLogic.Map[i, j];
             if (typeOfField == TypeOfField.Snake)
             {
                 _rectangles[i, j].Color = Brushes.ForestGreen;
             }
             else if (typeOfField == TypeOfField.Apple)
             {
                 _rectangles[i, j].Color = Brushes.DarkRed;
             }
             else
             {
                 _rectangles[i, j].Color = Brushes.Black;
             }
         }
     }
 }
Пример #8
0
 public static string ConvertTypeOfFieldEnumToStringType(TypeOfField typeOfField)
 {
     return(typeOfField == TypeOfField.Number ? "int" : "string");
 }
Пример #9
0
 public ObjectOnMap(int x, int y, TypeOfField typeOfField)
 {
     X           = x;
     Y           = y;
     TypeOfField = typeOfField;
 }
 public CreateAdditionalInfoDefinitionCommand(AdditionalInfoDefinitionCreateOrEditDto additionalInfoDefinitionCreateOrEditDto)
 {
     Id          = additionalInfoDefinitionCreateOrEditDto.Id;
     InfoName    = additionalInfoDefinitionCreateOrEditDto.InfoName;
     TypeOfField = additionalInfoDefinitionCreateOrEditDto.TypeOfField;
 }
        public async Task ShouldRequireFieldAndThrowValidationExceptionDuringArticleCreating(string infoName, TypeOfField typeOfField)
        {
            var loggedUser = await RunAsUserAsync("scott101@localhost", "Pa$$w0rd!");

            var additionalInfoDefinitionToCreate = new Faker <AdditionalInfoDefinitionCreateOrEditDto>("en")
                                                   .RuleFor(a => a.Id, f => f.Random.Guid())
                                                   .RuleFor(a => a.InfoName, f => infoName)
                                                   .RuleFor(a => a.TypeOfField, f => typeOfField)
                                                   .Generate();

            var command = new CreateAdditionalInfoDefinitionCommand(additionalInfoDefinitionToCreate);

            Func <Task> act = async() => await SendAsync(command);

            act.Should().Throw <Common.Exceptions.ValidationException>();
        }
Пример #12
0
 private bool IsColorTheSame(TypeOfField typeOfField, ColourOfPiece colour)
 {
     return(typeOfField == TypeOfField.BlackPiece && colour == ColourOfPiece.Black ||
            typeOfField == TypeOfField.WhitePiece && colour == ColourOfPiece.White);
 }