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.
Instead of using an Arc Mutex for state management embedded directly
into the bot, utilize actor pattern, with the idea that this will be
much more useful than simply logging a message once in the future.
This also refactors the bot code so that instead of a single run_bot
function, the DiceBot struct now has a run() method attached to it.
This also necessitated changes and cleanup to the dicebot main, which
is for the better anyhow.
The error and config types are also now in their own files, and
implemented for more in-depth use cases.
Updates to the latest matrix SDK, which has a new version of olm-sys
(must be dynamically linked at the moment). Also cleans up the
Dockerfile to remove rustup because Void has reached Rust 1.46.0, for
a faster build.
This gives us many things for free, like automated state management,
no need to declare special API structs and use HTTP requests directly,
and most importantly: ENCRYPTION!