Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/olhado/dicer
dice string parser and roller
https://github.com/olhado/dicer
Last synced: about 1 month ago
JSON representation
dice string parser and roller
- Host: GitHub
- URL: https://github.com/olhado/dicer
- Owner: olhado
- License: mit
- Archived: true
- Created: 2014-08-13T00:53:18.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-05-24T01:36:15.000Z (over 9 years ago)
- Last Synced: 2024-10-02T17:45:42.014Z (2 months ago)
- Language: Elixir
- Size: 551 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
- freaking_awesome_elixir - Elixir - A dice roller expression evaluator. (Text and Numbers)
- fucking-awesome-elixir - dicer - A dice roller expression evaluator. (Text and Numbers)
- awesome-elixir - dicer - A dice roller expression evaluator. (Text and Numbers)
README
# NOW DEPRECATED!
Dicer is still available on hex.pm, but will not be worked on anymore. Check out my new replacement project [at gitlab.com named Rollex](https://gitlab.com/olhado/rollex).
Dicer
=====A dice roller expression evaluator written in Elixir!
Installation
============Pre-requisites
--------------* Erlang 17 or greater
* Elixir 1.0.1
* git (to clone the repository)Creating a command line binary
------------------------------`mix escript.build`
From here, execute rolls like this:
`$ dicer "1+2+3"`
Running in interactive shell
----------------------------`iex -S mix`
From here, execute rolls like this:
`iex(1)> Dicer.roll "1+2+3"`
Adding as a mix dependency
--------------------------In your mix.exs file:
```
def application do
[mod: {MyApp, []},
applications: [:dicer]]
end
```and this:
```
defp deps do
[{:dicer, "0.4.0"}]
end
```Details
=======Dicer is an elixir application that lets you evaluate dice rolls with simple arithmetic operators.
* The operators supported are `+, -, /, *`.
* Grouping is via parentheses
* Polyhedral dice are designated using the `d` format (Ex. 20d8 or D100).
* Fudge/Fate dice are designated using the `dF` format (Ex. 42dF)
* You can ask Dicer to take the top or bottom X rolls via the `^` (take top) and `v` (take bottom) symbols (Ex. 10d100^5 [take top 5 results from 10 rolls of a 100-sided die])Why?
====Because it was a fun, somewhat non-trivial way to work in Elixir.
Thanks
======Thanks to [Lukasz Wrobel](http://lukaszwrobel.pl/) for his [short series on parsing](http://lukaszwrobel.pl/blog/math-parser-part-1-introduction). Part 3 was my template for my code, even if it took me way too long to translate the loops into recursive function calls!