-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
121 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,53 @@ | ||
package com.github.alphaneet.suparobo | ||
|
||
case class GameMaker( | ||
inside: Option[Player] = None, | ||
outside: Option[Player] = None, | ||
board: Option[Board] = None | ||
) { | ||
def createGame() = Game( | ||
inside getOrElse (throw new NoSuchInsidePlayerException), | ||
outside getOrElse (throw new NoSuchOutsidePlayerException), | ||
board getOrElse (throw new NoSuchBoardException) | ||
) | ||
} | ||
|
||
object Game { | ||
sealed case class Status(id: Int) extends NotNull | ||
object SETUP extends Status(1) | ||
object PLAY extends Status(2) | ||
object END extends Status(3) | ||
} | ||
|
||
// TK: GameReady とかの Option 用のクラスを用意すべきかも | ||
// GameDeliver という名前を思いついた | ||
case class Game( | ||
self: Option[Player] = None, | ||
other: Option[Player] = None, | ||
board: Option[Board] = None | ||
) extends NotNull | ||
inside: Player, | ||
outside: Player, | ||
board: Board | ||
) extends NotNull { | ||
import Game._ | ||
private var _status: Status = SETUP | ||
private def status_=(status: Status) { _status = status } | ||
def status = _status | ||
|
||
def isSetup = status == SETUP | ||
def isPlay = status == PLAY | ||
def isEnd = status == END | ||
|
||
def gotoSetup() {} | ||
def gotoPlay() { | ||
if (isComplateSetup) { | ||
status = PLAY | ||
} else { | ||
throw new IllegalGotoGameStatusException(status + " -> " + PLAY) | ||
} | ||
} | ||
def gotoEnd() {} | ||
|
||
def isComplateSetup: Boolean = { | ||
if(!isSetup) return false | ||
|
||
|
||
true | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.github.alphaneet.suparobo | ||
|
||
class GameSuite extends FunSuite with ShouldMatchers { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters