Show matches that have started as full in match listing

This commit is contained in:
Trevor Slocum 2023-11-13 11:26:06 -08:00
parent 9b2226d9a8
commit 4acaf3128e
2 changed files with 11 additions and 5 deletions

View file

@ -77,15 +77,15 @@ func RollForMove(from int, to int, player int) int {
// CanBearOff returns whether the provided player can bear checkers off of the board.
func CanBearOff(board []int, player int, local bool) bool {
if PlayerCheckers(board[SpaceBarPlayer], player) > 0 || PlayerCheckers(board[SpaceBarOpponent], player) > 0 {
return false
}
homeStart, homeEnd := 1, 6
if !local {
homeStart, homeEnd = HomeRange(player)
homeStart, homeEnd = minInt(homeStart, homeEnd), maxInt(homeStart, homeEnd)
}
if PlayerCheckers(board[SpaceBarPlayer], player) > 0 || PlayerCheckers(board[SpaceBarOpponent], player) > 0 {
return false
}
for i := 1; i < 24; i++ {
if (i < homeStart || i > homeEnd) && PlayerCheckers(board[i], player) > 0 {
return false

View file

@ -456,15 +456,21 @@ COMMANDS:
ev := &bgammon.EventList{}
s.gamesLock.RLock()
var playerCount int
for _, g := range s.games {
if g.terminated() {
continue
}
if len(g.allowed1) != 0 && !bytes.Equal(g.allowed1, cmd.client.name) && !bytes.Equal(g.allowed2, cmd.client.name) {
playerCount = 2
} else {
playerCount = g.playerCount()
}
ev.Games = append(ev.Games, bgammon.GameListing{
ID: g.id,
Points: g.Points,
Password: len(g.password) != 0,
Players: g.playerCount(),
Players: playerCount,
Name: string(g.name),
})
}