duels titles not getting displayed properly
Archived a year ago
7
7wlr
i've had this issue for quite a bit long but the constant debugging just got to me
the issue is that the individual modes gets defaulted to rookie which is not good
it should display none instead of rookie if the player has below 50 wins in that specific gamemode
```js
function getDuelsTitlesForMode(player, modeKey, modeName) {
const titles = [
{ key: 'ascended', name: 'Ascended', class: 'title-ascended', maxPrestige: 50 },
{ key: 'divine', name: 'Divine', class: 'title-divine', maxPrestige: 5 },
{ key: 'celestial', name: 'Celestial', class: 'title-celestial', maxPrestige: 5 },
{ key: 'godlike', name: 'Godlike', class: 'title-godlike', maxPrestige: 5 },
{ key: 'grandmaster', name: 'Grandmaster', class: 'title-grandmaster', maxPrestige: 5 },
{ key: 'legend', name: 'Legend', class: 'title-legend', maxPrestige: 5 },
{ key: 'master', name: 'Master', class: 'title-master', maxPrestige: 5 },
{ key: 'diamond', name: 'Diamond', class: 'title-diamond', maxPrestige: 5 },
{ key: 'gold', name: 'Gold', class: 'title-gold', maxPrestige: 5 },
{ key: 'iron', name: 'Iron', class: 'title-iron', maxPrestige: 5 },
{ key: 'rookie', name: 'Rookie', class: 'title-rookie', maxPrestige: 5 }
];
let highestTitle = null;
for (const title of titles) {
const prestigeKey = `${modeKey}_${title.key}_title_prestige`;
const prestige = player.stats.Duels[prestigeKey];
if (prestige !== undefined && prestige > 0) {
if (!highestTitle || titles.findIndex(t => t.key === highestTitle.key) > titles.findIndex(t => t.key === title.key)) {
highestTitle = { ...title, prestige };
}
}
}
const winsKey = modeKey === 'overall' ? 'wins' : `${modeKey}_duel_wins`;
const wins = player.stats.Duels[winsKey];
if (modeKey === 'overall' && (!wins || wins < 50)) {
return `<span class="title-none">${modeName} None</span>`;
}
if (highestTitle) {
let titleString = `<span class="${highestTitle.class}">${modeName} ${highestTitle.name}`;
if (highestTitle.prestige > 1) {
titleString += ` ${numberToRoman(highestTitle.prestige)}`;
}
titleString += `</span>`;
return titleString;
} else {
return `<span class="title-none">${modeName} None</span>`;
}
}
function getAllDuelsTitles(player) {
const modes = [
{ key: 'all_modes', name: 'Overall' },
{ key: 'uhc', name: 'UHC' },
{ key: 'blitz', name: 'Blitz' },
{ key: 'no_debuff', name: 'No Debuff' },
{ key: 'combo', name: 'Combo' },
{ key: 'tnt_games', name: 'TNT Games' },
{ key: 'classic', name: 'Classic' },
{ key: 'bow', name: 'Bow' },
{ key: 'mega_walls', name: 'Mega Walls' },
{ key: 'op', name: 'OP' },
{ key: 'sumo', name: 'Sumo' },
{ key: 'skywars', name: 'SkyWars' },
{ key: 'bridge', name: 'Bridge' },
{ key: 'parkour', name: 'Parkour' },
{ key: 'boxing', name: 'Boxing' },
];
const duelsTitles = modes.map(mode => getDuelsTitlesForMode(player, mode.key, mode.name));
return duelsTitles;
}
```
