Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block self challenges #214

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion modules/challenge/src/main/ChallengeGranter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ object ChallengeDenied {
case class RatingIsProvisional(perf: PerfType) extends Reason
case object FriendsOnly extends Reason
case object BotUltraBullet extends Reason
case object SelfChallenge extends Reason
}

def translated(d: ChallengeDenied)(implicit lang: Lang): String =
Expand All @@ -34,6 +35,7 @@ object ChallengeDenied {
case Reason.RatingIsProvisional(perf) => trans.cannotChallengeDueToProvisionalXRating.txt(perf.trans)
case Reason.FriendsOnly => trans.xOnlyAcceptsChallengesFromFriends.txt(d.dest.titleUsername)
case Reason.BotUltraBullet => "Bots cannot play UltraBullet. Choose a slower time control."
case Reason.SelfChallenge => "You cannot challenge yourself."
}
}

Expand Down Expand Up @@ -68,6 +70,7 @@ final class ChallengeGranter(
}
}
case (_, Pref.Challenge.ALWAYS) => none
case _ if from == dest => SelfChallenge.some
case _ => none
}
}
Expand All @@ -80,4 +83,4 @@ final class ChallengeGranter(
_.map { ChallengeDenied(dest, _) }
}

}
}