s3games.engine

## Class GameSpecification

- java.lang.Object
- - s3games.engine.GameSpecification

-     public class GameSpecification
      extends java.lang.Object

  The GameSpecification contains all information loaded from the game specification file. It is all the information that is needed to now how to play and visualize a specific game.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `java.lang.String` | `boardBackgroundFileName` path to a file that contains an image for the game window background
    `java.util.ArrayList<CameraObjectType>` | `cameraObjectTypes` lists specifications of objects to be detected by the camera when playing on real-world game board
    `java.util.Map<java.lang.String,Element>` | `elements` list of elements indexed through their name
    `java.util.Map<java.lang.String,ElementType>` | `elementTypes` list of element types indexed through their name
    `java.util.Map<java.lang.String,Expression>` | `expressions` list of all expressions.
    `java.lang.String` | `gameName` name of the game
    `int` | `initialPlayerScore` initial scores for all players
    `java.util.Map<java.lang.String,Location>` | `locations` list of locations indexed through their name
    `java.util.Map<java.lang.String,LocationType>` | `locationTypes` list of location types indexed through their name
    `java.lang.String[]` | `playerNames` names of players - just for visualization
    `java.util.Map<java.lang.String,GameRule>` | `rules` lists all the game rules, indexed by their name
    `java.util.ArrayList<GameScoring>` | `scorings` specifies how the players scores change if particular game states are reached
    `java.util.Map<Expr,Expr>` | `terminationConditions` list of conditions expressions that determine the game is over, if they evaluate to true.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GameSpecification(Config config, GameLogger logger)` construct a new empty game specification

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Location` | `findClosestCameraLocation(int x, int y)` find a camera location which is closest to a specified pixel
    `boolean` | `load(java.lang.String gameName)` load game specification from a file

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### gameName

          public java.lang.String gameName

      name of the game

    - #### boardBackgroundFileName

          public java.lang.String boardBackgroundFileName

      path to a file that contains an image for the game window background

    - #### locationTypes

          public java.util.Map<java.lang.String,LocationType> locationTypes

      list of location types indexed through their name

    - #### elementTypes

          public java.util.Map<java.lang.String,ElementType> elementTypes

      list of element types indexed through their name

    - #### elements

          public java.util.Map<java.lang.String,Element> elements

      list of elements indexed through their name

    - #### locations

          public java.util.Map<java.lang.String,Location> locations

      list of locations indexed through their name

    - #### expressions

          public java.util.Map<java.lang.String,Expression> expressions

      list of all expressions. expressions are user "functions" that can be evaluated in current context to get any value. they are used in many different places in game rules, and can have names. This list contains named expressions and is indexed through the names of the expressions

    - #### terminationConditions

          public java.util.Map<Expr,Expr> terminationConditions

      list of conditions expressions that determine the game is over, if they evaluate to true. the map contains conditions as keys, and player numbers that win the game in that case as values

    - #### scorings

          public java.util.ArrayList<GameScoring> scorings

      specifies how the players scores change if particular game states are reached

    - #### rules

          public java.util.Map<java.lang.String,GameRule> rules

      lists all the game rules, indexed by their name

    - #### cameraObjectTypes

          public java.util.ArrayList<CameraObjectType> cameraObjectTypes

      lists specifications of objects to be detected by the camera when playing on real-world game board

    - #### playerNames

          public java.lang.String[] playerNames

      names of players - just for visualization

    - #### initialPlayerScore

          public int initialPlayerScore

      initial scores for all players

  - ### Constructor Detail

    - #### GameSpecification

          public GameSpecification(Config config,
                           GameLogger logger)

      construct a new empty game specification

  - ### Method Detail

    - #### load

          public boolean load(java.lang.String gameName)
                       throws java.lang.Exception

      load game specification from a file
      Parameters:
        `gameName` - the name of game, and the file where the specification is loaded from (in games/ folder)
      Returns:
        true, if the game specification was successfully parsed and loaded
      Throws:
        `java.lang.Exception`

    - #### findClosestCameraLocation

          public Location findClosestCameraLocation(int x,
                                           int y)

      find a camera location which is closest to a specified pixel
      Parameters:
        `x` - x-coordinate of the pixel
        `y` - y-coordinate of the pixel
      Returns:
        a location object that is closest to the specified pixel of the camera image