GameState Class

Represents the current state of the shared resources in the game.
  • The row of available white puzzles.
  • The row of available black puzzles.
  • The tetrominos left in the shared reserve.
  • The decks of white and black puzzles.

Definition

Namespace: ProjectLCore.GameLogic
Assembly: ProjectLCore (in ProjectLCore.dll) Version: 1.0.0+d0f5e2a7a5f4bb0431970f279d2f79d24b15d256
C#
public class GameState : ITetrominoCollectionNotifier
Inheritance
Object    GameState
Implements
ITetrominoCollectionNotifier

Constructors

GameState Initializes a new instance of the GameState class.

Properties

NumBlackPuzzlesLeft The number of puzzles left in the black deck.
NumInitialTetrominos The amount of tetrominos of each shape in the shared reserve at the beginning of the game.
NumWhitePuzzlesLeft The number of puzzles left in the white deck.

Methods

AddListener(IGameStatePuzzleAsyncListener) Subscribes the given tetromino listener to the events of this GameState.
AddListener(IGameStatePuzzleListener) Subscribes the given puzzle listener to the events of this GameState.
AddListener(ITetrominoCollectionListener) Subscribes the given tetromino listener to the events of this GameState.
AddTetromino Adds the tetromino of the given shape to the shared reserve.
CreateFromFileT Initializes a new instance of the GameState class from a file containing puzzles.
CreateFromStreamT Initializes a new instance of the GameState class from a stream containing puzzles.
GetAllPuzzlesInGame Creates a copy of all the puzzles in the game. This includes puzzles which have already been finished. The puzzles are cloned to prevent modification of the original data.
GetAvailableBlackPuzzles Creates a list containing the puzzles in the black row.
GetAvailableWhitePuzzles Creates a list containing the puzzles in the white row.
GetGameInfo Creates a copy of information about the game wrapped in a GameStateGameInfo object. It prevents modification of the original data.
GetNumTetrominosLeft Gets the number of tetrominos of each type left in the shared reserve.
GetPuzzleWithId Finds the puzzle matching the given identifier in one of the rows.
PutPuzzleToTheBottomOfDeck Puts the puzzle to the bottom of the deck it belongs to.
RefillPuzzles Refills the blank spots in the puzzle rows with puzzles from the decks.
RefillPuzzlesAsync Refills the blank spots in the puzzle rows with puzzles from the decks. Before a puzzle is refilled, the OnPuzzleRefilledAsync(Int32, CancellationToken) method of all subscribed listeners is called and awaited.
RemoveListener(IGameStatePuzzleAsyncListener) Unsubscribes the tetromino listener from the events of this GameState.
RemoveListener(IGameStatePuzzleListener) Unsubscribes the puzzle listener from the events of this GameState.
RemoveListener(ITetrominoCollectionListener) Unsubscribes the tetromino listener from the events of this GameState.
RemovePuzzleWithId Removes the puzzle matching the given identifier from one of the rows, if it is present.
RemoveTetromino Removes the tetromino of the given shape from the shared reserve.
TakeTopBlackPuzzle Removes 1 puzzle from the top of the black deck and returns it.
TakeTopWhitePuzzle Removes 1 puzzle from the top of the white deck and returns it.

Fields

MinNumInitialTetrominos The minimum number initial tetrominos of each shape in the shared reserve at the beginning of the game.
NumPuzzlesInRow The number puzzles in a row.

See Also