-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript.js
executable file
·2016 lines (1762 loc) · 79.6 KB
/
script.js
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
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
function wiggleOnClick() {
this.disabled = true;
setTimeout(() => this.disabled = false, 900);
nourishment += nourishIncrement;
updateStory("wiggle");
updateResources();
if (firstWiggle) {
unlockAchievement(0); // Unlock Achievement if first wiggling
firstWiggle = false;
//initTone(); // begin music
}
// Randomize the seed for the wiggle effect
var turbulence = document.getElementById('turbulence');
var wiggleOnlyTurbulence = document.getElementById('wiggleOnlyTurbulence');
// Check if the turbulence elements exist before attempting to modify
if (turbulence && wiggleOnlyTurbulence) {
turbulence.setAttribute('seed', Math.random() * 1000);
wiggleOnlyTurbulence.setAttribute('seed', Math.random() * 1000);
// Apply the wiggle filter to the cell
var cell = document.getElementById('cell');
if (cell) {
cell.style.filter = 'url(#glowWiggle)';
}
// Animate the baseFrequency attribute of the feTurbulence primitive in the wiggle filter
var baseFrequency = 0;
var frequencyIncrement = 0.01;
var wiggleAnimation = setInterval(function() {
baseFrequency += frequencyIncrement;
turbulence.setAttribute('baseFrequency', baseFrequency);
wiggleOnlyTurbulence.setAttribute('baseFrequency', baseFrequency); // Apply the same effect to the wiggleOnly filter
if (baseFrequency >= 0.1) {
clearInterval(wiggleAnimation);
//turbulence.setAttribute('baseFrequency', '0'); // Reset the base frequency to stop the wiggle effect
}
}, 52); // animation duration
}
}
function senseOnClick() {
if(nourishment >= 1) {
nourishment--;
information += informationIncrement;
if (senseStoryIndex < senseStoryLines.length && information >= senseStoryLines[senseStoryIndex].information) {
addStoryLine(senseStoryLines[senseStoryIndex].text);
senseStoryIndex++;
}
}
}
function glowOnClick() {
if(information >= 1) {
information--;
warmth += warmthIncrement;
if (glowStoryIndex < glowStoryLines.length && warmth >= glowStoryLines[glowStoryIndex].warmth) {
addStoryLine(glowStoryLines[glowStoryIndex].text);
glowStoryIndex++;
}
}
}
function grabOnClick() {
if(warmth >= 1) {
warmth--;
energy += energyIncrement;
if (grabStoryIndex < grabStoryLines.length && energy >= grabStoryLines[grabStoryIndex].energy) {
addStoryLine(grabStoryLines[grabStoryIndex].text);
grabStoryIndex++;
}
}
}
// ProtoWorm movement
function slitherOnClick() {
let segments = [];
let flagella = [];
for (let i = 1; i < 5; i++) {
segments.push(document.getElementById("protowormsegment-" + i));
flagella.push(document.getElementById("flagella-" + i));
}
let amplitudeSegments = 5; // Max vertical displacement for segments
let amplitudeFlagella = 3; // Smaller vertical displacement for flagella
let frequency = 0.001; // Reduced frequency to slow down the wave
let phaseShift = 0.5; // Controls the delay between segments
let slitherAnimation;
slitherAnimation = setInterval(function() {
for (let i = 0; i < segments.length; i++) {
let yPositionSegments = 400 + amplitudeSegments * Math.sin(frequency * Date.now() + phaseShift * i);
let yPositionFlagella = 400 + amplitudeFlagella * Math.sin(frequency * Date.now() + phaseShift * i);
segments[i].setAttribute("cy", yPositionSegments);
// You may need to adjust how the flagella's position is set, depending on the SVG structure
// flagella[i].setAttribute("cy", yPositionFlagella);
}
}, 20); // Interval duration
document.getElementById("slitherButton").disabled = true; // disable the slither button once activated
displayOnChat("In the gloom of your existence, a transformation occurs. You, once confined to a simple form, find yourself elongated, segmented, complex. The monotonous wiggle of yore gives way to a graceful slither, a dance with shadows in the desolate void. " +
"Yet, with evolution comes realization. You, now gifted with movement, feel the weight of your solitude more profoundly. Each slither is a cry for connection, a yearning for something beyond the barren emptiness. The very ability that grants you freedom becomes a haunting reminder of isolation. " +
"But you endure, for in the dark recesses of existence, resilience is your only companion. You slither onward, a lonely traveler in search of meaning, a spark of life in an otherwise indifferent universe.")
// Optional: You may want to set a condition to stop the slithering effect after some time
setTimeout(displayEvolutionModal, 60000);
}
function addSlitherButton() {
// Create the button element
var slitherButton = document.createElement("button");
// Set the ID and text content
slitherButton.id = "slitherButton";
slitherButton.textContent = "Slither";
// Add the slitherOnClick function as a click event listener
slitherButton.addEventListener("click", slitherOnClick);
// Find the Actions div and append the new button to it
var actionsDiv = document.getElementById("Actions");
actionsDiv.appendChild(slitherButton);
}
function addCrawlButton() {
// Create the button element
var crawlButton = document.createElement("button");
// Set the ID and text content
crawlButton.id = "crawlButton";
crawlButton.textContent = "Crawl";
// Add the crawlOnClick function as a click event listener
crawlButton.addEventListener("click", crawlOnClick);
// Find the Actions div and append the new button to it
var actionsDiv = document.getElementById("Actions");
actionsDiv.appendChild(crawlButton);
}
function removeWiggleButton() {
// Find the wiggle button by its ID
var wiggleButton = document.getElementById("wiggleButton");
// Remove the button from the DOM
if (wiggleButton) {
wiggleButton.remove();
}
}
// ProtoPod Crawl
function crawlOnClick() {
resetLimbPositions(); // reset limbs to origin first to be safe
let group1 = [0, 1, 4, 5]; // IDs of the limbs in the first group (top limbs)
let group2 = [2, 3, 6, 7]; // IDs of the limbs in the second group (bottom limbs)
let limbState = { group1: 0, group2: 0 }; // 0: Initial position, -1: Forward, 1: Backward
function moveLimb(i, direction) {
let limbInfo = protoPodLimbsInfo[i];
let limb = document.getElementById(limbInfo.id);
let outlineLimb = document.getElementById(limbInfo.outlineId);
if (limb && outlineLimb) {
// Random deviation in movement
let randomX = (Math.random() * 10) - 5; // Between -5 and 5
let randomY = (Math.random() * 10) - 5; // Between -5 and 5
// Calculate the new end point with constraints
let newX = limbInfo.originalEndX + (direction * 25) + randomX;
let newY = limbInfo.originalEndY + (direction * 5) + randomY;
// Ensure newX and newY stay within a certain range of the original position
let maxDistance = 20; // Maximum allowed distance from the original position
newX = Math.max(limbInfo.originalEndX - maxDistance, Math.min(newX, limbInfo.originalEndX + maxDistance));
newY = Math.max(limbInfo.originalEndY - maxDistance, Math.min(newY, limbInfo.originalEndY + maxDistance));
// Update the path with the new end point
let newPath = `M${limbInfo.startX} ${limbInfo.startY} Q${limbInfo.controlPointX} ${limbInfo.controlPointY}, ${newX} ${newY}`;
// Set the new path data
limb.setAttribute("d", newPath);
outlineLimb.setAttribute("d", newPath);
// Add transition for smooth movement
limb.style.transition = 'all 0.5s';
outlineLimb.style.transition = 'all 0.5s';
}
}
function moveLimbs(group, groupName, direction) {
group.forEach((limbIndex, index) => {
setTimeout(() => moveLimb(limbIndex, direction), index * 200); // Reduced time to 0.2 seconds before moving the next limb
});
limbState[groupName] = direction; // Update the state of the group
}
let crawlAnimation = setInterval(function() {
if (limbState.group1 === 0 && limbState.group2 === 0) {
moveLimbs(group1, "group1", -1); // Move top limbs forward
} else if (limbState.group1 === -1 && limbState.group2 === 0) {
moveLimbs(group1, "group1", 1); // Move top limbs back to original position
moveLimbs(group2, "group2", -1); // Move bottom limbs forward
} else if (limbState.group1 === 1 && limbState.group2 === -1) {
moveLimbs(group2, "group2", 1); // Move bottom limbs back to original position
}
// Reset the state if both groups are back to original position
if (limbState.group1 === 1 && limbState.group2 === 1) {
limbState.group1 = 0;
limbState.group2 = 0;
}
}, 500); // Animation duration, 2 seconds rest before starting again
document.getElementById("crawlButton").disabled = true; // disable the crawl button once activated
displayOnChat("With limbs reaching and grasping, you move across the barren landscape, a pioneer in a world unexplored. The evolution from mere wiggling to purposeful crawling marks a new chapter in your solitary journey. " +
"Each crawl is a testament to your resilience, a manifestation of life's relentless pursuit of progress. But with this newfound ability, the silence of your existence echoes louder, the absence of companionship more palpable. You reach out, not just to the ground beneath, but to the emptiness around, longing for connection, for something to share this strange dance of life. " +
"Yet, the world remains indifferent to your plea. You are alone but not defeated, for within you burns the undying spirit of life. You crawl forward, not merely a traveler now but a conqueror, forging your path through the wilderness, a beacon of hope in a desolate world.")
setTimeout(displayEvolutionModal, 60000);
}
function hideAllTabContents() {
var tabcontent = document.getElementsByClassName("tabcontent");
for (var i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
}
function deactivateAllTabLinks() {
var tablinks = document.getElementsByClassName("tablinks");
for (var i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
}
function setupActionsTab() {
// Check if the wiggleButton exists before setting the onclick handler
var wiggleButton = document.getElementById("wiggleButton");
if (wiggleButton) {
wiggleButton.onclick = wiggleOnClick;
}
document.getElementById("tendonButton").onclick = tendonOnClick;
document.getElementById("senseButton").onclick = senseOnClick;
document.getElementById("glowButton").onclick = glowOnClick;
document.getElementById("grabButton").onclick = grabOnClick;
}
let sensorsToolTipContent = `
<b>Description:</b> Sense the world in whispers of light and shadow
<br>
<b>Effect:</b> +0.01i per tendon/tick
`
let radiatorsToolTipContent = `
<b>Description:</b> Glow softly, sharing warmth in your lonely existence
<br>
<b>Effect:</b> +0.04 warmth per tendon/tick
`
let mitochondriaToolTipContent = `
<b>Description:</b> Ignite silent stars of energy within your being
<br>
<b>Effect:</b> +0.24 energy per tendon/tick
`
let membraneToolTipContent = `
<b>Description:</b> Erect a Proustian shield, isolating and preserving you
<br>
<b>Effect:</b> +0.03 warmth per tendon/tick
`
let nucleusTipContent = `
<b>Description:</b> Forge an inner sanctuary, where dreams dance in the quiet interlude
<br>
<b>Effect:</b> +0.05 nourishment, +0.04 information, +0.02 energy per tendon/tick
`
let endoplasmicToolTipContent = `
<b>Description:</b> Craft a Daedalian maze, streamlining your inner cosmos
<br>
<b>Effect:</b> +0.08 nourishment, +0.04 energy, +0.02 warmth per tendon/tick
`
let echoChamberToolTipContent = `
<b>Description:</b> Amplify your longing into resonant echoes
<br>
<b>Effect:</b> Increase the power of your echoes
`
let resonanceTendrilsToolTipContent = `
<b>Description:</b> Hear the voice of your surroundings through tendrils attuned to yearning
<br>
<b>Effect:</b> Increase the power of your echoes
`
let sensoryPulsarsToolTipContent = `
<b>Description:</b> Quiver like the still unravished bride of quietness
<br>
<b>Effect:</b> Increase the power of your echoes
`
let monotrichousFlagellaToolTipContent = `
<b>Description:</b> Propel through the abyss with melancholic grace
<br>
<b>Effect:</b> Leads to basic movement
`
let lophotrichousFlagellaToolTipContent = `
<b>Description:</b> Fan out tendrils of hope, making the abyss navigable
<br>
<b>Effect:</b> Halves energy cost for world navigation
`
let spikesToolTipContent = `
<b>Description:</b> Defensive barbs stand as fortresses around your heart
<br>
<b>Effect:</b> +0.2 nourishment, +0.09 energy per tendon/tick
`
let suctionCupsToolTipContent = `
<b>Description:</b> Each moment is a place you've never been, as you cling
<br>
<b>Effect:</b> +0.2 nourishment, +0.09 energy per tendon/tick
`
let featheredAntennaToolTipContent = `
<b>Description:</b> Feathers whisper and flow out like endless rain
<br>
<b>Effect:</b> +0.2 nourishment, +0.09 energy per tendon/tick
`
let synapticGlacialisToolTipContent = `
<b>Description:</b> Enhance your cell workers' information processing abilities with crystal-clear cognition.
<br>
<b>Effect:</b> +0.1 information per cell worker/tick
`;
let calorimetricGranulumToolTipContent = `
<b>Description:</b> Bask in the warmth generated by your cell workers, each a microcosm of thermal energy.
<br>
<b>Effect:</b> +0.1 warmth per cell worker/tick
`;
function setupEvolutionTab() {
setupUpgradeButton("sensorsButton", shouldShowSensorsButton, canPurchaseSensors, purchaseSensors, sensorsToolTipContent);
setupUpgradeButton("radiatorsButton", shouldShowRadiatorsButton, canPurchaseRadiators, purchaseRadiators, radiatorsToolTipContent);
setupUpgradeButton("mitochondriaButton", shouldShowMitochondriaButton, canPurchaseMitochondria, purchaseMitochondria, mitochondriaToolTipContent);
setupUpgradeButton("membraneButton", shouldShowMembraneButton, canPurchaseMembrane, purchaseMembrane, membraneToolTipContent);
setupUpgradeButton("nucleusButton", shouldShowNucleusButton, canPurchaseNucleus, purchaseNucleus, nucleusTipContent);
setupUpgradeButton("endoplasmicButton", shouldShowEndoplasmicButton, canPurchaseEndoplasmic, purchaseEndoplasmic, endoplasmicToolTipContent);
unlockSoulEvolutionUpgradeOne(); // unlocks Spikes, Suction Cups or Feathered Antenna - based on soul traits
setupUpgradeButton("echoChamberButton", shouldShowEchoChamberButton, canPurchaseEchoChamber, purchaseEchoChamber, echoChamberToolTipContent);
setupUpgradeButton("resonanceTendrilsButton", shouldShowResonanceTendrilsButton, canPurchaseResonanceTendrils, purchaseResonanceTendrils, resonanceTendrilsToolTipContent);
setupUpgradeButton("sensoryPularsButton", shouldShowSensoryPulsarsButton, canPurchaseSensoryPulsars, purchaseSensoryPulsars, sensoryPulsarsToolTipContent);
setupUpgradeButton("monotrichousFlagellaButton", shouldShowMonotrichousFlagellaButton, canPurchaseMonotrichousFlagella, purchaseMonotrichousFlagella, monotrichousFlagellaToolTipContent);
setupUpgradeButton("lophotrichousFlagellaButton", shouldShowLophotrichousFlagellaButton, canPurchaseLophotrichousFlagella, purchaseLophotrichousFlagella, lophotrichousFlagellaToolTipContent);
setupUpgradeButton("synapticGlacialisEvolution", shouldShowSynapticGlacialisButton, canPurchaseSynapticGlacialis, purchaseSynapticGlacialis, synapticGlacialisToolTipContent);
setupUpgradeButton("calorimetricGranulumEvolution", shouldShowCalorimetricGranulumButton, canPurchaseCalorimetricGranulum, purchaseCalorimetricGranulum, calorimetricGranulumToolTipContent);
}
// Example of a setup function
function setupUpgradeButton(buttonId, shouldShow, canPurchase, purchaseAction, tooltipContent) {
var button = document.getElementById(buttonId);
if (shouldShow()) {
// Create tooltip container
let tooltipContainer = document.createElement("div");
tooltipContainer.className = "tooltip";
button.parentNode.appendChild(tooltipContainer);
tooltipContainer.appendChild(button);
// Create tooltip text
let tooltipText = document.createElement("span");
tooltipText.className = "tooltiptext";
tooltipText.innerHTML = tooltipContent;
tooltipContainer.appendChild(tooltipText);
// Event listeners for tooltip
button.addEventListener('mousemove', function(e) {
let tooltip = tooltipContainer.querySelector('.tooltiptext');
tooltip.style.left = "120px";
tooltip.style.top = "60px";
});
button.addEventListener('mouseenter', function() {
let tooltip = tooltipContainer.querySelector('.tooltiptext');
tooltip.style.visibility = 'visible';
tooltip.style.opacity = '1';
});
button.addEventListener('mouseleave', function() {
let tooltip = tooltipContainer.querySelector('.tooltiptext');
tooltip.style.visibility = 'hidden';
tooltip.style.opacity = '0';
});
button.style.display = "block";
button.onclick = function() {
if (canPurchase()) {
purchaseAction();
this.style.display = "none";
} else {
indicateFailure(button);
}
};
}
}
// Condition functions
function shouldShowMonotrichousFlagellaButton() {
return echoUses > 8 && !monotrichousFlagellaUpgradePurchased;
}
function canPurchaseMonotrichousFlagella() {
let costNourishment = 7500;
let costInformation = 750;
let costWarmth = 1250;
let costEnergy = 2500;
return nourishment >= costNourishment && information >= costInformation && warmth >= costWarmth && energy >= costEnergy;
}
function shouldShowLophotrichousFlagellaButton() {
return echoUses > 9 && monotrichousFlagellaUpgradePurchased && !lophotrichousFlagellaUpgradePurchased;
}
function canPurchaseLophotrichousFlagella() {
let costNourishment = 15000;
let costInformation = 0;
let costWarmth = 0;
let costEnergy = 15000;
return nourishment >= costNourishment && information >= costInformation && warmth >= costWarmth && energy >= costEnergy;
}
function shouldShowResonanceTendrilsButton() {
return echoUses == 2 && !resonanceTendrilsUpgradePurchased;
}
function canPurchaseResonanceTendrils() {
let costNourishment = 4000;
let costInformation = 650;
let costWarmth = 1750;
let costEnergy = 400;
return nourishment >= costNourishment && information >= costInformation && warmth >= costWarmth && energy >= costEnergy;
}
function shouldShowSensoryPulsarsButton() {
return echoUses == 3 && !sensoryPulsarsUpgradePurchased;
}
function canPurchaseSensoryPulsars() {
let costNourishment = 5000;
let costInformation = 650;
let costWarmth = 2000;
let costEnergy = 500;
return nourishment >= costNourishment && information >= costInformation && warmth >= costWarmth && energy >= costEnergy;
}
function shouldShowNucleusButton() {
return tendons > 3 && !nucleusUpgradePurchased && osmoregulationStudyCompleted;
}
function canPurchaseNucleus() {
return nourishment >= 600 && information >= 100 && warmth >= 200;
}
function shouldShowEndoplasmicButton() {
return tendons > 3 && !endoplasmicUpgradePurchased && osmoregulationStudyCompleted;
}
function canPurchaseEndoplasmic() {
return nourishment >= 1250 && information >= 250 && warmth >= 500;
}
function shouldShowMitochondriaButton() {
return tendons > 2 && !mitochondriaUpgradePurchased && mitoticStudyCompleted;
}
function canPurchaseMitochondria() {
return nourishment >= 1750 && information >= 100 && warmth >= 750;
}
function shouldShowMembraneButton() {
return tendons > 1 && !membraneUpgradePurchased && cellmembraneStudyCompleted;
}
function canPurchaseMembrane() {
return nourishment >= 200 && information >= 40;
}
function shouldShowSensorsButton() {
return tendons > 0 && !sensorUpgradePurchased;
}
function canPurchaseSensors() {
return nourishment >= 50 && information >= 10;
}
function shouldShowRadiatorsButton() {
return tendons > 1 && !radiatorUpgradePurchased;
}
function canPurchaseRadiators() {
return nourishment >= 100 && information >= 50 && warmth >= 20;
}
function shouldShowSpikesButton() {
return tendons > 4 && !spikesUpgradePurchased;
}
function shouldShowSuctionCupsButton() {
return tendons > 4 && !suctionCupsUpgradePurchased;
}
function shouldShowFeatheredAntennaButton() {
return tendons > 4 && !featheredAntennaUpgradePurchased;
}
function canPurchaseSpikes() {
return nourishment >= 1250 && information >= 100 && warmth >= 1750;
}
function canPurchaseSuctionCups() {
return nourishment >= 1750 && information >= 100 && warmth >= 750;
}
function canPurchaseFeatheredAntenna() {
return nourishment >= 1750 && information >= 100 && warmth >= 750;
}
function shouldShowEchoChamberButton() {
return echoUses == 1 && !echoChamberUpgradePurchased;
}
function canPurchaseEchoChamber() {
let costNourishment = 3000;
let costInformation = 650;
let costWarmth = 1500;
let costEnergy = 10000;
return nourishment >= costNourishment && information >= costInformation && warmth >= costWarmth && energy >= costEnergy;
}
function shouldShowSynapticGlacialisButton() {
return snowCapsAnalysed && !synapticGlacialisEvolutionPurchased; // Assuming you have a flag for purchase
}
function shouldShowCalorimetricGranulumButton() {
return sandDunesAnalysed && !calorimetricGranulumEvolutionPurchased; // Assuming you have a flag for purchase
}
// Can purchase functions for new evolutions
function canPurchaseSynapticGlacialis() {
let costBiomites = 20000;
let costZymers = 50000;
return biomites >= costBiomites && zymers >= costZymers;
}
function canPurchaseCalorimetricGranulum() {
let costSludge = 35000;
let costAlgae = 10000;
return sludge >= costSludge && algae >= costAlgae;
}
function purchaseSpikes() {
nourishment -= 1250;
information -= 100;
warmth -= 1750;
spikesUpgradePurchased = true;
displayOnChat("You sprout jagged, defensive barbs. They embody your anger and resilience, a fortress against the pains of existence. Your soul takes physical form, isolating you and keeping the harsh, uncaring abyss at bay.");
addSpikes();
nourishmentPerTendon += 0.2;
energyPerTendon += 0.09;
}
function purchaseSuctionCups() {
nourishment -= 1750;
information -= 100;
warmth -= 750;
suctionCupsUpgradePurchased = true;
displayOnChat("Soft, adhesive pads emerge from your tendrils. A symbol of your empathy and optimism, they hold fast to life's fleeting moments, trying to make each instant last. Yet they also represent your fear of letting go, of losing what little you have.");
addSuctionCups();
nourishmentPerTendon += 0.2;
energyPerTendon += 0.09;
}
function purchaseFeatheredAntenna() {
nourishment -= 1750;
information -= 100;
warmth -= 750;
featheredAntennaUpgradePurchased = true;
displayOnChat("Wisps of delicate feathers adorn your tendrils, extending your senses further than ever before. These feathered extensions symbolize your curiosity and solitude, feeling out for anything—even if it's just the void. Each feather a question, longing for an answer.");
addFeatheredAntenna();
nourishmentPerTendon += 0.2;
energyPerTendon += 0.09;
}
// Purchase actions
function purchaseSensors() {
nourishment -= 50;
information -= 10;
sensorUpgradePurchased = true;
checkResearchTabUnlock();
displayOnChat("A new awareness dawns within you. With the growth of rudimentary sensors, you can now sense the world around you in a way you could not before. The darkness is no longer absolute; you can perceive the faintest stirrings of light and darkness.");
addSensorsToExistingTendons();
informationPerTendon += 0.01;
}
function purchaseRadiators() {
nourishment -= 100;
information -= 50;
warmth -= 20;
radiatorUpgradePurchased = true;
glow();
displayOnChat("Your being hums softly, emitting a newfound light. An unknown, constant warmth is transformed—no longer just a presence, but an embrace your form can share.");
warmthPerTendon += 0.04;
}
function purchaseMitochondria() {
nourishment -= 1750;
information -= 100;
warmth -= 750;
mitochondriaUpgradePurchased = true;
displayOnChat("The birth of mitochondria within you is a silent, solitary event. They pulse with energy, each a lonely star in the cosmos of your being. They provide strength, but also a profound awareness of your solitude.");
addMitochondria();
energyPerTendon += 0.24;
}
function purchaseMembrane() {
nourishment -= 200;
information -= 40;
membraneUpgradePurchased = true;
displayOnChat("A thin barrier forms around you, a membrane. It separates you from the world, accentuates your solitude. Yet, it also protects you, holding your existence intact against the vast, indifferent sea.");
increaseCellMembraneThickness();
warmthPerTendon += 0.03;
}
function purchaseNucleus() {
nourishment -= 600;
information -= 100;
warmth -= 200;
nucleusUpgradePurchased = true;
displayOnChat("A nucleus develops within you, a fortress in your solitary existence. It's the orchestrator of your life, a silent testament to your perseverance. It's your stronghold, standing resilient against the solitude of the depths.");
addNucleus();
nourishmentPerTendon += 0.05;
informationPerTendon += 0.04;
energyPerTendon += 0.02;
}
function purchaseEndoplasmic() {
nourishment -= 1250;
information -= 250;
warmth -= 500;
endoplasmicUpgradePurchased = true;
displayOnChat("A maze-like structure begins to weave throughout your being, the endoplasmic reticulum. It's a solitary path, a lonely network within your existence. Yet it streamlines your functions, easing your struggle in the desolate deep.");
addEndoplasmicReticulum();
nourishmentPerTendon += 0.08;
energyPerTendon += 0.04;
warmthPerTendon += 0.02;
}
function purchaseEchoChamber() {
let costNourishment = 3000;
let costInformation = 650;
let costWarmth = 1500;
let costEnergy = 10000;
nourishment -= costNourishment;
information -= costInformation;
warmth -= costWarmth;
energy -= costEnergy;
echoChamberUpgradePurchased = true;
document.getElementById("echoButton").disabled = false; // Re-enables the echo action
displayOnChat("Your echoes reverberate more powerfully now, amplified by the chamber you've crafted. Each echo returns louder, yet the silence between them deepens.");
addEchoChamber();
}
function purchaseResonanceTendrils() {
let costNourishment = 4000;
let costInformation = 650;
let costWarmth = 1750;
let costEnergy = 400;
nourishment -= costNourishment;
information -= costInformation;
warmth -= costWarmth;
energy -= costEnergy;
resonanceTendrilsUpgradePurchased = true;
document.getElementById("echoButton").disabled = false;
displayOnChat("As you weave the resonance tendrils into your being, you feel a new sensitivity ripple through you. The world feels a shade less distant, each echo now tinged with a whisper of potential.");
addResonanceTendrils();
}
function purchaseSensoryPulsars() {
let costNourishment = 5000;
let costInformation = 20;
let costWarmth = 14;
let costEnergy = 10;
nourishment -= costNourishment;
information -= costInformation;
warmth -= costWarmth;
energy -= costEnergy;
sensoryPulsarsUpgradePurchased = true;
document.getElementById("echoButton").disabled = false;
displayOnChat("Your resonance tendrils pulse in newfound clarity.");
addSensoryPulsars();
}
function purchaseMonotrichousFlagella() {
let costNourishment = 7500;
let costInformation = 750;
let costWarmth = 1250;
let costEnergy = 2500;
nourishment -= costNourishment;
information -= costInformation;
warmth -= costWarmth;
energy -= costEnergy;
monotrichousFlagellaUpgradePurchased = true;
displayOnChat("With the addition of the Monotrichous Flagella, you feel a newfound agility. The solitary whip-like structure propels you with a melancholic grace, enabling you to journey through the vast expanse.");
addMonotrichousFlagella();
}
function purchaseLophotrichousFlagella() {
let costNourishment = 15000;
//let costInformation = 0;
//let costWarmth = 0;
let costEnergy = 15000;
nourishment -= costNourishment;
//information -= costInformation;
//warmth -= costWarmth;
energy -= costEnergy;
lophotrichousFlagellaUpgradePurchased = true;
displayOnChat(
"As the final echo resonates through the vast emptiness, a profound realization dawns upon you. " +
"The weight of solitude and the relentless pursuit of understanding becomes both a blessing and a curse. " +
"The ache of being alone is sharp, but it has also sculpted you, refined you. In the echoing silence, a metamorphosis begins. " +
"From your core, new tendrils of hope emerge. Not just one, but multiple. It's as if the accumulated longing and determination " +
"has given birth to new avenues of exploration. These flagella, like silent companions, fan out from you, each seeking a different direction, " +
"a different future. Together, they symbolize your resilience and adaptability, a testament to your unwavering spirit in the face of despair. " +
"With these new extensions, you feel more grounded, more capable. The vast expanse seems a little less intimidating. " +
"The journey ahead, while still uncertain, feels a tad more navigable. With each wiggle of your new flagella, " +
"you're writing a new chapter of your story, one where you harness the power of solitude to explore, adapt, and thrive."
);
addLophotrichousFlagella();
}
// Placeholder purchase functions for new evolutions
function purchaseSynapticGlacialis() {
biomites -= 20000;
zymers -= 50000;
addSynapticGlacialis();
synapticGlacialisEvolutionPurchased = true;
informationPerWorker += 0.1;
displayOnChat("A frigid silence is broken by a flurry of activity within. The Synaptic Glacialis evolution infuses your cell workers with a crystalline clarity of thought. Information flows like meltwater streams, each droplet a spark of insight in the frozen expanse of your consciousness.");
}
function purchaseCalorimetricGranulum() {
sludge -= 35000;
algae -= 10000;
//addCalorimetricGranulum();
calorimetricGranulumEvolutionPurchased = true;
warmthPerWorker += 0.1;
displayOnChat("From the heart of each grain of sand, a warm resonance spreads through your cell workers. The Calorimetric Granulum evolution turns each one into a beacon of sustenance, radiating life-giving warmth. Desolation gives way to a comforting embrace that fuels your relentless growth.");
}
// Function to determine which post tendon-5 upgrade should be made available based on soul statistics
function unlockSoulEvolutionUpgradeOne() {
if (tendons <= 4) {
return; // No upgrades should be shown if there are 4 or fewer tendons
}
// Find the soul trait with the maximum value
let maxTraitValue = Math.max(anger, empathy, resilience, curiosity, optimism, loneliness);
// Array of soul traits to simplify the next part
const traits = [
{ name: 'anger', value: anger },
{ name: 'empathy', value: empathy },
{ name: 'resilience', value: resilience },
{ name: 'curiosity', value: curiosity },
{ name: 'optimism', value: optimism },
{ name: 'loneliness', value: loneliness },
];
// Sort traits by value in descending order
traits.sort((a, b) => b.value - a.value);
// Determine which upgrade to unlock based on the soul trait with the maximum value
if (traits[0].value === maxTraitValue) {
let highestTrait = traits[0].name;
if (highestTrait === 'anger' || highestTrait === 'resilience') {
if (!spikesUpgradePurchased && !suctionCupsUpgradePurchased && !featheredAntennaUpgradePurchased) {
setupUpgradeButton("spikesButton", shouldShowSpikesButton, canPurchaseSpikes, purchaseSpikes, spikesToolTipContent);
}
}
if (highestTrait === 'empathy' || highestTrait === 'optimism') {
if (!spikesUpgradePurchased && !suctionCupsUpgradePurchased && !featheredAntennaUpgradePurchased) {
setupUpgradeButton("suctionCupsButton", shouldShowSuctionCupsButton, canPurchaseSuctionCups, purchaseSuctionCups, suctionCupsToolTipContent);
}
}
if (highestTrait === 'curiosity' || highestTrait === 'loneliness') {
if (!spikesUpgradePurchased && !suctionCupsUpgradePurchased && !featheredAntennaUpgradePurchased) {
setupUpgradeButton("featheredAntennaButton", shouldShowFeatheredAntennaButton, canPurchaseFeatheredAntenna, purchaseFeatheredAntenna, featheredAntennaToolTipContent);
}
}
}
}
// Utility function to change button color when action fails
function indicateFailure(button) {
button.classList.add("failure");
setTimeout(function() {
button.classList.remove("failure");
}, 300);
}
function openTab(evt, tabName) {
hideAllTabContents();
deactivateAllTabLinks();
document.getElementById(tabName).style.display = "block";
evt.currentTarget.className += " active";
// Set up the onclick handlers here
if (tabName === 'Actions') {
setupActionsTab();
}
if (tabName === 'Evolution') {
setupEvolutionTab();
}
if (tabName === 'Soul') {
setupSoulTab();
maybeDisplaySoulTutorial();
}
if (tabName === 'Solara') {
setupSolaraTab();
}}
/*
// UberWiggle to help with game testing
// Quickly Progresses the game
document.getElementById("uberButton").onclick = function() {
this.disabled = true;
setTimeout(() => this.disabled = false, 100);
nourishment+=1000000;
energy+=1000000;
warmth+=1000000;
information+=1000000;
uberButton();
updateResources();
}
function uberButton() {
let delay = 0;
const interval = 200; // 200ms delay for each action
// Call addTendon() 5 times
for (let i = 0; i < 5; i++) {
setTimeout(() => {
tendonOnClick();
//tendons++;
}, delay);
delay += interval;
}
// Perform other single tasks
setTimeout(() => {
addSensorsToExistingTendons();
sensorUpgradePurchased = true;
checkResearchTabUnlock();
}, delay);
delay += interval;
setTimeout(() => {
glowColor = getTendonColor();
radiatorUpgradePurchased = true;
}, delay);
delay += interval;
setTimeout(() => {
addMitochondria();
mitochondriaUpgradePurchased = true;
}, delay);
delay += interval;
setTimeout(() => {
addNucleus();
nucleusUpgradePurchased = true;
}, delay);
delay += interval;
setTimeout(() => {
increaseCellMembraneThickness();
membraneUpgradePurchased = true;
}, delay);
delay += interval;
setTimeout(() => {
addEndoplasmicReticulum();
endoplasmicUpgradePurchased = true;
}, delay);
delay += interval;
setTimeout(() => {
addSpikes();
spikesUpgradePurchased = true;
}, delay);
delay += interval;
// Call emitEcho() 10 times
for (let i = 0; i < 10; i++) {
setTimeout(() => {
emitEcho();
// After the first echo, add the Echo Chamber
if (i == 0) {
addEchoChamber();
echoChamberUpgradePurchased = true;
}
// After the second echo, add the Resonance Tendrils
if (i == 1) {
addResonanceTendrils();
resonanceTendrilsUpgradePurchased = true;
}
// After the third echo, add the Resonance Tendrils
if (i == 2) {
addSensoryPulsars();
sensoryPulsarsUpgradePurchased = true;
}
if (i == 7) { // After the 8th echo, apply monotrichous flagella
addMonotrichousFlagella();
monotrichousFlagellaUpgradePurchased = true;
}
if (i == 8) { // After the 9th echo, apply lophotrichous flagella
lophotrichousFlagellaUpgradePurchased = true;
addLophotrichousFlagella();
}
}, delay);
delay += interval;
}
cellworkers+=50;
totalcellworkers+=50;
boostTF();
icecaveDiscovered = true;
enableViewSwitchIfAppropriate();
populateResearchTab(); // Unlock more research
}
*/
document.getElementById("wiggleButton").onclick = function() {
this.disabled = true;
setTimeout(() => this.disabled = false, 100);
nourishment++;
if(nourishment <= 10) {
updateStory("wiggle");
}
updateResources();
}
function unlockSolaraTab() {
// Exit the function if vision is already unlocked
if (visionUnlocked) {
return;
}
// Unhide the 'Solara' tab button only if Solara has been analyzed
if (solaraAnalysed) {
document.getElementById("solaraTabButton").style.display = "inline-block";
} else {
console.log("Solara has not been analyzed yet.");
}
}
// Function to handle arrow key presses for movement
function handleArrowKeyPress(event) {
if (currentView !== 'discovery' || !geomagneticSensingCompleted) {
return; // Only allow arrow key navigation in discovery view if geomagneticSensingCompleted is true
}
switch (event.key) {
case 'ArrowUp':
movePlayer(0, -30);
break;
case 'ArrowRight':
movePlayer(30, 0);
break;
case 'ArrowDown':
movePlayer(0, 30);
break;
case 'ArrowLeft':
movePlayer(-30, 0);
break;
default:
break; // Do nothing if it's not an arrow key
}
}
// Function to allow switching between the cell and map views
function switchView(view) {
console.log("switchView called with view="+view);
if (view === currentView) {
return;
}
var container = document.getElementById('container');
var map = document.getElementById('map');