Giter VIP home page Giter VIP logo

cards's Introduction

Cards

The cards package extends the gamebetr/provable package to provide a provably fair way to shuffle and utilize decks of cards.

Installation

composer require gamebetr/cards ^1.0

Gamebetr\Cards\Deck Object

Initialization

$deck = new Gamebetr\Cards\Deck();

or

$deck = Gamebetr\Cards\Deck::init();

Deck Methods

__construct(string $clientSeed = null, string $serverSeed = null, int $deckCount = 1, bool $jokers = false)

$clientSeed - This is the client seed used to generate the provably fair shuffle. The default value of null will cause the Provable class to auto generate a client seed.

$serverSeed - This is the server seed used to generate the provably fair shuffle. The default value of null will cause the Provable class to auto generate a server seed.

$deckCount - This is the amount of card decks to use. The default is 1.

$jokers - This parameter determines whether jokers will be included in the deck. The default is false.

init(string $clientSeed = null, string $serverSeed = null, int $deckCount = 1, bool $jokers = false) : Gamebetr\Cards\Deck

This method is just a static constructor to make it cleaner when instanciating the Deck class. This will return a Deck class.

getProvable() : Gamebetr\Provable\Provable

This method will return the Gamebetr\Provable\Provable instance used to shuffle the deck.

deal() : Gamebetr\Cards\Card

This method will return the top Gamebetr\Cards\Card in the deck.

burn()

This method will burn the top card in the deck.

getCards() : array

This method will return the full, original shuffled values of the deck. The values in this array are the numeric values used to create the Gamebetr\Cards\Card objects.

getRemainingCards() : array

This method will return an array of all remaining Gamebetr\Cards\Card in the deck.

getDealtCards() : array

This method will return an array of all of the dealt Gamebetr\Cards\Card in the deck.

getBurntCards() : array

This method will return an array of all of the burnt Gamebetr\Cards\Card in the deck.

Card Methods

__construct(int $value)

$value - This is the value of the card.

init(int $value) : Card

This method is just a static constructor for the Card object. This will return a Card class.

isJoker() : bool

This method will return true of the Card is a joker.

suit() : int

This method will return an integer representation of the card suit. 0 = clubs, 1 = diamonds, 2 = hearts, 3 = spades.

suitName() : string

This method will return the name of the card suit.

rank() : int

This method will return an integer representation of the card rank. -1 = joker, 0 = 2, 1 = 3, 2 = 4, 3 = 5, 4 = 6, 5 = 7, 6 = 8, 7 = 9, 8 = 10, 9 = jack, 10 = queen, 11 = king, 12 = ace.

rankName() : string

This method will return the name of the card rank.

value() : int

This method will return the integer value for the card. joker = 0, 2-9 = the face value, 10-king = 10, ace = 11.

name() : string

This method is an alias of rankName().

fullName() : string

This method returns the full name of the card (e.g. two of diamonds).

greaterThan(Gamebetr\Cards\Card $card, bool $useSuitValue = false)

This method will compare the card against a different card and return true if the current card is of greater value. By specifying true for the $useSuitValue, it will rank two matching cards by suit.

lessThan(Gamebetr\Cards\Card $card, bool $useSuitValue = false)

This method will compare the card against a different card and return true if the current card is of lesser value. By specifying true for the $useSuitValue, it will rank two matching cards by suit.

equalTo(Gamebetr\Cards\Card $card, bool $useSuitValue = false)

This method will compare the card against a different card and return true if the current card is of the same value. By specifying true for the $useSuitValue, it will rank two matching cards by suit.

compare(Gamebetr\Cards\Card $card, bool $useSuitValue = false)

This method will compare the card against a different card and return -1 if the card is of lesser value, 0 if the cards have the same value, and 1 if the card is of greater value. By specifying true for the $useSuitValue, it will rank two matching cards by suit.

__toString()

This method is an alias of getName().

cards's People

Contributors

gamebetr avatar submtd avatar swichers avatar

Watchers

 avatar  avatar

Forkers

swichers

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.