Skip to content
Browse files

Implemented score display for user and toggling of gameplay direction…

… indicator on play of a reverse card
  • Loading branch information...
1 parent 788a4e1 commit aaf8d0cc94155593c0e2ce74731e3d627e029443 @mscdex committed Apr 5, 2011
Showing with 35 additions and 7 deletions.
  1. +9 −0 html/main_begin.htm
  2. +23 −4 lib/frontends/web/public/game.js
  3. +3 −3 lib/frontends/web/public/index.htm
View
9 html/main_begin.htm
@@ -14,6 +14,15 @@
}
th { font-weight: bold; }
a, a:visited, a:active, a:hover { color: white; text-decoration: underline; }
+ a:hover {
+ color: #3399FF;
+ background: white;
+ }
+ a:active {
+ background: #36C;
+ color: #FFF;
+ border: 1px inset #36C;
+ }
</style>
</head>
<body>
View
27 lib/frontends/web/public/game.js
@@ -1,5 +1,5 @@
var conn, callback, players = {}, me, imgBack = 'images/back.png',
- inGame = false, isNewRound = false, isWild = false, elWild;
+ inGame = false, isNewRound = false, isWild = false, elWild, dir = 1;
/* Game functions */
function addPlayer(p) {
@@ -65,11 +65,21 @@ function imageToCard(src) {
return [parseInt(src.substring(0, idxSep)),
parseInt(src.substring(idxSep+1, idxEnd))];
}
+function toggleDir() {
+ dir *= -1;
+ if (dir > 0)
+ $('#dir').html('&rarr;');
+ else
+ $('#dir').html('&larr;');
+}
function reset() {
isWild = inGame = false;
+ dir = -1;
$('.playingarea').hide();
$('#players, #hand').empty();
$('#piles, #pass, #showWC').hide();
+ $('#myscore').html('Score: 0');
+ toggleDir();
players = {};
me = callback = undefined;
}
@@ -89,8 +99,12 @@ function handleEvent(res) {
} else if (res.event === 'start') {
var msg;
if (res.roundWinner) {
- msg = (res.roundWinner.id === me.id ? 'You' : res.roundWinner.name) +
- ' won this round. Next round started.';
+ if (res.roundWinner.id === me.id) {
+ msg = 'You';
+ $('#myscore').html('Score: ' + res.roundWinner.points);
+ } else
+ msg = res.roundWinner.name;
+ msg += ' won this round. Next round started.';
isNewRound = true;
isWild = false;
callback = undefined;
@@ -124,11 +138,14 @@ function handleEvent(res) {
var msg = res.player.name + ' played a ' + cardToText(res.card);
if (typeof res.wildColor !== 'undefined') {
isWild = true;
- $('#wildColor').attr('class', 'center wildColor' + res.wildColor).show();
+ $('#wildColor').attr('class', 'center wildColor' + res.wildColor);
+ $('#showWC').show();
} else if (isWild) {
isWild = false;
$('#showWC').hide();
}
+ if (res.card[0] < 4 && res.card[1] === 11)
+ toggleDir();
addCardCount(res.player.id, -1);
animPlay('#player-' + res.player.id + ' div.cardcount', res.card);
status(msg);
@@ -359,6 +376,8 @@ function initUIHandlers() {
isNewRound = false;
animPlay(self);
$('#pass').hide();
+ if (card[0] < 4 && card[1] === 11)
+ toggleDir();
});
}
});
View
6 lib/frontends/web/public/index.htm
@@ -1,6 +1,6 @@
<html>
<head>
- <title>youknow</title>
+ <title>Youknow</title>
<script type="text/javascript" src="flashws.js"></script>
<script type="text/javascript" src="transport.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
@@ -16,7 +16,7 @@
.button {
padding: 5px 10px;
- display: inline;
+ display: block;
background: #777 url(images/button.png) repeat-x bottom;
text-decoration: none;
border: none;
@@ -97,7 +97,7 @@
<div style="padding: 5px;">
<div id="me" class="txtCenter"><img src="images/player.png" />You</div>
</div>
- <div id="myscore" class="txtCenter">Score: 500</div>
+ <div id="myscore" class="txtCenter">Score: 0</div>
<div id="dir" class="txtCenter" style="font-size: 30pt; cursor: default;" title="Gameplay direction">&rarr;</div>
<div id="showWC">
<div class="txtCenter">Wild Color</div>

0 comments on commit aaf8d0c

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