예제 #1
0
        private static ValidationType ValidateLocationSideCountInternal(ActionSide side, string countWord, Location location)
        {
            var count      = CommonSteps.ParseWordNumber(countWord);
            var validation = new ValidationType {
                Location = location, Size = count, Type = ValidationFlag.Normal
            };

            if (side == ActionSide.Blue)
            {
                validation.Contents = ValidationPiece.Blue;
            }
            else if (side == ActionSide.Red)
            {
                validation.Contents = ValidationPiece.Red;
            }

            return(validation);
        }
예제 #2
0
        public static bool ValidateRow(this StringBuilder errorLog, State actual, ValidationType validation)
        {
            Cell expected = 0, mask = 0;

            if (validation.Type.HasValue)
            {
                mask = Cell.Blessed | Cell.Cursed | Cell.King;
                switch (validation.Type.Value)
                {
                case ValidationFlag.Blessed:
                    expected = Cell.Blessed;
                    break;

                case ValidationFlag.Cursed:
                    expected = Cell.Cursed;
                    break;

                case ValidationFlag.King:
                    expected = Cell.King;
                    break;

                case ValidationFlag.BlessedKing:
                    expected = Cell.Blessed | Cell.King;
                    break;
                }
            }

            if (validation.Size.HasValue)
            {
                expected |= (Cell)validation.Size;
                mask     |= Cell.SizeMask;
            }

            if (validation.Contents.HasValue)
            {
                switch (validation.Contents.Value)
                {
                case ValidationPiece.Empty:
                    expected = Cell.Empty;
                    mask     = ~(Cell)0;
                    break;

                case ValidationPiece.Red:
                    expected |= Cell.SideRed;
                    mask     |= Cell.SideRed;
                    break;

                case ValidationPiece.Blue:
                    mask |= Cell.SideRed;
                    break;

                case ValidationPiece.Block:
                    expected = Cell.Block;
                    mask     = ~(Cell)0;
                    break;

                case ValidationPiece.AnyColor:
                    mask |= Cell.Block;
                    break;
                }
            }

            Assert.IsTrue(Movement.IsValidLocation(validation.Location),
                          $"{validation.Location} (0x{((int) (validation.Location)):X2}) is not a board location.");
            return(errorLog.CheckPiece(expected, actual[validation.Location], mask));
        }