Download the PHP package kusabi/dice without Composer

On this page you can find all versions of the php package kusabi/dice. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package dice

PHP Dice

Tests codecov Licence Badge Release Badge Tag Badge Issues Badge Code Size

A library designed to simulate the table-top dice for games like Dungeons and Dragons.

Compatibility and dependencies

This library is compatible with PHP version 5.6, 7.0, 7.1, 7.2, 7.3 and 7.4.

This library has no dependencies.

Installation

Installation is simple using composer.

Or simply add it to your composer.json file

Using the library

The simplest way to use the library is by using the Dice factory class.

A simple example would be

Using the dice class

This library contains 4 dice implementations that when used together can simulate a huge range of possibilities.

The first class is Dice.

A Dice object can represent most basic rolls in a table-top game.

It takes 3 optional parameters to set the number of sides, the multiplier and the offset.

Without any parameters it will default to represent 1d6.

Using the single dice class

The other three dice classes can be used in combination, to create much more complex dice setups.

The first of these is SingleDice. A SingleDice object takes a single parameter which represents the number of sides it has.

Using the dice modifier class

The DiceModifier class uses the Decorator pattern to augment the results of another implementation of DiceInterface.

It takes two arguments, the first is another object that implements DiceInterface and the second is an integer to augment the result by.

The example below simulates how you might represent 1D12+4.

Using the dice group class

The DiceGroup can cluster multiple implementations of DiceInterface together, and returns the sum of results from all of them.

Because one of those instances can be a Dice, SingleDice, DiceModifier or even another DiceGroup and because this object can itself by placed into a DiceModifier instance, the possibilities are fairly sufficient.

The example below simulates how you might represent 5D12+4.

Using the dice factory

The DiceFactory makes creating a die implementation simpler.

You can pass it the common string form of a die instead of figuring out how to build it.

or more simply

The class will throw an /InvalidArgumentException if it fails to parse the string so make sure you plan for that.


All versions of dice with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package kusabi/dice contains the following files

Loading the files please wait ....