Forum: Ruby Hazard, a new dice rolling library

00259848c144389e79daca04430518d5?d=identicon&s=25 Cédric ZUGER (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: https://github.com/czuger/hazard#usage

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

Cedric
4828d528e2e46f7c8160c336eb332836?d=identicon&s=25 Robert Heiler (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
perhaps?

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*
00259848c144389e79daca04430518d5?d=identicon&s=25 Cédric ZUGER (czuger)
on 2016-12-29 09:56
Hello,

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
class.

Good luck for your projects. Hope you'll finally find the time :)

Best regards,

Cedric
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.