atsmacode/poker-game 问题修复 & 功能扩展

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

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

atsmacode/poker-game

最新稳定版本:v4.0.6

Composer 安装命令:

composer create-project atsmacode/poker-game

包简介

A PHP Based Poker Game

README 文档

README

A database driven package that provides logic to drive a basic Texas Hold-Em poker game.

It can be pulled in via composer to be used within a parent front-end package, but could also be used within an independent container as an API.

A brief description of how it works is:

  • The SitController starts a new Hand
  • The PlayerActionController accept a Request containing information on which Hand is being played, and what the last thing to happen was (who was the last to act and what action did they take)
  • This data is passed to the ActionHandler which updates the status of all players accordingly and returns a GameState object containing all the information of the current Hand
  • The GameState is passed to a GamePlay class which decides what should happen next in the Hand
  • Depending on what the next step is, the logic is delegated to respective HandStep interfaces which carry out the appropriate process for each thing:
    • The players are still betting on a street
    • A new street card should be dealt
    • All bets have been called on the river and we have reached showdown
    • A new Hand should be started
  • If we have reached showdown, the Showdown class decides the winner by calling the HandIdentifier which identifies and ranks each hand the players have based on the ranking of active cards (a King would be the active card in a pair of Kings hand, for example) and kickers
  • The updated GameState is returned

It is by no means a finished poker game. Here are some of the things it does not yet do:

  • Split and side pots
  • All-ins
  • No-limit betting
  • Game winners/losers as opposed to Hand winners/losers
  • Incrementing blinds and antes

The testing is primarily based on Feature tests where I've set-up a range of scenarios.

Documentation

I've saved some examples of how I plan and map out changes using Lucid Charts:

Improvments

Planning

Environment

PHP

8.1.3

MySQL

8.0.13

Commands

Linux

Build the test DB:

dev/builddb

Run the unit test suite:

dev/phpunit

Individual Drop, Create and Seed commands. Remove '-d true' for prodution:

php dev/PokerGameApp.php app:create-database -d true

php dev/PokerGameApp.php app:build-card-games -d true

php dev/PokerGameApp.php app:build-poker-game -d true

Windows

Drop, Create and Seed all tables:

.\dev\builddb.bat

Run the unit test suite:

.\dev\runtests.bat

Individual Drop, Create and Seed commands. Remove '-d true' for prodution:

php .\dev\PokerGameApp.php app:create-database -d true

php .\dev\PokerGameApp.php app:build-card-games -d true

php .\dev\PokerGameApp.php app:build-poker-game -d true

Laragon

Using Laragon, the following example path to run PHP might be useful:

C:\laragon\bin\php\php-8.1.3-nts-Win32-vs16-x64/php

Configs

You need to add poker_game.php to configure your local DB credentials and log path, like so:

<?php

return [
    'poker_game' => [
        'db' => [
            'live' => [
                'servername' => 'localhost',
                'username'   => 'DB_USER',
                'password'   => 'DB_PASSWORD',
                'database'   => 'poker_game',
                'driver'     => 'pdo_mysql',
            ],
            'test' => [
                'servername' => 'localhost',
                'username'   => 'DB_USER',
                'password'   => 'DB_PASSWORD',
                'database'   => 'poker_game_test',
                'driver'     => 'pdo_mysql',
            ],
        ],
        'logger' => [
            'path' => '/your/log/file'
        ]
    ],
];

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2022-11-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固