Skip to content
This repository has been archived by the owner on Apr 8, 2020. It is now read-only.

Commit

Permalink
Merge pull request #16 from bb30/develop
Browse files Browse the repository at this point in the history
Get project to run on Travis again
  • Loading branch information
DonatJR authored Apr 8, 2020
2 parents 82e020b + fab444c commit e05640e
Show file tree
Hide file tree
Showing 46 changed files with 1,633 additions and 1,501 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,13 @@ project/.sbtserver

# Application
learn-duel.log

#Ensime
.ensime
.ensime_cache/
ensime-langserver.log
pc.stdout.log

#VS Code settings file
.vscode/settings.json

21 changes: 12 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
language: scala

scala:
- 2.12.4

script:
- sbt clean coverage test coverageReport
after_success:
- sbt coveralls
language: scala

scala:
- 2.12.6

jdk:
- openjdk11

script:
- sbt clean coverage test coverageReport
after_success:
- bash <(curl -s https://codecov.io/bash) -t 2289df37-0bc4-41a7-8803-45e20561b24f
33 changes: 33 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"version": "2.0.0",
"command": "sbt",
"type": "shell",
"presentation": {
"reveal": "always"
},
"tasks": [
{
"label": "build",
"type": "shell",
"command": "sbt compile",
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "test",
"type": "shell",
"command": "sbt test",
"group": {
"kind": "test",
"isDefault": true
}
},
{
"label": "run",
"type": "shell",
"command": "sbt run"
}
]
}
41 changes: 25 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
# Learn Duel [![Build Status](https://travis-ci.org/DonatJR/learn-duel.svg?branch=develop)](https://travis-ci.org/DonatJR/learn-duel) [![Coverage Status](https://coveralls.io/repos/github/DonatJR/learn-duel/badge.svg?branch=develop)](https://coveralls.io/github/DonatJR/learn-duel?branch=develop)

## About
Learn Duel is based on QuizDuel and works in a similar fashion, but with a new twist:
You play with questions based on your school or study assignments.

## Current features
For now, there is only local play, but online features will be added later.
If you are playing alone, the answers can be selected with the mouse or the keys 1-4.
In local multiplayer mode player 1 can specify his answer with the keys 1-4 and
player 2 with the keys 6-9.


## Future features:
- define your own questions
- play with up to 3 friends online and compete against each other
# Learn Duel

## Build status
Travis:
* develop [![Build Status](https://travis-ci.org/bb30/learn-duel.svg?branch=develop)](https://travis-ci.org/bb30/learn-duel)
* master [![Build Status](https://travis-ci.org/bb30/learn-duel.svg?branch=master)](https://travis-ci.org/bb30/learn-duel)

codecov:
* develop [![codecov](https://codecov.io/gh/bb30/learn-duel/branch/develop/graph/badge.svg)](https://codecov.io/gh/bb30/learn-duel)
* master [![codecov](https://codecov.io/gh/bb30/learn-duel/branch/master/graph/badge.svg)](https://codecov.io/gh/bb30/learn-duel)

## About
Learn Duel is based on QuizDuel and works in a similar fashion, but with a new twist:
You play with questions based on your school or study assignments.

## Current features
For now, there is only local play, but online features will be added later.
If you are playing alone, the answers can be selected with the mouse or the keys 1-4.
In local multiplayer mode player 1 can specify his answer with the keys 1-4 and
player 2 with the keys 6-9.


## Future features:
- define your own questions
- play with up to 3 friends online and compete against each other
59 changes: 39 additions & 20 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,20 +1,39 @@
name := "LearnDuel"
organization := "de.htwg.se"
version := "0.0.1"
scalaVersion := "2.12.4"

libraryDependencies += "org.scalactic" %% "scalactic" % "3.0.4"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.4" % "test"
libraryDependencies += "junit" % "junit" % "4.12" % "test"

libraryDependencies += "org.scalafx" %% "scalafx" % "8.0.144-R12"
libraryDependencies += "com.google.inject" % "guice" % "4.1.0"
libraryDependencies += "net.codingwell" %% "scala-guice" % "4.1.0"
libraryDependencies += "com.typesafe.play" %% "play-json" % "2.6.6"
libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.2.3"
libraryDependencies += "com.typesafe.scala-logging" %% "scala-logging" % "3.7.2"

import org.scoverage.coveralls.Imports.CoverallsKeys._
coverageExcludedPackages := ".*view.*;.*GuiceModule.*;.*LearnDuel.*"
coverageEnabled := true
coverageHighlighting := true
name := "LearnDuel"
organization := "de.htwg.se"
version := "0.0.1"
scalaVersion := "2.12.6"

libraryDependencies += "org.scalactic" %% "scalactic" % "3.0.4"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.4" % "test"
libraryDependencies += "junit" % "junit" % "4.12" % "test"

// Add dependency on ScalaFX library
libraryDependencies += "org.scalafx" %% "scalafx" % "12.0.2-R18"

// Determine OS version of JavaFX binaries
lazy val osName = System.getProperty("os.name") match {
case n if n.startsWith("Linux") => "linux"
case n if n.startsWith("Mac") => "mac"
case n if n.startsWith("Windows") => "win"
case _ => throw new Exception("Unknown platform!")
}

// Add dependency on JavaFX libraries, OS dependent
lazy val javaFXModules = Seq("base", "controls", "fxml", "graphics", "media", "swing", "web")
libraryDependencies ++= javaFXModules.map( m =>
"org.openjfx" % s"javafx-$m" % "12.0.2" classifier osName
)

libraryDependencies += "com.google.inject" % "guice" % "4.1.0"
libraryDependencies += "net.codingwell" %% "scala-guice" % "4.1.0"
libraryDependencies += "com.typesafe.play" %% "play-json" % "2.6.6"
libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.2.3"
libraryDependencies += "com.typesafe.scala-logging" %% "scala-logging" % "3.7.2"

unmanagedSourceDirectories in Compile := (unmanagedSourceDirectories in Compile).value.filter{ _.exists }
unmanagedSourceDirectories in Test := (unmanagedSourceDirectories in Test).value.filter{ _.exists }

import org.scoverage.coveralls.Imports.CoverallsKeys._
coverageExcludedPackages := ".*view.*;.*GuiceModule.*;.*LearnDuel.*"
coverageEnabled := true
coverageHighlighting := true
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.0.3
sbt.version=1.3.8
16 changes: 9 additions & 7 deletions src/main/scala/de/htwg/se/learn_duel/GuiceModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ import play.api.libs.json.{JsValue, Json}
import scala.io.Source

class GuiceModule extends AbstractModule {
val jsonString: String = Source.fromResource("questions.json").getLines.mkString("\n")
val json: JsValue = Json.parse(jsonString)
val questions: List[Question] = Json.fromJson[List[Question]](json).getOrElse(List())
val jsonString: String =
Source.fromResource("questions.json").getLines.mkString("\n")
val json: JsValue = Json.parse(jsonString)
val questions: List[Question] =
Json.fromJson[List[Question]](json).getOrElse(List())

override def configure(): Unit = {
bind(classOf[Game]).toInstance(GameImpl(questions = questions))
bind(classOf[Controller]).to(classOf[ControllerImpl])
}
override def configure(): Unit = {
bind(classOf[Game]).toInstance(GameImpl(questions = questions))
bind(classOf[Controller]).to(classOf[ControllerImpl])
}
}
21 changes: 8 additions & 13 deletions src/main/scala/de/htwg/se/learn_duel/LearnDuel.scala
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
package de.htwg.se.learn_duel

import de.htwg.se.learn_duel.controller.Controller
import de.htwg.se.learn_duel.model.impl.Game
import java.io.BufferedReader

import com.google.inject.Guice
import de.htwg.se.learn_duel.model.Question
import de.htwg.se.learn_duel.view.{GUI, TUI}
import play.api.libs.json.Json

import scala.io.Source

object LearnDuel {
def main(args: Array[String]): Unit = {
val injector = Guice.createInjector(new GuiceModule())
val controller = injector.getInstance(classOf[Controller])
def main(args: Array[String]): Unit = {
val injector = Guice.createInjector(new GuiceModule())
val controller = injector.getInstance(classOf[Controller])

val tui = TUI.create(controller)
GUI.create(controller)
val tui = TUI.create(controller)
GUI.create(controller)

controller.requestUpdate
tui.processInput(new BufferedReader(Console.in))
}
controller.requestUpdate()
tui.processInput(new BufferedReader(Console.in))
}
}
10 changes: 6 additions & 4 deletions src/main/scala/de/htwg/se/learn_duel/Observable.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package de.htwg.se.learn_duel

trait Observable {
private var observers: List[Observer] = List()
def addObserver(observer: Observer): Unit = observers = observer :: observers
def removeObserver(observer: Observer): Unit = observers = observers.filter(_ != observer)
protected def notifyObservers(updateParam: UpdateData): Unit = observers.foreach(o => o.update(updateParam))
private var observers: List[Observer] = List()
def addObserver(observer: Observer): Unit = observers = observer :: observers
def removeObserver(observer: Observer): Unit =
observers = observers.filter(_ != observer)
protected def notifyObservers(updateParam: UpdateData): Unit =
observers.foreach(o => o.update(updateParam))
}
12 changes: 6 additions & 6 deletions src/main/scala/de/htwg/se/learn_duel/Observer.scala
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package de.htwg.se.learn_duel

object UpdateAction extends Enumeration {
type UpdateAction = Value
val BEGIN, CLOSE_APPLICATION, PLAYER_UPDATE, SHOW_HELP,
SHOW_GAME, SHOW_RESULT, TIMER_UPDATE = Value
type UpdateAction = Value
val BEGIN, CLOSE_APPLICATION, PLAYER_UPDATE, SHOW_HELP, SHOW_GAME,
SHOW_RESULT, TIMER_UPDATE = Value
}
import UpdateAction._
import de.htwg.se.learn_duel.model.Game

class UpdateData(updateAction: UpdateAction, gameState: Game) {
def getAction(): UpdateAction = updateAction
def getState(): Game = gameState
def getAction: UpdateAction = updateAction
def getState: Game = gameState
}

trait Observer {
def update(updateData: UpdateData): Unit
def update(updateData: UpdateData): Unit
}
32 changes: 16 additions & 16 deletions src/main/scala/de/htwg/se/learn_duel/controller/Controller.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ import de.htwg.se.learn_duel.controller.impl.{Controller => ControllerImpl}
import de.htwg.se.learn_duel.model.{Game, Resettable}

trait Controller extends Observable with Resettable {
def nextPlayerName(): Option[String]
def getPlayerNames: List[String]
def maxPlayerCount(): Int
def requestUpdate(): Unit
def reset(): Unit
def onAddPlayer(name: Option[String]): Unit
def onRemovePlayer(name: String): Unit
def onPlayerActionUndo(): Unit
def onPlayerActionRedo(): Unit
def onHelp(): Unit
def onStartGame(): Unit
def onClose(): Unit
def onAnswerChosen(input: Int)
def nextPlayerName: Option[String]
def getPlayerNames: List[String]
def maxPlayerCount: Int
def requestUpdate(): Unit
def reset(): Unit
def onAddPlayer(name: Option[String]): Unit
def onRemovePlayer(name: String): Unit
def onPlayerActionUndo(): Unit
def onPlayerActionRedo(): Unit
def onHelp(): Unit
def onStartGame(): Unit
def onClose(): Unit
def onAnswerChosen(input: Int)
}

object Controller {
def create(gameState: Game): ControllerImpl = {
new ControllerImpl(gameState)
}
def create(gameState: Game): ControllerImpl = {
new ControllerImpl(gameState)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package de.htwg.se.learn_duel.controller

trait ControllerException {
self: Throwable =>
val message: String
self: Throwable =>
val message: String
}
Loading

0 comments on commit e05640e

Please sign in to comment.