Commits

Maximiliano Guerra committed 78ab363 Draft

Adicionando suporte a crítico

Comments (0)

Files changed (2)

               <span class="badge badge-info" data-id="result-two"></span><br />
               <span class="label label-info">Maior:</span>
               <span class="badge badge-info" data-id="results-biggest"></span>
+
+              <span class="label label-important hide" data-id="critical-label">Critico!!!</span>
+              <span class="badge badge-important hide" data-id="critical-value"></span>
             </div>
           </fieldset>
         </form>
 $("#dice-roller").submit(function(event) {
+    event.preventDefault();
+    var $criticalLabel = $("#dice-roller [data-id=critical-label]");
+    var $critical = $("#dice-roller [data-id=critical-value]");
+    $criticalLabel.hide();
+    $critical.hide();
+
     var result1 = Math.floor(Math.random() * 10) + 1;
     var result2 = Math.floor(Math.random() * 10) + 1;
     var biggest;
     $("#dice-roller [data-id=result-two]").text(result2);
     $("#dice-roller [data-id=results-biggest]").text(biggest);
 
+    if ((result1 + result2) >= 18) {
+        $critical.text(biggest);
+        $criticalLabel.show();
+        $critical.show();
+    }
+
     $("#dice-result").show();
 });