-
Notifications
You must be signed in to change notification settings - Fork 0
/
application.js
43 lines (38 loc) · 1.2 KB
/
application.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
$(function() {
var cashMoneyz = 100;
$('#guessing-form').on('submit', function(e) {
e.preventDefault();
var bet = +($('#bets-form :input').val());
var guess = $('#guessing-form :input').val();
var RNGGod = function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min)) + min;
};
var ranNum = RNGGod(1, 10);
if (guess == ranNum) {
$('#flash-correct').fadeIn('fast', function() {
$(this).delay(500).fadeOut();
cashMoneyz += bet;
$('#bank').text(cashMoneyz);
});
}
else if ((guess - ranNum) == Math.abs(1)) {
$('#flash-almost').fadeIn('fast', function() {
$(this).delay(500).fadeOut();
});
}
else {
$('#flash-incorrect').fadeIn('fast', function() {
$(this).delay(500).fadeOut();
if (cashMoneyz < bet) {
$('#bank').text(0);
}
else {
cashMoneyz -= bet;
$('#bank').text(cashMoneyz);
}
});
}
});
});
// Next thing is to make a check that there are no decimals and that all inputs are whole numbers within specific range.
// Then beautify