-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.js
More file actions
59 lines (59 loc) · 1.34 KB
/
functions.js
File metadata and controls
59 lines (59 loc) · 1.34 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
function decClick( image ) {
var i = image.id;
decValue( Number( i ) );
};
function decValue( idx ) {
ele = 'hd' + idx;
curHdValues[idx]--;
ta = document.getElementById( ele );
if( curHdValues[idx] < 0 ) {
curHdValues[idx] = 0;
alert( "Die Value can't be lower than 0" );
return
}
ta.innerHTML = "";
ta.innerHTML = curHdValues[idx];
};
function dieType( roll ) {
if( roll <= 4 ){
return 4;
}else if( roll <= 8 ) {
return 6;
}else if( roll <= 12 ) {
return 8;
}else if( roll <= 16 ) {
return 10;
}else if( roll <= 20 ) {
return 12;
} else{
alert( "Oops! Nothing to see here" );
}
};
function dX( dice ) {
return Math.floor( Math.random() * (dice - 1 + 1 ) ) + 1;
};
function getConModifier( score ) {
if( score <= 8 ) {
return -1;
} else if( score >= 15 ){
return 1;
} else{
return 0;
}
};
function incClick( image ) {
var i = image.id;
incValue( Number( i ) );
};
function incValue( idx ) {
ele = 'hd' + idx;
curHdValues[idx]++;
ta = document.getElementById( ele );
if( curHdValues[idx] > hdValues[idx] ) {
alert( "Value higher than initial" );
curHdValues[idx]--;
return;
}
ta.innerHTML = "";
ta.innerHTML = curHdValues[idx];
}