gamebetr/provable
Composer 安装命令:
composer require gamebetr/provable
包简介
Package that provides the ability to create provably fair numbers and shuffles
README 文档
README
This package provides the means to create provibly fair random numbers and provably fair random shuffles.
Installation
via composer:
composer require dbd-net/provable ^1.0
Basic Useage
// set some vars $clientSeed = 'your client seed here'; $serverSeed = 'your server seed here'; $min = 1; $max = 52; $type = 'shuffle'; // instanciate the provable class $provable = new Gamebetr\Provable\Provable($clientSeed, $serverSeed, $min, $max, $type); // get the results print $provable->results(); // prints [6,21,19,13,41,28,40,43,2,39,5,24,18,52,46,26,20,7,29,38,23,37,30,31,33,44,22,16,35,48,25,14,45,27,11,8,17,36,51,4,42,15,49,32,3,9,1,47,10,34,50,12]
Methods
__construct(string $clientSeed = null, string $serverSeed = null, int $min = 0, int $max = 0, string $type = 'number')
The class constructor takes the optional parameters, clientSeed, serverSeed, min, max, and type. If clientSeed or serverSeed are not provided, it will generate random seeds automatically. The min and max parameters are the minimum and maximum values of the random number or shuffle. Type is either number or shuffle.
static init(string $clientSeed = null, string $serverSeed = null, int $min = 0, int $max = 0, string $type = 'number')
The init method is just a static constructor. It allows you to do the following:
$provable = Gamebetr\Provable::init()
// returns an instance of Gamebetr\Provable
setClientSeed(string $clientSeed = null)
This sets the client seed. If no seed is provided, one will be automatically generated. The Provable instance is returned allowing you to chain commands.
getClientSeed()
This returns the current client seed.
setServerSeed(string $serverSeed = null)
This sets the server seed. If no seed is provided, one will be automatically generated. The Provable instance is returned allowing you to chain commands.
getServerSeed()
This returns the current server seed.
getHashedServerSeed()
This returns the hashed version of the server seed.
setMin(int $min)
This sets the minimum value property. The Provable instance is returned allowing you to chain commands.
getMin()
This returns the current minimum value property.
setMax(int $max)
This sets the maximum value property. The Provable instance is returned allowing you to chain commands.
getMax()
This returns the current maximum value property.
setType(string $type)
This sets the type property. Allowed values are number and shuffle. The Provable instance is returned allowing you to chain commands.
getType()
This returns the current type property.
results()
This calculates the random number or shuffle and returns it.
number(int $minimumNumber = null, int $maximumNumber = null)
This generates a random number between $minimumNumber and $maximumNumber. If no values are provided, it will use the $min and $max properties of the object.
shuffle(int $minimumNumber = null, int $maximumNumber = null)
This generates a random shuffle of numbers between $minimumNumber and $maximumNumber. If no values are provided, it will use the $min and $max properties of the object.
gamebetr/provable 适用场景与选型建议
gamebetr/provable 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 346 次下载、GitHub Stars 达 9, 最近一次更新时间为 2019 年 09 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 gamebetr/provable 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gamebetr/provable 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 346
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 2
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2019-09-16