From 768906a1a4975b76021689656a294be59f5f1df3 Mon Sep 17 00:00:00 2001 From: Naviary2 Date: Mon, 27 Jan 2025 00:54:28 -0700 Subject: [PATCH] Oops that function actually returns the C of the linekey, not X --- src/client/scripts/esm/chess/logic/legalmoves.js | 5 +++-- src/client/scripts/esm/chess/logic/organizedlines.ts | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/client/scripts/esm/chess/logic/legalmoves.js b/src/client/scripts/esm/chess/logic/legalmoves.js index 28500b7f..6788d2ed 100644 --- a/src/client/scripts/esm/chess/logic/legalmoves.js +++ b/src/client/scripts/esm/chess/logic/legalmoves.js @@ -15,6 +15,7 @@ import jsutil from '../../util/jsutil.js'; import coordutil from '../util/coordutil.js'; import winconutil from '../util/winconutil.js'; import movesets from './movesets.js'; +import math from '../../util/math.js'; // Import End /** @@ -149,7 +150,7 @@ function calculate(gamefile, piece, { onlyCalcSpecials = false } = {}) { // piec const lines = gamefile.startSnapshot.slidingPossible; for (let i = 0; i < lines.length; i++) { const line = lines[i]; // [x,y] - const lineKey = coordutil.getKeyFromVec2(line); // 'x,y' + const lineKey = math.getKeyFromVec2(line); // 'x,y' if (!thisPieceMoveset.sliding[lineKey]) continue; const key = organizedlines.getKeyFromLine(line, coords); legalSliding[line] = slide_CalcLegalLimit(blockingFunc, gamefile.piecesOrganizedByLines[line][key], line, thisPieceMoveset.sliding[lineKey], coords, color); @@ -178,7 +179,7 @@ function calculate(gamefile, piece, { onlyCalcSpecials = false } = {}) { // piec * @param {gamefile} gamefile * @param {Piece} piece * @param {Vec2} slide - * @param {Vec2Key} lineKey - The key `X|C` of the specific organized line we need to find out how far this piece can slide on + * @param {Vec2Key} lineKey - The key `C|X` of the specific organized line we need to find out how far this piece can slide on * @param {Piece[]} organizedLine - The organized line of the above key that our piece is on * @returns {undefined | Coords} */ diff --git a/src/client/scripts/esm/chess/logic/organizedlines.ts b/src/client/scripts/esm/chess/logic/organizedlines.ts index cc7efd62..4996ad80 100644 --- a/src/client/scripts/esm/chess/logic/organizedlines.ts +++ b/src/client/scripts/esm/chess/logic/organizedlines.ts @@ -74,7 +74,7 @@ interface PieceLinesByKey { [line: LineKey]: Array } -/** A unique identifier for a single line of pieces. `X|C` */ +/** A unique identifier for a single line of pieces. `C|X` */ type LineKey = `${number}|${number}` // (Deleted "use strict" as I don't think it has an effect if we're using typescript) @@ -342,7 +342,7 @@ function getXFromLine(step: Coords, coords: Coords): number { } /** Splits the `C` value out of the line key */ -function getXFromKey(lineKey: LineKey): number { +function getCFromKey(lineKey: LineKey): number { return Number(lineKey.split('|')[0]); } @@ -408,7 +408,7 @@ export default { buildStateFromKeyList, getKeyFromLine, getCFromLine, - getXFromKey, + getCFromKey, areColinearSlidesPresentInGame, areHippogonalsPresentInGame, }; \ No newline at end of file