tenebrous-dicebot/src
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
..
bin Encapsulate config with Arc. Further bot code cleanup. 2020-10-03 20:45:14 +00:00
cofd Dice pool and command parser rewrite to prepare for user variables. 2020-10-11 21:22:12 +00:00
commands Dice pool and command parser rewrite to prepare for user variables. 2020-10-11 21:22:12 +00:00
dice cargo fix and fmt 2020-04-21 00:09:43 -06:00
bot.rs Encapsulate config with Arc. Further bot code cleanup. 2020-10-03 20:45:14 +00:00
cofd.rs Move CofD dice rolling into dice.rs file under cofd/ 2020-08-27 23:56:19 +00:00
commands.rs Dice pool and command parser rewrite to prepare for user variables. 2020-10-11 21:22:12 +00:00
config.rs Inline all config getters. 2020-10-03 20:59:04 +00:00
dice.rs cargo fix and fmt 2020-04-21 00:09:43 -06:00
error.rs Dice pool and command parser rewrite to prepare for user variables. 2020-10-11 21:22:12 +00:00
help.rs Implement basic, not-well-formatted help. 2020-08-30 21:54:01 +00:00
lib.rs Implement Actix for state, refactor bot code. 2020-10-03 20:45:14 +00:00
parser.rs Remove useless trim function and unnecessary uses of eat_whitespace. 2020-08-31 20:16:43 +00:00
roll.rs Implement Chronicles of Darkness dice system, improve error handling. 2020-08-23 21:24:04 +00:00
state.rs Encapsulate config with Arc. Further bot code cleanup. 2020-10-03 20:45:14 +00:00