Fixed typeError on vitest
This commit is contained in:
parent
cb9371b33b
commit
71b24fedee
@ -19,6 +19,7 @@ const wsService = new WebSocketService(import.meta.env.VITE_API_WS);
|
|||||||
// TODO bug, when refreshing page, some data is missing until other clients make a move
|
// TODO bug, when refreshing page, some data is missing until other clients make a move
|
||||||
// TODO bug, teleportation doesn't work
|
// TODO bug, teleportation doesn't work
|
||||||
|
|
||||||
|
// TODO guest users
|
||||||
// TODO store map in backend and save it in state on each client
|
// TODO store map in backend and save it in state on each client
|
||||||
// TODO add debug menu on dev, for testing and cheating
|
// TODO add debug menu on dev, for testing and cheating
|
||||||
// TODO sign up player page
|
// TODO sign up player page
|
||||||
|
@ -18,26 +18,26 @@ export default function findPossiblePositions(board: GameMap, character: Charact
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uses recursion to move through the board and find all the possible positions
|
* Uses recursion to move through the map and find all the possible positions
|
||||||
* @param board The board the character is on
|
* @param map The map the character is on
|
||||||
* @param currentPath The current path the character is on
|
* @param currentPath The current path the character is on
|
||||||
* @param steps The number of steps the character can move
|
* @param steps The number of steps the character can move
|
||||||
* @param character The current character
|
* @param character The current character
|
||||||
* @param characters
|
* @param characters
|
||||||
* @returns An array of paths the character can move to
|
* @returns An array of paths the character can move to
|
||||||
*/
|
*/
|
||||||
function findPossibleRecursive(board: GameMap, currentPath: Path, steps: number, character: Character, characters: Character[]): Path[] {
|
function findPossibleRecursive(map: GameMap, currentPath: Path, steps: number, character: Character, characters: Character[]): Path[] {
|
||||||
|
|
||||||
const paths: Path[] = [];
|
const paths: Path[] = [];
|
||||||
if (isOutsideBoard(currentPath, board.length)) { // TODO not working on new map
|
if (isOutsideBoard(currentPath, map.length)) { // TODO not working on new map
|
||||||
if (character.isPacMan()) {
|
if (character.isPacMan()) {
|
||||||
return addTeleportationTiles(board, currentPath, steps, character, characters);
|
return addTeleportationTiles(map, currentPath, steps, character, characters);
|
||||||
}
|
}
|
||||||
} else if (!isWall(board, currentPath)) {
|
} else if (!isWall(map, currentPath)) {
|
||||||
|
|
||||||
if (!characterHitsAnotherCharacter(character, currentPath, characters)) {
|
if (!characterHitsAnotherCharacter(character, currentPath, characters)) {
|
||||||
if (steps <= 0) {
|
if (steps <= 0) {
|
||||||
if (!(isSpawn(board, currentPath) && !isOwnSpawn(currentPath, character))) {
|
if (!(isSpawn(map, currentPath) && !isOwnSpawn(currentPath, character))) {
|
||||||
paths.push(currentPath);
|
paths.push(currentPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ function findPossibleRecursive(board: GameMap, currentPath: Path, steps: number,
|
|||||||
|
|
||||||
steps--;
|
steps--;
|
||||||
for (const direction of getDirections()) {
|
for (const direction of getDirections()) {
|
||||||
paths.push(...tryMove(board, currentPath, direction, steps, character, characters));
|
paths.push(...tryMove(map, currentPath, direction, steps, character, characters));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
export const getData: Api = async (path, {headers} = {}) => {
|
export const getData: Api = async (path, {headers} = {}) => {
|
||||||
|
if (import.meta.env.MODE === "test") return Promise.resolve(new Response(JSON.stringify([])));
|
||||||
return await fetch(import.meta.env.VITE_API_HTTP + path, {
|
return await fetch(import.meta.env.VITE_API_HTTP + path, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: headers
|
headers: headers
|
||||||
|
Loading…
x
Reference in New Issue
Block a user