Hazard, a new dice rolling library

Hello everybody,

I wanted to have a library that allow me to write the dice rolls like
they are in an rpg manual. For instance: 3d6, 1d4, etc …

So I wrote a small library called Hazard which is very simple to use:

Hazard.d6 => roll one 6 sided dice
Hazard.r2d8 => rolls two 8 sided dices

You can get the sum of the rolls or have the detail, it is up to you.

For more, please have a look at: GitHub - czuger/hazard: A very simple dice library for ruby

The Gem is finalized, tested and usable now.
Comments and advices are welcome.


I tested your gem just now. It seems to work.

Btw you mispelled Hazard once in your example code above. :slight_smile:

The name Hazard, can you add an alias name to Die or Dice

Dice.d6 may seem more readable IMO.

I also once needed it for RPG-related games, also for MUDs
or simulating MUDs after finding faerieMUD (was written in
ruby back then) but reallife got the better of me and I
am writing mostly non-fantasy related code in ruby these
days. But one day I shall give it another try to write a
MUD engine in ruby shakes fist


Thank you for your interest :slight_smile:

I called the gem hazard because dice was already taken, so I called the
class hazard to be consistent.

But you are right, I’ll create aliases so you can use it with a Dice

Good luck for your projects. Hope you’ll finally find the time :slight_smile:

Best regards,