From 2d42e3a247d85272b7a123e3ed099a5bbefaae8d Mon Sep 17 00:00:00 2001 From: Lucas Garron Date: Thu, 3 Oct 2024 05:08:08 -0700 Subject: [PATCH] [puzzle-geometry] Rename several icosehedral puzzles. As suggested at: https://github.com/cubing/cubing.js/issues/336 --- .../src/import-restrictions/allowedImports.ts | 3 +++ src/bin/puzzle-geometry-bin.ts | 4 ++-- src/cubing/puzzle-geometry/PGPuzzles.spec.ts | 12 +++++------- src/cubing/puzzle-geometry/PGPuzzles.ts | 15 +++++++++++---- .../puzzle-geometry/cubing-private/index.ts | 1 + src/sites/alpha.twizzle.net/explore/url-params.ts | 8 +++++++- 6 files changed, 29 insertions(+), 14 deletions(-) create mode 100644 src/cubing/puzzle-geometry/cubing-private/index.ts diff --git a/script/test/src/import-restrictions/allowedImports.ts b/script/test/src/import-restrictions/allowedImports.ts index 1bdc7b179..b9196e69b 100644 --- a/script/test/src/import-restrictions/allowedImports.ts +++ b/script/test/src/import-restrictions/allowedImports.ts @@ -148,6 +148,9 @@ export const mainAllowedImports: AllowedImports = { "src/sites/experiments.cubing.net/cubing.js/rust/wasm": { static: ["getbuiltinmodule-ponyfill"], }, + "src/sites/alpha.twizzle.net/explore": { + static: ["src/cubing/puzzle-geometry/cubing-private"], + }, }; // This is a separate definition because the `spec` files are interleaved with source files, and it's easier to run a separate check for them. diff --git a/src/bin/puzzle-geometry-bin.ts b/src/bin/puzzle-geometry-bin.ts index a4b896b4f..fd0025b0c 100644 --- a/src/bin/puzzle-geometry-bin.ts +++ b/src/bin/puzzle-geometry-bin.ts @@ -142,8 +142,8 @@ little chop, pyramorphix, mastermorphix, pyraminx, Jing pyraminx, master paramorphix, megaminx, gigaminx, pentultimate, starminx, starminx 2, pyraminx crystal, chopasaurus, big chop, skewb diamond, FTO, Christopher's jewel, octastar, Trajber's octahedron, radio chop, -icosamate, icosahedron 2, icosahedron 3, icosahedron static faces, -icosahedron moving faces, and Eitan's star. +icosamate, Regular Astrominx, Regular Astrominx + Big Chop, +Redicosahedron, Icosaminx, and Eitan's star. Examples: puzzlegeometry --ss 2x2x2 diff --git a/src/cubing/puzzle-geometry/PGPuzzles.spec.ts b/src/cubing/puzzle-geometry/PGPuzzles.spec.ts index d5aef6298..04a348ad8 100644 --- a/src/cubing/puzzle-geometry/PGPuzzles.spec.ts +++ b/src/cubing/puzzle-geometry/PGPuzzles.spec.ts @@ -80,14 +80,12 @@ const expectedData: { [name: string]: string | null } = { "Trajber's octahedron": "Trajber's octahedron, 8, 7, 26, 3, 9, 120", "radio chop": "radio chop, 20, 10, 92, 3, 20, 41580", icosamate: slow("icosamate, 20, 4, 32, 2, 12, 720"), - "icosahedron 2": slow("icosahedron 2, 20, 9, 102, 3, 18, 432630"), - "icosahedron 3": slow("icosahedron 3, 20, 18, 360, 6, 48, 1615854240"), - "icosahedron static faces": slow( - "icosahedron static faces, 20, 7, 62, 3, 18, 180", - ), - "icosahedron moving faces": slow( - "icosahedron moving faces, 20, 7, 62, 3, 18, 180", + "Regular Astrominx": slow("Regular Astrominx, 20, 9, 102, 3, 18, 432630"), + "Regular Astrominx + Big Chop": slow( + "Regular Astrominx + Big Chop, 20, 18, 360, 6, 48, 1615854240", ), + Redicosahedron: slow("Redicosahedron, 20, 7, 62, 3, 18, 180"), + Icosaminx: slow("Icosaminx, 20, 7, 62, 3, 18, 180"), "Eitan's star": slow("Eitan's star, 20, 13, 152, 4, 30, 384560"), "2x2x2 + dino": "2x2x2 + dino, 6, 8, 24, 1, 18, 70", "2x2x2 + little chop": "2x2x2 + little chop, 6, 8, 48, 2, 18, 168", diff --git a/src/cubing/puzzle-geometry/PGPuzzles.ts b/src/cubing/puzzle-geometry/PGPuzzles.ts index 4e87a46ef..433bce536 100644 --- a/src/cubing/puzzle-geometry/PGPuzzles.ts +++ b/src/cubing/puzzle-geometry/PGPuzzles.ts @@ -72,10 +72,10 @@ export const PGPuzzles: { [name: string]: PuzzleDescriptionString } = { "Trajber's octahedron": "o v 0.433012701892219", "radio chop": "i f 0", icosamate: "i v 0", - "icosahedron 2": "i v 0.18759247376021", - "icosahedron 3": "i v 0.18759247376021 e 0", - "icosahedron static faces": "i v 0.84", - "icosahedron moving faces": "i v 0.73", + "Regular Astrominx": "i v 0.18759247376021", + "Regular Astrominx + Big Chop": "i v 0.18759247376021 e 0", + Redicosahedron: "i v 0.84", + Icosaminx: "i v 0.73", "Eitan's star": "i f 0.61803398874989", "2x2x2 + dino": "c f 0 v 0.577350269189626", "2x2x2 + little chop": "c f 0 e 0", @@ -85,4 +85,11 @@ export const PGPuzzles: { [name: string]: PuzzleDescriptionString } = { "starminx combo": "d f 0.23606797749979 v 0.937962370425399", }; +export const legacyPuzzleNameMapping: Partial> = { + "icosahedron 2": "Regular Astrominx", + "icosahedron 3": "Regular Astrominx + Big Chop", + "icosahedron static faces": "Redicosahedron", + "icosahedron moving faces": "Icosaminx", +}; + export type PuzzleName = keyof typeof PGPuzzles; diff --git a/src/cubing/puzzle-geometry/cubing-private/index.ts b/src/cubing/puzzle-geometry/cubing-private/index.ts new file mode 100644 index 000000000..b3aab1538 --- /dev/null +++ b/src/cubing/puzzle-geometry/cubing-private/index.ts @@ -0,0 +1 @@ +export { legacyPuzzleNameMapping } from "../PGPuzzles"; diff --git a/src/sites/alpha.twizzle.net/explore/url-params.ts b/src/sites/alpha.twizzle.net/explore/url-params.ts index 86b5df374..b04bb800e 100644 --- a/src/sites/alpha.twizzle.net/explore/url-params.ts +++ b/src/sites/alpha.twizzle.net/explore/url-params.ts @@ -1,12 +1,13 @@ // TODO: implement URL listener. import { Alg } from "../../../cubing/alg"; +import { legacyPuzzleNameMapping } from "../../../cubing/puzzle-geometry/cubing-private"; export interface PartialURLParamValues { alg?: Alg; puzzle?: string; puzzlegeometry?: string; - "puzzle-description": string; + "puzzle-description"?: string; "debug-show-render-stats"?: boolean; tempo?: string; } @@ -135,3 +136,8 @@ export function setURLParams(newParams: PartialURLParamValues): void { } window.history.replaceState("", "", url.toString()); } + +const remappedPuzzleName = legacyPuzzleNameMapping[getURLParam("puzzle")]; +if (remappedPuzzleName) { + setURLParams({ puzzle: remappedPuzzleName }); +}