Skip to content

Commit f92dbfc

Browse files
committed
deselect_pieces function
1 parent 3c57e96 commit f92dbfc

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

common/browser.js

+8
Original file line numberDiff line numberDiff line change
@@ -2205,6 +2205,14 @@ BOARD.prototype.deselect_piece = function(piece) {
22052205
}
22062206
}
22072207

2208+
/**
2209+
* Deselects the supplied list (or all pieces if none supplied)
2210+
*/
2211+
BOARD.prototype.deselect_pieces = function(pieces) {
2212+
pieces = or_default(pieces, board.pieces);
2213+
for(var n in pieces) this.deselect_piece(pieces[n]);
2214+
}
2215+
22082216
// whenever someone clicks the mouse
22092217
BOARD.prototype.event_mousedown = function(e) {
22102218

games/cards/game.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ function setup() {
138138

139139
// Avatars
140140
board.expand_pieces(board.avatars, 8, 0, 1000, 100, 100, 0, 0, 0);
141+
142+
// Deselect everything
143+
board.deselect_pieces();
141144
}
142145

143146
function collect_all_cards() {
@@ -147,7 +150,7 @@ function collect_all_cards() {
147150
var team = get_team_number();
148151

149152
// Unselect all cards from all clients
150-
for(var n in cards) board.deselect_piece(cards[n]);
153+
board.deselect_pieces(cards);
151154

152155
// Make them your selection if they're within R2 (so you can disable cards)
153156
var sps = [];

games/poker/game.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ function setup() {
193193

194194
// Avatars
195195
board.expand_pieces(board.avatars, 8, 0, 1000, 100, 100, 0, 0, 0);
196+
197+
// Deselect everything
198+
board.deselect_pieces();
196199
}
197200

198201
function collect_all_cards() {
@@ -202,7 +205,7 @@ function collect_all_cards() {
202205
var team = get_team_number();
203206

204207
// Unselect all cards from all clients
205-
for(var n in cards) board.deselect_piece(cards[n]);
208+
board.deselect_pieces(cards);
206209

207210
// Make them your selection if they're within R2 (so you can disable cards)
208211
var sps = [];

0 commit comments

Comments
 (0)