README.rst 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. |Build Status| |Coverage Status| |Documentation Status|
  2. **xdice**
  3. *xdice* is a lightweight python library for managing dice, scores, and
  4. dice-notation patterns.
  5. - Parse almost any Dice Notation pattern: '1d6+1', 'd20', '3d%', '1d20//2 - 2*(6d6+2)', 'max(1d4+1,1d6)', '3D6L2', 'R3(1d6+1)'...etc.
  6. - API help you to easily manipulate dices, patterns, and scores as objects
  7. - A command line tool for convenience
  8. Python Versions
  9. ^^^^^^^^^^^^^^^
  10. DiceRollParser has been tested with **python 3.3+**
  11. Documentation
  12. ~~~~~~~~~~~~~
  13. For more, see the Documentation_
  14. Examples:
  15. ^^^^^^^^^
  16. ::
  17. import dice
  18. # Roll simple dices with **rolldice()**
  19. score = rolldice(6, amount=2)
  20. # manipulates score as an integer
  21. print(score)
  22. >> 11
  23. print(score * 2)
  24. >> 22
  25. print(score == 11)
  26. >> True
  27. # Or iterates over the results
  28. for result in score:
  29. print(result)
  30. >> 5
  31. >> 6
  32. # Parse patterns with **roll()**
  33. ps = roll("2d6+18")
  34. print(ps)
  35. >> 28
  36. print(ps.format())
  37. >> '[5,6]+18'
  38. ps = roll("6D%L2")
  39. print(ps)
  40. >> 315
  41. print(ps.format(verbose=True))
  42. >> '6D%L2(scores:[80, 70, 76, 89], dropped:[2, 49])'
  43. CLI
  44. ^^^
  45. Run ``python roll.py [options] <expr>``
  46. ::
  47. Usage:
  48. roll [options] <expr>
  49. Options:
  50. -s Numeric score only
  51. -h --help Displays help message
  52. --version Displays current xdice version
  53. CONTRIBUTION
  54. ^^^^^^^^^^^^
  55. Any opinion / contribution is welcome, please contact us.
  56. TO INSTALL
  57. ^^^^^^^^^^
  58. ::
  59. pip install xdice
  60. License
  61. ^^^^^^^
  62. *xdice* is under GNU License
  63. Author
  64. ^^^^^^
  65. Olivier Massot, 2017, with *Cro-ki Lab*
  66. Tags
  67. ^^^^
  68. ::
  69. dice roll d20 game random parser dices role board
  70. .. _Documentation: https://xdice.readthedocs.io/en/latest/
  71. .. |Build Status| image:: https://travis-ci.org/cro-ki/xdice.svg?branch=master
  72. :target: https://travis-ci.org/cro-ki/xdice
  73. .. |Coverage Status| image:: https://coveralls.io/repos/github/cro-ki/xdice/badge.svg?branch=master
  74. :target: https://coveralls.io/github/cro-ki/xdice?branch=master
  75. .. |Documentation Status| image:: https://readthedocs.org/projects/xdice/badge/?version=latest
  76. :target: http://xdice.readthedocs.io/en/latest/?badge=latest