use rank 10 million for unranked players
This commit is contained in:
@@ -95,8 +95,8 @@ async function main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unranked → rank 100,000 (~1000 ELO)
|
// Unranked → rank 10,000,000 (yields 0 ELO)
|
||||||
const effectiveRank = rank && rank > 0 ? rank : 100_000;
|
const effectiveRank = rank && rank > 0 ? rank : 10_000_000;
|
||||||
const seedElo = rankToElo(effectiveRank);
|
const seedElo = rankToElo(effectiveRank);
|
||||||
// Adjust by win/loss differential to preserve some earned progress
|
// Adjust by win/loss differential to preserve some earned progress
|
||||||
const adjustment = (r.wins - r.losses) * 12;
|
const adjustment = (r.wins - r.losses) * 12;
|
||||||
|
|||||||
@@ -14,8 +14,9 @@ import { proxyImage } from './storage/r2';
|
|||||||
let pendingOsuProfile: { rank: number | null } | null = null;
|
let pendingOsuProfile: { rank: number | null } | null = null;
|
||||||
|
|
||||||
function eloFromRank(rank: number | null): { elo: number; osuRank: number | null } {
|
function eloFromRank(rank: number | null): { elo: number; osuRank: number | null } {
|
||||||
if (!rank || rank <= 0) return { elo: 1000, osuRank: null };
|
// Unranked → treat as rank 10,000,000 (yields 0 ELO)
|
||||||
const rawElo = 3500 - Math.log10(rank) * 500;
|
const effectiveRank = rank && rank > 0 ? rank : 10_000_000;
|
||||||
|
const rawElo = 3500 - Math.log10(effectiveRank) * 500;
|
||||||
return { elo: Math.round(Math.max(0, Math.min(3500, rawElo))), osuRank: rank };
|
return { elo: Math.round(Math.max(0, Math.min(3500, rawElo))), osuRank: rank };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -148,15 +148,31 @@ export const actions: Actions = {
|
|||||||
// API failure — treat as unranked
|
// API failure — treat as unranked
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unranked → rank 100,000 (~1000 ELO)
|
// Unranked → rank 10,000,000 (yields 0 ELO)
|
||||||
const effectiveRank = rank && rank > 0 ? rank : 100_000;
|
const effectiveRank = rank && rank > 0 ? rank : 10_000_000;
|
||||||
const rawElo = 3500 - Math.log10(effectiveRank) * 500;
|
const rawElo = 3500 - Math.log10(effectiveRank) * 500;
|
||||||
const elo = Math.round(Math.max(0, Math.min(3500, rawElo)));
|
const elo = Math.round(Math.max(0, Math.min(3500, rawElo)));
|
||||||
|
|
||||||
await db
|
// Upsert: insert if no rating row exists, update if it does
|
||||||
.update(playerRating)
|
const existing = await db.query.playerRating.findFirst({
|
||||||
.set({ elo, initialElo: elo, osuRankAtSeed: rank, wins: 0, losses: 0, updatedAt: new Date() })
|
where: eq(playerRating.userId, u.id)
|
||||||
.where(eq(playerRating.userId, u.id));
|
});
|
||||||
|
|
||||||
|
if (existing) {
|
||||||
|
await db
|
||||||
|
.update(playerRating)
|
||||||
|
.set({ elo, initialElo: elo, osuRankAtSeed: rank, wins: 0, losses: 0, updatedAt: new Date() })
|
||||||
|
.where(eq(playerRating.userId, u.id));
|
||||||
|
} else {
|
||||||
|
await db.insert(playerRating).values({
|
||||||
|
userId: u.id,
|
||||||
|
elo,
|
||||||
|
initialElo: elo,
|
||||||
|
osuRankAtSeed: rank,
|
||||||
|
wins: 0,
|
||||||
|
losses: 0
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
console.log(`[Admin] Reset ${u.name}: rank #${rank ?? 'unranked'} → ${elo} ELO`);
|
console.log(`[Admin] Reset ${u.name}: rank #${rank ?? 'unranked'} → ${elo} ELO`);
|
||||||
updated++;
|
updated++;
|
||||||
|
|||||||
Reference in New Issue
Block a user