Skip to content

diceroll A C++ Command Line Dice Rolling Program

License

Notifications You must be signed in to change notification settings

fraterm/diceroll

Repository files navigation

diceroll

Diceroll Logo

A C++ Command Line Dice Rolling Program

DICE STRING FORMAT

Initially uses the same format that the rolldice C program uses:

{#x}{#}d[#|%]{*#}{+/-#}{s#}

number of rolls or throws of the dice group specified later, optional.

{#x}

number of dice then their sides, or the % to represent 100 beginning required

{#}d[#|%]

@TODO explain the rest of the notation

Which becomes an ECMAScript (JavaScript) regex with named-groups parseable by srell regex library:

  std::string regexString = "^"
                            "(?<throwgroup>(?<throws>[0-9]{1,})(?<throwch>[x|X]{1})){0,}"
                            "(?<dicegroup>(?<numdice>[0-9]{1,})(?<dicechar>[d|D]{1})(?<sidestype>[0-9]{0,}|[%]{1})){0,}"
                            "(?<multgroup>(?<charmult>[*]{1})(?<nummult>[0-9]{1,})){0,}"
                            "(?<addsubgroup>(?<chaddsub>[+|-]{1})(?<numaddsub>[0-9]{1,})){0,}"
                            "(?<droplowgroup>(?<chardroplow>[s]{1})(?<numdroplow>[0-9]{1,})){0,}"
                            "$";

Stage the string parse into parts: Number of throws part optional Number and type of dice part required

Future Plans

  • If there are no positional string arguments, drop into a "rolling shell" or "rolling session" where you type dicestrings and they are parsed from the line...
  • fill in the options existing to operate similarly to rolldice
  • someday I might integrate with GNOLLs amazing TTRPG dice string parser.
  • Profit?