Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2025
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.04 KB | None | 0 0
  1. console.log("šŸ” Fetching and analyzing teamSeasons data...");
  2.  
  3. const teamSeasons = await bbgm.idb.cache.teamSeasons.getAll();
  4. const teams = await bbgm.idb.cache.teams.getAll();
  5.  
  6. console.log(`āœ… Found ${teamSeasons.length} teamSeasons entries.`);
  7.  
  8. // Extract valid seasons
  9. const availableSeasons = [...new Set(teamSeasons.map(ts => ts.season))].sort((a, b) => a - b);
  10. const earliestSeason = availableSeasons[0];
  11. const latestSeason = availableSeasons.at(-1);
  12.  
  13. console.log(`šŸ“… Available Seasons: ${availableSeasons.join(", ")}`);
  14. console.log(`šŸ“Œ Earliest recorded season: ${earliestSeason}`);
  15. console.log(`šŸ“Œ Latest recorded season: ${latestSeason}`);
  16.  
  17. // **Determine Actual Season Champions**
  18. const seasonChampions = {};
  19. teamSeasons.forEach(season => {
  20. if (season.playoffRoundsWon > 0) {
  21. if (!seasonChampions[season.season] || season.playoffRoundsWon > seasonChampions[season.season].roundsWon) {
  22. seasonChampions[season.season] = { tid: season.tid, roundsWon: season.playoffRoundsWon };
  23. }
  24. }
  25. });
  26.  
  27. // **Calculate Prestige**
  28. const teamPrestiges = teams.map(team => {
  29. const teamHistory = teamSeasons.filter(ts => ts.tid === team.tid);
  30. if (!teamHistory.length) return { tid: team.tid, prestige: 0, totalWins: 0, totalChampionships: 0, recentWins: 0, recentChampionships: 0 };
  31.  
  32. // **All-Time Wins & Championships**
  33. const totalWins = teamHistory.reduce((sum, season) => sum + (season.won || 0), 0);
  34. const totalChampionships = teamHistory.reduce((count, season) => {
  35. return count + (seasonChampions[season.season]?.tid === team.tid ? 1 : 0);
  36. }, 0);
  37.  
  38. // **Recent Wins & Championships (Last 3 Seasons)**
  39. const recentSeasons = teamHistory.filter(ts => ts.season >= latestSeason - 2);
  40. const recentWins = recentSeasons.reduce((sum, season) => sum + (season.won || 0), 0);
  41. const recentChampionships = recentSeasons.reduce((count, season) => {
  42. return count + (seasonChampions[season.season]?.tid === team.tid ? 1 : 0);
  43. }, 0);
  44.  
  45. // **Fetch budget values from the team object**
  46. const { budget } = team;
  47. const coaching = budget?.coaching ?? 50;
  48. const facilities = budget?.facilities ?? 50;
  49. const health = budget?.health ?? 50;
  50. const scouting = budget?.scouting ?? 50;
  51.  
  52. // **Balanced Prestige Formula**
  53. let prestige = 0;
  54. prestige += (coaching * 0.4) + (facilities * 0.3) + (health * 0.1) + (scouting * 0.2);
  55. prestige += (totalWins * 0.08); // Slightly reduced weighting for all-time wins
  56. prestige += (totalChampionships * 4); // Lowered championship weight
  57. prestige += (recentWins * 0.4); // Boosted recent wins
  58. prestige += (recentChampionships * 6); // Recent championships still matter but balanced
  59.  
  60. return { tid: team.tid, prestige, totalWins, totalChampionships, recentWins, recentChampionships };
  61. });
  62.  
  63. // **Sort teams by prestige**
  64. teamPrestiges.sort((a, b) => b.prestige - a.prestige);
  65.  
  66. // **Log Prestige Rankings**
  67. console.log("\nšŸ€ Updated Team Prestiges (All-Time + Recent Performance) šŸ€");
  68. for (const teamData of teamPrestiges) {
  69. const team = teams.find(t => t.tid === teamData.tid);
  70. if (!team) continue;
  71.  
  72. console.log(`${team.region} ${team.name}:`);
  73. console.log(` - All-Time Wins: ${teamData.totalWins}`);
  74. console.log(` - All-Time Championships: ${teamData.totalChampionships}`);
  75. console.log(` - Recent Wins (Last 3 Seasons): ${teamData.recentWins}`);
  76. console.log(` - Recent Championships: ${teamData.recentChampionships}`);
  77. console.log(` - Prestige: ${teamData.prestige.toFixed(1)}`);
  78. console.log("------------------------");
  79. }
  80.  
  81. // **Log Final Prestige Rankings**
  82. console.log("\nšŸ€ Final Prestige Rankings:");
  83. teamPrestiges.slice(0, 5).forEach((teamData, index) => {
  84. const team = teams.find(t => t.tid === teamData.tid);
  85. console.log(`${index + 1}. ${team.region} ${team.name} (${teamData.prestige.toFixed(1)})`);
  86. });
  87. console.log("...");
  88. console.log("(Continued for all 172 teams)");
  89. console.log("\nšŸ€ Final Prestige Rankings Updated āœ…");
  90.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement