Skip to content

Commit

Permalink
Surely
Browse files Browse the repository at this point in the history
  • Loading branch information
Arsoniv committed Feb 23, 2025
1 parent 8621357 commit 0a7d9ad
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions src/boardCreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ export function generateBoard(width: number, height: number, mines: number): Boa
board[y][x] = mineCount;
}
}
let hiddenBoard = board;

hiddenBoard.forEach((row) => {
board.forEach((row) => {
row.forEach((cell) => {
if (cell !== -1){
cell = 0;
Expand Down
18 changes: 7 additions & 11 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ let userTokens: UserAuthToken[] = [];
let matches: Match[] = [];

const app: Application = express();
const PORT = 80;
const PORT = 3000;

app.use(cors());
app.use(express.json());
Expand Down Expand Up @@ -399,12 +399,12 @@ const handleMessage = async (message: string, id: number) => {

const match = matches.find((match) => {
if ((match.players.some((user) => user.id === id)&& !match.matchEnded)) return true;
});
})

const softMatch = matches.find((match, index) => {
const softMatch = matches.find((match) => {
if (match.players.some((user) => user.id === id)&&match.startTime === matchST&& matchST !== undefined) {
return true;
};
}
});

const matchIndex = matches.findIndex((match) => {
Expand All @@ -413,7 +413,7 @@ const handleMessage = async (message: string, id: number) => {

const playerIndex = match?.players.findIndex((user) => user.id === id);

if (request.type === 3) { // client forfiet
if (request.type === 3) { // client forfeit
if (!match || playerIndex === undefined || match.matchEnded) return;

match.matchEnded = true;
Expand Down Expand Up @@ -697,11 +697,7 @@ const checkQueues = ():void => {

setTimeout(() => {
const i = matches.findIndex((match) => {
if (match.startTime === newMatchObject.startTime) {
return true;
}else {
return false;
}
return match.startTime === newMatchObject.startTime;
})

if (matches[i]) {
Expand Down Expand Up @@ -740,7 +736,7 @@ const handleDisconnect = (id: number): void => {
}
})
})
matches.forEach((match, index2) => {
matches.forEach((match) => {
match.players.forEach(async (player, index) => {
if (player.id === id) {

Expand Down
4 changes: 2 additions & 2 deletions src/solver.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default class MinesweeperSolver {
private board: number[][];
private rows: number;
private cols: number;
private readonly rows: number;
private readonly cols: number;

constructor(board: number[][]) {
this.board = board;
Expand Down

0 comments on commit 0a7d9ad

Please sign in to comment.