// *** METHODS *** /// <summary> /// Parses a notation string into a LayerMove /// </summary> /// <param name="notation">Defines to string to be parsed</param> /// <returns></returns> public static LayerMove Parse(string notation) { string layer = notation[0].ToString(); CubeFlag rotationLayer = CubeFlagService.Parse(layer); char[] ccwChars = new char[] { '\'', 'i' }; bool direction = !ccwChars.Any(c => notation.Contains(c)); bool twice = notation.Contains("2"); return(new LayerMove(rotationLayer, direction, twice)); }
/// <summary> /// Parses a notation string into a layer move /// </summary> /// <param name="notation">String to be parsed</param> /// <param name="move">The resulting layer move</param> /// <returns>True, if the string was successfully parsed into a layermove</returns> public static bool TryParse(string notation, out LayerMove move) { move = null; string layer = notation[0].ToString(); CubeFlag rotationLayer = CubeFlagService.Parse(layer); char[] ccwChars = new char[] { '\'', 'i' }; bool direction = !ccwChars.Any(c => notation.Contains(c)); bool twice = notation.Contains("2"); if (CubeFlagService.CountFlags(rotationLayer) == 1) { move = new LayerMove(rotationLayer, direction, twice); return(true); } else { return(false); } }