knadh / dns.toys

A DNS server that offers useful utilities and services over the DNS protocol. Weather, world time, unit conversion etc.
https://www.dns.toys
MIT License
2.48k stars 135 forks source link

Add a dice-rolling feature #30

Closed mikolysz closed 2 years ago

mikolysz commented 2 years ago

I propose adding a dice-rolling and random number generation feature, useful when E.G. playing tabletop RPG games, or when not sure which option/person to pick for something.

The feature should consist of two services, .dice and .random. The first service should accept requests in the standard format kdn(+m.)dice, where k, n and m are numbers. For example:

I'm not sure if DNS considers + as an acceptable character, if not, we can use / instead.

The service should return the results for each roll separately, as well as the total of all rolls + the modifier.

The second service should accept requests in the format n-m.random, and return a random number between n and m (inclusive).

I'm willing to work on this personally if @knadh considers this useful enough to merge, but I'd love to get their opinion on this first so that my work doesn't go to waste.

knadh commented 2 years ago

Sounds good, @mikolysz! Please do send a PR.

3d20+5.dice

We can use - here also for consistency.