terminull-arcade 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,13 +11,13 @@ var ALL_GAMES_METADATA = {
11
11
  id: "packet-man",
12
12
  name: "Packet Man",
13
13
  tagline: "Chomp byte pellets and evade rogue memory daemons",
14
- description: "Classic maze arcade: navigate memory labyrinths, chomp clean data bits, grab Super Capacitors, and hunt vulnerable daemons.",
14
+ description: "Classic maze arcade: navigate labyrinths, chomp pellets, grab Super Capacitors, and hunt vulnerable daemons.",
15
15
  category: "arcade",
16
16
  difficultyLevels: ["easy", "normal", "hard", "insane"],
17
17
  controls: [
18
- { key: "Arrow Keys / WASD", action: "Direct Packet Man", description: "Navigate through memory grid" },
18
+ { key: "Arrow Keys / WASD", action: "Move Packet Man", description: "Navigate through corridors" },
19
19
  { key: "Esc / P", action: "Pause Menu", description: "Open pause / exit dialog" },
20
- { key: "R", action: "Restart Game", description: "Restart from level 1" },
20
+ { key: "R", action: "Restart Game", description: "Restart round" },
21
21
  { key: "Q", action: "Quit", description: "Return to arcade menu" }
22
22
  ],
23
23
  achievements: [
@@ -26,231 +26,62 @@ var ALL_GAMES_METADATA = {
26
26
  { id: "maze_sweeper", title: "Zero Remaining", description: "Clear an entire memory maze board" }
27
27
  ]
28
28
  },
29
- "neon-circuit": {
30
- id: "neon-circuit",
31
- name: "Neon Circuit",
32
- tagline: "Route pure energy through cybernetic node grids",
33
- description: "Grid puzzle: rotate circuit conduits to bridge power cores before capacity depletes.",
34
- category: "puzzle",
35
- difficultyLevels: ["easy", "normal", "hard", "insane"],
36
- controls: [
37
- { key: "Arrow Keys / WASD", action: "Navigate Grid", description: "Move circuit cursor" },
38
- { key: "Space / Enter", action: "Rotate Tile", description: "Rotate wire 90 degrees clockwise" },
39
- { key: "R", action: "Reset Grid", description: "Reset puzzle to initial state" },
40
- { key: "P / Esc", action: "Pause Menu", description: "Open pause dialog" }
41
- ],
42
- achievements: [
43
- { id: "first_spark", title: "First Spark", description: "Complete your first circuit" },
44
- { id: "overclocked", title: "Overclocked Flow", description: "Complete a level with 5+ moves remaining" },
45
- { id: "grid_master", title: "Grid Overlord", description: "Solve an insane circuit puzzle" }
46
- ]
47
- },
48
- "byte-runner": {
49
- id: "byte-runner",
50
- name: "Byte Runner",
51
- tagline: "Sprint down the endless packet highway",
52
- description: "Arcade runner: dodge fragmented corruptions, vacuum clean packets, and engage subroutines.",
29
+ "cyber-viper": {
30
+ id: "cyber-viper",
31
+ name: "Cyber Viper",
32
+ tagline: "Feast on energy apples, grow longer, avoid your tail",
33
+ description: "The definitive snake arcade: steer your viper, feast on glowing energy apples, and snag rare golden bonus orbs.",
53
34
  category: "arcade",
54
35
  difficultyLevels: ["easy", "normal", "hard", "insane"],
55
36
  controls: [
56
- { key: "Left / Right / A / D", action: "Change Lane", description: "Shift between data lanes" },
57
- { key: "Up / W / Space", action: "Phase Jump", description: "Hop over low corruptions" },
58
- { key: "Down / S", action: "Downlink Boost", description: "Dive fast or slide" },
59
- { key: "P / Esc", action: "Pause Menu", description: "Open pause dialog" }
60
- ],
61
- achievements: [
62
- { id: "packet_chaser", title: "Packet Chaser", description: "Collect 50 clean byte clusters" },
63
- { id: "shield_matrix", title: "Hardened Buffer", description: "Absorb a collision with an active shield" },
64
- { id: "hyperspeed", title: "Fiber Velocity", description: "Reach a distance score over 5,000" }
65
- ]
66
- },
67
- "terminal-typer": {
68
- id: "terminal-typer",
69
- name: "Terminal Typer",
70
- tagline: "Type command scripts under time compression",
71
- description: "Speed typing gauntlet featuring bash pipelines, system calls, and code syntaxes.",
72
- category: "educational",
73
- difficultyLevels: ["easy", "normal", "hard", "insane"],
74
- controls: [
75
- { key: "Keyboard", action: "Type Characters", description: "Input matching terminal tokens" },
76
- { key: "Backspace", action: "Erase Token", description: "Fix typographical mistakes" },
77
- { key: "Esc", action: "Abort Session", description: "Exit or pause typing trial" }
78
- ],
79
- achievements: [
80
- { id: "prompt_novice", title: "Prompt Novice", description: "Achieve 40+ WPM with 95% accuracy" },
81
- { id: "bash_wizard", title: "Shell Maestro", description: "Type 100+ tokens without a typo" },
82
- { id: "laser_fingers", title: "Ghost Typist", description: "Break 90 WPM in survival mode" }
83
- ]
84
- },
85
- "stack-overflow": {
86
- id: "stack-overflow",
87
- name: "Stack Overflow",
88
- tagline: "Gravity-driven memory buffer management",
89
- description: "Dynamic block sorting puzzle where volatile stack frames cascade with chain reactions.",
90
- category: "puzzle",
91
- difficultyLevels: ["easy", "normal", "hard", "insane"],
92
- controls: [
93
- { key: "Left / Right", action: "Move Frame", description: "Shift stack block horizontally" },
94
- { key: "Down", action: "Soft Drop", description: "Accelerate memory fall" },
95
- { key: "Space", action: "Hard Commit", description: "Instantly drop frame" },
96
- { key: "P / Esc", action: "Pause Menu", description: "Open pause dialog" }
97
- ],
98
- achievements: [
99
- { id: "clean_stack", title: "Clean Stack", description: "Clear 4 memory lines simultaneously" },
100
- { id: "patch_master", title: "Hotfixer", description: "Neutralize 3 bug blocks" },
101
- { id: "buffer_hero", title: "Buffer Sovereign", description: "Score 10,000 in stack clearance" }
102
- ]
103
- },
104
- "cipher-hunt": {
105
- id: "cipher-hunt",
106
- name: "Cipher Hunt",
107
- tagline: "Cryptographic sleuth investigation cases",
108
- description: "Decrypt encoded transcripts, Caesar shifts, and hex forensics across 20 dossier archives.",
109
- category: "puzzle",
110
- difficultyLevels: ["easy", "normal", "hard", "insane"],
111
- controls: [
112
- { key: "Tab / Arrows", action: "Select Glyph", description: "Navigate encrypted strings" },
113
- { key: "A-Z / 0-9", action: "Substitute", description: "Set plaintext hypothesis" },
114
- { key: "H", action: "Decrypt Hint", description: "Reveal partial key" },
115
- { key: "Esc", action: "Case File", description: "Return to dossiers" }
116
- ],
117
- achievements: [
118
- { id: "first_clue", title: "Cipher Initiate", description: "Solve Case 01" },
119
- { id: "master_decoder", title: "Cryptanalyst", description: "Decode a message with 0 hints" },
120
- { id: "cold_case", title: "Archivist Prime", description: "Complete all 20 dossiers" }
121
- ]
122
- },
123
- "pixel-farm": {
124
- id: "pixel-farm",
125
- name: "Pixel Farm",
126
- tagline: "Cultivate algorithmic soil and seasonal yields",
127
- description: "Turn-based agricultural economy: balance moisture, harvest cyber-flora, and trade commodities.",
128
- category: "strategy",
129
- difficultyLevels: ["easy", "normal", "hard", "insane"],
130
- controls: [
131
- { key: "Arrow Keys", action: "Inspect Plot", description: "Move across farm coordinates" },
132
- { key: "P", action: "Plant Seed", description: "Sow current selected crop" },
133
- { key: "W", action: "Irrigate", description: "Water target soil parcel" },
134
- { key: "H", action: "Harvest", description: "Reap ripe crop" }
135
- ],
136
- achievements: [
137
- { id: "green_byte", title: "Green Byte", description: "Harvest your first algorithmic crop" },
138
- { id: "market_mogul", title: "Market Mogul", description: "Accumulate 1,000 digital credits" },
139
- { id: "four_seasons", title: "Solstice Keeper", description: "Survive four complete seasonal cycles" }
140
- ]
141
- },
142
- "ghost-protocol": {
143
- id: "ghost-protocol",
144
- name: "Ghost Protocol",
145
- tagline: "Infiltrate surveillance networks in silence",
146
- description: "ASCII stealth labyrinth: navigate patrolling guard sensory cones, extract secrets, and vanish.",
147
- category: "action",
148
- difficultyLevels: ["easy", "normal", "hard", "insane"],
149
- controls: [
150
- { key: "WASD / Arrows", action: "Sneak Step", description: "Move agent in grid" },
151
- { key: "Shift + Move", action: "Sprint (Noisy)", description: "Move double distance with audio footprint" },
152
- { key: "E", action: "Extract Node", description: "Extract data drive from terminal" },
153
- { key: "P / Esc", action: "Tactical Pause", description: "Survey grid telemetry" }
154
- ],
155
- achievements: [
156
- { id: "unseen_whisper", title: "Zero Trace", description: "Extract all data without detection" },
157
- { id: "phantom_agent", title: "Phantom Operative", description: "Complete floor in under 60 seconds" },
158
- { id: "black_ops", title: "Black Hat Ghost", description: "Survive on insane security protocols" }
159
- ]
160
- },
161
- "quantum-chess": {
162
- id: "quantum-chess",
163
- name: "Quantum Chess",
164
- tagline: "Superposition tactics on a dual-state board",
165
- description: "Chess variant where pieces inhabit multiple squares until observation collapses reality.",
166
- category: "strategy",
167
- difficultyLevels: ["easy", "normal", "hard", "insane"],
168
- controls: [
169
- { key: "Arrows / WASD", action: "Target Tile", description: "Hover board positions" },
170
- { key: "Enter / Space", action: "Select / Move", description: "Designate quantum split or standard step" },
171
- { key: "C", action: "Collapse State", description: "Force measurement on entangled pieces" },
172
- { key: "M", action: "Toggle Mode", description: "Toggle between Single and 2-Player" }
37
+ { key: "Arrow Keys / WASD", action: "Steer Viper", description: "Turn direction" },
38
+ { key: "Esc / P", action: "Pause Menu", description: "Open pause / exit dialog" },
39
+ { key: "R", action: "Restart", description: "Try again immediately" },
40
+ { key: "Q", action: "Quit", description: "Return to arcade menu" }
173
41
  ],
174
42
  achievements: [
175
- { id: "schrodinger_gambit", title: "Schr\xF6dinger Gambit", description: "Split a piece into twin superpositions" },
176
- { id: "wave_collapse", title: "Decoherence", description: "Win a match via observation capture" },
177
- { id: "grandmaster_q", title: "Quantum Maestro", description: "Defeat the Deep State quantum engine" }
43
+ { id: "first_bite", title: "First Crunch", description: "Eat your first energy apple" },
44
+ { id: "golden_feast", title: "Golden Appetite", description: "Snag a rare golden power orb" },
45
+ { id: "long_viper", title: "Anaconda Protocol", description: "Reach a snake length of 25 segments" }
178
46
  ]
179
47
  },
180
- "bug-squash": {
181
- id: "bug-squash",
182
- name: "Bug Squash",
183
- tagline: "Defend source trees from recursive infestation",
184
- description: "Arcade exterminator: track bugs crawling over code files, deploy patches, and crush boss defects.",
48
+ "void-invaders": {
49
+ id: "void-invaders",
50
+ name: "Space Invaders",
51
+ tagline: "Shoot descending alien invaders before they hit ground",
52
+ description: "Classic space shooter: slide your cannon left and right, blast descending alien scouts, and defend earth across 3 lives.",
185
53
  category: "arcade",
186
54
  difficultyLevels: ["easy", "normal", "hard", "insane"],
187
55
  controls: [
188
- { key: "Arrow Keys", action: "Target Reticle", description: "Move debugger pointer" },
189
- { key: "Space", action: "Deploy Patch", description: "Squash insect at crosshair" },
190
- { key: "B", action: "Breakpoint Bomb", description: "Clear all bugs in current scope" },
191
- { key: "P / Esc", action: "Pause Menu", description: "Pause debug session" }
192
- ],
193
- achievements: [
194
- { id: "debugger_prime", title: "Zero Warnings", description: "Squash 50 runtime anomalies" },
195
- { id: "combo_streak", title: "Hex Striker", description: "Maintain a 10x elimination streak" },
196
- { id: "boss_squashed", title: "Null Pointer Slayer", description: "Defeat the Memory Leak Boss" }
197
- ]
198
- },
199
- "memory-matrix": {
200
- id: "memory-matrix",
201
- name: "Memory Matrix",
202
- tagline: "Recall sensory sequences in cybernetic resonance",
203
- description: "Choreographed recall challenge: echo complex terminal sound-and-symbol telemetry patterns.",
204
- category: "puzzle",
205
- difficultyLevels: ["easy", "normal", "hard", "insane"],
206
- controls: [
207
- { key: "1, 2, 3, 4 / Arrows", action: "Input Sector", description: "Replicate pulse quadrant" },
208
- { key: "Space", action: "Commit Sequence", description: "Finalize answer" },
209
- { key: "D", action: "Daily Seed", description: "Toggle Daily Challenge pattern" },
210
- { key: "P / Esc", action: "Pause Menu", description: "Open pause dialog" }
211
- ],
212
- achievements: [
213
- { id: "perfect_recall", title: "Synaptic Link", description: "Reach sequence level 10" },
214
- { id: "daily_champ", title: "Daily Chronicler", description: "Conquer the daily matrix seed" },
215
- { id: "coop_harmony", title: "Twin Processors", description: "Complete a round in co-op mode" }
216
- ]
217
- },
218
- "space-salvage": {
219
- id: "space-salvage",
220
- name: "Space Salvage",
221
- tagline: "Command derelict recovery in orbital graveyards",
222
- description: "Strategic roguelite: balance crew oxygen, thermal levels, salvage weight, and rogue defense drones.",
223
- category: "strategy",
224
- difficultyLevels: ["easy", "normal", "hard", "insane"],
225
- controls: [
226
- { key: "1-5", action: "Order Crew", description: "Dispatch scavengers to bulkheads" },
227
- { key: "Space", action: "Next Turn", description: "Advance exploration tick" },
228
- { key: "J", action: "Jettison Cargo", description: "Lighten load for emergency thrusters" },
229
- { key: "Esc", action: "Status HUD", description: "Inspect ship schematics" }
56
+ { key: "Left / Right / A / D", action: "Move Cannon", description: "Slide laser cannon" },
57
+ { key: "Space", action: "Fire Laser", description: "Shoot plasma cannons" },
58
+ { key: "Esc / P", action: "Pause Menu", description: "Open pause dialog" },
59
+ { key: "R", action: "Restart", description: "Try again immediately" },
60
+ { key: "Q", action: "Quit", description: "Return to arcade menu" }
230
61
  ],
231
62
  achievements: [
232
- { id: "first_haul", title: "Scrap Scavenger", description: "Extract 500 tons of alloy" },
233
- { id: "full_crew_home", title: "No Drone Left Behind", description: "Reach station without casualties" },
234
- { id: "derelict_titan", title: "Ghost Fleet Sovereign", description: "Salvage a Class-5 flagship" }
63
+ { id: "alien_down", title: "First Contact", description: "Destroy your first alien invader" },
64
+ { id: "mothership_shot", title: "UFO Hunter", description: "Shoot down a high-value red mothership" },
65
+ { id: "wave_cleared", title: "Sky Guardian", description: "Clear 20 descending invaders" }
235
66
  ]
236
67
  },
237
- "shell-quest": {
238
- id: "shell-quest",
239
- name: "Shell Quest",
240
- tagline: "Master unix arcana across the command realm",
241
- description: "Terminal RPG: wield grep, awk, git, and pipelines to overcome daemon bosses in simulated root.",
242
- category: "educational",
68
+ "hash-matrix": {
69
+ id: "hash-matrix",
70
+ name: "Hash Matrix",
71
+ tagline: "Hollywood hacker cascade of crypto hashes and symbols",
72
+ description: "Hypnotic hacker visualizer: random cryptographic hashes, memory hex dumps, and matrix rain streaming harmlessly across your screen.",
73
+ category: "arcade",
243
74
  difficultyLevels: ["easy", "normal", "hard", "insane"],
244
75
  controls: [
245
- { key: "Input Line", action: "Type Shell Cmd", description: "Issue commands to bash interface" },
246
- { key: "Tab", action: "Autocomplete", description: "Complete paths and binaries" },
247
- { key: "Ctrl+L", action: "Clear Screen", description: "Clear adventure log output" },
248
- { key: "Esc / :q", action: "Exit Quest", description: "Return to portal" }
76
+ { key: "Ctrl+C / Q / Esc", action: "Exit to Menu", description: "Stop hacker stream" },
77
+ { key: "Space", action: "Freeze / Pause", description: "Pause hash cascade" },
78
+ { key: "M", action: "Switch Mode", description: "Cycle rain, hash, hex modes" },
79
+ { key: "C / T", action: "Cycle Colors", description: "Matrix green, cyan, amber, red" }
249
80
  ],
250
81
  achievements: [
251
- { id: "sudo_apprentice", title: "UID Zero", description: "Attain root privileges in Area 1" },
252
- { id: "pipe_master", title: "Pipe Virtuoso", description: "Chasm puzzle cleared with 3+ pipes" },
253
- { id: "git_guru", title: "Rebase Conqueror", description: "Resolve the detached HEAD calamity" }
82
+ { id: "first_breach", title: "Script Kiddie", description: "Run the hacker stream for 10 seconds" },
83
+ { id: "hash_miner", title: "Crypto Sovereign", description: "Compute 5,000 hashes in one session" },
84
+ { id: "matrix_unlocked", title: "The White Rabbit", description: "Cycle through all visual modes" }
254
85
  ]
255
86
  }
256
87
  };
@@ -549,10 +380,12 @@ var TerminalRenderer = class {
549
380
  getTheme() {
550
381
  return this.currentTheme;
551
382
  }
383
+ previousLineCount = 0;
552
384
  enterScreen() {
553
385
  if (!this.inAltBuffer && process.stdout.isTTY) {
554
386
  process.stdout.write("\x1B[?1049h\x1B[?25l\x1B[2J\x1B[H");
555
387
  this.inAltBuffer = true;
388
+ this.previousLineCount = 0;
556
389
  }
557
390
  }
558
391
  exitScreen() {
@@ -561,14 +394,45 @@ var TerminalRenderer = class {
561
394
  this.inAltBuffer = false;
562
395
  }
563
396
  }
397
+ /**
398
+ * Safe frame render with zero flickering.
399
+ * Repaints lines in place with cursor hidden and atomic buffer write,
400
+ * avoiding full-screen blanking clears.
401
+ */
402
+ renderFrame(content) {
403
+ if (!process.stdout.isTTY) return;
404
+ const lines = content.split("\n");
405
+ let output = "\x1B[?25l\x1B[H";
406
+ for (let i = 0; i < lines.length; i++) {
407
+ output += `${lines[i]}\x1B[K
408
+ `;
409
+ }
410
+ if (lines.length < this.previousLineCount) {
411
+ output += "\x1B[J";
412
+ }
413
+ this.previousLineCount = lines.length;
414
+ process.stdout.write(output);
415
+ }
416
+ /**
417
+ * Retained for compatibility. Forwards to flicker-free renderFrame.
418
+ */
419
+ draw(content) {
420
+ this.renderFrame(content);
421
+ }
422
+ /**
423
+ * Intentionally no-op during active game loop to prevent blank-frame visual strobing.
424
+ */
564
425
  clear() {
426
+ }
427
+ /**
428
+ * Explicit full screen wipe when transitioning between major modes.
429
+ */
430
+ forceClear() {
565
431
  if (process.stdout.isTTY) {
566
432
  process.stdout.write("\x1B[2J\x1B[H");
433
+ this.previousLineCount = 0;
567
434
  }
568
435
  }
569
- draw(content) {
570
- process.stdout.write(`\x1B[H${content}`);
571
- }
572
436
  isWindowAdequate() {
573
437
  const width = process.stdout.columns || 80;
574
438
  const height = process.stdout.rows || 24;
@@ -592,14 +456,20 @@ var TerminalRenderer = class {
592
456
  }
593
457
  createBox(lines, width = 76, title = "") {
594
458
  const t = this.currentTheme;
595
- const topBarLen = Math.max(0, width - 4 - (title ? title.length + 2 : 0));
459
+ const topBarLen = Math.max(0, width - 3 - (title ? title.length + 2 : 0));
596
460
  const titleSection = title ? ` ${t.primary(title)} ` : "";
597
461
  const top = t.border(`\u250C\u2500${titleSection}${"\u2500".repeat(topBarLen)}\u2510`);
598
462
  const bottom = t.border(`\u2514${"\u2500".repeat(width - 2)}\u2518`);
463
+ const maxInner = width - 4;
599
464
  const middle = lines.map((line) => {
600
- const cleanLen = line.replace(/\x1b\[[0-9;]*m/g, "").length;
601
- const padLen = Math.max(0, width - 4 - cleanLen);
602
- return `${t.border("\u2502")} ${line}${" ".repeat(padLen)}${t.border("\u2502")}`;
465
+ let content = line;
466
+ const cleanLen = content.replace(/\x1b\[[0-9;]*m/g, "").length;
467
+ if (cleanLen > maxInner) {
468
+ content = content.slice(0, content.length - (cleanLen - maxInner));
469
+ }
470
+ const finalCleanLen = content.replace(/\x1b\[[0-9;]*m/g, "").length;
471
+ const padLen = Math.max(0, maxInner - finalCleanLen);
472
+ return `${t.border("\u2502")} ${content}${" ".repeat(padLen)}${t.border("\u2502")}`;
603
473
  });
604
474
  return [top, ...middle, bottom].join("\n");
605
475
  }
@@ -867,14 +737,121 @@ function formatTime(seconds) {
867
737
  function clamp(val, min, max) {
868
738
  return Math.max(min, Math.min(max, val));
869
739
  }
870
- function padCenter(str, width) {
871
- if (str.length >= width) return str.slice(0, width);
872
- const left = Math.floor((width - str.length) / 2);
873
- const right = width - str.length - left;
874
- return " ".repeat(left) + str + " ".repeat(right);
740
+ function stripAnsi(str) {
741
+ return str.replace(/\x1b\[[0-9;]*m/g, "");
742
+ }
743
+ function visibleLength(str) {
744
+ return stripAnsi(str).length;
745
+ }
746
+ function padRightVisible(str, targetWidth) {
747
+ const vLen = stripAnsi(str).length;
748
+ if (vLen >= targetWidth) return str;
749
+ return str + " ".repeat(targetWidth - vLen);
750
+ }
751
+ function wordWrap(text, maxWidth) {
752
+ const words = text.split(" ");
753
+ const lines = [];
754
+ let current = "";
755
+ for (const word of words) {
756
+ if (!current) {
757
+ current = word;
758
+ } else if (stripAnsi(current + " " + word).length <= maxWidth) {
759
+ current += " " + word;
760
+ } else {
761
+ lines.push(current);
762
+ current = word;
763
+ }
764
+ }
765
+ if (current) lines.push(current);
766
+ return lines;
875
767
  }
876
768
 
877
769
  // src/core/menu.ts
770
+ import chalk2 from "chalk";
771
+ var HACKER_STAGE_1 = [
772
+ "ACCESSING ORBITAL DEFENSE SATELLITE...",
773
+ "LOCATING PENTAGON FIBER-OPTIC TRUNK...",
774
+ "CONNECTING TO ENCRYPTED SWISS BANK NODE...",
775
+ "INTERCEPTING TOP-SECRET NASA RADAR...",
776
+ "ESTABLISHING SECURE PROXY IN BERMUDA...",
777
+ "PINGING DEEP-SEA MILITARY SUBMARINE..."
778
+ ];
779
+ var HACKER_STAGE_2 = [
780
+ "HACKING INTO FBI MAINFRAME... [BYPASS OK]",
781
+ "DOWNLOADING 64GB OF EXTRA CLOUD RAM...",
782
+ "OVERCLOCKING POTATO POWERED CPU TO 5.0 GHz...",
783
+ "CRACKING AREA 51 ALIEN ENCRYPTION CODES...",
784
+ "DISABLING NSA COVERT SURVEILLANCE CAMERAS...",
785
+ "MINING BITCOIN ON SMART REFRIGERATOR..."
786
+ ];
787
+ var HACKER_STAGE_3 = [
788
+ "RE-ROUTING POWER FROM FLUX CAPACITOR...",
789
+ "ORDERING EXTRA PEPPERONI PIZZA VIA CMD...",
790
+ "INVERTING WARP TACHYON EMITTERS...",
791
+ "BRIBERY ATTEMPT: SENDING MEMES TO SYSTEM ADMIN...",
792
+ "SPOOFING IP ADDRESS TO 127.0.0.1 (WAIT WHAT)...",
793
+ "CONVERTING COFFEE DIRECTLY INTO MACHINE CODE..."
794
+ ];
795
+ var HACKER_STAGE_4 = [
796
+ "BYPASSING FINAL FIREWALL WITH ELECTRIC TOASTER...",
797
+ "OVERRIDING MAINFRAME AIR CONDITIONING...",
798
+ "DELETING SEARCH BROWSER HISTORY JUST IN CASE...",
799
+ "INITIALIZING 80s HOLLYWOOD KEYBOARD TYPING...",
800
+ "ARMING RETRO PHOSPHOR SCANLINE CANNONS...",
801
+ "QUANTUM KERNEL COMPILED: ACCESS GRANTED..."
802
+ ];
803
+ var HACKER_STAGE_5 = [
804
+ "WE ARE IN! FULL ROOT ACCESS GRANTED!",
805
+ "MATRIX BREACHED! LAUNCHING SYSTEM NOW!",
806
+ "SECURITY PROTOCOLS CRACKED! WE HAVE TAKEOVER!",
807
+ "MAINFRAME BYPASSED! WELCOME TO THE MATRIX!"
808
+ ];
809
+ async function playArcadeLoadingScreen(game, renderer = defaultRenderer, storage = defaultStorage) {
810
+ const profile = storage.getProfile();
811
+ if (profile.settings.reducedMotion) return;
812
+ const t = renderer.getTheme();
813
+ const width = 74;
814
+ const barWidth = 36;
815
+ const tips = {
816
+ "packet-man": "Tip: Grab Super Capacitors to hunt blue daemons for combos!",
817
+ "cyber-viper": "Tip: Snag rare golden bonus orbs quickly for 5x points!",
818
+ "void-invaders": "Tip: Blast descending aliens before they touch ground! 3 lives.",
819
+ "hash-matrix": "Tip: Press Space to freeze stream, M for mode, C for color theme!"
820
+ };
821
+ const tip = tips[game.id] || "Tip: Press Esc or P at any time to pause or access settings.";
822
+ const pick = (arr) => arr[Math.floor(Math.random() * arr.length)];
823
+ const steps = [
824
+ { fill: 6, pct: 15, label: pick(HACKER_STAGE_1), delay: 350 },
825
+ { fill: 14, pct: 40, label: pick(HACKER_STAGE_2), delay: 350 },
826
+ { fill: 23, pct: 65, label: pick(HACKER_STAGE_3), delay: 350 },
827
+ { fill: 31, pct: 85, label: pick(HACKER_STAGE_4), delay: 350 },
828
+ { fill: 36, pct: 100, label: pick(HACKER_STAGE_5), delay: 400 }
829
+ ];
830
+ for (const step of steps) {
831
+ const bar = "\u2588".repeat(step.fill) + "\u2591".repeat(barWidth - step.fill);
832
+ const title = ` INITIALIZING: ${game.name.toUpperCase()} `;
833
+ const meter = `[${bar}] ${step.pct.toString().padStart(3)}%`;
834
+ const status = step.label;
835
+ const innerLines = [
836
+ "",
837
+ " ".repeat(Math.max(0, Math.floor((width - 4 - title.length) / 2))) + t.highlight(title),
838
+ "",
839
+ " ".repeat(Math.max(0, Math.floor((width - 4 - meter.length) / 2))) + t.primary(meter),
840
+ " ".repeat(Math.max(0, Math.floor((width - 4 - status.length) / 2))) + t.secondary(status),
841
+ "",
842
+ " ".repeat(Math.max(0, Math.floor((width - 4 - tip.length) / 2))) + t.muted(tip),
843
+ ""
844
+ ];
845
+ const box = renderer.createBox(innerLines, width, "TERMINULL ARCADE SYSTEM");
846
+ renderer.draw(`
847
+
848
+
849
+ ${box}
850
+
851
+ `);
852
+ await new Promise((r) => setTimeout(r, step.delay));
853
+ }
854
+ }
878
855
  var ArcadeMenu = class {
879
856
  storage;
880
857
  achievements;
@@ -886,6 +863,8 @@ var ArcadeMenu = class {
886
863
  currentTab = "arcade";
887
864
  selectedDifficulty = "normal";
888
865
  onSelectCallback = null;
866
+ animTimer = null;
867
+ animFrame = 0;
889
868
  constructor(storage = defaultStorage, achievements = defaultAchievements, renderer = defaultRenderer) {
890
869
  this.storage = storage;
891
870
  this.achievements = achievements;
@@ -898,18 +877,34 @@ var ArcadeMenu = class {
898
877
  this.renderer.setTheme(profile.settings.theme);
899
878
  this.renderer.enterScreen();
900
879
  this.render();
880
+ if (!profile.settings.reducedMotion) {
881
+ this.animTimer = setInterval(() => {
882
+ this.animFrame = (this.animFrame + 1) % 2;
883
+ this.render();
884
+ }, 700);
885
+ }
901
886
  this.input.start(
902
887
  (key) => this.handleInput(key),
903
888
  () => {
904
- this.renderer.exitScreen();
889
+ this.close();
905
890
  process.exit(0);
906
891
  }
907
892
  );
908
893
  }
909
894
  close() {
895
+ if (this.animTimer) {
896
+ clearInterval(this.animTimer);
897
+ this.animTimer = null;
898
+ }
910
899
  this.input.stop();
911
900
  this.renderer.exitScreen();
912
901
  }
902
+ ringBell() {
903
+ const profile = this.storage.getProfile();
904
+ if (profile.settings.soundEnabled) {
905
+ process.stdout.write("\x07");
906
+ }
907
+ }
913
908
  getFilteredGames() {
914
909
  const all = Object.values(ALL_GAMES_METADATA);
915
910
  if (!this.searchQuery.trim()) return all;
@@ -918,6 +913,22 @@ var ArcadeMenu = class {
918
913
  (g) => g.name.toLowerCase().includes(q) || g.category.toLowerCase().includes(q) || g.id.toLowerCase().includes(q) || g.description.toLowerCase().includes(q)
919
914
  );
920
915
  }
916
+ async triggerLaunch(game) {
917
+ if (this.animTimer) {
918
+ clearInterval(this.animTimer);
919
+ this.animTimer = null;
920
+ }
921
+ this.input.stop();
922
+ this.ringBell();
923
+ await playArcadeLoadingScreen(game, this.renderer, this.storage);
924
+ if (this.onSelectCallback) {
925
+ this.onSelectCallback({
926
+ action: "play",
927
+ gameId: game.id,
928
+ difficulty: this.selectedDifficulty
929
+ });
930
+ }
931
+ }
921
932
  handleInput(key) {
922
933
  const filtered = this.getFilteredGames();
923
934
  if (this.isSearching) {
@@ -937,33 +948,62 @@ var ArcadeMenu = class {
937
948
  const tabs = ["arcade", "stats", "settings"];
938
949
  const nextIdx = (tabs.indexOf(this.currentTab) + 1) % tabs.length;
939
950
  this.currentTab = tabs[nextIdx];
951
+ this.ringBell();
940
952
  this.render();
941
953
  return;
942
954
  }
943
955
  if (this.currentTab === "arcade") {
944
- if (key.name === "up" || key.name === "k") {
956
+ const num = parseInt(key.sequence || key.name, 10);
957
+ if (!isNaN(num) && num >= 1 && num <= filtered.length) {
958
+ const targetIdx = num - 1;
959
+ const targetGame = filtered[targetIdx];
960
+ if (targetGame) {
961
+ if (this.selectedIndex === targetIdx) {
962
+ this.triggerLaunch(targetGame);
963
+ return;
964
+ }
965
+ this.selectedIndex = targetIdx;
966
+ this.ringBell();
967
+ this.render();
968
+ return;
969
+ }
970
+ }
971
+ if (key.name === "up" || key.name === "w" || key.name === "k") {
945
972
  this.selectedIndex = (this.selectedIndex - 1 + filtered.length) % Math.max(1, filtered.length);
973
+ this.ringBell();
946
974
  this.render();
947
- } else if (key.name === "down" || key.name === "j") {
975
+ } else if (key.name === "down" || key.name === "s" || key.name === "j") {
948
976
  this.selectedIndex = (this.selectedIndex + 1) % Math.max(1, filtered.length);
977
+ this.ringBell();
949
978
  this.render();
950
- } else if (key.name === "d") {
979
+ } else if (key.name === "d" || key.sequence === "d") {
951
980
  const diffs = ["easy", "normal", "hard", "insane"];
952
981
  const curr = diffs.indexOf(this.selectedDifficulty);
953
982
  this.selectedDifficulty = diffs[(curr + 1) % diffs.length];
983
+ this.ringBell();
984
+ this.render();
985
+ } else if (key.name === "t" || key.sequence === "t") {
986
+ const themes = ["default", "retro-green", "neon", "minimal", "high-contrast"];
987
+ const profile = this.storage.getProfile();
988
+ const currIdx = themes.indexOf(profile.settings.theme);
989
+ const nextTheme = themes[(currIdx + 1) % themes.length];
990
+ this.storage.updateSettings({ theme: nextTheme });
991
+ this.renderer.setTheme(nextTheme);
992
+ this.ringBell();
993
+ this.render();
994
+ } else if (key.name === "b" || key.sequence === "b") {
995
+ const profile = this.storage.getProfile();
996
+ const nextVal = !profile.settings.soundEnabled;
997
+ this.storage.updateSettings({ soundEnabled: nextVal });
998
+ if (nextVal) this.ringBell();
954
999
  this.render();
955
1000
  } else if (key.name === "slash" || key.sequence === "/") {
956
1001
  this.isSearching = true;
957
1002
  this.render();
958
1003
  } else if (key.name === "return" || key.name === "space") {
959
1004
  const game = filtered[this.selectedIndex];
960
- if (game && this.onSelectCallback) {
961
- this.input.stop();
962
- this.onSelectCallback({
963
- action: "play",
964
- gameId: game.id,
965
- difficulty: this.selectedDifficulty
966
- });
1005
+ if (game) {
1006
+ this.triggerLaunch(game);
967
1007
  }
968
1008
  } else if (key.name === "q") {
969
1009
  this.close();
@@ -979,10 +1019,13 @@ var ArcadeMenu = class {
979
1019
  const nextTheme = themes[(currIdx + 1) % themes.length];
980
1020
  this.storage.updateSettings({ theme: nextTheme });
981
1021
  this.renderer.setTheme(nextTheme);
1022
+ this.ringBell();
982
1023
  this.render();
983
1024
  } else if (key.name === "b") {
984
1025
  const profile = this.storage.getProfile();
985
- this.storage.updateSettings({ soundEnabled: !profile.settings.soundEnabled });
1026
+ const nextVal = !profile.settings.soundEnabled;
1027
+ this.storage.updateSettings({ soundEnabled: nextVal });
1028
+ if (nextVal) this.ringBell();
986
1029
  this.render();
987
1030
  } else if (key.name === "m") {
988
1031
  const profile = this.storage.getProfile();
@@ -1000,11 +1043,11 @@ var ArcadeMenu = class {
1000
1043
  }
1001
1044
  }
1002
1045
  render() {
1003
- const t = this.renderer.getTheme();
1004
1046
  const { width, height } = this.renderer.isWindowAdequate();
1005
- if (width < 80 || height < 24) {
1006
- this.renderer.clear();
1007
- this.renderer.draw(this.renderer.renderSizeWarning());
1047
+ if (!width || !height) {
1048
+ this.renderer.draw(
1049
+ this.renderer.renderHeader({ title: APP_NAME }) + chalk2.redBright("\n\n Terminal window size too small!\n Please resize to at least 80x24.\n")
1050
+ );
1008
1051
  return;
1009
1052
  }
1010
1053
  let body = "";
@@ -1015,45 +1058,89 @@ var ArcadeMenu = class {
1015
1058
  } else if (this.currentTab === "settings") {
1016
1059
  body = this.renderSettingsTab();
1017
1060
  }
1018
- this.renderer.clear();
1019
1061
  this.renderer.draw(body);
1020
1062
  }
1063
+ renderFunkyBanner() {
1064
+ const t = this.renderer.getTheme();
1065
+ const profile = this.storage.getProfile();
1066
+ const themeName = profile.settings.theme;
1067
+ let row12Color = t.highlight;
1068
+ let row34Color = t.secondary;
1069
+ let row56Color = t.muted;
1070
+ if (themeName === "default") {
1071
+ row12Color = (str) => chalk2.cyanBright.bold(str);
1072
+ row34Color = (str) => chalk2.magentaBright.bold(str);
1073
+ row56Color = (str) => chalk2.gray(str);
1074
+ } else if (themeName === "retro-green") {
1075
+ row12Color = (str) => chalk2.greenBright.bold(str);
1076
+ row34Color = (str) => chalk2.green.bold(str);
1077
+ row56Color = (str) => chalk2.hex("#1f5f1f")(str);
1078
+ } else if (themeName === "neon") {
1079
+ row12Color = (str) => chalk2.hex("#00ffff").bold(str);
1080
+ row34Color = (str) => chalk2.hex("#ff007f").bold(str);
1081
+ row56Color = (str) => chalk2.hex("#553377")(str);
1082
+ } else if (themeName === "minimal") {
1083
+ row12Color = (str) => chalk2.whiteBright.bold(str);
1084
+ row34Color = (str) => chalk2.white(str);
1085
+ row56Color = (str) => chalk2.gray(str);
1086
+ } else if (themeName === "high-contrast") {
1087
+ row12Color = (str) => chalk2.yellowBright.bold(str);
1088
+ row34Color = (str) => chalk2.cyanBright.bold(str);
1089
+ row56Color = (str) => chalk2.white(str);
1090
+ }
1091
+ const bannerLines = [
1092
+ row12Color(` \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557\u2588\u2588\u2557\u2588\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557 `),
1093
+ row12Color(` \u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551 `),
1094
+ row34Color(` \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2554\u2588\u2588\u2588\u2588\u2554\u2588\u2588\u2551\u2588\u2588\u2551\u2588\u2588\u2554\u2588\u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551 `),
1095
+ row34Color(` \u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551\u255A\u2588\u2588\u2554\u255D\u2588\u2588\u2551\u2588\u2588\u2551\u2588\u2588\u2551\u255A\u2588\u2588\u2557\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551 `),
1096
+ row56Color(` \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u255A\u2550\u255D \u2588\u2588\u2551\u2588\u2588\u2551\u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557`),
1097
+ row56Color(` \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D`),
1098
+ ` ${t.accent(APP_TAGLINE)} \u2502 ${t.muted("Tab: Switch Views \u2502 /: Search \u2502 Q: Quit")}`,
1099
+ ` ${t.border("\u2500".repeat(74))}`
1100
+ ];
1101
+ return bannerLines.join("\n");
1102
+ }
1103
+ renderDifficultyBadge(diff) {
1104
+ if (diff === "easy") return chalk2.greenBright("[ EASY ]");
1105
+ if (diff === "normal") return chalk2.cyanBright("[ NORMAL ]");
1106
+ if (diff === "hard") return chalk2.yellowBright("[ HARD ]");
1107
+ return chalk2.redBright.bold("[ INSANE ]");
1108
+ }
1021
1109
  renderArcadeTab() {
1022
1110
  const t = this.renderer.getTheme();
1023
1111
  const filtered = this.getFilteredGames();
1024
1112
  const activeGame = filtered[this.selectedIndex];
1025
1113
  const profile = this.storage.getProfile();
1026
- const banner = [
1027
- t.highlight(` \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557\u2588\u2588\u2557\u2588\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557 `),
1028
- t.highlight(` \u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551 `),
1029
- t.primary(` \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2554\u2588\u2588\u2588\u2588\u2554\u2588\u2588\u2551\u2588\u2588\u2551\u2588\u2588\u2554\u2588\u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551 `),
1030
- t.secondary(` \u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551\u255A\u2588\u2588\u2554\u255D\u2588\u2588\u2551\u2588\u2588\u2551\u2588\u2588\u2551\u255A\u2588\u2588\u2557\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551 `),
1031
- t.muted(` \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u255A\u2550\u255D \u2588\u2588\u2551\u2588\u2588\u2551\u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557`),
1032
- t.muted(` \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D`),
1033
- ` ${t.accent(APP_TAGLINE)} \u2502 ${t.muted("Tab: Switch Views \u2502 /: Search \u2502 Q: Quit")}`,
1034
- ` ${t.border("\u2500".repeat(74))}`
1035
- ].join("\n");
1114
+ const banner = this.renderFunkyBanner();
1036
1115
  const tabs = ` ${t.highlight("[ 1. ARCADE ]")} ${t.muted("[ 2. STATS (Tab) ]")} ${t.muted("[ 3. SETTINGS (Tab) ]")}
1037
1116
  `;
1038
1117
  const searchBar = this.isSearching ? ` ${t.warning("SEARCH >")} ${this.searchQuery}\u2588
1039
1118
  ` : this.searchQuery ? ` ${t.muted("Filtered by:")} "${this.searchQuery}" (Press / to edit)
1040
1119
  ` : "";
1041
- const listLines = [];
1042
- const maxVisible = 10;
1043
- const startIndex = Math.max(0, Math.min(this.selectedIndex - 4, filtered.length - maxVisible));
1044
- const visibleGames = filtered.slice(startIndex, startIndex + maxVisible);
1045
- for (let i = 0; i < visibleGames.length; i++) {
1046
- const g = visibleGames[i];
1047
- const realIndex = startIndex + i;
1048
- const isSelected = realIndex === this.selectedIndex;
1120
+ const listLines = ["", t.highlight("ARCADE SELECTION:")];
1121
+ for (let i = 0; i < filtered.length; i++) {
1122
+ const g = filtered[i];
1123
+ const isSelected = i === this.selectedIndex;
1049
1124
  const high = profile.highScores[g.id] || 0;
1050
1125
  const highStr = high > 0 ? t.accent(`\u2605 ${high}`) : t.muted("\u2014");
1126
+ const numBadge = `[${i + 1}]`;
1127
+ const label = `${numBadge} ${g.name}`.padEnd(19);
1051
1128
  if (isSelected) {
1052
- listLines.push(t.primary(` \u25B6 ${t.highlight(g.name.padEnd(16))} ${t.secondary(`[${g.category}]`)} ${highStr}`));
1129
+ listLines.push(t.primary(` \u25B6 ${t.highlight(label)} ${highStr}`));
1053
1130
  } else {
1054
- listLines.push(t.muted(` ${g.name.padEnd(16)} [${g.category}] ${highStr}`));
1131
+ listLines.push(t.muted(` ${label} ${highStr}`));
1055
1132
  }
1056
1133
  }
1134
+ listLines.push("");
1135
+ listLines.push(t.border("\u2500\u2500 QUICK CONTROLS \u2500\u2500\u2500\u2500"));
1136
+ listLines.push(` ${t.primary("[1-4]")} ${t.muted("Select / Play")}`);
1137
+ listLines.push(` ${t.secondary("[D]")} ${this.renderDifficultyBadge(this.selectedDifficulty)}`);
1138
+ listLines.push(` ${t.accent("[T]")} ${t.muted("Theme:")} ${t.highlight(profile.settings.theme.toUpperCase())}`);
1139
+ listLines.push(` ${t.muted("[B] Sound:")} ${profile.settings.soundEnabled ? t.success("ON") : t.muted("OFF")}`);
1140
+ listLines.push(` ${t.muted("[Tab] Pilot Dossier")}`);
1141
+ while (listLines.length < 13) {
1142
+ listLines.push("");
1143
+ }
1057
1144
  const detailLines = [];
1058
1145
  if (activeGame) {
1059
1146
  const high = profile.highScores[activeGame.id] || 0;
@@ -1062,15 +1149,19 @@ var ArcadeMenu = class {
1062
1149
  const achs = this.achievements.getAchievementsForGame(activeGame.id);
1063
1150
  const unlockedAchs = achs.filter((a) => a.unlocked).length;
1064
1151
  detailLines.push(t.highlight(activeGame.name.toUpperCase()));
1065
- detailLines.push(t.secondary(activeGame.tagline));
1152
+ for (const line of wordWrap(activeGame.tagline, 40)) {
1153
+ detailLines.push(t.secondary(line));
1154
+ }
1066
1155
  detailLines.push("");
1067
- detailLines.push(activeGame.description);
1156
+ for (const line of wordWrap(activeGame.description, 40)) {
1157
+ detailLines.push(line);
1158
+ }
1068
1159
  detailLines.push("");
1069
- detailLines.push(`${t.muted("Personal Best:")} ${t.accent(high.toString())} ${t.muted("Runs:")} ${plays} ${t.muted("Time:")} ${formatTime(timeSec)}`);
1070
- detailLines.push(`${t.muted("Difficulty:")} ${t.secondary(this.selectedDifficulty.toUpperCase())} ${t.muted("(Press D to cycle)")}`);
1160
+ detailLines.push(`${t.muted("Best:")} ${t.accent(high.toString())} ${t.muted("Runs:")} ${plays} ${t.muted("Time:")} ${formatTime(timeSec)}`);
1161
+ detailLines.push(`${t.muted("Difficulty:")} ${this.renderDifficultyBadge(this.selectedDifficulty)}`);
1071
1162
  detailLines.push(`${t.muted("Achievements:")} ${unlockedAchs}/${achs.length} unlocked`);
1072
1163
  detailLines.push("");
1073
- detailLines.push(t.muted("Primary Controls:"));
1164
+ detailLines.push(t.muted("Controls:"));
1074
1165
  for (const ctrl of activeGame.controls.slice(0, 3)) {
1075
1166
  detailLines.push(` ${t.primary(ctrl.key.padEnd(14))} ${ctrl.action}`);
1076
1167
  }
@@ -1080,13 +1171,13 @@ var ArcadeMenu = class {
1080
1171
  const combinedLines = [];
1081
1172
  const maxRows = Math.max(listLines.length, detailBoxLines.length);
1082
1173
  for (let r = 0; r < maxRows; r++) {
1083
- const left = (listLines[r] || "").padEnd(32);
1174
+ const left = padRightVisible(listLines[r] || "", 30);
1084
1175
  const right = detailBoxLines[r] || "";
1085
1176
  combinedLines.push(` ${left} ${right}`);
1086
1177
  }
1087
1178
  const footer = [
1088
1179
  ` ${t.border("\u2500".repeat(74))}`,
1089
- ` ${t.primary("Enter/Space")}: Launch Game \u2502 ${t.secondary("Up/Down")}: Select \u2502 ${t.accent("D")}: Difficulty \u2502 ${t.muted("Q")}: Exit`
1180
+ ` ${t.primary("Enter/Space")}: Play \u2502 ${t.secondary("1-4")}: Select \u2502 ${t.accent("D")}: Difficulty \u2502 ${t.primary("T")}: Theme \u2502 ${t.muted("Q")}: Exit`
1090
1181
  ].join("\n");
1091
1182
  return `
1092
1183
  ${banner}
@@ -1115,10 +1206,10 @@ ${footer}
1115
1206
  "",
1116
1207
  `${t.muted("Total High Score Cumulative:")} ${t.accent(totalScore.toLocaleString())}`,
1117
1208
  `${t.muted("Total Play Sessions:")} ${t.primary(totalPlays.toString())}`,
1118
- `${t.muted("Total Time Beyond Prompt:")} ${t.secondary(formatTime(totalTime))}`,
1209
+ `${t.muted("Total Time Played:")} ${t.secondary(formatTime(totalTime))}`,
1119
1210
  `${t.muted("Global Achievements:")} ${t.success(`${unlockedCount} / ${totalCount} (${percentage}%)`)}`,
1120
1211
  "",
1121
- t.highlight("PER-GAME ARCHIVE:"),
1212
+ t.highlight("ARCADE HIGH SCORES:"),
1122
1213
  ...Object.values(ALL_GAMES_METADATA).map((g) => {
1123
1214
  const score = profile.highScores[g.id] || 0;
1124
1215
  const plays = profile.playCounts[g.id] || 0;
@@ -1219,32 +1310,64 @@ var DeterministicRNG = class {
1219
1310
  }
1220
1311
  };
1221
1312
 
1222
- // src/games/neon-circuit/index.ts
1223
- var NeonCircuitGame = class {
1224
- id = "neon-circuit";
1225
- metadata = ALL_GAMES_METADATA["neon-circuit"];
1313
+ // src/games/packet-man/index.ts
1314
+ var MAZE_TEMPLATE = [
1315
+ "###########################",
1316
+ "#............#............#",
1317
+ "#.####.#####.#.#####.####.#",
1318
+ "#O####.#####.#.#####.####O#",
1319
+ "#.####.#####.#.#####.####.#",
1320
+ "#.........................#",
1321
+ "#.####.##.#######.##.####.#",
1322
+ "#......##....#....##......#",
1323
+ "######.##### # #####.######",
1324
+ " #.# #.# ",
1325
+ "######.# ###---### #.######",
1326
+ "#......# # # #......#",
1327
+ "#.####.# ######### #.####.#",
1328
+ "#O..##...............##..O#",
1329
+ "###.##.##.#######.##.##.###",
1330
+ "#......##....#....##......#",
1331
+ "#.##########.#.##########.#",
1332
+ "#.........................#",
1333
+ "###########################"
1334
+ ];
1335
+ var MAZE_WIDTH = 27;
1336
+ var MAZE_HEIGHT = 19;
1337
+ var PacketManGame = class {
1338
+ id = "packet-man";
1339
+ metadata = ALL_GAMES_METADATA["packet-man"];
1226
1340
  config = null;
1227
1341
  renderer = defaultRenderer;
1228
1342
  input = new TerminalInputHandler();
1229
1343
  rng = new DeterministicRNG();
1344
+ gameLoopTimer = null;
1345
+ grid = [];
1346
+ daemons = [];
1347
+ daemonsChompedInSurge = 0;
1348
+ pelletsEatenCount = 0;
1230
1349
  state = {
1231
- grid: [],
1232
- width: 5,
1233
- height: 5,
1234
- cursorX: 0,
1235
- cursorY: 0,
1236
- movesRemaining: 25,
1237
- maxMoves: 25,
1350
+ playerX: 13,
1351
+ playerY: 13,
1352
+ playerDx: 0,
1353
+ playerDy: 0,
1354
+ desiredDx: 0,
1355
+ desiredDy: 0,
1356
+ mouthOpen: true,
1357
+ lives: 3,
1238
1358
  score: 0,
1239
1359
  level: 1,
1240
- targetsRemaining: 1,
1241
- totalTargets: 1,
1360
+ pelletsRemaining: 0,
1361
+ totalPellets: 0,
1362
+ frightenedTicksRemaining: 0,
1363
+ frightenedCombo: 0,
1242
1364
  isWon: false,
1243
1365
  isGameOver: false
1244
1366
  };
1245
1367
  isPaused = false;
1246
1368
  pauseMenuIndex = 0;
1247
1369
  showTutorial = true;
1370
+ tickIntervalMs = 150;
1248
1371
  init(config) {
1249
1372
  this.config = config;
1250
1373
  this.renderer.setTheme(config.theme);
@@ -1252,7 +1375,7 @@ var NeonCircuitGame = class {
1252
1375
  if (config.skipTutorial !== void 0) {
1253
1376
  this.showTutorial = !config.skipTutorial;
1254
1377
  }
1255
- this.setupLevel(1, config.difficulty);
1378
+ this.resetGame(1, config.difficulty);
1256
1379
  }
1257
1380
  start() {
1258
1381
  this.isPaused = false;
@@ -1264,236 +1387,357 @@ var NeonCircuitGame = class {
1264
1387
  process.exit(0);
1265
1388
  }
1266
1389
  );
1390
+ this.scheduleNextTick();
1267
1391
  }
1268
1392
  pause() {
1269
1393
  this.isPaused = true;
1394
+ if (this.gameLoopTimer) {
1395
+ clearTimeout(this.gameLoopTimer);
1396
+ this.gameLoopTimer = null;
1397
+ }
1270
1398
  }
1271
1399
  resume() {
1272
1400
  this.isPaused = false;
1401
+ this.scheduleNextTick();
1273
1402
  this.render();
1274
1403
  }
1275
1404
  restart() {
1276
1405
  if (this.config) {
1277
- this.state.score = 0;
1278
- this.setupLevel(1, this.config.difficulty);
1406
+ this.resetGame(1, this.config.difficulty);
1407
+ this.scheduleNextTick();
1279
1408
  this.render();
1280
1409
  }
1281
1410
  }
1282
1411
  saveState() {
1283
1412
  return {
1284
1413
  state: this.state,
1414
+ grid: this.grid,
1415
+ daemons: this.daemons,
1285
1416
  showTutorial: this.showTutorial
1286
1417
  };
1287
1418
  }
1288
1419
  loadState(saved) {
1289
- if (saved["state"]) {
1290
- this.state = saved["state"];
1291
- }
1292
- if (saved["showTutorial"] !== void 0) {
1293
- this.showTutorial = !!saved["showTutorial"];
1294
- }
1295
- this.updatePowerFlow();
1420
+ if (saved["state"]) this.state = saved["state"];
1421
+ if (saved["grid"]) this.grid = saved["grid"];
1422
+ if (saved["daemons"]) this.daemons = saved["daemons"];
1423
+ if (saved["showTutorial"] !== void 0) this.showTutorial = !!saved["showTutorial"];
1296
1424
  }
1297
1425
  destroy() {
1426
+ if (this.gameLoopTimer) {
1427
+ clearTimeout(this.gameLoopTimer);
1428
+ this.gameLoopTimer = null;
1429
+ }
1298
1430
  this.input.stop();
1299
1431
  }
1300
- setupLevel(level, difficulty) {
1301
- let size = 5;
1302
- let moves = 20;
1432
+ resetGame(level, difficulty) {
1303
1433
  switch (difficulty) {
1304
1434
  case "easy":
1305
- size = 4;
1306
- moves = 25;
1435
+ this.tickIntervalMs = 175;
1307
1436
  break;
1308
1437
  case "normal":
1309
- size = 5;
1310
- moves = 22;
1438
+ this.tickIntervalMs = 145;
1311
1439
  break;
1312
1440
  case "hard":
1313
- size = 6;
1314
- moves = 20;
1441
+ this.tickIntervalMs = 120;
1315
1442
  break;
1316
1443
  case "insane":
1317
- size = 7;
1318
- moves = 18;
1444
+ this.tickIntervalMs = 95;
1319
1445
  break;
1320
1446
  }
1321
- this.state.width = size;
1322
- this.state.height = size;
1323
- this.state.level = level;
1324
- this.state.maxMoves = moves;
1325
- this.state.movesRemaining = moves;
1326
- this.state.cursorX = 0;
1327
- this.state.cursorY = 0;
1328
- this.state.isWon = false;
1329
- this.state.isGameOver = false;
1330
- const grid = [];
1331
- for (let y = 0; y < size; y++) {
1332
- const row = [];
1333
- for (let x = 0; x < size; x++) {
1334
- row.push(this.createRandomTile(x, y, size, difficulty));
1335
- }
1336
- row.push();
1337
- grid.push(row);
1338
- }
1339
- grid[0][0] = {
1340
- type: "source",
1341
- rotation: 0,
1342
- baseConnections: [false, true, true, false],
1343
- currentConnections: [false, true, true, false],
1344
- isPowered: true,
1345
- isFixed: true
1346
- };
1347
- grid[size - 1][size - 1] = {
1348
- type: "target",
1349
- rotation: 0,
1350
- baseConnections: [true, false, false, true],
1351
- currentConnections: [true, false, false, true],
1352
- isPowered: false,
1353
- isFixed: true
1354
- };
1355
- if (difficulty === "insane") {
1356
- grid[0][size - 1] = {
1357
- type: "target",
1358
- rotation: 0,
1359
- baseConnections: [false, false, true, true],
1360
- currentConnections: [false, false, true, true],
1361
- isPowered: false,
1362
- isFixed: true
1363
- };
1364
- this.state.totalTargets = 2;
1365
- this.state.targetsRemaining = 2;
1366
- } else {
1367
- this.state.totalTargets = 1;
1368
- this.state.targetsRemaining = 1;
1369
- }
1370
- this.state.grid = grid;
1371
- this.updatePowerFlow();
1372
- }
1373
- createRandomTile(x, y, size, difficulty) {
1374
- if ((difficulty === "hard" || difficulty === "insane") && this.rng.next() < 0.12 && (x > 0 || y > 0)) {
1375
- return {
1376
- type: "blocked",
1377
- rotation: 0,
1378
- baseConnections: [false, false, false, false],
1379
- currentConnections: [false, false, false, false],
1380
- isPowered: false,
1381
- isFixed: true
1382
- };
1383
- }
1384
- const roll = this.rng.next();
1385
- let type = "corner";
1386
- let base = [true, true, false, false];
1387
- if (roll < 0.4) {
1388
- type = "straight";
1389
- base = [true, false, true, false];
1390
- } else if (roll < 0.75) {
1391
- type = "corner";
1392
- base = [true, true, false, false];
1393
- } else if (roll < 0.92) {
1394
- type = "t-shape";
1395
- base = [true, true, false, true];
1396
- } else {
1397
- type = "cross";
1398
- base = [true, true, true, true];
1399
- }
1400
- const rotation = this.rng.nextInt(0, 3);
1401
- const current = this.rotateMask(base, rotation);
1402
- return {
1403
- type,
1404
- rotation,
1405
- baseConnections: base,
1406
- currentConnections: current,
1407
- isPowered: false,
1408
- isFixed: false
1447
+ this.state = {
1448
+ playerX: 13,
1449
+ playerY: 13,
1450
+ playerDx: -1,
1451
+ playerDy: 0,
1452
+ desiredDx: -1,
1453
+ desiredDy: 0,
1454
+ mouthOpen: true,
1455
+ lives: 3,
1456
+ score: this.state.score,
1457
+ level,
1458
+ pelletsRemaining: 0,
1459
+ totalPellets: 0,
1460
+ frightenedTicksRemaining: 0,
1461
+ frightenedCombo: 0,
1462
+ isWon: false,
1463
+ isGameOver: false
1409
1464
  };
1465
+ this.daemonsChompedInSurge = 0;
1466
+ this.loadMaze();
1467
+ this.resetDaemons();
1410
1468
  }
1411
- rotateMask(mask, times) {
1412
- const res = [...mask];
1413
- for (let i = 0; i < times % 4; i++) {
1414
- const [top, right, bottom, left] = res;
1415
- res[0] = left;
1416
- res[1] = top;
1417
- res[2] = right;
1418
- res[3] = bottom;
1419
- }
1420
- return res;
1421
- }
1422
- rotateTileAt(x, y) {
1423
- const tile = this.state.grid[y]?.[x];
1424
- if (!tile || tile.isFixed || this.state.isWon || this.state.isGameOver) return false;
1425
- tile.rotation = (tile.rotation + 1) % 4;
1426
- tile.currentConnections = this.rotateMask(tile.baseConnections, tile.rotation);
1427
- this.state.movesRemaining--;
1428
- this.updatePowerFlow();
1429
- if (this.config?.soundEnabled) {
1430
- playTerminalBell();
1431
- }
1432
- if (this.state.isWon) {
1433
- const bonus = this.state.movesRemaining * 100;
1434
- this.state.score += 500 + bonus;
1435
- this.config?.onScoreUpdate?.(this.state.score);
1436
- this.config?.onAchievementUnlock?.("first_spark");
1437
- if (this.state.movesRemaining >= 5) {
1438
- this.config?.onAchievementUnlock?.("overclocked");
1439
- }
1440
- if (this.config?.difficulty === "insane") {
1441
- this.config?.onAchievementUnlock?.("grid_master");
1442
- }
1443
- } else if (this.state.movesRemaining <= 0) {
1444
- this.state.isGameOver = true;
1445
- this.config?.onGameOver?.(this.state.score);
1469
+ loadMaze() {
1470
+ this.grid = [];
1471
+ let pellets = 0;
1472
+ for (let y = 0; y < MAZE_HEIGHT; y++) {
1473
+ const row = [];
1474
+ const line = MAZE_TEMPLATE[y] || "";
1475
+ for (let x = 0; x < MAZE_WIDTH; x++) {
1476
+ const char = line[x] || " ";
1477
+ if (char === "#") {
1478
+ row.push("wall");
1479
+ } else if (char === ".") {
1480
+ row.push("pellet");
1481
+ pellets++;
1482
+ } else if (char === "O") {
1483
+ row.push("power");
1484
+ pellets++;
1485
+ } else if (char === "-") {
1486
+ row.push("gate");
1487
+ } else {
1488
+ row.push("empty");
1489
+ }
1490
+ }
1491
+ this.grid.push(row);
1492
+ }
1493
+ this.state.pelletsRemaining = pellets;
1494
+ this.state.totalPellets = pellets;
1495
+ }
1496
+ resetDaemons() {
1497
+ this.daemons = [
1498
+ {
1499
+ id: "blinky",
1500
+ name: "Blinky",
1501
+ x: 13,
1502
+ y: 7,
1503
+ dx: 1,
1504
+ dy: 0,
1505
+ baseX: 25,
1506
+ baseY: 1,
1507
+ state: "chase",
1508
+ frightenedTicks: 0,
1509
+ colorName: "red"
1510
+ },
1511
+ {
1512
+ id: "pinky",
1513
+ name: "Pinky",
1514
+ x: 12,
1515
+ y: 11,
1516
+ dx: 0,
1517
+ dy: -1,
1518
+ baseX: 1,
1519
+ baseY: 1,
1520
+ state: "chase",
1521
+ frightenedTicks: 0,
1522
+ colorName: "pink"
1523
+ },
1524
+ {
1525
+ id: "inky",
1526
+ name: "Inky",
1527
+ x: 13,
1528
+ y: 11,
1529
+ dx: 0,
1530
+ dy: -1,
1531
+ baseX: 25,
1532
+ baseY: 17,
1533
+ state: "chase",
1534
+ frightenedTicks: 0,
1535
+ colorName: "cyan"
1536
+ },
1537
+ {
1538
+ id: "clyde",
1539
+ name: "Clyde",
1540
+ x: 14,
1541
+ y: 11,
1542
+ dx: 0,
1543
+ dy: -1,
1544
+ baseX: 1,
1545
+ baseY: 17,
1546
+ state: "chase",
1547
+ frightenedTicks: 0,
1548
+ colorName: "yellow"
1549
+ }
1550
+ ];
1551
+ }
1552
+ scheduleNextTick() {
1553
+ if (this.gameLoopTimer) clearTimeout(this.gameLoopTimer);
1554
+ if (this.isPaused || this.state.isGameOver || this.state.isWon || this.showTutorial) return;
1555
+ this.gameLoopTimer = setTimeout(() => {
1556
+ this.tick();
1557
+ this.scheduleNextTick();
1558
+ }, this.tickIntervalMs);
1559
+ }
1560
+ tick() {
1561
+ if (this.state.isGameOver || this.state.isWon || this.isPaused || this.showTutorial) return;
1562
+ this.state.mouthOpen = !this.state.mouthOpen;
1563
+ if (this.state.frightenedTicksRemaining > 0) {
1564
+ this.state.frightenedTicksRemaining--;
1565
+ if (this.state.frightenedTicksRemaining === 0) {
1566
+ for (const d of this.daemons) {
1567
+ if (d.state === "frightened") d.state = "chase";
1568
+ }
1569
+ }
1570
+ }
1571
+ if (this.canMove(this.state.playerX, this.state.playerY, this.state.desiredDx, this.state.desiredDy)) {
1572
+ this.state.playerDx = this.state.desiredDx;
1573
+ this.state.playerDy = this.state.desiredDy;
1574
+ }
1575
+ if (this.canMove(this.state.playerX, this.state.playerY, this.state.playerDx, this.state.playerDy)) {
1576
+ this.state.playerX += this.state.playerDx;
1577
+ this.state.playerY += this.state.playerDy;
1578
+ if (this.state.playerX < 0) this.state.playerX = MAZE_WIDTH - 1;
1579
+ else if (this.state.playerX >= MAZE_WIDTH) this.state.playerX = 0;
1580
+ this.chompCurrentTile();
1446
1581
  }
1582
+ this.moveDaemons();
1583
+ this.checkCollisions();
1584
+ this.render();
1585
+ }
1586
+ canMove(x, y, dx, dy, isDaemon = false) {
1587
+ let nx = x + dx;
1588
+ let ny = y + dy;
1589
+ if (nx < 0) nx = MAZE_WIDTH - 1;
1590
+ else if (nx >= MAZE_WIDTH) nx = 0;
1591
+ if (ny < 0 || ny >= MAZE_HEIGHT) return false;
1592
+ const tile = this.grid[ny]?.[nx];
1593
+ if (!tile || tile === "wall") return false;
1594
+ if (tile === "gate" && !isDaemon) return false;
1447
1595
  return true;
1448
1596
  }
1449
- updatePowerFlow() {
1450
- const { width, height, grid } = this.state;
1451
- for (let y = 0; y < height; y++) {
1452
- for (let x = 0; x < width; x++) {
1453
- if (grid[y][x].type !== "source") {
1454
- grid[y][x].isPowered = false;
1597
+ chompCurrentTile() {
1598
+ const tile = this.grid[this.state.playerY]?.[this.state.playerX];
1599
+ if (tile === "pellet") {
1600
+ this.grid[this.state.playerY][this.state.playerX] = "empty";
1601
+ this.state.score += 10;
1602
+ this.state.pelletsRemaining--;
1603
+ this.pelletsEatenCount++;
1604
+ this.config?.onScoreUpdate?.(this.state.score);
1605
+ if (this.pelletsEatenCount >= 50) {
1606
+ this.config?.onAchievementUnlock?.("first_chomp");
1607
+ }
1608
+ if (this.state.pelletsRemaining === 0) {
1609
+ this.state.isWon = true;
1610
+ this.config?.onAchievementUnlock?.("maze_sweeper");
1611
+ return;
1612
+ }
1613
+ } else if (tile === "power") {
1614
+ this.grid[this.state.playerY][this.state.playerX] = "empty";
1615
+ this.state.score += 50;
1616
+ this.state.pelletsRemaining--;
1617
+ this.daemonsChompedInSurge = 0;
1618
+ let surgeTicks = 45;
1619
+ if (this.config?.difficulty === "easy") surgeTicks = 65;
1620
+ else if (this.config?.difficulty === "hard") surgeTicks = 30;
1621
+ else if (this.config?.difficulty === "insane") surgeTicks = 18;
1622
+ this.state.frightenedTicksRemaining = surgeTicks;
1623
+ this.state.frightenedCombo = 0;
1624
+ for (const d of this.daemons) {
1625
+ if (d.state !== "eaten") {
1626
+ d.state = "frightened";
1627
+ d.dx = -d.dx;
1628
+ d.dy = -d.dy;
1455
1629
  }
1456
1630
  }
1631
+ if (this.config?.soundEnabled) playTerminalBell();
1457
1632
  }
1458
- const queue = [[0, 0]];
1459
- const visited = /* @__PURE__ */ new Set();
1460
- visited.add("0,0");
1461
- let targetsLit = 0;
1462
- const dx = [0, 1, 0, -1];
1463
- const dy = [-1, 0, 1, 0];
1464
- const oppositeDir = [2, 3, 0, 1];
1465
- while (queue.length > 0) {
1466
- const [cx, cy] = queue.shift();
1467
- const curr = grid[cy][cx];
1468
- for (let dir = 0; dir < 4; dir++) {
1469
- if (!curr.currentConnections[dir]) continue;
1470
- const nx = cx + dx[dir];
1471
- const ny = cy + dy[dir];
1472
- if (nx < 0 || nx >= width || ny < 0 || ny >= height) continue;
1473
- const key = `${nx},${ny}`;
1474
- if (visited.has(key)) continue;
1475
- const neighbor = grid[ny][nx];
1476
- if (neighbor.type === "blocked") continue;
1477
- const opp = oppositeDir[dir];
1478
- if (neighbor.currentConnections[opp]) {
1479
- neighbor.isPowered = true;
1480
- visited.add(key);
1481
- queue.push([nx, ny]);
1482
- if (neighbor.type === "target") {
1483
- targetsLit++;
1633
+ }
1634
+ moveDaemons() {
1635
+ const directions = [
1636
+ [0, -1],
1637
+ // Up
1638
+ [-1, 0],
1639
+ // Left
1640
+ [0, 1],
1641
+ // Down
1642
+ [1, 0]
1643
+ // Right
1644
+ ];
1645
+ for (const d of this.daemons) {
1646
+ if (d.state === "eaten") {
1647
+ if (d.x === 13 && d.y === 9) {
1648
+ d.state = "chase";
1649
+ }
1650
+ }
1651
+ const validDirs = [];
1652
+ for (const [dx, dy] of directions) {
1653
+ if (dx === -d.dx && dy === -d.dy) continue;
1654
+ if (this.canMove(d.x, d.y, dx, dy, true)) {
1655
+ validDirs.push([dx, dy]);
1656
+ }
1657
+ }
1658
+ if (validDirs.length === 0) {
1659
+ if (this.canMove(d.x, d.y, -d.dx, -d.dy, true)) {
1660
+ validDirs.push([-d.dx, -d.dy]);
1661
+ }
1662
+ }
1663
+ if (validDirs.length > 0) {
1664
+ let chosenDir;
1665
+ if (d.state === "frightened") {
1666
+ chosenDir = this.rng.pick(validDirs);
1667
+ } else {
1668
+ let targetX = this.state.playerX;
1669
+ let targetY = this.state.playerY;
1670
+ if (d.id === "pinky") {
1671
+ targetX += this.state.playerDx * 4;
1672
+ targetY += this.state.playerDy * 4;
1673
+ } else if (d.id === "clyde") {
1674
+ const dist = Math.hypot(d.x - this.state.playerX, d.y - this.state.playerY);
1675
+ if (dist < 6) {
1676
+ targetX = d.baseX;
1677
+ targetY = d.baseY;
1678
+ }
1679
+ }
1680
+ chosenDir = validDirs[0];
1681
+ let minDist = Infinity;
1682
+ for (const [vx, vy] of validDirs) {
1683
+ const nx = d.x + vx;
1684
+ const ny = d.y + vy;
1685
+ const dist = Math.hypot(nx - targetX, ny - targetY);
1686
+ if (dist < minDist) {
1687
+ minDist = dist;
1688
+ chosenDir = [vx, vy];
1689
+ }
1484
1690
  }
1485
1691
  }
1692
+ d.dx = chosenDir[0];
1693
+ d.dy = chosenDir[1];
1694
+ d.x += d.dx;
1695
+ d.y += d.dy;
1696
+ if (d.x < 0) d.x = MAZE_WIDTH - 1;
1697
+ else if (d.x >= MAZE_WIDTH) d.x = 0;
1486
1698
  }
1487
1699
  }
1488
- this.state.targetsRemaining = this.state.totalTargets - targetsLit;
1489
- if (this.state.targetsRemaining === 0) {
1490
- this.state.isWon = true;
1700
+ }
1701
+ checkCollisions() {
1702
+ for (const d of this.daemons) {
1703
+ if (d.x === this.state.playerX && d.y === this.state.playerY) {
1704
+ if (d.state === "frightened") {
1705
+ d.state = "eaten";
1706
+ d.x = 13;
1707
+ d.y = 9;
1708
+ this.state.frightenedCombo++;
1709
+ const points = 200 * Math.pow(2, this.state.frightenedCombo - 1);
1710
+ this.state.score += points;
1711
+ this.daemonsChompedInSurge++;
1712
+ if (this.daemonsChompedInSurge >= 4) {
1713
+ this.config?.onAchievementUnlock?.("daemon_slayer");
1714
+ }
1715
+ if (this.config?.soundEnabled) playTerminalBell();
1716
+ } else if (d.state === "chase") {
1717
+ this.state.lives--;
1718
+ if (this.config?.soundEnabled) playTerminalBell();
1719
+ if (this.state.lives <= 0) {
1720
+ this.state.isGameOver = true;
1721
+ this.config?.onGameOver?.(this.state.score);
1722
+ } else {
1723
+ this.state.playerX = 13;
1724
+ this.state.playerY = 13;
1725
+ this.state.playerDx = -1;
1726
+ this.state.playerDy = 0;
1727
+ this.state.desiredDx = -1;
1728
+ this.state.desiredDy = 0;
1729
+ this.resetDaemons();
1730
+ }
1731
+ break;
1732
+ }
1733
+ }
1491
1734
  }
1492
1735
  }
1493
1736
  handleInput(key) {
1494
1737
  if (this.showTutorial) {
1495
1738
  if (key.name === "return" || key.name === "space") {
1496
1739
  this.showTutorial = false;
1740
+ this.scheduleNextTick();
1497
1741
  this.render();
1498
1742
  } else if (key.name === "escape" || key.name === "q") {
1499
1743
  this.destroy();
@@ -1511,10 +1755,12 @@ var NeonCircuitGame = class {
1511
1755
  } else if (key.name === "return" || key.name === "space") {
1512
1756
  if (this.pauseMenuIndex === 0) {
1513
1757
  this.isPaused = false;
1758
+ this.scheduleNextTick();
1514
1759
  this.render();
1515
1760
  } else if (this.pauseMenuIndex === 1) {
1516
1761
  this.isPaused = false;
1517
- this.setupLevel(this.state.level, this.config?.difficulty || "normal");
1762
+ this.resetGame(this.state.level, this.config?.difficulty || "normal");
1763
+ this.scheduleNextTick();
1518
1764
  this.render();
1519
1765
  } else if (this.pauseMenuIndex === 2) {
1520
1766
  this.destroy();
@@ -1522,6 +1768,7 @@ var NeonCircuitGame = class {
1522
1768
  }
1523
1769
  } else if (key.name === "escape" || key.name === "p") {
1524
1770
  this.isPaused = false;
1771
+ this.scheduleNextTick();
1525
1772
  this.render();
1526
1773
  } else if (key.name === "q") {
1527
1774
  this.destroy();
@@ -1532,6 +1779,10 @@ var NeonCircuitGame = class {
1532
1779
  if (key.name === "escape" || key.name === "p") {
1533
1780
  this.isPaused = true;
1534
1781
  this.pauseMenuIndex = 0;
1782
+ if (this.gameLoopTimer) {
1783
+ clearTimeout(this.gameLoopTimer);
1784
+ this.gameLoopTimer = null;
1785
+ }
1535
1786
  this.render();
1536
1787
  return;
1537
1788
  }
@@ -1542,7 +1793,8 @@ var NeonCircuitGame = class {
1542
1793
  }
1543
1794
  if (this.state.isWon) {
1544
1795
  if (key.name === "return" || key.name === "space") {
1545
- this.setupLevel(this.state.level + 1, this.config?.difficulty || "normal");
1796
+ this.resetGame(this.state.level + 1, this.config?.difficulty || "normal");
1797
+ this.scheduleNextTick();
1546
1798
  this.render();
1547
1799
  } else if (key.name === "escape" || key.name === "q") {
1548
1800
  this.destroy();
@@ -1560,42 +1812,36 @@ var NeonCircuitGame = class {
1560
1812
  return;
1561
1813
  }
1562
1814
  if (key.name === "up" || key.name === "w") {
1563
- this.state.cursorY = Math.max(0, this.state.cursorY - 1);
1564
- this.render();
1815
+ this.state.desiredDx = 0;
1816
+ this.state.desiredDy = -1;
1565
1817
  } else if (key.name === "down" || key.name === "s") {
1566
- this.state.cursorY = Math.min(this.state.height - 1, this.state.cursorY + 1);
1567
- this.render();
1818
+ this.state.desiredDx = 0;
1819
+ this.state.desiredDy = 1;
1568
1820
  } else if (key.name === "left" || key.name === "a") {
1569
- this.state.cursorX = Math.max(0, this.state.cursorX - 1);
1570
- this.render();
1821
+ this.state.desiredDx = -1;
1822
+ this.state.desiredDy = 0;
1571
1823
  } else if (key.name === "right" || key.name === "d") {
1572
- this.state.cursorX = Math.min(this.state.width - 1, this.state.cursorX + 1);
1573
- this.render();
1574
- } else if (key.name === "space" || key.name === "return") {
1575
- this.rotateTileAt(this.state.cursorX, this.state.cursorY);
1576
- this.render();
1577
- } else if (key.name === "r") {
1578
- this.setupLevel(this.state.level, this.config?.difficulty || "normal");
1579
- this.render();
1824
+ this.state.desiredDx = 1;
1825
+ this.state.desiredDy = 0;
1580
1826
  }
1581
1827
  }
1582
1828
  render() {
1583
1829
  const t = this.renderer.getTheme();
1584
1830
  if (this.showTutorial) {
1585
- const tutorialLines = [
1831
+ const lines = [
1586
1832
  "",
1587
- t.highlight("OBJECTIVE: ROUTE HIGH-VOLTAGE FLUX"),
1833
+ t.highlight("OBJECTIVE: CHOMP BYTE PELLETS & PURGE DAEMONS"),
1588
1834
  "",
1589
- "\u2022 Navigate cursor using Arrow Keys or WASD.",
1590
- "\u2022 Press Space or Enter to rotate circuit tiles clockwise.",
1591
- "\u2022 Connect the glowing [S] Power Source to the [T] Target nodes.",
1592
- "\u2022 Watch your Capacity (Moves Remaining) meter.",
1593
- "\u2022 Obstacles [\u2593] cannot conduct energy or rotate.",
1835
+ "\u2022 Use Arrow Keys or WASD to navigate memory corridors.",
1836
+ "\u2022 Chomp all data pellets [ \xB7 ] to clear the sector.",
1837
+ "\u2022 Ingest Super Capacitors [ \u25CF ] to trigger Power Surge state.",
1838
+ "\u2022 During Power Surge, hunt vulnerable memory daemons for huge multipliers!",
1839
+ "\u2022 Wrap through the side tunnels to evade ambushes.",
1594
1840
  "",
1595
1841
  t.border("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),
1596
1842
  t.primary("Press Space or Enter to start \u2502 Esc / Q to Exit")
1597
1843
  ];
1598
- const box = this.renderer.createBox(tutorialLines, 64, "CIRCUIT PROTOCOL MANUAL");
1844
+ const box = this.renderer.createBox(lines, 64, "PACKET MAN PROTOCOL MANUAL");
1599
1845
  this.renderer.clear();
1600
1846
  this.renderer.draw(`
1601
1847
 
@@ -1604,10 +1850,10 @@ ${box}
1604
1850
  return;
1605
1851
  }
1606
1852
  if (this.isPaused) {
1607
- const pauseItems = ["Resume Circuit (Esc / Enter)", "Restart Level (R)", "Quit to Arcade / Terminal (Q)"];
1853
+ const pauseItems = ["Resume Arcade (Esc / Enter)", "Restart Round (R)", "Return to Game List (Q)"];
1608
1854
  const pauseLines = [
1609
1855
  "",
1610
- t.highlight("\u2550\u2550\u2550 CIRCUIT SUBROUTINE PAUSED \u2550\u2550\u2550"),
1856
+ t.highlight("\u2550\u2550\u2550 MEMORY MAZE PAUSED \u2550\u2550\u2550"),
1611
1857
  "",
1612
1858
  ...pauseItems.map((item, idx) => {
1613
1859
  if (idx === this.pauseMenuIndex) {
@@ -1617,7 +1863,7 @@ ${box}
1617
1863
  }),
1618
1864
  "",
1619
1865
  t.border("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),
1620
- t.muted("Use Up/Down to navigate \u2502 Enter: Select \u2502 Esc: Resume \u2502 Q: Quit")
1866
+ t.muted("Use Up/Down to navigate \u2502 Enter: Select \u2502 Esc: Resume \u2502 Q: Return to Game List")
1621
1867
  ];
1622
1868
  const pauseBox = this.renderer.createBox(pauseLines, 64, "SYSTEM PAUSE");
1623
1869
  this.renderer.clear();
@@ -1628,106 +1874,127 @@ ${pauseBox}
1628
1874
  return;
1629
1875
  }
1630
1876
  const header = this.renderer.renderHeader({
1631
- title: "NEON CIRCUIT",
1632
- category: "PUZZLE",
1877
+ title: "PACKET MAN",
1878
+ category: "ARCADE",
1633
1879
  difficulty: this.config?.difficulty,
1634
1880
  score: this.state.score,
1635
1881
  level: this.state.level
1636
1882
  });
1637
- const lines = [];
1638
- const { width, height, grid, cursorX, cursorY } = this.state;
1639
- lines.push(` Level: ${t.primary(this.state.level.toString())} Moves: ${this.state.movesRemaining > 5 ? t.success(this.state.movesRemaining.toString()) : t.error(this.state.movesRemaining.toString())} Targets: ${t.accent(`${this.state.totalTargets - this.state.targetsRemaining}/${this.state.totalTargets}`)}`);
1640
- lines.push("");
1641
- for (let y = 0; y < height; y++) {
1642
- let rowStr = " ";
1643
- for (let x = 0; x < width; x++) {
1644
- const tile = grid[y][x];
1645
- const isCursor = x === cursorX && y === cursorY;
1646
- const glyph = this.getTileGlyph(tile);
1647
- let formatted = glyph;
1648
- if (tile.isPowered) {
1649
- formatted = t.highlight(glyph);
1650
- } else {
1651
- formatted = t.muted(glyph);
1883
+ const hudLines = [];
1884
+ const livesStr = `${t.muted("Buffer Lives:")} ${t.highlight("\u25BA ".repeat(Math.max(0, this.state.lives)))}`;
1885
+ const surgeStr = this.state.frightenedTicksRemaining > 0 ? t.warning(`\u26A1 OVERCLOCK SURGE [${Math.ceil(this.state.frightenedTicksRemaining / 5)}s]`) : t.muted("NORMAL FLUX");
1886
+ hudLines.push(` ${livesStr} ${surgeStr} ${t.muted("Pellets:")} ${t.primary(this.state.pelletsRemaining.toString())}`);
1887
+ const boardLines = [];
1888
+ for (let y = 0; y < MAZE_HEIGHT; y++) {
1889
+ let row = " ";
1890
+ for (let x = 0; x < MAZE_WIDTH; x++) {
1891
+ if (x === this.state.playerX && y === this.state.playerY) {
1892
+ const char = this.getPlayerGlyph();
1893
+ row += t.highlight(char);
1894
+ continue;
1895
+ }
1896
+ const daemon = this.daemons.find((d) => d.x === x && d.y === y);
1897
+ if (daemon) {
1898
+ row += this.getDaemonGlyph(daemon);
1899
+ continue;
1652
1900
  }
1653
- if (isCursor) {
1654
- rowStr += `[${t.accent(glyph)}] `;
1901
+ const tile = this.grid[y][x];
1902
+ if (tile === "wall") {
1903
+ row += t.border("\u2588\u2588");
1904
+ } else if (tile === "pellet") {
1905
+ row += t.primary(" \xB7");
1906
+ } else if (tile === "power") {
1907
+ row += t.accent(" \u25CF");
1908
+ } else if (tile === "gate") {
1909
+ row += t.secondary("\u2550\u2550");
1655
1910
  } else {
1656
- rowStr += ` ${formatted} `;
1911
+ row += " ";
1657
1912
  }
1658
1913
  }
1659
- lines.push(rowStr);
1660
- lines.push("");
1914
+ boardLines.push(row);
1661
1915
  }
1662
1916
  if (this.state.isWon) {
1663
- lines.push(` ${t.success("\u26A1 CIRCUIT SYNCHRONIZED! ALL NODES POWERED!")}`);
1664
- lines.push(` ${t.primary("Press Space or Enter for Next Level...")}`);
1917
+ boardLines.push(`
1918
+ ${t.success("\u{1F389} MEMORY SECTOR COMPLETELY PURGED! EXCELLENT OPERATOR.")}`);
1919
+ boardLines.push(` ${t.primary("Press Space or Enter for Next Level...")}`);
1665
1920
  } else if (this.state.isGameOver) {
1666
- lines.push(` ${t.error("\u274C CAPACITY EXHAUSTED! POWER COLLAPSE.")}`);
1667
- lines.push(` ${t.muted("Press R to Retry Level, or P for Pause Menu.")}`);
1921
+ boardLines.push(`
1922
+ ${t.error("\u{1F4A5} SYSTEM FAULT: LIVES DEPLETED. KERNEL DUMP.")}`);
1923
+ boardLines.push(` ${t.muted("Press R to Re-engage, or Esc / Q to Return to Game List.")}`);
1668
1924
  } else {
1669
- lines.push(` ${t.muted("Controls: Arrows/WASD: Move \u2502 Space: Rotate \u2502 Esc/P: Pause \u2502 Q: Quit")}`);
1925
+ boardLines.push(`
1926
+ ${t.muted("Controls: Arrows/WASD: Move \u2502 Esc/P: Pause \u2502 Q: Return to Game List")}`);
1670
1927
  }
1671
1928
  this.renderer.clear();
1672
1929
  this.renderer.draw(`
1673
1930
  ${header}
1674
- ${lines.join("\n")}
1931
+ ${hudLines.join("\n")}
1932
+ ${boardLines.join("\n")}
1675
1933
  `);
1676
1934
  }
1677
- getTileGlyph(tile) {
1678
- if (tile.type === "source") return "S";
1679
- if (tile.type === "target") return "T";
1680
- if (tile.type === "blocked") return "\u2593";
1681
- const [top, right, bottom, left] = tile.currentConnections;
1682
- if (top && bottom && !right && !left) return "\u2502";
1683
- if (!top && !bottom && right && left) return "\u2500";
1684
- if (bottom && right && !top && !left) return "\u250C";
1685
- if (bottom && left && !top && !right) return "\u2510";
1686
- if (top && right && !bottom && !left) return "\u2514";
1687
- if (top && left && !bottom && !right) return "\u2518";
1688
- if (top && bottom && right && !left) return "\u251C";
1689
- if (top && bottom && !right && left) return "\u2524";
1690
- if (!top && bottom && right && left) return "\u252C";
1691
- if (top && !bottom && right && left) return "\u2534";
1692
- if (top && bottom && right && left) return "\u253C";
1693
- return "\u2022";
1935
+ getPlayerGlyph() {
1936
+ if (!this.state.mouthOpen) return "\u25CB ";
1937
+ if (this.state.playerDx === 1) return "\u25BA ";
1938
+ if (this.state.playerDx === -1) return "\u25C4 ";
1939
+ if (this.state.playerDy === -1) return "\u25B2 ";
1940
+ if (this.state.playerDy === 1) return "\u25BC ";
1941
+ return "\u25BA ";
1942
+ }
1943
+ getDaemonGlyph(d) {
1944
+ const t = this.renderer.getTheme();
1945
+ if (d.state === "frightened") {
1946
+ if (this.state.frightenedTicksRemaining < 10 && this.state.frightenedTicksRemaining % 2 === 0) {
1947
+ return t.accent("\xA7 ");
1948
+ }
1949
+ return t.secondary("\xA7 ");
1950
+ }
1951
+ if (d.state === "eaten") {
1952
+ return t.muted('""');
1953
+ }
1954
+ if (d.colorName === "red") return t.error("M ");
1955
+ if (d.colorName === "pink") return t.secondary("M ");
1956
+ if (d.colorName === "cyan") return t.primary("M ");
1957
+ return t.accent("M ");
1694
1958
  }
1695
1959
  getState() {
1696
1960
  return this.state;
1697
1961
  }
1698
1962
  };
1699
1963
 
1700
- // src/games/byte-runner/index.ts
1701
- var HIGHWAY_HEIGHT = 16;
1702
- var LANE_COUNT = 3;
1703
- var ByteRunnerGame = class {
1704
- id = "byte-runner";
1705
- metadata = ALL_GAMES_METADATA["byte-runner"];
1964
+ // src/games/cyber-viper/index.ts
1965
+ var GRID_WIDTH = 30;
1966
+ var GRID_HEIGHT = 16;
1967
+ var CyberViperGame = class {
1968
+ id = "cyber-viper";
1969
+ metadata = ALL_GAMES_METADATA["cyber-viper"];
1706
1970
  config = null;
1707
1971
  renderer = defaultRenderer;
1708
1972
  input = new TerminalInputHandler();
1709
1973
  rng = new DeterministicRNG();
1710
1974
  gameLoopTimer = null;
1711
- entityIdCounter = 0;
1712
- entities = [];
1713
1975
  state = {
1714
- playerLane: 1,
1715
- isJumping: false,
1716
- jumpTicksRemaining: 0,
1976
+ snake: [
1977
+ { x: 15, y: 8 },
1978
+ { x: 14, y: 8 },
1979
+ { x: 13, y: 8 }
1980
+ ],
1981
+ dx: 1,
1982
+ dy: 0,
1983
+ desiredDx: 1,
1984
+ desiredDy: 0,
1985
+ food: { x: 22, y: 8 },
1986
+ goldenFood: null,
1987
+ goldenFoodTicks: 0,
1717
1988
  score: 0,
1718
- distance: 0,
1719
- cleanBytesCollected: 0,
1720
- activeShield: false,
1721
- slowMotionTicks: 0,
1722
- magnetTicks: 0,
1723
- doubleScoreTicks: 0,
1724
- speedMs: 110,
1989
+ highScore: 0,
1990
+ applesEaten: 0,
1725
1991
  isGameOver: false,
1726
- multiplier: 1
1992
+ isWon: false
1727
1993
  };
1728
1994
  isPaused = false;
1729
1995
  pauseMenuIndex = 0;
1730
1996
  showTutorial = true;
1997
+ tickIntervalMs = 120;
1731
1998
  init(config) {
1732
1999
  this.config = config;
1733
2000
  this.renderer.setTheme(config.theme);
@@ -1771,20 +2038,12 @@ var ByteRunnerGame = class {
1771
2038
  saveState() {
1772
2039
  return {
1773
2040
  state: this.state,
1774
- entities: this.entities,
1775
2041
  showTutorial: this.showTutorial
1776
2042
  };
1777
2043
  }
1778
2044
  loadState(saved) {
1779
- if (saved["state"]) {
1780
- this.state = saved["state"];
1781
- }
1782
- if (saved["entities"]) {
1783
- this.entities = saved["entities"];
1784
- }
1785
- if (saved["showTutorial"] !== void 0) {
1786
- this.showTutorial = !!saved["showTutorial"];
1787
- }
2045
+ if (saved["state"]) this.state = saved["state"];
2046
+ if (saved["showTutorial"] !== void 0) this.showTutorial = !!saved["showTutorial"];
1788
2047
  }
1789
2048
  destroy() {
1790
2049
  if (this.gameLoopTimer) {
@@ -1794,176 +2053,140 @@ var ByteRunnerGame = class {
1794
2053
  this.input.stop();
1795
2054
  }
1796
2055
  resetState(difficulty) {
1797
- let baseSpeed = 110;
1798
2056
  switch (difficulty) {
1799
2057
  case "easy":
1800
- baseSpeed = 140;
2058
+ this.tickIntervalMs = 160;
1801
2059
  break;
1802
2060
  case "normal":
1803
- baseSpeed = 110;
2061
+ this.tickIntervalMs = 120;
1804
2062
  break;
1805
2063
  case "hard":
1806
- baseSpeed = 85;
2064
+ this.tickIntervalMs = 85;
1807
2065
  break;
1808
2066
  case "insane":
1809
- baseSpeed = 65;
2067
+ this.tickIntervalMs = 55;
1810
2068
  break;
1811
2069
  }
1812
2070
  this.state = {
1813
- playerLane: 1,
1814
- isJumping: false,
1815
- jumpTicksRemaining: 0,
2071
+ snake: [
2072
+ { x: 15, y: 8 },
2073
+ { x: 14, y: 8 },
2074
+ { x: 13, y: 8 }
2075
+ ],
2076
+ dx: 1,
2077
+ dy: 0,
2078
+ desiredDx: 1,
2079
+ desiredDy: 0,
2080
+ food: { x: 22, y: 8 },
2081
+ goldenFood: null,
2082
+ goldenFoodTicks: 0,
1816
2083
  score: 0,
1817
- distance: 0,
1818
- cleanBytesCollected: 0,
1819
- activeShield: false,
1820
- slowMotionTicks: 0,
1821
- magnetTicks: 0,
1822
- doubleScoreTicks: 0,
1823
- speedMs: baseSpeed,
2084
+ highScore: this.state.highScore,
2085
+ applesEaten: 0,
1824
2086
  isGameOver: false,
1825
- multiplier: 1
2087
+ isWon: false
1826
2088
  };
1827
- this.entities = [];
2089
+ this.spawnFood();
1828
2090
  }
1829
2091
  scheduleNextTick() {
1830
- if (this.gameLoopTimer) {
1831
- clearTimeout(this.gameLoopTimer);
1832
- }
1833
- if (this.isPaused || this.state.isGameOver || this.showTutorial) return;
1834
- let delay = this.state.speedMs;
1835
- if (this.state.slowMotionTicks > 0) {
1836
- delay = Math.round(delay * 1.6);
1837
- }
2092
+ if (this.gameLoopTimer) clearTimeout(this.gameLoopTimer);
2093
+ if (this.isPaused || this.state.isGameOver || this.state.isWon || this.showTutorial) return;
1838
2094
  this.gameLoopTimer = setTimeout(() => {
1839
2095
  this.tick();
1840
2096
  this.scheduleNextTick();
1841
- }, delay);
2097
+ }, this.tickIntervalMs);
1842
2098
  }
1843
2099
  tick() {
1844
- if (this.state.isGameOver || this.isPaused || this.showTutorial) return;
1845
- this.state.distance += 1;
1846
- const pointGain = 1 * (this.state.doubleScoreTicks > 0 ? 2 : 1);
1847
- this.state.score += pointGain;
1848
- if (this.state.jumpTicksRemaining > 0) {
1849
- this.state.jumpTicksRemaining--;
1850
- if (this.state.jumpTicksRemaining === 0) {
1851
- this.state.isJumping = false;
1852
- }
1853
- }
1854
- if (this.state.slowMotionTicks > 0) this.state.slowMotionTicks--;
1855
- if (this.state.magnetTicks > 0) this.state.magnetTicks--;
1856
- if (this.state.doubleScoreTicks > 0) this.state.doubleScoreTicks--;
1857
- for (const ent of this.entities) {
1858
- ent.y += 1;
1859
- if (this.state.magnetTicks > 0 && ent.type === "clean" && ent.y >= HIGHWAY_HEIGHT - 6) {
1860
- ent.lane = this.state.playerLane;
1861
- }
1862
- }
1863
- const playerY = HIGHWAY_HEIGHT - 2;
1864
- const remainingEntities = [];
1865
- for (const ent of this.entities) {
1866
- if (ent.y === playerY && ent.lane === this.state.playerLane) {
1867
- if (ent.type === "corrupt") {
1868
- if (this.state.isJumping) {
1869
- remainingEntities.push(ent);
1870
- continue;
1871
- }
1872
- if (this.state.activeShield) {
1873
- this.state.activeShield = false;
1874
- this.config?.onAchievementUnlock?.("shield_matrix");
1875
- if (this.config?.soundEnabled) playTerminalBell();
1876
- continue;
1877
- }
1878
- this.state.isGameOver = true;
1879
- this.config?.onGameOver?.(this.state.score);
1880
- if (this.config?.soundEnabled) playTerminalBell();
1881
- break;
1882
- } else if (ent.type === "clean") {
1883
- this.state.cleanBytesCollected++;
1884
- this.state.score += 100 * (this.state.doubleScoreTicks > 0 ? 2 : 1);
1885
- this.config?.onScoreUpdate?.(this.state.score);
1886
- if (this.state.cleanBytesCollected >= 50) {
1887
- this.config?.onAchievementUnlock?.("packet_chaser");
1888
- }
1889
- if (this.config?.soundEnabled) playTerminalBell();
1890
- continue;
1891
- } else if (ent.type === "powerup") {
1892
- this.activatePowerUp(ent.subType);
1893
- if (this.config?.soundEnabled) playTerminalBell();
1894
- continue;
1895
- }
1896
- }
1897
- if (ent.y < HIGHWAY_HEIGHT) {
1898
- remainingEntities.push(ent);
2100
+ if (this.state.isGameOver || this.state.isWon || this.isPaused || this.showTutorial) return;
2101
+ if (this.state.desiredDx !== -this.state.dx || this.state.desiredDy !== -this.state.dy) {
2102
+ this.state.dx = this.state.desiredDx;
2103
+ this.state.dy = this.state.desiredDy;
2104
+ }
2105
+ const head = this.state.snake[0];
2106
+ const newHead = {
2107
+ x: head.x + this.state.dx,
2108
+ y: head.y + this.state.dy
2109
+ };
2110
+ if (newHead.x < 0 || newHead.x >= GRID_WIDTH || newHead.y < 0 || newHead.y >= GRID_HEIGHT) {
2111
+ this.state.isGameOver = true;
2112
+ this.config?.onGameOver?.(this.state.score);
2113
+ if (this.config?.soundEnabled) playTerminalBell();
2114
+ this.render();
2115
+ return;
2116
+ }
2117
+ for (let i = 0; i < this.state.snake.length - 1; i++) {
2118
+ const seg = this.state.snake[i];
2119
+ if (seg.x === newHead.x && seg.y === newHead.y) {
2120
+ this.state.isGameOver = true;
2121
+ this.config?.onGameOver?.(this.state.score);
2122
+ if (this.config?.soundEnabled) playTerminalBell();
2123
+ this.render();
2124
+ return;
1899
2125
  }
1900
2126
  }
1901
- this.entities = remainingEntities;
1902
- if (this.state.distance >= 5e3) {
1903
- this.config?.onAchievementUnlock?.("hyperspeed");
2127
+ this.state.snake.unshift(newHead);
2128
+ if (this.state.goldenFoodTicks > 0) {
2129
+ this.state.goldenFoodTicks--;
2130
+ if (this.state.goldenFoodTicks === 0) {
2131
+ this.state.goldenFood = null;
2132
+ }
1904
2133
  }
1905
- if (this.state.distance % 2 === 0) {
1906
- this.spawnHighwayWave();
2134
+ let grew = false;
2135
+ if (newHead.x === this.state.food.x && newHead.y === this.state.food.y) {
2136
+ grew = true;
2137
+ this.state.score += 100;
2138
+ this.state.applesEaten++;
2139
+ this.config?.onScoreUpdate?.(this.state.score);
2140
+ this.config?.onAchievementUnlock?.("first_bite");
2141
+ if (this.state.snake.length >= 25) {
2142
+ this.config?.onAchievementUnlock?.("long_viper");
2143
+ }
2144
+ if (this.config?.soundEnabled) playTerminalBell();
2145
+ this.spawnFood();
2146
+ if (this.rng.next() < 0.25 && !this.state.goldenFood) {
2147
+ this.spawnGoldenFood();
2148
+ }
2149
+ } else if (this.state.goldenFood && newHead.x === this.state.goldenFood.x && newHead.y === this.state.goldenFood.y) {
2150
+ grew = true;
2151
+ this.state.score += 500;
2152
+ this.state.goldenFood = null;
2153
+ this.state.goldenFoodTicks = 0;
2154
+ this.config?.onScoreUpdate?.(this.state.score);
2155
+ this.config?.onAchievementUnlock?.("golden_feast");
2156
+ if (this.config?.soundEnabled) playTerminalBell();
1907
2157
  }
1908
- if (this.state.distance % 200 === 0 && this.state.speedMs > 45) {
1909
- this.state.speedMs -= 2;
2158
+ if (!grew) {
2159
+ this.state.snake.pop();
1910
2160
  }
1911
2161
  this.render();
1912
2162
  }
1913
- activatePowerUp(type) {
1914
- switch (type) {
1915
- case "shield":
1916
- this.state.activeShield = true;
1917
- break;
1918
- case "slow":
1919
- this.state.slowMotionTicks = 60;
1920
- break;
1921
- case "magnet":
1922
- this.state.magnetTicks = 70;
1923
- break;
1924
- case "double":
1925
- this.state.doubleScoreTicks = 80;
1926
- break;
2163
+ spawnFood() {
2164
+ const emptyCells = [];
2165
+ for (let y = 0; y < GRID_HEIGHT; y++) {
2166
+ for (let x = 0; x < GRID_WIDTH; x++) {
2167
+ if (!this.state.snake.some((s) => s.x === x && s.y === y)) {
2168
+ emptyCells.push({ x, y });
2169
+ }
2170
+ }
2171
+ }
2172
+ if (emptyCells.length > 0) {
2173
+ this.state.food = this.rng.pick(emptyCells);
2174
+ } else {
2175
+ this.state.isWon = true;
1927
2176
  }
1928
2177
  }
1929
- spawnHighwayWave() {
1930
- const roll = this.rng.next();
1931
- const lane = this.rng.nextInt(0, LANE_COUNT - 1);
1932
- if (roll < 0.45) {
1933
- const labels = ["[CORRUPT]", "[BAD_MEM]", "[NULL_PTR]", "[SEG_FLT]"];
1934
- this.entities.push({
1935
- id: ++this.entityIdCounter,
1936
- lane,
1937
- y: 0,
1938
- type: "corrupt",
1939
- label: this.rng.pick(labels)
1940
- });
1941
- } else if (roll < 0.8) {
1942
- const labels = ["0x7F", "0xFF", "[CLEAN]", "[PACKET]"];
1943
- this.entities.push({
1944
- id: ++this.entityIdCounter,
1945
- lane,
1946
- y: 0,
1947
- type: "clean",
1948
- label: this.rng.pick(labels)
1949
- });
1950
- } else if (roll < 0.95) {
1951
- const powerups = ["shield", "slow", "magnet", "double"];
1952
- const chosen = this.rng.pick(powerups);
1953
- const labels = {
1954
- shield: "\u{1F6E1}\uFE0F [SHLD]",
1955
- slow: "\u23F1\uFE0F [SLOW]",
1956
- magnet: "\u{1F9F2} [MAG]",
1957
- double: "\u26A1 [2X]"
1958
- };
1959
- this.entities.push({
1960
- id: ++this.entityIdCounter,
1961
- lane,
1962
- y: 0,
1963
- type: "powerup",
1964
- subType: chosen,
1965
- label: labels[chosen]
1966
- });
2178
+ spawnGoldenFood() {
2179
+ const emptyCells = [];
2180
+ for (let y = 0; y < GRID_HEIGHT; y++) {
2181
+ for (let x = 0; x < GRID_WIDTH; x++) {
2182
+ if (!this.state.snake.some((s) => s.x === x && s.y === y) && (x !== this.state.food.x || y !== this.state.food.y)) {
2183
+ emptyCells.push({ x, y });
2184
+ }
2185
+ }
2186
+ }
2187
+ if (emptyCells.length > 0) {
2188
+ this.state.goldenFood = this.rng.pick(emptyCells);
2189
+ this.state.goldenFoodTicks = 70;
1967
2190
  }
1968
2191
  }
1969
2192
  handleInput(key) {
@@ -1992,7 +2215,9 @@ var ByteRunnerGame = class {
1992
2215
  this.render();
1993
2216
  } else if (this.pauseMenuIndex === 1) {
1994
2217
  this.isPaused = false;
1995
- this.restart();
2218
+ this.resetState(this.config?.difficulty || "normal");
2219
+ this.scheduleNextTick();
2220
+ this.render();
1996
2221
  } else if (this.pauseMenuIndex === 2) {
1997
2222
  this.destroy();
1998
2223
  this.config?.onExit?.();
@@ -2031,26 +2256,26 @@ var ByteRunnerGame = class {
2031
2256
  }
2032
2257
  return;
2033
2258
  }
2034
- if (key.name === "left" || key.name === "a") {
2035
- if (this.state.playerLane > 0) {
2036
- this.state.playerLane--;
2037
- this.render();
2259
+ if (key.name === "up" || key.name === "w") {
2260
+ if (this.state.dy !== 1) {
2261
+ this.state.desiredDx = 0;
2262
+ this.state.desiredDy = -1;
2038
2263
  }
2039
- } else if (key.name === "right" || key.name === "d") {
2040
- if (this.state.playerLane < LANE_COUNT - 1) {
2041
- this.state.playerLane++;
2042
- this.render();
2264
+ } else if (key.name === "down" || key.name === "s") {
2265
+ if (this.state.dy !== -1) {
2266
+ this.state.desiredDx = 0;
2267
+ this.state.desiredDy = 1;
2043
2268
  }
2044
- } else if (key.name === "up" || key.name === "w" || key.name === "space") {
2045
- if (!this.state.isJumping) {
2046
- this.state.isJumping = true;
2047
- this.state.jumpTicksRemaining = 3;
2048
- this.render();
2269
+ } else if (key.name === "left" || key.name === "a") {
2270
+ if (this.state.dx !== 1) {
2271
+ this.state.desiredDx = -1;
2272
+ this.state.desiredDy = 0;
2273
+ }
2274
+ } else if (key.name === "right" || key.name === "d") {
2275
+ if (this.state.dx !== -1) {
2276
+ this.state.desiredDx = 1;
2277
+ this.state.desiredDy = 0;
2049
2278
  }
2050
- } else if (key.name === "down" || key.name === "s") {
2051
- this.state.isJumping = false;
2052
- this.state.jumpTicksRemaining = 0;
2053
- this.render();
2054
2279
  }
2055
2280
  }
2056
2281
  render() {
@@ -2058,18 +2283,17 @@ var ByteRunnerGame = class {
2058
2283
  if (this.showTutorial) {
2059
2284
  const lines = [
2060
2285
  "",
2061
- t.highlight("OBJECTIVE: SPRINT THE FIBER HIGHWAY"),
2286
+ t.highlight("OBJECTIVE: FEAST AND GROW THE CYBER VIPER"),
2062
2287
  "",
2063
- "\u2022 Use Left/Right (or A/D) to switch between 3 data lanes.",
2064
- "\u2022 Press Up / Space to Phase Jump over low corrupted blocks.",
2065
- "\u2022 Collect Clean Byte packets to boost your score.",
2066
- "\u2022 Grab Power-ups: [SHLD] Shield, [SLOW] Buffer, [MAG] Magnet, [2X] Double.",
2067
- "\u2022 Speed escalates continuously with distance.",
2288
+ "\u2022 Use Arrow Keys or WASD to steer the viper.",
2289
+ "\u2022 Eat glowing Energy Apples [ \u25C6 ] to grow longer and gain +100 score.",
2290
+ "\u2022 Snag rare Golden Orbs [ \u2605 ] before they vanish for +500 points!",
2291
+ "\u2022 Do NOT crash into the grid borders or your own tail.",
2068
2292
  "",
2069
2293
  t.border("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),
2070
2294
  t.primary("Press Space or Enter to launch \u2502 Esc / Q to Exit")
2071
2295
  ];
2072
- const box = this.renderer.createBox(lines, 64, "BYTE RUNNER MANUAL");
2296
+ const box = this.renderer.createBox(lines, 64, "CYBER VIPER MANUAL");
2073
2297
  this.renderer.clear();
2074
2298
  this.renderer.draw(`
2075
2299
 
@@ -2078,10 +2302,10 @@ ${box}
2078
2302
  return;
2079
2303
  }
2080
2304
  if (this.isPaused) {
2081
- const pauseItems = ["Resume Runner (Esc / Enter)", "Restart Run (R)", "Quit to Arcade / Terminal (Q)"];
2305
+ const pauseItems = ["Resume Viper (Esc / Enter)", "Restart Round (R)", "Return to Game List (Q)"];
2082
2306
  const pauseLines = [
2083
2307
  "",
2084
- t.highlight("\u2550\u2550\u2550 HIGHWAY PACKET STREAM PAUSED \u2550\u2550\u2550"),
2308
+ t.highlight("\u2550\u2550\u2550 VIPER RUN PAUSED \u2550\u2550\u2550"),
2085
2309
  "",
2086
2310
  ...pauseItems.map((item, idx) => {
2087
2311
  if (idx === this.pauseMenuIndex) {
@@ -2091,7 +2315,7 @@ ${box}
2091
2315
  }),
2092
2316
  "",
2093
2317
  t.border("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),
2094
- t.muted("Use Up/Down to navigate \u2502 Enter: Select \u2502 Esc: Resume \u2502 Q: Quit")
2318
+ t.muted("Use Up/Down to navigate \u2502 Enter: Select \u2502 Esc: Resume \u2502 Q: Return to Game List")
2095
2319
  ];
2096
2320
  const pauseBox = this.renderer.createBox(pauseLines, 64, "SYSTEM PAUSE");
2097
2321
  this.renderer.clear();
@@ -2102,68 +2326,58 @@ ${pauseBox}
2102
2326
  return;
2103
2327
  }
2104
2328
  const header = this.renderer.renderHeader({
2105
- title: "BYTE RUNNER",
2329
+ title: "CYBER VIPER",
2106
2330
  category: "ARCADE",
2107
2331
  difficulty: this.config?.difficulty,
2108
2332
  score: this.state.score
2109
2333
  });
2110
2334
  const hudLines = [];
2111
- const distStr = `${t.muted("Distance:")} ${t.primary(`${this.state.distance}m`)}`;
2112
- const bytesStr = `${t.muted("Clean Bytes:")} ${t.accent(this.state.cleanBytesCollected.toString())}`;
2113
- const buffs = [];
2114
- if (this.state.activeShield) buffs.push(t.success("[SHIELD ACTIVE]"));
2115
- if (this.state.slowMotionTicks > 0) buffs.push(t.warning(`[SLOW-MO ${Math.ceil(this.state.slowMotionTicks / 10)}s]`));
2116
- if (this.state.magnetTicks > 0) buffs.push(t.secondary(`[MAGNET ${Math.ceil(this.state.magnetTicks / 10)}s]`));
2117
- if (this.state.doubleScoreTicks > 0) buffs.push(t.highlight(`[2X SCORE ${Math.ceil(this.state.doubleScoreTicks / 10)}s]`));
2118
- hudLines.push(` ${distStr} ${bytesStr} ${buffs.join(" ")}`);
2119
- hudLines.push("");
2120
- const trackWidth = 54;
2121
- const laneWidth = 18;
2122
- const trackLines = [];
2123
- trackLines.push(` ${t.border("\u250C" + "\u2500".repeat(trackWidth) + "\u2510")}`);
2124
- for (let y = 0; y < HIGHWAY_HEIGHT; y++) {
2125
- let rowContent = "";
2126
- for (let lane = 0; lane < LANE_COUNT; lane++) {
2127
- const ent = this.entities.find((e) => e.lane === lane && e.y === y);
2128
- let cellText = " ".repeat(laneWidth);
2129
- if (ent) {
2130
- let formattedLabel = ent.label;
2131
- if (ent.type === "corrupt") {
2132
- formattedLabel = t.error(ent.label);
2133
- } else if (ent.type === "clean") {
2134
- formattedLabel = t.success(ent.label);
2135
- } else if (ent.type === "powerup") {
2136
- formattedLabel = t.highlight(ent.label);
2137
- }
2138
- const cleanLen = ent.label.length;
2139
- const leftPad = Math.floor((laneWidth - cleanLen) / 2);
2140
- const rightPad = laneWidth - cleanLen - leftPad;
2141
- cellText = " ".repeat(Math.max(0, leftPad)) + formattedLabel + " ".repeat(Math.max(0, rightPad));
2335
+ const lenStr = `${t.muted("Length:")} ${t.primary(this.state.snake.length.toString())}`;
2336
+ const applesStr = `${t.muted("Apples:")} ${t.accent(this.state.applesEaten.toString())}`;
2337
+ const goldStr = this.state.goldenFoodTicks > 0 ? t.warning(`\u2605 GOLDEN ORB ACTIVE [${Math.ceil(this.state.goldenFoodTicks / 10)}s]`) : "";
2338
+ hudLines.push(` ${lenStr} ${applesStr} ${goldStr}`);
2339
+ const boardLines = [];
2340
+ boardLines.push(` ${t.border("\u2554" + "\u2550\u2550".repeat(GRID_WIDTH) + "\u2557")}`);
2341
+ for (let y = 0; y < GRID_HEIGHT; y++) {
2342
+ let row = ` ${t.border("\u2551")}`;
2343
+ for (let x = 0; x < GRID_WIDTH; x++) {
2344
+ if (x === this.state.snake[0].x && y === this.state.snake[0].y) {
2345
+ row += t.highlight("\u25C6 ");
2346
+ continue;
2142
2347
  }
2143
- if (y === HIGHWAY_HEIGHT - 2 && lane === this.state.playerLane) {
2144
- const avatar = this.state.isJumping ? "\u25B2 [AIRBORNE] \u25B2" : "\u25B2\u2550\u2550[RUNNER]\u2550\u2550\u25B2";
2145
- const colored = this.state.activeShield ? t.highlight(avatar) : t.primary(avatar);
2146
- const pad = Math.max(0, Math.floor((laneWidth - 14) / 2));
2147
- cellText = " ".repeat(pad) + colored + " ".repeat(Math.max(0, laneWidth - 14 - pad));
2348
+ const isBody = this.state.snake.some((s, idx) => idx > 0 && s.x === x && s.y === y);
2349
+ if (isBody) {
2350
+ row += t.success("\u25A0 ");
2351
+ continue;
2148
2352
  }
2149
- rowContent += cellText + (lane < LANE_COUNT - 1 ? t.border("\u2506") : "");
2353
+ if (x === this.state.food.x && y === this.state.food.y) {
2354
+ row += t.error("\u25C6 ");
2355
+ continue;
2356
+ }
2357
+ if (this.state.goldenFood && x === this.state.goldenFood.x && y === this.state.goldenFood.y) {
2358
+ row += t.accent("\u2605 ");
2359
+ continue;
2360
+ }
2361
+ row += " ";
2150
2362
  }
2151
- trackLines.push(` ${t.border("\u2502")}${rowContent}${t.border("\u2502")}`);
2363
+ row += t.border("\u2551");
2364
+ boardLines.push(row);
2152
2365
  }
2153
- trackLines.push(` ${t.border("\u2514" + "\u2500".repeat(trackWidth) + "\u2518")}`);
2366
+ boardLines.push(` ${t.border("\u255A" + "\u2550\u2550".repeat(GRID_WIDTH) + "\u255D")}`);
2154
2367
  if (this.state.isGameOver) {
2155
- trackLines.push(`
2156
- ${t.error("\u{1F4A5} SYSTEM FAULT: PACKET CORRUPTED!")}`);
2157
- trackLines.push(` ${t.accent(`Final Distance: ${this.state.distance}m \u2502 Final Score: ${this.state.score}`)}`);
2158
- trackLines.push(` ${t.muted("Press R to Re-engage Runner, or Esc / Q to Exit.")}`);
2368
+ boardLines.push(`
2369
+ ${t.error("\u{1F4A5} COLLISION! VIPER TERMINATED.")}`);
2370
+ boardLines.push(` ${t.accent(`Final Length: ${this.state.snake.length} segments \u2502 Final Score: ${this.state.score}`)}`);
2371
+ boardLines.push(` ${t.muted("Press R to Re-engage, or Esc / Q to Return to Game List.")}`);
2159
2372
  } else {
2160
- trackLines.push(` ${t.muted("Controls: Left/Right: Lane \u2502 Up/Space: Jump \u2502 Esc/P: Pause \u2502 Q: Quit")}`);
2373
+ boardLines.push(`
2374
+ ${t.muted("Controls: Arrows/WASD: Steer \u2502 Esc/P: Pause \u2502 Q: Return to Game List")}`);
2161
2375
  }
2162
2376
  this.renderer.clear();
2163
2377
  this.renderer.draw(`
2164
2378
  ${header}
2165
2379
  ${hudLines.join("\n")}
2166
- ${trackLines.join("\n")}
2380
+ ${boardLines.join("\n")}
2167
2381
  `);
2168
2382
  }
2169
2383
  getState() {
@@ -2171,64 +2385,39 @@ ${trackLines.join("\n")}
2171
2385
  }
2172
2386
  };
2173
2387
 
2174
- // src/games/packet-man/index.ts
2175
- var MAZE_TEMPLATE = [
2176
- "###########################",
2177
- "#............#............#",
2178
- "#.####.#####.#.#####.####.#",
2179
- "#O####.#####.#.#####.####O#",
2180
- "#.####.#####.#.#####.####.#",
2181
- "#.........................#",
2182
- "#.####.##.#######.##.####.#",
2183
- "#......##....#....##......#",
2184
- "######.##### # #####.######",
2185
- " #.# #.# ",
2186
- "######.# ###---### #.######",
2187
- "#......# # # #......#",
2188
- "#.####.# ######### #.####.#",
2189
- "#O..##...............##..O#",
2190
- "###.##.##.#######.##.##.###",
2191
- "#......##....#....##......#",
2192
- "#.##########.#.##########.#",
2193
- "#.........................#",
2194
- "###########################"
2195
- ];
2196
- var MAZE_WIDTH = 27;
2197
- var MAZE_HEIGHT = 19;
2198
- var PacketManGame = class {
2199
- id = "packet-man";
2200
- metadata = ALL_GAMES_METADATA["packet-man"];
2388
+ // src/games/void-invaders/index.ts
2389
+ var ARENA_WIDTH = 52;
2390
+ var ARENA_HEIGHT = 16;
2391
+ var PLAYER_Y = 15;
2392
+ var VoidInvadersGame = class {
2393
+ id = "void-invaders";
2394
+ metadata = ALL_GAMES_METADATA["void-invaders"];
2201
2395
  config = null;
2202
2396
  renderer = defaultRenderer;
2203
2397
  input = new TerminalInputHandler();
2204
2398
  rng = new DeterministicRNG();
2205
2399
  gameLoopTimer = null;
2206
- grid = [];
2207
- daemons = [];
2208
- daemonsChompedInSurge = 0;
2209
- pelletsEatenCount = 0;
2400
+ invaderIdCounter = 0;
2401
+ baseSpeedTicks = 12;
2210
2402
  state = {
2211
- playerX: 13,
2212
- playerY: 13,
2213
- playerDx: 0,
2214
- playerDy: 0,
2215
- desiredDx: 0,
2216
- desiredDy: 0,
2217
- mouthOpen: true,
2403
+ playerX: 24,
2404
+ playerY: PLAYER_Y,
2218
2405
  lives: 3,
2219
2406
  score: 0,
2220
- level: 1,
2221
- pelletsRemaining: 0,
2222
- totalPellets: 0,
2223
- frightenedTicksRemaining: 0,
2224
- frightenedCombo: 0,
2225
- isWon: false,
2226
- isGameOver: false
2407
+ invadersDestroyed: 0,
2408
+ wave: 1,
2409
+ descentSpeedTicks: 12,
2410
+ descentTickCounter: 0,
2411
+ currentInvader: null,
2412
+ bullets: [],
2413
+ isGameOver: false,
2414
+ isWon: false
2227
2415
  };
2228
2416
  isPaused = false;
2229
2417
  pauseMenuIndex = 0;
2230
2418
  showTutorial = true;
2231
- tickIntervalMs = 150;
2419
+ tickIntervalMs = 45;
2420
+ // Smooth 22 FPS loop
2232
2421
  init(config) {
2233
2422
  this.config = config;
2234
2423
  this.renderer.setTheme(config.theme);
@@ -2236,7 +2425,7 @@ var PacketManGame = class {
2236
2425
  if (config.skipTutorial !== void 0) {
2237
2426
  this.showTutorial = !config.skipTutorial;
2238
2427
  }
2239
- this.resetGame(1, config.difficulty);
2428
+ this.resetGame(config.difficulty);
2240
2429
  }
2241
2430
  start() {
2242
2431
  this.isPaused = false;
@@ -2264,7 +2453,7 @@ var PacketManGame = class {
2264
2453
  }
2265
2454
  restart() {
2266
2455
  if (this.config) {
2267
- this.resetGame(1, this.config.difficulty);
2456
+ this.resetGame(this.config.difficulty);
2268
2457
  this.scheduleNextTick();
2269
2458
  this.render();
2270
2459
  }
@@ -2272,15 +2461,11 @@ var PacketManGame = class {
2272
2461
  saveState() {
2273
2462
  return {
2274
2463
  state: this.state,
2275
- grid: this.grid,
2276
- daemons: this.daemons,
2277
2464
  showTutorial: this.showTutorial
2278
2465
  };
2279
2466
  }
2280
2467
  loadState(saved) {
2281
2468
  if (saved["state"]) this.state = saved["state"];
2282
- if (saved["grid"]) this.grid = saved["grid"];
2283
- if (saved["daemons"]) this.daemons = saved["daemons"];
2284
2469
  if (saved["showTutorial"] !== void 0) this.showTutorial = !!saved["showTutorial"];
2285
2470
  }
2286
2471
  destroy() {
@@ -2290,125 +2475,69 @@ var PacketManGame = class {
2290
2475
  }
2291
2476
  this.input.stop();
2292
2477
  }
2293
- resetGame(level, difficulty) {
2478
+ resetGame(difficulty) {
2294
2479
  switch (difficulty) {
2295
2480
  case "easy":
2296
- this.tickIntervalMs = 175;
2481
+ this.baseSpeedTicks = 14;
2297
2482
  break;
2298
2483
  case "normal":
2299
- this.tickIntervalMs = 145;
2484
+ this.baseSpeedTicks = 11;
2300
2485
  break;
2301
2486
  case "hard":
2302
- this.tickIntervalMs = 120;
2487
+ this.baseSpeedTicks = 8;
2303
2488
  break;
2304
2489
  case "insane":
2305
- this.tickIntervalMs = 95;
2490
+ this.baseSpeedTicks = 6;
2306
2491
  break;
2307
2492
  }
2308
2493
  this.state = {
2309
- playerX: 13,
2310
- playerY: 13,
2311
- playerDx: -1,
2312
- playerDy: 0,
2313
- desiredDx: -1,
2314
- desiredDy: 0,
2315
- mouthOpen: true,
2494
+ playerX: 24,
2495
+ playerY: PLAYER_Y,
2316
2496
  lives: 3,
2317
- score: this.state.score,
2318
- level,
2319
- pelletsRemaining: 0,
2320
- totalPellets: 0,
2321
- frightenedTicksRemaining: 0,
2322
- frightenedCombo: 0,
2323
- isWon: false,
2324
- isGameOver: false
2497
+ score: 0,
2498
+ invadersDestroyed: 0,
2499
+ wave: 1,
2500
+ descentSpeedTicks: this.baseSpeedTicks,
2501
+ descentTickCounter: 0,
2502
+ currentInvader: null,
2503
+ bullets: [],
2504
+ isGameOver: false,
2505
+ isWon: false
2325
2506
  };
2326
- this.daemonsChompedInSurge = 0;
2327
- this.loadMaze();
2328
- this.resetDaemons();
2507
+ this.spawnNextInvader();
2329
2508
  }
2330
- loadMaze() {
2331
- this.grid = [];
2332
- let pellets = 0;
2333
- for (let y = 0; y < MAZE_HEIGHT; y++) {
2334
- const row = [];
2335
- const line = MAZE_TEMPLATE[y] || "";
2336
- for (let x = 0; x < MAZE_WIDTH; x++) {
2337
- const char = line[x] || " ";
2338
- if (char === "#") {
2339
- row.push("wall");
2340
- } else if (char === ".") {
2341
- row.push("pellet");
2342
- pellets++;
2343
- } else if (char === "O") {
2344
- row.push("power");
2345
- pellets++;
2346
- } else if (char === "-") {
2347
- row.push("gate");
2348
- } else {
2349
- row.push("empty");
2350
- }
2351
- }
2352
- this.grid.push(row);
2509
+ spawnNextInvader() {
2510
+ const x = this.rng.nextInt(2, ARENA_WIDTH - 6);
2511
+ const roll = this.rng.next();
2512
+ let type = "scout";
2513
+ let glyph = "\u203B ";
2514
+ let points = 100;
2515
+ if (roll < 0.45) {
2516
+ type = "scout";
2517
+ glyph = "\u203B ";
2518
+ points = 100;
2519
+ } else if (roll < 0.75) {
2520
+ type = "fighter";
2521
+ glyph = "\u{1F47E}";
2522
+ points = 150;
2523
+ } else if (roll < 0.92) {
2524
+ type = "bomber";
2525
+ glyph = "W ";
2526
+ points = 200;
2527
+ } else {
2528
+ type = "mothership";
2529
+ glyph = "\u{1F6F8}";
2530
+ points = 400;
2353
2531
  }
2354
- this.state.pelletsRemaining = pellets;
2355
- this.state.totalPellets = pellets;
2356
- }
2357
- resetDaemons() {
2358
- this.daemons = [
2359
- {
2360
- id: "blinky",
2361
- name: "Blinky",
2362
- x: 13,
2363
- y: 7,
2364
- dx: 1,
2365
- dy: 0,
2366
- baseX: 25,
2367
- baseY: 1,
2368
- state: "chase",
2369
- frightenedTicks: 0,
2370
- colorName: "red"
2371
- },
2372
- {
2373
- id: "pinky",
2374
- name: "Pinky",
2375
- x: 12,
2376
- y: 11,
2377
- dx: 0,
2378
- dy: -1,
2379
- baseX: 1,
2380
- baseY: 1,
2381
- state: "chase",
2382
- frightenedTicks: 0,
2383
- colorName: "pink"
2384
- },
2385
- {
2386
- id: "inky",
2387
- name: "Inky",
2388
- x: 13,
2389
- y: 11,
2390
- dx: 0,
2391
- dy: -1,
2392
- baseX: 25,
2393
- baseY: 17,
2394
- state: "chase",
2395
- frightenedTicks: 0,
2396
- colorName: "cyan"
2397
- },
2398
- {
2399
- id: "clyde",
2400
- name: "Clyde",
2401
- x: 14,
2402
- y: 11,
2403
- dx: 0,
2404
- dy: -1,
2405
- baseX: 1,
2406
- baseY: 17,
2407
- state: "chase",
2408
- frightenedTicks: 0,
2409
- colorName: "yellow"
2410
- }
2411
- ];
2532
+ this.state.currentInvader = {
2533
+ id: ++this.invaderIdCounter,
2534
+ type,
2535
+ x,
2536
+ y: 1,
2537
+ glyph,
2538
+ points,
2539
+ alive: true
2540
+ };
2412
2541
  }
2413
2542
  scheduleNextTick() {
2414
2543
  if (this.gameLoopTimer) clearTimeout(this.gameLoopTimer);
@@ -2420,179 +2549,75 @@ var PacketManGame = class {
2420
2549
  }
2421
2550
  tick() {
2422
2551
  if (this.state.isGameOver || this.state.isWon || this.isPaused || this.showTutorial) return;
2423
- this.state.mouthOpen = !this.state.mouthOpen;
2424
- if (this.state.frightenedTicksRemaining > 0) {
2425
- this.state.frightenedTicksRemaining--;
2426
- if (this.state.frightenedTicksRemaining === 0) {
2427
- for (const d of this.daemons) {
2428
- if (d.state === "frightened") d.state = "chase";
2429
- }
2430
- }
2431
- }
2432
- if (this.canMove(this.state.playerX, this.state.playerY, this.state.desiredDx, this.state.desiredDy)) {
2433
- this.state.playerDx = this.state.desiredDx;
2434
- this.state.playerDy = this.state.desiredDy;
2435
- }
2436
- if (this.canMove(this.state.playerX, this.state.playerY, this.state.playerDx, this.state.playerDy)) {
2437
- this.state.playerX += this.state.playerDx;
2438
- this.state.playerY += this.state.playerDy;
2439
- if (this.state.playerX < 0) this.state.playerX = MAZE_WIDTH - 1;
2440
- else if (this.state.playerX >= MAZE_WIDTH) this.state.playerX = 0;
2441
- this.chompCurrentTile();
2442
- }
2443
- this.moveDaemons();
2552
+ this.updateBullets();
2444
2553
  this.checkCollisions();
2554
+ this.state.descentTickCounter++;
2555
+ if (this.state.descentTickCounter >= this.state.descentSpeedTicks) {
2556
+ this.state.descentTickCounter = 0;
2557
+ this.advanceInvaderDescent();
2558
+ }
2445
2559
  this.render();
2446
2560
  }
2447
- canMove(x, y, dx, dy, isDaemon = false) {
2448
- let nx = x + dx;
2449
- let ny = y + dy;
2450
- if (nx < 0) nx = MAZE_WIDTH - 1;
2451
- else if (nx >= MAZE_WIDTH) nx = 0;
2452
- if (ny < 0 || ny >= MAZE_HEIGHT) return false;
2453
- const tile = this.grid[ny]?.[nx];
2454
- if (!tile || tile === "wall") return false;
2455
- if (tile === "gate" && !isDaemon) return false;
2456
- return true;
2457
- }
2458
- chompCurrentTile() {
2459
- const tile = this.grid[this.state.playerY]?.[this.state.playerX];
2460
- if (tile === "pellet") {
2461
- this.grid[this.state.playerY][this.state.playerX] = "empty";
2462
- this.state.score += 10;
2463
- this.state.pelletsRemaining--;
2464
- this.pelletsEatenCount++;
2465
- this.config?.onScoreUpdate?.(this.state.score);
2466
- if (this.pelletsEatenCount >= 50) {
2467
- this.config?.onAchievementUnlock?.("first_chomp");
2468
- }
2469
- if (this.state.pelletsRemaining === 0) {
2470
- this.state.isWon = true;
2471
- this.config?.onAchievementUnlock?.("maze_sweeper");
2472
- return;
2473
- }
2474
- } else if (tile === "power") {
2475
- this.grid[this.state.playerY][this.state.playerX] = "empty";
2476
- this.state.score += 50;
2477
- this.state.pelletsRemaining--;
2478
- this.daemonsChompedInSurge = 0;
2479
- let surgeTicks = 45;
2480
- if (this.config?.difficulty === "easy") surgeTicks = 65;
2481
- else if (this.config?.difficulty === "hard") surgeTicks = 30;
2482
- else if (this.config?.difficulty === "insane") surgeTicks = 18;
2483
- this.state.frightenedTicksRemaining = surgeTicks;
2484
- this.state.frightenedCombo = 0;
2485
- for (const d of this.daemons) {
2486
- if (d.state !== "eaten") {
2487
- d.state = "frightened";
2488
- d.dx = -d.dx;
2489
- d.dy = -d.dy;
2490
- }
2561
+ updateBullets() {
2562
+ const nextBullets = [];
2563
+ for (const b of this.state.bullets) {
2564
+ b.y -= 1;
2565
+ if (b.y >= 0) {
2566
+ nextBullets.push(b);
2491
2567
  }
2492
- if (this.config?.soundEnabled) playTerminalBell();
2493
2568
  }
2569
+ this.state.bullets = nextBullets;
2494
2570
  }
2495
- moveDaemons() {
2496
- const directions = [
2497
- [0, -1],
2498
- // Up
2499
- [-1, 0],
2500
- // Left
2501
- [0, 1],
2502
- // Down
2503
- [1, 0]
2504
- // Right
2505
- ];
2506
- for (const d of this.daemons) {
2507
- if (d.state === "eaten") {
2508
- if (d.x === 13 && d.y === 9) {
2509
- d.state = "chase";
2510
- }
2511
- }
2512
- const validDirs = [];
2513
- for (const [dx, dy] of directions) {
2514
- if (dx === -d.dx && dy === -d.dy) continue;
2515
- if (this.canMove(d.x, d.y, dx, dy, true)) {
2516
- validDirs.push([dx, dy]);
2517
- }
2518
- }
2519
- if (validDirs.length === 0) {
2520
- if (this.canMove(d.x, d.y, -d.dx, -d.dy, true)) {
2521
- validDirs.push([-d.dx, -d.dy]);
2522
- }
2523
- }
2524
- if (validDirs.length > 0) {
2525
- let chosenDir;
2526
- if (d.state === "frightened") {
2527
- chosenDir = this.rng.pick(validDirs);
2528
- } else {
2529
- let targetX = this.state.playerX;
2530
- let targetY = this.state.playerY;
2531
- if (d.id === "pinky") {
2532
- targetX += this.state.playerDx * 4;
2533
- targetY += this.state.playerDy * 4;
2534
- } else if (d.id === "clyde") {
2535
- const dist = Math.hypot(d.x - this.state.playerX, d.y - this.state.playerY);
2536
- if (dist < 6) {
2537
- targetX = d.baseX;
2538
- targetY = d.baseY;
2539
- }
2540
- }
2541
- chosenDir = validDirs[0];
2542
- let minDist = Infinity;
2543
- for (const [vx, vy] of validDirs) {
2544
- const nx = d.x + vx;
2545
- const ny = d.y + vy;
2546
- const dist = Math.hypot(nx - targetX, ny - targetY);
2547
- if (dist < minDist) {
2548
- minDist = dist;
2549
- chosenDir = [vx, vy];
2550
- }
2551
- }
2552
- }
2553
- d.dx = chosenDir[0];
2554
- d.dy = chosenDir[1];
2555
- d.x += d.dx;
2556
- d.y += d.dy;
2557
- if (d.x < 0) d.x = MAZE_WIDTH - 1;
2558
- else if (d.x >= MAZE_WIDTH) d.x = 0;
2571
+ advanceInvaderDescent() {
2572
+ const inv = this.state.currentInvader;
2573
+ if (!inv || !inv.alive) {
2574
+ this.spawnNextInvader();
2575
+ return;
2576
+ }
2577
+ inv.y += 1;
2578
+ if (inv.y >= PLAYER_Y) {
2579
+ inv.alive = false;
2580
+ this.state.lives -= 1;
2581
+ if (this.config?.soundEnabled) playTerminalBell();
2582
+ if (this.state.lives <= 0) {
2583
+ this.state.isGameOver = true;
2584
+ this.config?.onGameOver?.(this.state.score);
2585
+ } else {
2586
+ this.spawnNextInvader();
2559
2587
  }
2560
2588
  }
2561
2589
  }
2562
2590
  checkCollisions() {
2563
- for (const d of this.daemons) {
2564
- if (d.x === this.state.playerX && d.y === this.state.playerY) {
2565
- if (d.state === "frightened") {
2566
- d.state = "eaten";
2567
- d.x = 13;
2568
- d.y = 9;
2569
- this.state.frightenedCombo++;
2570
- const points = 200 * Math.pow(2, this.state.frightenedCombo - 1);
2571
- this.state.score += points;
2572
- this.daemonsChompedInSurge++;
2573
- if (this.daemonsChompedInSurge >= 4) {
2574
- this.config?.onAchievementUnlock?.("daemon_slayer");
2575
- }
2576
- if (this.config?.soundEnabled) playTerminalBell();
2577
- } else if (d.state === "chase") {
2578
- this.state.lives--;
2579
- if (this.config?.soundEnabled) playTerminalBell();
2580
- if (this.state.lives <= 0) {
2581
- this.state.isGameOver = true;
2582
- this.config?.onGameOver?.(this.state.score);
2583
- } else {
2584
- this.state.playerX = 13;
2585
- this.state.playerY = 13;
2586
- this.state.playerDx = -1;
2587
- this.state.playerDy = 0;
2588
- this.state.desiredDx = -1;
2589
- this.state.desiredDy = 0;
2590
- this.resetDaemons();
2591
- }
2592
- break;
2591
+ const inv = this.state.currentInvader;
2592
+ if (!inv || !inv.alive) return;
2593
+ const remainingBullets = [];
2594
+ let invaderHit = false;
2595
+ for (const b of this.state.bullets) {
2596
+ if ((b.y === inv.y || b.y === inv.y - 1) && b.x >= inv.x - 1 && b.x <= inv.x + 2) {
2597
+ invaderHit = true;
2598
+ inv.alive = false;
2599
+ this.state.score += inv.points;
2600
+ this.state.invadersDestroyed++;
2601
+ this.state.descentSpeedTicks = Math.max(2, this.baseSpeedTicks - Math.floor(this.state.invadersDestroyed / 4));
2602
+ this.state.wave = 1 + Math.floor(this.state.invadersDestroyed / 10);
2603
+ this.config?.onScoreUpdate?.(this.state.score);
2604
+ this.config?.onAchievementUnlock?.("alien_down");
2605
+ if (inv.type === "mothership") {
2606
+ this.config?.onAchievementUnlock?.("mothership_shot");
2593
2607
  }
2608
+ if (this.state.invadersDestroyed >= 20) {
2609
+ this.config?.onAchievementUnlock?.("wave_cleared");
2610
+ }
2611
+ if (this.config?.soundEnabled) playTerminalBell();
2612
+ break;
2613
+ } else {
2614
+ remainingBullets.push(b);
2594
2615
  }
2595
2616
  }
2617
+ if (invaderHit) {
2618
+ this.state.bullets = remainingBullets;
2619
+ this.spawnNextInvader();
2620
+ }
2596
2621
  }
2597
2622
  handleInput(key) {
2598
2623
  if (this.showTutorial) {
@@ -2620,7 +2645,7 @@ var PacketManGame = class {
2620
2645
  this.render();
2621
2646
  } else if (this.pauseMenuIndex === 1) {
2622
2647
  this.isPaused = false;
2623
- this.resetGame(this.state.level, this.config?.difficulty || "normal");
2648
+ this.resetGame(this.config?.difficulty || "normal");
2624
2649
  this.scheduleNextTick();
2625
2650
  this.render();
2626
2651
  } else if (this.pauseMenuIndex === 2) {
@@ -2652,17 +2677,6 @@ var PacketManGame = class {
2652
2677
  this.config?.onExit?.();
2653
2678
  return;
2654
2679
  }
2655
- if (this.state.isWon) {
2656
- if (key.name === "return" || key.name === "space") {
2657
- this.resetGame(this.state.level + 1, this.config?.difficulty || "normal");
2658
- this.scheduleNextTick();
2659
- this.render();
2660
- } else if (key.name === "escape" || key.name === "q") {
2661
- this.destroy();
2662
- this.config?.onExit?.();
2663
- }
2664
- return;
2665
- }
2666
2680
  if (this.state.isGameOver) {
2667
2681
  if (key.name === "r") {
2668
2682
  this.restart();
@@ -2672,18 +2686,25 @@ var PacketManGame = class {
2672
2686
  }
2673
2687
  return;
2674
2688
  }
2675
- if (key.name === "up" || key.name === "w") {
2676
- this.state.desiredDx = 0;
2677
- this.state.desiredDy = -1;
2678
- } else if (key.name === "down" || key.name === "s") {
2679
- this.state.desiredDx = 0;
2680
- this.state.desiredDy = 1;
2681
- } else if (key.name === "left" || key.name === "a") {
2682
- this.state.desiredDx = -1;
2683
- this.state.desiredDy = 0;
2689
+ if (key.name === "left" || key.name === "a") {
2690
+ if (this.state.playerX > 1) {
2691
+ this.state.playerX -= 2;
2692
+ this.render();
2693
+ }
2684
2694
  } else if (key.name === "right" || key.name === "d") {
2685
- this.state.desiredDx = 1;
2686
- this.state.desiredDy = 0;
2695
+ if (this.state.playerX < ARENA_WIDTH - 4) {
2696
+ this.state.playerX += 2;
2697
+ this.render();
2698
+ }
2699
+ } else if (key.name === "space" || key.name === "up" || key.name === "w") {
2700
+ if (this.state.bullets.length < 3) {
2701
+ this.state.bullets.push({
2702
+ x: this.state.playerX + 1,
2703
+ y: PLAYER_Y - 1
2704
+ });
2705
+ if (this.config?.soundEnabled) playTerminalBell();
2706
+ this.render();
2707
+ }
2687
2708
  }
2688
2709
  }
2689
2710
  render() {
@@ -2691,18 +2712,18 @@ var PacketManGame = class {
2691
2712
  if (this.showTutorial) {
2692
2713
  const lines = [
2693
2714
  "",
2694
- t.highlight("OBJECTIVE: CHOMP BYTE PELLETS & PURGE DAEMONS"),
2715
+ t.highlight("MISSION BRIEFING: INTERCEPT DESCENDING INVADERS"),
2695
2716
  "",
2696
- "\u2022 Use Arrow Keys or WASD to navigate memory corridors.",
2697
- "\u2022 Chomp all data pellets [ \xB7 ] to clear the sector.",
2698
- "\u2022 Ingest Super Capacitors [ \u25CF ] to trigger Power Surge state.",
2699
- "\u2022 During Power Surge, hunt vulnerable memory daemons for huge multipliers!",
2700
- "\u2022 Wrap through the side tunnels to evade ambushes.",
2717
+ "\u2022 Invaders drop from the top of the screen one at a time at random spots.",
2718
+ "\u2022 Slide your Laser Cannon Left & Right to line up your shot.",
2719
+ "\u2022 Press Spacebar to shoot them down BEFORE they reach the ground!",
2720
+ "\u2022 If an invader touches the ground, you lose 1 Cannon Life.",
2721
+ "\u2022 You have 3 Lives. Speed increases gradually as you score higher!",
2701
2722
  "",
2702
2723
  t.border("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),
2703
- t.primary("Press Space or Enter to start \u2502 Esc / Q to Exit")
2724
+ t.primary("Press Space or Enter to engage armada \u2502 Esc / Q to Exit")
2704
2725
  ];
2705
- const box = this.renderer.createBox(lines, 64, "PACKET MAN PROTOCOL MANUAL");
2726
+ const box = this.renderer.createBox(lines, 64, "SPACE INVADERS MANUAL");
2706
2727
  this.renderer.clear();
2707
2728
  this.renderer.draw(`
2708
2729
 
@@ -2711,10 +2732,10 @@ ${box}
2711
2732
  return;
2712
2733
  }
2713
2734
  if (this.isPaused) {
2714
- const pauseItems = ["Resume Arcade (Esc / Enter)", "Restart Round (R)", "Quit to Arcade / Terminal (Q)"];
2735
+ const pauseItems = ["Resume Battle (Esc / Enter)", "Restart Round (R)", "Return to Game List (Q)"];
2715
2736
  const pauseLines = [
2716
2737
  "",
2717
- t.highlight("\u2550\u2550\u2550 MEMORY MAZE PAUSED \u2550\u2550\u2550"),
2738
+ t.highlight("\u2550\u2550\u2550 SPACE INVADERS PAUSED \u2550\u2550\u2550"),
2718
2739
  "",
2719
2740
  ...pauseItems.map((item, idx) => {
2720
2741
  if (idx === this.pauseMenuIndex) {
@@ -2724,7 +2745,7 @@ ${box}
2724
2745
  }),
2725
2746
  "",
2726
2747
  t.border("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),
2727
- t.muted("Use Up/Down to navigate \u2502 Enter: Select \u2502 Esc: Resume \u2502 Q: Quit")
2748
+ t.muted("Use Up/Down to navigate \u2502 Enter: Select \u2502 Esc: Resume \u2502 Q: Return to Game List")
2728
2749
  ];
2729
2750
  const pauseBox = this.renderer.createBox(pauseLines, 64, "SYSTEM PAUSE");
2730
2751
  this.renderer.clear();
@@ -2735,56 +2756,70 @@ ${pauseBox}
2735
2756
  return;
2736
2757
  }
2737
2758
  const header = this.renderer.renderHeader({
2738
- title: "PACKET MAN",
2759
+ title: "SPACE INVADERS",
2739
2760
  category: "ARCADE",
2740
2761
  difficulty: this.config?.difficulty,
2741
- score: this.state.score,
2742
- level: this.state.level
2762
+ score: this.state.score
2743
2763
  });
2744
2764
  const hudLines = [];
2745
- const livesStr = `${t.muted("Buffer Lives:")} ${t.highlight("\u25BA ".repeat(Math.max(0, this.state.lives)))}`;
2746
- const surgeStr = this.state.frightenedTicksRemaining > 0 ? t.warning(`\u26A1 OVERCLOCK SURGE [${Math.ceil(this.state.frightenedTicksRemaining / 5)}s]`) : t.muted("NORMAL FLUX");
2747
- hudLines.push(` ${livesStr} ${surgeStr} ${t.muted("Pellets:")} ${t.primary(this.state.pelletsRemaining.toString())}`);
2765
+ const livesStr = `${t.muted("Cannons:")} ${t.highlight("\u25B2\u2550\u25B2 ".repeat(Math.max(0, this.state.lives)))}`;
2766
+ const defeatedStr = `${t.muted("Destroyed:")} ${t.primary(this.state.invadersDestroyed.toString())}`;
2767
+ const levelStr = `${t.muted("Level:")} ${t.secondary(this.state.wave.toString())}`;
2768
+ hudLines.push(` ${livesStr} ${defeatedStr} ${levelStr}`);
2769
+ const grid = [];
2770
+ for (let y = 0; y < ARENA_HEIGHT; y++) {
2771
+ grid.push(new Array(ARENA_WIDTH).fill(" "));
2772
+ }
2773
+ const inv = this.state.currentInvader;
2774
+ if (inv && inv.alive && inv.y >= 0 && inv.y < ARENA_HEIGHT) {
2775
+ const glyph = inv.glyph;
2776
+ if (inv.x >= 0 && inv.x < ARENA_WIDTH) grid[inv.y][inv.x] = glyph[0];
2777
+ if (inv.x + 1 >= 0 && inv.x + 1 < ARENA_WIDTH) grid[inv.y][inv.x + 1] = glyph[1];
2778
+ }
2779
+ for (const b of this.state.bullets) {
2780
+ if (b.y >= 0 && b.y < ARENA_HEIGHT && b.x >= 0 && b.x < ARENA_WIDTH) {
2781
+ grid[b.y][b.x] = "\u2502";
2782
+ }
2783
+ }
2784
+ const px = this.state.playerX;
2785
+ if (px >= 0 && px + 2 < ARENA_WIDTH) {
2786
+ grid[PLAYER_Y][px] = "\u25B2";
2787
+ grid[PLAYER_Y][px + 1] = "\u2550";
2788
+ grid[PLAYER_Y][px + 2] = "\u25B2";
2789
+ }
2748
2790
  const boardLines = [];
2749
- for (let y = 0; y < MAZE_HEIGHT; y++) {
2750
- let row = " ";
2751
- for (let x = 0; x < MAZE_WIDTH; x++) {
2752
- if (x === this.state.playerX && y === this.state.playerY) {
2753
- const char = this.getPlayerGlyph();
2754
- row += t.highlight(char);
2755
- continue;
2756
- }
2757
- const daemon = this.daemons.find((d) => d.x === x && d.y === y);
2758
- if (daemon) {
2759
- row += this.getDaemonGlyph(daemon);
2760
- continue;
2761
- }
2762
- const tile = this.grid[y][x];
2763
- if (tile === "wall") {
2764
- row += t.border("\u2588\u2588");
2765
- } else if (tile === "pellet") {
2766
- row += t.primary(" \xB7");
2767
- } else if (tile === "power") {
2768
- row += t.accent(" \u25CF");
2769
- } else if (tile === "gate") {
2770
- row += t.secondary("\u2550\u2550");
2791
+ boardLines.push(` ${t.border("\u250C" + "\u2500".repeat(ARENA_WIDTH) + "\u2510")}`);
2792
+ for (let y = 0; y < ARENA_HEIGHT; y++) {
2793
+ let row = "";
2794
+ for (let x = 0; x < ARENA_WIDTH; x++) {
2795
+ const ch = grid[y][x];
2796
+ if (ch === "\u25B2" || ch === "\u2550") {
2797
+ row += t.highlight(ch);
2798
+ } else if (ch === "\u2502") {
2799
+ row += t.primary(ch);
2800
+ } else if (ch === "\u203B") {
2801
+ row += t.accent(ch);
2802
+ } else if (ch === "\u{1F47E}") {
2803
+ row += t.secondary(ch);
2804
+ } else if (ch === "W") {
2805
+ row += t.error(ch);
2806
+ } else if (ch === "\u{1F6F8}") {
2807
+ row += t.warning(ch);
2771
2808
  } else {
2772
- row += " ";
2809
+ row += ch;
2773
2810
  }
2774
2811
  }
2775
- boardLines.push(row);
2812
+ boardLines.push(` ${t.border("\u2502")}${row}${t.border("\u2502")}`);
2776
2813
  }
2777
- if (this.state.isWon) {
2778
- boardLines.push(`
2779
- ${t.success("\u{1F389} MEMORY SECTOR COMPLETELY PURGED! EXCELLENT OPERATOR.")}`);
2780
- boardLines.push(` ${t.primary("Press Space or Enter for Next Level...")}`);
2781
- } else if (this.state.isGameOver) {
2814
+ boardLines.push(` ${t.border("\u2514" + "\u2500".repeat(ARENA_WIDTH) + "\u2518")}`);
2815
+ if (this.state.isGameOver) {
2782
2816
  boardLines.push(`
2783
- ${t.error("\u{1F4A5} SYSTEM FAULT: LIVES DEPLETED. KERNEL DUMP.")}`);
2784
- boardLines.push(` ${t.muted("Press R to Re-engage, or Esc / Q to Exit.")}`);
2817
+ ${t.error("\u{1F4A5} DEFENSES BREACHED! EARTH OVERRUN.")}`);
2818
+ boardLines.push(` ${t.accent(`Invaders Destroyed: ${this.state.invadersDestroyed} \u2502 Final Score: ${this.state.score}`)}`);
2819
+ boardLines.push(` ${t.muted("Press R to Re-engage, or Esc / Q to Return to Game List.")}`);
2785
2820
  } else {
2786
2821
  boardLines.push(`
2787
- ${t.muted("Controls: Arrows/WASD: Move \u2502 Esc/P: Pause \u2502 Q: Quit")}`);
2822
+ ${t.muted("Controls: Left/Right / A/D: Move \u2502 Space: Fire \u2502 Esc/P: Pause \u2502 Q: Return to Game List")}`);
2788
2823
  }
2789
2824
  this.renderer.clear();
2790
2825
  this.renderer.draw(`
@@ -2793,32 +2828,392 @@ ${hudLines.join("\n")}
2793
2828
  ${boardLines.join("\n")}
2794
2829
  `);
2795
2830
  }
2796
- getPlayerGlyph() {
2797
- if (!this.state.mouthOpen) return "\u25CB ";
2798
- if (this.state.playerDx === 1) return "\u25BA ";
2799
- if (this.state.playerDx === -1) return "\u25C4 ";
2800
- if (this.state.playerDy === -1) return "\u25B2 ";
2801
- if (this.state.playerDy === 1) return "\u25BC ";
2802
- return "\u25BA ";
2831
+ getState() {
2832
+ return this.state;
2803
2833
  }
2804
- getDaemonGlyph(d) {
2805
- const t = this.renderer.getTheme();
2806
- if (d.state === "frightened") {
2807
- if (this.state.frightenedTicksRemaining < 10 && this.state.frightenedTicksRemaining % 2 === 0) {
2808
- return t.accent("\xA7 ");
2834
+ };
2835
+
2836
+ // src/games/hash-matrix/index.ts
2837
+ import chalk3 from "chalk";
2838
+ var MATRIX_CHARS = "0123456789ABCDEFabcdef!@#$%&*?+-=<>:;~^\xA7\xB1\xB5\xB6\xB7\xBB\xAB";
2839
+ var HashMatrixGame = class {
2840
+ id = "hash-matrix";
2841
+ metadata = ALL_GAMES_METADATA["hash-matrix"];
2842
+ config = null;
2843
+ renderer = defaultRenderer;
2844
+ input = new TerminalInputHandler();
2845
+ rng = new DeterministicRNG();
2846
+ loopTimer = null;
2847
+ resizeHandler = null;
2848
+ rainDrops = [];
2849
+ memoryAddress = 2147434496;
2850
+ state = {
2851
+ mode: "hash-cascade",
2852
+ colorScheme: "matrix-green",
2853
+ hashesGenerated: 0,
2854
+ isPaused: false,
2855
+ speedMs: 40,
2856
+ modesVisited: /* @__PURE__ */ new Set(["hash-cascade"]),
2857
+ sessionStartMs: 0,
2858
+ showBriefing: true
2859
+ };
2860
+ getDimensions() {
2861
+ return {
2862
+ cols: Math.max(40, process.stdout.columns || 80),
2863
+ rows: Math.max(16, process.stdout.rows || 24)
2864
+ };
2865
+ }
2866
+ init(config) {
2867
+ this.config = config;
2868
+ this.renderer.setTheme(config.theme);
2869
+ this.rng = new DeterministicRNG(config.seed || Date.now());
2870
+ const speedMap = {
2871
+ easy: 75,
2872
+ normal: 40,
2873
+ hard: 25,
2874
+ insane: 15
2875
+ };
2876
+ this.state.speedMs = speedMap[config.difficulty] || 40;
2877
+ if (config.theme === "neon") this.state.colorScheme = "cyber-neon";
2878
+ else if (config.theme === "retro-green") this.state.colorScheme = "matrix-green";
2879
+ else if (config.theme === "minimal") this.state.colorScheme = "ghost-white";
2880
+ if (config.skipTutorial !== void 0) {
2881
+ this.state.showBriefing = !config.skipTutorial;
2882
+ }
2883
+ this.initRain();
2884
+ if (process.stdout.on) {
2885
+ this.resizeHandler = () => {
2886
+ this.initRain();
2887
+ this.render();
2888
+ };
2889
+ process.stdout.on("resize", this.resizeHandler);
2890
+ }
2891
+ }
2892
+ initRain() {
2893
+ const { cols, rows } = this.getDimensions();
2894
+ this.rainDrops = [];
2895
+ for (let x = 0; x < cols; x += 2) {
2896
+ this.rainDrops.push({
2897
+ x,
2898
+ y: this.rng.nextInt(0, rows),
2899
+ speed: this.rng.nextInt(1, 3),
2900
+ length: this.rng.nextInt(6, Math.max(10, Math.floor(rows / 2))),
2901
+ chars: Array.from({ length: 25 }, () => MATRIX_CHARS[this.rng.nextInt(0, MATRIX_CHARS.length - 1)])
2902
+ });
2903
+ }
2904
+ }
2905
+ start() {
2906
+ this.state.sessionStartMs = Date.now();
2907
+ this.state.isPaused = false;
2908
+ this.render();
2909
+ this.input.start(
2910
+ (key) => this.handleInput(key),
2911
+ () => {
2912
+ this.stopAndExit();
2809
2913
  }
2810
- return t.secondary("\xA7 ");
2914
+ );
2915
+ if (!this.state.showBriefing) {
2916
+ this.scheduleTick();
2811
2917
  }
2812
- if (d.state === "eaten") {
2813
- return t.muted('""');
2918
+ }
2919
+ pause() {
2920
+ this.state.isPaused = true;
2921
+ if (this.loopTimer) {
2922
+ clearTimeout(this.loopTimer);
2923
+ this.loopTimer = null;
2814
2924
  }
2815
- if (d.colorName === "red") return t.error("M ");
2816
- if (d.colorName === "pink") return t.secondary("M ");
2817
- if (d.colorName === "cyan") return t.primary("M ");
2818
- return t.accent("M ");
2819
2925
  }
2820
- getState() {
2821
- return this.state;
2926
+ resume() {
2927
+ this.state.isPaused = false;
2928
+ this.scheduleTick();
2929
+ }
2930
+ restart() {
2931
+ this.state.hashesGenerated = 0;
2932
+ this.state.sessionStartMs = Date.now();
2933
+ this.initRain();
2934
+ this.render();
2935
+ }
2936
+ saveState() {
2937
+ return {
2938
+ mode: this.state.mode,
2939
+ colorScheme: this.state.colorScheme,
2940
+ hashesGenerated: this.state.hashesGenerated,
2941
+ speedMs: this.state.speedMs,
2942
+ showBriefing: this.state.showBriefing
2943
+ };
2944
+ }
2945
+ loadState(saved) {
2946
+ if (saved["mode"]) this.state.mode = saved["mode"];
2947
+ if (saved["colorScheme"]) this.state.colorScheme = saved["colorScheme"];
2948
+ if (saved["hashesGenerated"]) this.state.hashesGenerated = Number(saved["hashesGenerated"]);
2949
+ if (saved["speedMs"]) this.state.speedMs = Number(saved["speedMs"]);
2950
+ if (saved["showBriefing"] !== void 0) this.state.showBriefing = !!saved["showBriefing"];
2951
+ }
2952
+ destroy() {
2953
+ if (this.loopTimer) {
2954
+ clearTimeout(this.loopTimer);
2955
+ this.loopTimer = null;
2956
+ }
2957
+ if (this.resizeHandler && process.stdout.removeListener) {
2958
+ process.stdout.removeListener("resize", this.resizeHandler);
2959
+ this.resizeHandler = null;
2960
+ }
2961
+ this.input.stop();
2962
+ }
2963
+ stopAndExit() {
2964
+ this.destroy();
2965
+ if (this.config?.onGameOver) {
2966
+ this.config.onGameOver(this.state.hashesGenerated, {
2967
+ hashes: this.state.hashesGenerated,
2968
+ mode: this.state.mode
2969
+ });
2970
+ }
2971
+ if (this.config?.onExit) {
2972
+ this.config.onExit();
2973
+ }
2974
+ }
2975
+ handleInput(key) {
2976
+ if (this.state.showBriefing) {
2977
+ if (key.name === "space" || key.name === "return") {
2978
+ this.state.showBriefing = false;
2979
+ this.scheduleTick();
2980
+ this.render();
2981
+ } else if (key.sequence === "" || key.ctrl && key.name === "c" || key.name === "q" || key.name === "escape") {
2982
+ this.stopAndExit();
2983
+ }
2984
+ return;
2985
+ }
2986
+ if (key.sequence === "" || key.ctrl && key.name === "c" || key.name === "q" || key.name === "escape") {
2987
+ this.stopAndExit();
2988
+ return;
2989
+ }
2990
+ if (key.name === "space") {
2991
+ this.state.isPaused = !this.state.isPaused;
2992
+ if (!this.state.isPaused) this.scheduleTick();
2993
+ this.render();
2994
+ return;
2995
+ }
2996
+ if (key.name === "m" || key.sequence === "m") {
2997
+ const modes = ["hash-cascade", "matrix-rain", "hex-dump", "cipher-breach"];
2998
+ const curr = modes.indexOf(this.state.mode);
2999
+ this.state.mode = modes[(curr + 1) % modes.length];
3000
+ this.state.modesVisited.add(this.state.mode);
3001
+ if (this.state.modesVisited.size >= 4 && this.config?.onAchievementUnlock) {
3002
+ this.config.onAchievementUnlock("matrix_unlocked");
3003
+ }
3004
+ this.render();
3005
+ return;
3006
+ }
3007
+ if (key.name === "c" || key.name === "t" || key.sequence === "c") {
3008
+ const colors = ["matrix-green", "cyber-neon", "amber-crt", "crimson-glitch", "ghost-white"];
3009
+ const curr = colors.indexOf(this.state.colorScheme);
3010
+ this.state.colorScheme = colors[(curr + 1) % colors.length];
3011
+ this.render();
3012
+ return;
3013
+ }
3014
+ if (key.name === "up" || key.name === "1") {
3015
+ this.state.speedMs = Math.max(10, this.state.speedMs - 10);
3016
+ return;
3017
+ }
3018
+ if (key.name === "down" || key.name === "2") {
3019
+ this.state.speedMs = Math.min(150, this.state.speedMs + 10);
3020
+ return;
3021
+ }
3022
+ }
3023
+ scheduleTick() {
3024
+ if (this.state.isPaused || this.state.showBriefing) return;
3025
+ this.loopTimer = setTimeout(() => {
3026
+ this.tick();
3027
+ this.scheduleTick();
3028
+ }, this.state.speedMs);
3029
+ }
3030
+ tick() {
3031
+ const { cols } = this.getDimensions();
3032
+ this.state.hashesGenerated += Math.max(8, Math.floor(cols / 10));
3033
+ if (this.config?.onAchievementUnlock) {
3034
+ const elapsedSec = (Date.now() - this.state.sessionStartMs) / 1e3;
3035
+ if (elapsedSec >= 10) {
3036
+ this.config.onAchievementUnlock("first_breach");
3037
+ }
3038
+ if (this.state.hashesGenerated >= 5e3) {
3039
+ this.config.onAchievementUnlock("hash_miner");
3040
+ }
3041
+ }
3042
+ if (this.config?.onScoreUpdate) {
3043
+ this.config.onScoreUpdate(this.state.hashesGenerated);
3044
+ }
3045
+ this.render();
3046
+ }
3047
+ colorize(str, level) {
3048
+ const s = this.state.colorScheme;
3049
+ if (s === "matrix-green") {
3050
+ if (level === "head") return chalk3.whiteBright.bold(str);
3051
+ if (level === "body") return chalk3.greenBright(str);
3052
+ if (level === "dim") return chalk3.green(str);
3053
+ return chalk3.hex("#106010")(str);
3054
+ }
3055
+ if (s === "cyber-neon") {
3056
+ if (level === "head") return chalk3.whiteBright.bold(str);
3057
+ if (level === "body") return chalk3.cyanBright(str);
3058
+ if (level === "dim") return chalk3.magentaBright(str);
3059
+ return chalk3.hex("#336699")(str);
3060
+ }
3061
+ if (s === "amber-crt") {
3062
+ if (level === "head") return chalk3.whiteBright.bold(str);
3063
+ if (level === "body") return chalk3.yellowBright(str);
3064
+ if (level === "dim") return chalk3.hex("#FFB000")(str);
3065
+ return chalk3.hex("#885500")(str);
3066
+ }
3067
+ if (s === "crimson-glitch") {
3068
+ if (level === "head") return chalk3.whiteBright.bold(str);
3069
+ if (level === "body") return chalk3.redBright(str);
3070
+ if (level === "dim") return chalk3.hex("#FF3366")(str);
3071
+ return chalk3.hex("#771122")(str);
3072
+ }
3073
+ if (level === "head") return chalk3.whiteBright.bold(str);
3074
+ if (level === "body") return chalk3.white(str);
3075
+ if (level === "dim") return chalk3.gray(str);
3076
+ return chalk3.hex("#333333")(str);
3077
+ }
3078
+ generateRandomHash(length) {
3079
+ const hex = "0123456789abcdef";
3080
+ let res = "";
3081
+ for (let i = 0; i < length; i++) {
3082
+ res += hex[this.rng.nextInt(0, 15)];
3083
+ }
3084
+ return res;
3085
+ }
3086
+ renderHashCascade(rows, cols) {
3087
+ const lines = [];
3088
+ const hashTypes = ["SHA-256", "KECCAK ", "BLAKE2b", "ECDSA ", "MD5-RAW", "RSA-SIG"];
3089
+ for (let r = 0; r < rows; r++) {
3090
+ const type = hashTypes[this.rng.nextInt(0, hashTypes.length - 1)];
3091
+ const nonce = "0x" + this.rng.nextInt(4096, 65535).toString(16).toUpperCase();
3092
+ const status = this.rng.next() > 0.3 ? "[OK]" : "[SYNC]";
3093
+ const prefix = ` ${this.colorize(type, "dim")} [${this.colorize(nonce, "accent")}] `;
3094
+ const suffix = ` ${this.colorize(status, "head")}`;
3095
+ const overheadLen = 22;
3096
+ const hashLen = Math.max(16, cols - overheadLen - 2);
3097
+ const hash = this.generateRandomHash(hashLen);
3098
+ lines.push(`${prefix}${this.colorize(hash, "body")}${suffix}`);
3099
+ }
3100
+ return lines;
3101
+ }
3102
+ renderHexDump(rows, cols) {
3103
+ const lines = [];
3104
+ const hexChars = "0123456789ABCDEF";
3105
+ const bytesPerLine = cols > 110 ? 32 : 16;
3106
+ for (let r = 0; r < rows; r++) {
3107
+ this.memoryAddress += bytesPerLine;
3108
+ const addr = "0x" + this.memoryAddress.toString(16).toUpperCase().padStart(8, "0");
3109
+ let hexBytes = "";
3110
+ let ascii = "";
3111
+ for (let b = 0; b < bytesPerLine; b++) {
3112
+ const val = this.rng.nextInt(0, 255);
3113
+ hexBytes += hexChars[val >> 4 & 15] + hexChars[val & 15] + " ";
3114
+ ascii += val >= 32 && val <= 126 ? String.fromCharCode(val) : ".";
3115
+ }
3116
+ const line = ` ${this.colorize(addr, "accent")}: ${this.colorize(hexBytes, "body")} ${this.colorize(`|${ascii}|`, "dim")}`;
3117
+ lines.push(line.slice(0, cols + 20));
3118
+ }
3119
+ return lines;
3120
+ }
3121
+ renderMatrixRain(rows, cols) {
3122
+ const grid = Array.from({ length: rows }, () => Array.from({ length: cols }, () => " "));
3123
+ for (const drop of this.rainDrops) {
3124
+ drop.y = (drop.y + drop.speed) % (rows + drop.length);
3125
+ if (this.rng.next() > 0.6) {
3126
+ drop.chars[0] = MATRIX_CHARS[this.rng.nextInt(0, MATRIX_CHARS.length - 1)];
3127
+ }
3128
+ for (let i = 0; i < drop.length; i++) {
3129
+ const py = Math.floor(drop.y) - i;
3130
+ if (py >= 0 && py < rows && drop.x < cols) {
3131
+ const char = drop.chars[i % drop.chars.length] || "X";
3132
+ if (i === 0) {
3133
+ grid[py][drop.x] = this.colorize(char, "head");
3134
+ } else if (i < 3) {
3135
+ grid[py][drop.x] = this.colorize(char, "body");
3136
+ } else if (i < 7) {
3137
+ grid[py][drop.x] = this.colorize(char, "dim");
3138
+ } else {
3139
+ grid[py][drop.x] = this.colorize(char, "accent");
3140
+ }
3141
+ }
3142
+ }
3143
+ }
3144
+ return grid.map((row) => row.join(""));
3145
+ }
3146
+ renderCipherBreach(rows, cols) {
3147
+ const lines = [];
3148
+ const keywords = [
3149
+ "ACCESS GRANTED // BYPASS PROTOCOL INITIALIZED",
3150
+ "AUTHENTICATING TERMINULL KERNEL CORE... [SUCCESS]",
3151
+ "DECRYPTING RSA-4096 ROOT CERTIFICATE: 0x88F02C41",
3152
+ "MEMORY OVERCLOCK: BUS BANDWIDTH 100% SATURATED",
3153
+ "QUANTUM HASH RESISTANCE MATRIX ENGAGED",
3154
+ "ZERO-DAY ENTROPY VECTOR NULLIFIED ACROSS ALL NODES"
3155
+ ];
3156
+ for (let r = 0; r < rows; r++) {
3157
+ if (r % 3 === 0) {
3158
+ const kw = keywords[Math.floor(r / 3) % keywords.length];
3159
+ lines.push(` ${this.colorize(">>>", "accent")} ${this.colorize(kw, "head")}`);
3160
+ } else {
3161
+ let gibberish = "";
3162
+ while (gibberish.length < cols - 8) {
3163
+ gibberish += MATRIX_CHARS[this.rng.nextInt(0, MATRIX_CHARS.length - 1)];
3164
+ }
3165
+ lines.push(` ${this.colorize(gibberish, "dim")}`);
3166
+ }
3167
+ }
3168
+ return lines;
3169
+ }
3170
+ render() {
3171
+ const { cols, rows } = this.getDimensions();
3172
+ const t = this.renderer.getTheme();
3173
+ if (this.state.showBriefing) {
3174
+ const boxWidth = Math.min(cols - 4, 72);
3175
+ const lines = [
3176
+ "",
3177
+ t.highlight("TERMINULL HACKER STREAM // PROTOCOL INITIALIZATION"),
3178
+ "",
3179
+ t.secondary("IMMERSION MODE:"),
3180
+ "All controls and UI borders are hidden during stream for 100% movie realism.",
3181
+ "The stream dynamically expands across your entire monitor resolution.",
3182
+ "",
3183
+ t.highlight("KEYBOARD CONTROLS (Memorize before starting):"),
3184
+ ` ${t.primary("[Ctrl+C]")} or ${t.primary("[Q]")} or ${t.primary("[Esc]")} Return to Game List`,
3185
+ ` ${t.primary("[Space]")} Freeze / Resume Stream`,
3186
+ ` ${t.primary("[M]")} Switch Mode (Rain, Hashes, Hex, Cipher)`,
3187
+ ` ${t.primary("[C]")} or ${t.primary("[T]")} Switch Color Palette`,
3188
+ ` ${t.primary("[\u2191]")} / ${t.primary("[\u2193]")} Adjust Speed (10ms - 150ms)`,
3189
+ "",
3190
+ t.border("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),
3191
+ ` ${t.success("Press [SPACE] or [ENTER] to begin full-screen immersion...")}`,
3192
+ ` ${t.muted("Press [Q] or [ESC] to return to Arcade Game List")}`
3193
+ ];
3194
+ const box = this.renderer.createBox(lines, boxWidth, "HACKER STREAM");
3195
+ const padTop = Math.max(1, Math.floor((rows - 20) / 2));
3196
+ this.renderer.clear();
3197
+ this.renderer.draw("\n".repeat(padTop) + box + "\n");
3198
+ return;
3199
+ }
3200
+ let bodyLines = [];
3201
+ if (this.state.mode === "hash-cascade") {
3202
+ bodyLines = this.renderHashCascade(rows, cols);
3203
+ } else if (this.state.mode === "matrix-rain") {
3204
+ bodyLines = this.renderMatrixRain(rows, cols);
3205
+ } else if (this.state.mode === "hex-dump") {
3206
+ bodyLines = this.renderHexDump(rows, cols);
3207
+ } else if (this.state.mode === "cipher-breach") {
3208
+ bodyLines = this.renderCipherBreach(rows, cols);
3209
+ }
3210
+ if (this.state.isPaused) {
3211
+ const pauseHud = ` [ STREAM PAUSED // SPACE: Resume \u2502 M: Mode \u2502 C: Color \u2502 Q: Return to Game List ] `;
3212
+ const midRow = Math.floor(rows / 2);
3213
+ const padLeft = Math.max(0, Math.floor((cols - pauseHud.length) / 2));
3214
+ bodyLines[midRow] = " ".repeat(padLeft) + chalk3.bgBlack.yellowBright.bold(pauseHud);
3215
+ }
3216
+ this.renderer.draw(bodyLines.join("\n"));
2822
3217
  }
2823
3218
  };
2824
3219
 
@@ -2846,11 +3241,16 @@ export {
2846
3241
  playTerminalBell,
2847
3242
  formatTime,
2848
3243
  clamp,
2849
- padCenter,
3244
+ stripAnsi,
3245
+ visibleLength,
3246
+ padRightVisible,
3247
+ wordWrap,
3248
+ playArcadeLoadingScreen,
2850
3249
  ArcadeMenu,
2851
3250
  DeterministicRNG,
2852
- NeonCircuitGame,
2853
- ByteRunnerGame,
2854
- PacketManGame
3251
+ PacketManGame,
3252
+ CyberViperGame,
3253
+ VoidInvadersGame,
3254
+ HashMatrixGame
2855
3255
  };
2856
- //# sourceMappingURL=chunk-5CMAXV4B.js.map
3256
+ //# sourceMappingURL=chunk-BIOTUQT7.js.map