-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathValues.js
More file actions
1749 lines (1717 loc) · 59.3 KB
/
Values.js
File metadata and controls
1749 lines (1717 loc) · 59.3 KB
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
import {skill, structure} from './Classes.js';
import {ref} from 'vue';
import {deepClone, format} from './Functions.js';
import loc from './Localization.js';
import {save} from './Save.js';
/*baseEffect(l, e){return 0.1 * l * e}, //this.effects.stat1.baseEffect(), baseEffect = linear additive modifier for stats.
effect(l, e){return 1 + (0.01 * l * e)}, //effect = multiplicative modifier for stats (can go below 1 for a penalty),
studyEffect(l, e){return 1 + (0.02 * l * e)}, //studyEffect = multiplicative modifier for stats (can go below 1 for a penalty) only affects study rate for items dependent on the skill.
//price(l, e){return 1.01 ** (l * e)}, //price = multiplicative price divider for items dependent on the stat, divides amount of exp needed to get a level based on how dependent the skill is. To be removed or reworked as the effect is too complicated.
skillCreep(l, e){return 1.001 ** (l * e)}, //skillCreep = multiplicative cost creep divider for skills, reduces the speed at which the experience requirement goes up with every level
skillEffect(l, e){return 1 + (0.01 * l)}, //skillEffect = multiplicative effect modifier for skills, affects the "e" value. (additive multiplier should not be needed?)
skillBaseLevel(l, e){return 0.1 * l * e}, //skillLevel = additive level modifier for skills, increases the "l" value.
skillLevel(l, e){return 1 + (0.01 * l * e)}, //skillLevel = multiplicative level modifier for skills, increases the "l" value.
skillTagEffect(l){return 1 + (0.01 * l)} //skillTagEffect = multiplicative effect modifier for all skills that have a matching tag. Affects the "e" value.
skillTagStudy(l){return 1 + (0.01 * l)} //skillTagStudy = multiplicative exp modifier for all skills that have a matching tag.*/
export const statValues = ref({
effect:{}, //stat multiplicative effect
baseEffect:{}, //stat additive effect
skillEffect:{}, //skill multiplicative effect
skillStudy:{}, //skill multiplicative study rate
skillBaseLevel:{}, //skill free extra base level
skillLevel:{}, //skill free extra multiplicative level
skillTagEffect:{}, //skill tag multiplicative effect
skillTagStudy:{}, //skill tag multiplicative study rate
structureEffect:{}, //structure multiplicative effect
structureStudy:{}, //structure multiplicative study rate
structureBaseLevel:{}, //structure free extra base level
structureLevel:{}, //structure free extra multiplicative level
effectMods(type){return Object.values(statValues.value.effect[type]).reduce((a,b) => a*b, 1)},
baseEffectMods(type){return Object.values(statValues.value.baseEffect[type]).reduce((a,b) => a+b, 0)}, //base is additive
skillEffectMods(type){return Object.values(statValues.value.skillEffect[type]).reduce((a,b) => a*b, 1)},
skillStudyMods(type){return Object.values(statValues.value.skillStudy[type]).reduce((a,b) => a*b, 1)},
skillBaseLevelMods(type){return Object.values(statValues.value.skillBaseLevel[type]).reduce((a,b) => a+b, 0)}, //base is additive
skillLevelMods(type){return Object.values(statValues.value.skillLevel[type]).reduce((a,b) => a*b, 1)},
skillTagEffectMods(type){return Object.values(statValues.value.skillTagEffect[type]).reduce((a,b) => a*b, 1)},
skillTagStudyMods(type){return Object.values(statValues.value.skillTagStudy[type]).reduce((a,b) => a*b, 1)},
structureEffectMods(type){return Object.values(statValues.value.structureEffect[type]).reduce((a,b) => a*b, 1)},
structureStudyMods(type){return Object.values(statValues.value.structureStudy[type]).reduce((a,b) => a*b, 1)},
structureBaseLevelMods(type){return Object.values(statValues.value.structureBaseLevel[type]).reduce((a,b) => a+b, 0)}, //base is additive
structureLevelMods(type){return Object.values(statValues.value.structureLevel[type]).reduce((a,b) => a*b, 1)},
tags:[],
initialize(stats, skills, structures){
//add new stats so they can be used by future items.
//can be re-run to add new stats afterwards
for(let [index, entry] of Object.entries(stats)){ //initialize stats
this.baseEffect[index] = {base:entry.base ?? 1};
this.effect[index] = {base:1};
}
for(let [index, entry] of Object.entries(skills)){ //initialize skills
for(let i=0;i<entry.tags.length;i++){
if(!this.tags.includes(entry.tags[i])){
this.tags.push(entry.tags[i]); //check skill for tags, add unique tags to list
}
}
this.skillEffect[index] = {base:1};
this.skillStudy[index] = {base:1};
this.skillBaseLevel[index] = {base:0};
this.skillLevel[index] = {base:1};
this.structureEffect[index] = {base:1};
this.structureStudy[index] = {base:1};
this.structureBaseLevel[index] = {base:0};
this.structureLevel[index] = {base:1};
}
for(let [index, entry] of Object.entries(structures)){ //initialize structures
for(let i=0;i<entry.tags.length;i++){
if(!this.tags.includes(entry.tags[i])){
this.tags.push(entry.tags[i]); //check structures for tags, add unique tags to list
}
}
this.skillEffect[index] = {base:1};
this.skillStudy[index] = {base:1};
this.skillBaseLevel[index] = {base:0};
this.skillLevel[index] = {base:1};
this.structureEffect[index] = {base:1};
this.structureStudy[index] = {base:1};
this.structureBaseLevel[index] = {base:0};
this.structureLevel[index] = {base:1};
}
for(let i=0;i<this.tags.length;i++){ //initialize tags
const tag = this.tags[i];
this.skillTagEffect[tag] = {base:1};
this.skillTagStudy[tag] = {base:1};
}
},
formatTypes(types){
if(!types){ types = []}
if(typeof types !== 'object'){ types = [types]; }
const result = types;
for(let i=0;i<types.length;i++){
if(!this.effect[types[i]]){
result.splice(result.indexOf(i), 1); //remove tags that do not have an accompanying effect
}
}
return result;
},
effectTotal(type, mods=[]){
//returns total effect of a stat, base of all modifiers happens first, then mult.
if(!this.effect[type]){
console.warn(`Invalid value in statValues.studyTotal: ${type}`);
return 1
}
let effect = this.baseEffectMods(type) * this.effectMods(type);
const tags = refValues.value.stats[type];
if(tags.special || mods.includes('raw')){ //do not apply extra modifiers to special stats like time
return effect;
}
if(tags.study){ //modifiers exclusive to skills used for studies.
effect *= formulas.sizeBonus();
effect *= formulas.studyPenalty();
}
return effect
},
priceTotal(type){ //returns experience cap divider from one or more types combined, 1 = 100% required, 2 = 50% required
if(!this.effect[type]){
console.warn(`Invalid value in statValues.priceTotal: ${type}`);
return 1
}
return 1 //rework or removal in progress
},
creepTotal(type){ //returns divider to how much more expensive items become with each level from one or more types combined, 1 = 100% cost creep, 2 = 50% cost creep
if(!this.effect[type]){
console.warn(`Invalid value in statValues.creepTotal: ${type}`);
return 1
}
return 1 //rework in progress
},
skillEffectTotal(id){ //effect multiplier ("e" value) of a skill
let effect = this.skillEffectMods(id);
const skill = skillables.value.skills[id];
for(let i=0;i<skill.tags.length;i++){ //apply effect modifiers that are tag-dependent.
effect *= this.skillTagEffectMods(skill.tags[i]);
}
return effect;
},
skillLevelTotal(skill){ //level total from a skill. Can get free levels from other sources.
let effect = this.skillBaseLevelMods(skill) + (skillables.value.skills[skill].capped ? skillables.value.skills[skill].maxLevel : skillables.value.skills[skill].level) * this.skillLevelMods(skill);
return effect;
},
allStats(){ //returns object with all stat types and additive, multiplicative, price and creep modifiers attached. Used for debugging.
const result = {};
for(let [index, entry] of Object.entries(this.effect)){
result[index] = {base:0, mult:1, total:1, price:1, creep:1, tags:save.value.stats[index]};
for(let [index2, entry2] of Object.entries(entry)){
result[index].mult *= entry2;
}
}
for(let [index, entry] of Object.entries(this.baseEffect)){
for(let [index2, entry2] of Object.entries(entry)){
result[index].base += entry2;
}
result[index].total = result[index].base * result[index].mult;
}
for(let [index, entry] of Object.entries(this.price)){
for(let [index2, entry2] of Object.entries(entry)){
result[index].price *= entry2;
}
}
for(let [index, entry] of Object.entries(this.creep)){
for(let [index2, entry2] of Object.entries(entry)){
result[index].creep *= entry2;
}
}
return result;
},
allSkills(){
const result = {}
for(let [index, entry] of Object.entries(skillables.value.skills)){
result[index] = {level:entry.level, exp:entry.exp, stats:{}}
for(let [index2, entry2] of Object.entries(skillables.value.skills[index].effects)){
result[index].stats[index2] = {}
for(let [index3, entry3] of Object.entries(entry2)){
result[index].stats[index2][index3] = entry3(entry.level);
}
}
}
return result;
}
});
export const values = { //do not modify
res:{
nutrients:0,
size:1,
},
timers:{ //in seconds
nutrAction:30,
rival1Attack:100,
rival2Attack:240,
selfAttack:100,
exploration:240,
beingsAttack:60
},
misc:{
gameSpeed:0.1, //multiplier to all resource production and consumption
timerSpeed:100, //game timer rate in ms, multiplies game speed as well
nutrAction:'scouting', //stage 1 feature, swaps between scouting and digestion to indicate which action is more effective
scoutSpeed:1, //nutrient gathering rate for stage 1
digestSpeed:1, //nutrient digestion rate for stage 1
digestionEfficiency:0.1, //nutrient to size conversion rate
sizeBonus:1.3, //bonus for larger size, applied addively once every time size doubles above 1
fooledConfuseMult:2, //multiplier to confusion gained for rivals in stage 1 after they get fooled by mimicry
structureFocusExplorePenalty:1/3*2, //penalty to exploration rate for every point of structure focus invested
exploreTimeIncrease:1.6, //extra time needed to complete next exploration every time the bar fills
maxShownBeings:10 //maximum amount of beings that can be shown on screen in stage 2
},
tags:{
basic:{},
combat:{},
ability:{},
stage1:{hidden:true},
stage2:{hidden:true},
stage3:{hidden:true},
danger:{hidden:true},
},
stats:{
//hidden: Whether the stat is hidden or not. Shows as ??? in tooltips and doesn't show up in stats display (latter tbd)
//base: sets the base starting value of a stat (default 1), skills requiring a stat with a value of 0 can't be completed.
test:{/* tags */}, //test skill with no effect
time:{study:true, special:true}, //basic stat, unaffected by all stat boosts and penalties
locomotion:{study:true}, //basic stat, just used to speed up study rate of other skills
senses:{study:true}, //basic stat
scouting:{base:0}, //scouting finds nutrients at 1 nutrient/s per 1 scouting
digestion:{study:true}, //basic stat
nutrientDigestion:{base:0}, //turns nutrients into size at a rate of 1 nutrient/s into 0.1 size per 1 nutrientDigestion
digestionEfficiency:{base:1}, //raises the amount of size gained per nutrient. default is a 1 to 0.1 ratio. Increases linearly.
multitasking:{base:0}, //lowers the study penalty for assigning multiple focus points at once. each 0.01 increases speed by 1% additively. Caps at 100% speed.
scavenger:{base:0}, //allows digesting nutrients while gathering and gathering nutrients while digesting. Gain 1% speed additively per point of scavenger
memory:{study:true}, //basic stat
focus:{}, //allow learning one extra skill at a time per point of focus, study rate is divided by amount of activated skills
structureFocus:{}, //allow learning one extra structure at a time per point of structureFocus, study rate is divided by amount of activated studies
rivals:{hidden:true, study:true}, //basic stat. Hidden until the first rival attacks.
defense:{}, //lowers size loss from rival attacks. Size lost is divided by defense value
attack:{base:0}, //raises size stolen from attacks. Size stolen is multiplied by attack value
attackSpeed:{}, //speed at which attacks from the player happen. By default this happens every 100 seconds, rate is multiplied by attack speed
ability:{study:true}, //basic stat
mindControl:{base:0}, //raises chance for rivals to attack other rivals instead of you
shapeShifting:{base:0}, //may cause rivals to fail an attack on you. Builds up mind control faster if they do.
boneGrowth:{study:true}, //basic stat
sizeMultBonus:{}, //multiplicative multiplier to study rate based on size. 1 = +100% per log2 size
exploration:{base:0}, //specialized scouting for stage 2, builds progress towards exploring your surroundings and finding new structures (organs) instead of finding nutrients.
fleshDigestion:{base:0}, //specialized digestion for stage 2, converts the environment into size. Does not rely on scouting for nutrients.
skillStudyRate:{}, //multiplies study rate for all skills
structureStudyRate:{}, //multiplies study rate for structures
beings:{hidden:true, study:true} //basic stat. Hidden until the tiny beings attack in stage 2
},
rivals:{
rival1:{
baseSize:800,
baseStrength:30,
baseConfuseGain:1,
baseConfuseMax:10,
},
rival2:{
baseSize:3000,
baseStrength:60,
baseConfuseGain:2,
baseConfuseMax:10,
},
self:{
baseAttackTimer:1000,
baseMimicryMax:10
}
},
rivalNames:['rival1', 'rival2']
}
const gameSpeed = values.misc.gameSpeed;
export const saveValues = {
res:{
nutrients:values.res.nutrients,
size:values.res.size
},
timers:{
nutrAction:0,
rival1Attack:0,
rival2Attack:0,
selfAttack:0,
exploration:0,
beingsAttack:0
},
misc:{
nutrAction:values.misc.nutrAction,
},
skills:{},
structures:{},
stage:1,
rivals:{
rival1:{
unlocked:false,
size:values.rivals.rival1.baseSize,
attacks:0,
confuse:0,
stolen:0,
lastTarget:false,
alive:true
},
rival2:{
unlocked:false,
size:values.rivals.rival2.baseSize,
attacks:0,
confuse:0,
stolen:0,
lastTarget:false,
alive:true
},
self:{
attacks:0,
stolen:0,
mimicry:0,
lastTarget:false
}
},
beings:{ //rivals for stage 2
unlocked:false,
amount:0
},
exploration:{
count:0
},
study:{
skills:{
order:[]
},
structures:{
order:[]
}
},
settings:{
autoSave:false
},
seed:0,
}
function seededRandom(adv=true) {
let a = save.value.seed;
a |= 0;
a = a + 0x9e3779b9 | 0;
let t = a ^ (a >>> 16);
t = Math.imul(t, 0x21f0aaad);
t = t ^ (t >>> 15);
t = Math.imul(t, 0x735a2d97);
const result = ((t = t ^ (t >>> 15)) >>> 0) / 4294967296;
if(adv){ save.value.seed = a; }
return result;
}
export const refValuesBase = { //do not modify
stats:deepClone(values.stats),
tagLock:[], /* all skills that include a tag in this list are locked regardless of unlock condition. Has priority over noTagLock */
noTagLock:[], /*all skills that do not have all tags in this list are locked regardless of unlock condition */
settings:{
infoMode:'guide',
showGuide:'',
showStat:'',
showSkill:'',
screen:'game',
gameSection:'skills',
pause:false
},
tags:deepClone(values.tags),
timers:deepClone(values.timers),
misc:{
rival1Warn:false, //currently unused
rival2Warn:false, //currently unused
skillNotif:false, //highlight skills tab if a new skill option is unlocked (unimplemented)
exploreNotif:false //highlight explore tab if a new exploration option is unlocked
},
rivals:{
rival1:{
size:values.rivals.rival1.baseSize,
strength:values.rivals.rival1.baseStrength,
confuseGain:values.rivals.rival1.baseConfuseGain,
confuseMax:values.rivals.rival1.baseConfuseMax
},
rival2:{
size:values.rivals.rival2.baseSize,
strength:values.rivals.rival2.baseStrength,
confuseGain:values.rivals.rival2.baseConfuseGain,
confuseMax:values.rivals.rival2.baseConfuseMax
},
self:{
attackTimer:values.rivals.self.baseAttackTimer,
mimicryMax:values.rivals.self.baseMimicryMax
}
}
}
export const refValues = ref({}); //tracks values not used in the save file. These are cleared on page reload);
export function initRefValues(){
refValues.value = {...deepClone(refValuesBase),
get rivalAttacks(){
return save.value.rivals.rival1.attacks + save.value.rivals.rival2.attacks
},
get rivalsAlive(){
return save.value.rivals.rival1.alive || save.value.rivals.rival2.alive;
},
seededRandom:seededRandom,
advanceTimer: function(id, amount=1, mods=[]){
if(!save.value.timers.hasOwnProperty(id)){
console.warn(`property ${id} not found in timers!`);
return false;
}
if(mods.includes('watch')){
return save.value.timers[id] + amount * gameSpeed;
}
if(!mods.includes('check')){
save.value.timers[id] += amount * gameSpeed;
}
if(save.value.timers[id] >= refValues.value.timers[id]){
if(mods.includes('subtract')){
save.value.timers[id] -= refValues.value.timers[id]
}
else if(!mods.includes('keep')){
save.value.timers[id] = 0;
}
return true
}
return false;
},
getTimer: function(id, percentage=true){
if(percentage){
return format(save.value.timers[id] / refValues.value.timers[id] * 100, 4, 'eng');
}
else{
return save.value.timers[id];
}
}
}
}
export const formulas = {
nutrientGathering:function(stage=save.value.stage){ //gather 1 nutrients per second per point of scouting.
//gathering and digestion are on a cycle, gathering reduced to 10% of original per point of scavenger above 1 if cycle is digestion
let amount = 0
if(stage === 1){
const scavenger = statValues.value.effectTotal('scavenger');
const gather = statValues.value.effectTotal('scouting');
const rate = save.value.misc.nutrAction === 'scouting' ? 1 : scavenger;
amount = values.misc.scoutSpeed * gather * gameSpeed * rate;
}
return amount;
},
nutrientDigestion:function(stage=save.value.stage){ //convert 1 nutrients per second into mass per point of nutrientDigestion
//digestion converts 1 nutrients into 0.1 mass, this rate can be increased with the efficient digestion skill
//gathering and digestion are on a cycle, digestion reduced to 10% of original per point of scavenger above 1 if cycle is scavenger
let amount = 0;
if(stage === 1){
const scavenger = statValues.value.effectTotal('scavenger');
const digestion = statValues.value.effectTotal('nutrientDigestion');
const rate = save.value.misc.nutrAction === 'digestion' ? 1 : scavenger;
amount = values.misc.digestSpeed * digestion * gameSpeed * rate;
amount = Math.min(amount, save.value.res.nutrients);
amount = Math.max(0, amount);
}
else if(stage === 2){
const digestion = statValues.value.effectTotal('fleshDigestion');
amount = values.misc.digestSpeed * digestion * gameSpeed;
}
return amount;
},
passiveSizeLoss:function(){
let loss = Math.max(0, Math.log10(save.value.res.size) - 1) * gameSpeed; //lose size/s equal to log10 of size
loss = Math.min(save.value.res.size-10, loss); //size can't go below 10
loss = Math.max(0, loss); //loss can't go below 0
return loss;
},
rivalPassiveSizeGain:function(which){ //rivals gain back 0.01% of their missing size per second
const rival = save.value.rivals[which];
const rivalValue = refValues.value.rivals[which];
if(rivalValue.size > rival.size){
return (rivalValue.size - rival.size) * 0.0001 * gameSpeed
}
return 0;
},
rivalAttackSpeed:function(which){ //returns attack value that rivals gain per cycle. Amount of value needed varies per rival, rival1 has 100, rival2 has 240, by default it's 1/s, reduced by the delayAttack stat
//rival2 becomes faster if rival1 is dead
if(which === 'rival2' && !save.value.rivals.rival1.alive){
return 2;
}
return 1;
},
attackSizeStolen:function(which, target){ //return the amount of size that either you or a rival would steal from you or another rival during an attack. Can go above the current size that a target has.
//you can't attack yourself
let stolen = 0;
if(save.value.stage === 1){
if(target === 'you'){ //rival attacks you
const defense = statValues.value.effectTotal('defense');
const rivalStrength = refValues.value.rivals[which].strength;
const rivalSize = save.value.rivals[which].size;
//steals either a percentage of size equal to strength or a flat amount of strength multiplied by 1% of size. Whichever is more.
stolen = Math.max(save.value.res.size / 100 * rivalStrength, rivalStrength * rivalSize / 100);
stolen /= defense;
//amount of size that mass gains is capped at their strength value
}
else if(which === 'you'){ //you attack rival
const attack = statValues.value.effectTotal('attack');
stolen = attack;
stolen = Math.min(save.value.res.size, stolen); //capped at 100% of your mass
//stolen = Math.min(save.value.rivals[target].size, stolen); //capped at 100% of rival mass
}
else{ //rival attacks rival
//steals either a percentage of size equal to strength or a flat amount of strength multiplied by 1% of size. Whichever is less
const rivalStrength = refValues.value.rivals[which].strength;
const rivalSize = save.value.rivals[which].size;
stolen = Math.min(save.value.rivals[target].size * rivalStrength / 100, rivalStrength * rivalSize);
//amount of size that mass gains is capped at their strength value.
}
}
return stolen;
},
beingSizeStolen(amount){
let stolen = 0;
//for when beings attack in stage 2
if(save.value.stage === 2){
const defense = statValues.value.effectTotal('defense');
stolen = 50 * amount; //each being steals 50 size + 1% of your current size.
stolen += save.value.res.size * 0.01 * amount;
stolen /= defense;
stolen = Math.min(save.value.res.size, stolen); //can't steal more than current size
}
return stolen;
},
digestSizeGain:function(amount){ //Size gained is divided by amount of ditits in size above 2 (100)
const eff = statValues.value.effectTotal('digestionEfficiency');
amount *= eff * values.misc.digestionEfficiency; //values.digestionEfficiency = 0.1 by default
return amount / Math.max(1, Math.log10(save.value.res.size + amount)-1);
},
rivalSizeGain:function(which, amount){ //rivals gain diminished size if they go over the value they start with to prevent them growing out of control.
amount = Math.min(amount, refValues.value.rivals[which].strength); //size stolen is also capped at rival strength to prevent them gaining large amounts of size from attacking the player or other rivals.
return amount * 0.99 ** Math.max(0, (save.value.rivals[which].size + amount - refValues.value.rivals[which].size));
},
rivalConfuseGain:function(which){ //rivals become confused over time, when their value reaches the max value (by defaul 10), they'll attack the other rival. Raises by 1 per attack for rival1 and 3 for rival2, affected by confusion skills.
const confusion = statValues.value.effectTotal('mindControl');
return refValues.value.rivals[which].confuseGain * confusion;
},
mimicryGain(){ //when mimicry reaches the max value (by default 10), the next rival attack will deal no damage. Confusion raises twice as fast on the target rival if this happens.
const mimicry = statValues.value.effectTotal('shapeShifting');
return mimicry;
},
sizeBonus(size=false){ //study bonus from larger size. By default it's +30% additively whenever your size doubles
size = Math.max(1, Number.isInteger(size) ? size : save.value.res.size);
const sizeMult = Math.log2(size);
const multBonus = statValues.value.effectTotal('sizeMultBonus'); //size mult is a secondary compounding multiplier to the size bonus. (currently unused)
return Math.max(1, 1+(values.misc.sizeBonus-1) * sizeMult) * (multBonus ** sizeMult);
},
studyPenalty(which='skills'){ //study penalty for assigning more focus points at once, by default, study rate is divided by amount of points invested. Penalty reduced by multitasking skill
return Math.min(1, 1 / Math.max(1, study.value.used(which)) + statValues.value.effectTotal("multitasking"));
}
}
export const guides = {
basics:{
unlock:function(){return true}
},
expGain:{
unlock:function(){return true}
},
size:{
unlock:function(){return skillables.value.skills.scouting.unlocked || skillables.value.skills.nutrientDigestion.unlocked}
},
rivals:{
unlock:function(){return refValues.value.rivalAttacks}
}
}
export const study = ref({
max: function(which){
if(which === 'skills'){
return Math.floor(statValues.value.effectTotal('focus'));
}
else if(which === 'structures'){
return Math.floor(statValues.value.effectTotal('structureFocus'));
}
},
order: function(which){return save.value.study[which].order},
used: function(which){return this.order(which).length},
free: function(which){return this.max(which) - this.used(which)},
switch:function(which, id){
//enabled skillables are tracked two separate ways, once in the save, and once in the skillable item.
//The save item matters for gameplay, the skillable item matters for visuals.
const item = skillables.value[which];
if(!item){
console.error('incorrect value for which in study', which);
return false;
}
const order = save.value.study[which].order;
const studyVal = save.value.study[which];
if(!item[id].enabled && !item[id].capped && (order.includes(id) || this.free(which))){
if(!order.includes(id)){
save.value.study[which].order.push(id);
}
item[id].enabled = true;
}
else if(item[id].enabled){
if(order.includes(id)){
save.value.study[which].order.splice(studyVal.order.indexOf(id), 1);
}
item[id].enabled = false;
}
if(!this.free(which) && !item[id].enabled){
return -1; //item can't be enabled because you do not have enough focus available
}
return item[id].enabled;
},
flash:{ //when set to true, a red flash happens if your focus is capped if you try to study more skills
get skills(){return this._skills >= Date.now()},
_skills:false,
get structures(){return this._structures >= Date.now()},
_structures:false
},
setFlash(which, howLong){
this.flash[`_${which}`] = Date.now() + howLong;
}
});
export function updateStage(stage=-1){
if(stage !== -1){
save.value.stage = stage;
if(stage === 2){
save.value.res.size = 1;
save.value.res.nutrients = 0;
}
}
if(save.value.stage === 1){
skillLockByNoTag('stage1', true, true);
skillLockByNoTag('stage2', false, true);
skillLockByNoTag('stage3', false, true);
}
else if(save.value.stage === 2){
skillLockByNoTag('stage1', false, true);
skillLockByNoTag('stage2', true, true);
skillLockByNoTag('stage3', false, true);
}
if(save.value.stage !== 1){
for(let i=0;i<values.rivalNames.length;i++){
const name = values.rivalNames[i];
delete statValues.value.effect.scouting[`effect_deceased_${name}`]; //no deceased rival bonus outside of stage 1
delete statValues.value.effect.nutrientDigestion[`effect_deceased_${name}`];
}
}
updateEffects(true);
}
export function skillLockByTag(tag, lock='toggle', skipUpdate=false){ //lock or unlock all skills that have a certain tag. When locked, they are unavailable and inactive regardless of conditions.
const tagLock = refValues.value.tagLock;
if(!tagLock.includes(tag) && (lock === true || lock === 'toggle')){
refValues.value.tagLock.push(tag);
}
else if(tagLock.includes(tag) && (lock === false || lock === 'toggle')){
const pos = tagLock.indexOf(tag);
refValues.value.tagLock.splice(pos, 1); //remove lock on skills with tag
}
if(!skipUpdate){
updateEffects();
}
}
export function skillLockByNoTag(tag, lock='toggle', skipUpdate=false){ //lock or unlock all skills that do not have a certain tag. When locked, they are unavailable and inactive regardless of conditions.
const noTagLock = refValues.value.noTagLock;
if(!noTagLock.includes(tag) && (lock === true || lock === 'toggle')){
refValues.value.noTagLock.push(tag);
}
else if(noTagLock.includes(tag) && (lock === false || lock === 'toggle')){
const pos = noTagLock.indexOf(tag);
refValues.value.noTagLock.splice(pos, 1); //remove lock on skills with tag
}
if(!skipUpdate){
updateEffects();
}
}
export function resetByTag(tag, which, update=true){
for(let [index, entry] of Object.entries(skillables.value[which])){
if(entry.tags.includes(tag) || tag === 'all'){
entry.unlocked = false;
entry.exp = 0;
entry.level = 0;
delete save.value.skills[index];
}
}
if(update){
updateEffects();
}
}
export function updateEffects(force=false, type='all'){
for(let [index, entry] of Object.entries(skillables.value)){
if(type === 'all' || index === type){
for(let [index2, entry2] of Object.entries(entry)){
entry2.update(force); //check if new skills can be unlocked. Can lock skills again if the ['relock'] tag for said skill is set.
if(entry2.unlocked && !save.value.skills[index]){
save.value[index][index2] = {unlocked:true, exp:0, level:0};
}
if(save.value[index][index2]){
save.value[index][index2].unlocked = entry2.unlocked;
save.value[index][index2].exp = entry2.exp;
save.value[index][index2].level = entry2.level;
}
}
}
}
for(let [index, entry] of Object.entries(skillables.value)){
if(type === 'all' || index === type){
for(let i=save.value.study[index].order.length-1;i>=0; i--){
const id = save.value.study[index].order[i];
const enabled = skillables.value[index][id].enabled;
const item = skillables.value[index][id];
if(!item.unlocked || item.capped){
study.value.switch(index, id); //switch off locked or capped skillables
}
if(!enabled && item.unlocked){
study.value.switch(index, id); //switch on studies that are not enabled but are enabled in the save.
}
}
for(let i=save.value.study[index].order.length-1;i>=0; i--){
const id = save.value.study[index].order[i];
const enabled = skillables.value[index][id].enabled;
if(study.value.free(index) < 0 && enabled){
study.value.switch(index, id); //switch off studies that are over the limit.
}
}
}
}
/*if(['all', 'skills'].includes(type)){
for(let [index, entry] of Object.entries(skillables.value.skills)){
entry.update(force); //check if new skills can be unlocked. Can lock skills again if the ['relock'] tag for said skill is set.
if(entry.unlocked && !save.value.skills[index]){
save.value.skills[index] = {unlocked:true, exp:0, level:0};
}
if(save.value.skills[index]){
save.value.skills[index].unlocked = entry.unlocked;
save.value.skills[index].exp = entry.exp;
save.value.skills[index].level = entry.level;
}
}
}
if(['all', 'structures'].includes(type)){
for(let [index, entry] of Object.entries(skillables.value.structures)){
entry.update(force); //check if new skills can be unlocked. Can lock skills again if the ['relock'] tag for said skill is set.
if(entry.unlocked && !save.value.structures[index]){
save.value.structures[index] = {unlocked:true, exp:0, level:0};
}
if(save.value.structures[index]){
save.value.structures[index].unlocked = entry.unlocked;
save.value.structures[index].exp = entry.exp;
save.value.structures[index].level = entry.level;
}
}
}
if(['all', 'skills'].includes(type)){
for(let i=save.value.study.skill.order.length-1;i>=0; i--){
const id = save.value.study.skill.order[i];
if(!skillables.value.skills[id].unlocked){
study.value.switch('skill', id);
}
}
}
if(['all', 'structures'].includes(type)){
for(let i=save.value.study.structure.order.length-1;i>=0; i--){
const id = save.value.study.structure.order[i];
if(!skillables.value.structures[id].unlocked){
study.value.switch('structures', id);
}
}
}*/
}
/*new skill(
'id', //this.id, internal id of item
['tag1', 'tag2'], //this.tags, tags of the item, may affect various parts or unlock conditions
{stat1: 0.3, stat2:0.3, stat3:0.3}, //this.types, which stats the item is affected by with a weight attached.
100, //this.expMax, amount of exp needed to get the first level
1.12, //this.scaling, cost creep, when a level is gained, the experience required for the next level is multiplied by this amount
{ //this.effects
stat1:{ //affects statValues.value.stat1 OR skillables.value.skills.stat1 OR skillables.value.skills.tags.includes('stat1'), effects are only applied if this item is unlocked
//l is equal to the level of the item
//e is equal to the effect modifier of the item (default 1)
baseEffect(l, e){return 0.1 * l * e}, //this.effects.stat1.baseEffect(), baseEffect = linear additive modifier for stats.
effect(l, e){return 1 + (0.01 * l * e)}, //effect = multiplicative modifier for stats (ALL multiplicative modifiers can go below 1 for a penalty),
//price(l, e){return 1.01 ** (l * e)}, //price = multiplicative price divider for items dependent on the stat, divides amount of exp needed to get a level based on how dependent the skill is. To be removed or reworked as the effect is too complicated.
//skillCreep(l, e){return 1.001 ** (l * e)}, //skillCreep = multiplicative cost creep divider for skills, reduces the speed at which the experience requirement goes up with every level
skillEffect(l){return 1 + (0.01 * l)}, //skillEffect = multiplicative effect modifier for skills, affects the "e" value. Can NOT be affected by "e" or a recursive boost can happen
skillStudy(l){return 1 + (0.01 * l)}, //skillStudy = multiplicative exp modifier for skills
skillBaseLevel(l){return 0.1 * l}, //skillBaseLevel = additive level modifier for skills, increases the "l" value.
skillLevel(l){return 1 + (0.01 * l)}, //skillLevel = multiplicative level modifier for skills, increases the "l" value.
skillTagEffect(l){return 1 + (0.01 * l)} //skillTagEffect = multiplicative effect modifier for all skills that have a matching tag. Affects the "e" value.
skillTagStudy(l){return 1 + (0.01 * l)} //skillTagStudy = multiplicative exp modifier for all skills that have a matching tag.
},
stat2{ //multiple stats can be affected
effect(l, e) {return 1 + (l / (l + 500) * e)} //scaling can be different
}
},
levelMax=-1 //maximum level, a skill can not go higher level than this amount. -1 means no cap.
function(){return `Description text. Current speed: ${this.studyTotal()}`}, //description shown when hovering over this item
function(){return statValues.value.studyTotal('stat1') >= 10} //unlock requirement. Item becomes active when the condition is met.
function(){return statValues.value.studyTotal('stat1') >= 3} //visible requirement. Item becomes visible but shows as a question mark and is further not usable. Has a different hover tooltip if it's specified in loc
)*/
/*more details on stat affect:
{stat1:0.2, stat2:0.3, stat3:0.4}
//means this item is affected by 20% of the effect of stat1 + 30% of stat2 + 40% of stat3
//if stat1 has 20 speed, stat2 has 50 speed and stat3 has 1 speed and you need 1000 exp for a level
speed = 1000 / 20 * 0.2 (10)
speed += 1000 / 50 * 0.3 (6)
speed += 1000 / 1 * 0.4 (400) < big effect, raise stat3 to significantly speed up progress
exp = 1000 / 416 = 2.403 exp base
//exp amount is the same regardless of exp required
speed = 2000 / 20 * 0.2 (20)
speed += 2000 / 50 * 0.3 (12)
speed += 2000 / 1 * 0.4 (800)
exp = 2000 / 832 = 2.403 exp base < exp value remains the same no matter the exp required
/stat3 becomes 10 (10x as high)
speed = 2000 / 20 * 0.2 (20)
speed += 2000 / 50 * 0.3 (12)
speed += 2000 / 10 * 0.4 (80) < significantly lower number
exp = 2000 / 112 = 17.86 exp base < much higher exp
exp requirement mult
stat1 = 3, stat2 = 2, stat3 = 1
speed = 1 / (3 - 1) * 0.2 + 1 (1 / 1.4 = 0,714)
speed += 1 / (2 - 1) * 0.3 + 1 (0,714 / 1.3 = 0.549)
speed += 1 / (1 - 1) * 0.4 + 1 (0.549 / 1 = 0.549)
final exp requirement = 0.549
const time = 0;
for(let [index, entry] of Object.entries(item.stats)){
time += item.expRequired / statValues[stats] * entry;
}
return item.expRequired / time
*/
//special skill tags
//relock: skill can become locked at any time if conditions are not met anymore.
//
function desc_skill(skill, insert=[], locName=`skillDesc_${skill.id}`, exclude=[]){
const tags = skill.tags.filter((entry, index) => !refValues.value.tags[entry].hidden);
return `${insert[0] ? `${insert[0]}<br>` : ''}\
${exclude.includes('descr') ? '' : `${loc(locName)}<br>`}\
${insert[1] ? `${insert[1]}<br>` : ''}\
${exclude.includes('tags') || !tags.length ? '' : `Tags:
${tags.map((entry, index) => {
return `<span class='tag'>${loc(`tag_${entry}`)}</span>`}).join(", ")
}<br>`}\
${insert[2] ? `${insert[2]}<br>` : ''}\
${exclude.includes('statDescr') ? '' : `${desc_stats(skill.types)}<br>`}\
${insert[3] ? `${insert[3]}<br>` : ''}\
${exclude.includes('effect') || !Object.keys(skill.effects).length ? '' : `${desc_skill_effects(skill)}<br>`}\
${insert[4] ? `${insert[4]}<br>` : ''}\
${exclude.includes('speed') ? '' : `speed: ${format(skillables.value.skills[skill.id].studyTotal() / gameSpeed, 4, 'eng')}/s<br>`}\
${insert[5] ? `${insert[5]}<br>` : ''}`.slice(0, -4);
}
function desc_structure(structure, insert=[], locName=`structureDesc_${structure.id}`, exclude=[]){
return `${exclude.includes('descr') ? '' : `${loc(locName)}<br>`}\
${exclude.includes('statDescr') ? '' : `${desc_stats(structure.types)}<br>`}\
${exclude.includes('effect') || !Object.keys(structure.effects).length ? '' : `${desc_skill_effects(structure)}<br>`}\
${exclude.includes('speed') ? '' : `speed: ${format(skillables.value.structures[structure.id].studyTotal() / gameSpeed, 4, 'eng')}/s<br>`}`.slice(0, -4);
}
function desc_stats(types){
return Object.entries(types).map((entry) => (
refValues.value.stats[entry[0]].hidden ?
`???: ${format(entry[1]*100, 4, 'eng')}%`
:
`<span class='stat'>${loc(`stat_${entry[0]}`)}</span>: ${format(entry[1]*100, 4, 'eng')}%`)
).join(' ');
}
/*if(['skillEffect', 'skillBaseLevel', 'skillLevel'].includes(index2)){
statValues.value[index2][index][this.id] = entry2(this._level); //skill effect boosting effects are not and should not be affected by skill effect
}
else{
statValues.value[index2][index][this.id] = entry2(this._level, this.skillEffect);
}*/
function desc_skill_effects(skill){
let desc = '';
let i = 0;
for(let [index, entry] of Object.entries(skill.effects)){
for(let [index2, entry2] of Object.entries(entry)){
if(i && !(i%4)){
desc += '<br>';
}
if(['baseEffect', 'effect'].includes(index2)){
const name = refValues.value.stats[index].hidden ? '???' : loc(`stat_${index}`);
if(index2 === 'baseEffect'){
desc += `${name}: +${format(entry2(skill.trueLevel, skill.effect), 4, 'eng')} `;
}
if(index2 === 'effect'){
desc += `${name}: +${format((entry2(skill.trueLevel, skill.effect) - 1) * 100, 4, 'eng')}% `;
}
}
if(['skillEffect', 'skillBaseLevel', 'skillLevel'].includes(index2)){
if(index2 === 'skillEffect'){
desc += `<span class='skill'>${index}</span> skill effect: +${format((entry2(skill.trueLevel) - 1) * 100, 4, 'eng')}% `;
}
if(index2 === 'skillBaseLevel'){
desc += `<span class='skill'>${index}</span> skill level: +${format(entry2(skill.trueLevel), 4, 'eng')} `;
}
if(index2 === 'skillLevel'){
desc += `<span class='skill'>${index}</span> skill level: +${format((entry2(skill.trueLevel) - 1) * 100, 4, 'eng')}% `;
}
}
if(['skillTagEffect', 'skillTagStudy'].includes(index2)){
const name = loc(`tag_${index}`);
if(index2 === 'skillTagEffect'){
desc += `<span class='tag'>${name}</span> skill effect: +${format((entry2(skill.trueLevel) - 1) * 100, 4, 'eng')}% `;
}
if(index2 === 'skillTagStudy'){
desc += `<span class='tag'>${name}</span> skill speed: +${format((entry2(skill.trueLevel) - 1) * 100, 4, 'eng')}% `;
}
}
i++;
}
}
return desc;
}
const skills = {
focus:new skill(
'focus',
['stage1'],
{memory:1},
1000,
4,
{
focus:{
baseEffect(l){return 1 * l}
}
},
-1,
function(){return desc_skill(this)},
function(){return skillables.value.skills.memorization.level >= 10}
),
movement:new skill(
'movement',
['stage1'],
{senses:0.3, locomotion:0.3, memory:0.4},
100,
1.05,
{
locomotion:{
baseEffect(l, e){ return 0.1 * l * e}
}
},
-1,
function(){return desc_skill(this)}
),
sensing:new skill(
'sensing',
['stage1'],
{senses:0.2, locomotion:0.3, memory:0.5},
100,
1.05,
{
senses:{
baseEffect(l, e){ return 0.1 * l * e}
}
},
-1,
function(){return desc_skill(this)},
function(){return skillables.value.skills.movement.level >= 3}
),
digestion:new skill(
'digestion',
['stage1'],
{senses:0.4, digestion:0.4, memory:0.2},
100,
1.05,
{
digestion:{
baseEffect(l, e){ return 0.1 * l * e}
}
},
-1,
function(){return desc_skill(this)},
function(){return skillables.value.skills.movement.level >= 3}
),
memorization:new skill(
'memorization',
['stage1'],
{senses:0.2, memory:0.8},
100,
1.05,
{
memory:{
baseEffect(l, e){return 0.1 * l * e }
}
},
-1,
function(){return desc_skill(this)},
function(){return skillables.value.skills.movement.level >= 8 && skillables.value.skills.sensing.level >= 8}
),
scouting:new skill(
'scouting',
['stage1'],