Open awan1 opened 1 week ago
I would like to work on this, if nobody else has taken this on yet.
I took a look at the old lichess app, and this seems to be the calculation for the threshold:
this.emergMs = 1000 * Math.min(60, Math.max(10, cdata.initial * .125))
so basically 1/8 of your total time, clamped to a minimum of 10s and a maximum of 60s.
We can probably start with reusing this logic for the new app?
There also seems to be some hysteresis logic, to avoid playing the sounds repeatedly when the increment takes us above the threshold again:
if (this.emergSound.playable[color]) {
if (millis < this.emergMs && !(now < this.emergSound.next!)) {
this.emergSound.play()
this.emergSound.next = now + this.emergSound.delay
this.emergSound.playable[color] = false
}
} else if (millis > 1.5 * this.emergMs) {
this.emergSound.playable[color] = true
}
Huh, so I just checked with the latest version of the app, and the clock warning sound is actually already implemented - So all that's left is probably to make it configurable..? (On/Off for starters, like in the old app)
As a user playing a timed real-time game, when my remaining time decreases below some threshold (described below), I would like to hear a warning sound.
As a user of the app, I would like to be able to configure whether the app makes this warning sound or not from the settings.
The threshold can be fixed (e.g. 30sec, 10sec, 5sec) or depend on the game format played. Ideally this behavior should match the web app.