Class PlayerNodes
java.lang.Object
org.xxdc.oss.example.PlayerNodes
- All Implemented Interfaces:
Serializable
Represents a collection of
PlayerNode instances, providing methods to manage and render
the players.
The PlayerNodes class maintains a SequencedMap of PlayerNode
instances, indexed by their unique player marker. It also maintains a list of the player markers
in the order they were added.
The class provides methods to retrieve players by index, get the next player index, render the
player information, and close any AutoCloseable players.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newPlayerNodesinstance with an initial capacity of 2 for both the player map and the player marker list. -
Method Summary
Modifier and TypeMethodDescriptionbyIndex(int index) Returns thePlayerNodeinstance at the specified index in the ordered list of players.voidclose()intnextPlayerIndex(int index) Returns the index of the next player in the ordered list of players.static PlayerNodesof(PlayerNode... players) Creates a newPlayerNodesinstance and adds the providedPlayerNodeinstances to it.Returns a list of all the player markers in the PlayerNodes instance.Returns a comma-separated string of all the player markers in the PlayerNodes instance.voidrender()Renders a list of players, logging their player identifiers.
-
Constructor Details
-
PlayerNodes
public PlayerNodes()Constructs a newPlayerNodesinstance with an initial capacity of 2 for both the player map and the player marker list.
-
-
Method Details
-
of
Creates a newPlayerNodesinstance and adds the providedPlayerNodeinstances to it.- Parameters:
players- thePlayerNodeinstances to add to the newPlayerNodesinstance- Returns:
- a new
PlayerNodesinstance containing the providedPlayerNodeinstances
-
byIndex
Returns thePlayerNodeinstance at the specified index in the ordered list of players.- Parameters:
index- the index of the player to retrieve- Returns:
- the
PlayerNodeinstance at the specified index
-
nextPlayerIndex
public int nextPlayerIndex(int index) Returns the index of the next player in the ordered list of players. If the current index is the last player, it returns 0 to wrap around to the first player.- Parameters:
index- the current index of the player- Returns:
- the index of the next player in the ordered list
-
render
public void render()Renders a list of players, logging their player identifiers. This method is used to display information about the players in the PlayerNodes instance. -
playerMarkers
Returns a comma-separated string of all the player markers in the PlayerNodes instance.- Returns:
- a string containing all the player markers
-
playerMarkerList
-
close
public void close()
-