Forum: Ruby Hazard, a new dice rolling library

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
E197b971050a5c97956850248a11d6c9?d=identicon&s=25 Cédric Z. (czuger)
on 2016-12-27 19:14
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:

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

7e17d370dc95b48cd82944a62f1caf76?d=identicon&s=25 Robert H. (shevegen)
on 2016-12-28 21:12
I tested your gem just now. It seems to work.

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

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*
E197b971050a5c97956850248a11d6c9?d=identicon&s=25 Cédric Z. (czuger)
on 2016-12-29 09:56

Thank you for your interest :)

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 :)

Best regards,

This topic is locked and can not be replied to.