This commit is contained in:
milo
2026-01-27 22:52:38 +01:00
parent a08e9ed626
commit beabace9eb
3 changed files with 24 additions and 17 deletions

View File

@@ -491,6 +491,7 @@ export function apiRoutes(client, io) {
try {
const games = getUserGames.all({ user_id: req.params.id });
const eloHistory = games
.filter((g) => g.type !== 'POKER_ROUND' && g.type !== 'SOTD')
.filter((game) => game.p2 !== null)
.map((game) => (game.p1 === req.params.id ? game.p1_new_elo : game.p2_new_elo));
eloHistory.splice(0, 0, 1000);
@@ -528,7 +529,7 @@ export function apiRoutes(client, io) {
router.get("/user/:id/games-history", async (req, res) => {
try {
const games = getUserGames.all({ user_id: req.params.id });
const games = getUserGames.all({ user_id: req.params.id }).filter((g) => g.type !== 'POKER_ROUND' && g.type !== 'SOTD').reverse().slice(0, 50);
res.json({ games });
} catch (err) {
res.status(500).json({ error: "Failed to fetch games history." });

View File

@@ -77,20 +77,24 @@ export function blackjackRoutes(io) {
let changed = false;
for (const p of Object.values(room.players)) {
if (!p.inRound) continue;
const h = p.hands[p.activeHand];
if (!h.hasActed && !h.busted && !h.stood && !h.surrendered) {
h.surrendered = true;
h.stood = true;
h.hasActed = true;
//room.leavingAfterRound[p.id] = true; // kick at end of round
emitToast({ type: "player-timeout", userId: p.id });
changed = true;
} else if (h.hasActed && !h.stood) {
h.stood = true;
//room.leavingAfterRound[p.id] = true; // kick at end of round
emitToast({ type: "player-auto-stand", userId: p.id });
changed = true;
try {
if (!p.inRound) continue;
const h = p.hands[p.activeHand];
if (h && !h.hasActed && !h.busted && !h.stood && !h.surrendered) {
h.surrendered = true;
h.stood = true;
h.hasActed = true;
//room.leavingAfterRound[p.id] = true; // kick at end of round
emitToast({ type: "player-timeout", userId: p.id });
changed = true;
} else if (h && h.hasActed && !h.stood) {
h.stood = true;
//room.leavingAfterRound[p.id] = true; // kick at end of round
emitToast({ type: "player-auto-stand", userId: p.id });
changed = true;
}
} catch (e) {
console.log(e);
}
}
if (changed) emitUpdate("auto-surrender", snapshot(room));

View File

@@ -292,7 +292,8 @@ async function refreshQueuesForUser(userId, client) {
if (index > -1) {
tictactoeQueue.splice(index, 1);
try {
const generalChannel = await client.channels.fetch(process.env.BOT_CHANNEL_ID);
const guild = await client.guilds.fetch(process.env.GUILD_ID);
const generalChannel = await guild.channels.fetch(process.env.BOT_CHANNEL_ID);
const user = await client.users.fetch(userId);
const queueMsg = await generalChannel.messages.fetch(queueMessagesEndpoints[userId]);
const updatedEmbed = new EmbedBuilder()
@@ -311,7 +312,8 @@ async function refreshQueuesForUser(userId, client) {
if (index > -1) {
connect4Queue.splice(index, 1);
try {
const generalChannel = await client.channels.fetch(process.env.BOT_CHANNEL_ID);
const guild = await client.guilds.fetch(process.env.GUILD_ID);
const generalChannel = await guild.channels.fetch(process.env.BOT_CHANNEL_ID);
const user = await client.users.fetch(userId);
const queueMsg = await generalChannel.messages.fetch(queueMessagesEndpoints[userId]);
const updatedEmbed = new EmbedBuilder()