ethtezahl / dice-roller
桌面角色扮演游戏掷骰子模拟
0.1.3
2017-07-13 16:12 UTC
Requires
- php: >=7.0
Requires (Dev)
- phpunit/phpunit: ^6.2
This package is not auto-updated.
Last update: 2024-09-21 15:48:24 UTC
README
概念。
我想编写一个程序来为桌面角色扮演游戏“克苏鲁的呼唤”中的预组角色生成统计数据。我需要一个能够模拟和给出多个骰子(有时是不同面数)掷骰结果的库。因此,我创建了这个库,以进行这些掷骰。
安装
composer require ethtezahl/dice-roller
基本用法
上面的代码将模拟掷两个六面的骰子
// First: import needed class use Ethtezahl\DiceRoller\CupFactory; // Factory allow us to create dice cup. $factory = new CupFactory(); // We create the cup that will contain the two die: $cup = $factory->newInstance('2D6'); // Display the result: echo $cup->roll();
高级用法:使用多种类型的骰子
想象你需要掷三个二十面的骰子和一个四面骰子
$cup = $factory->newInstance('3D20+D4');