crazyhouse: can hover the drop on opponent turn
This commit is contained in:
parent
8a0fe82660
commit
ed52974a56
|
@ -4,7 +4,7 @@ var game = require('game').game;
|
|||
|
||||
module.exports = function(ctrl, e) {
|
||||
if (e.button !== 0) return; // only left click
|
||||
if (!game.isPlayerTurn(ctrl.data)) return;
|
||||
if (!game.isPlayerPlaying(ctrl.data)) return;
|
||||
var node = e.target.parentNode.parentNode;
|
||||
var role = node.getAttribute('data-role'),
|
||||
color = node.getAttribute('data-color');
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
var util = require('./util');
|
||||
var game = require('game').game;
|
||||
|
||||
module.exports = {
|
||||
|
||||
validateDrop: function(chessground, dropStr, piece, pos) {
|
||||
validateDrop: function(chessground, data, piece, pos) {
|
||||
|
||||
if (!game.isPlayerTurn(data)) return false;
|
||||
|
||||
if (piece.role === 'pawn' && (pos[1] === '1' || pos[1] === '8')) return false;
|
||||
|
||||
var dropStr = data.possibleDrops;
|
||||
|
||||
if (typeof dropStr === 'undefined' || dropStr === null) return true;
|
||||
|
||||
var drops = dropStr.match(/.{2}/g) || [];
|
||||
|
|
|
@ -59,7 +59,7 @@ module.exports = function(opts) {
|
|||
}.bind(this);
|
||||
|
||||
var onUserNewPiece = function(piece, pos) {
|
||||
if (crazyhouse.validateDrop(this.chessground, this.data.possibleDrops, piece, pos))
|
||||
if (crazyhouse.validateDrop(this.chessground, this.data, piece, pos))
|
||||
this.sendNewPiece(piece.role, pos);
|
||||
else this.jump(this.vm.ply);
|
||||
}.bind(this);
|
||||
|
|
Loading…
Reference in a new issue