simple-hacker/phpoker 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

simple-hacker/phpoker

Composer 安装命令:

composer require simple-hacker/phpoker

包简介

PHP library package for No Limit Texas Holdem poker

README 文档

README

PHP library package for No Limit Texas Holdem poker. This package allows you to find the best Texas Holdem hand out of the given Cards.

Installation

Require the package using composer

composer require simple-hacker/phpoker

Usage

use simplehacker\PHPoker\Hands\TexasHoldemHand;

$communityCards = '3hJdQdAdKd';
$holeCards = 'Td6s';

$hand = new TexasHoldemHand($communityCards, $holeCards);

The Cards as a string of short values, or an array of short values and/or Card instances.

The following results at the same:

$communityCards = '3hJdQdAdKd';
$communityCards = ['3h', 'Jd', 'Qd', 'Ad', 'Kd'];
$communityCards = [new Card('3h'), new Card('Jd'), new Card('Qd'), new Card('Ad'), new Card('Kd')];
$communityCards = [new Card('3h'), 'Jd', new Card('Qd'), 'Ad', new Card('Kd')];  // A mix of both

Once a hand has been instantiated, you are able to get the hand description as well as a numerical value of the hand used for comparing against other hands.

use simplehacker\PHPoker\Hands\TexasHoldemHand;

$communityCards = '3hJdQdAdKd';
$holeCards = 'Td6s';

$hand = new TexasHoldemHand($communityCards, $holeCards);

// Royal Flush, Ace to Ten of Diamonds
$hand->getDescription();

// AdKdQdJdTd
$hand->getShortDescription();

// 10
$hand->getHandRank();

// const ROYAL_FLUSH_RANK      = 10;
// const STRAIGHT_FLUSH_RANK   = 9;
// const FOUR_OF_A_KIND_RANK   = 8;
// const FULL_HOUSE_RANK       = 7;
// const FLUSH_RANK            = 6;
// const STRAIGHT_RANK         = 5;
// const THREE_OF_A_KIND_RANK  = 4;
// const TWO_PAIR_RANK         = 3;
// const ONE_PAIR_RANK         = 2;
// const HIGH_CARD_RANK        = 1;

// 11459770
$hand->getHandValue();

// Hand value is generated from converting Hand Rank and all Card values to a binary string, and converting back to base 10.  This ensures the best hand will always be the highest number

Cards

Cards can be instantiated in numerous ways. The following all result in the Ace of Spades:

// As a short value where the first character is card value 23456789TJQKA,
// and the second character is card suit as shcd
new Card('As');

// Arguments for both value and suit
new Card('Ace', 'Spades');
new Card('A', 's');

// As numerical values
// Jack = 11, Queen = 12, King = 13, Ace = 1 or 14
// Clubs = 1, Diamonds = 2, Hearts = 3, Spades = 4
new Card(14, 4);

// Or any combination of the above
new Card('Ace', 's');
new Card(1, 'spades');

A InvalidCardException will be thrown for invalid values or suits

Upcoming releases

  • Compare TexasHoldemHands to determine winner
  • Other poker variants such as Omaha, Short Deck, Razz, Stud etc

Disclaimer

I am not responsible for any money won or loss as a result of any mistakes made in this package. This was created as a learning exercise so use this package at your own risk.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

simple-hacker/phpoker 适用场景与选型建议

simple-hacker/phpoker 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17 次下载、GitHub Stars 达 2, 最近一次更新时间为 2020 年 11 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 simple-hacker/phpoker 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 simple-hacker/phpoker 我们能提供哪些服务?
定制开发 / 二次开发

基于 simple-hacker/phpoker 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 17
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 9
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-11-26