Browse Source

Add pass and uh-uh buttons

Thomas Dy 11 years ago
parent
commit
50b4c59ef3
3 changed files with 21 additions and 1 deletions
  1. 2 1
      app/models/Taboo.scala
  2. 17 0
      public/javascripts/tabooServices.js
  3. 2 0
      public/partials/chatRoom.html

+ 2 - 1
app/models/Taboo.scala

@@ -180,7 +180,8 @@ class TabooGame(val chatActor: ActorRef) extends Actor {
       roundActor = context.actorOf(Props[TabooRound])
       Akka.system.scheduler.scheduleOnce(1 minute, roundActor, End)
       chatActor ! Announce(Json.obj(
-        "kind" -> "roundStart"
+        "kind" -> "roundStart",
+        "round" -> round
       ))
       self ! NextCard
 

+ 17 - 0
public/javascripts/tabooServices.js

@@ -7,6 +7,12 @@ angular.module('tabooServices', [])
   game.status = function() {
     Chat.send('/status');
   };
+  game.taboo = function() {
+    Chat.send('/taboo');
+  };
+  game.pass = function() {
+    Chat.send('/pass');
+  };
   game.roundStart = function() {
     game.pendingRound = false;
     game.startTime = new Date();
@@ -15,6 +21,13 @@ angular.module('tabooServices', [])
   game.roundEnd = function() {
     game.pendingRound = false;
     game.card = null;
+    game.monitors = [];
+  };
+  game.isMonitor = function() {
+    return game.monitors.indexOf(Chat.username) >= 0;
+  };
+  game.isPlayer = function() {
+    return game.player == Chat.username;
   };
 
   $rootScope.$on('ws:connected', init);
@@ -26,6 +39,8 @@ angular.module('tabooServices', [])
     game.card = null;
     game.points = 0;
     game.pendingRound = false;
+    game.player = '';
+    game.monitors = [];
     game.status();
   }
 
@@ -63,6 +78,8 @@ angular.module('tabooServices', [])
     else if(message.kind == "roundStart") {
       gmMessage("Start game!");
       game.roundStart();
+      game.player = message.round.team.player;
+      game.monitors = message.round.monitors;
     }
     else if(message.kind == "roundEnd") {
       if(message.card) {

+ 2 - 0
public/partials/chatRoom.html

@@ -31,6 +31,8 @@
     <div class="span4" ng-controller="GameCtrl">
       <button class="btn" ng-show="game.pendingRound" ng-click="game.startRound()">Start</button>
       <div ng-show="game.card">
+        <button class="btn" ng-show="game.isPlayer()" ng-click="game.pass()">Pass</button>
+        <button class="btn" ng-show="game.isMonitor()" ng-click="game.taboo()">Uh-uh!</button>
         <h2>Card</h2>
         <h3>{{game.card.word}}</h3>
         <ul class="taboo">