diff --git a/app/views/account/pref.scala.html b/app/views/account/pref.scala.html
index 21934e8d50..63cd7f6484 100644
--- a/app/views/account/pref.scala.html
+++ b/app/views/account/pref.scala.html
@@ -23,6 +23,10 @@
@base.checkbox(form("clockTenths"), "Chess clock: show tenths of seconds", 1)
Only visible under 10 seconds.
+
+ @base.checkbox(form("premove"), "Player: enable premoves", 1)
+ Make a move before the opponent response
+
diff --git a/app/views/round/player.scala.html b/app/views/round/player.scala.html
index eaccd34592..d33cdd6b10 100644
--- a/app/views/round/player.scala.html
+++ b/app/views/round/player.scala.html
@@ -22,7 +22,7 @@ signedJs = pov.game.rated option routes.Round.signedJs(pov.gameId) map (_.toStri
data-players-url="@routes.Round.players(gameId)">
@Html(lila.app.ui.Board.render(pov))
-
@trans.premoveEnabledClickAnywhereToCancel()
+
@trans.premoveEnabledClickAnywhereToCancel()
@round.cemetery(pov, "top")
diff --git a/modules/pref/src/main/DataForm.scala b/modules/pref/src/main/DataForm.scala
index 05588800a1..04426797fd 100644
--- a/modules/pref/src/main/DataForm.scala
+++ b/modules/pref/src/main/DataForm.scala
@@ -9,23 +9,27 @@ private[pref] final class DataForm(api: PrefApi) {
val pref = Form(mapping(
"autoQueen" -> number.verifying(Pref.AutoQueen.choices.toMap contains _),
- "clockTenths" -> optional(number)
+ "clockTenths" -> optional(number),
+ "premove" -> optional(number)
)(PrefData.apply)(PrefData.unapply))
case class PrefData(
autoQueen: Int,
- clockTenths: Option[Int]) {
+ clockTenths: Option[Int],
+ premove: Option[Int]) {
def apply(pref: Pref) = pref.copy(
autoQueen = autoQueen,
- clockTenths = clockTenths.isDefined)
+ clockTenths = clockTenths.isDefined,
+ premove = premove.isDefined)
}
object PrefData {
def apply(pref: Pref): PrefData = PrefData(
autoQueen = pref.autoQueen,
- clockTenths = pref.clockTenths option 1)
+ clockTenths = pref.clockTenths option 1,
+ premove = pref.premove option 1)
}
def prefOf(user: User): Fu[Form[PrefData]] = api getPref user map { p ⇒
diff --git a/modules/pref/src/main/Pref.scala b/modules/pref/src/main/Pref.scala
index 928a2527e1..1a00285d60 100644
--- a/modules/pref/src/main/Pref.scala
+++ b/modules/pref/src/main/Pref.scala
@@ -7,7 +7,8 @@ case class Pref(
dark: Boolean,
theme: String,
autoQueen: Int,
- clockTenths: Boolean) {
+ clockTenths: Boolean,
+ premove: Boolean) {
def realTheme = Theme(theme)
@@ -41,7 +42,8 @@ object Pref {
dark = false,
theme = Theme.default.name,
autoQueen = AutoQueen.PREMOVE,
- clockTenths = true)
+ clockTenths = true,
+ premove = true)
val default = create("")
@@ -61,5 +63,6 @@ object Pref {
"dark" -> default.dark,
"theme" -> default.theme,
"autoQueen" -> default.autoQueen,
- "clockTenths" -> true)
+ "clockTenths" -> default.clockTenths,
+ "premove" -> default.premove)
}
diff --git a/modules/round/src/main/RoundHelper.scala b/modules/round/src/main/RoundHelper.scala
index 55611ba9d8..87a97d063b 100644
--- a/modules/round/src/main/RoundHelper.scala
+++ b/modules/round/src/main/RoundHelper.scala
@@ -42,6 +42,7 @@ trait RoundHelper { self: PrefHelper ⇒
"animation_delay" -> animationDelay(pov),
"autoQueen" -> pref.autoQueen,
"clockTenths" -> pref.clockTenths,
+ "enablePremove" -> pref.premove,
"tournament_id" -> game.tournamentId
)
}
diff --git a/public/javascripts/big.js b/public/javascripts/big.js
index 3378654f5b..9ed3203828 100644
--- a/public/javascripts/big.js
+++ b/public/javascripts/big.js
@@ -1023,10 +1023,12 @@ var storage = {
});
},
premove: function() {
- self.element.queue(function() {
- self.applyPremove();
- self.element.dequeue();
- });
+ if (self.options.enablePremove) {
+ self.element.queue(function() {
+ self.applyPremove();
+ self.element.dequeue();
+ });
+ }
},
crowd: function(event) {
$(["white", "black"]).each(function() {
@@ -1170,7 +1172,7 @@ var storage = {
},
applyPremove: function() {
var self = this;
- if (self.premove && self.isMyTurn()) {
+ if (self.options.enablePremove && self.premove && self.isMyTurn()) {
var move = self.premove;
self.unsetPremove();
if (self.possibleMovesContain(move.from, move.to)) {
@@ -1185,19 +1187,19 @@ var storage = {
},
setPremove: function(move) {
var self = this;
- if (self.isMyTurn()) return;
+ if (!self.options.enablePremove || self.isMyTurn()) return;
self.unsetPremove();
if (!self.validMove(move.from, move.to, move.piece)) return;
self.premove = move;
$("#" + move.from + ",#" + move.to).addClass("premoved");
self.unselect();
- $("#premove").show();
+ $("#premove_alert").show();
},
unsetPremove: function() {
var self = this;
self.premove = null;
self.$board.find('div.lcs.premoved').removeClass('premoved');
- $("#premove").hide();
+ $("#premove_alert").hide();
},
unselect: function() {
this.$board.find('> div.selected').removeClass('selected');
diff --git a/public/stylesheets/board.css b/public/stylesheets/board.css
index 84f45155a8..620b92615d 100644
--- a/public/stylesheets/board.css
+++ b/public/stylesheets/board.css
@@ -161,7 +161,7 @@ div.lichess_overboard p.explanations {
text-align: left;
padding-left: 1em;
}
-#premove, #dont_touch {
+#premove_alert, #dont_touch {
display: none;
position: absolute;
top: 512px;
diff --git a/public/stylesheets/user-form.css b/public/stylesheets/user-form.css
index 0ac76d3a8e..85659c7ad5 100644
--- a/public/stylesheets/user-form.css
+++ b/public/stylesheets/user-form.css
@@ -4,7 +4,7 @@
.content_box form li {
display: block;
list-style: none outside none;
- margin: 1em 0;
+ margin: 2em 0;
}
.content_box form .field label {
display: block;
@@ -24,5 +24,6 @@ form .error {
margin-left: 160px;
}
form .help {
+ font-size: 80%;
margin-left: 160px;
}
diff --git a/todo b/todo
index 33579a7720..1e2bade2ef 100644
--- a/todo
+++ b/todo
@@ -75,5 +75,4 @@ people page = trends by day, week, month. user achievments?
user options: premove, sounds, sound choice
user stats: http://en.lichess.org/forum/lichess-feedback/feature-request-extended-stats
forum improvements http://en.lichess.org/forum/lichess-feedback/suggestions-for-the-forum#1
-analysis 64... Kg6 should be blunder, not mistake
-real tournaments (round robin/swiss) (hellball)
+realt tournaments (round robin/swiss) (hellball)