@Cards-TS
    Preparing search index...

    Module @cards-ts/core

    @cards-ts/core

    GitHub Latest Commit Documentation

    This is a card game framework written in Typescript. This package contains the framework and useful components, including functionality to display a card game in the command line.

    Implementations of a card game must share a certain set of exports to be able to be run, see Hearts for an up-to-date example.

    Contributions of games to the library are welcome on the Github.

    We use SemVer for versioning. For the versions available, see the tags on this repository.

    See also the list of contributors who participated in this project.

    Controller

    A controller is a class extending AbstractController that is initialized at state load time that wraps a slice of the state and has complete control over that state. For example, the HandsController has control over the cards found in each player's hand. Controllers can also define dependencies on other controllers, as the DeckController does for the HandsController, which allows them to have more advanced or sophisticated functionality that helps to reduce verbosity in the game transitions for shared functionality (e.g. dealing out cards to hands). Controllers are responsible for modifying (through user defined functions) and validating their underlying state and transforming it for the handlers (i.e. hiding data that isn't to be known).

    AbstractController

    Parent class of controllers, which own a slice of state

    AbstractHandsController

    Handles state for players' hands Has children classes that allow for hiding and showing the hands to handlers

    BetsController

    Stores bets for players

    CompletedController

    Stores whether the game has ended

    DataController

    Controls the data for the handlers

    DeckController

    Controls a deck for the game

    GameStateController

    Keeps track of the state of the game

    GenericHandlerController

    Allows for controlling the handlers

    GlobalController

    Subclass of abstract controller that shows the state for all handlers

    HandsController

    Handles state for players' hands and shows it to handlers

    HiddenHandsController

    Handles state for players' hands but keeps it hidden from handlers

    MeldController

    Handles the state for meld type games

    NamesController

    Holds the names for the players

    ParamsController

    Handles the params for a game

    PointsController

    Handles scores for players

    StatelessController

    Subclass of abstract controller for a controller with no state

    TricksController

    Handles state for trick based games

    TurnController

    Controls state around whose turn it is for something

    WaitingController

    Controls state around who the game is currently waiting for

    IndexedControllers

    Controllers indexed by a string

    ControllerHandlerState

    Gets the handler state of controllers

    ControllersProviders

    Gets the providers that would produce controllers

    UnwrapProviders

    Gets the associated controllers out of providers

    ValidatedProviders

    The providers that will exist once the dependency tree is run (assuming no loops) by removing items whose dependencies cannot be fulfilled

    Controller Provider

    Every controller has an associated provider which defines the dependent controllers and handles the initialization of the state and construction of the controller object.

    BetsControllerProvider
    CompletedControllerProvider
    DataControllerProvider
    DeckControllerProvider
    GameStateControllerProvider
    GenericHandlerControllerProvider

    Provides the handlers controller

    HandsControllerProvider
    HiddenHandsControllerProvider
    MeldControllerProvider
    NamesControllerProvider
    ParamsControllerProvider
    PointsControllerProvider
    TricksControllerProvider
    TurnControllerProvider
    WaitingControllerProvider
    GenericControllerProvider

    Provides a controller

    IndexedProviders

    Controller providers indexed by a string

    Core

    Card

    Class to represent cards in a deck

    Deck

    Class representing N standard 54 card decks' draw and discard pile, tracking the top card

    FourCardRun

    A class representing a run (or straight flush) of at least four cards being in sequential order and of the same suit, potentially containing wilds

    Meld

    Parent class for three card sets and four card runs

    Rank

    A class for the rank of a card like 'TWO' or 'KING'

    Suit

    Class / Enum representing the possible suits in a deck

    ThreeCardSet

    A class representing a three (or more) of a kind

    Game Builder

    Allows for implementing a new game type.

    See Creating a New Game

    EventHandler

    A set of utility functions that are helpful when writing event handlers

    GameDriver

    Class that steps though the game using the game state transitions

    GenericGameState

    A class used to track the current state of the game

    GenericHandlerProxy

    Class that allows calls to the handlers

    EventHandlerInterface

    Class for validating and merging incoming events

    GenericGameSetup

    Gives a nicer way to setup a game

    DefaultControllerKeys

    The reserved names that the default controllers use

    DefaultControllers

    The type of the default controllers, once initialized from their providers in buildDefaultProviders

    STANDARD_STATES

    Standard states for the state machine with special purposes

    buildEventHandler

    Builds the event handler interface by combining various validators and merger components together

    buildGameFactory

    Wraps the classes in a game library into one common interface to make usages less verbose and to hide internal implementation details

    Handler

    A handler is the interface by which a player (or bot) reacts to various events. There are the SystemHandler events, allowing for reacting to generic status messages and whoever the game is currently waiting on, and also whatever events are defined by the individual games (like prompting for a discard or a bid), which allow the handler to respond with proper response messages that mutate the state. Handler instances are joined in a HandlerChain, which allows for more shared functionality by only implementing a few of all the needed handlers.

    ArrayMessageHandler
    HandlerChain

    A chain of handlers, where the first that can handle an event will handle it

    IntermediarySystemHandler

    Interface to listen for all system events (e.g. message and waiting)

    MessageHandler

    Interface to listen for message events

    SystemHandler

    Interface to listen for all system events (e.g. message and waiting)

    WaitingHandler

    Interface to listen for waiting events

    Handler

    An element that can listen to events and push response messages

    HandlerAction

    Message

    A Message is a serializable element of communication, which takes two flavors: status/game-generated events which inform handlers about what has changed in the game state, as well as response/handler-generated events which tell the game that a handler would like to respond to something (like an opportunity to bid, discard, or play a card). A Presentable should contain a message that can be displayed to an end user, as well as any other data that may be helpful for a bot to process the event without parsing the message.

    Message
    DealerMessage

    Designates that a player is dealer

    DealtOutMessage

    Class that denotes to a handler that they have been dealt or drawn a card

    DiscardMessage

    Class that denotes to a handler that a player has discarded a card

    DiscardResponseMessage

    Designates a card to be discarded

    EndRoundMessage

    Class denoting to handlers that the round has ended

    LeadsMessage

    Class that denotes to a handler that a certain player is leading this round

    Message

    A serializable object designating a change in the game state. A Message is a serializable element of communication, which takes two flavors: status/game-generated events which inform handlers about what has changed in the game state, as well as response/handler-generated events which tell the game that a handler would like to respond to something (like an opportunity to bid, discard, or play a card). A Presentable should contain a message that can be displayed to an end user, as well as any other data that may be helpful for a bot to process the event without parsing the message.

    OutOfCardsMessage

    Designates that a player ran out of cards

    PickupMessage

    A class designating to a handler that anpther player has picked up a card, or that a card was not picked up at all

    PlayCardResponseMessage

    Designates that a card is to be played and optionally data to be set for this player

    PlayedMessage

    A class designating that a player put down cards on the table

    ReshuffleMessage

    A class designating that the deck was reshuffled

    SpacingMessage

    Empty message for adding spacing

    TurnUpMessage

    Class that denotes to a handler that a card was flipped over

    Other

    Intermediary
    IncrementalIntermediary

    Class that presents each display element one at a time

    InquirerPresenter

    Prompts questions to the user using the Inquirer library

    InvalidError

    A class to designate an error

    ProtocolIntermediary

    Sends the messages or forms over a protocol

    Provider

    Class used to lazily provide a value

    ResponseQueue

    A queue that handlers push messages to to return them to the driver. Seamlessly handles async items and sync items.

    ValueError

    A class to designate an error

    HandlerResponsesQueue
    Intermediary

    Class that handles how material is presented to the end user

    Presenter

    Interface describing the different forms of questions that can be posed to the user over a variety of mediums

    Protocol

    Generic interface for a medium that can have messages sent over channels

    ControllerState
    DisplayElement
    GenericGameStateTransitions

    Interface for describing the changes in the state of the game and the effect on the game state

    IntermediaryMapping
    MessageHandlerParams
    Presentable

    Things the library knows how to write out as a human-readable string

    ReadonlySerializable
    Serializable

    Things that the library knows how to serialize and deserialize

    SerializableObject
    SystemHandlerParams
    WaitingHandlerParams
    checkFourCardRunPossible

    Checks whether it is possible to construct a four card run with the given cards

    combinations

    Returns all possible combinations of the provided items

    deserialize

    Deserializes from a string

    distinct

    Function to be used with filter that checks that the current item is not equal to any previous item

    isDefined

    Type guard for making sure a value is not undefined or void

    isPromise

    Type guard for whether a value is a promise (or promise-like)

    reconstruct

    Creates serializable objects out of plain object values

    serialize

    Writes a value to a string

    zip

    Util function allowing for iterating over multiple arrays item by item