forked from tomcur/ClickerHeroesCalculator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
804 lines (699 loc) · 38 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
<!DOCTYPE html>
<!-- -->
<!-- HAIL BORB -->
<!-- -->
<html>
<head>
<title>Clicker Heroes Optimizer</title>
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Open+Sans">
<link rel="stylesheet" type="text/css" href="css/style.css?v=9">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-slider/7.1.0/css/bootstrap-slider.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.10.0/lodash.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-slider/7.1.0/bootstrap-slider.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.2/rollups/md5.js"></script>
<script src="js/decimal.min.js"></script>
<script src="data/functions.js?v=9"></script>
<script src="data/model.js?v=9"></script>
<script src="js/calc.js?v=9"></script>
<script src="js/utils.js?v=9"></script>
</head>
<body>
<div class="wrapper">
<div class="panel panel-info">
<header class="panel-heading">Note</header>
<div class="panel-body">
<p>
The calculator assumes that, at the very least, you own Siyalatas for idle and hybrid builds, and Fragsworth for active builds.
</p>
<p>
The source code can be found <a href="https://github.com/Beskhue/ClickerHeroesCalculator">here</a>.
</p>
</div>
</div>
<div id="input">
<div class="panel panel-primary">
<header class="panel-heading">Data</header>
<div class="panel-body">
<label>Upload your save file here (Mobile) : </label>
<input type="file" style="display:none"id="files" class="inputfile" name="file" />
<label class="btn btn-primary" style="float:right"for="files">Upload</label>
<label>Paste your game file here:
<textarea id="savedata" style="width: 100%; height: 50px" onclick="this.select()" autofocus></textarea></label>
<div style="float: right; margin-top: 10px;">
<button type="button" id="update" onclick="calculateAndUpdate()" class="btn btn-default">Update</button>
<button type="button" onclick="Import()" class="btn btn-primary" style="float: right;">Import</button>
</div>
<div class="panel-settings">
<div>
<label><input type="checkbox" onclick="Import()" id="addsouls"> Include souls gained after ascension</label>
</div>
<div>
<label><input type="checkbox" onclick="Import()" id="wep8k"> Best hero will be leveled beyond 8,000</label>
</div>
<div>
<label><input type="checkbox" onclick="Import()" id="copyancientlevels"> Copy ancient change to clipboard when selected</label>
</div>
<div>
<label><input type="checkbox" id="displayadvancedconfiguration"> Display advanced configuration</label>
</div>
<hr>
<div>
Build
<label><input type="radio" name="buildmode" onclick="Import()" value="idle" checked="checked"> Idle</label>
<label><input type="radio" name="buildmode" onclick="Import()" value="hybrid" checked="checked"> Hybrid</label>
<label><input type="radio" name="buildmode" onclick="Import()" value="active"> Active</label>
</div>
<div id="hybridratiocontainer">
<label>Ratio Fragsworth/Siyalatas (default: 0.5)<br>
<input id="hybridratio" data-slider-id="hybridratioSlider" type="text" data-slider-min="0.05" data-slider-max="5" data-slider-step="0.05" data-slider-scale="logarithmic" value="0.5"/>
</label>
</div>
</div>
</div>
</div>
<div id="advancedconfiguration" class="panel panel-primary">
<header class="panel-heading">Advanced configuration</header>
<div class="panel-body">
<div>
<label>
Level Revolc<br>
(0 = not at all, 1 = extremely)<br>
<input id="revolcrate" data-slider-id="revolcrateSlider" type="text" data-slider-min="0" data-slider-max="1" data-slider-step="0.1" value="0"/>
</label>
</div>
<div>
<label>
Level skill ancients<br>
(0 = not at all, 1 = extremely)<br>
<input id="skillancientsrate" data-slider-id="skillancientsrateSlider" type="text" data-slider-min="0" data-slider-max="1" data-slider-step="0.1" value="0"/>
</label>
</div>
<div>
<label><input type="checkbox" onclick="Import()" id="keepsoulsforregilding"> Reserve hero souls for regilding</label>
</div>
</div>
</div>
<div id="generatedsavedatacontainer" class="panel panel-primary">
<header class="panel-heading">Save-game output</header>
<div class="panel-body">
<p>This functionality is experimental. Always backup your original save-game. If you notice problems, please notify me as soon as possible.</p>
<label>Import this into Clicker Heroes:
<textarea id="generatedsavedata" style="width: 100%; height: 50px" onclick="this.select()" autofocus></textarea></label></label>
<div class="panel-settings">
<div>
<label><input type="checkbox" onclick="toggleGenerateSaveGameData()" id="generatesavedata"> Enable save-game generation</label>
</div>
</div>
</div>
</div>
</div>
<div role="tabpanel" id="output">
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#tab-ancients" aria-controls="tab-ancients" role="tab" data-toggle="tab">Ancients</a></li>
<li role="presentation"><a href="#tab-outsiders" aria-controls="tab-outsiders" role="tab" data-toggle="tab">Outsiders</a></li>
<li role="presentation"><a href="#tab-other" aria-controls="tab-other" role="tab" data-toggle="tab">Other</a></li>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="tab-ancients">
<div class="panel-heading"></div>
<table id="ancienttbl" class="table">
<thead>
<tr>
<th class="col1">Ancient</th>
<th class="col2">Current</th>
<th class="col3">Goal</th>
<th class="col4">Change</th>
<th class="col5">Cost (HS)</th>
</tr>
</thead>
<tbody>
<tr class="odd_row">
<td class="col1">Hero Souls</td>
<td class="col2"><input type="text" id="soulsin" value="0" onblur="manualHeroSoulEntry();"></td>
<td class="col3"><span id="soulsgoal"></span></td>
<td class="col4"><span id="soulschange"></span></td>
<td class="col5"></td>
</tr>
</tbody>
</table>
</div>
<div role="tabpanel" class="tab-pane" id="tab-outsiders">
<table id="outsidertbl" class="table table-striped">
<thead><tr><th>Outsider</th><th>Current</th></tr></thead>
</table>
</div>
<div role="tabpanel" class="tab-pane" id="tab-other">
<table class="table table-striped">
<tr><td><label for="tp">Transcendent Power</label></td><td><input type="text" id="tp" disabled></td></tr>
<tr><td><label for="ascensionzone">Highest Zone Reached</td><td><input type="text" id="ascensionzone" disabled></td></tr>
<tr><td><label for="tprewardcapzone">TP Reward Cap Zone</label></td><td><input type="text" id="tprewardcapzone" disabled></td></tr>
<tr><td><label for="astotal">Ancient Souls Total</label></td><td><input type="text" id="astotal" disabled></td></tr>
<tr><td><label for="gilds">Number of Gilds</label></td><td><input type="text" id="gilds" disabled></td></tr>
</table>
</div>
</div>
</div>
<div role="tabpanel" id="about">
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#tab-about" aria-controls="tab-about" role="tab" data-toggle="tab">About</a></li>
<li role="presentation"><a href="#tab-faq" aria-controls="tab-faq" role="tab" data-toggle="tab">FAQ</a></li>
<li role="presentation"><a href="#tab-changelog" aria-controls="tab-changelog" role="tab" data-toggle="tab">Changelog</a></li>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="tab-about">
<p>
<em>Calculator for Clicker Heroes v1.0 by <a href="https://www.reddit.com/u/beskhue">/u/beskhue</a>.</em>
</p>
<p>
This calculator uses the <em><a href="https://www.reddit.com/r/ClickerHeroes/comments/4naohc/math_and_transcendance/">Rules of Thumb</a></em> to offer ancient suggestions. The calculator distributes the available hero souls among the available ancients.
</p>
<p>
See also: <a href="https://www.reddit.com/user/Shruikan864">/u/Shruikan864</a>'s <a href="https://www.reddit.com/r/ClickerHeroes/comments/4nox6i/rules_of_thumb_10_spreadsheet/">Rules of Thumb 1.0 Spreadsheet</a> and <a href="https://www.reddit.com/user/sugima">/u/sugima</a>'s <a href="https://www.reddit.com/r/ClickerHeroes/comments/4naohc/math_and_transcendance/">1.0 Rules of Thumb</a>.
</p>
<p>
Data structure is loosely based on the code by <a href="https://philni.neocities.org/ancientssoul.html">/u/philni</a>, which is based on the code by <a href="https://s3-us-west-2.amazonaws.com/clickerheroes/ancientssoul.html">/u/rler</a>, which in turn was based on the original calculator and source from <a href="http://www.rivsoft.net/clicker/ancientssoul">rivsoft</a>. Optimization procedure based on <a href="https://www.reddit.com/user/graceoflives">/u/graceoflives</a>' <a href="https://www.reddit.com/r/ClickerHeroes/comments/4nwf3h/10_ancient_calculator/">calculator</a>. Visit <a href="https://www.reddit.com/r/clickerheroes">/r/clickerheroes</a> for more info.
</p>
</div>
<div role="tabpanel" class="tab-pane" id="tab-faq">
<h3>What is the easiest method to level ancients?</h3>
<p>If you press on the number in the <em>change</em> field, the number changes to a long format and is automatically selected for copying. If you hold "v" when clicking on the corresponding ancient's purchase button, an input field will pop up. Paste the number you just copied into this field, and press "Ok".</p>
<h3>Why does the calculator tell me to level Morgulis more than I am able to?</h3>
<p>It probably doesn't. If you have the outsider Chor'gorloth leveled, all ancients become cheaper, including Morgulis. This means that one level in Morgulis costs less than one soul when buying in bulk.</p>
<h3>After buying the recommended ancients, why do I have more souls left over than the calculator predicts?</h3>
<p>Firstly, when you have many souls to spend the calculator will over-estimate the cost of a few ancients with a "difficult" cost formula. This approximation is accurate enough to yield very good recommendations; calculating it precisely often does not actually make a difference in regard to the number of levels recommended. Only the predicted cost becomes more accurate. Secondly, when you have only few souls to spend the predicted cost is accurate as far as the cost formulae go; there appear to be some issues in-game where an ancient sometimes costs one soul less or more than it should.</p>
<h3>What does this "best hero will be leveled beyond 8,000" mean?</h3>
<p>Level 8,000 is the last level where heroes get a x10 multiplier to their damage. After level 8,000 their damage increase factor is reduced. This affects the optimal distribution of ancient levels. If you level a hero beyond level 8,000 and cannot afford a better hero that has a lower level, then check this box.</p>
<h3>What hybrid ratio should I go with?</h3>
<p>This depends on your personal play style. A good starting point is to go with a ratio of 0.5. This works well if you usually push at the end of a run. If you notice you do not often push, drop to a lower ratio. If you notice you often push for many zones, go higher. Perhaps you only idle at the very start of an ascension. In that case, going higher than a ratio of 1 makes sense.</p>
</div>
<div role="tabpanel" class="tab-pane" id="tab-changelog">
<table class="table table-striped">
<thead>
<tr><th>Date</th><th>Change</th></tr>
</thead>
<tbody>
<tr><td>2016/12/16</td><td>Make optimization process adaptive to make optimization quicker.</td></tr>
<tr><td>2016/12/16</td><td>Add support for very big numbers.</td></tr>
<tr><td>2016/12/09</td><td>Add advanced configuration options: leveling the auxiliary ancients and reserving hero souls for regilding.</td></tr>
<tr><td>2016/12/08</td><td>Add ability to copy suggested ancient level changes directly to the clipboard. Thanks <a href="https://github.com/emiln">emiln</a>!</td></tr>
<tr><td>2016/12/01</td><td>Improve data model.</td></tr>
<tr><td>2016/11/17</td><td>Add Nogardnit.</td></tr>
<tr><td>2016/07/26</td><td>Improve suggestions for the case where Wepwawet will be leveled beyond level 8,000.</td></tr>
<tr><td>2016/07/02</td><td>Add FAQ.</td></tr>
<tr><td>2016/07/01</td><td>Add adjustable hybrid ratio.</td></tr>
<tr><td>2016/06/20</td><td>Implemented much better cost approximation.</td></tr>
<tr><td>2016/06/20</td><td>Implemented quicker and more precise formulae.</td></tr>
<tr><td>2016/06/17</td><td>Update rule for Kumawakamaru.</td></tr>
<tr><td>2016/06/16</td><td>Display TP reward cap zone.</td></tr>
<tr><td>2016/06/16</td><td>Remove Solomon leveling at TP cap based on new calculations.</td></tr>
<tr><td>2016/06/16</td><td>Implemented Solomon leveling at TP cap.</td></tr>
<tr><td>2016/06/16</td><td>Support Atman and Kumawakamaru pre-transcendence (note that optimal RoTs still need to be devised for these ancients).</td></tr>
<tr><td>2016/06/16</td><td>Add method to underlevel Solomon.</td></tr>
<tr><td>2016/06/16</td><td>Solomon calculation is now correct pre-transcendence.</td></tr>
<tr><td>2016/06/15</td><td>Implement easier copying of ancient level changes.</td></tr>
<tr><td>2016/06/15</td><td>If Morgulis is not owned, keep a soul bank.</td></tr>
<tr><td>2016/06/15</td><td>Further improvements to optimization speed. Notably, optimization (for high HS) now runs in constant time.</td></tr>
<tr><td>2016/06/15</td><td>Now correctly takes into account HS requirement to upgrade Siyalatas.</td></tr>
<tr><td>2016/06/15</td><td>Optimization when there are a lot of HS to distribute is now significantly faster.</td></tr>
<tr><td>2016/06/14</td><td>Added support for hybrid and active builds.</td></tr>
<tr><td>2016/06/14</td><td>Initial release.</td></tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<script language="javascript">
$('#files').change(function(evt){
var files = evt.target.files;
for (var i = 0, f; f = files[i]; i++)
{
var reader = new FileReader();
reader.onload = (function(reader)
{
return function()
{
var contents = reader.result;
var lines = contents.split('\n');
var firstIndex = contents.indexOf('{"');
var lastIndex = contents.lastIndexOf('}');
var formattedContent = contents.substring(firstIndex,lastIndex+1);
var base64content = btoa(formattedContent);
var result = sprinkle(base64content) + ANTI_CHEAT_CODE + getHash(base64content);
$('#savedata').val(result);
Import();
}
})(reader);
reader.readAsText(f);
}
})
function getHash(string) {
var charaters = string.split();
charaters.sort();
var sortedCharaters = charaters.join();
return CryptoJS.MD5(sortedCharaters + SALT);
}
function sprinkle(string) {
var characters;
var randomIndex;
var array = string.split("");
var result = [];
var counter = 0;
while (counter < array.length) {
result[counter * 2] = array[counter];
characters = CHARACTERS;
randomIndex = Math.floor(Math.random() * (characters.length - 1));
result[counter * 2 + 1] = characters.substr(randomIndex, 1);
counter++;
}
return result.join("");
}
"use strict";
var strSettingsCheckBox = [
"#addsouls",
"#wep8k",
"#copyancientlevels",
"#displayadvancedconfiguration",
"#keepsoulsforregilding",
"#generatesavedata"
];
var strSettingsRadio = [
"buildmode"
];
var strSettingsList = [
"#hybridratio",
"#revolcrate",
"#skillancientsrate"
];
var strCustomSave = [
];
function LoadAllSettings() {
if (typeof(Storage) !== "undefined") {
for (var i in strCustomSave) {
if (localStorage.hasOwnProperty(i)) {
strCustomSave[i] = localStorage[i];
}
}
for (var i in strSettingsCheckBox) {
var str = strSettingsCheckBox[i];
if (localStorage.hasOwnProperty(str)) {
$(str).prop('checked', localStorage[str]=="true");
}
}
for (var i in strSettingsRadio) {
var str = strSettingsRadio[i];
if (localStorage.hasOwnProperty(str)) {
$('input[name="'+str+'"][value="'+localStorage[str]+'"]').prop('checked', true);
}
}
// Now the other settings.
for (var i in strSettingsList) {
var str = strSettingsList[i];
if (localStorage.hasOwnProperty(str)) {
$(str).val(localStorage[str]);
}
}
}
}
function SaveSettings(strSetting) {
if (typeof(Storage) !== "undefined") {
localStorage[strSetting] = $(strSetting).val();
}
};
function SaveSettingsCheckBox(strSetting) {
if (typeof(Storage) !== "undefined") {
localStorage[strSetting] = $(strSetting).prop('checked');
}
}
function saveBuildMode() {
var strBuildMode = $('input[name="buildmode"]:checked').val();
if (typeof(Storage) !== "undefined") {
localStorage.buildmode = strBuildMode;
}
}
function showHideHybridRatioContainer() {
if($('input[name="buildmode"]:checked').val() == "hybrid") {
$("#hybridratiocontainer").show();
} else {
$("#hybridratiocontainer").hide();
}
}
function showHideAdvancedConfigurationContainer() {
if($("#displayadvancedconfiguration").prop('checked')) {
$("#advancedconfiguration").show();
} else {
$("#advancedconfiguration").hide();
}
}
function showHideGeneratedSaveGameContainer() {
if($("#generatesavedata").prop('checked')) {
$("#generatedsavedatacontainer").show();
} else {
$("#generatedsavedatacontainer").hide();
}
}
$(function () {
$('#addsouls').change(function() {
SaveSettingsCheckBox("#addsouls");
});
$('#wep8k').change(function() {
SaveSettingsCheckBox("#wep8k");
});
$('#copyancientlevels').change(function() {
SaveSettingsCheckBox('#copyancientlevels');
});
$('#displayadvancedconfiguration').change(function() {
SaveSettingsCheckBox('#displayadvancedconfiguration');
});
$("input[name=buildmode]:radio").change(function() {
saveBuildMode();
showHideHybridRatioContainer();
});
$("#hybridratio").change(function() {
SaveSettings("#hybridratio");
});
$("#displayadvancedconfiguration").change(function() {
showHideAdvancedConfigurationContainer();
});
$("#revolcrate").change(function() {
SaveSettings("#revolcrate");
});
$("#skillancientsrate").change(function() {
SaveSettings("#skillancientsrate");
});
$('#keepsoulsforregilding').change(function() {
SaveSettingsCheckBox("#keepsoulsforregilding");
});
$('#generatesavedata').change(function() {
SaveSettingsCheckBox("#generatesavedata");
showHideGeneratedSaveGameContainer();
});
$(window).on("message", function(event) {
$("#savedata").val(event.originalEvent.data);
Import();
});
// Load game data
$.ajax('data/ClickerHeroes_v8448.js', {
complete: function(xhr) {
window.data = $.parseJSON(xhr.responseText);
createObjects(data);
window.Items = {items : {}, slots : {}}; // No relics.
ShowTables();
LoadAllSettings();
// Set up hybrid ratio slider
$('#hybridratio').slider({
formatter: function(value) {
return value;
},
value: Number($('#hybridratio').val())
});
$('#hybridratio').on("slideStop", function() { Import(); });
showHideHybridRatioContainer();
// Set up revolc level rate slider
$('#revolcrate').slider({
formatter: function(value) {
return value;
},
value: Number($('#revolcrate').val())
});
$('#revolcrate').on("slideStop", function() { Import(); });
// Set up skill ancients level rate slider
$('#skillancientsrate').slider({
formatter: function(value) {
return value;
},
value: Number($('#skillancientsrate').val())
});
$('#skillancientsrate').on("slideStop", function() { Import(); });
// Show or hide the advanced configuration container
showHideAdvancedConfigurationContainer();
// Show or hide the generated save game container
showHideGeneratedSaveGameContainer()
}
});
configureDecimal();
});
function configureDecimal() {
Decimal.config({
precision: 20
});
}
function AddAncient(key) {
data.ancients[key].ui = {};
var tr = data.ancients[key].ui.targetBox = $("<tr></tr>");
tr.append($("<td></td>").addClass("col1").append(data.ancients[key].used).append($("<span></span>").text(data.ancients[key].name.substring(0, data.ancients[key].name.indexOf(','))).attr("title", data.ancients[key].name)));
data.ancients[key].level = 0;
data.ancients[key].ui.level = $("<span></span>").text(numberToStringFormatted(0));
data.ancients[key].ui.goal = $("<span></span>").text(numberToStringFormatted(0));
data.ancients[key].ui.change = $("<input></input>").attr("readonly", "readonly").attr("type", "text").addClass("col_change");
data.ancients[key].ui.cost = $("<span></span>").text(numberToStringFormatted(0));
var changeSelectFunction = function() {
$(this).val(numberToClickerHeroesPasteableString(data.ancients[key].extraInfo.optimalLevel.minus(data.ancients[key].level)));
$(this).select();
if (data.settings.copyAncientLevelsToClipboard && document.queryCommandSupported('copy')) {
document.execCommand('copy');
}
};
/* Bind to both the focus and the click event */
data.ancients[key].ui.change.focus(changeSelectFunction);
data.ancients[key].ui.change.click(changeSelectFunction);
data.ancients[key].ui.change.focusout(function() {
$(this).val(numberToStringFormatted(data.ancients[key].extraInfo.optimalLevel.minus(data.ancients[key].level)));
});
tr .append($("<td></td>").addClass("col2").append(data.ancients[key].ui.level))
.append($("<td></td>").addClass("col3").append(data.ancients[key].ui.goal))
.append($("<td></td>").addClass("col4").append(data.ancients[key].ui.change))
.append($("<td></td>").addClass("col5").append(data.ancients[key].ui.cost));
$("#ancienttbl").append(tr);
tr.hide();
}
function addOutsider(key) {
data.outsiders[key].ui = {};
var tr = $("<tr></tr>");
tr.append($("<td></td>").append($("<span></span>").text(data.outsiders[key].name)));
data.outsiders[key].ui.level = $("<span></span>").text(numberToStringFormatted(0));
tr.append($("<td></td>").append(data.outsiders[key].ui.level));
$("#outsidertbl").append(tr);
}
function ShowTables() {
var ancientList = _.keys(data.ancients).sort();
// Ancient Tab
for (var i = 0; i < ancientList.length; i++) {
var key = ancientList[i];
if (!data.ancients[key].maxLevel) {
AddAncient(key);
}
}
for (var i = 0; i < ancientList.length; i++) {
var key = ancientList[i];
if (data.ancients[key].maxLevel) {
AddAncient(key);
}
}
// data.outsiders Tab
for (var k in data.outsiders) {
addOutsider(k);
}
}
var ToPurchase = [1,2,4,8,16,35,70,125,250,500,800,1200,1700,2200,2750,3400,4100,5000,6000,7500,10000,12500,16000,25000,35000,50000,70000,100000,150000,250000,400000];
var ItemTypeMap = {
"1": "siyalatas",
"2": "fragsworth",
"3": "chronos",
"4": "chawedo",
"5": "revolc",
"6": "iris",
"7": "argaiv",
"8": "energon",
"9": "kleptos",
"10": "sniperino",
"11": "berserker",
"12": "hecatoncheir",
"13": "bubos",
"14": "morgulis",
"15": "bhaal",
"16": "dora",
"17": "atman",
"18": "fortuna",
"19": "dogcog",
"20": "pluto",
"21": "mimzee",
"22": "mammon",
"24": "libertas",
"25": "solomon"
};
function SetDifference(a, b) {
var cnt = 0;
for (var k in b) {
if (!a.hasOwnProperty(k)) {
cnt++;
}
}
return cnt;
}
function Import() {
var rawData = decodeSaveGame($("#savedata").val());
// Read on-page settings
data.settings = {};
data.settings.includeSoulsAfterAscension = $("#addsouls").prop("checked");
data.settings.wep8k = $("#wep8k").prop("checked");
data.settings.copyAncientLevelsToClipboard = $("#copyancientlevels").prop("checked");
data.settings.buildMode = $('input[name="buildmode"]:checked').val();
data.settings.hybridRatio = $('#hybridratio').slider('getValue');
data.settings.revolcLevelRate = $('#revolcrate').slider('getValue');
data.settings.skillAncientsLevelRate = $('#skillancientsrate').slider('getValue');
data.settings.keepSoulsForRegilding = $("#keepsoulsforregilding").prop("checked");
// Older saves won't have items.
data.items = rawData.hasOwnProperty("items") ? rawData.items : {items : {}, slots : {}};
data.heroSoulsSacrificed = new Decimal(rawData.heroSoulsSacrificed);
var heroes = rawData.heroCollection.heroes;
var ascensionSouls = new Decimal(0);
for (var k in heroes) {
var id = parseInt(k, 10);
ascensionSouls = ascensionSouls.plus(new Decimal(heroes[k].level));
}
ascensionSouls = ascensionSouls.dividedBy(2000).floor().plus(new Decimal(rawData.primalSouls));
data.ascensionSouls = ascensionSouls;
var levels = {};
for (var i = data.ancientMin; i <= data.ancientMax; i++) {
if (rawData.ancients.ancients.hasOwnProperty(i)) {
levels[i] = true;
}
}
data.heroSouls = new Decimal(rawData.heroSouls);
if (data.settings.includeSoulsAfterAscension) {
data.heroSouls = data.heroSouls.plus(data.ascensionSouls);
}
$("#soulsin").val(numberToString(data.heroSouls.floor()));
// Calculate number of gilds
data.gilds = new Decimal((Number(rawData.epicHeroReceivedUpTo)-90)/10 + Number(rawData.extraGildsAwarded));
for (var k in data.ancients) {
if (data.ancients.hasOwnProperty(k)) {
if (rawData.ancients.ancients[data.ancients[k].id]) {
data.ancients[k].level = new Decimal(rawData.ancients.ancients[data.ancients[k].id].level);
// Currently it's possible to own a decimal number of ancients due to a bug.
// The game treats the ancient level as being rounded down (at least for calculating cost).
// So round down the ancient level to be safe:
data.ancients[k].level = data.ancients[k].level.floor();
} else {
data.ancients[k].level = new Decimal(0);
}
data.ancients[k].ui.level.text(numberToStringFormatted(data.ancients[k].level));
}
}
for (var k in data.outsiders) {
if (data.outsiders.hasOwnProperty(k)) {
if (rawData.outsiders.outsiders[data.outsiders[k].id]) {
data.outsiders[k].level = new Decimal(rawData.outsiders.outsiders[data.outsiders[k].id].level);
} else {
data.outsiders[k].level = new Decimal(0);
}
data.outsiders[k].ui.level.text(numberToStringFormatted(data.outsiders[k].level));
}
}
data.ascensionZone = new Decimal(rawData.highestFinishedZonePersist);
$("#ascensionzone").val(data.ascensionZone);
data.ancientSoulsTotal = new Decimal(rawData.ancientSoulsTotal);
$("#astotal").val(data.ancientSoulsTotal);
var tpAncientSoulsPart = new Decimal(50).minus(new Decimal(49).times(data.ancientSoulsTotal.dividedBy(10000).times(-1).exp()));
var tpPhandoryssPart = new Decimal(50).times(new Decimal(1).minus(data.outsiders["phandoryss"].level.dividedBy(1000).times(-1).exp()));
data.tp = Decimal.max(tpAncientSoulsPart.plus(tpPhandoryssPart), new Decimal(1));
if(! rawData.transcendent) {
data.tp = new Decimal(0);
}
$("#tp").val(numberToString(data.tp));
data.capReached = tpCapReached();
$("#capreached").prop("checked", data.capReached);
$("#gilds").val(data.gilds);
data.useSoulsEnteredManually = false;
calculateAndUpdate();
}
function calculateAndUpdate() {
// Calculate the amount of souls we will use for leveling
if (data.useSoulsEnteredManually) {
data.heroSoulsForLeveling = new Decimal($("#soulsin").val());
} else {
data.heroSoulsForLeveling = data.heroSouls;
}
if (data.settings.keepSoulsForRegilding) {
data.heroSoulsForLeveling = data.heroSoulsForLeveling.minus(data.gilds.times(80));
}
var spentHS = calculate();
display(spentHS);
generateSaveGame(spentHS);
}
function manualHeroSoulEntry() {
data.useSoulsEnteredManually = true;
calculateAndUpdate();
}
function display(spentHS) {
$("#soulsgoal").text(numberToStringFormatted(data.heroSouls.minus(spentHS).floor()));
$("#soulschange").text((spentHS > 0 ? "-" : "") + numberToStringFormatted(spentHS));
for (var k in data.ancients) {
var ancient = data.ancients[k];
if (ancient.extraInfo.optimalLevel) {
ancient.ui.goal.text(numberToStringFormatted(ancient.extraInfo.optimalLevel));
ancient.ui.change.val(numberToStringFormatted(ancient.extraInfo.optimalLevel.minus(ancient.level)));
ancient.ui.cost.text(numberToStringFormatted(ancient.extraInfo.costToLevelToOptimal));
ancient.ui.targetBox.show();
} else {
ancient.ui.targetBox.hide();
}
}
$("#ancienttbl tr:visible").each(function(index, row){
$(row).removeClass('odd_row');
if (index%2==1){ //odd row
$(row).addClass('odd_row');
}
});
$("#tprewardcapzone").val(numberToStringFormatted(zoneToHitCap()));
}
function generateSaveGame(spentHS) {
// Only do this if save-game generation is enabled.
if (!$('#generatesavedata').prop('checked')) {
return;
}
// Only do this if the user did not enter souls manually.
if(data.useSoulsEnteredManually) {
$('#generatedsavedata').val("");
return;
}
var rawData = decodeSaveGame($("#savedata").val());
// Set ancient levels
for (var k in data.ancients) {
var ancient = data.ancients[k];
if (ancient.extraInfo.optimalLevel) {
rawData.ancients.ancients[ancient.id].level = ancient.extraInfo.optimalLevel.floor().toString();
rawData.ancients.ancients[ancient.id].spentHeroSouls = new Decimal(rawData.ancients.ancients[ancient.id].spentHeroSouls).plus(ancient.extraInfo.costToLevelToOptimal).toString();
}
}
// Set hero soul count
rawData.heroSouls = data.heroSouls.minus(spentHS).floor().toString();
// Output save game
$('#generatedsavedata').val(encodeSaveGame(rawData));
}
/* Enables save-game generation.
*/
function enableSaveGameGeneration() {
var msg = "Now enabling generation of save-game output.\n\n"
+ "Using this functionality can be considered cheating. Please do not publicly distribute instructions on how to enable this feature.\n\n"
+ "This functionality is experimental. Use it at your own risk. Always remember to back up your saves.";
console.log(msg);
alert(msg);
$('#generatesavedata').prop('checked', true);
$('#generatesavedata').change();
}
</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-45620982-1', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>