Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

verbose_print() not working on python #29

Closed
gabrieltomasin opened this issue Sep 5, 2021 · 2 comments
Closed

verbose_print() not working on python #29

gabrieltomasin opened this issue Sep 5, 2021 · 2 comments

Comments

@gabrieltomasin
Copy link

I can't get it to print the information I want on python. For example:

>>> import dice
>>> x = dice.roll('3d6+2d10+5')
>>> dice.utilities.verbose_print(x)
'26'

I wanted it to display something like what is displayed on the command line interface when I use the -v argument. I need the dice information so I can tell if my players crit or not.

$ roll -v 3d6+2d10+5
Result: 31
Breakdown:
Add(
  roll 3d6 -> [4, 4, 4] -> 12,
  roll 2d10 -> [4, 10] -> 14,
  5
) -> 31
@borntyping
Copy link
Owner

I can reproduce this, but not sure why it's happening. I'll investigate...

@borntyping
Copy link
Owner

Looks like you need to add the raw=True flag. I think this keeps the original parsed elements around in the result, instead of replacing them with the final rolls.

>>> import dice
>>> x = dice.roll('3d6+2d10+5', raw=True)
>>> dice.utilities.verbose_print(x)
'Add(\n  roll 3d6 -> [2, 4, 3] -> 9,\n  roll 2d10 -> [10, 4] -> 14,\n  5\n) -> 28'

It's a bit of an odd API choice - I wrote this a very very long time ago, though I've been thinking about rewriting it (see #16).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants