gamebetr/cards
Composer 安装命令:
composer require gamebetr/cards
包简介
Extends probable library for card games
README 文档
README
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().
gamebetr/cards 适用场景与选型建议
gamebetr/cards 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 352 次下载、GitHub Stars 达 1, 最近一次更新时间为 2019 年 12 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 gamebetr/cards 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gamebetr/cards 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 352
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2019-12-16