introduction.html 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <title>Introduction &#8212; xdice 1.0.0 documentation</title>
  7. <link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
  8. <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  9. <script type="text/javascript">
  10. var DOCUMENTATION_OPTIONS = {
  11. URL_ROOT: './',
  12. VERSION: '1.0.0',
  13. COLLAPSE_INDEX: false,
  14. FILE_SUFFIX: '.html',
  15. HAS_SOURCE: true,
  16. SOURCELINK_SUFFIX: '.txt'
  17. };
  18. </script>
  19. <script type="text/javascript" src="_static/jquery.js"></script>
  20. <script type="text/javascript" src="_static/underscore.js"></script>
  21. <script type="text/javascript" src="_static/doctools.js"></script>
  22. <link rel="index" title="Index" href="genindex.html" />
  23. <link rel="search" title="Search" href="search.html" />
  24. <link rel="next" title="Dice Notation" href="dice_notation.html" />
  25. <link rel="prev" title="Welcome to the documentation for xdice" href="index.html" />
  26. <link rel="stylesheet" href="_static/custom.css" type="text/css" />
  27. <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
  28. </head>
  29. <body>
  30. <div class="document">
  31. <div class="documentwrapper">
  32. <div class="bodywrapper">
  33. <div class="body" role="main">
  34. <div class="section" id="introduction">
  35. <h1>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h1>
  36. <div class="section" id="presentation">
  37. <h2>Presentation<a class="headerlink" href="#presentation" title="Permalink to this headline">¶</a></h2>
  38. <p><em>xdice</em> is a dice library for Python that provides the main functionality
  39. for managing dice, scores, and dice notation patterns.</p>
  40. <p>DiceRollParser has been tested with python 3.3+.
  41. <em>xdice</em> is under GNU License</p>
  42. <p>To install:</p>
  43. <div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">pip</span> <span class="n">install</span> <span class="n">xdice</span>
  44. </pre></div>
  45. </div>
  46. </div>
  47. <div class="section" id="what-can-it-do">
  48. <h2>What can it do?<a class="headerlink" href="#what-can-it-do" title="Permalink to this headline">¶</a></h2>
  49. <ul class="simple">
  50. <li>Parse most of common dice notations: ‘1d6+1’, ‘d20’, ‘3d%’, ‘1d20//2 - 2*(6d6+2)’, ‘max(1d4+1,1d6)’, ‘3D6L2’, ‘R3(1d6+1)’…etc.</li>
  51. <li>Manipulate Dice, Pattern, and Score as objects.</li>
  52. <li>Roll trough command-line or API</li>
  53. <li>Understand any mathematical expression</li>
  54. </ul>
  55. <div class="section" id="examples">
  56. <h3>Examples<a class="headerlink" href="#examples" title="Permalink to this headline">¶</a></h3>
  57. <div class="highlight-default"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">dice</span>
  58. <span class="n">score</span> <span class="o">=</span> <span class="n">dice</span><span class="o">.</span><span class="n">roll</span><span class="p">(</span><span class="s2">&quot;2d6+18&quot;</span><span class="p">)</span>
  59. <span class="nb">print</span><span class="p">(</span><span class="n">score</span><span class="p">)</span>
  60. <span class="o">&gt;&gt;</span> <span class="mi">28</span>
  61. <span class="nb">print</span><span class="p">(</span><span class="n">score</span><span class="o">*</span><span class="mi">2</span><span class="p">)</span>
  62. <span class="o">&gt;&gt;</span> <span class="mi">56</span>
  63. <span class="nb">print</span><span class="p">(</span><span class="n">score</span><span class="o">.</span><span class="n">format</span><span class="p">())</span>
  64. <span class="o">&gt;&gt;</span> <span class="s1">&#39;[5,6]+18&#39;</span>
  65. <span class="n">score</span> <span class="o">=</span> <span class="n">dice</span><span class="o">.</span><span class="n">roll</span><span class="p">(</span><span class="s2">&quot;6D%L2&quot;</span><span class="p">)</span>
  66. <span class="nb">print</span><span class="p">(</span><span class="n">ps</span><span class="p">,</span> <span class="n">ps</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">verbose</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span>
  67. <span class="o">&gt;&gt;</span> <span class="mi">315</span> <span class="s1">&#39;6D%L2(scores:[80, 70, 76, 89], dropped:[2, 49])&#39;</span>
  68. </pre></div>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. </div>
  74. </div>
  75. </div>
  76. <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
  77. <div class="sphinxsidebarwrapper">
  78. <h1 class="logo"><a href="index.html">xdice</a></h1>
  79. <h3>Navigation</h3>
  80. <ul class="current">
  81. <li class="toctree-l1 current"><a class="current reference internal" href="#">Introduction</a><ul>
  82. <li class="toctree-l2"><a class="reference internal" href="#presentation">Presentation</a></li>
  83. <li class="toctree-l2"><a class="reference internal" href="#what-can-it-do">What can it do?</a></li>
  84. </ul>
  85. </li>
  86. <li class="toctree-l1"><a class="reference internal" href="dice_notation.html">Dice Notation</a></li>
  87. <li class="toctree-l1"><a class="reference internal" href="cli.html">Command-Line</a></li>
  88. <li class="toctree-l1"><a class="reference internal" href="api.html">API</a></li>
  89. </ul>
  90. <div class="relations">
  91. <h3>Related Topics</h3>
  92. <ul>
  93. <li><a href="index.html">Documentation overview</a><ul>
  94. <li>Previous: <a href="index.html" title="previous chapter">Welcome to the documentation for xdice</a></li>
  95. <li>Next: <a href="dice_notation.html" title="next chapter">Dice Notation</a></li>
  96. </ul></li>
  97. </ul>
  98. </div>
  99. <div id="searchbox" style="display: none" role="search">
  100. <h3>Quick search</h3>
  101. <form class="search" action="search.html" method="get">
  102. <div><input type="text" name="q" /></div>
  103. <div><input type="submit" value="Go" /></div>
  104. <input type="hidden" name="check_keywords" value="yes" />
  105. <input type="hidden" name="area" value="default" />
  106. </form>
  107. </div>
  108. <script type="text/javascript">$('#searchbox').show(0);</script>
  109. </div>
  110. </div>
  111. <div class="clearer"></div>
  112. </div>
  113. <div class="footer">
  114. &copy;2017, Olivier Massot.
  115. |
  116. Powered by <a href="http://sphinx-doc.org/">Sphinx 1.6.3</a>
  117. &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.10</a>
  118. |
  119. <a href="_sources/introduction.rst.txt"
  120. rel="nofollow">Page source</a>
  121. </div>
  122. </body>
  123. </html>