forked from lichess-org/lila
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It warns players before they get playbanned, if they chose to ignore the warnings. But more importantly it informs their opponents that measures are effectively taken against bad sportmanship behaviours. Hopefully they'll stop assuming otherwise and complaining in public boards.
- Loading branch information
Showing
5 changed files
with
66 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package lila.playban | ||
|
||
import lila.chat.{ Chat, ChatApi } | ||
import lila.game.Pov | ||
|
||
private final class PlaybanFeedback( | ||
chatApi: ChatApi, | ||
lightUser: lila.common.LightUser.Getter | ||
) { | ||
|
||
private val tempBan = "will result in a temporary ban." | ||
|
||
def abort(pov: Pov): Unit = tell(pov, s"Warning, {user}: aborting too many games $tempBan") | ||
|
||
def noStart(pov: Pov): Unit = tell(pov, s"Warning, {user}: failing to start games $tempBan") | ||
|
||
def rageQuit(pov: Pov): Unit = tell(pov, s"Warning, {user}: leaving games without resigning $tempBan") | ||
|
||
def sitting(pov: Pov): Unit = tell(pov, s"Warning, {user}: letting time run out instead of resigning $tempBan") | ||
|
||
def sandbag(pov: Pov): Unit = tell(pov, s"Warning, {user}: losing games on purpose will result in a ban.") | ||
|
||
private def tell(pov: Pov, template: String): Unit = | ||
pov.player.userId foreach { userId => | ||
lightUser(userId) foreach { light => | ||
val message = template.replace("{user}", light.fold(userId)(_.name)) | ||
chatApi.userChat.volatile(Chat.Id(pov.gameId), message) | ||
} | ||
} | ||
} |