Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- console.log("š Fetching and analyzing teamSeasons data...");
- const teamSeasons = await bbgm.idb.cache.teamSeasons.getAll();
- const teams = await bbgm.idb.cache.teams.getAll();
- console.log(`ā Found ${teamSeasons.length} teamSeasons entries.`);
- // Extract valid seasons
- const availableSeasons = [...new Set(teamSeasons.map(ts => ts.season))].sort((a, b) => a - b);
- const earliestSeason = availableSeasons[0];
- const latestSeason = availableSeasons.at(-1);
- console.log(`š Available Seasons: ${availableSeasons.join(", ")}`);
- console.log(`š Earliest recorded season: ${earliestSeason}`);
- console.log(`š Latest recorded season: ${latestSeason}`);
- // **Determine Actual Season Champions**
- const seasonChampions = {};
- teamSeasons.forEach(season => {
- if (season.playoffRoundsWon > 0) {
- if (!seasonChampions[season.season] || season.playoffRoundsWon > seasonChampions[season.season].roundsWon) {
- seasonChampions[season.season] = { tid: season.tid, roundsWon: season.playoffRoundsWon };
- }
- }
- });
- // **Calculate Prestige**
- const teamPrestiges = teams.map(team => {
- const teamHistory = teamSeasons.filter(ts => ts.tid === team.tid);
- if (!teamHistory.length) return { tid: team.tid, prestige: 0, totalWins: 0, totalChampionships: 0, recentWins: 0, recentChampionships: 0 };
- // **All-Time Wins & Championships**
- const totalWins = teamHistory.reduce((sum, season) => sum + (season.won || 0), 0);
- const totalChampionships = teamHistory.reduce((count, season) => {
- return count + (seasonChampions[season.season]?.tid === team.tid ? 1 : 0);
- }, 0);
- // **Recent Wins & Championships (Last 3 Seasons)**
- const recentSeasons = teamHistory.filter(ts => ts.season >= latestSeason - 2);
- const recentWins = recentSeasons.reduce((sum, season) => sum + (season.won || 0), 0);
- const recentChampionships = recentSeasons.reduce((count, season) => {
- return count + (seasonChampions[season.season]?.tid === team.tid ? 1 : 0);
- }, 0);
- // **Fetch budget values from the team object**
- const { budget } = team;
- const coaching = budget?.coaching ?? 50;
- const facilities = budget?.facilities ?? 50;
- const health = budget?.health ?? 50;
- const scouting = budget?.scouting ?? 50;
- // **Balanced Prestige Formula**
- let prestige = 0;
- prestige += (coaching * 0.4) + (facilities * 0.3) + (health * 0.1) + (scouting * 0.2);
- prestige += (totalWins * 0.08); // Slightly reduced weighting for all-time wins
- prestige += (totalChampionships * 4); // Lowered championship weight
- prestige += (recentWins * 0.4); // Boosted recent wins
- prestige += (recentChampionships * 6); // Recent championships still matter but balanced
- return { tid: team.tid, prestige, totalWins, totalChampionships, recentWins, recentChampionships };
- });
- // **Sort teams by prestige**
- teamPrestiges.sort((a, b) => b.prestige - a.prestige);
- // **Log Prestige Rankings**
- console.log("\nš Updated Team Prestiges (All-Time + Recent Performance) š");
- for (const teamData of teamPrestiges) {
- const team = teams.find(t => t.tid === teamData.tid);
- if (!team) continue;
- console.log(`${team.region} ${team.name}:`);
- console.log(` - All-Time Wins: ${teamData.totalWins}`);
- console.log(` - All-Time Championships: ${teamData.totalChampionships}`);
- console.log(` - Recent Wins (Last 3 Seasons): ${teamData.recentWins}`);
- console.log(` - Recent Championships: ${teamData.recentChampionships}`);
- console.log(` - Prestige: ${teamData.prestige.toFixed(1)}`);
- console.log("------------------------");
- }
- // **Log Final Prestige Rankings**
- console.log("\nš Final Prestige Rankings:");
- teamPrestiges.slice(0, 5).forEach((teamData, index) => {
- const team = teams.find(t => t.tid === teamData.tid);
- console.log(`${index + 1}. ${team.region} ${team.name} (${teamData.prestige.toFixed(1)})`);
- });
- console.log("...");
- console.log("(Continued for all 172 teams)");
- console.log("\nš Final Prestige Rankings Updated ā ");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement