forked from lichess-org/lila
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSetupHelper.scala
228 lines (190 loc) · 8.37 KB
/
SetupHelper.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
package lila.app
package templating
import chess.{ Mode, Speed }
import lila.api.Context
import lila.i18n.{ I18nKeys => trans }
import lila.pref.Pref
import lila.report.Reason
import lila.setup.TimeMode
import lila.tournament.System
trait SetupHelper { self: I18nHelper =>
type SelectChoice = (String, String, Option[String])
val clockTimeChoices: List[SelectChoice] = List(
("0", "0", none),
("0.25", "¼", none),
("0.5", "½", none),
("0.75", "¾", none)
) ::: List(
"1", "1.5", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16",
"17", "18", "19", "20", "25", "30", "35", "40", "45", "60", "90", "120", "150", "180"
).map { v => (v.toString, v.toString, none) }
val clockIncrementChoices: List[SelectChoice] = {
(0 to 20).toList ::: List(25, 30, 35, 40, 45, 60, 90, 120, 150, 180)
} map { s =>
(s.toString, s.toString, none)
}
val corresDaysChoices: List[SelectChoice] =
("1", "One day", none) :: List(2, 3, 5, 7, 10, 14).map { d =>
(d.toString, s"${d} days", none)
}
def translatedTimeModeChoices(implicit ctx: Context) = List(
(TimeMode.RealTime.id.toString, trans.realTime.txt(), none),
(TimeMode.Correspondence.id.toString, trans.correspondence.txt(), none),
(TimeMode.Unlimited.id.toString, trans.unlimited.txt(), none)
)
def translatedReasonChoices(implicit ctx: Context) = List(
(Reason.Cheat.key, trans.cheat.txt()),
(Reason.Comm.key, trans.insult.txt()),
(Reason.Comm.key, trans.troll.txt()),
(Reason.Other.key, trans.other.txt())
)
def translatedModeChoices(implicit ctx: Context) = List(
(Mode.Casual.id.toString, trans.casual.txt(), none),
(Mode.Rated.id.toString, trans.rated.txt(), none)
)
def translatedModeChoicesTournament(implicit ctx: Context) = List(
(Mode.Casual.id.toString, trans.casualTournament.txt(), none),
(Mode.Rated.id.toString, trans.ratedTournament.txt(), none)
)
def translatedSystemChoices(implicit ctx: Context) = List(
System.Arena.id.toString -> "Arena"
)
private def variantTuple(variant: chess.variant.Variant)(implicit ctx: Context): SelectChoice =
(variant.id.toString, variant.name, variant.title.some)
def translatedVariantChoices(implicit ctx: Context) = List(
(chess.variant.Standard.id.toString, trans.standard.txt(), chess.variant.Standard.title.some)
)
def translatedVariantChoicesWithVariants(implicit ctx: Context) =
translatedVariantChoices(ctx) :+
variantTuple(chess.variant.Crazyhouse) :+
variantTuple(chess.variant.Chess960) :+
variantTuple(chess.variant.KingOfTheHill) :+
variantTuple(chess.variant.ThreeCheck) :+
variantTuple(chess.variant.Antichess) :+
variantTuple(chess.variant.Atomic) :+
variantTuple(chess.variant.Horde) :+
variantTuple(chess.variant.RacingKings)
def translatedVariantChoicesWithFen(implicit ctx: Context) =
translatedVariantChoices(ctx) :+
variantTuple(chess.variant.Chess960) :+
variantTuple(chess.variant.FromPosition)
def translatedAiVariantChoices(implicit ctx: Context) =
translatedVariantChoices(ctx) :+
variantTuple(chess.variant.Crazyhouse) :+
variantTuple(chess.variant.Chess960) :+
variantTuple(chess.variant.KingOfTheHill) :+
variantTuple(chess.variant.ThreeCheck) :+
variantTuple(chess.variant.Antichess) :+
variantTuple(chess.variant.Atomic) :+
variantTuple(chess.variant.Horde) :+
variantTuple(chess.variant.RacingKings) :+
variantTuple(chess.variant.FromPosition)
def translatedVariantChoicesWithVariantsAndFen(implicit ctx: Context) =
translatedVariantChoicesWithVariants :+
variantTuple(chess.variant.FromPosition)
def translatedSpeedChoices(implicit ctx: Context) = Speed.limited map { s =>
val minutes = s.range.max / 60 + 1
(
s.id.toString,
s.toString + " - " + trans.lessThanNbMinutes.pluralSameTxt(minutes),
none
)
}
def translatedSideChoices(implicit ctx: Context) = List(
("black", trans.black.txt(), none),
("random", trans.randomColor.txt(), none),
("white", trans.white.txt(), none)
)
def translatedAnimationChoices(implicit ctx: Context) = List(
(Pref.Animation.NONE, trans.none.txt()),
(Pref.Animation.FAST, trans.fast.txt()),
(Pref.Animation.NORMAL, trans.normal.txt()),
(Pref.Animation.SLOW, trans.slow.txt())
)
def translatedBoardCoordinateChoices(implicit ctx: Context) = List(
(Pref.Coords.NONE, trans.no.txt()),
(Pref.Coords.INSIDE, trans.insideTheBoard.txt()),
(Pref.Coords.OUTSIDE, trans.outsideTheBoard.txt())
)
def translatedMoveListWhilePlayingChoices(implicit ctx: Context) = List(
(Pref.Replay.NEVER, trans.never.txt()),
(Pref.Replay.SLOW, trans.onSlowGames.txt()),
(Pref.Replay.ALWAYS, trans.always.txt())
)
def translatedPieceNotationChoices(implicit ctx: Context) = List(
(Pref.PieceNotation.SYMBOL, trans.chessPieceSymbol.txt()),
(Pref.PieceNotation.LETTER, trans.pgnLetter.txt())
)
def translatedClockTenthsChoices(implicit ctx: Context) = List(
(Pref.ClockTenths.NEVER, trans.never.txt()),
(Pref.ClockTenths.LOWTIME, trans.whenTimeRemainingLessThanTenSeconds.txt()),
(Pref.ClockTenths.ALWAYS, trans.always.txt())
)
def translatedMoveEventChoices(implicit ctx: Context) = List(
(Pref.MoveEvent.CLICK, trans.clickTwoSquares.txt()),
(Pref.MoveEvent.DRAG, trans.dragPiece.txt()),
(Pref.MoveEvent.BOTH, trans.bothClicksAndDrag.txt())
)
def translatedTakebackChoices(implicit ctx: Context) = List(
(Pref.Takeback.NEVER, trans.never.txt()),
(Pref.Takeback.ALWAYS, trans.always.txt()),
(Pref.Takeback.CASUAL, trans.inCasualGamesOnly.txt())
)
def translatedMoretimeChoices(implicit ctx: Context) = List(
(Pref.Moretime.NEVER, trans.never.txt()),
(Pref.Moretime.ALWAYS, trans.always.txt()),
(Pref.Moretime.CASUAL, trans.inCasualGamesOnly.txt())
)
def translatedAutoQueenChoices(implicit ctx: Context) = List(
(Pref.AutoQueen.NEVER, trans.never.txt()),
(Pref.AutoQueen.PREMOVE, trans.whenPremoving.txt()),
(Pref.AutoQueen.ALWAYS, trans.always.txt())
)
def translatedAutoThreefoldChoices(implicit ctx: Context) = List(
(Pref.AutoThreefold.NEVER, trans.never.txt()),
(Pref.AutoThreefold.ALWAYS, trans.always.txt()),
(Pref.AutoThreefold.TIME, trans.whenTimeRemainingLessThanThirtySeconds.txt())
)
def submitMoveChoices(implicit ctx: Context) = List(
(Pref.SubmitMove.NEVER, trans.never.txt()),
(Pref.SubmitMove.CORRESPONDENCE_ONLY, trans.inCorrespondenceGames.txt()),
(Pref.SubmitMove.CORRESPONDENCE_UNLIMITED, trans.correspondenceAndUnlimited.txt()),
(Pref.SubmitMove.ALWAYS, trans.always.txt())
)
def confirmResignChoices(implicit ctx: Context) = List(
(Pref.ConfirmResign.NO, trans.no.txt()),
(Pref.ConfirmResign.YES, trans.yes.txt())
)
def translatedRookCastleChoices(implicit ctx: Context) = List(
(Pref.RookCastle.NO, trans.castleByMovingTwoSquares.txt()),
(Pref.RookCastle.YES, trans.castleByMovingOntoTheRook.txt())
)
def translatedChallengeChoices(implicit ctx: Context) = List(
(Pref.Challenge.NEVER, trans.never.txt()),
(Pref.Challenge.RATING, trans.ifRatingIsPlusMinusX.txt(lila.pref.Pref.Challenge.ratingThreshold)),
(Pref.Challenge.FRIEND, trans.onlyFriends.txt()),
(Pref.Challenge.ALWAYS, trans.always.txt())
)
def translatedMessageChoices(implicit ctx: Context) = privacyBaseChoices
def translatedStudyInviteChoices(implicit ctx: Context) = privacyBaseChoices
def translatedPalantirChoices(implicit ctx: Context) = privacyBaseChoices
def privacyBaseChoices(implicit ctx: Context) = List(
(Pref.StudyInvite.NEVER, trans.never.txt()),
(Pref.StudyInvite.FRIEND, trans.onlyFriends.txt()),
(Pref.StudyInvite.ALWAYS, trans.always.txt())
)
def translatedInsightShareChoices(implicit ctx: Context) = List(
(Pref.InsightShare.NOBODY, trans.withNobody.txt()),
(Pref.InsightShare.FRIENDS, trans.withFriends.txt()),
(Pref.InsightShare.EVERYBODY, trans.withEverybody.txt())
)
def translatedBoardResizeHandleChoices(implicit ctx: Context) = List(
(Pref.ResizeHandle.NEVER, trans.never.txt()),
(Pref.ResizeHandle.INITIAL, trans.onlyOnInitialPosition.txt()),
(Pref.ResizeHandle.ALWAYS, trans.always.txt())
)
def translatedBlindfoldChoices(implicit ctx: Context) = List(
Pref.Blindfold.NO -> trans.no.txt(),
Pref.Blindfold.YES -> trans.yes.txt()
)
}