Skip to content
Browse files

fixed various bugs.

- drawing undefined instead of letter
- placing multiple tiles in one space
- not being able to drag letters between spaces before playing them
  • Loading branch information...
1 parent b920f00 commit 3dd8833f05d9d144bad007190875d28e0c8fbb17 @icohen committed Dec 26, 2011
Showing with 20 additions and 18 deletions.
  1. +4 −0 public/css/style.css
  2. +3 −0 public/css/style.styl
  3. +8 −13 public/js/client.js
  4. +5 −5 scrabble.js
View
4 public/css/style.css
@@ -5,6 +5,9 @@
text-align: center;
border: 1px solid;
}
+.space .tile {
+ position: absolute;
+}
.tile {
text-align: center;
vertical-align: middle;
@@ -27,6 +30,7 @@
padding-left: 10px;
}
.rack .tile {
+ position: relative;
float: left;
margin: 4px 2px 0 2px;
}
View
3 public/css/style.styl
@@ -7,6 +7,8 @@ tiles = 7
height tile-size
text-align center
border 1px solid
+.space .tile
+ position absolute
.tile
text-align center
vertical-align middle
@@ -26,6 +28,7 @@ tiles = 7
margin-left 2px
padding-left 10px
.rack .tile
+ position relative
float left
margin 4px 2px 0 2px
ul.actions
View
21 public/js/client.js
@@ -15,29 +15,24 @@ $(function(){
connectWith: '.space',
revert: true,
stop: function (e, ui){
- console.log('stop', ui.draggable);
socket.emit('tile order change', getTilesFromRack());
},
- remove: function(e, ui){
- console.log('remove', ui.item);
- console.log('from', ui.sender);
- console.log('to', $(this));
- }
}).disableSelection();
$('.space')
.sortable({
- connectWith: '.rack',
+ connectWith: '.rack, .space',
revert: true,
- stop: function(e, ui){
- console.log('.space stop', ui.draggable);
- },
- }).disableSelection()
-
+ receive: function(e, ui){
+ if ($(this).find('.tile').size() > 1)
+ ui.sender.sortable('cancel');
+ }
+ }).disableSelection();
+
// events
$('#draw').click(function drawTilesHandler(){
socket.emit('draw tiles', getTilesFromRack());
});
- $('#play').click(function play(){
+ $('#play').click(function playHandler(){
var updates = {};
$('#board .not-played')
.each(function(){
View
10 scrabble.js
@@ -6,14 +6,14 @@ KJXQZ '; // created with ./bin/parse_letter_distributions.py and then added two
exports.getNewAndRemainingTiles = function(oldPlayerTiles, oldRemainingTiles){
var newTiles = ''
- , newRemainingTiles = ''
+ , newRemainingTiles = oldRemainingTiles
, tilesToGet = 7 - oldPlayerTiles.length
, pos;
for (var i = 0; i < tilesToGet; i++){
- pos = Math.floor(Math.random() * oldRemainingTiles.length);
- newTiles += oldRemainingTiles[pos];
- newRemainingTiles += oldRemainingTiles.substring(0, pos)
- + oldRemainingTiles.substring(pos+1);
+ pos = Math.floor(Math.random() * newRemainingTiles.length);
+ newTiles += newRemainingTiles[pos];
+ newRemainingTiles = newRemainingTiles.substring(0, pos)
+ + newRemainingTiles.substring(pos+1);
}
return [newTiles, newRemainingTiles];
}

0 comments on commit 3dd8833

Please sign in to comment.
Something went wrong with that request. Please try again.