Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ConfigurationHandler

Class containing the configuration for the MarbleEvolution game.

todo

Add more configuration options.

Hierarchy

  • ConfigurationHandler

Index

Properties

Static config

Current configuration.

Static Private updatedConfig

updatedConfig: Configuration

Updated configuration. Will be applied when applyChanges gets called.

Methods

Static applyChanges

  • applyChanges(): void

Static getGeneticAlgorithm

Static getLevel

  • Fetches the configuration of a specific level. This is a shorthand for getProperty<LevelConfiguration>('levels.levelNumber');

    Parameters

    • Default value levelNumber: number = 0

      The number of the level. Must be valid.

    Returns LevelConfiguration

    The configuration for the specified level.

Static getProperty

  • getProperty<T>(key: string): T
  • Gets the current value of a property of the configuration.

    Type parameters

    • T

      The type of the property.

    Parameters

    • key: string

      The key of the property which should be returned. Must be given as path starting the root of the configuration. Each level must be separated by a dot .. Example: gameSettings.verboseMode would return the current value of the property verboseMode inside the property gameSettings.

    Returns T

    Returns the value of the property in the specified type.

Static isHumanMode

  • isHumanMode(): boolean
  • Checks whether human mode is enabled or not. This is a shorthand for getProperty<boolean>('gameSettings.humanMode');

    Returns boolean

    Returns true if the human mode is enabled, else false.

Static isVerboseMode

  • isVerboseMode(): boolean
  • Checks whether verbose mode is enabled or not. This is a shorthand for getProperty<boolean>('gameSettings.verboseMode');

    Returns boolean

    Returns true if the verbose mode is enabled, else false.

Static setProperty

  • setProperty<T>(key: string, value: T): void
  • Updates/Sets the value of a property in the configuration.

    note

    The update takes affect after the call of the applyChanges method.

    note

    The user must ensure that the new value is of the right type in order to perform the update.

    see

    Configuration See the configuration interface for the actual types of the values.

    Type parameters

    • T

      The type of the new value.
      Note: Must match the type of the property.

    Parameters

    • key: string

      The key of the property which should be updated/set. Must be given as path starting the root of the configuration. Each level must be separated by a dot .. Example: gameSettings.verboseMode would set the value of the property verboseMode inside the property gameSettings to a given value.

    • value: T

      The new value of the property. Must be of the correct type.

    Returns void

Static Private setPropertyRec

  • setPropertyRec<T>(config: any, key: string, value: T): any
  • Helper function realizing the setProperty method. This method recursively travers the current configuration and updates every occurrence in the path with its new value. If the last layer of the given key is reached, the config will be updated with the new value and the updated object will be returned. For any other layer the object at the current layer will be updated with the result of this method when called for the underlying layer.

    Type parameters

    • T

      The type of the new value.
      Note: Must match the type of the property.

    Parameters

    • config: any

      The config at the current layer.

    • key: string

      The key of the property which should be updated/set. Must be given as path starting the root of the configuration.

    • value: T

      The new value of the property.

    Returns any

    Returns the updated config.

Static updateConfig

Generated using TypeDoc