1
This commit is contained in:
@@ -11,6 +11,7 @@ const leaderboardSchema = new Schema({
|
||||
stars: { type: Number, default: 0 },
|
||||
totalWins: { type: Number, default: 0 },
|
||||
position: { type: Number, required: true },
|
||||
lastWinDeck: { type: Object, default: null }, // 添加最后获胜牌组信息
|
||||
lastUpdated: { type: Date, default: Date.now }
|
||||
});
|
||||
|
||||
@@ -28,7 +29,7 @@ exports.generateLeaderboard = async () => {
|
||||
|
||||
// Sort users based on ranking criteria:
|
||||
// 1. Rank level (higher is better)
|
||||
// 2. Rank score (for王者分数 mechanism)
|
||||
// 2. Rank score (for King rank mechanism)
|
||||
// 3. Stars
|
||||
// 4. Total wins
|
||||
const sortedUsers = users.sort((a, b) => {
|
||||
@@ -40,7 +41,7 @@ exports.generateLeaderboard = async () => {
|
||||
return configB.Level - configA.Level;
|
||||
}
|
||||
|
||||
// For players with rank score mechanism
|
||||
// For players with rank score mechanism (King rank)
|
||||
if (configA.RankScore === 1 && configB.RankScore === 1) {
|
||||
if (a.rankScore !== b.rankScore) {
|
||||
return b.rankScore - a.rankScore;
|
||||
@@ -71,6 +72,7 @@ exports.generateLeaderboard = async () => {
|
||||
rankScore: player.rankScore,
|
||||
stars: player.stars,
|
||||
totalWins: player.totalWins,
|
||||
lastWinDeck: player.lastWinDeck, // 包含最后获胜牌组
|
||||
position: i + 1
|
||||
});
|
||||
leaderboardEntries.push(entry);
|
||||
@@ -115,5 +117,6 @@ exports.initializePlayerLadder = (player) => {
|
||||
player.rankScore = 0;
|
||||
player.winStreak = 0;
|
||||
player.totalWins = 0;
|
||||
player.lastWinDeck = null; // 初始化最后获胜牌组
|
||||
return player;
|
||||
};
|
||||
Reference in New Issue
Block a user