Skip to content

Commit 95ad280

Browse files
authored
Merge pull request #19 from QiuFeng54321/compatibility-1
Use utils.Includes instead of slices.Contains
2 parents 1f67ac0 + dd6145f commit 95ad280

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

multiplayer/game.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"fmt"
1414
"log"
1515
"math"
16-
"slices"
1716
"time"
1817
)
1918

@@ -143,7 +142,7 @@ func (game *Game) AddPlayer(userId int, password string) {
143142
func (game *Game) RemovePlayer(userId int) {
144143
user := sessions.GetUserById(userId)
145144

146-
var playerWasInMatch = slices.Contains(game.playersInMatch, userId)
145+
var playerWasInMatch = utils.Includes(game.playersInMatch, userId)
147146

148147
if user != nil {
149148
user.SetMultiplayerGameId(0)
@@ -1138,7 +1137,7 @@ func (game *Game) isAllPlayersFinished() bool {
11381137
}
11391138

11401139
func (game *Game) isPlayerSpectatorOrReferee(userId int) bool {
1141-
return game.Data.RefereeId == userId || slices.Contains(game.spectators, userId)
1140+
return game.Data.RefereeId == userId || utils.Includes(game.spectators, userId)
11421141
}
11431142

11441143
// Checks if all the players in the game have skipped the map and sends a packet letting them know.
@@ -1195,7 +1194,7 @@ func (game *Game) sendPacketToPlayers(packet interface{}) {
11951194

11961195
for _, id := range game.spectators {
11971196
// Referee will have already gotten the packet above.
1198-
if id == game.Data.RefereeId && slices.Contains(game.Data.PlayerIds, id) {
1197+
if id == game.Data.RefereeId && utils.Includes(game.Data.PlayerIds, id) {
11991198
continue
12001199
}
12011200

0 commit comments

Comments
 (0)