Package gamedata

Class Game

  • All Implemented Interfaces:
    IconProvider, java.lang.Comparable<Game>

    public final class Game
    extends java.lang.Object
    implements java.lang.Comparable<Game>, IconProvider
    The game class represents a distinct, standalone game. Instances of this class cannot be created directly but are instead registered. Each game is assigned a unique code that can be used to name it in a language-independent way. Game codes are typically 2-6 capital letters, but this is not a requirement. For example, the code for the game Arkham Horror is AH.

    Note: Expansions for a game, that is, products that add new material to an existing game but which cannot be used without it, are managed through the Expansion class.

    Author:
    Chris Jennings
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String ALL_GAMES_CODE
      The code assigned to the special "all games" instance.
      static java.lang.String GAME_SETTING_KEY
      This key is set on a component's private settings with the code of the component's game.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      int compareTo​(Game o)
      Compares this game to another game.
      static Game get​(java.lang.String code)
      Returns the game that was registered using the code, or null if no game has been registered with the code.
      static Game getAllGamesInstance()
      Returns a special Game instance that represents "all games".
      java.lang.String getCode()
      Return the unique identifier code of this game.
      StyleApplicator getDefaultDeckStyleApplicator()
      Returns the default style applicator used to modify the style of new objects that are added to a deck for this game.
      java.lang.String getGameName()
      Returns the name of this game in the game language.
      static Game[] getGames​(boolean includeAllGame)
      Returns an array of all of the registered games.
      ThemedIcon getIcon()
      Returns a small icon that can be used in the user interface to represent the game visually.
      Settings getMasterSettings()
      Deprecated.
      Replaced by getSettings().
      Settings getSettings()
      Returns the settings instance for this game.
      ExpansionSymbolTemplate getSymbolTemplate()
      Returns the template that describes the symbol graphics used to draw expansion symbols for this component.
      java.lang.String getUIName()
      Returns the name of this game in the user interface language.
      static Game register​(java.lang.String code, java.lang.String gameName)
      Register a new game with an associated icon.
      static Game register​(java.lang.String code, java.lang.String key, java.awt.image.BufferedImage iconImage)
      Deprecated.
      Prefer methods that take an icon or image resource.
      static Game register​(java.lang.String code, java.lang.String key, java.lang.String icon)
      Register a new game with an associated icon.
      static Game register​(java.lang.String code, java.lang.String uiName, java.lang.String gameName, java.awt.image.BufferedImage iconImage, ExpansionSymbolTemplate template)
      Deprecated.
      Prefer methods that take an icon or image resource.
      static Game register​(java.lang.String code, java.lang.String uiName, java.lang.String gameName, java.lang.String iconResource, ExpansionSymbolTemplate template)
      Register a new game with an associated icon.
      static Game register​(java.lang.String code, java.lang.String uiName, java.lang.String gameName, javax.swing.Icon icon, ExpansionSymbolTemplate template)
      Register a new game with an associated icon.
      void setDefaultDeckStyleApplicator​(StyleApplicator applicator)
      Sets the applicator that will be used to apply default style settings to objects that are added to a deck for this game.
      java.lang.String toString()
      Returns the user interface name of this game.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • ALL_GAMES_CODE

        public static final java.lang.String ALL_GAMES_CODE
        The code assigned to the special "all games" instance.
        See Also:
        Constant Field Values
      • GAME_SETTING_KEY

        public static final java.lang.String GAME_SETTING_KEY
        This key is set on a component's private settings with the code of the component's game. Components from versions of Strange Eons prior to 3 might not have this value set; you can set in when the card is being read in (for example, in a DIY's onRead function).
        See Also:
        Constant Field Values
    • Method Detail

      • getCode

        public java.lang.String getCode()
        Return the unique identifier code of this game.
        Returns:
        this game's code
      • getUIName

        public java.lang.String getUIName()
        Returns the name of this game in the user interface language.
        Returns:
        the game name
      • getGameName

        public java.lang.String getGameName()
        Returns the name of this game in the game language.
        Returns:
        the game name
      • getSymbolTemplate

        public ExpansionSymbolTemplate getSymbolTemplate()
        Returns the template that describes the symbol graphics used to draw expansion symbols for this component.
        Returns:
        the template instance
      • getIcon

        public ThemedIcon getIcon()
        Returns a small icon that can be used in the user interface to represent the game visually.
        Specified by:
        getIcon in interface IconProvider
        Returns:
        a representative icon for the game, or a generic icon if a specific icon is not available
      • getSettings

        public Settings getSettings()
        Returns the settings instance for this game. Each registered game has exactly one such instance. This is the preferred place to store the default values for all of the settings used by a particular game. The settings instance for a game should in turn be the parent of all of the private settings instances for individual components that belong to that game. (The game's settings will in turn have the shared settings as its parent.)
        Returns:
        the settings instance for this game
      • getMasterSettings

        @Deprecated
        public final Settings getMasterSettings()
        Deprecated.
        Replaced by getSettings().
      • setDefaultDeckStyleApplicator

        public void setDefaultDeckStyleApplicator​(StyleApplicator applicator)
        Sets the applicator that will be used to apply default style settings to objects that are added to a deck for this game. For example, the game Arkham Horror defines an applicator that changes the default style for new lines and curves to match the movement lines used on expansion boards for that game. If no applicator is explicitly set, a default applicator that leaves the style unchanged will be provided.
        Parameters:
        applicator - the applicator to use for the specified game
      • toString

        public java.lang.String toString()
        Returns the user interface name of this game.
        Overrides:
        toString in class java.lang.Object
        Returns:
        the name of the game, suitable for use in lists or other UI controls
      • compareTo

        public int compareTo​(Game o)
        Compares this game to another game. The all games instance will be considered less than any other game; other games are sorted by their user interface name.
        Specified by:
        compareTo in interface java.lang.Comparable<Game>
        Parameters:
        o - the game to compare this one to
        Returns:
        a negative integer, zero, or a positive integer as this game is less than, equal to, or greater than the parameter in terms of sort order
      • getAllGamesInstance

        public static Game getAllGamesInstance()
        Returns a special Game instance that represents "all games". This can be used in a user interface when filtering by game. This game has the code "*".
        Returns:
        the unique "All Games" instance
      • get

        public static Game get​(java.lang.String code)
        Returns the game that was registered using the code, or null if no game has been registered with the code.
        Parameters:
        code - the unique code that identifies the game
        Returns:
        the game for the requested code, or null
      • getGames

        public static Game[] getGames​(boolean includeAllGame)
        Returns an array of all of the registered games. If includeAllGame is true, then the special all games instance will be included at index 0 in the array.
        Parameters:
        includeAllGame - whether to include the special All Games instance
        Returns:
        a sorted array of games
      • register

        public static Game register​(java.lang.String code,
                                    java.lang.String gameName)
        Register a new game with an associated icon. This is a convenience method that uses a default icon to represent the game. It is only intended for use as an interim step early in the development of a game plug-in, or for experimenting with the API.
        Parameters:
        code - a short code string for the game, usually 2-6 capital letters
        gameName - the localized name of the game for presentation to the user
        Returns:
        the registered game
        Throws:
        java.lang.IllegalArgumentException - if a game with this code is already registered, or if the code contains characters that are not legal for file names
        java.lang.NullPointerException - if the code or name is null
        Since:
        2.1a9
        See Also:
        register(java.lang.String, java.lang.String, java.awt.image.BufferedImage)
      • register

        @Deprecated
        public static Game register​(java.lang.String code,
                                    java.lang.String key,
                                    java.awt.image.BufferedImage iconImage)
        Deprecated.
        Prefer methods that take an icon or image resource.
        Register a new game with an associated icon. This method looks up the names for the game using a string key and Language. (The interface name is determined using Language.string( code ) and the game name is determined using Language.gstring( code ).)
        Parameters:
        code - a short code string for the game, usually 2-6 capital letters
        key - the string table key to use when looking up the game name(s)
        iconImage - an image to use to represent the game; if null a default image is used (see register(java.lang.String, java.lang.String)).
        Returns:
        the registered game
        Throws:
        java.lang.IllegalArgumentException - if a game with this code is already registered, or if the code contains characters that are not legal for file names
        java.lang.NullPointerException - if the code or key is null
        See Also:
        register(java.lang.String, java.lang.String, java.lang.String, java.awt.image.BufferedImage, gamedata.ExpansionSymbolTemplate)
      • register

        public static Game register​(java.lang.String code,
                                    java.lang.String key,
                                    java.lang.String icon)
        Register a new game with an associated icon. This method looks up the names for the game using a string key and Language. (The interface name is determined using Language.string( code ) and the game name is determined using Language.gstring( code ).)
        Parameters:
        code - a short code string for the game, usually 2-6 capital letters
        key - the string table key to use when looking up the game name(s)
        icon - an image resource to use as an icon to represent the game; if null a default image is used (see register(java.lang.String, java.lang.String)).
        Returns:
        the registered game
        Throws:
        java.lang.IllegalArgumentException - if a game with this code is already registered, or if the code contains characters that are not legal for file names
        java.lang.NullPointerException - if the code or key is null
        See Also:
        register(java.lang.String, java.lang.String, java.lang.String, java.awt.image.BufferedImage, gamedata.ExpansionSymbolTemplate)
      • register

        @Deprecated
        public static Game register​(java.lang.String code,
                                    java.lang.String uiName,
                                    java.lang.String gameName,
                                    java.awt.image.BufferedImage iconImage,
                                    ExpansionSymbolTemplate template)
        Deprecated.
        Prefer methods that take an icon or image resource.
        Register a new game with an associated icon. Games are registered using a short identifier code, usually 2-6 letters and all caps. For example, the game Arkham Horror is registered as AH.

        When a component is created, a setting named game will be added to it, set to the game code indicated by the class map file. The parent settings for that component will then be the settings instance for the associated game. Components not associated with a specific game in their class map will be associated with the special "all games" game. (Generic components like Markers use this game.)

        Expansions are also associated with particular games, so that only the expansions that match the component currently being edited are listed as choices for that component.

        Game Editions: For games that have more than one edition, treat different editions as different games if they use substantially different rules or graphic design.

        Parameters:
        code - a short code string for the game, usually 2-6 capital letters
        uiName - the name of the game, in the user interface locale
        gameName - the name of the game, in the game locale
        iconImage - an image to use to represent the game; if null a default image is used (see register(java.lang.String, java.lang.String)).
        template - an expansion symbol template that describes the expansion symbols for this game, or null to use a default template
        Returns:
        the registered game
        Throws:
        java.lang.IllegalArgumentException - if a game with this code is already registered, or if the code contains characters that are not legal for file names
        java.lang.NullPointerException - if the code or either name is null
        See Also:
        getSettings(), getAllGamesInstance(), ClassMap
      • register

        public static Game register​(java.lang.String code,
                                    java.lang.String uiName,
                                    java.lang.String gameName,
                                    java.lang.String iconResource,
                                    ExpansionSymbolTemplate template)
        Register a new game with an associated icon. Games are registered using a short identifier code, usually 2-6 letters and all caps. For example, the game Arkham Horror is registered as AH.

        When a component is created, a setting named game will be added to it, set to the game code indicated by the class map file. The parent settings for that component will then be the settings instance for the associated game. Components not associated with a specific game in their class map will be associated with the special "all games" game. (Generic components like Markers use this game.)

        Expansions are also associated with particular games, so that only the expansions that match the component currently being edited are listed as choices for that component.

        Game Editions: For games that have more than one edition, treat different editions as different games if they use substantially different rules or graphic design.

        Parameters:
        code - a short code string for the game, usually 2-6 capital letters
        uiName - the name of the game, in the user interface locale
        gameName - the name of the game, in the game locale
        iconResource - an image resource to use to represent the game; if null a default image is used (see register(java.lang.String, java.lang.String)).
        template - an expansion symbol template that describes the expansion symbols for this game, or null to use a default template
        Returns:
        the registered game
        Throws:
        java.lang.IllegalArgumentException - if a game with this code is already registered, or if the code contains characters that are not legal for file names
        java.lang.NullPointerException - if the code or either name is null
        See Also:
        getSettings(), getAllGamesInstance(), ClassMap
      • register

        public static Game register​(java.lang.String code,
                                    java.lang.String uiName,
                                    java.lang.String gameName,
                                    javax.swing.Icon icon,
                                    ExpansionSymbolTemplate template)
        Register a new game with an associated icon. Games are registered using a short identifier code, usually 2-6 letters and all caps. For example, the game Arkham Horror is registered as AH.

        When a component is created, a setting named game will be added to it, set to the game code indicated by the class map file. The parent settings for that component will then be the settings instance for the associated game. Components not associated with a specific game in their class map will be associated with the special "all games" game. (Generic components like Markers use this game.)

        Expansions are also associated with particular games, so that only the expansions that match the component currently being edited are listed as choices for that component.

        Game Editions: For games that have more than one edition, treat different editions as different games if they use substantially different rules or graphic design.

        Parameters:
        code - a short code string for the game, usually 2-6 capital letters
        uiName - the name of the game, in the user interface locale
        gameName - the name of the game, in the game locale
        icon - an icon instance to use to represent the game; if null a default image is used (see register(java.lang.String, java.lang.String)).
        template - an expansion symbol template that describes the expansion symbols for this game, or null to use a default template
        Returns:
        the registered game
        Throws:
        java.lang.IllegalArgumentException - if a game with this code is already registered, or if the code contains characters that are not legal for file names
        java.lang.NullPointerException - if the code or either name is null
        See Also:
        getSettings(), getAllGamesInstance(), ClassMap