fixed merge issues
This commit is contained in:
commit
f6e68a74b8
11 changed files with 72153 additions and 71797 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
*.swp
|
3
build.js
3
build.js
|
@ -9,6 +9,9 @@ function skillPointsToPercentage(skp){
|
|||
//return(-0.0000000066695* Math.pow(Math.E, -0.00924033 * skp + 18.9) + 1.0771).toFixed(3);
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 151; i++) {
|
||||
console.log(i, ", ",skillPointsToPercentage(i));
|
||||
}
|
||||
|
||||
|
||||
class Build{
|
||||
|
|
143256
clean.json
143256
clean.json
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
50
compress.py
50
compress.py
|
@ -4,10 +4,22 @@ with open("dump.json", "r") as infile:
|
|||
data = json.loads(infile.read())
|
||||
|
||||
items = data["items"]
|
||||
del data["request"]
|
||||
|
||||
translate_mappings = {
|
||||
#"name": "name",
|
||||
#"displayName": "displayName",
|
||||
#"tier": "tier",
|
||||
#"set": "set",
|
||||
"sockets": "slots",
|
||||
#"type": "type",
|
||||
# UNUSED? "armorType": "armorType",
|
||||
"armorColor": "color",
|
||||
"addedLore": "lore",
|
||||
#"material": "material",
|
||||
"dropType": "drop",
|
||||
#"quest": "quest",
|
||||
"restrictions": "restrict",
|
||||
"damage": "nDam",
|
||||
"fireDamage": "fDam",
|
||||
"waterDamage": "wDam",
|
||||
|
@ -30,8 +42,8 @@ translate_mappings = {
|
|||
"defense": "defReq",
|
||||
"healthRegen": "hprPct",
|
||||
"manaRegen": "mr",
|
||||
"spellDamage": "spellPct",
|
||||
"damageBonus": "meleePct",
|
||||
"spellDamage": "sdPct",
|
||||
"damageBonus": "mdPct",
|
||||
"lifeSteal": "ls",
|
||||
"manaSteal": "ms",
|
||||
"xpBonus": "xpb",
|
||||
|
@ -45,14 +57,14 @@ translate_mappings = {
|
|||
#"thorns": "thorns",
|
||||
#"exploding": "expoding",
|
||||
"speed": "spd",
|
||||
"attackSpeedBonus": "attackTier",
|
||||
"attackSpeedBonus": "atkTier",
|
||||
#"poison": "poison",
|
||||
"healthBonus": "hpBonus",
|
||||
"soulPoints": "spRegen",
|
||||
"emeraldStealing": "stealing",
|
||||
"emeraldStealing": "eSteal",
|
||||
"healthRegenRaw": "hprRaw",
|
||||
"spellDamageRaw": "spellRaw",
|
||||
"damageBonusRaw": "meleeRaw",
|
||||
"spellDamageRaw": "sdRaw",
|
||||
"damageBonusRaw": "mdRaw",
|
||||
"bonusFireDamage": "fDamPct",
|
||||
"bonusWaterDamage": "wDamPct",
|
||||
"bonusAirDamage": "aDamPct",
|
||||
|
@ -63,22 +75,28 @@ translate_mappings = {
|
|||
"bonusAirDefense": "aDefPct",
|
||||
"bonusThunderDefense": "tDefPct",
|
||||
"bonusEarthDefense": "eDefPct",
|
||||
"accessoryType": "type",
|
||||
"identified": "fixID",
|
||||
#"skin": "skin",
|
||||
#"category": "category",
|
||||
|
||||
"spellCostPct1": "spellPct1",
|
||||
"spellCostRaw1": "spellRaw1",
|
||||
"spellCostPct2": "spellPct2",
|
||||
"spellCostRaw2": "spellRaw2",
|
||||
"spellCostPct3": "spellPct3",
|
||||
"spellCostRaw3": "spellRaw3",
|
||||
"spellCostPct4": "spellPct4",
|
||||
"spellCostRaw4": "spellRaw4",
|
||||
"spellCostPct1": "spPct1",
|
||||
"spellCostRaw1": "spRaw1",
|
||||
"spellCostPct2": "spPct2",
|
||||
"spellCostRaw2": "spRaw2",
|
||||
"spellCostPct3": "spPct3",
|
||||
"spellCostRaw3": "spRaw3",
|
||||
"spellCostPct4": "spPct4",
|
||||
"spellCostRaw4": "spRaw4",
|
||||
|
||||
"rainbowSpellDamageRaw": "rainbowSDRaw",
|
||||
"rainbowSpellDamageRaw": "rainbowRaw",
|
||||
"sprint": "sprint",
|
||||
"sprintRegen": "sprintReg",
|
||||
"jumpHeight": "jh",
|
||||
"lootQuality": "lq",
|
||||
|
||||
"gatherXpBonus": "gXp",
|
||||
"gatherSpeed": "gSpd",
|
||||
}
|
||||
|
||||
delete_keys = [
|
||||
|
@ -98,6 +116,8 @@ for item in items:
|
|||
item[v] = item[k]
|
||||
del item[k]
|
||||
|
||||
item["type"] = item["type"].lower()
|
||||
|
||||
with open("clean.json", "w") as outfile:
|
||||
outfile.write(json.dumps(data, indent=2))
|
||||
with open("compress.json", "w") as outfile:
|
||||
|
|
145
index.html
Normal file
145
index.html
Normal file
|
@ -0,0 +1,145 @@
|
|||
<!DOCTYPE html>
|
||||
<html scroll-behavior="smooth">
|
||||
<head>
|
||||
<link rel="stylesheet" href="styles.css">
|
||||
<link rel="icon" href="favicon.png">
|
||||
<link rel="manifest" href="manifest.json">
|
||||
<title>Wynn Clientside</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="header">
|
||||
Wynn build calculator
|
||||
</div>
|
||||
<div class="equipment">
|
||||
<div class="center" style="grid-column:1;grid-row:1">
|
||||
<div>
|
||||
<label for="helmet-choice">Helmet:</label>
|
||||
<input list="helmet-items" id="helmet-choice" name="helmet-choice" />
|
||||
<datalist id="helmet-items">
|
||||
</datalist>
|
||||
</div>
|
||||
<div id="helmet-slots">
|
||||
X slots
|
||||
</div>
|
||||
<div>
|
||||
<label for="helmet-powder">Powdering:</label>
|
||||
<input type="text" id="helmet-powder" name="helmet-powder" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="center" style="grid-column:2;grid-row:1">
|
||||
<div>
|
||||
<label for="chestplate-choice">Chestplate:</label>
|
||||
<input list="chestplate-items" id="chestplate-choice" name="chestplate-choice" />
|
||||
<datalist id="chestplate-items">
|
||||
</datalist>
|
||||
</div>
|
||||
<div id="chestplate-slots">
|
||||
X slots
|
||||
</div>
|
||||
<div>
|
||||
<label for="chestplate-powder">Powdering:</label>
|
||||
<input type="text" id="chestplate-powder" name="chestplate-powder" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="center" style="grid-column:3;grid-row:1">
|
||||
<div>
|
||||
<label for="leggings-choice">Leggings:</label>
|
||||
<input list="leggings-items" id="leggings-choice" name="leggings-choice" />
|
||||
<datalist id="leggings-items">
|
||||
</datalist>
|
||||
</div>
|
||||
<div id="leggings-slots">
|
||||
X slots
|
||||
</div>
|
||||
<div>
|
||||
<label for="leggings-powder">Powdering:</label>
|
||||
<input type="text" id="leggings-powder" name="leggings-powder" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="center" style="grid-column:4;grid-row:1">
|
||||
<div id="boots">
|
||||
<label for="boots-choice">Boots:</label>
|
||||
<input list="boots-items" id="boots-choice" name="boots-choice" />
|
||||
<datalist id="boots-items">
|
||||
</datalist>
|
||||
</div>
|
||||
<div id="boots-slots">
|
||||
X slots
|
||||
</div>
|
||||
<div>
|
||||
<label for="boots-powder">Powdering:</label>
|
||||
<input type="text" id="boots-powder" name="boots-powder" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="center" style="grid-column:1;grid-row:2">
|
||||
<label for="ring1-choice">Ring 1:</label>
|
||||
<input list="ring1-items" id="ring1-choice" name="ring1-choice" />
|
||||
<datalist id="ring1-items">
|
||||
</datalist>
|
||||
</div>
|
||||
<div class="center" style="grid-column:2;grid-row:2">
|
||||
<label for="ring2-choice">Ring 2:</label>
|
||||
<input list="ring2-items" id="ring2-choice" name="ring2-choice" />
|
||||
<datalist id="ring2-items">
|
||||
</datalist>
|
||||
</div>
|
||||
<div class="center" style="grid-column:3;grid-row:2">
|
||||
<label for="bracelet-choice">Bracelet:</label>
|
||||
<input list="bracelet-items" id="bracelet-choice" name="bracelet-choice" />
|
||||
<datalist id="bracelet-items">
|
||||
</datalist>
|
||||
</div>
|
||||
<div class="center" style="grid-column:4;grid-row:2">
|
||||
<label for="necklace-choice">Necklace:</label>
|
||||
<input list="necklace-items" id="necklace-choice" name="necklace-choice" />
|
||||
<datalist id="necklace-items">
|
||||
</datalist>
|
||||
</div>
|
||||
<div class="center" style="grid-column:1;grid-row:3">
|
||||
<label for="weapon-choice">Weapon:</label>
|
||||
<input list="weapon-items" id="weapon-choice" name="weapon-choice" />
|
||||
<datalist id="weapon-items">
|
||||
</datalist>
|
||||
</div>
|
||||
<div class="center" style="grid-column:2;grid-row:3">
|
||||
<div id="weapon-slots">
|
||||
X slots
|
||||
</div>
|
||||
<div>
|
||||
<label for="weapon-powder">Weapon powder:</label>
|
||||
<input type="text" id="weapon-powder" name="weapon-powder" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="center" style="grid-column:3;grid-row:3">
|
||||
Calculate
|
||||
</div>
|
||||
<div class="center" style="grid-column:4;grid-row:3">
|
||||
Reset
|
||||
</div>
|
||||
</div>
|
||||
<div class="skillpoints">
|
||||
<div class="center" style="grid-column:1;grid-row:1">
|
||||
<label for="str-skp">Strength:</label>
|
||||
<input type="text" id="str-skp" name="str-skp" />
|
||||
</div>
|
||||
<div class="center" style="grid-column:2;grid-row:1">
|
||||
<label for="dex-skp">Dexterity:</label>
|
||||
<input type="text" id="dex-skp" name="dex-skp" />
|
||||
</div>
|
||||
<div class="center" style="grid-column:3;grid-row:1">
|
||||
<label for="int-skp">Intelligence:</label>
|
||||
<input type="text" id="int-skp" name="int-skp" />
|
||||
</div>
|
||||
<div class="center" style="grid-column:4;grid-row:1">
|
||||
<label for="def-skp">Defense:</label>
|
||||
<input type="text" id="def-skp" name="def-skp" />
|
||||
</div>
|
||||
<div class="center" style="grid-column:5;grid-row:1">
|
||||
<label for="agi-skp">Agility:</label>
|
||||
<input type="text" id="agi-skp" name="agi-skp" />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script src="test.js"></script>
|
||||
</body>
|
||||
</html>
|
4
manifest.json
Normal file
4
manifest.json
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"display": "standalone",
|
||||
"orientation": "portrait"
|
||||
}
|
|
@ -1 +1,4 @@
|
|||
#A workspace for processing info/one-time operations
|
||||
#A workspace for processing info/one-time operations
|
||||
import math
|
||||
for i in range(151):
|
||||
print(-0.0000000066695* math.exp(-0.00924033 * i + 18.9) + 1.0771)
|
303
skillpoints.csv
303
skillpoints.csv
|
@ -1,151 +1,152 @@
|
|||
a,b
|
||||
1,0.01
|
||||
2,0.02
|
||||
3,0.029
|
||||
4,0.039
|
||||
5,0.049
|
||||
6,0.058
|
||||
7,0.067
|
||||
8,0.077
|
||||
9,0.086
|
||||
10,0.095
|
||||
11,0.104
|
||||
12,0.113
|
||||
13,0.122
|
||||
14,0.131
|
||||
15,0.139
|
||||
16,0.148
|
||||
17,0.157
|
||||
18,0.165
|
||||
19,0.173
|
||||
20,0.182
|
||||
21,0.19
|
||||
22,0.198
|
||||
23,0.206
|
||||
24,0.214
|
||||
25,0.222
|
||||
26,0.23
|
||||
27,0.238
|
||||
28,0.246
|
||||
29,0.253
|
||||
30,0.261
|
||||
31,0.268
|
||||
32,0.276
|
||||
33,0.283
|
||||
34,0.29
|
||||
35,0.298
|
||||
36,0.305
|
||||
37,0.312
|
||||
38,0.319
|
||||
39,0.326
|
||||
40,0.333
|
||||
41,0.34
|
||||
42,0.346
|
||||
43,0.353
|
||||
44,0.36
|
||||
45,0.366
|
||||
46,0.373
|
||||
47,0.379
|
||||
48,0.386
|
||||
49,0.392
|
||||
50,0.399
|
||||
51,0.405
|
||||
52,0.411
|
||||
53,0.417
|
||||
54,0.423
|
||||
55,0.429
|
||||
56,0.435
|
||||
57,0.441
|
||||
58,0.447
|
||||
59,0.453
|
||||
60,0.458
|
||||
61,0.464
|
||||
62,0.47
|
||||
63,0.475
|
||||
64,0.481
|
||||
65,0.486
|
||||
66,0.492
|
||||
67,0.497
|
||||
68,0.503
|
||||
69,0.508
|
||||
70,0.513
|
||||
71,0.518
|
||||
72,0.523
|
||||
73,0.528
|
||||
74,0.534
|
||||
75,0.539
|
||||
76,0.543
|
||||
77,0.548
|
||||
78,0.553
|
||||
79,0.558
|
||||
80,0.563
|
||||
81,0.568
|
||||
82,0.572
|
||||
83,0.577
|
||||
84,0.581
|
||||
85,0.586
|
||||
86,0.591
|
||||
87,0.595
|
||||
88,0.599
|
||||
89,0.604
|
||||
90,0.608
|
||||
91,0.613
|
||||
92,0.617
|
||||
93,0.621
|
||||
94,0.625
|
||||
95,0.629
|
||||
96,0.633
|
||||
97,0.638
|
||||
98,0.642
|
||||
99,0.646
|
||||
100,0.65
|
||||
101,0.654
|
||||
102,0.657
|
||||
103,0.661
|
||||
104,0.665
|
||||
105,0.669
|
||||
106,0.673
|
||||
107,0.676
|
||||
108,0.68
|
||||
109,0.684
|
||||
110,0.687
|
||||
111,0.691
|
||||
112,0.694
|
||||
113,0.698
|
||||
114,0.701
|
||||
115,0.705
|
||||
116,0.708
|
||||
117,0.712
|
||||
118,0.715
|
||||
119,0.718
|
||||
120,0.722
|
||||
121,0.725
|
||||
122,0.728
|
||||
123,0.731
|
||||
124,0.735
|
||||
125,0.738
|
||||
126,0.741
|
||||
127,0.744
|
||||
128,0.747
|
||||
129,0.75
|
||||
130,0.753
|
||||
131,0.756
|
||||
132,0.759
|
||||
133,0.762
|
||||
134,0.765
|
||||
135,0.768
|
||||
136,0.771
|
||||
137,0.773
|
||||
138,0.776
|
||||
139,0.779
|
||||
140,0.782
|
||||
141,0.784
|
||||
142,0.787
|
||||
143,0.79
|
||||
144,0.792
|
||||
145,0.795
|
||||
146,0.798
|
||||
147,0.8
|
||||
148,0.803
|
||||
149,0.805
|
||||
150,0.808
|
||||
assigned,ingame,calculated
|
||||
0,0.0,-7.338606692330885e-06
|
||||
1,0.01,0.009899646251607663
|
||||
2,0.02,0.019715508948295213
|
||||
3,0.029,0.029441087603991223
|
||||
4,0.039,0.03907721263048747
|
||||
5,0.049,0.048624706801628115
|
||||
6,0.058,0.05808438532357796
|
||||
7,0.067,0.06745705590441875
|
||||
8,0.077,0.0767435188231318
|
||||
9,0.086,0.08594456699790476
|
||||
10,0.095,0.09506098605385105
|
||||
11,0.104,0.10409355439008561
|
||||
12,0.113,0.11304304324618386
|
||||
13,0.122,0.12191021676804825
|
||||
14,0.131,0.13069583207313296
|
||||
15,0.139,0.13940063931510382
|
||||
16,0.148,0.1480253817478835
|
||||
17,0.157,0.1565707957891258
|
||||
18,0.165,0.16503761108307513
|
||||
19,0.173,0.17342655056288003
|
||||
20,0.182,0.18173833051231592
|
||||
21,0.19,0.189973660626943
|
||||
22,0.198,0.19813324407471433
|
||||
23,0.206,0.20621777755599702
|
||||
24,0.214,0.21422795136307204
|
||||
25,0.222,0.222164449439068
|
||||
26,0.23,0.23002794943637184
|
||||
27,0.238,0.23781912277447081
|
||||
28,0.246,0.24553863469729353
|
||||
29,0.253,0.2531871443300058
|
||||
30,0.261,0.26076530473530024
|
||||
31,0.268,0.26827376296914185
|
||||
32,0.276,0.27571316013602587
|
||||
33,0.283,0.2830841314437169
|
||||
34,0.29,0.2903873062574822
|
||||
35,0.298,0.29762330815384075
|
||||
36,0.305,0.3047927549737901
|
||||
37,0.312,0.3118962588755717
|
||||
38,0.319,0.3189344263869339
|
||||
39,0.326,0.32590785845693104
|
||||
40,0.333,0.3328171505072183
|
||||
41,0.34,0.3396628924829026
|
||||
42,0.346,0.34644566890291206
|
||||
43,0.353,0.3531660589099016
|
||||
44,0.36,0.3598246363197136
|
||||
45,0.366,0.3664219696703567
|
||||
46,0.373,0.37295862227056087
|
||||
47,0.379,0.3794351522478696
|
||||
48,0.386,0.3858521125963057
|
||||
49,0.392,0.3922100512235729
|
||||
50,0.399,0.3985095109978487
|
||||
51,0.405,0.40475102979413424
|
||||
52,0.411,0.41093514054017843
|
||||
53,0.417,0.4170623712619905
|
||||
54,0.423,0.42313324512891115
|
||||
55,0.429,0.42914828049829257
|
||||
56,0.435,0.4351079909597534
|
||||
57,0.441,0.44101288537904015
|
||||
58,0.447,0.4468634679414628
|
||||
59,0.453,0.45266023819495316
|
||||
60,0.458,0.45840369109271695
|
||||
61,0.464,0.46409431703549175
|
||||
62,0.47,0.469732601913429
|
||||
63,0.475,0.47531902714756813
|
||||
64,0.481,0.4808540697309509
|
||||
65,0.486,0.4863382022693453
|
||||
66,0.492,0.4917718930216064
|
||||
67,0.497,0.49715560593964647
|
||||
68,0.503,0.5024898007080566
|
||||
69,0.508,0.5077749327833555
|
||||
70,0.513,0.5130114534328759
|
||||
71,0.518,0.5181998097733035
|
||||
72,0.523,0.5233404448088418
|
||||
73,0.528,0.528433797469046
|
||||
74,0.534,0.5334803026462964
|
||||
75,0.539,0.5384803912329396
|
||||
76,0.543,0.5434344901580676
|
||||
77,0.548,0.5483430224239791
|
||||
78,0.553,0.5532064071422955
|
||||
79,0.558,0.558025059569744
|
||||
80,0.563,0.5627993911436221
|
||||
81,0.568,0.5675298095169159
|
||||
82,0.572,0.5722167185931156
|
||||
83,0.577,0.5768605185606984
|
||||
84,0.581,0.5814616059273056
|
||||
85,0.586,0.5860203735535872
|
||||
86,0.591,0.5905372106867532
|
||||
87,0.595,0.5950125029938078
|
||||
88,0.599,0.5994466325944774
|
||||
89,0.604,0.6038399780938442
|
||||
90,0.608,0.608192914614663
|
||||
91,0.613,0.6125058138293982
|
||||
92,0.617,0.6167790439919543
|
||||
93,0.621,0.6210129699691267
|
||||
94,0.625,0.6252079532717454
|
||||
95,0.629,0.6293643520855481
|
||||
96,0.633,0.6334825213017619
|
||||
97,0.638,0.6375628125474104
|
||||
98,0.642,0.6416055742153288
|
||||
99,0.646,0.6456111514939162
|
||||
100,0.65,0.6495798863966094
|
||||
101,0.654,0.6535121177910819
|
||||
102,0.657,0.6574081814281856
|
||||
103,0.661,0.6612684099706092
|
||||
104,0.665,0.6650931330212878
|
||||
105,0.669,0.6688826771515435
|
||||
106,0.673,0.6726373659289748
|
||||
107,0.676,0.676357519945076
|
||||
108,0.68,0.6800434568426164
|
||||
109,0.684,0.6836954913427596
|
||||
110,0.687,0.6873139352719362
|
||||
111,0.691,0.6908990975884723
|
||||
112,0.694,0.6944512844089634
|
||||
113,0.698,0.697970799034416
|
||||
114,0.701,0.7014579419761423
|
||||
115,0.705,0.7049130109814256
|
||||
116,0.708,0.7083363010589336
|
||||
117,0.712,0.711728104503914
|
||||
118,0.715,0.7150887109231503
|
||||
119,0.718,0.7184184072596882
|
||||
120,0.722,0.7217174778173412
|
||||
121,0.725,0.724986204284958
|
||||
122,0.728,0.72822486576048
|
||||
123,0.731,0.7314337387747685
|
||||
124,0.735,0.7346130973152214
|
||||
125,0.738,0.73776321284916
|
||||
126,0.741,0.7408843543470132
|
||||
127,0.744,0.7439767883052819
|
||||
128,0.747,0.7470407787692924
|
||||
129,0.75,0.7500765873557466
|
||||
130,0.753,0.7530844732750526
|
||||
131,0.756,0.7560646933534624
|
||||
132,0.759,0.7590175020549981
|
||||
133,0.762,0.7619431515031838
|
||||
134,0.765,0.7648418915025662
|
||||
135,0.768,0.7677139695600486
|
||||
136,0.771,0.7705596309060228
|
||||
137,0.773,0.7733791185153069
|
||||
138,0.776,0.7761726731278962
|
||||
139,0.779,0.7789405332695114
|
||||
140,0.782,0.78168293527197
|
||||
141,0.784,0.7844001132933628
|
||||
142,0.787,0.7870922993380516
|
||||
143,0.79,0.7897597232764726
|
||||
144,0.792,0.7924026128647677
|
||||
145,0.795,0.7950211937642291
|
||||
146,0.798,0.7976156895605719
|
||||
147,0.8,0.8001863217830184
|
||||
148,0.803,0.8027333099232168
|
||||
149,0.805,0.8052568714539818
|
||||
150,0.808,0.8077572218478628
|
|
24
styles.css
Normal file
24
styles.css
Normal file
|
@ -0,0 +1,24 @@
|
|||
.header {
|
||||
padding: 2%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.equipment {
|
||||
padding: 4%;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 25px;
|
||||
grid-auto-rows: minmax(60px, auto);
|
||||
}
|
||||
|
||||
.skillpoints {
|
||||
padding: 4%;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(5, 1fr);
|
||||
gap: 5px;
|
||||
grid-auto-rows: minmax(60px, auto);
|
||||
}
|
||||
|
||||
.center {
|
||||
text-align: center;
|
||||
}
|
157
test.js
Normal file
157
test.js
Normal file
|
@ -0,0 +1,157 @@
|
|||
const DB_VERSION = 1;
|
||||
// @See https://github.com/mdn/learning-area/blob/master/javascript/apis/client-side-storage/indexeddb/video-store/index.js
|
||||
|
||||
//const item_fields = [ "name", "displayName", "tier", "set", "slots", "type", "armorType", "color", "lore", "material", "drop", "quest", "restrict", "nDam", "fDam", "wDam", "aDam", "tDam", "eDam", "atkSpd", "hp", "fDef", "wDef", "aDef", "tDef", "eDef", "lvl", "classReq", "strReq", "dexReq", "intReq", "agiReq", "defReq", "hprPct", "mr", "sdPct", "mdPct", "ls", "ms", "xpb", "lb", "ref", "str", "dex", "int", "agi", "def", "thorns", "expoding", "spd", "atkTier", "poison", "hpBonus", "spRegen", "eSteal", "hprRaw", "sdRaw", "mdRaw", "fDamPct", "wDamPct", "aDamPct", "tDamPct", "eDamPct", "fDefPct", "wDefPct", "aDefPct", "tDefPct", "eDefPct", "accessoryType", "fixID", "skin", "category", "spPct1", "spRaw1", "spPct2", "spRaw2", "spPct3", "spRaw3", "spPct4", "spRaw4", "rainbowRaw", "sprint", "sprintReg", "jh", "lq", "gXp", "gSpd" ]
|
||||
|
||||
let db;
|
||||
let items;
|
||||
let reload = false;
|
||||
let armorTypes = [ "helmet", "chestplate", "leggings", "boots" ];
|
||||
let accessoryTypes = [ "ring", "bracelet", "necklace" ];
|
||||
let weaponTypes = [ "wand", "spear", "bow", "dagger", "relik" ];
|
||||
let itemTypes = armorTypes.concat(accessoryTypes).concat(weaponTypes);
|
||||
let itemLists = new Map();
|
||||
for (const it of itemTypes) {
|
||||
itemLists.set(it, []);
|
||||
}
|
||||
let itemMap = new Map();
|
||||
|
||||
function populateItemList(type) {
|
||||
let item_list = document.getElementById(type+"-items");
|
||||
for (const item of itemLists.get(type)) {
|
||||
let el = document.createElement("option");
|
||||
el.value = item;
|
||||
item_list.appendChild(el);
|
||||
}
|
||||
}
|
||||
|
||||
function init() {
|
||||
console.log(items);
|
||||
for (const item of items) {
|
||||
itemLists.get(item.type).push(item.name);
|
||||
itemMap.set(item.name, item);
|
||||
}
|
||||
|
||||
for (const armorType of armorTypes) {
|
||||
populateItemList(armorType);
|
||||
document.getElementById(armorType+"-choice").addEventListener("change", (event) => {
|
||||
let item = itemMap.get(event.target.value);
|
||||
if (item !== undefined) {
|
||||
document.getElementById(armorType+"-slots").textContent = item.slots + " slots";
|
||||
}
|
||||
else {
|
||||
document.getElementById(armorType+"-slots").textContent = "X slots";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let ring1_list = document.getElementById("ring1-items");
|
||||
let ring2_list = document.getElementById("ring2-items");
|
||||
for (const ring of itemLists.get("ring")) {
|
||||
let el1 = document.createElement("option");
|
||||
let el2 = document.createElement("option");
|
||||
el1.value = ring;
|
||||
el2.value = ring;
|
||||
ring1_list.appendChild(el1);
|
||||
ring2_list.appendChild(el2);
|
||||
}
|
||||
|
||||
populateItemList("bracelet");
|
||||
populateItemList("necklace");
|
||||
|
||||
let weapon_list = document.getElementById("weapon-items");
|
||||
for (const weaponType of weaponTypes) {
|
||||
for (const weapon of itemLists.get(weaponType)) {
|
||||
let el = document.createElement("option");
|
||||
el.value = weapon;
|
||||
weapon_list.appendChild(el);
|
||||
}
|
||||
}
|
||||
document.getElementById("weapon-choice").addEventListener("change", (event) => {
|
||||
let item = itemMap.get(event.target.value);
|
||||
if (item !== undefined) {
|
||||
document.getElementById("weapon-slots").textContent = item.slots + " slots";
|
||||
}
|
||||
else {
|
||||
document.getElementById("weapon-slots").textContent = "X slots";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function load_local() {
|
||||
let get_tx = db.transaction('item_db', 'readonly');
|
||||
let get_store = get_tx.objectStore('item_db');
|
||||
let request = get_store.getAll();
|
||||
request.onerror = function(event) {
|
||||
console.log("Could not read local db...");
|
||||
}
|
||||
request.onsuccess = function(event) {
|
||||
console.log("Successfully read local db.");
|
||||
items = request.result;
|
||||
init();
|
||||
}
|
||||
await get_tx.complete;
|
||||
db.close();
|
||||
}
|
||||
|
||||
function clean_item(item) {
|
||||
if (item.displayName === null) {
|
||||
item.displayName = item.name;
|
||||
}
|
||||
}
|
||||
|
||||
async function load() {
|
||||
let url = "https://hppeng-wynn.github.io/compress.json";
|
||||
let result = await (await fetch(url)).json();
|
||||
items = result.items;
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/IDBObjectStore/clear
|
||||
let clear_tx = db.transaction('item_db', 'readwrite');
|
||||
let clear_store = clear_tx.objectStore('item_db');
|
||||
|
||||
await clear_store.clear();
|
||||
await clear_tx.complete;
|
||||
|
||||
let add_tx = db.transaction('item_db', 'readwrite');
|
||||
let add_store = add_tx.objectStore('item_db');
|
||||
let add_promises = [];
|
||||
for (const item of items) {
|
||||
add_promises.push(add_store.add(item, item.name));
|
||||
}
|
||||
add_promises.push(add_tx.complete);
|
||||
Promise.all(add_promises).then((values) => {
|
||||
db.close();
|
||||
init();
|
||||
});
|
||||
}
|
||||
|
||||
let request = window.indexedDB.open('item_db', DB_VERSION);
|
||||
|
||||
request.onerror = function() {
|
||||
console.log("DB failed to open...");
|
||||
};
|
||||
|
||||
request.onsuccess = function() {
|
||||
db = request.result;
|
||||
if (!reload) {
|
||||
console.log("Using stored data...")
|
||||
load_local();
|
||||
}
|
||||
else {
|
||||
console.log("Using new data...")
|
||||
load();
|
||||
}
|
||||
}
|
||||
|
||||
request.onupgradeneeded = function(e) {
|
||||
reload = true;
|
||||
|
||||
let db = e.target.result;
|
||||
|
||||
let objectStore = db.createObjectStore('item_db');
|
||||
|
||||
objectStore.createIndex('item', 'item', {unique: false});
|
||||
|
||||
console.log("DB setup complete...");
|
||||
}
|
||||
|
Loading…
Reference in a new issue