-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
81 lines (78 loc) · 3.23 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<head>
<title>Pokemon Team Heuristics Site</title>
<script src = "./dist/site.js"></script>
<script src = "https://summerstyle.github.io/jsonTreeViewer/libs/jsonTree/jsonTree.js"></script>
<link href="https://summerstyle.github.io/jsonTreeViewer/libs/jsonTree/jsonTree.css" rel="stylesheet" />
<style>
* {
font-family: Arial;
}
textarea {
min-width: 27em;
min-height: 10em;
resize: vertical;
}
ul {
list-style-type: none;
}
</style>
</head>
<body>
<h1>Pokemon Heuristics Calculator</h1>
<hr>
<div id="calc-area">
<p>Heuristic <select id="heuristics" name="heuristics"></select> <button onclick = "calcHeuristic();">Calculate!</button></p>
<p>Method (0 for avg, 1 for log): <input id="hMethod" placeholder = "0"/></p>
<p id="calc-info"></p>
<div id="calc-results" style="background:#DDDDDD; width:fit-content"></div>
</div>
<p><b>Import Team</b> <button onclick = "setTestTeam();">Submit</button></p>
<p>Generation (1-9): <input id="gen-input" placeholder = "9"/></p>
<p>Tier (ex. gen9ou): <input id="tier-input" placeholder = "gen9ou" /></p>
<p><textarea id="team-input" rows="10"></textarea></p>
<footer>
<hr>
<p>Github Link: <a href = "https://github.com/gigalh128/gigalh128.github.io">https://github.com/gigalh128/gigalh128.github.io</a></p>
<p>Made by Ryan Kim</p>
</footer>
</body>
<script>
//fill in the list of heuristic options
const hOptions = document.getElementById("heuristics");
const hList = Object.getOwnPropertyNames(Team.prototype);
for(let i in hList) {
if (hList[i] === "constructor") {
continue;
}
hOptions.append(document.createElement("option"));
hOptions.lastChild.value = hList[i];
hOptions.lastChild.innerText = hList[i];
}
let testTeam;
function setTestTeam() {
testTeam = parseTeamTxt(document.getElementById("team-input").value,
Number(document.getElementById("gen-input").value || document.getElementById("gen-input").placeholder),
document.getElementById("tier-input").value || document.getElementById("tier-input").placeholder);
console.log("test team submitted", testTeam);
}
function calcHeuristic() {
const method = Number(document.getElementById("hMethod").value || document.getElementById("hMethod").placeholder);
const hVal = testTeam[document.getElementById("heuristics").value](undefined, undefined, method);
const info = document.getElementById("calc-info");
const results = document.getElementById("calc-results");
const cNode = results.cloneNode(false);
results.parentElement.replaceChild(cNode, results);
const tree = jsonTree.create(hVal, cNode);
tree.findAndHandle(function(item){return item.type === "number"},
function(item) {
const el = item.el.lastChild.lastElementChild;
el.innerText = Number(el.innerText).toFixed(3);
}
)
info.innerText = "";
if(hVal.length === 3) { //heuristics are split into special, physical, and combined attributes
info.innerText = "Index 0 -> values for the special side\nIndex 1 -> values for the physical side\n Index 2 -> values for both sides combined";
}
console.log(document.getElementById("heuristics").value + " heuristic calculated", hVal);
}
</script>