-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsl.ts
631 lines (565 loc) · 14.8 KB
/
sl.ts
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
import { delay } from "jsr:@std/[email protected]/delay";
import TermBox from "jsr:@deno-library/termbox";
const termbox = new TermBox();
const D51HEIGHT = 10;
const D51FUNNEL = 7;
const D51LENGTH = 83;
const D51PATTERNS = 6;
const D51STR1 = " ==== ________ ___________ ";
const D51STR2 = " _D _| |_______/ \\__I_I_____===__|_________| ";
const D51STR3 = " |(_)--- | H\\________/ | | =|___ ___| ";
const D51STR4 = " / | | H | | | | ||_| |_|| ";
const D51STR5 = " | | | H |__--------------------| [___] | ";
const D51STR6 = " | ________|___H__/__|_____/[][]~\\_______| | ";
const D51STR7 = " |/ | |-----------I_____I [][] [] D |=======|__ ";
const D51WHL11 = "__/ =| o |=-~~\\ /~~\\ /~~\\ /~~\\ ____Y___________|__ ";
const D51WHL12 = " |/-=|___|= || || || |_____/~\\___/ ";
const D51WHL13 = " \\_/ \\O=====O=====O=====O_/ \\_/ ";
const D51WHL21 = "__/ =| o |=-~~\\ /~~\\ /~~\\ /~~\\ ____Y___________|__ ";
const D51WHL22 = " |/-=|___|=O=====O=====O=====O |_____/~\\___/ ";
const D51WHL23 = " \\_/ \\__/ \\__/ \\__/ \\__/ \\_/ ";
const D51WHL31 = "__/ =| o |=-O=====O=====O=====O \\ ____Y___________|__ ";
const D51WHL32 = " |/-=|___|= || || || |_____/~\\___/ ";
const D51WHL33 = " \\_/ \\__/ \\__/ \\__/ \\__/ \\_/ ";
const D51WHL41 = "__/ =| o |=-~O=====O=====O=====O\\ ____Y___________|__ ";
const D51WHL42 = " |/-=|___|= || || || |_____/~\\___/ ";
const D51WHL43 = " \\_/ \\__/ \\__/ \\__/ \\__/ \\_/ ";
const D51WHL51 = "__/ =| o |=-~~\\ /~~\\ /~~\\ /~~\\ ____Y___________|__ ";
const D51WHL52 = " |/-=|___|= O=====O=====O=====O|_____/~\\___/ ";
const D51WHL53 = " \\_/ \\__/ \\__/ \\__/ \\__/ \\_/ ";
const D51WHL61 = "__/ =| o |=-~~\\ /~~\\ /~~\\ /~~\\ ____Y___________|__ ";
const D51WHL62 = " |/-=|___|= || || || |_____/~\\___/ ";
const D51WHL63 = " \\_/ \\_O=====O=====O=====O/ \\_/ ";
const D51DEL = " ";
const COAL01 = " ";
const COAL02 = " ";
const COAL03 = " _________________ ";
const COAL04 = " _| \\_____A ";
const COAL05 = " =| | ";
const COAL06 = " -| | ";
const COAL07 = "__|________________________|_ ";
const COAL08 = "|__________________________|_ ";
const COAL09 = " |_D__D__D_| |_D__D__D_| ";
const COAL10 = " \\_/ \\_/ \\_/ \\_/ ";
const COALDEL = " ";
const LOGOHEIGHT = 6;
const LOGOFUNNEL = 4;
const LOGOLENGTH = 84;
const LOGOPATTERNS = 6;
const LOGO1 = " ++ +------ ";
const LOGO2 = " || |+-+ | ";
const LOGO3 = " /---------|| | | ";
const LOGO4 = " + ======== +-+ | ";
const LWHL11 = " _|--O========O~\\-+ ";
const LWHL12 = "//// \\_/ \\_/ ";
const LWHL21 = " _|--/O========O\\-+ ";
const LWHL22 = "//// \\_/ \\_/ ";
const LWHL31 = " _|--/~O========O-+ ";
const LWHL32 = "//// \\_/ \\_/ ";
const LWHL41 = " _|--/~\\------/~\\-+ ";
const LWHL42 = "//// \\_O========O ";
const LWHL51 = " _|--/~\\------/~\\-+ ";
const LWHL52 = "//// \\O========O/ ";
const LWHL61 = " _|--/~\\------/~\\-+ ";
const LWHL62 = "//// O========O_/ ";
const LCOAL1 = "____ ";
const LCOAL2 = "| \\@@@@@@@@@@@ ";
const LCOAL3 = "| \\@@@@@@@@@@@@@_ ";
const LCOAL4 = "| | ";
const LCOAL5 = "|__________________| ";
const LCOAL6 = " (O) (O) ";
const LCAR1 = "____________________ ";
const LCAR2 = "| ___ ___ ___ ___ | ";
const LCAR3 = "| |_| |_| |_| |_| | ";
const LCAR4 = "|__________________| ";
const LCAR5 = "|__________________| ";
const LCAR6 = " (O) (O) ";
const DELLN = " ";
const C51HEIGHT = 11;
const C51FUNNEL = 7;
const C51LENGTH = 87;
const C51PATTERNS = 6;
const C51DEL = " ";
const C51STR1 = " ___ ";
const C51STR2 = " _|_|_ _ __ __ ___________";
const C51STR3 = " D__/ \\_(_)___| |__H__| |_____I_Ii_()|_________|";
const C51STR4 = " | `---' |:: `--' H `--' | |___ ___| ";
const C51STR5 = " +|~~~~~~~~++::~~~~~~~H~~+=====+~~~~~~|~~||_| |_|| ";
const C51STR6 = " || | :: H +=====+ | |:: ...| ";
const C51STR7 = "| | _______|_::-----------------[][]-----| | ";
const C51WH61 = "| /~~ || |-----/~~~~\\ /[I_____I][][] --|||_______|__";
const C51WH62 = "------'|oOo|==[]=- || || | ||=======_|__";
const C51WH63 = "/~\\____|___|/~\\_| O=======O=======O |__|+-/~\\_| ";
const C51WH64 = "\\_/ \\_/ \\____/ \\____/ \\____/ \\_/ ";
const C51WH51 = "| /~~ || |-----/~~~~\\ /[I_____I][][] --|||_______|__";
const C51WH52 = "------'|oOo|===[]=- || || | ||=======_|__";
const C51WH53 = "/~\\____|___|/~\\_| O=======O=======O |__|+-/~\\_| ";
const C51WH54 = "\\_/ \\_/ \\____/ \\____/ \\____/ \\_/ ";
const C51WH41 = "| /~~ || |-----/~~~~\\ /[I_____I][][] --|||_______|__";
const C51WH42 = "------'|oOo|===[]=- O=======O=======O | ||=======_|__";
const C51WH43 = "/~\\____|___|/~\\_| || || |__|+-/~\\_| ";
const C51WH44 = "\\_/ \\_/ \\____/ \\____/ \\____/ \\_/ ";
const C51WH31 = "| /~~ || |-----/~~~~\\ /[I_____I][][] --|||_______|__";
const C51WH32 = "------'|oOo|==[]=- O=======O=======O | ||=======_|__";
const C51WH33 = "/~\\____|___|/~\\_| || || |__|+-/~\\_| ";
const C51WH34 = "\\_/ \\_/ \\____/ \\____/ \\____/ \\_/ ";
const C51WH21 = "| /~~ || |-----/~~~~\\ /[I_____I][][] --|||_______|__";
const C51WH22 = "------'|oOo|=[]=- O=======O=======O | ||=======_|__";
const C51WH23 = "/~\\____|___|/~\\_| || || |__|+-/~\\_| ";
const C51WH24 = "\\_/ \\_/ \\____/ \\____/ \\____/ \\_/ ";
const C51WH11 = "| /~~ || |-----/~~~~\\ /[I_____I][][] --|||_______|__";
const C51WH12 = "------'|oOo|=[]=- || || | ||=======_|__";
const C51WH13 = "/~\\____|___|/~\\_| O=======O=======O |__|+-/~\\_| ";
const C51WH14 = "\\_/ \\_/ \\____/ \\____/ \\____/ \\_/ ";
let ACCIDENT = 0;
let LOGO = 0;
let FLY = 0;
let C51 = 0;
const ERR = -1;
const COLS = Deno.consoleSize().columns;
const LINES = Deno.consoleSize().rows;
function my_mvaddstr(y: number, x: number, str: string): void {
for (; x < 0; x++, str = str.substring(1)) {
if (str.length == 0) {
return;
}
}
for (const char of str) {
termbox.setCell(x, y, char);
x++;
}
}
function option(str: string) {
for (const char of str) {
switch (char) {
case "a":
ACCIDENT = 1;
break;
case "F":
FLY = 1;
break;
case "l":
LOGO = 1;
break;
case "c":
C51 = 1;
break;
default:
break;
}
}
}
const add_sl = (function () {
const sl = [
[LOGO1, LOGO2, LOGO3, LOGO4, LWHL11, LWHL12, DELLN],
[LOGO1, LOGO2, LOGO3, LOGO4, LWHL21, LWHL22, DELLN],
[LOGO1, LOGO2, LOGO3, LOGO4, LWHL31, LWHL32, DELLN],
[LOGO1, LOGO2, LOGO3, LOGO4, LWHL41, LWHL42, DELLN],
[LOGO1, LOGO2, LOGO3, LOGO4, LWHL51, LWHL52, DELLN],
[LOGO1, LOGO2, LOGO3, LOGO4, LWHL61, LWHL62, DELLN],
];
const coal = [LCOAL1, LCOAL2, LCOAL3, LCOAL4, LCOAL5, LCOAL6, DELLN];
const car = [LCAR1, LCAR2, LCAR3, LCAR4, LCAR5, LCAR6, DELLN];
return function (x: number) {
let i,
y,
py1 = 0,
py2 = 0,
py3 = 0;
if (x < -LOGOLENGTH) return ERR;
y = Math.floor(LINES / 2) - 3;
if (FLY === 1) {
y = Math.floor(x / 6) + LINES - Math.floor(COLS / 6) - LOGOHEIGHT;
py1 = 2;
py2 = 4;
py3 = 6;
}
for (i = 0; i <= LOGOHEIGHT; ++i) {
my_mvaddstr(
y + i,
x,
sl[Math.floor((LOGOLENGTH + x) / 3) % LOGOPATTERNS][i],
);
my_mvaddstr(y + i + py1, x + 21, coal[i]);
my_mvaddstr(y + i + py2, x + 42, car[i]);
my_mvaddstr(y + i + py3, x + 63, car[i]);
}
if (ACCIDENT === 1) {
add_man(y + 1, x + 14);
add_man(y + 1 + py2, x + 45);
add_man(y + 1 + py2, x + 53);
add_man(y + 1 + py3, x + 66);
add_man(y + 1 + py3, x + 74);
}
add_smoke(y - 1, x + LOGOFUNNEL);
};
})();
const add_D51 = (function add_D51() {
const d51 = [
[
D51STR1,
D51STR2,
D51STR3,
D51STR4,
D51STR5,
D51STR6,
D51STR7,
D51WHL11,
D51WHL12,
D51WHL13,
D51DEL,
],
[
D51STR1,
D51STR2,
D51STR3,
D51STR4,
D51STR5,
D51STR6,
D51STR7,
D51WHL21,
D51WHL22,
D51WHL23,
D51DEL,
],
[
D51STR1,
D51STR2,
D51STR3,
D51STR4,
D51STR5,
D51STR6,
D51STR7,
D51WHL31,
D51WHL32,
D51WHL33,
D51DEL,
],
[
D51STR1,
D51STR2,
D51STR3,
D51STR4,
D51STR5,
D51STR6,
D51STR7,
D51WHL41,
D51WHL42,
D51WHL43,
D51DEL,
],
[
D51STR1,
D51STR2,
D51STR3,
D51STR4,
D51STR5,
D51STR6,
D51STR7,
D51WHL51,
D51WHL52,
D51WHL53,
D51DEL,
],
[
D51STR1,
D51STR2,
D51STR3,
D51STR4,
D51STR5,
D51STR6,
D51STR7,
D51WHL61,
D51WHL62,
D51WHL63,
D51DEL,
],
];
const coal = [
COAL01,
COAL02,
COAL03,
COAL04,
COAL05,
COAL06,
COAL07,
COAL08,
COAL09,
COAL10,
COALDEL,
];
return function (x: number) {
let y,
i,
dy = 0;
if (x < -D51LENGTH) return ERR;
y = Math.floor(LINES / 2) - 5;
if (FLY === 1) {
y = Math.floor(x / 7) + LINES - Math.floor(COLS / 7) - D51HEIGHT;
dy = 1;
}
for (i = 0; i <= D51HEIGHT; ++i) {
my_mvaddstr(y + i, x, d51[(D51LENGTH + x) % D51PATTERNS][i]);
my_mvaddstr(y + i + dy, x + 53, coal[i]);
}
if (ACCIDENT === 1) {
add_man(y + 2, x + 43);
add_man(y + 2, x + 47);
}
add_smoke(y - 1, x + D51FUNNEL);
};
})();
const add_smoke = (function () {
interface Smoke {
y: number;
x: number;
ptrn: number;
kind: number;
}
const SMOKEPTNS = 16;
const S: Smoke[] = new Array(1000).fill(null).map(() => ({
y: 0,
x: 0,
ptrn: 0,
kind: 0,
}));
let sum = 0;
const Smoke: string[][] = [
[
"( )",
"( )",
"( )",
"( )",
"( )",
"( )",
"( )",
"( )",
"()",
"()",
"O",
"O",
"O",
"O",
"O",
" ",
],
[
"(@@@)",
"(@@@@)",
"(@@@@)",
"(@@@)",
"(@@)",
"(@@)",
"(@)",
"(@)",
"@@",
"@@",
"@",
"@",
"@",
"@",
"@",
" ",
],
];
const Eraser: string[] = [
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
];
const dy: number[] = [2, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
const dx: number[] = [-2, -1, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3];
return function (y: number, x: number) {
if (x % 4 === 0) {
for (let i = 0; i < sum; ++i) {
my_mvaddstr(S[i].y, S[i].x, Eraser[S[i].ptrn]);
S[i].y -= dy[S[i].ptrn];
S[i].x += dx[S[i].ptrn];
S[i].ptrn += S[i].ptrn < SMOKEPTNS - 1 ? 1 : 0;
my_mvaddstr(S[i].y, S[i].x, Smoke[S[i].kind][S[i].ptrn]);
}
my_mvaddstr(y, x, Smoke[sum % 2][0]);
S[sum].y = y;
S[sum].x = x;
S[sum].ptrn = 0;
S[sum].kind = sum % 2;
sum++;
}
};
})();
const add_man = (function () {
const man = [
["", "(O)"],
["Help!", "\\O/"],
];
return function (y: number, x: number) {
for (let i = 0; i < 2; ++i) {
my_mvaddstr(y + i, x, man[Math.floor((LOGOLENGTH + x) / 12) % 2][i]);
}
};
})();
const add_C51 = (function () {
const c51 = [
[
C51STR1,
C51STR2,
C51STR3,
C51STR4,
C51STR5,
C51STR6,
C51STR7,
C51WH11,
C51WH12,
C51WH13,
C51WH14,
C51DEL,
],
[
C51STR1,
C51STR2,
C51STR3,
C51STR4,
C51STR5,
C51STR6,
C51STR7,
C51WH21,
C51WH22,
C51WH23,
C51WH24,
C51DEL,
],
[
C51STR1,
C51STR2,
C51STR3,
C51STR4,
C51STR5,
C51STR6,
C51STR7,
C51WH31,
C51WH32,
C51WH33,
C51WH34,
C51DEL,
],
[
C51STR1,
C51STR2,
C51STR3,
C51STR4,
C51STR5,
C51STR6,
C51STR7,
C51WH41,
C51WH42,
C51WH43,
C51WH44,
C51DEL,
],
[
C51STR1,
C51STR2,
C51STR3,
C51STR4,
C51STR5,
C51STR6,
C51STR7,
C51WH51,
C51WH52,
C51WH53,
C51WH54,
C51DEL,
],
[
C51STR1,
C51STR2,
C51STR3,
C51STR4,
C51STR5,
C51STR6,
C51STR7,
C51WH61,
C51WH62,
C51WH63,
C51WH64,
C51DEL,
],
];
const coal = [
COALDEL,
COAL01,
COAL02,
COAL03,
COAL04,
COAL05,
COAL06,
COAL07,
COAL08,
COAL09,
COAL10,
COALDEL,
];
return function (x: number) {
let y,
i,
dy = 0;
if (x < -C51LENGTH) return ERR;
y = Math.floor(LINES / 2) - 5;
if (FLY === 1) {
y = Math.floor(x / 7) + LINES - Math.floor(COLS / 7) - C51HEIGHT;
dy = 1;
}
for (i = 0; i <= C51HEIGHT; ++i) {
my_mvaddstr(y + i, x, c51[(C51LENGTH + x) % C51PATTERNS][i]);
my_mvaddstr(y + i + dy, x + 55, coal[i]);
}
if (ACCIDENT === 1) {
add_man(y + 3, x + 45);
add_man(y + 3, x + 49);
}
add_smoke(y - 1, x + C51FUNNEL);
};
})();
async function main() {
const args = Deno.args;
for (const arg of args) {
if (arg[0] === "-") {
option(arg.substring(1));
}
}
// const { columns, rows } = await termbox.cursorPosition();
// await termbox.cursorSave();
await termbox.cursorHide();
await termbox.screenClear();
for (let x = COLS - 1;; --x) {
if (LOGO === 1) {
if (add_sl(x) === ERR) break;
} else if (C51 === 1) {
if (add_C51(x) === ERR) break;
} else {
if (add_D51(x) === ERR) break;
}
await delay(40);
await termbox.flush();
}
await termbox.cursorTo(0, 0);
// await termbox.cursorTo(rows - 1, columns - 1);
// await termbox.cursorTo(LINES-1, COLS-1);
// await termbox.cursorRestore();
await termbox.cursorShow();
termbox.end();
}
main();