Advertisement
Guest User

gui.js

a guest
Sep 25th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 1.76 KB | None | 0 0
  1. $(document).ready(function() {
  2.     $(".button").click(roll);
  3.     $(".img").click(function() {
  4.         var index = $(this).index();
  5.         h[index] = true;
  6.     });
  7.     $(".inputs").click(function() {
  8.        console.log(total);
  9.        $(this).attr("disabled", true);
  10.        $(".inputs").each(function() {
  11.            if(!($(this).is(':disabled'))) {
  12.                 $(this).val('');
  13.            }
  14.        });
  15.        total += parseInt($(this).val());
  16.        $(".inputTotal").val(total)
  17.     });
  18.     var total = 0;
  19.     var sum = 0;
  20.     var bonus = 50;
  21.     var arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
  22.  
  23.  
  24. });
  25.  
  26. var h = [false, false, false, false, false];
  27.  
  28. function roll() {
  29.     if(getThrowCount() <= 2) {
  30.         console.log(getThrowCount());
  31.         throwDice(h);
  32.         var values = getValues();
  33.         var results = getResults();
  34.         $(".inputs").each(function(i) {
  35.             if(!($(this).is(':disabled'))) {
  36.             $(this).val(results[i]);
  37.         }});
  38.         $(".img").each(function(i) {
  39.             console.log(values);
  40.             if(values[i] === 1) {
  41.                 $(this).attr('src',"img/dice-six-faces-one.png");
  42.             }else if(values[i] === 2) {
  43.                 $(this).attr('src',"img/dice-six-faces-two.png");
  44.             }else if(values[i] === 3) {
  45.                 $(this).attr('src',"img/dice-six-faces-three.png");
  46.             }else if(values[i] === 4) {
  47.                 $(this).attr('src',"img/dice-six-faces-four.png");
  48.             }else if(values[i] === 5) {
  49.                 $(this).attr('src',"img/dice-six-faces-five.png");
  50.             }else {
  51.                 $(this).attr('src',"img/dice-six-faces-six.png");
  52.             }
  53.         });
  54.         console.log(h);
  55.     }
  56. }
  57.  
  58. function takeTurn() {
  59.  
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement