Skip to content

Commit 7b0ae6e

Browse files
committed
fix rating of challenge from position - closes lichess-org#1680
1 parent b700d2d commit 7b0ae6e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

modules/challenge/src/main/Challenge.scala

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package lila.challenge
22

3-
import chess.variant.Variant
3+
import chess.variant.{Variant, FromPosition}
44
import chess.{ Mode, Clock, Speed }
55
import org.joda.time.DateTime
66

@@ -102,11 +102,13 @@ object Challenge {
102102
case _ => Speed.Correspondence
103103
}
104104

105-
private def perfTypeOf(variant: Variant, timeControl: TimeControl) =
105+
private def perfTypeOf(variant: Variant, timeControl: TimeControl): PerfType =
106106
PerfPicker.perfType(speedOf(timeControl), variant, timeControl match {
107107
case TimeControl.Correspondence(d) => d.some
108108
case _ => none
109-
}) | PerfType.Correspondence
109+
}).orElse {
110+
(variant == FromPosition) option perfTypeOf(chess.variant.Standard, timeControl)
111+
}.|(PerfType.Correspondence)
110112

111113
private val idSize = 8
112114

@@ -133,7 +135,7 @@ object Challenge {
133135
_id = randomId,
134136
status = Status.Created,
135137
variant = variant,
136-
initialFen = initialFen.ifTrue(variant == chess.variant.FromPosition),
138+
initialFen = initialFen.ifTrue(variant == FromPosition),
137139
timeControl = timeControl,
138140
mode = mode,
139141
colorChoice = colorChoice,

0 commit comments

Comments
 (0)