Class Replace

All Implemented Interfaces:
PropertyNameSource, PropertySource, EditablePiece, GamePiece, PropertyExporter, StateMergeable, TranslatablePiece, PersistentPropertyContainer, Auditable, ImageSearchTarget, SearchTarget, RecursionLimiter.Loopable

public class Replace extends PlaceMarker
GamePiece trait that replaces a GamePiece with another one
  • Field Details

  • Constructor Details

    • Replace

      public Replace()
    • Replace

      public Replace(String type, GamePiece inner)
  • Method Details

    • myKeyEvent

      public Command myKeyEvent(KeyStroke stroke)
      Description copied from class: Decorator
      The response of this trait alone to the given KeyStroke or the virtual keystroke of a NamedKeyStroke. NamedKeyStrokes are allocated a unique internal KeyStroke when they are first used in a module, and that KeyStroke is passed up and down the decorator stack to represent them (see NamedKeyStroke.getKeyStroke()).
      Overrides:
      myKeyEvent in class PlaceMarker
      Parameters:
      stroke - KeyStroke to apply (to apply a Named Keystroke send NamedKeyStroke.getKeyStroke()
      Returns:
      Generated Command to reproduce any changes just made to to the game state, or null if no effect
      See Also:
    • replacePiece

      protected Command replacePiece()
    • selectMarker

      protected void selectMarker(GamePiece marker)
      Overrides:
      selectMarker in class PlaceMarker
    • getDescription

      public String getDescription()
      Description copied from interface: EditablePiece
      A plain-English description of this type of trait/piece - includes data from fields where appropriate
      Specified by:
      getDescription in interface EditablePiece
      Overrides:
      getDescription in class PlaceMarker
    • getBaseDescription

      public String getBaseDescription()
      Description copied from interface: EditablePiece
      Support for a basic-name-only description introduced later, so this default retrofits it from the full description if an explicit one is not defined.
      Specified by:
      getBaseDescription in interface EditablePiece
      Overrides:
      getBaseDescription in class PlaceMarker
      Returns:
      name of trait/piece type, w/o additional data
    • getDescriptionField

      public String getDescriptionField()
      Description copied from class: Decorator
      If Decorator contains a description *field*, returns the current contents of it.
      Overrides:
      getDescriptionField in class PlaceMarker
      Returns:
      contents of "description" field, if it exists.
    • getHelpFile

      public HelpFile getHelpFile()
      Specified by:
      getHelpFile in interface EditablePiece
      Overrides:
      getHelpFile in class PlaceMarker
      Returns:
      the help file for this trait
    • myGetType

      public String myGetType()
      Description copied from class: Decorator
      The "type information" of a piece or trait is information that does not change during the course of a game. Image file names, context menu strings, etc., all should be reflected in the type. The type information is returned serialized string form, ready to be decoded by a SequenceEncoder#decode.
      Overrides:
      myGetType in class PlaceMarker
      Returns:
      the type information of this trait alone
      See Also:
    • getEditor

      public PieceEditor getEditor()
      Specified by:
      getEditor in interface EditablePiece
      Overrides:
      getEditor in class PlaceMarker
      Returns:
      the configurer for this trait - the dialog which allows the editing the piece's type information. Default configurer is a SimplePieceEditor, but many traits will want to provide custom versions.
    • createMarker

      public GamePiece createMarker()
      Description copied from class: PlaceMarker
      The marker, with prototypes fully expanded
      Overrides:
      createMarker in class PlaceMarker
      Returns:
      new Marker
    • matchTraits

      protected void matchTraits(GamePiece base, GamePiece marker)
      Match trait states from the supplied base Decorator to the marker - Markers are never matched - Dynamic Properties are matched on Name only - All other traits matched on full Type
      Parameters:
      base - Decorator in Base marker to start matching
      marker - Marker to set matched values into
    • getPropertyNames

      public List<String> getPropertyNames()
      Specified by:
      getPropertyNames in interface PropertyNameSource
      Overrides:
      getPropertyNames in class PlaceMarker
      Returns:
      List of property names "exposed" by this piece -- that are available to other Traits and components to read. Default behavior for a Trait is not to expose any properties, but Traits which should expose some (e.g. DynamicProperty or Marker) would provide an array of the property names here.
    • getI18nData

      public PieceI18nData getI18nData()
      Description copied from class: Decorator
      Return Internationalization (I18n) data for this piece
      Specified by:
      getI18nData in interface TranslatablePiece
      Overrides:
      getI18nData in class PlaceMarker
      Returns:
      I18n data, used to hold translations of strings