add user preference to disable premoves
This commit is contained in:
parent
5452629b93
commit
87131a272e
|
@ -23,6 +23,10 @@
|
|||
@base.checkbox(form("clockTenths"), "Chess clock: show tenths of seconds", 1)
|
||||
<p class="help">Only visible under 10 seconds.</p>
|
||||
<li>
|
||||
<li>
|
||||
@base.checkbox(form("premove"), "Player: enable premoves", 1)
|
||||
<p class="help">Make a move before the opponent response</p>
|
||||
<li>
|
||||
<input type="submit" class="submit button" value="@trans.apply()" />
|
||||
</li>
|
||||
</ul>
|
||||
|
|
|
@ -22,7 +22,7 @@ signedJs = pov.game.rated option routes.Round.signedJs(pov.gameId) map (_.toStri
|
|||
data-players-url="@routes.Round.players(gameId)">
|
||||
<div class="lichess_board_wrap">
|
||||
<div class="lichess_board with_marks">@Html(lila.app.ui.Board.render(pov))</div>
|
||||
<div id="premove">@trans.premoveEnabledClickAnywhereToCancel()</div>
|
||||
<div id="premove_alert">@trans.premoveEnabledClickAnywhereToCancel()</div>
|
||||
</div>
|
||||
<div class="lichess_ground">
|
||||
@round.cemetery(pov, "top")
|
||||
|
|
|
@ -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 ⇒
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
)
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
3
todo
3
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)
|
||||
|
|
Loading…
Reference in a new issue