Class PlayerRoster

All Implemented Interfaces:
PropertyChangeListener, EventListener, AutoConfigurable, Buildable, Configurable, GameComponent, GameSetupStep, PropertyNameSource, CommandEncoder, ComponentDescription, ValidityChecker, Translatable, Auditable, ImageSearchTarget, SearchTarget

Maintains a list of players involved in the current game
  • Field Details

  • Constructor Details

    • PlayerRoster

      public PlayerRoster()
  • Method Details

    • removeFrom

      public void removeFrom(Buildable parent)
      Description copied from class: AbstractToolbarItem
      Remove from our parent
      Specified by:
      removeFrom in interface Configurable
      Overrides:
      removeFrom in class AbstractToolbarItem
      Parameters:
      parent - parent
    • remove

      public void remove(Buildable child)
      Description copied from class: AbstractConfigurable
      Remove a Buildable object from this object
      Specified by:
      remove in interface Configurable
      Overrides:
      remove in class AbstractConfigurable
    • build

      public void build(Element e)
      Description copied from class: AbstractBuildable
      Build this component by getting all XML attributes of the XML element and calling AbstractBuildable.setAttribute(String, Object) with the String value of the attribute
      Specified by:
      build in interface Buildable
      Overrides:
      build in class AbstractBuildable
      Parameters:
      e - the XML element containing the object data
    • getConfigureName

      public String getConfigureName()
      Description copied from class: AbstractConfigurable
      ConfigureName is used, in particular, by the Editor to track the names of components, and is preferred by UniqueIdManager.
      Specified by:
      getConfigureName in interface Configurable
      Overrides:
      getConfigureName in class AbstractConfigurable
      Returns:
      The language-independent name of this component used for programmatic identification (including within Modules by e.g. Traits and module components)
    • getConfigureTypeName

      public static String getConfigureTypeName()
    • add

      public void add(Buildable child)
      Description copied from class: AbstractConfigurable
      Set the owning translatable of this component
      Specified by:
      add in interface Buildable
      Overrides:
      add in class AbstractConfigurable
      Parameters:
      child - Child to attach to this buildable as a subcomponent
    • getConfigureComponents

      public Configurable[] getConfigureComponents()
      Specified by:
      getConfigureComponents in interface Configurable
      Overrides:
      getConfigureComponents in class AbstractConfigurable
      Returns:
      A list of all child components (i.e. subcomponents) of this component that are configurable.
    • getBuildElement

      public Element getBuildElement(Document doc)
      Specified by:
      getBuildElement in interface Buildable
      Overrides:
      getBuildElement in class AbstractBuildable
      Parameters:
      doc - XML file
      Returns:
      an XML element from which this component can be built
    • addPropertyChangeListener

      public void addPropertyChangeListener(PropertyChangeListener l)
      Description copied from interface: Configurable
      Add a PropertyChangeListener. A PropertyChangeEvent should be fired with property name Configurable.NAME_PROPERTY when the value returned from Configurable.getConfigureName() has changed
      Specified by:
      addPropertyChangeListener in interface Configurable
      Overrides:
      addPropertyChangeListener in class AbstractConfigurable
    • addSideChangeListenerToInstance

      public void addSideChangeListenerToInstance(PlayerRoster.SideChangeListener l)
    • removeSideChangeListenerFromInstance

      public void removeSideChangeListenerFromInstance(PlayerRoster.SideChangeListener l)
    • getHelpFile

      public HelpFile getHelpFile()
      Specified by:
      getHelpFile in interface Configurable
      Returns:
      a HelpFile describing how to use and configure * this component
    • 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.
    • addTo

      public void addTo(Buildable b)
      Description copied from class: AbstractToolbarItem
      Default behavior adds the button to the parent component
      Specified by:
      addTo in interface Buildable
      Overrides:
      addTo in class AbstractToolbarItem
      Parameters:
      b - parent Buildable to add this component to as a subcomponent.
    • launch

      protected void launch()
      Called when the Launch Button for the player roster is clicked (i.e. the "Retire" or "Change Sides" button)
    • fireSideChange

      protected void fireSideChange(String oldSide, String newSide)
    • isActive

      public static boolean isActive()
    • getInstance

      @Deprecated(since="2021-12-01", forRemoval=true) protected static PlayerRoster getInstance()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getMySide

      public static String getMySide()
      Return my Untranslated side
    • getMyLocalizedSide

      public static String getMyLocalizedSide()
      Return my Translated Side
    • getCurrentPasswords

      protected static List<String> getCurrentPasswords()
      Returns:
      List of currently matchable passwords, including "defaults" of various types.
    • getMySide

      protected static String getMySide(boolean localized)
    • getPlayers

      public PlayerRoster.PlayerInfo[] getPlayers()
    • getSides

      public List<String> getSides()
    • getUntranslatedSideList

      public List<String> getUntranslatedSideList()
    • getUntranslatedSides

      public String[] getUntranslatedSides()
    • add

      public void add(String playerId, String playerName, String side)
      Adds a player to the list of active players occupying sides
      Parameters:
      playerId - player unique id (password)
      playerName - player name
      side - player side
    • remove

      public void remove(String playerId)
      Remove a player from the list of active players occupying sides
      Parameters:
      playerId - player unique id (password)
    • decode

      public Command decode(String command)
      Description copied from interface: CommandEncoder
      Translate a String into a Command
      Specified by:
      decode in interface CommandEncoder
    • encode

      public String encode(Command c)
      Description copied from interface: CommandEncoder
      Translate a Command into a String
      Specified by:
      encode in interface CommandEncoder
    • 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
      Overrides:
      getRestoreCommand in class AbstractToolbarItem
    • 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
      Overrides:
      setup in class AbstractToolbarItem
      Parameters:
      gameStarting - if true, a game is starting. If false, then a game is ending
    • finish

      public void finish()
      finish() step for Wizard
      Specified by:
      finish in interface GameSetupStep
    • reset

      public void reset()
      Called when a Game Start wizard has been cancelled. Record that the next call from the Wizard will be from a completelty new Wizard
    • getControls

      public Component getControls()
      Description copied from interface: GameSetupStep
      A GUI component that prompts the player for the needed information. If null, then no further information is needed
      Specified by:
      getControls in interface GameSetupStep
    • getStepTitle

      public String getStepTitle()
      Description copied from interface: GameSetupStep
      A human-understandable description of this step
      Specified by:
      getStepTitle in interface GameSetupStep
      Returns:
      step title for Wizard's GameSetupStep
    • validatePassword

      public void validatePassword()
    • setController

      public void setController(org.netbeans.spi.wizard.WizardController wc)
      Description copied from interface: GameSetupStep
      Tells the step who its wizard controller is
      Specified by:
      setController in interface GameSetupStep
    • setForcePwd

      public void setForcePwd(boolean forcePwd)
    • isFinished

      public boolean isFinished()
      Implement GameSetupStep for Wizard
      Specified by:
      isFinished in interface GameSetupStep
      Returns:
      true if Wizard GameSetupStep is finished
    • allSidesAllocated

      protected boolean allSidesAllocated()
      Returns:
      true if all sides have been claimed by a player
    • isTranslatedSoloSide

      public static boolean isTranslatedSoloSide(String side)
      Parameters:
      side - Name of a side to see if it's a "solo side"
      Returns:
      True if the side is "Solitaire", "Solo", "Moderator", or "Referee"
    • isSoloSide

      public static boolean isSoloSide(String side)
    • isMultiPlayer

      public boolean isMultiPlayer()
      Returns:
      True if this is currently a multiPlayer game (either connected to a server, or more than one player side allocated)
    • claimSlot

      protected void claimSlot(int index)
      Claims an existing slot for the current player, and sets our temporary user id appropriately
      Parameters:
      index - The index of the slot to be claimed in the roster
    • claimOccupiedSide

      protected void claimOccupiedSide()
      Claims the appropriate occupied side, if any, for the current player. If more than one is available, prompts.
    • getAvailableSides

      public List<String> getAvailableSides()
    • promptForSide

      protected String promptForSide()
    • promptForSide

      protected String promptForSide(String newSide)
    • getAttributeNames

      public String[] getAttributeNames()
      Description copied from class: AbstractToolbarItem
      This getAttributeNames() will return the items specific to the Toolbar Button - classes extending this should add their own items as well. If the "nameKey" is blank, then no "name" configure entry will be generated. Extending classes can use ArrayUtils.addAll(super.getAttributeNames(), key1, ..., keyN), or supply their own order from scratch.

      Lists all the buildFile (XML) attribute names for this component. If this component is ALSO an AbstractConfigurable, then this list of attributes determines the appropriate attribute order for AbstractConfigurable.getAttributeDescriptions() and AbstractConfigurable.getAttributeTypes().

      Specified by:
      getAttributeNames in interface AutoConfigurable
      Overrides:
      getAttributeNames in class AbstractToolbarItem
      Returns:
      an array of all buildFile (XML) attribute names for this component
    • getAttributeTypes

      public Class<?>[] getAttributeTypes()
      Description copied from class: AbstractToolbarItem
      This getAttributeTypes() will return the items specific to the Toolbar Button - classes extending this should add their own items as well. If the "nameKey" is blank, then no "name" configure entry will be generated. Extending classes can use ArrayUtils.addAll(super.getAttributeTypes(), key1, ..., keyN), or supply their own order from scratch.
      Specified by:
      getAttributeTypes in interface AutoConfigurable
      Overrides:
      getAttributeTypes in class AbstractToolbarItem
      Returns:
      the Class for the buildFile (XML) attributes of this component. Valid classes include: String, Integer, Double, Boolean, Image, Color, and KeyStroke, along with any class for which a Configurer exists in VASSAL.configure. The class determines, among other things, which type of AutoConfigurer will be used to configure the attribute when the object is configured in the Editor.

      The order of classes should be the same as the order of names in AbstractBuildable.getAttributeNames()

    • getAttributeValueString

      public String getAttributeValueString(String key)
      Description copied from class: AbstractToolbarItem
      Classes extending AbstractToolbarItem can call this as a super() method after checking for their own keys, to avoid needing to deal with the nitty gritty of the toolbar button.
      Specified by:
      getAttributeValueString in interface AutoConfigurable
      Specified by:
      getAttributeValueString in interface Translatable
      Overrides:
      getAttributeValueString in class AbstractToolbarItem
      Parameters:
      key - the name of the attribute. Will be one of those listed in AbstractToolbarItem.getAttributeNames()
      Returns:
      a String representation of the XML buildFile attribute with the given name. When initializing a module, this String value will loaded from the XML and passed to AbstractToolbarItem.setAttribute(String, Object). It is also frequently used for checking the current value of an attribute.
    • setAttribute

      public void setAttribute(String key, Object value)
      Description copied from class: AbstractToolbarItem
      Classes extending AbstractToolbarItem can call this as a super() method after checking for their own keys, to avoid needing to deal with the nitty gritty of the toolbar button.

      Sets a buildFile (XML) attribute value for this component. The key parameter will be one of those listed in AbstractToolbarItem.getAttributeNames(). If the value parameter is a String, it will be the value returned by AbstractToolbarItem.getAttributeValueString(String) for the same key. If the implementing class extends AbstractConfigurable, then value will be an instance of the corresponding Class listed in AbstractConfigurable.getAttributeTypes()

      Specified by:
      setAttribute in interface AutoConfigurable
      Specified by:
      setAttribute in interface Translatable
      Overrides:
      setAttribute in class AbstractToolbarItem
      Parameters:
      key - the name of the attribute. Will be one of those listed in AbstractToolbarItem.getAttributeNames()
      value - If the value parameter is a String, it will be the value returned by AbstractToolbarItem.getAttributeValueString(String) for the same key. If the implementing class extends AbstractConfigurable, then value can also be an instance of the corresponding Class listed in AbstractConfigurable.getAttributeTypes()
    • getSidesAsString

      protected String getSidesAsString()
    • setSidesFromString

      protected void setSidesFromString(String newSides)
      Set a new set of side names from a translation DO NOT apply if the number of sides does not match the number of currently defined sides as there is no way to tell which translation applies to which existing side
      Parameters:
      newSides - Comma delimited string of translated sides
    • untranslateSide

      public String untranslateSide(String side)
    • translateSide

      public String translateSide(String side)
    • getAttributeDescriptions

      public String[] getAttributeDescriptions()
      Description copied from class: AbstractToolbarItem
      This getAttributeDescriptions() will return the items specific to the Toolbar Button - classes extending this should add their own items as well. If the "nameKey" is blank, then no "name" configure entry will be generated. Extending classes can use ArrayUtils.addAll(super.getAttributeDescriptions(), key1, ..., keyN), or supply their own order from scratch.
      Specified by:
      getAttributeDescriptions in interface AutoConfigurable
      Overrides:
      getAttributeDescriptions in class AbstractToolbarItem
      Returns:
      an array of Strings describing the buildFile (XML) attributes of this component. These strings are used as prompts in the Properties window for this object, when the component is configured in the Editor. The order of descriptions should be the same as the order of names in AbstractBuildable.getAttributeNames()
    • getDescription

      public String getDescription()
      Specified by:
      getDescription in interface ComponentDescription
      Returns:
      Description to be displayed next to component type/name in the main Editor window. Or null or "" to not display anything.
    • getPropertyList

      public List<String> getPropertyList()
      Specified by:
      getPropertyList in interface SearchTarget
      Overrides:
      getPropertyList in class AbstractToolbarItem
      Returns:
      a list of any Property Names referenced in the Configurable, if any (for search)
    • getI18nData

      public ComponentI18nData getI18nData()
      Specified by:
      getI18nData in interface Translatable
      Overrides:
      getI18nData in class AbstractConfigurable
      Returns:
      the i18n data for this component
    • isMandatory

      public boolean isMandatory()
      Description copied from interface: Buildable
      Is this component a reqired component within its parent?
      Specified by:
      isMandatory in interface Buildable
      Returns:
      true if component is mandatory
    • isUnique

      public boolean isUnique()
      Description copied from interface: Buildable
      Does this component need to be unique within it's parent?
      Specified by:
      isUnique in interface Buildable
      Returns: