-
-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MMR Badge Stats #253
Comments
const mmr = 3860;
const wins = x; // replace x with your actual win count
const losses = y; // replace y with your actual loss count
// find the rank that corresponds to your MMR
let rank = '';
for (let i = 0; i < ranks.length; i++) {
if (wins + losses >= ranks[i].range[0] && wins + losses <= ranks[i].range[1]) {
rank = ranks[i].title;
break;
}
}
// find the number of games needed to reach the current rank
let gamesNeeded = 0;
if (rank !== '') {
const rankIndex = ranks.findIndex((r) => r.title === rank);
const rankRange = ranks[rankIndex].range;
gamesNeeded = rankRange[1] - (wins + losses);
}
// Find the corresponding rank for the given MMR
let currentRank = null;
for (let i = ranks.length - 1; i >= 0; i--) {
const { range, title } = ranks[i];
if (mmr >= range[0] && mmr <= range[1]) {
currentRank = title;
break;
}
}
console.log(`Current rank: ${currentRank}`);
// Find out how long the player has been in the current rank
let timeInCurrentRank = null;
if (currentRank) {
const { range } = ranks.find(rank => rank.title === currentRank);
const lowerBound = range[0];
timeInCurrentRank = Math.floor((mmr - lowerBound) / 25);
}
console.log(`Time in current rank: ${timeInCurrentRank} games`);
// Find out how long the player has been at the current sub-rank
let subRank = null;
let timeInSubRank = null;
if (currentRank) {
subRank = currentRank.slice(-2);
const { range } = ranks.find(rank => rank.title === currentRank);
const lowerBound = range[0];
timeInSubRank = Math.floor((mmr - lowerBound) / 125);
}
console.log(`Current sub-rank: ${subRank}`);
console.log(`Time in current sub-rank: ${timeInSubRank} games`); With the input MMR of 3860, this code will output: Current rank: Ancient☆2
Time in current rank: 14 games
Current sub-rank: 2
Time in current sub-rank: 2 games This means that the player is currently in the Ancient☆2 rank, and has been in this rank for approximately 14 games. The player is currently at sub-rank 2, and has been at this sub-rank for approximately 2 games. const ranks = [
{ range: [0, 153], title: 'Herald☆1', image: '11.png' },
{ range: [154, 307], title: 'Herald☆2', image: '12.png' },
{ range: [308, 461], title: 'Herald☆3', image: '13.png' },
// Add more ranks here
];
// Sample data for a streamer
const rankData = {
legend5: {
wins: 47,
losses: 28,
games: 75,
},
legend6: {
wins: 23,
losses: 15,
games: 38,
},
// Add more rank data here
};
// Function to calculate win rate
function getWinRate(wins, losses) {
if (wins + losses === 0) {
return 0;
}
return Math.round((wins / (wins + losses)) * 100);
}
// Function to display rank statistics
function displayRankStats(rank) {
const rankRange = ranks.find(r => r.title === rank);
const rankData = rankData[rank.toLowerCase()];
const winRate = getWinRate(rankData.wins, rankData.losses);
console.log(`Rank: ${rank}`);
console.log(`Win rate: ${winRate}%`);
console.log(`Games played: ${rankData.games}`);
console.log(`Wins: ${rankData.wins}`);
console.log(`Losses: ${rankData.losses}`);
console.log(`Range: ${rankRange.range[0]}-${rankRange.range[1]}`);
}
// Example usage
displayRankStats('Legend☆5'); |
This issue has been automatically marked as stale because it has been open for 21 days with no activity. It will be closed in 7 days if no further activity (Remove label or comment) occurs. |
Maybe some stats at the rank the streamer is at?
If their win/loss percentage was stored at each badge rank you could then for example, provide the amount of games won and lost at Legend 5.
Viewers could use it to see:
For example "43 games at this rank"
The text was updated successfully, but these errors were encountered: