-
Notifications
You must be signed in to change notification settings - Fork 0
/
map.js
1701 lines (1671 loc) · 63.3 KB
/
map.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
// FUNCTIONS, LEVELS, & GRAPHIC HANDLING
// FUNCTIONS
// Miscellaneous functions
function clear(index, coor = false) { // clears contexts
if (!coor) ctx[index].clearRect(0, 0, ctx[index].canvas.width, ctx[index].canvas.height);
else ctx[index].clearRect(coor[0] - unit / 20, coor[1] - unit / 20, unit * 1.1, unit * 1.1);
}
function semisolid(x, y, l) { // finds whether a 0 is a semisolid support
if (x >= width) return true;
else if (l[y][x] !== 0) return false;
let above = 0;
for (i = 0; i < y; i++) {
if (above !== 2) above = l[i][x];
else if (l[i][x] == 1) above = 1;
}
return (above == 2);
}
function between([a, b], num) {
return num >= Math.min(a, b) && num <= Math.max(a, b);
}
function isS([x, y], nonSemi = false, hor = false, l = levels.currentLevelMap, block = false) { // is solid???
// nonSemi = true --> don't collide with semis.
// hor = true --> do collide horizontally.
// block = true --> don't collide with 1.5s
let outside = false;
if (x < 0 || x >= width || y < 0 || y >= height) {
if (hor && (y < 0 || y >= height) && (x < 0 || x >= width)) return true;
else if (hor && (x < 0 || x >= width)) return true;
//else if (!hor && (x < 0 || x >= width))
if (x < 0 || x >= width) x = (x < 0) ? 0 : width - 1;
if (y < 0 || y >= height) y = (y < 0) ? 0 : height - 1;
outside = true;
}
if (nonSemi) return (l[y][x] == 1 || (l[y][x] == 1.5 && !outside));
else return (l[y][x] >= 1 && l[y][x] <= 2 && (l[y][x] != 1.5 || !outside) && !block);
}
function isGoalY([yt, yb]) { // checks if the character is in the goal y-values
let yg = levels.exits[levels.currentLevel]; // y-goal
if (yt < yg) return false;
for (y = yg; y < height; y++) {
if (levels.currentLevelMap[y][width - 1] == 1) break;
if (y == yb) return true;
}
return false;
}
function XOR(values) { // returns index if exactly one of the values is true
if (values.reduce((a, x) => x ? a + 1 : a, 0) == 1) {
for (i = 0; i < values.length; i++) {
if (values[i]) return i;
}
} else return -1; // not exactly 1 of them is true
}
function capitalize(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
function animationFrameCalc(f, dir, button = false) {
f = f + (animationStepSpeed * ((button) ? GFuel : 1)) * (dir * 2 - 1);
f = (f <= 0) ? 0 : ((f >= 2) ? 2 : Math.round(f * 100) / 100);
return f;
}
function inRect([Xleft, Xright, Ytop, Ybottom], points) {
let inside = false;
points.forEach(function (coor) {
if (coor[0] >= Xleft && coor[0] <= Xright && coor[1] >= Ytop && coor[1] <= Ybottom) inside = true;
});
return inside;
}
function save() {
saved["autoStart"] = autoStart;
saved["statisticTwo"] = statisticTwo;
if (statisticTwo) GFuel = 1;
else GFuel = 3;
tempScoreRecord = [];
saved["powers"] = [powers[0], powers[1]];
for (let l = 1; l <= levels.levels.length; l++) {
if (score.scores[l - 1][1][0] + score.scores[l - 1][1][1] + score.scores[l - 1][1][2] > 0) {
if (l !== levels.levels.length) {if (score.scores[l][1][0] + score.scores[l][1][1] + score.scores[l][1][2] <= 0) {
//console.log("Best level is now: ", l);
saved["bestLevel"] = l;
}} else {
//console.log("Saved that you beat the final level!");
}
tempScoreRecord.push(score.scores[l - 1]);
}
}
saved["scores"] = tempScoreRecord;
localStorage.setItem('SplitSecond-Saved', JSON.stringify(saved));
}
// LEVELS
//let currentLevel = []; // The currently displayed and manipulated level.
// Levels Object
let levels = {
levels: [],
exits: [],
ghosts: [],
buttons: [],
powers: [],
scores: [[0, 0], 0, [0, 0]], // [[lowest, highest (time)], swaps, [blocks, alreadyCounted]] - live recording of the current level's score.
currentLevel: -1,
currentLevelMap: [],
addLevel: function (values, goals, exitY, buttons, swaps, blocks) {
this.levels.push(values);
this.exits.push(exitY);
this.buttons.push(buttons);
this.powers.push([swaps, blocks]);
score.goals.push(goals);
},
drawLevel: function (level, simple = false) { // draw the specified level
let c = (simple) ? ctx.length - 1 : 1; // canvas index
let m = (simple) ? unit * 0.32 : unit; // size multiplier
clear(c); /*opskjdcjcv jvc99cxyde09idsu8dyuxs90 -- cat code! #Kip's 3rd birthday*/
if (c !== ctx.length - 1) {clear(2); clear(6); clear(7);}
let l = this.levels[level];
let semiShape = [0, []]; // [(1-open {=} 2-line {+}), [x's of no {=}]];
let doneGoal = false; // when a block stops the goal, it's done.
for (let y = 0; y < height; y++) {
let semiNext = [0, []]; // the going "semiShape" for the next row
for (let x = 0; x < width; x++) {
switch (l[y][x]) {
case 1.5:
l[y][x] = 0; // mistakenly kept as 1.5
case 0:
if (semisolid(x, y, l)) { // semisolid above
let option = Math.floor(Math.random() * 4); // style option: 1-{=} 2-{+} 3-{-}
if (semisolid(x + 1, y, l)) { // RIGHT is available
if (semiShape[1].includes(x)) { // CAN'T do {=}
if (option == 1) option = (Math.floor(Math.random() * 2)) * 2;
}
} else option = (Math.floor(Math.random() * 2)) * 3;
if (option == 1) semiNext[1].push(x);
if (semiShape[0]) option = option % 3;
ctx[c].drawImage(img[0], option * 100, 500 + semiShape[0] * 100, 100, 100, x * m, y * m, m, m);
semiShape[0] = option % 3; // % 3 turns option {-} into 0 (good!)
if (y < height - 1) {
if (l[y + 1][x] % 3 !== 0) {
ctx[c].drawImage(img[0], 400, 400, 100, 100, x * m, y * m, m, m); // feet
}
}
}
break;
case 1: // normal block
let blocks = [0, 0, 0, 0]; // [right, left, up, down]; 1 means not there.
if (x < width - 1) if (l[y][x + 1] !== 1) blocks[0] = 1;
if (x > 0) if (l[y][x - 1] !== 1) blocks[1] = 1;
if (y > 0) if (l[y - 1][x] !== 1) blocks[2] = 1;
if (y < height - 1) if (l[y + 1][x] !== 1) blocks[3] = 1;
ctx[c].drawImage(img[0], (blocks[1] + 2 * blocks[0]) * 100, (blocks[2] + 2 * blocks[3]) * 100, 100, 100, x * m, y * m, m, m);
if (x > 0 && y > 0) if (!blocks[1] && !blocks[2] && l[y - 1][x - 1] !== 1) ctx[c].drawImage(img[0], 400, 0, 100, 100, x * m, y * m, m, m);
if (x < width - 1 && y > 0) if (!blocks[0] && !blocks[2] && l[y - 1][x + 1] !== 1) ctx[c].drawImage(img[0], 400, 100, 100, 100, x * m, y * m, m, m);
if (x < width - 1 && y < height - 1) if (!blocks[0] && !blocks[3] && l[y + 1][x + 1] !== 1) ctx[c].drawImage(img[0], 400, 200, 100, 100, x * m, y * m, m, m);
if (x > 0 && y < height - 1) if (!blocks[1] && !blocks[3] && l[y + 1][x - 1] !== 1) ctx[c].drawImage(img[0], 400, 300, 100, 100, x * m, y * m, m, m);
break;
case 2: // semisolid block
let blocks2 = [0, 0]; // [right, left]; 1 means not there.
if (x < width - 1) if (l[y][x + 1] !== 2) blocks2[0] = 1;
if (x > 0) if (l[y][x - 1] !== 2) blocks2[1] = 1;
ctx[c].drawImage(img[0], (blocks2[1] + 2 * blocks2[0]) * 100, 400, 100, 100, x * m, y * m, m, m);
if (y < height - 1) if (l[y + 1][x] % 3 !== 0) ctx[c].drawImage(img[0], 400, 400, 100, 100, x * m, y * m, m, m); // feet
break;
case 3: // avatar location
if (!simple) avatar.init([x * unit, y * unit]);
else ctx[c].drawImage(img[2], 1 * 100, 1 * 100, 100, 100, Math.round(x * m), Math.round(y * m), m, m);
break;
case 4: // swap-item location
case 5: // block-item location
if (!powers[l[y][x] - 4]) ctx[c].drawImage(img[3], (l[y][x] - 2) * 100, 100, 100, 100, x * m, y * m, m, m);
}
if (x == width - 1 && y >= this.exits[level] && !doneGoal) {
if (l[y][x] == 1) {
doneGoal = true;
ctx[(c == ctx.length - 1) ? c : 7].drawImage(img[3], 1 * 100, 1 * 50, 100, 50, x * m, (y) * m, m, m / 2);
} else {
ctx[(c == ctx.length - 1) ? c : 7].drawImage(img[3], 0 * 100, 0 * 100, 100, 100, x * m, y * m, m, m);
if (y == this.exits[level]) ctx[(c == ctx.length - 1) ? c : 7].drawImage(img[3], 1 * 100, 0 * 50, 100, 50, x * m, (y - 1/2) * m, m, m / 2);
}
}
}
semiShape = semiNext;
}
// draw the buttons and spikes and walls and doors and stuff!!
this.buttons[level].forEach(function (button) {
button.activate(true, simple);
});
},
startLevel: function (level) {
if (level == this.currentLevel) { // restarting
this.buttons[level].forEach(function (button) {
button.activate(false);
});
//------- Coolmath Games -------//
if (coolMathGames) {
let parent = window.parent;
parent.cmgGameEvent("replay", (level + 1).toString());
}
//------------------------------//
} else if (level < this.levels.length) {
// No idea if the below code is something that helps with the lag AT ALL
for (let i = 0; i < this.currentLevelMap.length; i++) {
delete this.currentLevelMap[i];
}
delete this.currentLevelMap;
this.currentLevelMap = this.levels[level].map(row => [...row]);
//------- Coolmath Games -------//
if (coolMathGames) {
let parent = window.parent;
parent.cmgGameEvent("start", (level + 1).toString());
}
//------------------------------//
} else {
console.log("You beat the final level!");
this.startLevel(level - 1);
return;
}
if (level >= this.levels.length) level = this.levels.length - 1;
time = 1;
frame = 0;
stepcounter = 0;
step = 0;
clear(5);
clear(4);
this.currentLevel = level;
delete this.scores;
this.scores = [[0, 0], 0, [0, 0]];
updatePower();
this.drawLevel(level);
for (let i = 0; i < this.ghosts.length; i++) {
delete this.ghosts[i];
}
delete this.ghosts;
this.ghosts = [];
nextGhost = new Ghost();
dom.updateInstruct();
},
endLevel: function () {
// run the closing animation
let info = score.calculate(this.currentLevel, [Math.floor(Math.abs(this.scores[0][1] - this.scores[0][0]) / 60), this.scores[1], this.scores[2][0]]);
//console.log("Total Time: " + Math.abs(this.scores[0][1] - this.scores[0][0]) + ", Time-Swaps: " + this.scores[1] + ", Dino-Blocks: " + this.scores[2][0] + ", Rank: " + info[0] + ".");
//console.log(info);
/*
console.log("Ty " + info[2][0] + ", Sy " + info[2][1] + ", By " + info[2][2]);
console.log("Tg " + score.goals[this.currentLevel][0][0] + ", Sg " + score.goals[this.currentLevel][0][1] + ", Bg " + score.goals[this.currentLevel][0][2]);
*/
//console.log("Score: [" + info[2][0] + ", " + info[2][1] + ", " + info[2][2] + "]");
//console.log("Gold: [" + score.goals[this.currentLevel][0][0] + ", " + score.goals[this.currentLevel][0][1] + ", " + score.goals[this.currentLevel][0][2] + "]");
//console.log("RANK: " + info[0]);
this.buttons[this.currentLevel].forEach(function (button) {
button.activate(false);
});
document.body.querySelector("#LevelsMenu .content .back").style.display = "block";
if (autoStart) {
if (this.currentLevel < levels.levels.length - 1) {
dom.newLevel(true);
setTimeout(function () {levels.startLevel(levels.currentLevel + 1);}, 1000);
setTimeout(dom.newLevel, 1700);
} else {
dom.newMenu(0);
dom.newMenu(1);
}
// setTimeout for when to start the next level
} else {
setTimeout(function () {
dom.newLevel(false);
dom.newMenu(0);
dom.newMenu();
setTimeout(function () {
levels.currentLevel = -1;
document.body.querySelector("#LevelsMenu .content .back").style.display = "none";
}, 50);
}, 150);
}
dom.updateTotalScore(score.calcTotal());
},
update: function () {
// Check if anything should go from 1.5 to [what it was before]:
for (let y = 0; y < height; y++) {
for (let x = 0; x < width; x++) {
if (this.currentLevelMap[y][x] == 1.5) {
// run through the ghosts; is there anyone standing here now?
let there = false;
for (let i in this.ghosts) {
let g = this.ghosts[i];
if (!g.waiting) {
if (Math.floor(g.instructions[g.frame][0] / unit) == x && Math.floor(g.instructions[g.frame][1] / unit) == y && g.instructions[g.frame][6][0] == 2) {
there = true;
}
}
}
if (!there) this.currentLevelMap[y][x] = this.levels[this.currentLevel][y][x];
}
}
}
this.buttons[this.currentLevel].forEach(function (button) {
button.update();
});
},
updateTime: function (start) { // updates the score based on the total time
if (start) {
let okToWait = true;
this.buttons[this.currentLevel].forEach(function (button) {
if (button.memory[0][1] !== 1) {
button.first = Math.floor(frame / GFuel);
} else {
button.first = 0;
okToWait = false;
}
});
if (okToWait) {
this.scores[0][0] = frame;
this.scores[0][0] = frame;
}
} else {
this.scores[0][0] = (frame < this.scores[0][0]) ? frame : this.scores[0][0];
this.scores[0][1] = (frame > this.scores[0][1]) ? frame : this.scores[0][1];
}
}
}
// Score object
let score = {
goals: [], // calibrated from the 2nd parameter of 'levels.addLevel()'.
ranks: [], // array of the addition of 'goals'.
scores: [], // [rank, [0, 0, 0], message] player's information per level.
myBest: [
[2, 0, 0],
[2, 0, 0],
[2, 0, 0],
[1, 0, 0],
[2, 0, 0], // LEVEL 5 (not index)
[2, 0, 0],
[2, 1, 0],
[2, 1, 0],
[2, 0, 0],
[4, 0, 0], // LEVEL 10
[2, 1, 1],
[2, 1, 1],
[2, 1, 0],
[3, 1, 1],
[3, 0, 0], // LEVEL 15
[3, 2, 2],
[3, 0, 1],
[2, 4, 4],
[3, 0, 1],
[2, 1, 1], // LEVEL 20 (index 19)
[2, 1, 0],
[4, 0, 2],
[2, 1, 0],
[2, 1, 0], // 24
[3, 2, 3], // 25
[2, 3, 3], // 26
[4, 3, 2], // 27
[2, 2, 1], // 28
[6, 0, 2], // 29
[2, 1, 0], // 30
[6, 1, 0], // 31
[4, 3, 4], // 32
[4, 1, 2], // 33
[7, 2, 1], // 34
[11, 3, 0], // 35
[9, 6, 3], // 36
[99, 99, 99],
[99, 99, 99],
[99, 99, 99],
[99, 99, 99],
[99, 99, 99]
],
totalScore: 0, // total calibrated score.
translate: ["gold", "silver", "bronze", "uselessClass"], // translate rank (0-3) to text ("gold", etc).
messages: [ // 0-Gold 1-Silver 2-Bronze.
[
"You achieved <span class='gold'>Gold</span>, wondrous warrior!",
"You've achieved <span class='gold'>Gold</span>, fantastic fighter!",
"You've accomplished <span class='gold'>Gold</span>, super solver!",
"Your rank is <span class='gold'>Gold</span>. Nothing left to achieve.",
"Getting <span class='gold'>Gold</span> feels great, doesn't it?",
"You've reached <span class='gold'>Gold</span> rank; nice work.",
"Good luck with the rest of the levels!",
"You're <span class='gold'>Gold</span>, my friend.",
"That time you beat this level was so jazzy, <span class='gold'>Gold</span>-level player.",
"Wow! Chuck Norris didn't even get <span class='gold'>Gold</span> on this level.",
"To beat this level requires superior intellect. And you beat this level.",
"Excellent job perfoming at a <span class='gold'>Gold</span>-medal level.",
"Don't stop working hard to get that <span class='gold'>Gold</span> rank!",
"Good job reaching the rank of <span class='gold'>Gold</span>.",
"Your skill has taken you all the way to <span class='gold'>Gold</span>; well done.",
"Great work; getting <span class='gold'>Gold</span> is certainly not easy.",
"Exceptional job. You have done what you came here to do. You got <span class='gold'>Gold</span>.",
"Nothing <span class='gold'>Gold</span> can stay. That is, nothing but your legendary rank on this level.",
"Your forefathers would be proud of your <span class='gold'>Gold</span>-level achievement.",
"Noiiiiice. <br>('Cause you got <span class='gold'>Gold</span>.)",
"Pretty fantastic, what you've done. That is, getting <span class='gold'>Gold</span>.",
"Nice work getting <span class='gold'>Gold</span> on this level.",
"Your wisdom is beyond all human understanding, and it led you to the esteemed <span class='gold'>Gold</span> rank.",
"It was your destiny to reach <span class='gold'>Gold</span>, my friend.",
"You've done better than Chuck Norris: you've done <span class='gold'>Gold</span>.",
"Ya done it, my friend. Ya got the medallion of the <span class='gold'>Gold</span> alloy.",
"Amazing! I'm proud of you for getting <span class='gold'>Gold</span> on this level.",
"I'm not sure how, but you managed to get a <span class='gold'>Gold</span> medal on this level. Congrats.",
"You're really crushing these levels! <span class='gold'>Gold</span> after <span class='gold'>Gold</span> after <span class='gold'>Gold</span>."
],
[
"To reach <span class='gold'>Gold</span>, focussing on taking <span class='ital'>less in-game time</span> to solve this level will be best.",
"If <span class='silver'>Silver</span> isn't enough for you, you should try doing <span class='ital'>less time-swaps</span> to improve your rank.",
"If you're wondering how to achieve the <span class='gold'>Gold</span> rank, using <span class='ital'>less dino-blocks</span> will help you most on this level."
],
[
"You're at <span class='bronze'>Bronze</span>, but to get to <span class='silver'>Silver</span>, you should try to complete this level in <span class='ital'>less in-game time</span>.",
"The best way to improve your rank to <span class='silver'>Silver</span> will be to try doing <span class='ital'>less time-swaps</span>.",
"To reach <span class='silver'>Silver</span>, your best bet will be to try to use <span class='ital'>less dino-blocks</span>."
]
],
init: function () {
for (let i = 0; i < score.goals.length; i++) { // calibrate the 'goals'.
score.goals[i][0] = this.calibrate(score.goals[i][0]);
score.goals[i][1] = this.calibrate(score.goals[i][1]);
if (i < saved["scores"].length) {
score.scores.push(saved["scores"][i]);
} else {
score.scores.push([3, [0, 0, 0], "This level has not been completed."]);
}
}
let t = this;
t.goals.forEach((nums) => {
t.ranks.push([nums[0].reduce((a, b) => a + b, 0), nums[1].reduce((a, b) => a + b, 0)]);
});
initializeLevels();
},
calculate: function (level, [seconds, swaps, blocks], complete=true) {
let s = this.calibrate([seconds, swaps, blocks]);
let total = s.reduce((a, b) => a + b, 0);
let rank = (total <= this.ranks[level][0]) ? 0 : ((total <= this.ranks[level][1]) ? 1 : 2);
let diff = [
s[0] / (this.goals[level][(rank > 0) ? rank - 1 : 0][0] + 1),
s[1] / (this.goals[level][(rank > 0) ? rank - 1 : 0][1] + 1),
s[2] / (this.goals[level][(rank > 0) ? rank - 1 : 0][2] + 1)
];
let biggest = diff.indexOf(Math.max(...diff));
biggest = (biggest == -1) ? Math.floor(Math.random() * 3) : biggest;
let previousBest = this.scores[level][1].reduce((a, b) => a + b, 0);
console.log("(Level " + (levels.currentLevel + 1) + ") Score: [" + seconds + ", " + swaps + ", " + blocks + "] -- Rank: " + rank);
if (previousBest >= total || previousBest == 0) {
this.scores[level] = [rank, s, this.messages[rank][(rank > 0) ? biggest : Math.floor(Math.random() * (this.messages[0].length - 1))]];
if (complete) this.unlock(level + 1);
save();
return [rank, this.messages[rank][biggest], s];
} else return [rank, this.scores[level][1], s];
},
calibrate: function ([seconds, swaps, blocks], sum = false) {
// The below code needs to be super calibrated!
let calibratedScore = [seconds * 11, swaps * 79, blocks * 47];
if (!sum) return calibratedScore;
else return calibratedScore.reduce((a, b) => a + b, 0);
},
unCalibrate: function ([seconds, swaps, blocks]) {
return [Math.round(seconds / 11), Math.round(swaps / 79), Math.round(blocks / 47)];
},
displayScore: function (values, alreadyCalibrated, level) {
let value = (!alreadyCalibrated) ? this.calibrate(values).reduce((a, b) => a + b, 0) : values.reduce((a, b) => a + b, 0);
let bestScore = this.calibrate(this.myBest[level]).reduce((a, b) => a + b, 0);
if (value <= bestScore) return 1000;
let ratio = (value + 100) / (bestScore + 100);
let newValue = Math.floor(1000 / ratio);
//console.log(Math.floor(ratio * 1000) / 1000 + " --> " + newValue);
return newValue;
},
unlock: function (newLevel) {
// unlock the level in the html.
//console.log("Unlocking Level " + (newLevel + 1));
if (newLevel >= levels.levels.length) {
//console.log("You've beat the final level!!");
if (newLevel == levels.levels.length) {
let bar = document.querySelector("tr #td" + (newLevel) + " .bar");
//console.log("And you got " + score.translate[this.scores[newLevel - 1][0]] + ". (noice)");
bar.classList.add(score.translate[this.scores[newLevel - 1][0]]);
save();
}
return;
}
let td = document.querySelector("tr #td" + (newLevel + 1));
td.classList.remove("locked");
td.setAttribute("onclick", "dom.play(" + (newLevel + 1) + ");");
// update the bar for the previous level
let bar = document.querySelector("tr #td" + (newLevel) + " .bar");
//console.log(score.translate[this.scores[newLevel - 1][0]]);
bar.classList.add(score.translate[this.scores[newLevel - 1][0]]);
},
calcTotal: function () {
let curr = 0;
for (let l = 0; l < this.scores.length; l++) {
let calibrated = score.displayScore(this.scores[l][1], true, l);
if (this.scores[l][1].reduce((a, b) => a + b, 0) > 0) curr += calibrated;
}
this.totalScore = curr;
return curr;
}
}
// LEVELS
// Level creation!
/*
((template below))
// DIFFICULTY: 0 / 10
// MY PERSONAL BEST ON BELOW: [9, 9, 9]
levels.addLevel([
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
],
[[15, 0, 0], [25, 0, 0]], // [Gold, Silver] --> [seconds, swaps, blocks]
0, // [goal-y]
[],
0, 0 // swaps, blocks
); // ^ LEVEL index ##
*/
//////////////////////////////////////////////
//////////////////////////////////////////////
///////// LEVELS FOR YouTube TRAILER /////////
//////////////////////////////////////////////
//////////////////////////////////////////////
/*
levels.addLevel([
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 1, 2, 1, 1, 1, 2, 1, 1, 0, 0, 0],
[3, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0],
[1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1]
],
[[15, 0, 0], [25, 0, 0]], // [Gold, Silver] --> [seconds, swaps, blocks]
0, // [goal-y]
[
new Button(
2, [0, 0], 1,
[
new Lazer([8, [-1, 9]], "Swap", false)
],
true
)
],
10, 10 // swaps, blocks
); // VIDEO LEVEL 3
levels.addLevel([
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 1, 1, 1, 1],
[0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[3, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0]
],
[[15, 0, 0], [25, 0, 0]], // [Gold, Silver] --> [seconds, swaps, blocks]
4, // [goal-y]
[
new Button(
1, [3, 10], 1,
[
new Spikes([[7, 10, 1]], 1),
new Lazer([12, [3, 7]], "Kill", false)
]
)
],
10, 10 // swaps, blocks
); // VIDEO LEVEL 3
levels.addLevel([
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 1, 1, 1, 1]
],
[[15, 0, 0], [25, 0, 0]], // [Gold, Silver] --> [seconds, swaps, blocks]
0, // [goal-y]
[
new Button(
0, [4, 10], 0,
[
new Walls([[11, 8, 1]])
]
),
],
10, 10 // swaps, blocks
); // VIDEO LEVEL 1
levels.addLevel([
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1],
[0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1],
[3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
],
[[15, 0, 0], [25, 0, 0]], // [Gold, Silver] --> [seconds, swaps, blocks]
0, // [goal-y]
[],
0, 0 // swaps, blocks
); // VIDEO LEVEL 0
*/
levels.addLevel([
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
],
[[12, 0, 0], [30, 0, 0]],
0,
[
new Button(
2, [0, 0], 0,
[
new Lazer([10, [4, 8]], "Swap", false)
],
true
),
new Button(
0, [3, 10], 0,
[
new Walls([[12, 7, 1]])
]
),
],
0, 0
); // ^ LEVEL index 4
levels.addLevel([
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0],
[3, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0],
[1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1],
],
[[4, 0, 0], [15, 0, 0]],
0,
[],
0, 0
); // ^ LEVEL index 5
levels.addLevel([
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0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0, 0, 0, 0, 0, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
],
[[10, 1, 1], [20, 3, 3]],
0,
[
new Button(
1, [13, 8], 0,
[
new Spikes([[10, 10, 1], [11, 10, 1]], 1)
]
)
],
3, 3
); // ^ LEVEL index 10
levels.addLevel([
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 2, 2, 1, 1, 1, 1, 1, 0, 0],
[0, 0, 0, 0, 2, 2, 2, 1, 1, 1, 0, 0, 0, 1, 1, 1],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
],
[[5, 1, 1], [20, 3, 2]],
0,
[
new Button(
0, [0, 0], 0,
[
new Lazer([11, [-1, 5]], "Kill", false)
],
true
),
],
3, 3
); // ^ LEVEL index 11
levels.addLevel([
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1],
[0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0],
[0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0],
[0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0],
[0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0],
[3, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0],
[1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1],
],
[[5, 1, 0], [15, 2, 1]],
0,
[
new Button(
3, [2, 8], 0,
[
new Blocks([[7, 5, 0], [8, 5, 0], [13, 2, 1], [13, 3, 1]])
]
)
],
3, 0
); // ^ LEVEL index 12
levels.addLevel([
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],