Browse Source

Split out card model

Thomas Dy 11 years ago
parent
commit
bb41f5753b
2 changed files with 30 additions and 27 deletions
  1. 30 0
      app/models/Card.scala
  2. 0 27
      app/models/Taboo.scala

+ 30 - 0
app/models/Card.scala

@@ -0,0 +1,30 @@
+package models
+
+import play.api.libs.json._
+
+object Card {
+  implicit val writes = new Writes[Card] {
+    def writes(o: Card) = Json.obj(
+      "word" -> o.word,
+      "taboo" -> o.taboo
+    )
+  }
+}
+
+case class Card(word: String, taboo: Set[String]) {
+
+  def isTaboo(text: String) = {
+    val lower = text.toLowerCase
+    def contains(word: String) = {
+      lower.indexOf(word.toLowerCase) >= 0
+    }
+
+    // check if text contains word or anything in taboo
+    (taboo + word).map(contains).foldLeft(false)(_ || _)
+  }
+
+  def isCorrect(text: String) = {
+    text.toLowerCase.indexOf(word.toLowerCase) >= 0
+  }
+
+}

+ 0 - 27
app/models/Taboo.scala

@@ -7,33 +7,6 @@ import play.api.libs.json._
 import play.api.Play.current
 import play.api.libs.concurrent.Execution.Implicits._
 
-object Card {
-  implicit val writes = new Writes[Card] {
-    def writes(o: Card) = Json.obj(
-      "word" -> o.word,
-      "taboo" -> o.taboo
-    )
-  }
-}
-
-case class Card(word: String, taboo: Set[String]) {
-
-  def isTaboo(text: String) = {
-    val lower = text.toLowerCase
-    def contains(word: String) = {
-      lower.indexOf(word.toLowerCase) >= 0
-    }
-
-    // check if text contains word or anything in taboo
-    (taboo + word).map(contains).foldLeft(false)(_ || _)
-  }
-
-  def isCorrect(text: String) = {
-    text.toLowerCase.indexOf(word.toLowerCase) >= 0
-  }
-
-}
-
 object Team {
   implicit val writes = new Writes[Team] {
     def writes(o: Team) = Json.obj(