Skip to content

Commit

Permalink
#83: Bug fix: Bots receives skipped-turn-event events while dead
Browse files Browse the repository at this point in the history
  • Loading branch information
flemming-n-larsen committed Apr 23, 2024
1 parent 7aa3187 commit 5d3f76f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions VERSIONS.MD
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
- Bot API:
- #80: Fixed a major bug causing the body, gun, and radar to move in a wrong angle, which could be seen with
the Walls sample bot.
- Server:
- #83: Bots receives skipped-turn-event events while dead.

#### 🚀 Improvements

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,12 @@ class GameServer(
private fun getParticipantsThatSkippedTurn(): Collection<WebSocket> =
mutableListOf<WebSocket>().apply {
participants.forEach { participant ->
// Check if no intent was received from the participant during the turn
if (botIntents[participant] == null) this += participant
participantIds[participant]?.let {
// Check if no intent was received from the (alive) participant during the turn
if (modelUpdater?.isAlive(it) == true && botIntents[participant] == null) {
this += participant
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ class ModelUpdater(
/** The number of rounds played so far */
internal val numberOfRounds: Int get() = gameState.rounds.size

internal fun isAlive(botId: BotId) = botsMap[botId]?.isAlive ?: false

/**
* Updates game state.
* @param botIntents is the bot intents, which gives instructions to the game from the individual bots.
Expand Down

0 comments on commit 5d3f76f

Please sign in to comment.