public void WhenISplit(ActionSide side, string countWord, Location from, Location to) { var count = CommonSteps.ParseWordNumber(countWord); Assert.NotNull(_context.BoardState, "Board State has not been initialized."); var action = new GameSplitAction { Location = from, Side = side, Target = to, Size = count }; TryApplyAction(action, from, to); }
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); }
public void WhenIMovePointsDirection(ActionSide side, Location from, string distance, string direction) { Assert.NotNull(_context.BoardState, "Board State has not been initialized."); var distanceInt = CommonSteps.ParseWordNumber(distance); Movement.Mover directionFunc; switch (direction.ToLower().Trim()) { case "north": directionFunc = Movement.North; break; case "south": directionFunc = Movement.South; break; case "northeast": case "north-east": case "north east": directionFunc = Movement.NorthEast; break; case "northwest": case "north-west": case "north west": directionFunc = Movement.NorthWest; break; case "southeast": case "south-east": case "south east": directionFunc = Movement.SouthEast; break; case "southwest": case "south-west": case "south west": directionFunc = Movement.SouthWest; break; default: throw new ArgumentOutOfRangeException(nameof(direction), direction, "Was not a recognizable movement direction."); } var canPassRedWall = side == ActionSide.Blue ? Movement.Red.CanWrap : Movement.Red.CannotWrap; var canPassBlueWall = side == ActionSide.Red ? Movement.Blue.CanWrap : Movement.Blue.CannotWrap; var to = from; for (var i = 0; i < distanceInt; i++) { var next = directionFunc(to, canPassBlueWall, canPassRedWall, Movement.UnmarkedEdges.CannotWrap); if (!Movement.IsValidLocation(next)) { _context.LastMessage = $"Unable to reach point {i + 1} {direction} from {to} (starting from {from})"; Console.WriteLine(_context.LastMessage); return; } to = next; } var action = new GameMoveAction { Location = from, Side = side, Target = to }; TryApplyAction(action, from, to); }