Skip to content

Instantly share code, notes, and snippets.

@ppurang
Created April 14, 2012 07:58
Show Gist options
  • Save ppurang/2382768 to your computer and use it in GitHub Desktop.
Save ppurang/2382768 to your computer and use it in GitHub Desktop.
build.sbt for trivia
name := "coderetreat-trivia"
version := "0.0.1"
organization := "org.purang.net"
scalaVersion := "2.9.1"
libraryDependencies ++= Seq(
"org.scalaz" % "scalaz-core_2.9.1" % "6.0.3" withSources(),
"org.scalatest" % "scalatest_2.9.1" % "1.6.1" % "test"
)
scalacOptions ++= Seq("-encoding", "UTF-8", "-deprecation", "-unchecked")
cancelable := true
resolvers ++= Seq("Local Maven Repository" at "file://" + Path.userHome + "/.m2/repository", "Local Ivy Repository" at "file://" + Path.userHome + "/.ivy2/local")
//, "Local Ivy Cache" at "file://" + Path.userHome + "/.ivy2/cache"
@ppurang
Copy link
Author

ppurang commented Apr 14, 2012

put this in the ~/.sbt/plugins/build.sbt

resolvers += "sbt-idea-repo" at "http://mpeltonen.github.com/maven/"

addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "0.11.1-SNAPSHOT")

@ppurang
Copy link
Author

ppurang commented Apr 14, 2012

import collection.mutable.ArrayBuffer
import com.adaptionsoft.games.uglytrivia.Game
import java.util.Random
import org.scalatest.matchers.ShouldMatchers
import org.scalatest.{BeforeAndAfterEach, FunSuite, BeforeAndAfterAll}

class GameSpec extends FunSuite with ShouldMatchers with BeforeAndAfterAll with BeforeAndAfterEach {

test("first test") {
val aGame = new Game();
aGame.add("Chet")

val series = List(1,1,1,1,1,1)

val listOfOutcomes = new ArrayBuffer[(Int, Int,  Boolean, String)]

for (
  i <- series zipWithIndex
) {
  aGame.roll(i._1)
  aGame.wasCorrectlyAnswered
  listOfOutcomes += Tuple4(i._2, i._1, aGame.didPlayerWin, aGame.whichPlayerWon)
}
println(listOfOutcomes.mkString("\n"))
aGame.whichPlayerWon should be("Chet")

}

}

@ppurang
Copy link
Author

ppurang commented Apr 14, 2012

def whichPlayerWon = if(didPlayerWin) {
currentPlayer match {
case 0 => players.get(players.size() - 1)
case _ => players.get(currentPlayer - 1)
}
} else {
"no winner yet"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment