trait GameFieldInterface extends AnyRef
- Alphabetic
- By Inheritance
- GameFieldInterface
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
- abstract def addFigures(figures: Vector[Figure]): GameField
Adds the Figures to the gameField if the gameField does not contain them yet
Adds the Figures to the gameField if the gameField does not contain them yet
- figures
- Vector of Figures to adjust the current gameField
- returns
new gameField
- abstract def cellsFreeAroundFigure(figure: Figure): List[(Int, Int)]
Checks the adjacent cells and returns a list of those who are free
Checks the adjacent cells and returns a list of those who are free
- figure
which adjacent cells should be reviewed
- returns
List of free cells
- abstract def changePlayer(): Color
Changes the valid Player's color
Changes the valid Player's color
e.g. If it was White's turn before it is now Black's turn
White -> Black Black -> White
- returns
The color of the new valid Player
- abstract def clear(): Boolean
Sets the valid Player to White.
Sets the valid Player to White. Clears the gameField.
- returns
true if the gameField is now empty
- abstract def convertFigure(figure: Figure, toFigure: Figure): Unit
Converts one Figure to another
Converts one Figure to another
(Mostly used for converting a Pawn into Queen, Rook, Bishop or Knight after reaching the end)
- figure
to convert
- toFigure
of the wanted type
- abstract def getFigure(xPos: Int, yPos: Int): Option[Figure]
Fetches the Figure at the specified position.
Fetches the Figure at the specified position.
With
getFigure(x, y).get
you are able to fetch the actual Figure. But an Exception will be thrown if the cell is empty and the call returns Option[None]! getFigure(x, y).get }}} But an Exception will be thrown if the cell is empty and the call returns Option[None]!
- xPos
value of the field
- yPos
value of the field
- returns
Option[Figure] if there is a Figure, Option[None] if the cell is empty
- abstract def getFigures: Vector[Figure]
- returns
All Figures from the gameField, also those who are checked
- abstract def getPawnAtEnd(): Pawn
- returns
the Pawn at the end
- abstract def getPlayer: Color
- returns
Color of the Player who has to make his turn now (the valid Player)
- abstract def getStatus(): Int
- returns
the gameField/ Game status
- abstract def isChecked(playerCol: Color): Boolean
Inspects if the Player is checked by confirming wether any of the other Player's Figures could move to the King
Inspects if the Player is checked by confirming wether any of the other Player's Figures could move to the King
- playerCol
color of the to be examined Player
- returns
true if checked, else false
- abstract def isCheckmate(playerCol: Color): Boolean
Reviews wether there is no possibility for the king to get out of check by verifying if any cells around him are free that he can move to, to get out of check
Reviews wether there is no possibility for the king to get out of check by verifying if any cells around him are free that he can move to, to get out of check
- playerCol
color of the Player to examine
- returns
true if the king can't move anymore, else false
- abstract def moveTo(xNow: Int, yNow: Int, xNext: Int, yNext: Int): GameField
Moves Figure from (xNow, yNow) to (xNext, yNext).
Moves Figure from (xNow, yNow) to (xNext, yNext). If there is a (enemy) Figure at (xNext, yNext) it's going to be replaced.
- xNow
x-value the Figure stands at the moment
- yNow
y-value the Figure stands at the moment
- xNext
x-value the Figure should move to
- yNext
y-value the Figure should move to
- returns
gameField
- abstract def moveToFieldAllowed(x: Int, y: Int, figure: Figure): Boolean
Confirms if you set yourself into check with this move and whether the Figure at (x, y) is a king of the other Player
Confirms if you set yourself into check with this move and whether the Figure at (x, y) is a king of the other Player
- x
value of the field
- y
value of the field
- figure
you want to move
- returns
true if you not set yourself into check and there is no king of the other Player
- abstract def moveValid(xNow: Int, yNow: Int, xNext: Int, yNext: Int): Boolean
Confirms if right Player is moving.
Confirms if right Player is moving. If true validates if the move is allowed by the set rules.
- xNow
x-value the Figure stands at the moment
- yNow
y-value the Figure stands at the moment
- xNext
x-value the Figure should move to
- yNext
y-value the Figure should move to
- returns
true if the right Player is moving and if the move is valid, else false
- abstract def pawnHasReachedEnd(): Boolean
Inspects if a Pawn of any color has reached the end of the field (y = 7 || y = 0)
Inspects if a Pawn of any color has reached the end of the field (y = 7 || y = 0)
- returns
true if a Pawn has reached the end, else false
- abstract def setPlayer(color: Color): Color
Sets the Player who has to make his turn now (the valid Player)
Sets the Player who has to make his turn now (the valid Player)
- color
of the valid Player
- returns
the old Player's Color
- abstract def setSelfIntoCheck(figure: Figure, xNext: Int, yNext: Int): Boolean
Verifies if you set yourself into check by simulating that move and inspect if any figure of the enemy checks you.
Verifies if you set yourself into check by simulating that move and inspect if any figure of the enemy checks you.
- figure
you want to move
- xNext
x-value the Figure should move to
- yNext
y-value the Figure should move to
- returns
true if a Player could check you after that move, else false
- abstract def setStatus(newStatus: Int): Unit
Sets the status of the gameField/ ongoing Game
- abstract def wayToIsFreeDiagonal(xNow: Int, yNow: Int, xNext: Int, yNext: Int): Boolean
Checks if there are no Figures on the diagonal way from (xNow, yNow) to (xNext, yNext).
Checks if there are no Figures on the diagonal way from (xNow, yNow) to (xNext, yNext). Diagonal means if xNow = xNext + n and yNow = yNext + n. It will not verify if the cell at (xNext, yNext) is free!
- xNow
x-value the Figure stands at the moment
- yNow
y-value the Figure stands at the moment
- xNext
x-value the Figure should move to
- yNext
y-value the Figure should move to
- returns
true if the way is free
- abstract def wayToIsFreeStraight(xNow: Int, yNow: Int, xNext: Int, yNext: Int): Boolean
Checks if there are no Figures on the straight way from (xNow, yNow) to (xNext, yNext).
Checks if there are no Figures on the straight way from (xNow, yNow) to (xNext, yNext). Straight means if xNow = xNext or yNow = yNext. It will not verify if the cell at (xNext, yNext) is free!
- xNow
x-value the Figure stands at the moment
- yNow
y-value the Figure stands at the moment
- xNext
x-value the Figure should move to
- yNext
y-value the Figure should move to
- returns
true if the way is free