1. Maximiliano Guerra
  2. dragon-rpg-system

Commits

Maximiliano Guerra  committed 41294cb Draft

Adicionou rolagem de um dado

  • Participants
  • Parent commits 78ab363
  • Branches default

Comments (0)

Files changed (2)

File index.html

View file
  • Ignore whitespace
   <div class="container">
     <div class="row">
       <div class="span4">
-        <form class="bs-docs" id="dice-roller">
+        <form class="bs-docs" id="double-dice-roller">
           <fieldset>
-            <legend>Rolador de dados</legend>
+            <legend>Rolador de dados (dois dados)</legend>
             <button type="submit" class="btn btn-info input-block-level" style="margin-bottom: 10px">Rolar!</button>
             <hr />
-            <div id="dice-result" class="text-center hide">
+            <div id="double-dice-result" class="text-center hide">
               <span class="label label-info">Resultados:</span>
               <span class="badge badge-info" data-id="result-one"></span>
               <span class="badge badge-info" data-id="result-two"></span><br />
             </div>
           </fieldset>
         </form>
-
+        <form class="bs-docs" id="dice-roller">
+          <fieldset>
+            <legend>Rolador de dados (um dado)</legend>
+            <button type="submit" class="btn btn-info input-block-level" style="margin-bottom: 10px">Rolar!</button>
+            <hr />
+            <div id="dice-result" class="text-center hide">
+              <span class="label label-info">Resultado:</span>
+              <span class="badge badge-info" data-id="result"></span>
+            </div>
+          </fieldset>
+        </form>
       </div>
 
       <div class="span4">

File js/system.js

View file
  • Ignore whitespace
-$("#dice-roller").submit(function(event) {
+$("#double-dice-roller").submit(function(event) {
     event.preventDefault();
-    var $criticalLabel = $("#dice-roller [data-id=critical-label]");
-    var $critical = $("#dice-roller [data-id=critical-value]");
+    var $criticalLabel = $("#double-dice-roller [data-id=critical-label]");
+    var $critical = $("#double-dice-roller [data-id=critical-value]");
     $criticalLabel.hide();
     $critical.hide();
 
     else
         biggest = result2;
 
-    $("#dice-roller [data-id=result-one]").text(result1);
-    $("#dice-roller [data-id=result-two]").text(result2);
-    $("#dice-roller [data-id=results-biggest]").text(biggest);
+    $("#double-dice-roller [data-id=result-one]").text(result1);
+    $("#double-dice-roller [data-id=result-two]").text(result2);
+    $("#double-dice-roller [data-id=results-biggest]").text(biggest);
 
     if ((result1 + result2) >= 18) {
         $critical.text(biggest);
         $critical.show();
     }
 
+    $("#double-dice-result").show();
+});
+
+$("#dice-roller").submit(function(event) {
+    event.preventDefault();
+    var result = Math.floor(Math.random() * 10) + 1;
+    $("#dice-roller [data-id=result]").text(result);
     $("#dice-result").show();
 });