Kaynağa Gözat

Allow players to say someone got it right

Thomas Dy 11 yıl önce
ebeveyn
işleme
4d680ddd28

+ 9 - 0
app/models/Taboo.scala

@@ -73,6 +73,7 @@ case class Round(
 case class Information(text: String)
 case class Guess(username: String, text: String)
 case object Pass
+case class Correct(username: String)
 case class Taboo(username: String)
 case object End
 
@@ -125,6 +126,7 @@ class TabooGame(val chatActor: ActorRef) extends Actor {
       case Some(round) =>
         if(username == round.team.player) text match {
           case "/pass" | "/p" => roundActor ! Pass
+          case "/correct" | "/c" => roundActor ! Correct(username)
           case text => roundActor ! Information(text)
         }
         else if(round.team.guessers(username)) {
@@ -132,6 +134,7 @@ class TabooGame(val chatActor: ActorRef) extends Actor {
         }
         else if(round.monitors(username)) text match {
           case "/taboo" | "/t" => roundActor ! Taboo(username)
+          case "/correct" | "/c" => roundActor ! Correct(username)
         }
 
       case None =>
@@ -252,6 +255,12 @@ class TabooRound extends Actor {
       this.card = None
     }
 
+    case Correct(username) => card.map { card =>
+      points += 1
+      sender ! Score("correctp", points, card, username)
+      this.card = None
+    }
+
     case Taboo(username) => card.map { card =>
       points -= 1
       sender ! Score("taboo", points, card)

+ 6 - 0
public/javascripts/tabooServices.js

@@ -31,6 +31,9 @@ angular.module('tabooServices', [])
   game.taboo = function() {
     Chat.send('/taboo');
   };
+  game.correct = function() {
+    Chat.send('/correct');
+  };
   game.pass = function() {
     Chat.send('/pass');
   };
@@ -81,6 +84,9 @@ angular.module('tabooServices', [])
       if(message.action == "correct") {
         text = message.user + " got it!";
       }
+      else if(message.action == "correctp") {
+        text = "Let's take "+message.user+"'s word that someone got it.";
+      }
       else if(message.action == "invalid") {
         text = "Uh-uh! You said a taboo word.";
       }

+ 1 - 0
public/partials/chatRoom.html

@@ -36,6 +36,7 @@
       <div ng-if="game.roundRunning()">
         <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>
+        <button class="btn" ng-show="game.isMonitor() || game.isPlayer()" ng-click="game.correct()">Correct</button>
       </div>
       <div ng-show="game.card">
         <h2>Card</h2>