<commit_before>package org.romeo.loveletter.cli.Main

import java.lang.System

import org.romeo.loveletter.game.{Game, GameManager}
import org.romeo.loveletter.persistence.MemoryDataStore

import scala.io.StdIn
import scala.util.Random

/**
  * Created by tylerromeo on 1/13/17.
  */
object Main extends App {
  val gameId = "cli"
  implicit val random = new Random()
  val gameManager = new GameManager(new MemoryDataStore())
  var gameInstance: Option[Game] = None
  stdin foreach { command =>
    processCommand(command)
    gameInstance foreach { g =>
      val currentPlayer = Game.currentPlayer.eval(g)
      println(s"It is ${currentPlayer.name}'s turn")
      println(s"Your hand:\n${currentPlayer.hand.mkString("\n")}")
    }
  }

  def stdin: Stream[String] = StdIn.readLine("Enter Command:") match {
    case s if s == null => Stream.empty
    case s => s #:: stdin
  }

  def processCommand(s: String): Unit = {
    val split = s.split("""\s+""")
    split.toList match {
      case command :: _ if command == "help" => printHelp()
      case command :: args if command == "start" => startGame(players = args)
      case command :: _ if command == "quit" => sys.exit(0)
      case command :: _ if command == "hand" => showHand()
      case command :: _ if command == "status" => showStatus()
      case command :: cardName :: args if command == "play" || command == "discard" => {
        val target = args.headOption
        val guess = if(args.size >= 2) Some(args(1)) else None
        playCard(card = cardName,
          target = target,
          guess = guess)
      }
      case _ => printHelp()
    }
  }

  def printHelp(): Unit = {
    val help =
      """
        |Rules are online at: http://www.alderac.com/tempest/files/2012/09/Love_Letter_Rules_Final.pdf
        |`help` to get this help
        |`start [player names]` to start a new game
        |`quit` to end the game
        |`hand` to see your hand
        |`status` to see all available information on the board
        |`play [card name] [?target] [?guess]` to play a card. (play can be omitted)
        |`discard` is equivalent to `play`
        |Source for bot at: https://github.com/tylerjromeo/love-letter-slack-commands
      """.stripMargin
    println(help)
  }

  def startGame(players: List[String]): Unit = {
    gameManager.startGame(gameId, players) match {
      case Left(m) => println(s"Could not start game: $m")
      case Right(game) => {
        gameInstance = Some(game)
        println(s"Game started")
      }
    }
  }

  def showHand(): Unit = ???

  def showStatus(): Unit = ???

  def playCard(card: String, target: Option[String], guess: Option[String]):Unit = ???

}<commit_msg>print game status every turn instead of having commands<commit_after>package org.romeo.loveletter.cli.Main

import java.lang.System

import org.romeo.loveletter.game.{Game, GameManager}
import org.romeo.loveletter.persistence.MemoryDataStore

import scala.io.StdIn
import scala.util.Random

/**
  * Created by tylerromeo on 1/13/17.
  */
object Main extends App {
  val gameId = "cli"
  implicit val random = new Random()
  val gameManager = new GameManager(new MemoryDataStore())
  var gameStarted: Boolean = false
  stdin foreach { command =>
    processCommand(command)
    if (gameStarted) {
      val gameInfo = gameManager.getGameInfo(gameId)
      val currentPlayer = gameManager.getCurrentPlayerName(gameId)
      val playersHand = gameManager.getHandInfo(gameId, currentPlayer)
      println(gameInfo)
      println(s"Your hand:\n$playersHand")
    }
  }

  def stdin: Stream[String] = StdIn.readLine("Enter Command:") match {
    case s if s == null => Stream.empty
    case s => s #:: stdin
  }

  def processCommand(s: String): Unit = {
    val split = s.split("""\s+""")
    split.toList match {
      case command :: cardName :: args if command == "play" || command == "discard" => {
        val target = args.headOption
        val guess = if(args.size >= 2) Some(args(1)) else None
        playCard(card = cardName,
          target = target,
          guess = guess)
      }
      case command :: args if command == "start" => startGame(players = args)
      case command :: _ if command == "quit" => sys.exit(0)
      case command :: _ if command == "help" => printHelp()
      case _ => printHelp()
    }
  }

  def printHelp(): Unit = {
    val help =
      """
        |Rules are online at: http://www.alderac.com/tempest/files/2012/09/Love_Letter_Rules_Final.pdf
        |`help` to get this help
        |`start [player names]` to start a new game
        |`quit` to end the game
        |`play [card name] [?target] [?guess]` to play a card. (play can be omitted)
        |`discard` is equivalent to `play`
        |Source for bot at: https://github.com/tylerjromeo/love-letter-slack-commands
      """.stripMargin
    println(help)
  }

  def startGame(players: List[String]): Unit = {
    gameManager.startGame(gameId, players) match {
      case Left(m) => println(s"Could not start game: $m")
      case Right(game) => {
        gameStarted = true
        println(s"Game started")
      }
    }
  }

  def playCard(card: String, target: Option[String], guess: Option[String]):Unit = ???

}
{'fraction_non_alphanumeric': 0.1325139235644325, 'fraction_numerical': 0.005377376608411754, 'mean_word_length': 2.8237885462555066, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 28, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6985789', 'n_tokens_mistral': 1671, 'n_tokens_neox': 1629, 'n_words': 457}