Giter Club home page Giter Club logo

dices-rs's Introduction

dices-rs

Dice simulator

Build Status

main: main develop: develop

Description

Usual small Dice simulator for AD&D type of games.

Previous unreleased version was a straight port of the Ruby code in https://bitbucket.org/keltia/addfh-utils (Using Mercurial), rewritten before in Go here and now rewritten to use Rust.

It serves as well as a test-bed on my way of learning Rust. It has been rewritten several times (see the commits) as I progress further in my learning of the language.

Installation

cargo install dices-rs

or get the source and build:

git clone https://github.com/keltia/dices-rs
cd dices-rs
cargo test
cargo bench
cargo install --path .

The binary will be installed wherever it is defined on your machine and the library in dice itself will be compiled and available. The library itself is very minimal and usable only through the CLI utility.

Basic commands

Usage:

Small CLI utility to roll dices.

Usage: dices [OPTIONS]

Options:
  -A, --alias-file <ALIAS_FILE>  Alias file
  -v, --verbose...               Verbose mode
  -V, --version                  Display utility full version
  -h, --help                     Print help information

Example:

$ cargo run --   -A ./testdata/aliases
dices/0.9.4 by Ollivier Robert <[email protected]>
Small CLI utility to roll dices.

Available commands:
special macros = Macros
builtin dice = Builtin { name: "dice", cmd: Dice }
macro   move = Macro { name: "move", cmd: "dice 3D6 -9" }
alias   roll = Alias { name: "roll", cmd: "dice" }
alias   rulez = Alias { name: "rulez", cmd: "dice" }
macro   mouv = Macro { name: "mouv", cmd: "move +7" }
macro   doom = Macro { name: "doom", cmd: "dice 2D6" }
builtin open = Builtin { name: "open", cmd: Open }
special aliases = Aliases
alias   quit = Alias { name: "quit", cmd: "exit" }
special exit = Exit
special list = List

Dices>

If you specify the -v flag several times you increase the amount of debugging information displayed. See below for the format of the aliases file.

The main commands the dices CLI support are:

  • dice

    The regular dice everyone know and love. It can be any size, I could have limited to the usual 4, 6, 8, 10, 12, 20 but I do not see why I should. You can specify multiple dices and even a bonus like in:

    dice 3D6 +2

  • open

    This is a special dice, you can specify only a sized dice and if the roll is equal to its size, it will reroll again until the result is not the max.

    open D8

  • list

    List all available commands including aliases.

  • aliases

List only aliases.

  • macros

List all macros.

  • exit

    Should be obvious

Configuring

The dices utility supports configuring new command or aliases through the aliases file, usually located on $HOME/.config/dices on UNIX systems. Windows is also supported and use the same location for now.

# define a new command
doom = "dice 2D6"
! this is an alias
rulez = dice
// and another one
roll = dice
# or even
quit = exit
# Movement roll
move = "dice 3D6 -9"
# new command with argument
mouv = "move +7"

As you can see, you can alias existing commands or create new ones (common usage I expect). You can even create new command pointing to aliases or other new commands (see mouv above which points to move +7, etc.).

Some aliases are pre-defined at start to be useful:

  • roll for dice
  • doom for the special roll of 2D6

TODO

  • Document, document and more documentation
  • Tests and more tests
  • Fold aliases and macros into a specialized list through a special closure
  • Specifying the commands as a yaml file at compile time with include_str!
  • add CLI tests.
  • Allow alias to existing commands or other aliases

Contributing

Please see CONTRIBUTING.md for some simple rules.

I use Git Flow for this package so please use something similar or the usual github workflow.

  1. Fork it ( https://github.com/keltia/dmarc-rs/fork )
  2. Checkout the develop branch (git checkout develop)
  3. Create your feature branch (git checkout -b my-new-feature)
  4. Commit your changes (git commit -am 'Add some feature')
  5. Push to the branch (git push origin my-new-feature)
  6. Create a new Pull Request

NOTE: Pull Request on the "main" branch will be closed without commit.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.