-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create game configuration + update related view
- Loading branch information
1 parent
dcfa0b8
commit 8b8e67c
Showing
7 changed files
with
228 additions
and
32 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
33 changes: 33 additions & 0 deletions
33
chess/src/main/scala/io/github/chess/model/configuration/GameConfiguration.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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* MIT License | ||
* Copyright (c) 2023 Cesario Jahrim Gabriele & Derevyanchenko Maxim & Felice Mirko & Kentpayeva Madina | ||
* | ||
* Full license description available at: https://github.com/jahrim/PPS-22-chess/blob/master/LICENSE | ||
*/ | ||
package io.github.chess.model.configuration | ||
|
||
import io.github.chess.model.* | ||
|
||
/** | ||
* Represents the configuration of the game containing all needed settings. | ||
* @param timeConstraint [[TimeConstraint]] representing the time limit mode | ||
* @param gameMode [[GameMode]] chosen by the user | ||
* @param whitePlayer [[Player]] representing the white pieces | ||
* @param blackPlayer [[Player]] representing the black pieces | ||
*/ | ||
case class GameConfiguration( | ||
var timeConstraint: TimeConstraint, | ||
var gameMode: GameMode, | ||
var whitePlayer: Player, | ||
var blackPlayer: Player | ||
) | ||
|
||
object GameConfiguration: | ||
|
||
/** Creates a default game configuration, with no time constraint, pvp game mode and no name players. */ | ||
def default: GameConfiguration = GameConfiguration( | ||
TimeConstraint.NoLimit, | ||
GameMode.PVP, | ||
Player.noNameWhitePlayer, | ||
Player.noNameBlackPlayer | ||
) |
16 changes: 16 additions & 0 deletions
16
chess/src/main/scala/io/github/chess/model/configuration/GameMode.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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* MIT License | ||
* Copyright (c) 2023 Cesario Jahrim Gabriele & Derevyanchenko Maxim & Felice Mirko & Kentpayeva Madina | ||
* | ||
* Full license description available at: https://github.com/jahrim/PPS-22-chess/blob/master/LICENSE | ||
*/ | ||
package io.github.chess.model.configuration | ||
|
||
/** Represents the possible game mode for the chess game. */ | ||
enum GameMode: | ||
|
||
/** Represents the game mode in which 2 human players play against each other. */ | ||
case PVP | ||
|
||
/** Represents the game mode in which 1 human player plays against the computer. */ | ||
case PVE |
24 changes: 24 additions & 0 deletions
24
chess/src/main/scala/io/github/chess/model/configuration/Player.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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* MIT License | ||
* Copyright (c) 2023 Cesario Jahrim Gabriele & Derevyanchenko Maxim & Felice Mirko & Kentpayeva Madina | ||
* | ||
* Full license description available at: https://github.com/jahrim/PPS-22-chess/blob/master/LICENSE | ||
*/ | ||
package io.github.chess.model.configuration | ||
|
||
import io.github.chess.model.Team | ||
|
||
/** | ||
* Represents a player of the chess game. | ||
* @param name his name | ||
* @param team his [[Team]] | ||
*/ | ||
case class Player(name: String, team: Team) | ||
|
||
object Player: | ||
|
||
/** Creates a no name white player. */ | ||
def noNameWhitePlayer: Player = Player("", Team.WHITE) | ||
|
||
/** Creates a no name black player. */ | ||
def noNameBlackPlayer: Player = Player("", Team.BLACK) |
28 changes: 28 additions & 0 deletions
28
chess/src/main/scala/io/github/chess/model/configuration/TimeConstraint.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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* MIT License | ||
* Copyright (c) 2023 Cesario Jahrim Gabriele & Derevyanchenko Maxim & Felice Mirko & Kentpayeva Madina | ||
* | ||
* Full license description available at: https://github.com/jahrim/PPS-22-chess/blob/master/LICENSE | ||
*/ | ||
package io.github.chess.model.configuration | ||
|
||
/** Represents the possible time constraints available to the chess game. */ | ||
enum TimeConstraint(var minutes: Int = TimeConstraint.NoMinutesPerMove): | ||
|
||
/** Represents a no limit time constraint. */ | ||
case NoLimit extends TimeConstraint | ||
|
||
/** Represents a time limit per move, defaulting to 5 minutes per move. */ | ||
case MoveLimit extends TimeConstraint(TimeConstraint.DefaultMinutesPerMove) | ||
|
||
object TimeConstraint: | ||
|
||
private final val NoMinutesPerMove = -1 | ||
|
||
private final val DefaultMinutesPerMove = 5 | ||
|
||
/** Minimum time limit per move. */ | ||
final val MinMoveLimit: Int = 1 | ||
|
||
/** Maximum time limit per move. */ | ||
final val MaxMoveLimit: Int = 30 |
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