support for piece drop confirmation
This commit is contained in:
parent
eb961d3eeb
commit
416ed3ce32
|
@ -34,6 +34,7 @@ module.exports = function(opts) {
|
||||||
redirecting: false,
|
redirecting: false,
|
||||||
replayHash: '',
|
replayHash: '',
|
||||||
moveToSubmit: null,
|
moveToSubmit: null,
|
||||||
|
dropToSubmit: null,
|
||||||
buttonFeedback: null,
|
buttonFeedback: null,
|
||||||
goneBerserk: {},
|
goneBerserk: {},
|
||||||
resignConfirm: false,
|
resignConfirm: false,
|
||||||
|
@ -58,9 +59,9 @@ module.exports = function(opts) {
|
||||||
this.sendMove(orig, dest, false, meta.premove);
|
this.sendMove(orig, dest, false, meta.premove);
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
|
||||||
var onUserNewPiece = function(role, key) {
|
var onUserNewPiece = function(role, key, meta) {
|
||||||
if (!this.replaying() && crazyValid.drop(this.chessground, this.data, role, key))
|
if (!this.replaying() && crazyValid.drop(this.chessground, this.data, role, key))
|
||||||
this.sendNewPiece(role, key);
|
this.sendNewPiece(role, key, meta.predrop);
|
||||||
else this.jump(this.vm.ply);
|
else this.jump(this.vm.ply);
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
|
||||||
|
@ -159,14 +160,17 @@ module.exports = function(opts) {
|
||||||
});
|
});
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
|
||||||
this.sendNewPiece = function(role, key) {
|
this.sendNewPiece = function(role, key, isPredrop) {
|
||||||
var drop = {
|
var drop = {
|
||||||
role: role,
|
role: role,
|
||||||
pos: key
|
pos: key
|
||||||
};
|
};
|
||||||
if (this.clock) drop.lag = Math.round(lichess.socket.averageLag);
|
if (this.clock) drop.lag = Math.round(lichess.socket.averageLag);
|
||||||
this.resign(false);
|
this.resign(false);
|
||||||
this.socket.send('drop', drop, {
|
if (this.userId && this.data.pref.submitMove && !isPredrop) {
|
||||||
|
this.vm.dropToSubmit = drop;
|
||||||
|
m.redraw();
|
||||||
|
} else this.socket.send('drop', drop, {
|
||||||
ackable: true
|
ackable: true
|
||||||
});
|
});
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
@ -369,13 +373,19 @@ module.exports = function(opts) {
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
|
||||||
this.submitMove = function(v) {
|
this.submitMove = function(v) {
|
||||||
if (v && this.vm.moveToSubmit) {
|
if (v && (this.vm.moveToSubmit || this.vm.dropToSubmit)) {
|
||||||
this.socket.send('move', this.vm.moveToSubmit, {
|
if (this.vm.moveToSubmit)
|
||||||
ackable: true
|
this.socket.send('move', this.vm.moveToSubmit, {
|
||||||
});
|
ackable: true
|
||||||
|
});
|
||||||
|
else if (this.vm.dropToSubmit)
|
||||||
|
this.socket.send('drop', this.vm.dropToSubmit, {
|
||||||
|
ackable: true
|
||||||
|
});
|
||||||
$.sound.confirmation();
|
$.sound.confirmation();
|
||||||
} else this.jump(this.vm.ply);
|
} else this.jump(this.vm.ply);
|
||||||
this.vm.moveToSubmit = null;
|
this.vm.moveToSubmit = null;
|
||||||
|
this.vm.dropToSubmit = null;
|
||||||
this.vm.buttonFeedback = setTimeout(function() {
|
this.vm.buttonFeedback = setTimeout(function() {
|
||||||
this.vm.buttonFeedback = null;
|
this.vm.buttonFeedback = null;
|
||||||
m.redraw();
|
m.redraw();
|
||||||
|
|
|
@ -106,7 +106,7 @@ module.exports = {
|
||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
submitMove: function(ctrl) {
|
submitMove: function(ctrl) {
|
||||||
if (ctrl.vm.moveToSubmit) return [
|
if (ctrl.vm.moveToSubmit || ctrl.vm.dropToSubmit) return [
|
||||||
m('a.button.text[data-icon=E]', {
|
m('a.button.text[data-icon=E]', {
|
||||||
onclick: partial(ctrl.submitMove, true),
|
onclick: partial(ctrl.submitMove, true),
|
||||||
}, 'Submit move'),
|
}, 'Submit move'),
|
||||||
|
|
|
@ -89,7 +89,7 @@ function renderTablePlay(ctrl) {
|
||||||
]);
|
]);
|
||||||
return [
|
return [
|
||||||
renderReplay(ctrl),
|
renderReplay(ctrl),
|
||||||
ctrl.vm.moveToSubmit ? null : (
|
(ctrl.vm.moveToSubmit || ctrl.vm.dropToSubmit) ? null : (
|
||||||
button.feedback(ctrl) || m('div.control.icons', [
|
button.feedback(ctrl) || m('div.control.icons', [
|
||||||
game.abortable(d) ? button.standard(ctrl, null, 'L', 'abortGame', 'abort') :
|
game.abortable(d) ? button.standard(ctrl, null, 'L', 'abortGame', 'abort') :
|
||||||
button.standard(ctrl, game.takebackable, 'i', 'proposeATakeback', 'takeback-yes', ctrl.takebackYes),
|
button.standard(ctrl, game.takebackable, 'i', 'proposeATakeback', 'takeback-yes', ctrl.takebackYes),
|
||||||
|
|
Loading…
Reference in a new issue