Skip to content

Commit

Permalink
Fix up JS.
Browse files Browse the repository at this point in the history
  • Loading branch information
lgarron committed Aug 28, 2023
1 parent f80b746 commit 7fd8004
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/js/dev/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { setKPuzzleDefString, solveState, serializeDefToTws } from "..";
await setKPuzzleDefString(
serializeDefToTws(await cube3x3x3.kpuzzle(), {
moveSubset: ["U", "L", "F", "R", "B", "D"],
startState: `EDGES
startPattern: `EDGES
0 0 0 0 1 2 3 4 5 6 7 8
0 0 0 0 0 0 0 0 0 0 0 0
CORNERS
Expand Down
14 changes: 7 additions & 7 deletions src/js/serialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function serializeScrambleState(name: string, t: KPatternData): string {

export function serializeDefToTws(
kpuzzle: KPuzzle,
options?: { moveSubset?: string[]; startState?: string },
options?: { moveSubset?: string[]; startPattern?: string },
): string {
const outputLines: string[] = [];
const def = kpuzzle.definition;
Expand All @@ -62,19 +62,19 @@ export function serializeDefToTws(
outputLines.push(BLANK_LINE);

outputLines.push("StartState");
if (options?.startState) {
outputLines.push(options?.startState);
if (options?.startPattern) {
outputLines.push(options?.startPattern);
} else {
for (const [orbitName, orbitDef] of Object.entries(def.defaultPattern)) {
for (const [orbitName, orbitData] of Object.entries(def.defaultPattern)) {
outputLines.push(sanitize(orbitName));
outputLines.push(orbitDef.pieces.join(" "));
outputLines.push(orbitDef.orientation.join(" "));
outputLines.push(orbitData.pieces.join(" "));
outputLines.push(orbitData.orientation.join(" "));
}
}
outputLines.push(END);
outputLines.push(BLANK_LINE);

function include(moveName): boolean {
function include(moveName: string): boolean {
if (options?.moveSubset) {
return options.moveSubset.includes(moveName);
} else {
Expand Down

0 comments on commit 7fd8004

Please sign in to comment.