PlayerState Class

Represents the resources and progress of a single Player.
  • His current score.
  • Tetrominos he has.
  • Puzzles he is working on.
  • Puzzles he has completed.

Definition

Namespace: ProjectLCore.GameLogic
Assembly: ProjectLCore (in ProjectLCore.dll) Version: 1.0.0+d0f5e2a7a5f4bb0431970f279d2f79d24b15d256
C#
public class PlayerState : ITetrominoCollectionNotifier, 
	IComparable<PlayerState>, IEquatable<PlayerState>
Inheritance
Object    PlayerState
Implements
ITetrominoCollectionNotifier, IComparablePlayerState, IEquatablePlayerState

Constructors

PlayerState Initializes a new instance of the PlayerState class.

Properties

PlayerId Unique identifier of the player.
Score Current score of the player.

Methods

AddListener(IPlayerStatePuzzleFinishedAsyncListener) Subscribes the puzzle listener to this PlayerState.
AddListener(IPlayerStatePuzzleListener) Subscribes the puzzle listener to the events of this PlayerState.
AddListener(ITetrominoCollectionListener) Subscribes the tetromino listener to the events of this PlayerState.
AddTetromino Adds the given tetromino to the player's personal collection. Also calls the OnTetrominoCollectionChanged(TetrominoShape, Int32) method of all listeners.
CompareTo

Compares THIS instance with another PlayerState and returns an integer that indicates whether THIS instance precedes, follows, or occurs in the same position in the final scoring order as the other player. This is used for determining the order of players in the leaderboard. Meaning that if A<B then A is in a better position than B.

The player with the highest score wins.

  • In case of a tie, the player who has completed the most puzzles wins.
  • In case of a tie, the player with the most leftover tetrominos wins.
  • If there is still a tie, the payers are placed at the same position.
Equals(Object) Determines whether the specified object is equal to the current PlayerState.
(Overrides ObjectEquals(Object))
Equals(PlayerState) Indicates whether the current PlayerState is equal to another PlayerState of the same type.
FinishPuzzle Removes the puzzle specified in the FinishedPuzzleInfo from the player's unfinished puzzles and adds it to the list of finished puzzles. Also calls the OnPuzzleFinished(FinishedPuzzleInfo) method of all listeners.
FinishPuzzleAsync Asynchronously calls and awaits the OnPuzzleFinishedAsync(FinishedPuzzleInfo, CancellationToken) of all subscribed listeners. After that, it calls the FinishPuzzle(FinishedPuzzleInfo) method.
GetHashCode Returns a hash code for this instance.
(Overrides ObjectGetHashCode)
GetPlayerInfo Returns a copy of information about the player wrapped in a PlayerStatePlayerInfo object. It prevents modification of the original data.
GetPuzzleWithId Gets the puzzle matching the specified identifier.
GetUnfinishedPuzzles Creates a list of puzzles the player is currently working on.
PlaceNewPuzzle Adds the puzzle to the player's unfinished puzzles. Also calls the OnPuzzleAdded(Puzzle) method of all listeners.
RemoveListener(IPlayerStatePuzzleFinishedAsyncListener) Unsubscribes the puzzle listener from the events of this PlayerState.
RemoveListener(IPlayerStatePuzzleListener) Unsubscribes the puzzle listener from the events of this PlayerState.
RemoveListener(ITetrominoCollectionListener) Unsubscribes the tetromino listener from the events of this PlayerState.
RemoveTetromino Removes the tetromino from the player's personal collection. Also calls the OnTetrominoCollectionChanged(TetrominoShape, Int32) method of all listeners.

Operators

Equality(PlayerState, PlayerState) Implements the operator ==.
GreaterThan(PlayerState, PlayerState) Implements the operator >.
GreaterThanOrEqual(PlayerState, PlayerState) Implements the operator >=.
Inequality(PlayerState, PlayerState) Implements the operator !=.
LessThan(PlayerState, PlayerState) Implements the operator <.
LessThanOrEqual(PlayerState, PlayerState) Implements the operator <=.

Fields

MaxPuzzles The maximum number of puzzles a player can be working on at the same time.

See Also