Skip to content

Commit

Permalink
Run linter
Browse files Browse the repository at this point in the history
  • Loading branch information
simonkellly committed May 22, 2024
1 parent 54e18c0 commit eb0a979
Showing 1 changed file with 41 additions and 20 deletions.
61 changes: 41 additions & 20 deletions src/lib/solutionParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,12 @@ export function convertToSliceMoves(moves: string[]) {

export function checkTransformationIsAlg(
transformation: KTransformation
): [isEdge3Cycle: boolean, isCorner3Cycle: boolean, is2E2C: boolean, isTwist: boolean] {
): [
isEdge3Cycle: boolean,
isCorner3Cycle: boolean,
is2E2C: boolean,
isTwist: boolean,
] {
const corners = transformation.transformationData['CORNERS'];
const edges = transformation.transformationData['EDGES'];

Expand Down Expand Up @@ -256,8 +261,14 @@ export function checkTransformationIsAlg(
cornerCount == 8 && edgeCount == 9 && cornerTwist == 0 && edgeFlip == 0,
cornerCount == 5 && edgeCount == 12 && cornerTwist == 0 && edgeFlip == 0,
cornerCount == 6 && edgeCount == 10 && cornerTwist == 0 && edgeFlip == 0,
(edgeFlip == 0 && cornerTwist == 2 && edgeCount == 12 && cornerCount == 6) ||
(edgeFlip == 2 && cornerTwist == 0 && edgeCount == 10 && cornerCount == 8),
(edgeFlip == 0 &&
cornerTwist == 2 &&
edgeCount == 12 &&
cornerCount == 6) ||
(edgeFlip == 2 &&
cornerTwist == 0 &&
edgeCount == 10 &&
cornerCount == 8),
];
}

Expand All @@ -273,7 +284,12 @@ function uncancelTransformation(
length: number;
} {
const initialCheck = checkTransformationIsAlg(transformation);
if (initialCheck[0] || initialCheck[1] || initialCheck[2] || initialCheck[3]) {
if (
initialCheck[0] ||
initialCheck[1] ||
initialCheck[2] ||
initialCheck[3]
) {
return {
alg: '',
isEdge: initialCheck[0],
Expand Down Expand Up @@ -339,7 +355,7 @@ export async function extractAlgs(
isEdge: boolean,
isCorner: boolean,
is2E2C: boolean,
isTwist: boolean
isTwist: boolean,
][] = [];

let moves = '';
Expand Down Expand Up @@ -393,7 +409,17 @@ export async function extractAlgs(
const isTwist = val[5];

const isAnyAlg = isEdgeComm || isCornerComm || isTwist || is2E2C;
const comment = " // " + (!isAnyAlg ? ' // ?' : (isEdgeComm ? "Edge" : isCornerComm ? "Corner" : isTwist ? "Twist/Flip" : "2E2C"));
const comment =
' // ' +
(!isAnyAlg
? ' // ?'
: isEdgeComm
? 'Edge'
: isCornerComm
? 'Corner'
: isTwist
? 'Twist/Flip'
: '2E2C');

const simplifiedComm = simplify(comm);
let foundComm: string | undefined;
Expand All @@ -402,7 +428,6 @@ export async function extractAlgs(
return [simplifiedComm.toString() + comment, moveIdx] as [string, number];
}


if (isEdgeComm || isTwist) {
const slicesWithRotations = convertToSliceMoves(
simplifiedComm.toString().split(' ')
Expand All @@ -415,12 +440,8 @@ export async function extractAlgs(
})[0];
}


if (!isAnyAlg) {
return [simplify(comm.trim()) + comment, moveIdx] as [
string,
number,
];
return [simplify(comm.trim()) + comment, moveIdx] as [string, number];
}

if (!foundComm || foundComm.endsWith('.')) {
Expand All @@ -438,15 +459,15 @@ export async function extractAlgs(
}

if (foundComm.endsWith('.')) {
return [simplify(comm.trim()) + comment + ' (comm not found)', moveIdx] as [
string,
number,
];
return [
simplify(comm.trim()) + comment + ' (comm not found)',
moveIdx,
] as [string, number];
}

return [foundComm.replaceAll(',', ', ').replaceAll(':', ': ') + comment, moveIdx] as [
string,
number,
];
return [
foundComm.replaceAll(',', ', ').replaceAll(':', ': ') + comment,
moveIdx,
] as [string, number];
});
}

0 comments on commit eb0a979

Please sign in to comment.