public static bool MakeStep(int stepCount, Cell[] map, Figure figure) { if (stepCount == 0) { return(false); } var targetLocation = figure.Location + stepCount; if (map[figure.Location] is HouseOfWater) { switch (stepCount) { case 4: map[figure.Location].State = null; CurrentPlayer.FigureInTheHouseOfWater = null; return(true); case 5: return(false); default: MoveToHouseOfRevival(map, figure); CurrentPlayer.FigureInTheHouseOfWater = null; return(true); } } if (targetLocation < map.Length && map[targetLocation] is IFinalHouse && !(map[figure.Location] is IFinalHouse)) { StepToHouseOfBeauty(map, figure); CurrentPlayer.FigureInTheHouseOfBeauty = figure; return(true); } if (map[figure.Location] is HouseOfBeauty) { if (stepCount == 5) { StepOut(stepCount, map, figure); } else { if (map[targetLocation].State == null) { SimpleStep(stepCount, map, figure); } else { var temp = map[targetLocation].State; MoveToHouseOfRevival(map, temp); SimpleStep(stepCount, map, figure); } if (stepCount == 1) { CurrentPlayer.FigureInTheHouseOfWater = figure; } } CurrentPlayer.FigureInTheHouseOfBeauty = null; return(true); }//Вложенность if (map.Length - figure.Location <= 3) { return(StepOut(stepCount, map, figure)); } if (map[figure.Location + stepCount].State != null) { map[figure.Location + stepCount].State.IsFree = !CheckNeighbors(map, map[figure.Location + stepCount].State); } if (map[targetLocation].State == null) { SimpleStep(stepCount, map, figure); return(true); } if (map[targetLocation].State != null && map[targetLocation].State.IsFree && map[targetLocation].State.Type != figure.Type) { StepWithCut(stepCount, map, figure); return(true); } return(false); }
private static void SimpleStep(int stepCount, Cell[] map, Figure figure) { map[figure.Location + stepCount].State = map[figure.Location].State; map[figure.Location].State = null; figure.Location += stepCount; }