-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
48 lines (40 loc) · 1.22 KB
/
index.html
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
<html>
<head></head>
<body>
</body>
<script type="text/javascript">
var common = ["[c]Mana Wyrm", "[c]Mirror Entity", "[c]Ice Barrier"]
var rare = ["[r]Blizzard", "[r]Vaporize", "[r]Counterspell"]
var epic = ["[e]Meteor", "[e]Pyroblast", "[e]Doomsayer"]
var legendary = ["[l]Alexstrasza", "[l]Malygos", "[l]Ysera", "[l]Deathwing"]
var commonCount = 0
function random_card(percent = 100) {
// Between 1-100
randomRate = Math.floor((Math.random() * percent) + 1)
if (randomRate >= 1 && randomRate <= 5) {
// legendary 1-5 5%
console.log(legendary[Math.floor(Math.random() * legendary.length)])
} else if (randomRate >= 6 && randomRate <= 20) {
// epic 11-30 15%
console.log(epic[Math.floor(Math.random() * epic.length)])
} else if (randomRate >= 21 && randomRate <= 50) {
// rare 31-50 30%
console.log(rare[Math.floor(Math.random() * rare.length)])
} else {
// common 50%
commonCount += 1
console.log(common[Math.floor(Math.random() * common.length)])
}
}
function open_pack() {
for (i = 0; i < 5; i++) {
if (commonCount == 4) {
random_card(50)
} else {
random_card()
}
}
}
open_pack()
</script>
</html>