Commit Graph

9 Commits

Author SHA1 Message Date
projectmoon 3b70891b0a Reject dice pool expressions over 100 elements. 2020-10-16 22:20:46 +00:00
projectmoon d0a1f59ec7 Better error message when dice pool variable not defined. 2020-10-16 22:20:46 +00:00
projectmoon af2e58351f Resolve variables in dice pools. 2020-10-16 22:20:46 +00:00
projectmoon 7e44faf693 Dice pool and command parser rewrite to prepare for user variables.
This commit refactors the parsing and rolling for the dice pool system
to prepare for support of user variables. The nom parser was dropped
in favor of the easier-to-understand combine parser in most parts of
the code.

A breaking change was introduced into the dice pool syntax to allow
for proper expressions and variables. The syntax is now
"modifiers:pool-amount", e.g. "n:gnosis+8". The simple single-number
syntax with no modifiers is also still understood.

Dice pool expressions are translated into a Vec of "Amount" objects,
stored by the DicePool struct. They have an operator (+ or -) and
either a number or variable name. When the dice pool is rolled, this
list of Amonuts are is collapsed into a single number that is rolled,
as it was before the refactor.

The following changes were made to the dice rolling code:
 - Store Vec<Amount> on DicePool instead of single number to roll.
 - New struct RolledDicePool to store result of a dice pool roll.
 - Remove Display trait from DicePool, move it over to RolledDicePool.
 - Separate extra dice pool info into DicePoolModifiers.
 - DicePoolModifiers is shared between DicePool and RolledDicePool.
 - Dice parsing and rolling now return standard Result objects.

This commit does NOT enable support of actually using variables. Any
dice pool roll containing a variable will result in an eror.

The command parser was also rewritten to use combine and rely on the
standard Result pattern.
2020-10-11 21:22:12 +00:00
projectmoon 92e4a7c29b Rote die roll now respects dice pool success_on property.
Fixes #5.
2020-09-26 14:04:12 +00:00
projectmoon 16b5a3a51a Chance die should only succeed on 10. Added no-explode rolls. 2020-08-28 21:47:09 +00:00
projectmoon 5983592eb3 Limit large the display of large dice pools. 2020-08-28 00:30:28 +00:00
projectmoon f0a1fe53fc Move CofD dice rolling into dice.rs file under cofd/ 2020-08-27 23:56:19 +00:00
projectmoon 2c08eb41ad Implement Chronicles of Darkness dice system, improve error handling.
Adds the Chronicles of Darkness 2E dice system to the bot, and also
somewhat improves the error handling when weird commands are received.
2020-08-23 21:24:04 +00:00