[bknr-cvs] r2240 - in branches/trunk-reorg/projects/scrabble: src website

bknr at bknr.net bknr at bknr.net
Sun Oct 14 20:28:22 UTC 2007


Author: hhubner
Date: 2007-10-14 16:28:22 -0400 (Sun, 14 Oct 2007)
New Revision: 2240

Modified:
   branches/trunk-reorg/projects/scrabble/src/game.lisp
   branches/trunk-reorg/projects/scrabble/src/web.lisp
   branches/trunk-reorg/projects/scrabble/website/scrabble.css
   branches/trunk-reorg/projects/scrabble/website/scrabble.html
   branches/trunk-reorg/projects/scrabble/website/scrabble.js
Log:
tweak json output so that letters of the logged-on user are transmitted,
other player's trays are reported as counts only.
add html/css to display other player trays and score.


Modified: branches/trunk-reorg/projects/scrabble/src/game.lisp
===================================================================
--- branches/trunk-reorg/projects/scrabble/src/game.lisp	2007-10-14 19:27:25 UTC (rev 2239)
+++ branches/trunk-reorg/projects/scrabble/src/game.lisp	2007-10-14 20:28:22 UTC (rev 2240)
@@ -29,7 +29,7 @@
 (define-condition no-tiles-remaining (simple-error)
   ())
 
-(defmethod draw-tile ((tile-bag tile-bag))
+(deftransaction draw-tile (tile-bag)
   (unless (plusp (remaining-tile-count tile-bag))
     (error 'no-tiles-remaining))
   (with-slots (tiles) tile-bag

Modified: branches/trunk-reorg/projects/scrabble/src/web.lisp
===================================================================
--- branches/trunk-reorg/projects/scrabble/src/web.lisp	2007-10-14 19:27:25 UTC (rev 2239)
+++ branches/trunk-reorg/projects/scrabble/src/web.lisp	2007-10-14 20:28:22 UTC (rev 2240)
@@ -37,8 +37,13 @@
   (princ #\] stream))
 
 (defmethod encode-json ((participant participant) stream)
-  (encode-json-alist (list :name (user-full-name (player-of participant))
-			   :remaining-tiles (length (tray-of participant)))
+  (start-session)
+  (encode-json-alist (append (list :name (user-full-name (player-of participant))
+                                   :remaining-tiles)
+                             (list (if (equal (user-login (player-of participant))
+                                              (session-value :user))
+                                       (tray-of participant)
+                                       (length (tray-of participant)))))
 		     stream))
 
 (define-easy-handler (login :uri "/login" :default-request-type :post)

Modified: branches/trunk-reorg/projects/scrabble/website/scrabble.css
===================================================================
--- branches/trunk-reorg/projects/scrabble/website/scrabble.css	2007-10-14 19:27:25 UTC (rev 2239)
+++ branches/trunk-reorg/projects/scrabble/website/scrabble.css	2007-10-14 20:28:22 UTC (rev 2240)
@@ -1,4 +1,4 @@
-body { background-color: #004B36 }
+body { background-color: #004B36; color: #ffffff; font-family: sans-serif }
 #playfield { position: absolute }
 #playfield div { position: absolute; width: 40px; height: 40px }
 #playfield img { position: absolute; top: 3px; left: 3px }
@@ -234,3 +234,43 @@
 #playfield #my-tray-4 { left: 346; top: 665 }
 #playfield #my-tray-5 { left: 384; top: 665 }
 #playfield #my-tray-6 { left: 422; top: 665 }
+#playfield #their-name-0 { left: 670; top: 0 }
+#playfield #their-score-0 { left: 887; top: 0; text-align: right }
+#playfield #their-tray-0-0 { left: 665; top: 22 }
+#playfield #their-tray-0-1 { left: 703; top: 22 }
+#playfield #their-tray-0-2 { left: 741; top: 22 }
+#playfield #their-tray-0-3 { left: 779; top: 22 }
+#playfield #their-tray-0-4 { left: 817; top: 22 }
+#playfield #their-tray-0-5 { left: 855; top: 22 }
+#playfield #their-tray-0-6 { left: 893; top: 22 }
+
+#playfield #their-name-1 { left: 670; top: 66 }
+#playfield #their-score-1 { left: 887; top: 66; text-align: right }
+#playfield #their-tray-1-0 { left: 665; top: 88 }
+#playfield #their-tray-1-1 { left: 703; top: 88 }
+#playfield #their-tray-1-2 { left: 741; top: 88 }
+#playfield #their-tray-1-3 { left: 779; top: 88 }
+#playfield #their-tray-1-4 { left: 817; top: 88 }
+#playfield #their-tray-1-5 { left: 855; top: 88 }
+#playfield #their-tray-1-6 { left: 893; top: 88 }
+
+#playfield #their-name-2 { left: 670; top: 132 }
+#playfield #their-score-2 { left: 887; top: 132; text-align: right }
+#playfield #their-tray-2-0 { left: 665; top: 154 }
+#playfield #their-tray-2-1 { left: 703; top: 154 }
+#playfield #their-tray-2-2 { left: 741; top: 154 }
+#playfield #their-tray-2-3 { left: 779; top: 154 }
+#playfield #their-tray-2-4 { left: 817; top: 154 }
+#playfield #their-tray-2-5 { left: 855; top: 154 }
+#playfield #their-tray-2-6 { left: 893; top: 154 }
+
+#playfield #their-name-3 { left: 670; top: 198 }
+#playfield #their-score-3 { left: 887; top: 198; text-align: right }
+#playfield #their-tray-3-0 { left: 665; top: 220 }
+#playfield #their-tray-3-1 { left: 703; top: 220 }
+#playfield #their-tray-3-2 { left: 741; top: 220 }
+#playfield #their-tray-3-3 { left: 779; top: 220 }
+#playfield #their-tray-3-4 { left: 817; top: 220 }
+#playfield #their-tray-3-5 { left: 855; top: 220 }
+#playfield #their-tray-3-6 { left: 893; top: 220 }
+

Modified: branches/trunk-reorg/projects/scrabble/website/scrabble.html
===================================================================
--- branches/trunk-reorg/projects/scrabble/website/scrabble.html	2007-10-14 19:27:25 UTC (rev 2239)
+++ branches/trunk-reorg/projects/scrabble/website/scrabble.html	2007-10-14 20:28:22 UTC (rev 2240)
@@ -238,6 +238,42 @@
    <div id='my-tray-4'></div>
    <div id='my-tray-5'></div>
    <div id='my-tray-6'></div>
+   <div id='their-name-0'>Horst</div>
+   <div id='their-score-0'>192</div>
+   <div id='their-tray-0-0'><img src="images/NIL.png"/></div>
+   <div id='their-tray-0-1'><img src="images/NIL.png"/></div>
+   <div id='their-tray-0-2'><img src="images/NIL.png"/></div>
+   <div id='their-tray-0-3'><img src="images/NIL.png"/></div>
+   <div id='their-tray-0-4'><img src="images/NIL.png"/></div>
+   <div id='their-tray-0-5'><img src="images/NIL.png"/></div>
+   <div id='their-tray-0-6'><img src="images/NIL.png"/></div>
+   <div id='their-name-1'>Vladimir</div>
+   <div id='their-score-1'>188</div>
+   <div id='their-tray-1-0'><img src="images/NIL.png"/></div>
+   <div id='their-tray-1-1'><img src="images/NIL.png"/></div>
+   <div id='their-tray-1-2'><img src="images/NIL.png"/></div>
+   <div id='their-tray-1-3'><img src="images/NIL.png"/></div>
+   <div id='their-tray-1-4'><img src="images/NIL.png"/></div>
+   <div id='their-tray-1-5'><img src="images/NIL.png"/></div>
+   <div id='their-tray-1-6'><img src="images/NIL.png"/></div>
+   <div id='their-name-2'>Klarabella</div>
+   <div id='their-score-2'>190</div>
+   <div id='their-tray-2-0'><img src="images/NIL.png"/></div>
+   <div id='their-tray-2-1'><img src="images/NIL.png"/></div>
+   <div id='their-tray-2-2'><img src="images/NIL.png"/></div>
+   <div id='their-tray-2-3'><img src="images/NIL.png"/></div>
+   <div id='their-tray-2-4'><img src="images/NIL.png"/></div>
+   <div id='their-tray-2-5'><img src="images/NIL.png"/></div>
+   <div id='their-tray-2-6'><img src="images/NIL.png"/></div>
+   <div id='their-name-3'>Heidi</div>
+   <div id='their-score-3'>210</div>
+   <div id='their-tray-3-0'><img src="images/NIL.png"/></div>
+   <div id='their-tray-3-1'><img src="images/NIL.png"/></div>
+   <div id='their-tray-3-2'><img src="images/NIL.png"/></div>
+   <div id='their-tray-3-3'><img src="images/NIL.png"/></div>
+   <div id='their-tray-3-4'><img src="images/NIL.png"/></div>
+   <div id='their-tray-3-5'><img src="images/NIL.png"/></div>
+   <div id='their-tray-3-6'><img src="images/NIL.png"/></div>
   </div>
  </body>
 </html>
\ No newline at end of file

Modified: branches/trunk-reorg/projects/scrabble/website/scrabble.js
===================================================================
--- branches/trunk-reorg/projects/scrabble/website/scrabble.js	2007-10-14 19:27:25 UTC (rev 2239)
+++ branches/trunk-reorg/projects/scrabble/website/scrabble.js	2007-10-14 20:28:22 UTC (rev 2240)
@@ -8,6 +8,13 @@
     $('my-tray-' + n).innerHTML = letter ? '<img src="images/' + letter + '.png"/>' : '';
 }
 
+function setTheirTray(count, name, letterCount) {
+    $('their-name-' + count).innerHTML = name;
+    for (var i = 0; i < 7; i++) {
+        $('their-tray-' + count + '-' + i).style.visibility = (i < letterCount) ? 'visible' : 'hidden';
+    }
+}
+
 function drawGameState (gameState) {
     for (var i = 0; i < gameState.board.length; i++) {
 	var x = gameState.board[i][0];
@@ -26,13 +33,6 @@
     for (var i = 0; i < 7; i++) {
 	$('my-tray-' + i).onclick = trayClick;
     }
-    setMyTray(0, 'A');
-    setMyTray(1, 'B');
-    setMyTray(2, 'C');
-    setMyTray(3, 'D');
-    setMyTray(4, 'E');
-    setMyTray(5, 'F');
-    setMyTray(6, 'G');
     var d = loadJSONDoc("/game/108");
     d.addCallbacks(drawGameState, alert);
 }




More information about the Bknr-cvs mailing list