Skip to content

Commit

Permalink
Oops that function actually returns the C of the linekey, not X
Browse files Browse the repository at this point in the history
  • Loading branch information
Naviary2 committed Jan 27, 2025
1 parent 33bb7c0 commit 768906a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/client/scripts/esm/chess/logic/legalmoves.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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}
*/
Expand Down
6 changes: 3 additions & 3 deletions src/client/scripts/esm/chess/logic/organizedlines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ interface PieceLinesByKey {
[line: LineKey]: Array<Piece>
}

/** 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)
Expand Down Expand Up @@ -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]);
}

Expand Down Expand Up @@ -408,7 +408,7 @@ export default {
buildStateFromKeyList,
getKeyFromLine,
getCFromLine,
getXFromKey,
getCFromKey,
areColinearSlidesPresentInGame,
areHippogonalsPresentInGame,
};

0 comments on commit 768906a

Please sign in to comment.