-
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.
Merge branch 'develop' into feature-cleanup
- Loading branch information
Showing
47 changed files
with
834 additions
and
282 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
10 changes: 6 additions & 4 deletions
10
src/main/scala/scatan/controllers/game/SetUpController.scala
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,21 +1,23 @@ | ||
package scatan.controllers.game | ||
|
||
import scatan.lib.mvc.{Controller, EmptyController} | ||
import scatan.model.ApplicationState | ||
import scatan.model.{ApplicationState, GameMap} | ||
import scatan.views.game.SetUpView | ||
|
||
/** The controller for the game setup screen. | ||
*/ | ||
trait SetUpController extends Controller[ApplicationState]: | ||
|
||
/** Starts the game with the given usernames. | ||
* @param gameMap, | ||
* the game map to use. | ||
* @param usernames, | ||
* the usernames of the players. | ||
*/ | ||
def startGame(usernames: String*): Unit | ||
def startGame(gameMap: GameMap, usernames: String*): Unit | ||
|
||
object SetUpController: | ||
def apply(requirements: Controller.Requirements[SetUpView, ApplicationState]): SetUpController = | ||
new EmptyController(requirements) with SetUpController: | ||
override def startGame(usernames: String*): Unit = | ||
this.model.update(_.createGame(usernames*)) | ||
override def startGame(gameMap: GameMap, usernames: String*): Unit = | ||
this.model.update(_.createGame(gameMap, usernames*)) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package scatan.lib.game.ops | ||
|
||
import scatan.lib.game.{GameStatus, Rules} | ||
import scatan.model.GameMap | ||
|
||
/** Operations on [[Rules]] related to their construction. | ||
*/ | ||
object RulesOps: | ||
extension [State, P, S, A, Player](rules: Rules[State, P, S, A, Player]) | ||
|
||
/** Set the allowed number of players for this game. | ||
* @param sizes | ||
* The allowed number of players. | ||
* @return | ||
* A new set of rules with the allowed number of players set. | ||
*/ | ||
def withAllowedPlayersSizes(sizes: Set[Int]): Rules[State, P, S, A, Player] = | ||
rules.copy(allowedPlayersSizes = sizes) | ||
|
||
def withStartingStateFactory(stateFactory: (GameMap, Seq[Player]) => State): Rules[State, P, S, A, Player] = | ||
rules.copy(startingStateFactory = stateFactory) | ||
|
||
/** Set the starting phase for this game. | ||
* @param phase | ||
* The starting phase. | ||
* @return | ||
* A new set of rules with the starting phase set. | ||
*/ | ||
def withStartingPhase(phase: P): Rules[State, P, S, A, Player] = | ||
rules.copy(startingPhase = phase) | ||
|
||
/** Set the initial step for a phase. | ||
* @param phase | ||
* The phase | ||
* @param step | ||
* The initial step | ||
* @return | ||
* A new set of rules with the initial step set. | ||
*/ | ||
def withStartingStep(phase: P, step: S): Rules[State, P, S, A, Player] = | ||
rules.copy(startingSteps = rules.startingSteps + (phase -> step)) | ||
|
||
/** Set the ending step for a phase. | ||
* @param phase | ||
* The phase | ||
* @param step | ||
* The ending step | ||
* @return | ||
* A new set of rules with the ending step set. | ||
*/ | ||
def withEndingStep(phase: P, step: S): Rules[State, P, S, A, Player] = | ||
rules.copy(endingSteps = rules.endingSteps + (phase -> step)) | ||
|
||
/** Set the turn iterator factory for a phase. | ||
* @param phase | ||
* The phase | ||
* @param factory | ||
* The factory | ||
* @return | ||
* A new set of rules with the turn iterator factory set. | ||
*/ | ||
def withPhaseTurnIteratorFactory( | ||
phase: P, | ||
factory: Seq[Player] => Iterator[Player] | ||
): Rules[State, P, S, A, Player] = | ||
rules.copy(phaseTurnIteratorFactories = rules.phaseTurnIteratorFactories + (phase -> factory)) | ||
|
||
/** Set the next phase for a phase. | ||
* @param phase | ||
* The phase | ||
* @param next | ||
* The next phase | ||
* @return | ||
* A new set of rules with the next phase set. | ||
*/ | ||
def withNextPhase(phase: P, next: P): Rules[State, P, S, A, Player] = | ||
rules.copy(nextPhase = rules.nextPhase + (phase -> next)) | ||
|
||
/** Set the actions for a phase. | ||
* @param actions | ||
* The actions | ||
* @return | ||
* A new set of rules with the actions set. | ||
*/ | ||
def withActions(actions: (GameStatus[P, S], Map[A, S])): Rules[State, P, S, A, Player] = | ||
rules.copy(actions = rules.actions + actions) | ||
|
||
/** Set the winner for a state. | ||
* @param winner | ||
* The winner function | ||
* @return | ||
* A new set of rules with the winner function. | ||
*/ | ||
def withWinnerFunction(winner: State => Option[Player]): Rules[State, P, S, A, Player] = | ||
rules.copy(winnerFunction = winner) | ||
|
||
def withOnEnter(phase: P, onEnter: State => State): Rules[State, P, S, A, Player] = | ||
rules.copy(initialAction = rules.initialAction + (phase -> onEnter)) |
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
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
Oops, something went wrong.