core

## Class VGDLFactory

- java.lang.Object
- - core.VGDLFactory

-     public class VGDLFactory
      extends java.lang.Object

  Created with IntelliJ IDEA. User: Diego Date: 22/10/13 Time: 15:33 This is a Java port from Tom Schaul's VGDL - https://github.com/schaul/py-vgdl

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.util.HashMap<java.lang.String,java.lang.Class>` | `registeredEffects` Cache for registered effects.
    `static java.util.HashMap<java.lang.String,java.lang.Class>` | `registeredGames` Cache for registered games.
    `static java.util.HashMap<java.lang.String,java.lang.Class>` | `registeredSprites` Cache for registered sprites.
    `static java.util.HashMap<java.lang.String,java.lang.Class>` | `registeredTerminations` Cache for registered effects.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Effect` | `createEffect(InteractionContent content)` Creates a new effect, with parameters passed as InteractionContent.
    `Game` | `createGame(GameContent content)` Creates a game, receiving a GameContent object
    `VGDLSprite` | `createSprite(SpriteContent content, Vector2d position, java.awt.Dimension dim)` Creates a new sprite with a given dimension in a certain position.
    `Termination` | `createTermination(TerminationContent content)` Creates a new termination, with parameters passed as TerminationContent.
    `static VGDLFactory` | `GetInstance()` Returns the unique instance of this class.
    `void` | `init()` Initializes the maps for caching classes.
    `void` | `parseParameters(Content content, java.lang.Object obj)` Parses the parameters from content, assigns them to variables in obj.
    `int` | `requestFieldValueInt(java.lang.Object obj, java.lang.String fieldName)` Returns the value of an int field in the object specified

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

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

- - ### Field Detail

    - #### registeredGames

          public static java.util.HashMap<java.lang.String,java.lang.Class> registeredGames

      Cache for registered games.

    - #### registeredSprites

          public static java.util.HashMap<java.lang.String,java.lang.Class> registeredSprites

      Cache for registered sprites.

    - #### registeredEffects

          public static java.util.HashMap<java.lang.String,java.lang.Class> registeredEffects

      Cache for registered effects.

    - #### registeredTerminations

          public static java.util.HashMap<java.lang.String,java.lang.Class> registeredTerminations

      Cache for registered effects.

  - ### Method Detail

    - #### init

          public void init()

      Initializes the maps for caching classes.

    - #### GetInstance

          public static VGDLFactory GetInstance()

      Returns the unique instance of this class.
      Returns:
        the factory that creates the game and the sprite objects.

    - #### createGame

          public Game createGame(GameContent content)

      Creates a game, receiving a GameContent object
      Parameters:
        `content` - potential parameters for the class.
      Returns:
        The game just created.

    - #### createSprite

          public VGDLSprite createSprite(SpriteContent content,
                                Vector2d position,
                                java.awt.Dimension dim)

      Creates a new sprite with a given dimension in a certain position. Parameters are passed as SpriteContent.
      Parameters:
        `content` - parameters for the sprite, including its class.
        `position` - position of the object.
        `dim` - dimensions of the sprite on the world.
      Returns:
        the new sprite, created and initialized, ready for play!

    - #### createEffect

          public Effect createEffect(InteractionContent content)

      Creates a new effect, with parameters passed as InteractionContent.
      Parameters:
        `content` - parameters for the effect, including its class.
      Returns:
        the new effect, created and initialized, ready to be triggered!

    - #### createTermination

          public Termination createTermination(TerminationContent content)

      Creates a new termination, with parameters passed as TerminationContent.
      Parameters:
        `content` - parameters for the termination condition, including its class.
      Returns:
        the new termination, created and initialized, ready to be checked!

    - #### parseParameters

          public void parseParameters(Content content,
                             java.lang.Object obj)

      Parses the parameters from content, assigns them to variables in obj.
      Parameters:
        `content` - contains the parameters to read.
        `obj` - object with the variables to assign.

    - #### requestFieldValueInt

          public int requestFieldValueInt(java.lang.Object obj,
                                 java.lang.String fieldName)

      Returns the value of an int field in the object specified
      Parameters:
        `obj` - object that holds the field.
        `fieldName` - name of the field to retrieve.
      Returns:
        the value, or -1 if the parameter does not exist or it is not an int.