@@ -4,13 +4,12 @@ import cats.syntax.option._
44import cats .syntax .either ._
55import com .us .dsb .explore .algs .coloredlines .manual .game .board .CellAddress
66import com .us .dsb .explore .algs .coloredlines .manual .game .GameLogicSupport .MoveResult
7- import com .us .dsb .explore .algs .coloredlines .manual .game .GameState .GameResult .Done
87import com .us .dsb .explore .algs .coloredlines .manual .game .board .{BallKind , BoardPlus }
98import com .us .dsb .explore .algs .coloredlines .manual .game .board .{ColumnIndex , RowIndex }
109
1110import scala .util .Random
1211
13- private [manual] object GameState {
12+ private [manual] object UpperGameState {
1413
1514 /**
1615 * Result of completed game.
@@ -20,35 +19,35 @@ private[manual] object GameState {
2019 private [manual] case class Done (score : Int ) extends GameResult
2120 }
2221
23- private [this ] def makeInitialState (implicit rng : Random ): GameState = {
22+ private [this ] def makeInitialState (implicit rng : Random ): UpperGameState = {
2423 val initialPlacementResult = GameLogicSupport .placeInitialBalls(BoardPlus .empty)
2524 // ????? probably split GameState level from slightly lower game state
2625 // carrying board plus score (probably modifying MoveResult for that)
27- GameState (initialPlacementResult.boardPlus, None )
26+ UpperGameState (initialPlacementResult.boardPlus, None )
2827 }
2928
30- private [manual/* game*/ ] def initial (seed : Long ): GameState = makeInitialState(new Random (seed))
31- private [manual] def initial (): GameState = makeInitialState(new Random ())
29+ private [manual/* game*/ ] def initial (seed : Long ): UpperGameState = makeInitialState(new Random (seed))
30+ private [manual] def initial (): UpperGameState = makeInitialState(new Random ())
3231}
33- import GameState ._
32+ import UpperGameState ._
3433
3534// ???? add random-data state
3635
3736/** Game state AND currently controller.
3837 * @constructor
3938 * @param gameResult `None` means no win or draw yet
4039 */
41- private [manual] case class GameState (boardPlus : BoardPlus ,
42- gameResult : Option [GameResult ]
43- )(implicit rng : Random ) {
40+ private [manual] case class UpperGameState (boardPlus : BoardPlus ,
41+ gameResult : Option [GameResult ]
42+ )(implicit rng : Random ) {
4443
4544 // ????? Probably move to GameLogicSupport
4645
4746 // ?? later refine from Either[String, ...] to "fancier" error type
4847 // Xx?? maybe add result of move (win/draw/other) with new state (so caller
4948 // doesn't have to check state's gameResult; also, think about where I'd add
5049 // game history
51- private [manual] def tryMoveAt (tapAddress : CellAddress ): Either [String , GameState ] = {
50+ private [manual] def tryMoveAt (tapAddress : CellAddress ): Either [String , UpperGameState ] = {
5251 import GameLogicSupport .Action ._
5352 val tapAction = GameLogicSupport .interpretTapLocationToTapAction(boardPlus, tapAddress)
5453 println(" tryMoveAt: tapAction = " + tapAction)
@@ -76,10 +75,10 @@ private[manual] case class GameState(boardPlus: BoardPlus,
7675
7776 val nextState =
7877 if (! moveResult.boardPlus.isFull) {
79- GameState (moveResult.boardPlus, gameResult).asRight
78+ UpperGameState (moveResult.boardPlus, gameResult).asRight
8079 }
8180 else {
82- GameState (moveResult.boardPlus, Some (Done (moveResult.boardPlus.getScore))).asRight
81+ UpperGameState (moveResult.boardPlus, Some (GameResult . Done (moveResult.boardPlus.getScore))).asRight
8382 }
8483 nextState
8584 }
0 commit comments