Wazarr94 / haxball_bot_headless

Ready-to-go scripts and functions for the HaxBall Headless API !
MIT License
46 stars 74 forks source link

Saves doesn't counting #27

Closed huseyinsoyluu closed 2 years ago

huseyinsoyluu commented 2 years ago

Hello, I checked whole stats on localstorage and none of the players has saves, all of them have 0 and when I checked updatePlayerStats() and getGamePlayerStats() function, they don't have saves value,

function updatePlayerStats(player, teamStats) {
    var stats = new HaxStatistics(player.name);
    var pComp = getPlayerComp(player);
    if (localStorage.getItem(authArray[player.id][0])) {
        stats = JSON.parse(localStorage.getItem(authArray[player.id][0]));
    }
    stats.games++;
    if (lastWinner == teamStats) stats.wins++;
    stats.winrate =
        ((100 * stats.wins) / (stats.games || 1)).toPrecision(3) + `%`;
    stats.goals += getGoalsPlayer(pComp);
    stats.assists += getAssistsPlayer(pComp);
    stats.ownGoals += getOwnGoalsPlayer(pComp);
    localStorage.setItem(authArray[player.id][0], JSON.stringify(stats));
}
function getGamePlayerStats(player) {
    var stats = new HaxStatistics(player.name);
    var pComp = getPlayerComp(player);
    stats.goals += getGoalsPlayer(pComp);
    stats.assists += getAssistsPlayer(pComp);
    stats.ownGoals += getOwnGoalsPlayer(pComp);
    return stats;
}

and there is no getSavesPlayer() for checking pComp or player saves

and maybe you can add active time for users log on localstorage for checking who's the most active user? There is timeEntry and timeExit in PlayerComposition class. but I couldn't save on localstorage.

Wazarr94 commented 2 years ago

Saves are not supposed to exist in this script, I must have left it by mistake. I decided not to include advanced stats because it's an advanced system that needs a complete rewrite, and I don't have time for that.

You're right for the time stats, I'm pretty sure it would be relatively easy for me to add it as a stat with the system I have. Gonna close this after removing saves and adding time stat.