Interface PersistentPropertyContainer

  • Method Summary

    Modifier and Type
    Method
    Description
     
    Setting a persistent property writes a property value into the piece (creating a new entry in the piece's persistent property table if the specified key does not yet exist in it).
  • Method Details

    • setPersistentProperty

      Command setPersistentProperty(Object key, Object val)
      Setting a persistent property writes a property value into the piece (creating a new entry in the piece's persistent property table if the specified key does not yet exist in it). Persistent properties are game-state-robust: they are saved/restored with saved games, and are passed via Command to other players' clients in a multiplayer game. The persistent property value can then be read from the piece via e.g. #getProperty. When reading back properties out of a piece, the piece's built-in properties are checked first, then scratchpad properties (see #setProperty), then external properties such as Global Properties. If only persistentProperties are to be searched, use getPersistentProperty(java.lang.Object) instead.

      In practical terms, setPersistentProperty is used mainly to implement the "Old" properties of BasicPiece (e.g. "OldLocationName", "OldZone", "OldMap", "OldBoard", "OldX", "OldY"). A Persistent Property is indeed nearly identical with DynamicProperty in storage/retrieval characteristics, and simply lacks the in-module interface for setting values, etc. Module Designers are thus recommended to stick with Dynamic Property traits for these functions.
      Parameters:
      key - String key naming the persistent property to be set. If a corresponding persistent property does not exist it will be created.
      val - New value for the persistent property
      Returns:
      a Command object which, when passed to another player's client via logfile, server, or saved game, will allow the result of the "set" operation to be replicated.
    • getPersistentProperty

      Object getPersistentProperty(Object key)
      Parameters:
      key - String key naming the persistent property whose value is to be returned.
      Returns:
      the current value of a persistent property, or null if it doesn't exist.