Wait longer during rated matches
This commit is contained in:
parent
f01ac821f8
commit
1fa92d3cc9
3 changed files with 13 additions and 7 deletions
|
@ -311,17 +311,23 @@ func (c *Client) handleTimeout() {
|
|||
}
|
||||
}
|
||||
|
||||
limit := 5 * time.Minute
|
||||
if Game.Player1.Rating != 0 && Game.Player2.Rating != 0 {
|
||||
limit = 12 * time.Minute
|
||||
}
|
||||
|
||||
t := time.Now()
|
||||
delta := t.Sub(c.lastActivity)
|
||||
if delta >= 5*time.Minute {
|
||||
if delta >= limit {
|
||||
c.Out <- []byte("say Sorry, this match has timed out.")
|
||||
c.Out <- []byte("leave")
|
||||
} else if t.Sub(c.lastActivity) >= 2*time.Minute {
|
||||
} else if t.Sub(c.lastActivity) >= limit/2 {
|
||||
mins := 1 + int(limit/time.Minute) - int(math.Ceil(delta.Minutes()))
|
||||
plural := "s"
|
||||
if 6-math.Ceil(delta.Minutes()) == 1 {
|
||||
if mins == 1 {
|
||||
plural = ""
|
||||
}
|
||||
c.Out <- []byte(fmt.Sprintf("say Warning: This match will time out in %d minute%s. Please roll or make a move.", int(6-math.Ceil(delta.Minutes())), plural))
|
||||
c.Out <- []byte(fmt.Sprintf("say Warning: This match will time out in %d minute%s. Please roll or make a move.", mins, plural))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
2
go.mod
2
go.mod
|
@ -3,7 +3,7 @@ module code.rocket9labs.com/tslocum/bgammon-tabula-bot
|
|||
go 1.17
|
||||
|
||||
require (
|
||||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20240111193402-262ad93e51c2
|
||||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20240117214045-3607efee4129
|
||||
code.rocket9labs.com/tslocum/tabula v0.0.0-20240108183445-695ea428ae21
|
||||
nhooyr.io/websocket v1.8.10
|
||||
)
|
||||
|
|
4
go.sum
4
go.sum
|
@ -1,7 +1,7 @@
|
|||
code.rocket9labs.com/tslocum/bei v0.0.0-20240108012722-6db380cc190b h1:Y0a14Kf/hSYepSmp4ZfDeE4CZZGBGBS97CNjCbKJm0c=
|
||||
code.rocket9labs.com/tslocum/bei v0.0.0-20240108012722-6db380cc190b/go.mod h1:tS60/VNAJphKvDBkSLQhKALa15msIAuWWfEKNc4oFZc=
|
||||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20240111193402-262ad93e51c2 h1:H51VlgdBfZbqnRCqjgBY5WLSs2FeUVznBGZahrfU90M=
|
||||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20240111193402-262ad93e51c2/go.mod h1:65vhSKgeQb6ccjUm5NJlbBdwuAH3VSFoSApZ/aVG3+4=
|
||||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20240117214045-3607efee4129 h1:wguf0figCFqnSxAK8wAznDor28ZEkElA2ShoZmqLRHg=
|
||||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20240117214045-3607efee4129/go.mod h1:LAki3jpHOsr4fwaK0xC9tkg+wgu/9ZNEqqx1zE3/HP4=
|
||||
code.rocket9labs.com/tslocum/tabula v0.0.0-20240108183445-695ea428ae21 h1:1VG88tdhCSVv7wGoIKQe8A8KfBXJsdz5pDsyP4ymDwk=
|
||||
code.rocket9labs.com/tslocum/tabula v0.0.0-20240108183445-695ea428ae21/go.mod h1:WEJXESKXqrMFLAArikQ79lpRibNeeE1C0VruxXYMF5M=
|
||||
nhooyr.io/websocket v1.8.10 h1:mv4p+MnGrLDcPlBoWsvPP7XCzTYMXP9F9eIGoKbgx7Q=
|
||||
|
|
Loading…
Reference in a new issue