Wazarr94 / haxball_bot_headless

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

last player on red goes spectator when match end #28

Closed huseyinsoyluu closed 2 years ago

huseyinsoyluu commented 2 years ago

You can watch between 0:47 and 1:30

Summary

1) Before match end, room has 9 people; specs has 2 afk (which is gambler and Procyon) (maxTeamSize is 3, so there is no problem)

2) Red Team: wangdu, ihtiyar, z1z0u and Blue Team: loweskjea, KITIGAWA, NNAZYY

2) After match end, red team goes spectator(wangdu, ihtiyar, z1z0u), bcs blue team wins the match (0:51 on recording)

3) loweskjea, KITIGAWA, NNAZYY are going to red bcs they are lastWinner. (0:52 on recording)

4) There is a bug occurs. The latest player for winnerTeam going to spec for no reason, (in this case NNAZYY). (0:53 on recording)

5) I checked immediately afk players and NNAZYY doesn't afk (0:59, there is chat log 😴 AFK Oyuncular: gambler., which is listing AFK, there is just gambler)

6) Second bug: Red team captain(1:15 on recording, loweskjea) choose NNAZYY (there is no chat log, weird)

7) Red team captain (loweskjea, 1:25 on recording) kicked for not selecting player in time period (actually he selected or paired randomly )

https://thehax.pl/forum/powtorki.php?nagranie=680fa95e6ce632077ff5156b493af235 is recording link and I hope you can understand the issue, this really weird for me :D

Wazarr94 commented 2 years ago

It is linked with these lines in the balanceTeams function:

if (streak == 0 && gameState == State.STOP) {
    if (Math.abs(teamRed.length - teamBlue.length) == 2) {
        var teamIn = teamRed.length > teamBlue.length ? teamRed : teamBlue;
        room.setPlayerTeam(teamIn[teamIn.length - 1].id, Team.SPECTATORS)
    }
}

This is supposed to rebalance teams if both captains are choosing (streak == 0 is only supposed to happen if there was a draw). But in your case it wasn't a draw, so what happened ? I have seemingly forgotten to update the streak correctly, so this is a very important bug you spotted, and I will fix this in the same update as the issue before, in the afternoon. Thanks for noticing as always

Wazarr94 commented 2 years ago

For the other problem, I'm not sure at the moment, but fixing the first bug might be a good first step