Packages

trait GameFieldInterface extends AnyRef

Linear Supertypes
AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. GameFieldInterface
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Abstract Value Members

  1. 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

  2. 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

  3. 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

  4. 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

  5. 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

  6. 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

  7. abstract def getFigures: Vector[Figure]

    returns

    All Figures from the gameField, also those who are checked

  8. abstract def getPawnAtEnd(): Pawn

    returns

    the Pawn at the end

  9. abstract def getPlayer: Color

    returns

    Color of the Player who has to make his turn now (the valid Player)

  10. abstract def getStatus(): Int

    returns

    the gameField/ Game status

  11. 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

  12. 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

  13. 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

  14. 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

  15. 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

  16. 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

  17. 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

  18. 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

  19. abstract def setStatus(newStatus: Int): Unit

    Sets the status of the gameField/ ongoing Game

  20. 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

  21. 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

Concrete Value Members

  1. val CHECKED: Int
  2. val CHECKMATE: Int
  3. val MOVE_ILLEGAL: Int
  4. val PAWN_REACHED_END: Int
  5. val RUNNING: Int