File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change 11# connect4 scala
22Connect4 in Scala! For interviewing people who know some scala.
3-
3+
4+ ## Playing
5+ ``` bash
6+ > sbt run
7+ ```
8+
9+ ## Run the tests
10+ ``` bash
11+ > sbt test
12+ ```
413
514## User Requirements
615
Original file line number Diff line number Diff line change 11package connect4
22
3- import cats .effect .{ExitCode , IO , IOApp }
3+ import cats .effect .{IO , IOApp }
44import cats .syntax .all ._
55
66import scala .io .StdIn
@@ -20,7 +20,7 @@ object GameRunner extends IOApp.Simple {
2020 def swapPlayer (p : Player ): Player = if (p == p1) p2 else p1
2121
2222 def eval (command : String , board : Board , p : Player ): IO [Unit ] =
23- if (command == null ) IO .pure( ExitCode . Success ) else dropCoin(board, p, command) match {
23+ if (command == null ) IO .unit else dropCoin(board, p, command) match {
2424 case Left (err) => IO (println(s " Err: $err" )) *> loop(board, p)
2525 case Right (b) if b.gameState == Playing => IO (println(b.draw())) *> loop(b, swapPlayer(p))
2626 case Right (b) => IO (println(s " Game finished as ${b.gameState} : \n ${b.draw()}" )) *> IO .unit
You can’t perform that action at this time.
0 commit comments