Class Flare

All Implemented Interfaces:
MouseListener, EventListener, AutoConfigurable, Buildable, Configurable, GameComponent, Drawable, PropertyNameSource, CommandEncoder, ValidityChecker, Translatable, ImageSearchTarget, SearchTarget, UniqueIdManager.Identifyable

Allows a player to ping a location ("send up a flare") by clicking on a map with the correct modifier key combination held down (default: Alt+LeftClick). Can be shown as an animated colored circle, or a plain one. If reportFormat field is provided, a message is also displayed in the chat log. Flare will work with both online play and PBEM play.
  • Field Details

  • Constructor Details

    • Flare

      public Flare()
  • Method Details

    • getDescription

      public String getDescription()
      Returns:
      String description of this component, displayed in Editor.
    • getConfigureTypeName

      public static String getConfigureTypeName()
      Returns:
      String name of component class. The part in [..] in the Editor.
    • getMap

      public Map getMap()
      Returns:
      the Map associated with this Flare component.
    • getAttributeTypes

      public Class<?>[] getAttributeTypes()
      Attribute types for this component's buildFile (xml) entry. These launch the proper configurers when the component is edited in the Editor.
      Specified by:
      getAttributeTypes in interface AutoConfigurable
      Specified by:
      getAttributeTypes in class AbstractConfigurable
      Returns:
      list of classes for attributes
    • getAttributeNames

      public String[] getAttributeNames()
      Attribute names for this component's buildFile (xml) entry.
      Specified by:
      getAttributeNames in interface AutoConfigurable
      Specified by:
      getAttributeNames in class AbstractBuildable
      Returns:
      list of names for attributes
    • getAttributeDescriptions

      public String[] getAttributeDescriptions()
      Attribute names for this component's buildFile (xml) entry. These show up in the Editor next to the configurers for each attribute.
      Specified by:
      getAttributeDescriptions in interface AutoConfigurable
      Specified by:
      getAttributeDescriptions in class AbstractConfigurable
      Returns:
      list of names for attributes
    • getAttributeValueString

      public String getAttributeValueString(String key)
      Gets current attribute value in string form.
      Specified by:
      getAttributeValueString in interface AutoConfigurable
      Specified by:
      getAttributeValueString in interface Translatable
      Specified by:
      getAttributeValueString in class AbstractBuildable
      Parameters:
      key - - attribute name
      Returns:
      current the value of one of this component's attributes, in string form.
    • setAttribute

      public void setAttribute(String key, Object value)
      Sets the value of one of this component's attributes.
      Specified by:
      setAttribute in interface AutoConfigurable
      Specified by:
      setAttribute in interface Translatable
      Specified by:
      setAttribute in class AbstractBuildable
      Parameters:
      key - the name of the attribute
      value - new value for attribute. Can pass either the Object itself or the String version.
    • getHelpFile

      public HelpFile getHelpFile()
      Specified by:
      getHelpFile in interface Configurable
      Returns:
      Help file for this component, accessed when "Help" button in Editor is clicked while configuring component.
    • addTo

      public void addTo(Buildable parent)
      Adds this component to a Buildable component. In this case, a Map.
      Specified by:
      addTo in interface Buildable
      Parameters:
      parent - - the Map to add the Flare to.
    • removeFrom

      public void removeFrom(Buildable parent)
      Removes this component from a Buildable parent.
      Specified by:
      removeFrom in interface Configurable
      Parameters:
      parent - - the Map to remove the Flare from.
    • startAnimation

      public void startAnimation(boolean isLocal)
      Start the Flare animation.
      Parameters:
      isLocal - - true if this Flare was launched on this client (i.e. by this player). Otherwise, center on the ping location if user preferences are set for centering on opponent moves.
    • draw

      public void draw(Graphics g, Map map)
      Draw the Flare at current animation frame
      Specified by:
      draw in interface Drawable
      Parameters:
      g - - Graphics
      map - - Map component
    • drawAboveCounters

      public boolean drawAboveCounters()
      Flare is always drawn above counters
      Specified by:
      drawAboveCounters in interface Drawable
      Returns:
      true
    • encode

      public String encode(Command c)
      Serializes Flare commands into string form.
      Specified by:
      encode in interface CommandEncoder
      Parameters:
      c - Command
      Returns:
      String version of Flare Command, or null if not a Flare Command.
    • decode

      public Command decode(String s)
      Deserializes string command info into a Flare Command.
      Specified by:
      decode in interface CommandEncoder
      Parameters:
      s - String for a Flare Command
      Returns:
      Flare Command object
    • getAllowableConfigureComponents

      public Class<?>[] getAllowableConfigureComponents()
      Specified by:
      getAllowableConfigureComponents in interface Configurable
      Returns:
      a list of valid sub-component Classes. If a Class appears in this list, then instances of that class may be added to this component from the Editor's ConfigureTree window by right-clicking on the component and selecting the appropriate "Add" option.
    • mouseClicked

      public void mouseClicked(MouseEvent e)
      Specified by:
      mouseClicked in interface MouseListener
      Parameters:
      e - MouseEvent
    • mousePressed

      public void mousePressed(MouseEvent e)
      Check for our modifier key, and if so launch a Flare sequence on our map, and send a command to other players' along with a Chat Log message if a Report Format has been specified in the component.
      Specified by:
      mousePressed in interface MouseListener
      Parameters:
      e - - a MouseEvent
    • mouseReleased

      public void mouseReleased(MouseEvent e)
      Specified by:
      mouseReleased in interface MouseListener
      Parameters:
      e - MouseEvent
    • mouseEntered

      public void mouseEntered(MouseEvent e)
      Specified by:
      mouseEntered in interface MouseListener
      Parameters:
      e - MouseEvent
    • mouseExited

      public void mouseExited(MouseEvent e)
      Specified by:
      mouseExited in interface MouseListener
      Parameters:
      e - MouseEvent
    • setup

      public void setup(boolean gameStarting)
      Description copied from interface: GameComponent
      Notify the GameComponent that a game has started/ended
      Specified by:
      setup in interface GameComponent
      Parameters:
      gameStarting - true if starting a game, false if ending one
    • getRestoreCommand

      public Command getRestoreCommand()
      Description copied from interface: GameComponent
      When saving a game, each GameComponent should return a Command that, when executed, restores the GameComponent to its state when the game was saved If this component has no persistent state, return null
      Specified by:
      getRestoreCommand in interface GameComponent
      Returns:
      Theoretically returns the command to "restore" this from a saved game or when adding a new player, but of course Flare doesn't need to be "restored", so null.
    • setClickPoint

      public void setClickPoint(Point p)
      Record our clicked point on the map
      Parameters:
      p - - point where player clicked and where flare should be shown
    • getClickPoint

      public Point getClickPoint()
      Returns:
      point where player clicked and where flare should be shown
    • setId

      public void setId(String id)
      Sets our unique ID (among Flares), so that multiple Flares don't inadvertently start each other when we send commands to other clients.
      Specified by:
      setId in interface UniqueIdManager.Identifyable
      Parameters:
      id - Sets our unique ID
    • getId

      public String getId()
      Specified by:
      getId in interface UniqueIdManager.Identifyable
      Returns:
      unique ID of this flare, for purposes of distinguishing between Flare commands
    • getFormattedStringList

      public List<String> getFormattedStringList()
      Specified by:
      getFormattedStringList in interface SearchTarget
      Overrides:
      getFormattedStringList in class AbstractConfigurable
      Returns:
      a list of any Message Format strings referenced in the Configurable, if any (for search)
    • addLocalImageNames

      public void addLocalImageNames(Collection<String> s)
      In case reports use HTML and refer to any image files
      Specified by:
      addLocalImageNames in interface ImageSearchTarget
      Overrides:
      addLocalImageNames in class AbstractImageFinder
      Parameters:
      s - Collection to add image names to