· 6 years ago · Mar 10, 2019, 07:34 PM
1<html>
2<style>
3 body {
4 background-color: grey;
5 }
6</style>
7
8<head>
9<script type="text/javascript">
10
11tierSizes=[6,4,3,2]; //tier 4,3,2,1
12armorSlots=["Head","Shoulders","Chest"];
13traits=[
14 ["Impassive Visage","desc","classes","tier","0"], //0name, 1description, 2classes/specs, 3tier, 4selected(for script)
15 ["Strength of Spirit","desc","classes","tier","0"],
16 ["Winds of War","desc","classes","tier","0"],
17 ["Blood Siphon","desc","classes","tier","0"],
18 ["Blood Rite","desc","classes","tier","0"],
19 ["Staggering Strikes","desc","classes","tier","0"],
20 ["Fit to Burst","desc","classes","tier","0"],
21 ["Boiling Brew","desc","classes","tier","0"],
22 ["Longstrider","desc","classes","tier","0"],
23 ["Bulwark of the Masses","desc","classes","tier","0"],
24 ["On My Way","desc","classes","tier","0"],
25 ["Shimmering Haven","desc","classes","tier","0"],
26 ["Azerite Globules","desc","classes","tier","0"],
27 ["Rezan's Fury","desc","classes","tier","0"],
28 ["Training of Niuzao","desc","classes","tier","0"],
29 ["Elusive Footwork","desc","classes","tier","0"],
30 ["Self Reliance","desc","classes","tier","0"],
31 ["Earthlink","desc","classes","tier","0"],
32 ["Strength in Numbers","desc","classes","tier","0"],
33 ["Treacherous Covenant","desc","classes","tier","0"],
34 ["Auto-Self-Cauterizer","desc","classes","tier","0"],
35 ["Personal Absorb-o-tron","desc","classes","tier","0"],
36 ["Unstable Flames","desc","classes","tier","0"],
37 ["Ablative Shielding","desc","classes","tier","0"],
38 ["Synaptic Spark Capacitor","desc","classes","tier","0"],
39 ["Ricocheting Infatable Pyrosaw","desc","classes","tier","0"],
40 ["Exit Strategy","desc","classes","tier","0"],
41 ["Gemhide","desc","classes","tier","0"],
42 ["Lifespeed","desc","classes","tier","0"],
43 ["Gutripper","desc","classes","tier","0"],
44 ["Meticulous Scheming","desc","classes","tier","0"],
45 ["Sweep the Leg","desc","classes","tier","0"],
46 ["Resounding Protection","desc","classes","tier","0"],
47 ["Overwhelming Power","desc","classes","tier","0"],
48 ["Incite the Pack","desc","classes","tier","0"],
49 ["Straight, No Chaser","desc","classes","tier","0"],
50 ["Thunderous Blast","desc","classes","tier","0"],
51 ["Azerite Veins","desc","classes","tier","0"],
52 ["Elemental Whirl","desc","classes","tier","0"],
53 ["Bonded Souls","desc","classes","tier","0"],
54 ["Vampiric Speed","desc","classes","tier","0"],
55 ["Seductive Power","desc","classes","tier","0"],
56 ["Crystalline Carapace","desc","classes","tier","0"],
57 //["Fit To Burst","desc","classes","tier","0"], duplicate. Items edited and fixed.
58 ["Filthy Transfusion","desc","classes","tier","0"]
59]
60allItems=[
61 /*
62 ["TestTestName", //item name
63 [41,42], //tier4 traits (outer ring)
64 [31,32], //tier3 traits
65 [21,22,23], //tier2 traits
66 [11,12], //tier1 traits (inner ring)
67 [370,385,400,415], //item levels
68 [0]], //armor type (0=head 1=shoulders 2=chest) use armorSlots to interpret
69 */
70 ["Blood Bog Headcover",
71 [6,7],
72 [4,5],
73 [2,3],
74 [0,1],
75 [350,355,360,365,370,375,380,385,390,400,405,410,415],
76 [0]],
77 ["Gonk Outrunner Mask",
78 [14,15],
79 [7,13],
80 [10,11,12],
81 [8,9],
82 [350,355,360,365,370,375,380,385,390,400,405,410,415],
83 [0]],
84 ["Cowl of Righteous Resolve",
85 [7,15],
86 [19,6],
87 [17,18,10],
88 [1,16],
89 [350,355,360,365,370,375,380,385,390,400,405,410,415],
90 [0]],
91 ["Charged SP1-R1-73D Gearspun Goggles",
92 [7,5],
93 [24,25],
94 [22,23],
95 [20,21],
96 [350,355,360,365,370,375,380,385,390,400,405,410,415],
97 [0]],
98 ["Pistoleer's Spaulders",
99 [15,5],
100 [14,30],
101 [28,29],
102 [26,27],
103 [350,355,360,365,370,375,380,385,390,400,405,410,415],
104 [1]],
105 ["Gonk Outrunner Shoulderguards",
106 [35,5],
107 [34,15],
108 [33,28],
109 [31,32],
110 [350,355,360,365,370,375,380,385,390,400,405,410,415],
111 [1]],
112 ["Deathsnap Shoulderguards",
113 [15,5],
114 [36,6],
115 [29,11],
116 [27,16],
117 [350,355,360,365,370,375,380,385,390,400,405,410,415],
118 [1]],
119 ["Blood Bog Shoulderpads",
120 [14,15],
121 [35,4],
122 [22,10,37],
123 [26,32],
124 [350,355,360,365,370,375,380,385,390,400,405,410,415],
125 [1]],
126 ["Mestrah's Singing Spaulders",
127 [7,6],
128 [14,19],
129 [29,11],
130 [31,27],
131 [350,355,360,365,370,375,380,385,390,400,405,410,415],
132 [1]],
133 ["Phantom Stalker Shoulders",
134 [35,14],
135 [39,5],
136 [38,2],
137 [32,31],
138 [350,355,360,365,370,375,380,385,390,400,405,410,415],
139 [1]],
140 ["Grongpelt Vest",
141 [15,7],
142 [35,39],
143 [23,12],
144 [26,9],
145 [350,355,360,365,370,375,380,385,390,400,405,410,415],
146 [2]],
147 ["Vestments of Indomitable Will",
148 [5,14],
149 [15,41],
150 [3,28],
151 [40,1],
152 [350,355,360,365,370,375,380,385,390,400,405,410,415],
153 [2]],
154 ["Blood Bog Wraps",
155 [7,15],
156 [6,43],
157 [17,42],
158 [27,8],
159 [350,355,360,365,370,375,380,385,390,400,405,410,415],
160 [2]],
161 ["Gonk Outrunner Vest",
162 [14,15],
163 [35,34],
164 [29,18],
165 [40,16],
166 [350,355,360,365,370,375,380,385,390,400,405,410,415],
167 [2]]
168];
169items=allItems.slice();
170traitsSel=new Array();
171r=new Array();
172freeChoice="any";
173
174function startHere() {
175 printTraits();
176 printItems();
177 printButtons();
178 printR();
179}
180
181function printTraits() {
182 output="<table border='1'>";
183 for(i=0;i<traits.length;i++){
184 output+="<tr><td>"+i+"</td>";
185 for(j=0;j<traits[i].length;j++){
186 output+="<td>"+traits[i][j]+"</td>";
187 }
188 output+="</tr>";
189 }
190 output+="</table>";
191 document.getElementById("traitsList").innerHTML=output;
192}
193function printItems() {
194 output="";
195 for(i=0;i<allItems.length;i++){
196 output+="<tr style='color: black;'><td><input type='checkbox' checked='checked' onclick='javascript:toggleItem("+i+");'/></td>";
197 output+="<td>"+allItems[i][0]+"</td>"; //item name
198 output+="<td>"+armorSlots[allItems[i][6]]+"</td>"; // item armor slot
199 //dropdownmenu for ilvl (looping through possible ilvls)
200 output+="<td><select>"; for(j=0;j<allItems[i][5].length;j++){output+="<option>"+allItems[i][5][j]+"</option>";} output+="</select></td>";
201 //traits of each tier. Assume all traits are in the database. Output N/A if missing. (Right now we only have brewmaster traits in DB)
202 for(j=1;j<5;j++){
203 for(k=0;k<tierSizes[j-1];k++){
204 output+="<td>";
205 if(allItems[i][j][k]!=null){output+=traits[allItems[i][j][k]][0];}else{output+="N/A";}
206 output+="</td>";
207 }
208 }
209 output+="</tr>";
210 }
211 //write
212 document.getElementById("itemsTable").innerHTML=output;
213}
214function printButtons() {
215 /*
216 approach
217 loop through r.
218 extract all traits (don't care about tier/cross-item duplicate issues: those should be handled in the processing of r. Also we're making 1 choice at a time, so duplicates disappear down the line)
219 deduct from this extraction the selected traits.
220 remove duplicates
221 what remains are the available traits on the items in r. Print those to available traits buttons.
222 print selected traits to selected traits buttons.
223
224 Special case: if r and traitsSel are empty, then just print all available and zero in selected.
225 */
226 at=new Array();
227 output1="";
228 output2="";
229 //alert("r: "+r.length +" - traitsSel: "+traitsSel.length);
230 if(r.length>0 && traitsSel.length>0){
231 //available traits
232 //each permutation
233 for(i=0;i<r.length;i++){
234 //each item in the permutation
235 for(j=0;j<r[i].length;j++){
236 //each tier in the item
237 for(k=1;k<5;k++){
238 //each trait in the tier
239 for(l=0;l<items[r[i][j]][k].length;l++){
240 //write to at
241 at[at.length]=items[r[i][j]][k][l];
242 }
243 }
244 }
245 }
246 //deduct selected traits FLAG: Make it, so that it only removes traits once.
247 for(i=at.length-1;i>=0;i--){
248 for(j=0;j<traitsSel.length;j++){
249 if(at[i]==traitsSel[j]){at.splice(i,1);}
250 }
251 }
252 //remove duplicates (do we want to count them for display on buttons? Nah)
253 at=removeDuplicates(at);
254 //produce buttons from at
255 for(i=0;i<at.length;i++){
256 output1+="<input onclick=\"javascript:selectTrait("+at[i]+");\" type='button' value=\""+at[i]+":"+traits[at[i]][0]+"\"/>";
257 }
258
259 //selected traits
260 //produce buttons from selected traits
261 for(i=0;i<traitsSel.length;i++){output2+="<input onclick=\"javascript:deselectTrait("+traitsSel[i]+");\" type='button' value=\""+traitsSel[i]+":"+traits[traitsSel[i]][0]+"\"/>";}
262 }
263 else{
264 //if(items.length==allItems.length){alert(items[0]);}
265 //This is not simply outputting all traits: If we toggled an item, then we don't want those traits. So run through items, extract traits, remove duplicates, and print
266 //each item
267 for(i=0;i<items.length;i++){
268 //each tier in the item
269 for(j=1;j<5;j++){
270 //each trait in the tier
271 for(k=0;k<items[i][j].length;k++){
272 //write to at
273 at[at.length]=items[i][j][k];
274 }
275 }
276 }
277 //remove duplicates
278 at=removeDuplicates(at);
279 //produce buttons from at
280 at.sort();
281 for(i=0;i<at.length;i++){
282 output1+="<input onclick=\"javascript:selectTrait("+at[i]+");\" type='button' value=\""+at[i]+":"+traits[at[i]][0]+"\"/>";
283 }
284 //output1="";for(i=0;i<traits.length;i++){output1+="<input onclick=\"javascript:selectTrait("+i+");\" type='button' value=\""+i+":"+traits[i][0]+"\"/>";}
285
286 //selected traits is simply empty.
287 output2+="No selected traits.";
288 }
289 document.getElementById("traitsAvailable").innerHTML=output1;
290 document.getElementById("traitsSelected").innerHTML=output2;
291
292 /*
293 output1="";
294 output2="";
295
296 for(i=0;i<traits.length;i++){
297 tempOutput="<input onclick=\"javascript:selectTrait("+i+");\" type='button' value=\""+i+":"+traits[i][0]+"\"/>";
298 if(traits[i][4]==0){output1+=tempOutput;}else{output2+=tempOutput;}
299 }
300 document.getElementById("traitsAvailable").innerHTML=output1;
301 document.getElementById("traitsSelected").innerHTML=output2;
302 */
303 /*
304 note for printButtons():
305 this will have to update according to the traits on the items that selected for. -- That is a smaller selection, not just all non-selected.
306 this means the traitsAvailable output buttons will need to be sourced differently: Run through items, grab their traits, deduct selected traits (once or all? makes sense only once) and output reamining traits to buttons.
307 */
308}
309function printR() {
310 output="";
311 for(i=0;i<r.length;i++){
312 output+="<tr><td>"+i+"</td><td>"+items[r[i][0]][0]+"</td><td>a</td><td>"+items[r[i][1]][0]+"</td><td>b</td><td>"+items[r[i][2]][0]+"</td><td>c</td></tr>";
313 }
314 if(output==""){output="<tr><td colspan='7'>No item sets found with these traits or no traits selected.</td></tr>";}
315 document.getElementById("results").innerHTML=output;
316 //document.getElementById("resultsRaw").innerHTML=r;
317}
318
319function selectTrait(n) {
320 //alert("Selected "+traits[n][0]);
321 traits[n][4]=Math.abs((traits[n][4]*2-2)/2);//funny little math to make 0->1 and 1->0
322 //alert("items with this trait: "+getItemsByTrait(n));
323
324 traitsSel[traitsSel.length]=n;
325 //printTraits();
326 /*
327 branching tree approach
328 start with selected trait #1.
329 loop through items, find all items with that trait
330 for each item, create a branch in the tree
331 go on to trait #2
332 for each branch created previously, go through items (only the two other armor types), looking for items with trait #2
333 for each item create a new branch below the previous branch
334 repeat for last armor type
335 issue: this will only really look for 3 traits on 3 different items. Need some way to also look for multiple traits on 1 item.
336
337 however this *does* create permutations (all permutations?) of a number of selected traits -- maybe we can then apply a scoring mechanism to check for more traits among these permutations?
338
339 what we maybe want is some permutation stuff happening that can be evaluated afterwards (or during creation)
340
341 would it help if we eliminated all items with NONE WHATSOEVER of the selected traits? Or created a new selection of items with the selected traits? Eh, don't think so.
342 long answer: If we end up solving this in n^2 time, then this elimination will help, as it reduces n. But a method exists that can solve it in n time. So n^2 (all permutations) is sort of last resort. And not very pretty. And doesn't scale well with growing DB. Probably never gonna be a problem for us, but eh. For curiosity's sake, y'know.
343 for the n time solution, this elimination doesn't really do anything.
344
345
346
347 note for printButtons():
348 this will have to update according to the traits on the items that selected for. -- That is a smaller selection, not just all non-selected.
349 this means the traitsAvailable output buttons will need to be sourced differently: Run through items, grab their traits, deduct selected traits (once or all? makes sense only once) and output reamining traits to buttons.
350 */
351 pickItems();
352 printButtons();
353}
354function deselectTrait(n) {
355 hit=0;
356 for(i=traitsSel.length-1;i>=0;i--){
357 if(traitsSel[i]==n){traitsSel.splice(i,1);hit++;}
358 }
359 if(hit==0){alert("Error in function deselectedTrait: Trait ("+n+") could not be found in traitsSel.")}
360 pickItems();
361 printButtons();
362}
363function toggleItem(i) {
364 alert("toggle "+allItems[i][0]);
365 for(j=items.length-1;j>=0;j--){
366 if(items[j][0]==allItems[i][0]){items.splice(j,1);}
367 }
368 pickItems();
369 printButtons();
370}
371
372function pickItems() {
373 r=new Array();
374 /*
375 populating r:
376 first row: all heads
377 second row: all shoulders
378 third row: all chests
379 */
380
381 //stop if no traits are selected
382 if(traitsSel.length>0){
383 for(i=0;i<items.length;i++){
384 if(items[i][6]==0){
385 for(j=0;j<items.length;j++){
386 if(items[j][6]==1){
387 for(k=0;k<items.length;k++){
388 if(items[k][6]==2){
389 r[r.length]=[i,j,k];
390 }
391 }
392 }
393 }
394 }
395 }
396
397 //these next evaluations can maybe be built into the permutations creator above, but let's keep them seperated for now.
398 //issue: multiple traits in same tier of an item (ie. fit to burst + boiling brew)
399 //issue: same trait on multiple items (ie. boiling brew on head and chest): Here we want a permutation for each version
400
401 //but let's start easy
402 //eliminate permutation if it doesn't have all selected traits
403
404
405 for(i=r.length-1;i>=0;i--){
406 t=traitsSel.slice();
407 for(j=t.length-1;j>=0;j--){
408 for(k=0;k<r[i].length;k++){
409 //tier 1-4
410 for(l=1;l<5;l++){
411 //each tier ring, this one is complicated because of the item references
412 for(m=0;m<items[r[i][k]][l].length;m++){
413 if(items[r[i][k]][l][m]==t[j]){t.splice(j,1);}
414 }
415 }
416 }
417 }
418 if(t.length>0){r.splice(i,1);}
419 }
420
421
422
423 }
424 printR();
425}
426
427function removeDuplicates(inputArray) {
428 //this function I understand, so I like it. But a prettier function is this: traitsUnique=traits.filter((v,i) => traits.indexOf(v)===i);
429 return inputArray.filter(function(v,i){if(inputArray.indexOf(v)===i){return true;}});
430}
431
432//returns array with all items with trait
433function getItemsByTrait(trait) {
434 a=new Array();
435 for(i=0;i<items.length;i++){
436 for(j=1;j<5;j++){
437 for(k=0;k<items[i][j].length;k++){
438 if(items[i][j][k]==trait){a[a.length]=i;}
439 }
440 }
441 }
442 return a;
443}
444
445/*
446
447pickItems prototype
448all permutations approach
449build all permutations of
450 all head x all shoulders x all chests
451 big array, lots of useless combinations
452 task is now to evaluate and eliminate
453eliminate all permutations that don't have all selected traits (this step may not be necessary, as we do further eliminations below, but whatever, nice to do it, so we can get something to print)
454and what fucking now
455 issue: double traits on same tier. Say an item has 2 important traits on tier 4. But we can only pick one. Fuck.
456*/
457</script>
458</head>
459
460<body onload="javascript:startHere();">
461
462<p>Azerite necklace level</p>
463<select name="necklevel">
464 <option value="20">20</option><option value="21">21</option><option value="22">22</option><option value="23">23</option><option value="24">24</option><option value="25">25</option>
465 <option value="26">26</option><option value="27">27</option><option value="28">28</option><option value="29">29</option><option value="30">30</option>
466 <option value="31">31</option><option value="32">32</option><option value="33">33</option><option value="34">34</option><option value="35">35</option>
467 <option value="36">36</option><option value="37">37</option><option value="38">38</option><option value="39">39</option><option value="40">40</option>
468 <option value="41">41</option><option value="42">42</option><option value="43">43</option><option value="44">44</option><option value="45">45</option>
469 <option value="46">46</option><option value="47">47</option><option value="48">48</option><option value="49">49</option><option value="50">50</option>
470</select>
471
472<table border="1">
473 <thead><tr><th></th><th>Name</th><th>Slot</th><th>ilvl</th><th colspan='6'>Tier 4</th><th colspan='4'>Tier 3</th><th colspan='3'>Tier 2</th><th colspan='2'>Tier 1</th></tr></thead>
474 <tbody id="itemsTable">
475 </tbody>
476</table>
477<hr/>
478<table border="1">
479 <thead><tr><th>Available traits</th></tr></thead>
480 <tbody><tr><td id="traitsAvailable"></td></tr></tbody>
481 <thead><tr><th>Selected traits</th></tr></thead>
482 <tbody><tr><td id="traitsSelected"></td></tr></tbody>
483</table>
484<hr/>
485<table border="1">
486 <thead><tr><th>i</th><th>Head Name</th><th>Traits</th><th>Shoulders name</th><th>Traits</th><th>Chest Name</th><th>Traits</th></tr></thead>
487 <tbody id="results">
488 </tbody>
489</table>
490<p id="resultsRaw"></p>
491<hr/>
492<p id="traitsList"></p>
493
494</body>
495
496</html>