update crayhouse round pockets

This commit is contained in:
Thibault Duplessis 2016-01-20 23:15:23 +07:00
parent bdca3aa122
commit c5faeb32a5
4 changed files with 8 additions and 42 deletions

View file

@ -621,7 +621,7 @@ div.table {
transition: background-color 0.13s;
}
.pocket.usable piece:hover {
background: #999;
background-color: #999;
}
.pocket piece::after {
content: attr(data-nb);

View file

@ -2,21 +2,6 @@ var crazyDrag = require('./crazyDrag');
var partial = require('chessground').util.partial;
var m = require('mithril');
function crazyPocketTag(role, color) {
return {
tag: 'div',
attrs: {
class: 'no-square'
},
children: [{
tag: 'piece',
attrs: {
class: role + ' ' + color
}
}]
};
}
var eventNames = ['mousedown', 'touchstart'];
module.exports = {

View file

@ -5,10 +5,8 @@ var game = require('game').game;
module.exports = function(ctrl, e) {
if (e.button !== undefined && e.button !== 0) return; // only touch or left click
if (ctrl.replaying() || !game.isPlayerPlaying(ctrl.data)) return;
var node = e.target;
var role = node.getAttribute('data-role'),
color = node.getAttribute('data-color');
console.log(node, role, color);
var role = e.target.getAttribute('data-role'),
color = e.target.getAttribute('data-color');
if (!role || !color) return;
e.stopPropagation();
e.preventDefault();

View file

@ -4,21 +4,6 @@ var crazyDrag = require('./crazyDrag');
var game = require('game').game;
var m = require('mithril');
function crazyPocketTag(role, color) {
return {
tag: 'div',
attrs: {
class: 'no-square'
},
children: [{
tag: 'piece',
attrs: {
class: role + ' ' + color
}
}]
};
}
var eventNames = ['mousedown', 'touchstart'];
module.exports = {
@ -27,10 +12,9 @@ module.exports = {
if (!step.crazy) return;
var pocket = step.crazy.pockets[color === 'white' ? 0 : 1];
var oKeys = Object.keys(pocket)
var crowded = oKeys.length >= 4;
var usable = position === 'bottom' && !ctrl.replaying() && game.isPlayerPlaying(ctrl.data);
return m('div', {
class: 'pocket ' + position + (oKeys.length > 4 ? ' crowded' : '') + (usable ? ' usable' : ''),
class: 'pocket is2d ' + position + (usable ? ' usable' : ''),
config: position === 'bottom' ? function(el, isUpdate, context) {
if (isUpdate) return;
var onstart = partial(crazyDrag, ctrl);
@ -45,13 +29,12 @@ module.exports = {
} : null
},
oKeys.map(function(role) {
var pieces = [];
for (var i = 0; i < pocket[role]; i++) pieces.push(crazyPocketTag(role, color));
return m('div', {
class: 'role',
return m('piece', {
'data-role': role,
'data-color': color,
}, pieces);
'data-nb': pocket[role],
class: role + ' ' + color
});
})
);
}