Separate title for boosters (WIP)
This commit is contained in:
parent
23d2ea4b3d
commit
479d671782
|
@ -45,6 +45,7 @@ case class Check(userId: String)
|
|||
|
||||
package mod {
|
||||
case class MarkCheater(userId: String)
|
||||
case class MarkBooster(userId: String)
|
||||
}
|
||||
|
||||
package setup {
|
||||
|
|
|
@ -19,11 +19,11 @@ final class BoostingApi(modApi: ModApi, collBoosting: Coll) {
|
|||
.one[BoostingRecord]
|
||||
|
||||
def createBoostRecord(record: BoostingRecord) =
|
||||
collBoosting.update(BSONDocument("_id" -> record._id), record, upsert = true).void
|
||||
collBoosting.update(BSONDocument("_id" -> record.id), record, upsert = true).void
|
||||
|
||||
def determineBoosting(record: BoostingRecord, winner: User): Funit = {
|
||||
if (record.games + 1 >= 3) {
|
||||
modApi.autoAdjust(winner.username)
|
||||
modApi.autoBooster(winner.username)
|
||||
} else {
|
||||
funit
|
||||
}
|
||||
|
@ -32,7 +32,11 @@ final class BoostingApi(modApi: ModApi, collBoosting: Coll) {
|
|||
def boostingId(winner: User, loser: User): String = winner.id + "/" + loser.id
|
||||
|
||||
def check(game: Game, whiteUser: User, blackUser: User): Funit = {
|
||||
if (game.rated && game.accountable && game.playedTurns <= 10 && !game.isTournament && game.winnerColor.isDefined) {
|
||||
if (game.rated
|
||||
&& game.accountable
|
||||
&& game.playedTurns <= 10
|
||||
&& !game.isTournament
|
||||
&& game.winnerColor.isDefined) {
|
||||
game.winnerColor match {
|
||||
case Some(a) => {
|
||||
val result: GameResult = a match {
|
||||
|
@ -69,7 +73,9 @@ object BoostingApi {
|
|||
case class BoostingRecord(
|
||||
_id: String,
|
||||
player: String,
|
||||
games: Int)
|
||||
games: Int) {
|
||||
def id = _id
|
||||
}
|
||||
|
||||
case class GameResult(
|
||||
winner: User,
|
||||
|
|
|
@ -24,6 +24,18 @@ final class ModApi(
|
|||
case false => adjust("lichess", username)
|
||||
}
|
||||
|
||||
def adjustBooster(mod: String, username: String): Funit = withUser(username) { user =>
|
||||
logApi.booster(mod, user.id, !user.booster) zip
|
||||
UserRepo.toggleBooster(user.id) >>- {
|
||||
if (!user.booster) lilaBus.publish(lila.hub.actorApi.mod.MarkBooster(user.id), 'adjustBooster)
|
||||
} void
|
||||
}
|
||||
|
||||
def autoBooster(username: String): Funit = logApi.wasUnbooster(User.normalize(username)) flatMap {
|
||||
case true => funit
|
||||
case false => adjustBooster("lichess", username)
|
||||
}
|
||||
|
||||
def troll(mod: String, username: String): Fu[Boolean] = withUser(username) { u =>
|
||||
val user = u.copy(troll = !u.troll)
|
||||
((UserRepo updateTroll user) >>-
|
||||
|
|
|
@ -12,6 +12,8 @@ case class Modlog(
|
|||
def showAction = action match {
|
||||
case Modlog.engine => "mark as engine"
|
||||
case Modlog.unengine => "un-mark as engine"
|
||||
case Modlog.booster => "mark as booster"
|
||||
case Modlog.unbooster => "un-mark as booster"
|
||||
case Modlog.deletePost => "delete forum post"
|
||||
case Modlog.ban => "ban user"
|
||||
case Modlog.ipban => "ban IPs"
|
||||
|
@ -38,6 +40,8 @@ object Modlog {
|
|||
|
||||
val engine = "engine"
|
||||
val unengine = "unengine"
|
||||
val booster = "booster"
|
||||
val unbooster = "unbooster"
|
||||
val troll = "troll"
|
||||
val untroll = "untroll"
|
||||
val ban = "ban"
|
||||
|
|
|
@ -11,6 +11,10 @@ final class ModlogApi {
|
|||
Modlog(mod, user.some, v.fold(Modlog.engine, Modlog.unengine))
|
||||
}
|
||||
|
||||
def booster(mod: String, user: String, v: Boolean) = add {
|
||||
Modlog(mod, user.some, v.fold(Modlog.booster, Modlog.unbooster))
|
||||
}
|
||||
|
||||
def troll(mod: String, user: String, v: Boolean) = add {
|
||||
Modlog(mod, user.some, v.fold(Modlog.troll, Modlog.untroll))
|
||||
}
|
||||
|
@ -73,6 +77,11 @@ final class ModlogApi {
|
|||
"action" -> Modlog.unengine
|
||||
))
|
||||
|
||||
def wasUnbooster(userId: String) = $count.exists(Json.obj(
|
||||
"user" -> userId,
|
||||
"action" -> Modlog.unbooster
|
||||
))
|
||||
|
||||
def assessGame(mod: String, gameId: String, side: String, assessment: Int) = add {
|
||||
val assessmentString = assessment match {
|
||||
case 1 => "Not cheating"
|
||||
|
|
|
@ -16,6 +16,7 @@ case class User(
|
|||
roles: List[String],
|
||||
profile: Option[Profile] = None,
|
||||
engine: Boolean = false,
|
||||
booster: Boolean = false,
|
||||
toints: Int = 0,
|
||||
playTime: Option[User.PlayTime] = None,
|
||||
title: Option[String] = None,
|
||||
|
|
|
@ -222,6 +222,10 @@ trait UserRepo {
|
|||
$setBson("engine" -> BSONBoolean(!u.engine))
|
||||
}
|
||||
|
||||
def toggleBooster(id: ID): Funit = $update.docBson[ID, User](id) { u =>
|
||||
$setBson("booster" -> BSONBoolean(!u.booster))
|
||||
}
|
||||
|
||||
def toggleIpBan(id: ID) = $update.doc[ID, User](id) { u => $set("ipBan" -> !u.ipBan) }
|
||||
|
||||
def updateTroll(user: User) = $update.field(user.id, "troll", user.troll)
|
||||
|
|
Loading…
Reference in a new issue