定制 holistic-agency/dice-roll 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

holistic-agency/dice-roll

最新稳定版本:1.0.0

Composer 安装命令:

composer require holistic-agency/dice-roll

包简介

dice roll formula interpreter

关键字:

README 文档

README

One or More Dice to Roll.

Install

composer require holistic-agency/dice-roll:^1.x-dev

Usage

#!/usr/bin/env php
<?php

use HolisticAgency\DiceRoll\DiceFactory;

// signed dice -xDy±z is actually treated as -(xDy±z)
$sub1d4 = DiceFactory::fromFormula('-1D4+1');
echo $sub1d4 . ':' . $sub1d4->roll() . PHP_EOL; // Between -5 and -1, not -3 to 0
#!/usr/bin/env php
<?php

use HolisticAgency\DiceRoll\DiceFactory;

$potionOfHealing = DiceFactory::fromFormula('2D4+2');
echo $potionOfHealing . ':' . $potionOfHealing->roll() . PHP_EOL;

$sneakAttack = DiceFactory::fromFormula('1D8+2+3D6');
echo $sneakAttack . ':' . $sneakAttack->roll() . PHP_EOL;
#!/usr/bin/env php
<?php

use HolisticAgency\DiceRoll\Dice;
use HolisticAgency\DiceRoll\MersenneTwister;

$best3of4 = (new Dice('4D6'))->bestOf(3);
$best3of4->setNumberGenerator(new MersenneTwister());
for ($i = 0; $i < 6; $i++) {
    echo "Roll of $best3of4:" . $best3of4->roll() . PHP_EOL;
}

See other examples

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-10-28