Skip to content

Commit 01f56ee

Browse files
committed
Semi-thoroughly tested. Release?
1 parent ae0d0a6 commit 01f56ee

File tree

16 files changed

+3847
-98
lines changed

16 files changed

+3847
-98
lines changed

common/browser.js

+15-16
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,12 @@
2929
// https://stackoverflow.com/questions/11382495/how-to-be-sure-that-message-via-socket-io-has-been-received-to-the-client
3030
//
3131
// TO DO: middle mouse click = focus
32-
// TO DO: Shift-c reverse-sorts?
32+
// TO DO: Shift-c sort?
3333
// TO DO: Find a way to switch back to the more responsive piece rotation in board.draw(). (Make incremental changes to piece coordinates, rather than setting targets?)
3434
// TO DO: Add new_piece_layer integer for automatic layered drawing. It has to naturally stay sorted, or
3535
// else is_tray will not work, and selecting pieces would be a problem. Perhaps board.pieces should be {0:[], 1:[], ...}?
3636
// Alternatively, insert_piece() could auto-sort by checking piece layers and incrementing/decrementing when out of order.
37-
// TO DO: Server supplies a unique game id so you can work with multiple games of the same type? This would mean
38-
// setting up your views every time...
37+
// TO DO: Cookies assigned per web address AND game name.
3938

4039
//// OPTIONS
4140

@@ -187,7 +186,7 @@ function scramble_pieces(pieces, x, y, space, scale) {
187186
// x,y,r, angle,disable_snap,immediate
188187
p.set_target(x + d.n*a.x + d.m*b.x + v.x,
189188
y + d.n*a.y + d.m*b.y + v.y,
190-
(Math.random()-0.5)*720*scale, null, null, false);
189+
(Math.random()-0.5)*720*scale, null, true, false);
191190
p.active_image = rand_int(0, p.images.length-1);
192191
}
193192
}
@@ -310,10 +309,7 @@ function rotate_pieces(pieces, r_deg, immediate, x, y) {
310309

311310
// Get the center of the current target coordinates, and the origin target coordinates
312311
if(x == null || y == null) var d = get_center_of_pieces(pieces);
313-
else var d = {
314-
x :x,
315-
y :y,
316-
};
312+
else var d = {x:x,y:y};
317313

318314
for(var i in pieces) pieces[i].rotate(r_deg, d.x, d.y, immediate);
319315
}
@@ -624,7 +620,7 @@ function PIECE(board, piece_id, image_paths, private_image_paths) {
624620
PIECE.prototype.put_away = function() {
625621

626622
// x,y,r,angle,disable_snap,immediate
627-
this.set_target(this.board.box_x+this.box_x, this.board.box_y+this.box_y, 0, null, null, false);
623+
this.set_target(this.board.box_x+this.box_x, this.board.box_y+this.box_y, 0, null, true, false);
628624
return this;
629625
}
630626

@@ -654,17 +650,20 @@ PIECE.prototype.get_dimensions = function() {
654650
return {width: w, height: h, max: Math.max(w, h), min: Math.min(w, h)};
655651
}
656652

657-
// set the target location and rotation all then rotated by angle
653+
// set the target location x,y and rotation r, and everything rotated about the board origin by angle
658654
PIECE.prototype.set_target = function(x,y,r,angle,disable_snap,immediate) {
659655

660656
// Set default argument values
661657
x = or_default(x, this.x_target);
662658
y = or_default(y, this.y_target);
663659
r = or_default(r, null);
664-
angle = or_default(angle, null);
660+
angle = or_default(angle, null);
665661
disable_snap = or_default(disable_snap, false);
666662
immediate = or_default(immediate, false);
667-
663+
664+
// Always disable if held. This causes a single piece to not be let go on mouseup!
665+
//disable_snap = disable_snap || board.find_holding_client_index(this) >= 0;
666+
668667
// if we're supposed to transform the coordinates
669668
if(angle != null) {
670669
var v = rotate_vector(x, y, angle);
@@ -745,7 +744,7 @@ PIECE.prototype.rotate = function(r_deg, x0, y0, immediate) {
745744
// If specified, rotate about the supplied center coordinate
746745
if(x0 != this.x_target || y0 != this.y_target) {
747746
var d = rotate_vector(this.x_target-x0, this.y_target-y0, -r_deg);
748-
this.set_target(x0 + d.x, y0 + d.y, r_deg + this.r_target, null, null, immediate);
747+
this.set_target(x0 + d.x, y0 + d.y, r_deg + this.r_target, null, true, immediate);
749748
}
750749

751750
// Otherwise rotate around its center.
@@ -1624,7 +1623,7 @@ BOARD.prototype.collect_pieces = function(pieces,x,y,shuffle,active_image,r_piec
16241623
// x,y,r,angle,disable_snap,immediate
16251624
pieces[n].set_target(pieces[n].x + (Math.random()-0.5)*this.shuffle_distance,
16261625
pieces[n].y + (Math.random()-0.5)*this.shuffle_distance,
1627-
(Math.random()-0.5)*720, null, null, true);
1626+
(Math.random()-0.5)*720, null, true, true);
16281627

16291628
// Trigger an update to tell everyone the new locations
16301629
this.send_stream_update();
@@ -1656,7 +1655,7 @@ BOARD.prototype.collect_pieces = function(pieces,x,y,shuffle,active_image,r_piec
16561655
else {x = x+d.x; y = y-d.y;}
16571656

16581657
// x, y, r, angle, disable_snap, immediate
1659-
p.set_target(x, y, -r_piece, null, null, false);
1658+
p.set_target(x, y, -r_piece, null, true, false);
16601659

16611660
// If we have an active image specified, set it
16621661
if(active_image != null) p.set_active_image(active_image);
@@ -1728,7 +1727,7 @@ BOARD.prototype.expand_pieces = function(pieces, number_per_row, x, y, spacing_x
17281727
sps.push(p);
17291728

17301729
// Now set the coordinates x,y,r,angle,disable_snap,immediate
1731-
p.set_target(x+d.x,y+d.y,r_piece-this.r_target, null, null, false);
1730+
p.set_target(x+d.x,y+d.y,r_piece-this.r_target, null, true, false);
17321731

17331732
// Set the image
17341733
if(active_image != null) p.active_image = active_image;

common/images/measurement/grid.png

23.3 KB
Loading

common/images/measurement/measurements.svg

+95-18
Loading

common/images/measurement/rings.png

-2.22 KB
Loading

common/index.html

-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@
9797
<div id="controls" class="user-container raised">
9898

9999
<table class="tight" style="width:100%">
100-
<tr><td class="tight"><b>Table </b></td></tr>
101100
<tr>
102101
<td class="tight">
103102
<a href="/rules" target="new">Rules</a> <a href='/controls' target="new">Controls</a>

0 commit comments

Comments
 (0)