removed comments

This commit is contained in:
2026-01-03 14:45:14 +00:00
parent b046a85806
commit f7328d59eb
29 changed files with 266 additions and 351 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
import { addUser, removeUser } from "../state/connection.js";
const HEARTBEAT_INTERVAL = 30000; // 30 seconds
const HEARTBEAT_TIMEOUT = 10000; // 10 seconds
const HEARTBEAT_INTERVAL = 30000;
const HEARTBEAT_TIMEOUT = 10000;
export const handleConnectionEvents = (io, socket) => {
let heartbeatInterval;
-5
View File
@@ -4,13 +4,11 @@ import { getUser } from "../state/connection.js";
const API_URL = "http://localhost:8000/api/v1";
// --- HELPER: Card Strength for Auto-Play ---
const getStrength = (rank) => {
const strengthMap = { 1: 10, 7: 9, 13: 8, 11: 7, 12: 6, 6: 5, 5: 4, 4: 3, 3: 2, 2: 1 };
return strengthMap[rank] || 0;
};
// --- HELPER: Draw Card Logic ---
const drawCard = (game, playerId) => {
const player = game.players[playerId];
if (!player) return;
@@ -24,7 +22,6 @@ const drawCard = (game, playerId) => {
}
};
// --- HELPER: Sanitize Data ---
const sanitizeState = (state, game) => {
if (!state) return null;
const p1 = game.player1 || state.player1 || {};
@@ -90,7 +87,6 @@ async function saveGameResult(gameId, result, token) {
}
}
// --- SHARED END GAME LOGIC ---
const performGameEnd = (io, game, gameId, winnerId, loserId, reason) => {
const result = {
action: "game_ended",
@@ -267,7 +263,6 @@ export default (io, socket) => {
if (user) handleGameMove(io, gameId, user.id, cardId);
});
// --- NEW: SURRENDER HANDLER ---
socket.on("surrender", ({ gameId }) => {
const user = getUser(socket.id);
const game = getGame(gameId);
-4
View File
@@ -34,7 +34,6 @@ export default (io, socket) => {
}
};
// --- FIX: Timer Callback ---
const handleAutoPlay = (matchId) => (userId, cardId) => {
const match = getMatch(matchId);
if (!match || match.status !== "Playing") return;
@@ -66,7 +65,6 @@ export default (io, socket) => {
});
const matchData = res.data.data || res.data;
// Pass handleAutoPlay to constructor
match = new BiscaMatch(
matchData,
createMatchEmitter(matchId),
@@ -126,7 +124,6 @@ export default (io, socket) => {
if(!match || match.status !== "Playing") return;
const userId = socket.user.id;
// FIX: Abort current game to remove ghost
await match.abortCurrentGame(userId);
console.log(`[Match ${matchId}] User ${userId} surrendered MATCH.`);
@@ -144,7 +141,6 @@ export default (io, socket) => {
if (userId === match.player1Id || userId === match.player2Id) {
console.log(`[Match ${match.id}] Player ${userId} disconnected.`);
// FIX: Abort current game
await match.abortCurrentGame(userId);
const opponentId = match.player1Id == userId ? match.player2Id : match.player1Id;