Permalink
Browse files

whatever you did

  • Loading branch information...
1 parent 6a9fb53 commit 1d31ef73bd03f4154646ae73ad4d65fc6eac6789 @teleject teleject committed Aug 29, 2010
Showing with 38 additions and 22 deletions.
  1. +8 −1 lib/gamemanager.js
  2. +0 −7 public/css/style.css
  3. +1 −3 public/gameboard.html
  4. BIN public/images/blank.png
  5. +14 −5 public/js/socket.js
  6. +15 −6 public/results.html
View
@@ -82,6 +82,11 @@ GameManager.prototype.addUser = function(client, username) {
}
var existingGame = this.getCurrentGame();
+ // Is the game in progress?
+ if (existingGame.inProgress) {
+ return {success: false, reason: "Game in progress"};
+ }
+
// Is the game full?
if (existingGame.isFull()) {
return {success: false, reason: "Game is full"};
@@ -284,6 +289,7 @@ GameManager.prototype.placeShips = function(client, locations) {
var startGameMsg = {type: "gamestart", msg: "FRUIT!!!"};
game.playas.forEach(function(element) {
console.log("Alerting " + element.username + " game is starting");
+ game.inProgress = true;
var aConnection = manager.connections[element.username];
aConnection.client.send(JSON.stringify(startGameMsg));
});
@@ -312,7 +318,8 @@ function Game() {
this.name = this.battleNames[Math.floor(Math.random()*this.battleNames.length)];
this.playas = [];
this.currentPlaya = 0;
- this.maxPlayers = 5;
+ this.maxPlayers = 3;
+ this.inProgress = false;
// listeners
this.on("winner", function () {
View
@@ -449,13 +449,6 @@ section.myboard {
float: right;
}
-.xmyboard {
- position: absoulte;
- top: 0;
- right: 0;
- width: 550px;
-
-}
.gameboard_frame .gameboard_frame {
}
View
@@ -26,7 +26,7 @@
<header>
<h1><a href="#"><abbr title="Her Majesty's Ship">HMS</abbr> Dreadnode</a></h1>
<h2>The Classic Titanic Rock &#8217;Em Sock &#8217;Em Ship Battle Game</h2>
- </header>
+</header>
<div id="gameboard_content">
<article>
@@ -71,7 +71,6 @@
<strong id="gametime">:29</strong>
</section>
- <div id="gameboard_frame">
<section class="mod targetboard">
<h3>May Your Aim Be True</h3>
<div class="gameboard" id="target_board"></div>
@@ -81,7 +80,6 @@
<h3>Pray For Your Fleet</h3>
<div class="gameboard" id="my_board"></div>
</section>
- </div>
<section class="pieces_bin_frame mod">
<h3>Game Pieces</h3>
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -24,6 +24,11 @@
// Watership Down
var dispatch = {
+ _alertMessage : function(message) {
+ var msg = message.msg;
+ console.log(msg);
+ alert(msg)
+ },
auth : function(message) {
var status = message.status || "failed";
var msg = message.msg || "?";
@@ -35,10 +40,12 @@
}
},
destroyed : function(message) {
- var msg = message.msg;
- console.log(msg);
+ var msg = message.msg;
+ console.log(msg);
+ global.APPVIEW.win_state = false;
global.APPVIEW.next_page();
- },
+ },
+ gamestart : this._alertMessage,
// not implemented
gravatar : function(message) {
var msg = message.msg || "";
@@ -69,6 +76,7 @@
console.log("OUCH "+ouchLocation);
global.My_Gameboard.set_peg(ouchLocation);
},
+ quitter : this._alertMessage,
setup : function(message) {
var playersState = message.msg;
console.log(playersState);
@@ -78,13 +86,14 @@
win : function(message) {
var msg = message.msg;
console.log(msg);
+ global.APPVIEW.win_state = true;
global.APPVIEW.next_page();
},
yourturn : function(message) {
var msg = message.msg || "";
console.log(msg);
- $("#yourturn").slideDown();
- global.Target_Gameboard.set_your_turn(true);
+ $("#yourturn").show();
+ global.Target_Gameboard.set_your_turn(true);
}
};
View
@@ -23,7 +23,7 @@
<article>
<section class="mod">
- <h3>YOU DIED OF DYSENTERY OR YOU WON!</h3>
+ <h3 id="results_status_msg">Game Over</h3>
<section class="handle mod">
@@ -67,17 +67,14 @@
</section>
- <section class="mod results_image">
- <!-- results-lose.jpg -->
- <img src="images/results-win.jpg" alt="Congrats you won over XYZ, ABC, MNO, and BOB!">
- </section>
+ <section class="mod results_image"><img src="images/blank.png" /></section>
</section>
<section class="mod alwaysbeclosing">
- <button class="large orangellow" title="Did you lose honor to the mermaids again? Then there's only one thing to do!">Play Again!</button>
+ <button onclick="document.location.href='/';" class="large orangellow" title="Did you lose honor to the mermaids again? Then there's only one thing to do!">Play Again!</button>
</section>
@@ -87,5 +84,17 @@
</div>
<div id="yourturn"></div>
+
+ <script type="text/javascript" class="init">
+ if (APPVIEW.win_state === true) {
+ $(".results_image img").attr("src","images/results-win.jpg");
+ $("#results_status_msg").text("YOU WON!");
+ }
+ else if (APPVIEW.win_state === false) {
+ $(".results_image img").attr("src","images/results-lose.jpg");
+ $("#results_status_msg").text("YOU DIED OF DYSENTERY");
+ }
+ APPVIEW.win_state = null;
+ </script>
</body>
</html>

0 comments on commit 1d31ef7

Please sign in to comment.